Search in sources :

Example 1 with ReadableManufacturerFull

use of com.salesmanager.shop.model.catalog.manufacturer.ReadableManufacturerFull in project shopizer by shopizer-ecommerce.

the class ReadableManufacturerPopulator method populate.

@Override
public ReadableManufacturer populate(com.salesmanager.core.model.catalog.product.manufacturer.Manufacturer source, ReadableManufacturer target, MerchantStore store, Language language) throws ConversionException {
    if (language == null) {
        target = new ReadableManufacturerFull();
    }
    target.setOrder(source.getOrder());
    target.setId(source.getId());
    target.setCode(source.getCode());
    if (source.getDescriptions() != null && source.getDescriptions().size() > 0) {
        List<com.salesmanager.shop.model.catalog.manufacturer.ManufacturerDescription> fulldescriptions = new ArrayList<com.salesmanager.shop.model.catalog.manufacturer.ManufacturerDescription>();
        Set<ManufacturerDescription> descriptions = source.getDescriptions();
        ManufacturerDescription description = null;
        for (ManufacturerDescription desc : descriptions) {
            if (language != null && desc.getLanguage().getCode().equals(language.getCode())) {
                description = desc;
                break;
            } else {
                fulldescriptions.add(populateDescription(desc));
            }
        }
        if (description != null) {
            com.salesmanager.shop.model.catalog.manufacturer.ManufacturerDescription d = populateDescription(description);
            target.setDescription(d);
        }
        if (target instanceof ReadableManufacturerFull) {
            ((ReadableManufacturerFull) target).setDescriptions(fulldescriptions);
        }
    }
    return target;
}
Also used : ReadableManufacturerFull(com.salesmanager.shop.model.catalog.manufacturer.ReadableManufacturerFull) ArrayList(java.util.ArrayList) ManufacturerDescription(com.salesmanager.core.model.catalog.product.manufacturer.ManufacturerDescription)

Aggregations

ManufacturerDescription (com.salesmanager.core.model.catalog.product.manufacturer.ManufacturerDescription)1 ReadableManufacturerFull (com.salesmanager.shop.model.catalog.manufacturer.ReadableManufacturerFull)1 ArrayList (java.util.ArrayList)1