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;
}
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;
}
Aggregations