use of com.salesmanager.shop.model.catalog.manufacturer.ReadableManufacturerList in project shopizer by shopizer-ecommerce.
the class ManufacturerFacadeImpl method listByStore.
@Override
public ReadableManufacturerList listByStore(MerchantStore store, Language language, ListCriteria criteria, int page, int count) {
ReadableManufacturerList readableList = new ReadableManufacturerList();
try {
/**
* Is this a pageable request
*/
List<Manufacturer> manufacturers = null;
Page<Manufacturer> m = null;
if (language != null) {
m = manufacturerService.listByStore(store, language, criteria.getName(), page, count);
} else {
m = manufacturerService.listByStore(store, criteria.getName(), page, count);
}
manufacturers = m.getContent();
readableList.setTotalPages(m.getTotalPages());
readableList.setRecordsTotal(m.getTotalElements());
readableList.setNumber(m.getNumber());
ReadableManufacturerPopulator populator = new ReadableManufacturerPopulator();
List<ReadableManufacturer> returnList = new ArrayList<ReadableManufacturer>();
for (Manufacturer mf : manufacturers) {
ReadableManufacturer readableManufacturer = new ReadableManufacturer();
populator.populate(mf, readableManufacturer, store, language);
returnList.add(readableManufacturer);
}
readableList.setManufacturers(returnList);
return readableList;
} catch (Exception e) {
throw new ServiceRuntimeException("Error while get manufacturers", e);
}
}
use of com.salesmanager.shop.model.catalog.manufacturer.ReadableManufacturerList in project shopizer by shopizer-ecommerce.
the class ManufacturerFacadeImpl method getAllManufacturers.
@Override
public ReadableManufacturerList getAllManufacturers(MerchantStore store, Language language, ListCriteria criteria, int page, int count) {
ReadableManufacturerList readableList = new ReadableManufacturerList();
try {
/**
* Is this a pageable request
*/
List<Manufacturer> manufacturers = null;
if (page == 0 && count == 0) {
// need total count
int total = manufacturerService.count(store);
if (language != null) {
manufacturers = manufacturerService.listByStore(store, language);
} else {
manufacturers = manufacturerService.listByStore(store);
}
readableList.setRecordsTotal(total);
readableList.setNumber(manufacturers.size());
} else {
Page<Manufacturer> m = null;
if (language != null) {
m = manufacturerService.listByStore(store, language, criteria.getName(), page, count);
} else {
m = manufacturerService.listByStore(store, criteria.getName(), page, count);
}
manufacturers = m.getContent();
readableList.setTotalPages(m.getTotalPages());
readableList.setRecordsTotal(m.getTotalElements());
readableList.setNumber(m.getNumber());
}
ReadableManufacturerPopulator populator = new ReadableManufacturerPopulator();
List<ReadableManufacturer> returnList = new ArrayList<ReadableManufacturer>();
for (Manufacturer m : manufacturers) {
ReadableManufacturer readableManufacturer = new ReadableManufacturer();
populator.populate(m, readableManufacturer, store, language);
returnList.add(readableManufacturer);
}
readableList.setManufacturers(returnList);
return readableList;
} catch (Exception e) {
throw new ServiceRuntimeException("Error while get manufacturers", e);
}
}
Aggregations