use of com.salesmanager.shop.model.references.ReadableCountry in project shopizer by shopizer-ecommerce.
the class ShippingFacadeImpl method shipToCountry.
@Override
public List<ReadableCountry> shipToCountry(MerchantStore store, Language language) {
try {
List<Country> countries = shippingService.getShipToCountryList(store, language);
List<ReadableCountry> countryList = new ArrayList<ReadableCountry>();
if (!CollectionUtils.isEmpty(countries)) {
countryList = countries.stream().map(c -> {
try {
return convert(c, store, language);
} catch (ConversionException e) {
throw new ConversionRuntimeException("Error converting Country to readable country,e");
}
}).sorted(Comparator.comparing(ReadableCountry::getName)).collect(Collectors.toList());
}
return countryList;
} catch (Exception e) {
throw new ServiceRuntimeException("Error getting shipping country", e);
}
}
use of com.salesmanager.shop.model.references.ReadableCountry 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