Search in sources :

Example 1 with ReadableZone

use of com.salesmanager.shop.model.references.ReadableZone in project shopizer by shopizer-ecommerce.

the class ReadableZonePopulator method populate.

@Override
public ReadableZone populate(Zone source, ReadableZone target, MerchantStore store, Language language) throws ConversionException {
    if (target == null) {
        target = new ReadableZone();
    }
    target.setId(source.getId());
    target.setCode(source.getCode());
    target.setCountryCode(source.getCountry().getIsoCode());
    if (!CollectionUtils.isEmpty(source.getDescriptions())) {
        for (ZoneDescription d : source.getDescriptions()) {
            if (d.getLanguage().getId() == language.getId()) {
                target.setName(d.getName());
                continue;
            }
        }
    }
    return target;
}
Also used : ReadableZone(com.salesmanager.shop.model.references.ReadableZone) ZoneDescription(com.salesmanager.core.model.reference.zone.ZoneDescription)

Example 2 with ReadableZone

use of com.salesmanager.shop.model.references.ReadableZone in project shopizer by shopizer-ecommerce.

the class ReadableCountryPopulator method populate.

@Override
public ReadableCountry populate(Country source, ReadableCountry target, MerchantStore store, Language language) throws ConversionException {
    if (target == null) {
        target = new ReadableCountry();
    }
    target.setId(new Long(source.getId()));
    target.setCode(source.getIsoCode());
    target.setSupported(source.getSupported());
    if (!CollectionUtils.isEmpty(source.getDescriptions())) {
        target.setName(source.getDescriptions().iterator().next().getName());
    }
    if (!CollectionUtils.isEmpty(source.getZones())) {
        for (Zone z : source.getZones()) {
            ReadableZone readableZone = new ReadableZone();
            readableZone.setCountryCode(target.getCode());
            readableZone.setId(z.getId());
            if (!CollectionUtils.isEmpty(z.getDescriptions())) {
                for (ZoneDescription d : z.getDescriptions()) {
                    if (d.getLanguage().getId() == language.getId()) {
                        readableZone.setName(d.getName());
                        continue;
                    }
                }
            }
            target.getZones().add(readableZone);
        }
    }
    return target;
}
Also used : Zone(com.salesmanager.core.model.reference.zone.Zone) ReadableZone(com.salesmanager.shop.model.references.ReadableZone) ReadableZone(com.salesmanager.shop.model.references.ReadableZone) ReadableCountry(com.salesmanager.shop.model.references.ReadableCountry) ZoneDescription(com.salesmanager.core.model.reference.zone.ZoneDescription)

Aggregations

ZoneDescription (com.salesmanager.core.model.reference.zone.ZoneDescription)2 ReadableZone (com.salesmanager.shop.model.references.ReadableZone)2 Zone (com.salesmanager.core.model.reference.zone.Zone)1 ReadableCountry (com.salesmanager.shop.model.references.ReadableCountry)1