use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class StoreContactRESTController method store.
@RequestMapping(value = "/public/{store}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.ACCEPTED)
@ResponseBody
public AjaxResponse store(@PathVariable final String store, HttpServletRequest request, HttpServletResponse response) {
AjaxResponse ajaxResponse = new AjaxResponse();
try {
/**
* default routine *
*/
MerchantStore merchantStore = (MerchantStore) request.getAttribute(Constants.MERCHANT_STORE);
if (merchantStore != null) {
if (!merchantStore.getCode().equals(store)) {
merchantStore = null;
}
}
if (merchantStore == null) {
merchantStore = merchantStoreService.getByCode(store);
}
if (merchantStore == null) {
LOGGER.error("Merchant store is null for code " + store);
response.sendError(503, "Merchant store is null for code " + store);
return null;
}
Language language = merchantStore.getDefaultLanguage();
Map<String, Language> langs = languageService.getLanguagesMap();
return null;
} catch (Exception e) {
LOGGER.error("Error while saving category", e);
try {
response.sendError(503, "Error while saving category " + e.getMessage());
} catch (Exception ignore) {
}
return null;
}
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class PersistableUserPopulator method populate.
@Override
public User populate(PersistableUser source, User target, MerchantStore store, Language language) throws ConversionException {
Validate.notNull(source, "PersistableUser cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
if (target == null) {
target = new User();
}
target.setFirstName(source.getFirstName());
target.setLastName(source.getLastName());
target.setAdminEmail(source.getEmailAddress());
target.setAdminName(source.getUserName());
if (!StringUtils.isBlank(source.getPassword())) {
target.setAdminPassword(passwordEncoder.encode(source.getPassword()));
}
if (!StringUtils.isBlank(source.getStore())) {
try {
MerchantStore userStore = merchantStoreService.getByCode(source.getStore());
target.setMerchantStore(userStore);
} catch (ServiceException e) {
throw new ConversionException("Error while reading MerchantStore store [" + source.getStore() + "]", e);
}
} else {
target.setMerchantStore(store);
}
target.setActive(source.isActive());
Language lang = null;
try {
lang = languageService.getByCode(source.getDefaultLanguage());
} catch (Exception e) {
throw new ConversionException("Cannot get language [" + source.getDefaultLanguage() + "]", e);
}
// set default language
target.setDefaultLanguage(lang);
List<Group> userGroups = new ArrayList<Group>();
List<String> names = new ArrayList<String>();
for (PersistableGroup group : source.getGroups()) {
names.add(group.getName());
}
try {
List<Group> groups = groupService.listGroupByNames(names);
for (Group g : groups) {
userGroups.add(g);
}
} catch (Exception e1) {
throw new ConversionException("Error while getting user groups", e1);
}
target.setGroups(userGroups);
return target;
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method getReadableOrderHistory.
@Override
public List<ReadableOrderStatusHistory> getReadableOrderHistory(Long orderId, MerchantStore store, Language language) {
Order order = orderService.getOrder(orderId, store);
if (order == null) {
throw new ResourceNotFoundException("Order id [" + orderId + "] not found for merchand [" + store.getId() + "]");
}
Set<OrderStatusHistory> historyList = order.getOrderHistory();
List<ReadableOrderStatusHistory> returnList = historyList.stream().map(f -> mapToReadbleOrderStatusHistory(f)).collect(Collectors.toList());
return returnList;
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class ShippingConfigurationApi method shippingModules.
/**
* Get available shipping modules
*
* @param merchantStore
* @param language
* @return
*/
@GetMapping("/private/modules/shipping")
@ApiOperation(httpMethod = "GET", value = "List list of shipping modules", notes = "Requires administration access", produces = "application/json", response = List.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT") })
public List<IntegrationModuleSummaryEntity> shippingModules(@ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
try {
List<IntegrationModule> modules = shippingService.getShippingMethods(merchantStore);
// configured modules
Map<String, IntegrationConfiguration> configuredModules = shippingService.getShippingModulesConfigured(merchantStore);
return modules.stream().map(m -> integrationModule(m, configuredModules)).collect(Collectors.toList());
} catch (ServiceException e) {
LOGGER.error("Error getting shipping modules", e);
throw new ServiceRuntimeException("Error getting shipping modules", e);
}
}
use of com.salesmanager.core.model.reference.language.Language in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method getAllCustomerReviewsByReviewed.
@Override
public List<ReadableCustomerReview> getAllCustomerReviewsByReviewed(Long customerId, MerchantStore store, Language language) {
// customer exist
Customer customer = getCustomerById(customerId);
Validate.notNull(customer, "Reviewed customer cannot be null");
return customerReviewService.getByReviewedCustomer(customer).stream().map(customerReview -> convertCustomerReviewToReadableCustomerReview(customerReview, store, language)).collect(Collectors.toList());
}
Aggregations