All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.escalon.hypermedia.sample.store.OrderedItemAssembler Maven / Gradle / Ivy

There is a newer version: 0.4.2
Show newest version
package de.escalon.hypermedia.sample.store;

import de.escalon.hypermedia.sample.beans.store.OrderedItem;
import de.escalon.hypermedia.sample.model.store.OrderedItemModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import org.springframework.stereotype.Component;

/**
 * Assembles product as ordererdItem.
 *
 * Created by Dietrich on 02.11.2015.
 */
@Component
public class OrderedItemAssembler extends ResourceAssemblerSupport {


    @Autowired
    ProductAssembler productAssembler;

    public OrderedItemAssembler() {
        super(OrderedItemController.class, OrderedItem.class);
    }

    @Override
    public OrderedItem toResource(OrderedItemModel entity) {
        return createResourceWithId(entity.orderedItemId, entity);
    }

    @Override
    protected OrderedItem instantiateResource(OrderedItemModel entity) {
        OrderedItem orderedItem = super.instantiateResource(entity);
        orderedItem.setOrderedItem(productAssembler.toResource(entity.orderedItem));
        orderedItem.setOrderItemNumber(Integer.toString(entity.orderedItemId));
        return orderedItem;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy