public String getContainerConfigName() {
return "pos-container";
}
public void configure(ContainerConfig.Container cc) throws ContainerException {
XuiSession session = XuiContainer.getSession();
GenericValue productStore = null;
GenericValue facility = null;
// get the facility id
String facilityId = ContainerConfig.getPropertyValue(cc, "facility-id", null);
if (UtilValidate.isEmpty(facilityId)) {
throw new ContainerException("No facility-id value set in pos-container!");
} else {
try {
facility = session.getDelegator().findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId));
} catch (GenericEntityException e) {
throw new ContainerException("Invalid facilityId : " + facilityId);
}
}
// verify the facility exists
if (facility == null) {
throw new ContainerException("Invalid facility; facility ID not found [" + facilityId + "]");
}
session.setAttribute("facilityId", facilityId);
session.setAttribute("facility", facility);
// get the product store id
String productStoreId = facility.getString("productStoreId");
if (UtilValidate.isEmpty(productStoreId)) {
throw new ContainerException("No productStoreId set on facility [" + facilityId + "]!");
} else {
productStore = ProductStoreWorker.getProductStore(productStoreId, session.getDelegator());
if (productStore == null) {
throw new ContainerException("Invalid productStoreId : " + productStoreId);
}
}
session.setAttribute("productStoreId", productStoreId);
session.setAttribute("productStore", productStore);
// get the store locale
String localeStr = ContainerConfig.getPropertyValue(cc, "locale", null);
if (UtilValidate.isEmpty(localeStr)) {
localeStr = productStore.getString("defaultLocaleString");
}
if (UtilValidate.isEmpty(localeStr)) {
throw new ContainerException("Invalid Locale for POS!");
}
Locale locale = UtilMisc.parseLocale(localeStr);
session.setAttribute("locale", locale);
// get the store currency
String currencyStr = ContainerConfig.getPropertyValue(cc, "currency", null);
if (UtilValidate.isEmpty(currencyStr)) {
currencyStr = productStore.getString("defaultCurrencyUomId");
}
if (UtilValidate.isEmpty(currencyStr)) {
throw new ContainerException("Invalid Currency for POS!");
}
session.setAttribute("currency", currencyStr);
}