The rest of the generics markup, just in product/.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@712917 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -57,9 +57,9 @@ public class CatalogWorker {
|
||||
return WebSiteWorker.getWebSite(request);
|
||||
}
|
||||
|
||||
public static List getAllCatalogIds(ServletRequest request) {
|
||||
List catalogIds = FastList.newInstance();
|
||||
List catalogs = null;
|
||||
public static List<String> getAllCatalogIds(ServletRequest request) {
|
||||
List<String> catalogIds = FastList.newInstance();
|
||||
List<GenericValue> catalogs = null;
|
||||
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
|
||||
try {
|
||||
catalogs = delegator.findList("ProdCatalog", null, null, UtilMisc.toList("catalogName"), null, false);
|
||||
@@ -67,22 +67,22 @@ public class CatalogWorker {
|
||||
Debug.logError(e, "Error looking up all catalogs", module);
|
||||
}
|
||||
if (catalogs != null) {
|
||||
Iterator i = catalogs.iterator();
|
||||
Iterator<GenericValue> i = catalogs.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue c = (GenericValue) i.next();
|
||||
GenericValue c = i.next();
|
||||
catalogIds.add(c.getString("prodCatalogId"));
|
||||
}
|
||||
}
|
||||
return catalogIds;
|
||||
}
|
||||
|
||||
public static List getStoreCatalogs(ServletRequest request) {
|
||||
public static List<GenericValue> getStoreCatalogs(ServletRequest request) {
|
||||
String productStoreId = ProductStoreWorker.getProductStoreId(request);
|
||||
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
|
||||
return getStoreCatalogs(delegator, productStoreId);
|
||||
}
|
||||
|
||||
public static List getStoreCatalogs(GenericDelegator delegator, String productStoreId) {
|
||||
public static List<GenericValue> getStoreCatalogs(GenericDelegator delegator, String productStoreId) {
|
||||
try {
|
||||
return EntityUtil.filterByDate(delegator.findByAndCache("ProductStoreCatalog", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNum", "prodCatalogId")), true);
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -91,7 +91,7 @@ public class CatalogWorker {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List getPartyCatalogs(ServletRequest request) {
|
||||
public static List<GenericValue> getPartyCatalogs(ServletRequest request) {
|
||||
HttpSession session = ((HttpServletRequest) request).getSession();
|
||||
GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
|
||||
if (userLogin == null) userLogin = (GenericValue) session.getAttribute("autoUserLogin");
|
||||
@@ -102,7 +102,7 @@ public class CatalogWorker {
|
||||
return getPartyCatalogs(delegator, partyId);
|
||||
}
|
||||
|
||||
public static List getPartyCatalogs(GenericDelegator delegator, String partyId) {
|
||||
public static List<GenericValue> getPartyCatalogs(GenericDelegator delegator, String partyId) {
|
||||
if (delegator == null || partyId == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -115,14 +115,14 @@ public class CatalogWorker {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List getProdCatalogCategories(ServletRequest request, String prodCatalogId, String prodCatalogCategoryTypeId) {
|
||||
public static List<GenericValue> getProdCatalogCategories(ServletRequest request, String prodCatalogId, String prodCatalogCategoryTypeId) {
|
||||
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
|
||||
return getProdCatalogCategories(delegator, prodCatalogId, prodCatalogCategoryTypeId);
|
||||
}
|
||||
|
||||
public static List getProdCatalogCategories(GenericDelegator delegator, String prodCatalogId, String prodCatalogCategoryTypeId) {
|
||||
public static List<GenericValue> getProdCatalogCategories(GenericDelegator delegator, String prodCatalogId, String prodCatalogCategoryTypeId) {
|
||||
try {
|
||||
List prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAndCache("ProdCatalogCategory",
|
||||
List<GenericValue> prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAndCache("ProdCatalogCategory",
|
||||
UtilMisc.toMap("prodCatalogId", prodCatalogId),
|
||||
UtilMisc.toList("sequenceNum", "productCategoryId")), true);
|
||||
|
||||
@@ -145,7 +145,7 @@ public class CatalogWorker {
|
||||
*/
|
||||
public static String getCurrentCatalogId(ServletRequest request) {
|
||||
HttpSession session = ((HttpServletRequest) request).getSession();
|
||||
Map requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request);
|
||||
Map<String, Object> requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request);
|
||||
String prodCatalogId = null;
|
||||
boolean fromSession = false;
|
||||
|
||||
@@ -158,40 +158,40 @@ public class CatalogWorker {
|
||||
}
|
||||
// get it from the database
|
||||
if (prodCatalogId == null) {
|
||||
List catalogIds = getCatalogIdsAvailable(request);
|
||||
if (catalogIds != null && catalogIds.size() > 0) prodCatalogId = (String) catalogIds.get(0);
|
||||
List<String> catalogIds = getCatalogIdsAvailable(request);
|
||||
if (catalogIds != null && catalogIds.size() > 0) prodCatalogId = catalogIds.get(0);
|
||||
}
|
||||
|
||||
if (!fromSession) {
|
||||
if (Debug.verboseOn()) Debug.logVerbose("[CatalogWorker.getCurrentCatalogId] Setting new catalog name: " + prodCatalogId, module);
|
||||
session.setAttribute("CURRENT_CATALOG_ID", prodCatalogId);
|
||||
CategoryWorker.setTrail(request, FastList.newInstance());
|
||||
CategoryWorker.setTrail(request, FastList.<String>newInstance());
|
||||
}
|
||||
return prodCatalogId;
|
||||
}
|
||||
|
||||
public static List getCatalogIdsAvailable(ServletRequest request) {
|
||||
List partyCatalogs = getPartyCatalogs(request);
|
||||
List storeCatalogs = getStoreCatalogs(request);
|
||||
public static List<String> getCatalogIdsAvailable(ServletRequest request) {
|
||||
List<GenericValue> partyCatalogs = getPartyCatalogs(request);
|
||||
List<GenericValue> storeCatalogs = getStoreCatalogs(request);
|
||||
return getCatalogIdsAvailable(partyCatalogs, storeCatalogs);
|
||||
}
|
||||
|
||||
public static List getCatalogIdsAvailable(GenericDelegator delegator, String productStoreId, String partyId) {
|
||||
List storeCatalogs = getStoreCatalogs(delegator, productStoreId);
|
||||
List partyCatalogs = getPartyCatalogs(delegator, partyId);
|
||||
public static List<String> getCatalogIdsAvailable(GenericDelegator delegator, String productStoreId, String partyId) {
|
||||
List<GenericValue> storeCatalogs = getStoreCatalogs(delegator, productStoreId);
|
||||
List<GenericValue> partyCatalogs = getPartyCatalogs(delegator, partyId);
|
||||
return getCatalogIdsAvailable(partyCatalogs, storeCatalogs);
|
||||
}
|
||||
|
||||
public static List getCatalogIdsAvailable(List partyCatalogs, List storeCatalogs) {
|
||||
List categoryIds = FastList.newInstance();
|
||||
List allCatalogLinks = FastList.newInstance();
|
||||
public static List<String> getCatalogIdsAvailable(List<GenericValue> partyCatalogs, List<GenericValue> storeCatalogs) {
|
||||
List<String> categoryIds = FastList.newInstance();
|
||||
List<GenericValue> allCatalogLinks = FastList.newInstance();
|
||||
if (partyCatalogs != null) allCatalogLinks.addAll(partyCatalogs);
|
||||
if (storeCatalogs != null) allCatalogLinks.addAll(storeCatalogs);
|
||||
|
||||
if (allCatalogLinks.size() > 0) {
|
||||
Iterator aclIter = allCatalogLinks.iterator();
|
||||
Iterator<GenericValue> aclIter = allCatalogLinks.iterator();
|
||||
while (aclIter.hasNext()) {
|
||||
GenericValue catalogLink = (GenericValue) aclIter.next();
|
||||
GenericValue catalogLink = aclIter.next();
|
||||
categoryIds.add(catalogLink.getString("prodCatalogId"));
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class CatalogWorker {
|
||||
public static String getCatalogTopCategoryId(ServletRequest request, String prodCatalogId) {
|
||||
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
|
||||
|
||||
List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_BROWSE_ROOT");
|
||||
List<GenericValue> prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_BROWSE_ROOT");
|
||||
|
||||
if (UtilValidate.isNotEmpty(prodCatalogCategories)) {
|
||||
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
|
||||
@@ -281,7 +281,7 @@ public class CatalogWorker {
|
||||
public static String getCatalogSearchCategoryId(GenericDelegator delegator, String prodCatalogId) {
|
||||
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
|
||||
|
||||
List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_SEARCH");
|
||||
List<GenericValue> prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_SEARCH");
|
||||
if (UtilValidate.isNotEmpty(prodCatalogCategories)) {
|
||||
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
|
||||
return prodCatalogCategory.getString("productCategoryId");
|
||||
@@ -293,7 +293,7 @@ public class CatalogWorker {
|
||||
public static String getCatalogViewAllowCategoryId(GenericDelegator delegator, String prodCatalogId) {
|
||||
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
|
||||
|
||||
List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_VIEW_ALLW");
|
||||
List<GenericValue> prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_VIEW_ALLW");
|
||||
if (UtilValidate.isNotEmpty(prodCatalogCategories)) {
|
||||
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
|
||||
return prodCatalogCategory.getString("productCategoryId");
|
||||
@@ -305,7 +305,7 @@ public class CatalogWorker {
|
||||
public static String getCatalogPurchaseAllowCategoryId(GenericDelegator delegator, String prodCatalogId) {
|
||||
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
|
||||
|
||||
List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_PURCH_ALLW");
|
||||
List<GenericValue> prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_PURCH_ALLW");
|
||||
if (UtilValidate.isNotEmpty(prodCatalogCategories)) {
|
||||
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
|
||||
return prodCatalogCategory.getString("productCategoryId");
|
||||
@@ -321,7 +321,7 @@ public class CatalogWorker {
|
||||
public static String getCatalogPromotionsCategoryId(ServletRequest request, String prodCatalogId) {
|
||||
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
|
||||
|
||||
List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_PROMOTIONS");
|
||||
List<GenericValue> prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_PROMOTIONS");
|
||||
|
||||
if (UtilValidate.isNotEmpty(prodCatalogCategories)) {
|
||||
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
|
||||
@@ -359,7 +359,7 @@ public class CatalogWorker {
|
||||
public static String getCatalogQuickaddCategoryPrimary(ServletRequest request, String prodCatalogId) {
|
||||
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
|
||||
|
||||
List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD");
|
||||
List<GenericValue> prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD");
|
||||
|
||||
if (UtilValidate.isNotEmpty(prodCatalogCategories)) {
|
||||
GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories);
|
||||
@@ -370,22 +370,22 @@ public class CatalogWorker {
|
||||
}
|
||||
}
|
||||
|
||||
public static Collection getCatalogQuickaddCategories(ServletRequest request) {
|
||||
public static Collection<String> getCatalogQuickaddCategories(ServletRequest request) {
|
||||
return getCatalogQuickaddCategories(request, getCurrentCatalogId(request));
|
||||
}
|
||||
|
||||
public static Collection getCatalogQuickaddCategories(ServletRequest request, String prodCatalogId) {
|
||||
public static Collection<String> getCatalogQuickaddCategories(ServletRequest request, String prodCatalogId) {
|
||||
if (prodCatalogId == null || prodCatalogId.length() <= 0) return null;
|
||||
|
||||
Collection categoryIds = FastList.newInstance();
|
||||
Collection<String> categoryIds = FastList.newInstance();
|
||||
|
||||
Collection prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD");
|
||||
Collection<GenericValue> prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD");
|
||||
|
||||
if (UtilValidate.isNotEmpty(prodCatalogCategories)) {
|
||||
Iterator pccIter = prodCatalogCategories.iterator();
|
||||
Iterator<GenericValue> pccIter = prodCatalogCategories.iterator();
|
||||
|
||||
while (pccIter.hasNext()) {
|
||||
GenericValue prodCatalogCategory = (GenericValue) pccIter.next();
|
||||
GenericValue prodCatalogCategory = pccIter.next();
|
||||
|
||||
categoryIds.add(prodCatalogCategory.getString("productCategoryId"));
|
||||
}
|
||||
|
||||
@@ -139,12 +139,12 @@ public class CategoryContentWrapper implements ContentWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
List categoryContentList = delegator.findByAndCache("ProductCategoryContent", UtilMisc.toMap("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId), UtilMisc.toList("-fromDate"));
|
||||
List<GenericValue> categoryContentList = delegator.findByAndCache("ProductCategoryContent", UtilMisc.toMap("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId), UtilMisc.toList("-fromDate"));
|
||||
categoryContentList = EntityUtil.filterByDate(categoryContentList);
|
||||
GenericValue categoryContent = EntityUtil.getFirst(categoryContentList);
|
||||
if (categoryContent != null) {
|
||||
// when rendering the category content, always include the Product Category and ProductCategoryContent records that this comes from
|
||||
Map inContext = FastMap.newInstance();
|
||||
Map<String, Object> inContext = FastMap.newInstance();
|
||||
inContext.put("productCategory", productCategory);
|
||||
inContext.put("categoryContent", categoryContent);
|
||||
ContentWorker.renderContentAsText(dispatcher, delegator, categoryContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false);
|
||||
|
||||
@@ -28,6 +28,7 @@ import javolution.util.FastMap;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilDateTime;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilMisc;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
import org.ofbiz.entity.GenericDelegator;
|
||||
@@ -52,11 +53,11 @@ public class CategoryServices {
|
||||
|
||||
public static final String module = CategoryServices.class.getName();
|
||||
|
||||
public static Map getCategoryMembers(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> getCategoryMembers(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
String categoryId = (String) context.get("categoryId");
|
||||
GenericValue productCategory = null;
|
||||
List members = null;
|
||||
List<GenericValue> members = null;
|
||||
|
||||
try {
|
||||
productCategory = delegator.findByPrimaryKeyCache("ProductCategory", UtilMisc.toMap("productCategoryId", categoryId));
|
||||
@@ -67,13 +68,13 @@ public class CategoryServices {
|
||||
Debug.logError(e, errMsg, module);
|
||||
return ServiceUtil.returnError(errMsg);
|
||||
}
|
||||
Map result = ServiceUtil.returnSuccess();
|
||||
Map<String, Object> result = ServiceUtil.returnSuccess();
|
||||
result.put("category", productCategory);
|
||||
result.put("categoryMembers", members);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map getPreviousNextProducts(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> getPreviousNextProducts(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
String categoryId = (String) context.get("categoryId");
|
||||
String productId = (String) context.get("productId");
|
||||
@@ -84,12 +85,12 @@ public class CategoryServices {
|
||||
return ServiceUtil.returnError("Both Index and ProductID cannot be null.");
|
||||
}
|
||||
|
||||
List orderByFields = (List) context.get("orderByFields");
|
||||
List<String> orderByFields = UtilGenerics.checkList(context.get("orderByFields"));
|
||||
if (orderByFields == null) orderByFields = FastList.newInstance();
|
||||
String entityName = getCategoryFindEntityName(delegator, orderByFields);
|
||||
|
||||
GenericValue productCategory;
|
||||
List productCategoryMembers;
|
||||
List<GenericValue> productCategoryMembers;
|
||||
try {
|
||||
productCategory = delegator.findByPrimaryKeyCache("ProductCategory", UtilMisc.toMap("productCategoryId", categoryId));
|
||||
productCategoryMembers = delegator.findByAndCache(entityName, UtilMisc.toMap("productCategoryId", categoryId), orderByFields);
|
||||
@@ -104,9 +105,9 @@ public class CategoryServices {
|
||||
|
||||
|
||||
if (productId != null && index == null) {
|
||||
Iterator i = productCategoryMembers.iterator();
|
||||
Iterator<GenericValue> i = productCategoryMembers.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue v = (GenericValue) i.next();
|
||||
GenericValue v = i.next();
|
||||
if (v.getString("productId").equals(productId)) {
|
||||
index = Integer.valueOf(productCategoryMembers.indexOf(v));
|
||||
}
|
||||
@@ -118,31 +119,31 @@ public class CategoryServices {
|
||||
return ServiceUtil.returnSuccess("Product not found in the current category.");
|
||||
}
|
||||
|
||||
Map result = ServiceUtil.returnSuccess();
|
||||
Map<String, Object> result = ServiceUtil.returnSuccess();
|
||||
result.put("category", productCategory);
|
||||
|
||||
String previous = null;
|
||||
String next = null;
|
||||
|
||||
if (index.intValue() - 1 >= 0 && index.intValue() - 1 < productCategoryMembers.size()) {
|
||||
previous = ((GenericValue) productCategoryMembers.get(index.intValue() - 1)).getString("productId");
|
||||
previous = productCategoryMembers.get(index.intValue() - 1).getString("productId");
|
||||
result.put("previousProductId", previous);
|
||||
} else {
|
||||
previous = ((GenericValue) productCategoryMembers.get(productCategoryMembers.size() - 1)).getString("productId");
|
||||
previous = productCategoryMembers.get(productCategoryMembers.size() - 1).getString("productId");
|
||||
result.put("previousProductId", previous);
|
||||
}
|
||||
|
||||
if (index.intValue() + 1 < productCategoryMembers.size()) {
|
||||
next = ((GenericValue) productCategoryMembers.get(index.intValue() + 1)).getString("productId");
|
||||
next = productCategoryMembers.get(index.intValue() + 1).getString("productId");
|
||||
result.put("nextProductId", next);
|
||||
} else {
|
||||
next = ((GenericValue) productCategoryMembers.get(0)).getString("productId");
|
||||
next = productCategoryMembers.get(0).getString("productId");
|
||||
result.put("nextProductId", next);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String getCategoryFindEntityName(GenericDelegator delegator, List orderByFields) {
|
||||
private static String getCategoryFindEntityName(GenericDelegator delegator, List<String> orderByFields) {
|
||||
// allow orderByFields to contain fields from the Product entity, if there are such fields
|
||||
String entityName = "ProductCategoryMember";
|
||||
if (orderByFields == null) {
|
||||
@@ -155,10 +156,9 @@ public class CategoryServices {
|
||||
|
||||
ModelEntity productModel = delegator.getModelEntity("Product");
|
||||
ModelEntity productCategoryMemberModel = delegator.getModelEntity("ProductCategoryMember");
|
||||
Iterator orderByFieldIter = orderByFields.iterator();
|
||||
Iterator<String> orderByFieldIter = orderByFields.iterator();
|
||||
while (orderByFieldIter.hasNext()) {
|
||||
String orderByField = (String) orderByFieldIter.next();
|
||||
|
||||
String orderByField = orderByFieldIter.next();
|
||||
// Get the real field name from the order by field removing ascending/descending order
|
||||
if (UtilValidate.isNotEmpty(orderByField)) {
|
||||
int startPos = 0, endPos = orderByField.length();
|
||||
@@ -191,13 +191,13 @@ public class CategoryServices {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
public static Map getProductCategoryAndLimitedMembers(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> getProductCategoryAndLimitedMembers(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
String productCategoryId = (String) context.get("productCategoryId");
|
||||
boolean limitView = ((Boolean) context.get("limitView")).booleanValue();
|
||||
int defaultViewSize = ((Integer) context.get("defaultViewSize")).intValue();
|
||||
|
||||
List orderByFields = (List) context.get("orderByFields");
|
||||
List<String> orderByFields = UtilGenerics.checkList(context.get("orderByFields"));
|
||||
if (orderByFields == null) orderByFields = FastList.newInstance();
|
||||
String entityName = getCategoryFindEntityName(delegator, orderByFields);
|
||||
|
||||
@@ -252,7 +252,7 @@ public class CategoryServices {
|
||||
highIndex = 0;
|
||||
}
|
||||
|
||||
List productCategoryMembers = null;
|
||||
List<GenericValue> productCategoryMembers = null;
|
||||
if (productCategory != null) {
|
||||
try {
|
||||
if (useCacheForMembers) {
|
||||
@@ -281,7 +281,8 @@ public class CategoryServices {
|
||||
highIndex = listSize;
|
||||
}
|
||||
} else {
|
||||
List mainCondList = UtilMisc.toList(EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, productCategory.getString("productCategoryId")));
|
||||
List<EntityCondition> mainCondList = FastList.newInstance();
|
||||
mainCondList.add(EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, productCategory.getString("productCategoryId")));
|
||||
if (activeOnly) {
|
||||
mainCondList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp));
|
||||
mainCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, nowTimestamp)));
|
||||
@@ -302,7 +303,7 @@ public class CategoryServices {
|
||||
int chunkSize = 0;
|
||||
listSize = 0;
|
||||
|
||||
while ((nextValue = (GenericValue) pli.next()) != null) {
|
||||
while ((nextValue = pli.next()) != null) {
|
||||
String productId = nextValue.getString("productId");
|
||||
if (CategoryWorker.isProductInCategory(delegator, productId, viewProductCategoryId)) {
|
||||
if (listSize + 1 >= lowIndex && chunkSize < viewSize) {
|
||||
@@ -348,7 +349,7 @@ public class CategoryServices {
|
||||
}
|
||||
}
|
||||
|
||||
Map result = FastMap.newInstance();
|
||||
Map<String, Object> result = FastMap.newInstance();
|
||||
result.put("viewIndex", Integer.valueOf(viewIndex));
|
||||
result.put("viewSize", Integer.valueOf(viewSize));
|
||||
result.put("lowIndex", Integer.valueOf(lowIndex));
|
||||
|
||||
@@ -33,6 +33,7 @@ import javolution.util.FastList;
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilDateTime;
|
||||
import org.ofbiz.base.util.UtilFormatOut;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilHttp;
|
||||
import org.ofbiz.base.util.UtilMisc;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
@@ -90,18 +91,18 @@ public class CategoryWorker {
|
||||
|
||||
public static void getCategoriesWithNoParent(ServletRequest request, String attributeName) {
|
||||
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
|
||||
Collection results = FastList.newInstance();
|
||||
Collection<GenericValue> results = FastList.newInstance();
|
||||
|
||||
try {
|
||||
Collection allCategories = delegator.findList("ProductCategory", null, null, null, null, false);
|
||||
Collection<GenericValue> allCategories = delegator.findList("ProductCategory", null, null, null, null, false);
|
||||
|
||||
if (allCategories == null)
|
||||
return;
|
||||
Iterator aciter = allCategories.iterator();
|
||||
Iterator<GenericValue> aciter = allCategories.iterator();
|
||||
|
||||
while (aciter.hasNext()) {
|
||||
GenericValue curCat = (GenericValue) aciter.next();
|
||||
Collection parentCats = curCat.getRelatedCache("CurrentProductCategoryRollup");
|
||||
GenericValue curCat = aciter.next();
|
||||
Collection<GenericValue> parentCats = curCat.getRelatedCache("CurrentProductCategoryRollup");
|
||||
|
||||
if (parentCats == null || parentCats.size() <= 0)
|
||||
results.add(curCat);
|
||||
@@ -118,7 +119,7 @@ public class CategoryWorker {
|
||||
}
|
||||
|
||||
public static void getRelatedCategories(ServletRequest request, String attributeName, boolean limitView) {
|
||||
Map requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request);
|
||||
Map<String, Object> requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request);
|
||||
String requestId = null;
|
||||
|
||||
requestId = UtilFormatOut.checkNull((String)requestParameters.get("catalog_id"), (String)requestParameters.get("CATALOG_ID"),
|
||||
@@ -140,32 +141,32 @@ public class CategoryWorker {
|
||||
}
|
||||
|
||||
public static void getRelatedCategories(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty) {
|
||||
List categories = getRelatedCategoriesRet(request, attributeName, parentId, limitView, excludeEmpty);
|
||||
List<GenericValue> categories = getRelatedCategoriesRet(request, attributeName, parentId, limitView, excludeEmpty);
|
||||
|
||||
if (categories.size() > 0)
|
||||
request.setAttribute(attributeName, categories);
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
public static List getRelatedCategoriesRet(PageContext pageContext, String attributeName, String parentId, boolean limitView) {
|
||||
public static List<GenericValue> getRelatedCategoriesRet(PageContext pageContext, String attributeName, String parentId, boolean limitView) {
|
||||
return getRelatedCategoriesRet(pageContext.getRequest(), attributeName, parentId, limitView);
|
||||
}
|
||||
|
||||
public static List getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView) {
|
||||
public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView) {
|
||||
return getRelatedCategoriesRet(request, attributeName, parentId, limitView, false);
|
||||
}
|
||||
|
||||
public static List getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty) {
|
||||
public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty) {
|
||||
return getRelatedCategoriesRet(request, attributeName, parentId, limitView, excludeEmpty, false);
|
||||
}
|
||||
|
||||
public static List getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty, boolean recursive) {
|
||||
List categories = FastList.newInstance();
|
||||
public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty, boolean recursive) {
|
||||
List<GenericValue> categories = FastList.newInstance();
|
||||
|
||||
if (Debug.verboseOn()) Debug.logVerbose("[CategoryWorker.getRelatedCategories] ParentID: " + parentId, module);
|
||||
|
||||
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
|
||||
List rollups = null;
|
||||
List<GenericValue> rollups = null;
|
||||
|
||||
try {
|
||||
rollups = delegator.findByAndCache("ProductCategoryRollup",
|
||||
@@ -180,10 +181,10 @@ public class CategoryWorker {
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(rollups)) {
|
||||
// Debug.log("Rollup size: " + rollups.size(), module);
|
||||
Iterator ri = rollups.iterator();
|
||||
Iterator<GenericValue> ri = rollups.iterator();
|
||||
|
||||
while (ri.hasNext()) {
|
||||
GenericValue parent = (GenericValue) ri.next();
|
||||
GenericValue parent = ri.next();
|
||||
// Debug.log("Adding child of: " + parent.getString("parentProductCategoryId"), module);
|
||||
GenericValue cv = null;
|
||||
|
||||
@@ -258,12 +259,12 @@ public class CategoryWorker {
|
||||
}
|
||||
|
||||
private static EntityCondition buildCountCondition(String fieldName, String fieldValue) {
|
||||
List orCondList = FastList.newInstance();
|
||||
List<EntityCondition> orCondList = FastList.newInstance();
|
||||
orCondList.add(EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp()));
|
||||
orCondList.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null));
|
||||
EntityCondition orCond = EntityCondition.makeCondition(orCondList, EntityOperator.OR);
|
||||
|
||||
List andCondList = FastList.newInstance();
|
||||
List<EntityCondition> andCondList = FastList.newInstance();
|
||||
andCondList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, UtilDateTime.nowTimestamp()));
|
||||
andCondList.add(EntityCondition.makeCondition(fieldName, EntityOperator.EQUALS, fieldValue));
|
||||
andCondList.add(orCond);
|
||||
@@ -278,7 +279,7 @@ public class CategoryWorker {
|
||||
}
|
||||
|
||||
public static void setTrail(ServletRequest request, String currentCategory) {
|
||||
Map requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request);
|
||||
Map<String, Object> requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request);
|
||||
String previousCategory = (String) requestParameters.get("pcategory");
|
||||
|
||||
if (Debug.verboseOn()) Debug.logVerbose("[CategoryWorker.setTrail] Start: previousCategory=" + previousCategory +
|
||||
@@ -289,7 +290,7 @@ public class CategoryWorker {
|
||||
return;
|
||||
|
||||
// always get the last crumb list
|
||||
List crumb = getTrail(request);
|
||||
List<String> crumb = getTrail(request);
|
||||
|
||||
if (crumb == null) {
|
||||
crumb = FastList.newInstance();
|
||||
@@ -303,7 +304,7 @@ public class CategoryWorker {
|
||||
|
||||
if (cindex < (crumb.size() - 1)) {
|
||||
for (int i = crumb.size() - 1; i > cindex; i--) {
|
||||
String deadCat = (String) crumb.remove(i);
|
||||
String deadCat = crumb.remove(i);
|
||||
|
||||
if (Debug.infoOn()) Debug.logInfo("[CategoryWorker.setTrail] Removed after current category index: " + i +
|
||||
" catname: " + deadCat, module);
|
||||
@@ -336,7 +337,7 @@ public class CategoryWorker {
|
||||
|
||||
if (index < (crumb.size() - 1)) {
|
||||
for (int i = crumb.size() - 1; i > index; i--) {
|
||||
String deadCat = (String) crumb.remove(i);
|
||||
String deadCat = crumb.remove(i);
|
||||
|
||||
if (Debug.infoOn()) Debug.logInfo("[CategoryWorker.setTrail] Removed after previous category index: " + i +
|
||||
" catname: " + deadCat, module);
|
||||
@@ -351,22 +352,22 @@ public class CategoryWorker {
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
public static List getTrail(PageContext pageContext) {
|
||||
public static List<String> getTrail(PageContext pageContext) {
|
||||
return getTrail(pageContext.getRequest());
|
||||
}
|
||||
|
||||
public static List getTrail(ServletRequest request) {
|
||||
public static List<String> getTrail(ServletRequest request) {
|
||||
HttpSession session = ((HttpServletRequest) request).getSession();
|
||||
List crumb = (List) session.getAttribute("_BREAD_CRUMB_TRAIL_");
|
||||
List<String> crumb = UtilGenerics.checkList(session.getAttribute("_BREAD_CRUMB_TRAIL_"));
|
||||
return crumb;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
public static List setTrail(PageContext pageContext, List crumb) {
|
||||
public static List<String> setTrail(PageContext pageContext, List<String> crumb) {
|
||||
return setTrail(pageContext.getRequest(), crumb);
|
||||
}
|
||||
|
||||
public static List setTrail(ServletRequest request, List crumb) {
|
||||
public static List<String> setTrail(ServletRequest request, List<String> crumb) {
|
||||
HttpSession session = ((HttpServletRequest) request).getSession();
|
||||
session.setAttribute("_BREAD_CRUMB_TRAIL_", crumb);
|
||||
return crumb;
|
||||
@@ -378,7 +379,7 @@ public class CategoryWorker {
|
||||
}
|
||||
|
||||
public static boolean checkTrailItem(ServletRequest request, String category) {
|
||||
List crumb = getTrail(request);
|
||||
List<String> crumb = getTrail(request);
|
||||
|
||||
if (crumb != null && crumb.contains(category))
|
||||
return true;
|
||||
@@ -392,10 +393,10 @@ public class CategoryWorker {
|
||||
}
|
||||
|
||||
public static String lastTrailItem(ServletRequest request) {
|
||||
List crumb = getTrail(request);
|
||||
List<String> crumb = getTrail(request);
|
||||
|
||||
if (UtilValidate.isNotEmpty(crumb)) {
|
||||
return (String) crumb.get(crumb.size() - 1);
|
||||
return crumb.get(crumb.size() - 1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -405,17 +406,17 @@ public class CategoryWorker {
|
||||
if (productCategoryId == null) return false;
|
||||
if (productId == null || productId.length() == 0) return false;
|
||||
|
||||
List productCategoryMembers = EntityUtil.filterByDate(delegator.findByAndCache("ProductCategoryMember",
|
||||
List<GenericValue> productCategoryMembers = EntityUtil.filterByDate(delegator.findByAndCache("ProductCategoryMember",
|
||||
UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId)), true);
|
||||
if (productCategoryMembers == null || productCategoryMembers.size() == 0) {
|
||||
//before giving up see if this is a variant product, and if so look up the virtual product and check it...
|
||||
GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));
|
||||
List productAssocs = ProductWorker.getVariantVirtualAssocs(product);
|
||||
List<GenericValue> productAssocs = ProductWorker.getVariantVirtualAssocs(product);
|
||||
//this does take into account that a product could be a variant of multiple products, but this shouldn't ever really happen...
|
||||
if (UtilValidate.isNotEmpty(productAssocs)) {
|
||||
Iterator pasIter = productAssocs.iterator();
|
||||
Iterator<GenericValue> pasIter = productAssocs.iterator();
|
||||
while (pasIter.hasNext()) {
|
||||
GenericValue productAssoc = (GenericValue) pasIter.next();
|
||||
GenericValue productAssoc = pasIter.next();
|
||||
if (isProductInCategory(delegator, productAssoc.getString("productId"), productCategoryId)) {
|
||||
return true;
|
||||
}
|
||||
@@ -428,19 +429,19 @@ public class CategoryWorker {
|
||||
}
|
||||
}
|
||||
|
||||
public static List filterProductsInCategory(GenericDelegator delegator, List valueObjects, String productCategoryId) throws GenericEntityException {
|
||||
public static List<GenericValue> filterProductsInCategory(GenericDelegator delegator, List<GenericValue> valueObjects, String productCategoryId) throws GenericEntityException {
|
||||
return filterProductsInCategory(delegator, valueObjects, productCategoryId, "productId");
|
||||
}
|
||||
|
||||
public static List filterProductsInCategory(GenericDelegator delegator, List valueObjects, String productCategoryId, String productIdFieldName) throws GenericEntityException {
|
||||
List newList = FastList.newInstance();
|
||||
public static List<GenericValue> filterProductsInCategory(GenericDelegator delegator, List<GenericValue> valueObjects, String productCategoryId, String productIdFieldName) throws GenericEntityException {
|
||||
List<GenericValue> newList = FastList.newInstance();
|
||||
|
||||
if (productCategoryId == null) return newList;
|
||||
if (valueObjects == null) return null;
|
||||
|
||||
Iterator valIter = valueObjects.iterator();
|
||||
Iterator<GenericValue> valIter = valueObjects.iterator();
|
||||
while (valIter.hasNext()) {
|
||||
GenericValue curValue = (GenericValue) valIter.next();
|
||||
GenericValue curValue = valIter.next();
|
||||
String productId = curValue.getString(productIdFieldName);
|
||||
if (isProductInCategory(delegator, productId, productCategoryId)) {
|
||||
newList.add(curValue);
|
||||
@@ -449,13 +450,13 @@ public class CategoryWorker {
|
||||
return newList;
|
||||
}
|
||||
|
||||
public static void getCategoryContentWrappers(Map catContentWrappers, List categoryList, HttpServletRequest request) throws GenericEntityException {
|
||||
public static void getCategoryContentWrappers(Map<String, CategoryContentWrapper> catContentWrappers, List<GenericValue> categoryList, HttpServletRequest request) throws GenericEntityException {
|
||||
if (catContentWrappers == null || categoryList == null) {
|
||||
return;
|
||||
}
|
||||
Iterator catIterator = categoryList.iterator();
|
||||
while(catIterator.hasNext()) {
|
||||
GenericValue cat = (GenericValue) catIterator.next();
|
||||
Iterator<GenericValue> catIterator = categoryList.iterator();
|
||||
while (catIterator.hasNext()) {
|
||||
GenericValue cat = catIterator.next();
|
||||
String productCategoryId = (String) cat.get("productCategoryId");
|
||||
|
||||
if (catContentWrappers.containsKey(productCategoryId)) {
|
||||
@@ -465,8 +466,7 @@ public class CategoryWorker {
|
||||
|
||||
CategoryContentWrapper catContentWrapper = new CategoryContentWrapper(cat, request);
|
||||
catContentWrappers.put(productCategoryId, catContentWrapper);
|
||||
List subCat = FastList.newInstance();
|
||||
subCat = getRelatedCategoriesRet(request, "subCatList", productCategoryId, true);
|
||||
List<GenericValue> subCat = getRelatedCategoriesRet(request, "subCatList", productCategoryId, true);
|
||||
if(subCat != null) {
|
||||
getCategoryContentWrappers(catContentWrappers, subCat, request );
|
||||
}
|
||||
|
||||
+2
-2
@@ -134,12 +134,12 @@ public class ProductConfigItemContentWrapper implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
List productConfigItemContentList = delegator.findByAndCache("ProdConfItemContent", UtilMisc.toMap("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId), UtilMisc.toList("-fromDate"));
|
||||
List<GenericValue> productConfigItemContentList = delegator.findByAndCache("ProdConfItemContent", UtilMisc.toMap("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId), UtilMisc.toList("-fromDate"));
|
||||
productConfigItemContentList = EntityUtil.filterByDate(productConfigItemContentList);
|
||||
GenericValue productConfigItemContent = EntityUtil.getFirst(productConfigItemContentList);
|
||||
if (productConfigItemContent != null) {
|
||||
// when rendering the product config item content, always include the ProductConfigItem and ProdConfItemContent records that this comes from
|
||||
Map inContext = FastMap.newInstance();
|
||||
Map<String, Object> inContext = FastMap.newInstance();
|
||||
inContext.put("productConfigItem", productConfigItem);
|
||||
inContext.put("productConfigItemContent", productConfigItemContent);
|
||||
ContentWorker.renderContentAsText(dispatcher, delegator, productConfigItemContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ProductConfigWorker {
|
||||
public static final String resource = "ProductUiLabels";
|
||||
public static final String SEPARATOR = "::"; // cache key separator
|
||||
|
||||
public static UtilCache productConfigCache = new UtilCache("product.config", true); // use soft reference to free up memory if needed
|
||||
public static UtilCache<String, ProductConfigWrapper> productConfigCache = new UtilCache<String, ProductConfigWrapper>("product.config", true); // use soft reference to free up memory if needed
|
||||
|
||||
public static ProductConfigWrapper getProductConfigWrapper(String productId, String currencyUomId, HttpServletRequest request) {
|
||||
ProductConfigWrapper configWrapper = null;
|
||||
@@ -72,7 +72,7 @@ public class ProductConfigWorker {
|
||||
autoUserLogin);
|
||||
productConfigCache.put(cacheKey, new ProductConfigWrapper(configWrapper));
|
||||
} else {
|
||||
configWrapper = new ProductConfigWrapper((ProductConfigWrapper)productConfigCache.get(cacheKey));
|
||||
configWrapper = new ProductConfigWrapper(productConfigCache.get(cacheKey));
|
||||
}
|
||||
} catch(ProductConfigWrapperException we) {
|
||||
configWrapper = null;
|
||||
@@ -85,11 +85,11 @@ public class ProductConfigWorker {
|
||||
public static void fillProductConfigWrapper(ProductConfigWrapper configWrapper, HttpServletRequest request) {
|
||||
int numOfQuestions = configWrapper.getQuestions().size();
|
||||
for (int k = 0; k < numOfQuestions; k++) {
|
||||
String[] opts = request.getParameterValues("" + k);
|
||||
String[] opts = request.getParameterValues(Integer.toString(k));
|
||||
if (opts == null) {
|
||||
|
||||
// check for standard item comments
|
||||
ProductConfigWrapper.ConfigItem question = (ProductConfigWrapper.ConfigItem) configWrapper.getQuestions().get(k);
|
||||
ProductConfigWrapper.ConfigItem question = configWrapper.getQuestions().get(k);
|
||||
if (question.isStandard()) {
|
||||
int i = 0;
|
||||
while (i <= (question.getOptions().size() -1)) {
|
||||
@@ -123,10 +123,10 @@ public class ProductConfigWorker {
|
||||
|
||||
// set selected variant products
|
||||
if (UtilValidate.isNotEmpty(option) && (option.hasVirtualComponent())) {
|
||||
List components = option.getComponents();
|
||||
List<GenericValue> components = option.getComponents();
|
||||
int variantIndex = 0;
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
GenericValue component = (GenericValue)components.get(i);
|
||||
GenericValue component = components.get(i);
|
||||
if (option.isVirtualComponent(component)) {
|
||||
String productParamName = "add_product_id" + k + "_" + cnt + "_" + variantIndex;
|
||||
String selectedProdcutId = request.getParameter(productParamName);
|
||||
@@ -138,7 +138,7 @@ public class ProductConfigWorker {
|
||||
if (ProductWorker.isVirtual((GenericDelegator)request.getAttribute("delegator"), selectedProdcutId)) {
|
||||
if ("VV_FEATURETREE".equals(ProductWorker.getProductvirtualVariantMethod((GenericDelegator)request.getAttribute("delegator"), selectedProdcutId))) {
|
||||
// get the selected features
|
||||
List <String> selectedFeatures = FastList.newInstance();
|
||||
List<String> selectedFeatures = FastList.newInstance();
|
||||
Enumeration paramNames = request.getParameterNames();
|
||||
while(paramNames.hasMoreElements()) {
|
||||
String paramName = (String)paramNames.nextElement();
|
||||
@@ -183,21 +183,21 @@ public class ProductConfigWorker {
|
||||
public static void storeProductConfigWrapper(ProductConfigWrapper configWrapper, GenericDelegator delegator) {
|
||||
if (configWrapper == null || (!configWrapper.isCompleted())) return;
|
||||
String configId = null;
|
||||
List questions = configWrapper.getQuestions();
|
||||
List configsToCheck = FastList.newInstance();
|
||||
List<ConfigItem> questions = configWrapper.getQuestions();
|
||||
List<GenericValue> configsToCheck = FastList.newInstance();
|
||||
int selectedOptionSize = 0;
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
String configItemId = null;
|
||||
Long sequenceNum = null;
|
||||
List <ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance();
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
List options = ci.getOptions();
|
||||
List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance();
|
||||
ConfigItem ci = questions.get(i);
|
||||
List<ConfigOption> options = ci.getOptions();
|
||||
if (ci.isStandard()) {
|
||||
selectedOptions.addAll(options);
|
||||
} else {
|
||||
Iterator availOptions = options.iterator();
|
||||
Iterator<ConfigOption> availOptions = options.iterator();
|
||||
while (availOptions.hasNext()) {
|
||||
ConfigOption oneOption = (ConfigOption)availOptions.next();
|
||||
ConfigOption oneOption = availOptions.next();
|
||||
if (oneOption.isSelected()) {
|
||||
selectedOptions.add(oneOption);
|
||||
}
|
||||
@@ -209,13 +209,13 @@ public class ProductConfigWorker {
|
||||
configItemId = ci.getConfigItemAssoc().getString("configItemId");
|
||||
sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum");
|
||||
try {
|
||||
List <GenericValue> configs = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configItemId",configItemId,"sequenceNum", sequenceNum));
|
||||
Iterator <GenericValue> configIt = configs.iterator();
|
||||
List<GenericValue> configs = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configItemId",configItemId,"sequenceNum", sequenceNum));
|
||||
Iterator<GenericValue> configIt = configs.iterator();
|
||||
while (configIt.hasNext()) {
|
||||
GenericValue productConfigConfig = configIt.next();
|
||||
Iterator selOpIt = selectedOptions.iterator();
|
||||
Iterator<ConfigOption> selOpIt = selectedOptions.iterator();
|
||||
while (selOpIt.hasNext()) {
|
||||
ConfigOption oneOption = (ConfigOption)selOpIt.next();
|
||||
ConfigOption oneOption = selOpIt.next();
|
||||
String configOptionId = oneOption.configOption.getString("configOptionId");
|
||||
if (productConfigConfig.getString("configOptionId").equals(configOptionId)) {
|
||||
String comments = oneOption.getComments() != null ? oneOption.getComments() : "";
|
||||
@@ -233,12 +233,12 @@ public class ProductConfigWorker {
|
||||
}
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(configsToCheck)) {
|
||||
Iterator <GenericValue> ctci = configsToCheck.iterator();
|
||||
Iterator<GenericValue> ctci = configsToCheck.iterator();
|
||||
while (ctci.hasNext()) {
|
||||
GenericValue productConfigConfig = ctci.next();
|
||||
String tempConfigId = productConfigConfig.getString("configId");
|
||||
try {
|
||||
List tempResult = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId",tempConfigId));
|
||||
List<GenericValue> tempResult = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId",tempConfigId));
|
||||
if (tempResult.size() == selectedOptionSize && configsToCheck.containsAll(tempResult)) {
|
||||
List<GenericValue> configOptionProductOptions = delegator.findByAnd("ConfigOptionProductOption", UtilMisc.toMap("configId",tempConfigId));
|
||||
if (UtilValidate.isNotEmpty(configOptionProductOptions)) {
|
||||
@@ -247,15 +247,15 @@ public class ProductConfigWorker {
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
String configItemId = null;
|
||||
Long sequenceNum = null;
|
||||
List <ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance();
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
List options = ci.getOptions();
|
||||
List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance();
|
||||
ConfigItem ci = questions.get(i);
|
||||
List<ConfigOption> options = ci.getOptions();
|
||||
if (ci.isStandard()) {
|
||||
selectedOptions.addAll(options);
|
||||
} else {
|
||||
Iterator availOptions = options.iterator();
|
||||
Iterator<ConfigOption> availOptions = options.iterator();
|
||||
while (availOptions.hasNext()) {
|
||||
ConfigOption oneOption = (ConfigOption)availOptions.next();
|
||||
ConfigOption oneOption = availOptions.next();
|
||||
if (oneOption.isSelected()) {
|
||||
selectedOptions.add(oneOption);
|
||||
}
|
||||
@@ -268,9 +268,9 @@ public class ProductConfigWorker {
|
||||
List<GenericValue> components = anOption.getComponents();
|
||||
for (GenericValue aComponent : components) {
|
||||
if (anOption.isVirtualComponent(aComponent)) {
|
||||
Map componentOptions = anOption.getComponentOptions();
|
||||
Map<String, String> componentOptions = anOption.getComponentOptions();
|
||||
String optionProductId = aComponent.getString("productId");
|
||||
String optionProductOptionId = (String)componentOptions.get(optionProductId);
|
||||
String optionProductOptionId = componentOptions.get(optionProductId);
|
||||
String configOptionId = anOption.configOption.getString("configOptionId");
|
||||
configItemId = ci.getConfigItemAssoc().getString("configItemId");
|
||||
sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum");
|
||||
@@ -316,15 +316,15 @@ public class ProductConfigWorker {
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
String configItemId = null;
|
||||
Long sequenceNum = null;
|
||||
List <ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance();
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
List options = ci.getOptions();
|
||||
List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance();
|
||||
ConfigItem ci = questions.get(i);
|
||||
List<ConfigOption> options = ci.getOptions();
|
||||
if (ci.isStandard()) {
|
||||
selectedOptions.addAll(options);
|
||||
} else {
|
||||
Iterator availOptions = options.iterator();
|
||||
Iterator<ConfigOption> availOptions = options.iterator();
|
||||
while (availOptions.hasNext()) {
|
||||
ConfigOption oneOption = (ConfigOption)availOptions.next();
|
||||
ConfigOption oneOption = availOptions.next();
|
||||
if (oneOption.isSelected()) {
|
||||
selectedOptions.add(oneOption);
|
||||
}
|
||||
@@ -339,10 +339,10 @@ public class ProductConfigWorker {
|
||||
}
|
||||
configItemId = ci.getConfigItemAssoc().getString("configItemId");
|
||||
sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum");
|
||||
Iterator selOpIt = selectedOptions.iterator();
|
||||
Iterator<ConfigOption> selOpIt = selectedOptions.iterator();
|
||||
while (selOpIt.hasNext()) {
|
||||
List toBeStored = FastList.newInstance();
|
||||
ConfigOption oneOption = (ConfigOption)selOpIt.next();
|
||||
List<GenericValue> toBeStored = FastList.newInstance();
|
||||
ConfigOption oneOption = selOpIt.next();
|
||||
String configOptionId = oneOption.configOption.getString("configOptionId");
|
||||
String description = oneOption.getComments();
|
||||
GenericValue productConfigConfig = delegator.makeValue("ProductConfigConfig");
|
||||
@@ -354,9 +354,9 @@ public class ProductConfigWorker {
|
||||
toBeStored.add(productConfigConfig);
|
||||
|
||||
if (oneOption.hasVirtualComponent()) {
|
||||
List components = oneOption.getComponents();
|
||||
List<GenericValue> components = oneOption.getComponents();
|
||||
for (int j = 0; j < components.size(); j++) {
|
||||
GenericValue component = (GenericValue)components.get(j);
|
||||
GenericValue component = (GenericValue)components.get(j);
|
||||
if (oneOption.isVirtualComponent(component)) {
|
||||
String componentOption = (String)oneOption.componentOptions.get(component.getString("productId"));
|
||||
GenericValue configOptionProductOption = delegator.makeValue("ConfigOptionProductOption");
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
protected double basePrice = 0.0;
|
||||
protected double defaultPrice = 0.0;
|
||||
protected String configId = null; // Id of persisted ProductConfigWrapper
|
||||
protected List questions = null; // ProductConfigs
|
||||
protected List<ConfigItem> questions = null; // ProductConfigs
|
||||
|
||||
/** Creates a new instance of ProductConfigWrapper */
|
||||
public ProductConfigWrapper() {
|
||||
@@ -83,7 +83,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
delegator = pcw.delegator;
|
||||
autoUserLogin = pcw.autoUserLogin;
|
||||
for (int i = 0; i < pcw.questions.size(); i++) {
|
||||
questions.add(new ConfigItem((ConfigItem)pcw.questions.get(i)));
|
||||
questions.add(new ConfigItem(pcw.questions.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,22 +101,21 @@ public class ProductConfigWrapper implements Serializable {
|
||||
this.autoUserLogin = autoUserLogin;
|
||||
|
||||
// get the base price
|
||||
Map priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId, "productStoreId", productStoreId,
|
||||
Map<String, Object> priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId, "productStoreId", productStoreId,
|
||||
"currencyUomId", currencyUomId, "autoUserLogin", autoUserLogin);
|
||||
Map priceMap = dispatcher.runSync("calculateProductPrice", priceContext);
|
||||
Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", priceContext);
|
||||
Double price = (Double)priceMap.get("price");
|
||||
if (price != null) {
|
||||
basePrice = price.doubleValue();
|
||||
}
|
||||
questions = FastList.newInstance();
|
||||
List questionsValues = FastList.newInstance();
|
||||
if (product.getString("productTypeId") != null && product.getString("productTypeId").equals("AGGREGATED")) {
|
||||
questionsValues = delegator.findByAnd("ProductConfig", UtilMisc.toMap("productId", productId), UtilMisc.toList("sequenceNum"));
|
||||
List<GenericValue> questionsValues = delegator.findByAnd("ProductConfig", UtilMisc.toMap("productId", productId), UtilMisc.toList("sequenceNum"));
|
||||
questionsValues = EntityUtil.filterByDate(questionsValues);
|
||||
Iterator questionsValuesIt = questionsValues.iterator();
|
||||
Set itemIds = FastSet.newInstance();
|
||||
Set<String> itemIds = FastSet.newInstance();
|
||||
Iterator<GenericValue> questionsValuesIt = questionsValues.iterator();
|
||||
while (questionsValuesIt.hasNext()) {
|
||||
ConfigItem oneQuestion = new ConfigItem((GenericValue)questionsValuesIt.next());
|
||||
ConfigItem oneQuestion = new ConfigItem(questionsValuesIt.next());
|
||||
oneQuestion.setContent(locale, "text/html"); // TODO: mime-type shouldn't be hardcoded
|
||||
if (itemIds.contains(oneQuestion.getConfigItem().getString("configItemId"))) {
|
||||
oneQuestion.setFirst(false);
|
||||
@@ -124,10 +123,10 @@ public class ProductConfigWrapper implements Serializable {
|
||||
itemIds.add(oneQuestion.getConfigItem().getString("configItemId"));
|
||||
}
|
||||
questions.add(oneQuestion);
|
||||
List configOptions = delegator.findByAnd("ProductConfigOption", UtilMisc.toMap("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")), UtilMisc.toList("sequenceNum"));
|
||||
Iterator configOptionsIt = configOptions.iterator();
|
||||
List<GenericValue> configOptions = delegator.findByAnd("ProductConfigOption", UtilMisc.toMap("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")), UtilMisc.toList("sequenceNum"));
|
||||
Iterator<GenericValue> configOptionsIt = configOptions.iterator();
|
||||
while (configOptionsIt.hasNext()) {
|
||||
ConfigOption option = new ConfigOption(delegator, dispatcher, (GenericValue)configOptionsIt.next(), oneQuestion, catalogId, webSiteId, currencyUomId, autoUserLogin);
|
||||
ConfigOption option = new ConfigOption(delegator, dispatcher, configOptionsIt.next(), oneQuestion, catalogId, webSiteId, currencyUomId, autoUserLogin);
|
||||
oneQuestion.addOption(option);
|
||||
}
|
||||
}
|
||||
@@ -139,11 +138,11 @@ public class ProductConfigWrapper implements Serializable {
|
||||
//configure ProductConfigWrapper according to ProductConfigConfig entity
|
||||
if (UtilValidate.isNotEmpty(configId)) {
|
||||
this.configId = configId;
|
||||
List productConfigConfig = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId", configId));
|
||||
List<GenericValue> productConfigConfig = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId", configId));
|
||||
if (UtilValidate.isNotEmpty(productConfigConfig)) {
|
||||
Iterator pccIt = productConfigConfig.iterator();
|
||||
Iterator<GenericValue> pccIt = productConfigConfig.iterator();
|
||||
while (pccIt.hasNext()) {
|
||||
GenericValue pcc =(GenericValue) pccIt.next();
|
||||
GenericValue pcc = pccIt.next();
|
||||
String configItemId = pcc.getString("configItemId");
|
||||
String configOptionId = pcc.getString("configOptionId");
|
||||
Long sequenceNum = pcc.getLong("sequenceNum");
|
||||
@@ -156,11 +155,11 @@ public class ProductConfigWrapper implements Serializable {
|
||||
|
||||
public void setSelected(String configItemId, Long sequenceNum, String configOptionId, String comments) throws Exception {
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
ConfigItem ci = questions.get(i);
|
||||
if (ci.configItemAssoc.getString("configItemId").equals(configItemId) && ci.configItemAssoc.getLong("sequenceNum").equals(sequenceNum)) {
|
||||
List avalOptions = ci.getOptions();
|
||||
List<ConfigOption> avalOptions = ci.getOptions();
|
||||
for (int j = 0; j < avalOptions.size(); j++) {
|
||||
ConfigOption oneOption = (ConfigOption)avalOptions.get(j);
|
||||
ConfigOption oneOption = avalOptions.get(j);
|
||||
if (oneOption.configOption.getString("configOptionId").equals(configOptionId)) {
|
||||
setSelected(i, j, comments);
|
||||
break;
|
||||
@@ -172,11 +171,11 @@ public class ProductConfigWrapper implements Serializable {
|
||||
|
||||
public void resetConfig() {
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
ConfigItem ci = questions.get(i);
|
||||
if (!ci.isStandard()) {
|
||||
List options = ci.getOptions();
|
||||
List<ConfigOption> options = ci.getOptions();
|
||||
for (int j = 0; j < options.size(); j++) {
|
||||
ConfigOption co = (ConfigOption)options.get(j);
|
||||
ConfigOption co = options.get(j);
|
||||
co.setSelected(false);
|
||||
co.setComments(null);
|
||||
}
|
||||
@@ -187,13 +186,13 @@ public class ProductConfigWrapper implements Serializable {
|
||||
public void setDefaultConfig() {
|
||||
resetConfig();
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
ConfigItem ci = questions.get(i);
|
||||
if (ci.isMandatory()) {
|
||||
ConfigOption co = ci.getDefault();
|
||||
if(co != null){
|
||||
co.setSelected(true);
|
||||
}else if (ci.getOptions().size() > 0) {
|
||||
co = (ConfigOption)ci.getOptions().get(0);
|
||||
co = ci.getOptions().get(0);
|
||||
co.setSelected(true);
|
||||
}
|
||||
}
|
||||
@@ -205,19 +204,19 @@ public class ProductConfigWrapper implements Serializable {
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof ProductConfigWrapper)) {
|
||||
if (!(obj instanceof ProductConfigWrapper)) {
|
||||
return false;
|
||||
}
|
||||
ProductConfigWrapper cw = (ProductConfigWrapper)obj;
|
||||
if (!product.getString("productId").equals(cw.getProduct().getString("productId"))) {
|
||||
return false;
|
||||
}
|
||||
List cwq = cw.getQuestions();
|
||||
List<ConfigItem> cwq = cw.getQuestions();
|
||||
if (questions.size() != cwq.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
ConfigItem ci = questions.get(i);
|
||||
if (!ci.equals(cwq.get(i))) {
|
||||
return false;
|
||||
}
|
||||
@@ -226,10 +225,10 @@ public class ProductConfigWrapper implements Serializable {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + questions;
|
||||
return questions.toString();
|
||||
}
|
||||
|
||||
public List getQuestions() {
|
||||
public List<ConfigItem> getQuestions() {
|
||||
return questions;
|
||||
}
|
||||
|
||||
@@ -238,8 +237,8 @@ public class ProductConfigWrapper implements Serializable {
|
||||
}
|
||||
|
||||
public void setSelected(int question, int option, String comments) throws Exception {
|
||||
ConfigItem ci = (ConfigItem)questions.get(question);
|
||||
List avalOptions = ci.getOptions();
|
||||
ConfigItem ci = questions.get(question);
|
||||
List<ConfigOption> avalOptions = ci.getOptions();
|
||||
if (ci.isSingleChoice()) {
|
||||
for (int j = 0; j < avalOptions.size(); j++) {
|
||||
ConfigOption oneOption = (ConfigOption)avalOptions.get(j);
|
||||
@@ -249,7 +248,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
}
|
||||
ConfigOption theOption = null;
|
||||
if (option >= 0 && option < avalOptions.size()) {
|
||||
theOption = (ConfigOption)avalOptions.get(option);
|
||||
theOption = avalOptions.get(option);
|
||||
}
|
||||
if (theOption != null) {
|
||||
theOption.setSelected(true);
|
||||
@@ -260,8 +259,8 @@ public class ProductConfigWrapper implements Serializable {
|
||||
public void setSelected(int question, int option, int component, String componentOption) throws Exception {
|
||||
// set variant products
|
||||
ConfigOption theOption = getItemOtion(question, option);
|
||||
List components = theOption.getComponents();
|
||||
GenericValue oneComponent = (GenericValue)components.get(component);
|
||||
List<GenericValue> components = theOption.getComponents();
|
||||
GenericValue oneComponent = components.get(component);
|
||||
if (theOption.isVirtualComponent(oneComponent)) {
|
||||
if (theOption.componentOptions == null) {
|
||||
theOption.componentOptions = FastMap.newInstance();
|
||||
@@ -274,16 +273,16 @@ public class ProductConfigWrapper implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public List getSelectedOptions() {
|
||||
List selectedOptions = FastList.newInstance();
|
||||
public List<ConfigOption> getSelectedOptions() {
|
||||
List<ConfigOption> selectedOptions = FastList.newInstance();
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
ConfigItem ci = questions.get(i);
|
||||
if (ci.isStandard()) {
|
||||
selectedOptions.addAll(ci.getOptions());
|
||||
} else {
|
||||
Iterator availOptions = ci.getOptions().iterator();
|
||||
Iterator<ConfigOption> availOptions = ci.getOptions().iterator();
|
||||
while (availOptions.hasNext()) {
|
||||
ConfigOption oneOption = (ConfigOption)availOptions.next();
|
||||
ConfigOption oneOption = availOptions.next();
|
||||
if (oneOption.isSelected()) {
|
||||
selectedOptions.add(oneOption);
|
||||
}
|
||||
@@ -293,10 +292,10 @@ public class ProductConfigWrapper implements Serializable {
|
||||
return selectedOptions;
|
||||
}
|
||||
|
||||
public List getDefaultOptions() {
|
||||
List defaultOptions = FastList.newInstance();
|
||||
public List<ConfigOption> getDefaultOptions() {
|
||||
List<ConfigOption> defaultOptions = FastList.newInstance();
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
ConfigItem ci = questions.get(i);
|
||||
ConfigOption co = ci.getDefault();
|
||||
if (co != null){
|
||||
defaultOptions.add(co);
|
||||
@@ -307,9 +306,9 @@ public class ProductConfigWrapper implements Serializable {
|
||||
|
||||
public double getTotalPrice() {
|
||||
double totalPrice = basePrice;
|
||||
List options = getSelectedOptions();
|
||||
List<ConfigOption> options = getSelectedOptions();
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
ConfigOption oneOption = (ConfigOption)options.get(i);
|
||||
ConfigOption oneOption = options.get(i);
|
||||
totalPrice += oneOption.getPrice();
|
||||
}
|
||||
return totalPrice;
|
||||
@@ -317,9 +316,9 @@ public class ProductConfigWrapper implements Serializable {
|
||||
|
||||
private void setDefaultPrice() {
|
||||
double totalPrice = basePrice;
|
||||
List options = getDefaultOptions();
|
||||
List<ConfigOption> options = getDefaultOptions();
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
ConfigOption oneOption = (ConfigOption)options.get(i);
|
||||
ConfigOption oneOption = options.get(i);
|
||||
totalPrice += oneOption.getPrice();
|
||||
}
|
||||
defaultPrice = totalPrice;
|
||||
@@ -332,11 +331,11 @@ public class ProductConfigWrapper implements Serializable {
|
||||
public boolean isCompleted() {
|
||||
boolean completed = true;
|
||||
for (int i = 0; i < questions.size(); i++) {
|
||||
ConfigItem ci = (ConfigItem)questions.get(i);
|
||||
ConfigItem ci = questions.get(i);
|
||||
if (!ci.isStandard() && ci.isMandatory()) {
|
||||
Iterator availOptions = ci.getOptions().iterator();
|
||||
Iterator<ConfigOption> availOptions = ci.getOptions().iterator();
|
||||
while (availOptions.hasNext()) {
|
||||
ConfigOption oneOption = (ConfigOption)availOptions.next();
|
||||
ConfigOption oneOption = availOptions.next();
|
||||
if (oneOption.isSelected()) {
|
||||
completed = true;
|
||||
break;
|
||||
@@ -354,10 +353,10 @@ public class ProductConfigWrapper implements Serializable {
|
||||
|
||||
public ConfigOption getItemOtion(int itemIndex, int optionIndex) {
|
||||
if (questions.size() > itemIndex) {
|
||||
ConfigItem ci = (ConfigItem)questions.get(itemIndex);
|
||||
List options = ci.getOptions();
|
||||
ConfigItem ci = questions.get(itemIndex);
|
||||
List<ConfigOption> options = ci.getOptions();
|
||||
if (options.size() > optionIndex) {
|
||||
ConfigOption co = (ConfigOption)options.get(optionIndex);
|
||||
ConfigOption co = options.get(optionIndex);
|
||||
return co;
|
||||
}
|
||||
}
|
||||
@@ -369,7 +368,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
GenericValue configItem = null;
|
||||
GenericValue configItemAssoc = null;
|
||||
ProductConfigItemContentWrapper content = null;
|
||||
List options = null;
|
||||
List<ConfigOption> options = null;
|
||||
boolean first = true;
|
||||
|
||||
public ConfigItem(GenericValue questionAssoc) throws Exception {
|
||||
@@ -383,7 +382,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
configItemAssoc = GenericValue.create(ci.configItemAssoc);
|
||||
options = FastList.newInstance();
|
||||
for (int i = 0; i < ci.options.size(); i++) {
|
||||
options.add(new ConfigOption((ConfigOption)ci.options.get(i)));
|
||||
options.add(new ConfigOption(ci.options.get(i)));
|
||||
}
|
||||
first = ci.first;
|
||||
content = ci.content; // FIXME: this should be cloned
|
||||
@@ -429,7 +428,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
options.add(option);
|
||||
}
|
||||
|
||||
public List getOptions() {
|
||||
public List<ConfigOption> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -463,9 +462,9 @@ public class ProductConfigWrapper implements Serializable {
|
||||
|
||||
public boolean isSelected() {
|
||||
if (isStandard()) return true;
|
||||
Iterator availOptions = getOptions().iterator();
|
||||
Iterator<ConfigOption> availOptions = getOptions().iterator();
|
||||
while (availOptions.hasNext()) {
|
||||
ConfigOption oneOption = (ConfigOption)availOptions.next();
|
||||
ConfigOption oneOption = availOptions.next();
|
||||
if (oneOption.isSelected()) {
|
||||
return true;
|
||||
}
|
||||
@@ -474,9 +473,9 @@ public class ProductConfigWrapper implements Serializable {
|
||||
}
|
||||
|
||||
public ConfigOption getSelected() {
|
||||
Iterator availOptions = getOptions().iterator();
|
||||
Iterator<ConfigOption> availOptions = getOptions().iterator();
|
||||
while (availOptions.hasNext()) {
|
||||
ConfigOption oneOption = (ConfigOption)availOptions.next();
|
||||
ConfigOption oneOption = availOptions.next();
|
||||
if (oneOption.isSelected()) {
|
||||
return oneOption;
|
||||
}
|
||||
@@ -487,7 +486,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
public ConfigOption getDefault(){
|
||||
String defaultConfigOptionId = configItemAssoc.getString("defaultConfigOptionId");
|
||||
if(UtilValidate.isNotEmpty(defaultConfigOptionId)){
|
||||
for(ConfigOption oneOption : (List<ConfigOption>)getOptions()) {
|
||||
for(ConfigOption oneOption : getOptions()) {
|
||||
String currentConfigOptionId = oneOption.getId();
|
||||
if (defaultConfigOptionId.compareToIgnoreCase(currentConfigOptionId) == 0 ){
|
||||
return oneOption;
|
||||
@@ -505,12 +504,12 @@ public class ProductConfigWrapper implements Serializable {
|
||||
if (!configItem.getString("configItemId").equals(ci.getConfigItem().getString("configItemId"))) {
|
||||
return false;
|
||||
}
|
||||
List opts = ci.getOptions();
|
||||
List<ConfigOption> opts = ci.getOptions();
|
||||
if (options.size() != opts.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
ConfigOption co = (ConfigOption)options.get(i);
|
||||
ConfigOption co = options.get(i);
|
||||
if (!co.equals(opts.get(i))) {
|
||||
return false;
|
||||
}
|
||||
@@ -526,8 +525,8 @@ public class ProductConfigWrapper implements Serializable {
|
||||
public class ConfigOption implements java.io.Serializable {
|
||||
double optionPrice = 0;
|
||||
Date availabilityDate = null;
|
||||
List componentList = null; // lists of ProductConfigProduct
|
||||
Map componentOptions = null;
|
||||
List<GenericValue> componentList = null; // lists of ProductConfigProduct
|
||||
Map<String, String> componentOptions = null;
|
||||
GenericValue configOption = null;
|
||||
boolean selected = false;
|
||||
boolean available = true;
|
||||
@@ -538,14 +537,14 @@ public class ProductConfigWrapper implements Serializable {
|
||||
configOption = option;
|
||||
parentConfigItem = configItem;
|
||||
componentList = option.getRelated("ConfigOptionProductConfigProduct");
|
||||
Iterator componentsIt = componentList.iterator();
|
||||
Iterator<GenericValue> componentsIt = componentList.iterator();
|
||||
while (componentsIt.hasNext()) {
|
||||
double price = 0;
|
||||
GenericValue oneComponent = (GenericValue)componentsIt.next();
|
||||
GenericValue oneComponent = componentsIt.next();
|
||||
// Get the component's price
|
||||
Map fieldMap = UtilMisc.toMap("product", oneComponent.getRelatedOne("ProductProduct"), "prodCatalogId", catalogId, "webSiteId", webSiteId,
|
||||
Map<String, Object> fieldMap = UtilMisc.toMap("product", oneComponent.getRelatedOne("ProductProduct"), "prodCatalogId", catalogId, "webSiteId", webSiteId,
|
||||
"currencyUomId", currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin", autoUserLogin);
|
||||
Map priceMap = dispatcher.runSync("calculateProductPrice", fieldMap);
|
||||
Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", fieldMap);
|
||||
Double componentPrice = (Double) priceMap.get("price");
|
||||
Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound");
|
||||
double mult = 1;
|
||||
@@ -559,7 +558,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
price = componentPrice.doubleValue();
|
||||
} else {
|
||||
fieldMap.put("productPricePurposeId", "PURCHASE");
|
||||
Map purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap);
|
||||
Map<String, Object> purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap);
|
||||
Double purchasePrice = (Double) purchasePriceResultMap.get("price");
|
||||
if (purchasePrice != null) {
|
||||
price = purchasePrice.doubleValue();
|
||||
@@ -574,7 +573,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
configOption = GenericValue.create(co.configOption);
|
||||
componentList = FastList.newInstance();
|
||||
for (int i = 0; i < co.componentList.size(); i++) {
|
||||
componentList.add(GenericValue.create((GenericValue)co.componentList.get(i)));
|
||||
componentList.add(GenericValue.create(co.componentList.get(i)));
|
||||
}
|
||||
optionPrice = co.optionPrice;
|
||||
available = co.available;
|
||||
@@ -584,21 +583,21 @@ public class ProductConfigWrapper implements Serializable {
|
||||
|
||||
public void recalculateOptionPrice(ProductConfigWrapper pcw) throws Exception {
|
||||
optionPrice = 0;
|
||||
Iterator componentsIt = componentList.iterator();
|
||||
Iterator<GenericValue> componentsIt = componentList.iterator();
|
||||
while (componentsIt.hasNext()) {
|
||||
double price = 0;
|
||||
GenericValue oneComponent = (GenericValue)componentsIt.next();
|
||||
GenericValue oneComponent = componentsIt.next();
|
||||
GenericValue oneComponentProduct = oneComponent.getRelatedOne("ProductProduct");
|
||||
String variantProductId = (String)componentOptions.get(oneComponent.getString("productId"));
|
||||
String variantProductId = componentOptions.get(oneComponent.getString("productId"));
|
||||
|
||||
if (UtilValidate.isNotEmpty(variantProductId)) {
|
||||
oneComponentProduct = pcw.delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", variantProductId));
|
||||
}
|
||||
|
||||
// Get the component's price
|
||||
Map fieldMap = UtilMisc.toMap("product", oneComponentProduct, "prodCatalogId", pcw.catalogId, "webSiteId", pcw.webSiteId,
|
||||
Map<String, Object> fieldMap = UtilMisc.toMap("product", oneComponentProduct, "prodCatalogId", pcw.catalogId, "webSiteId", pcw.webSiteId,
|
||||
"currencyUomId", pcw.currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin", pcw.autoUserLogin);
|
||||
Map priceMap = dispatcher.runSync("calculateProductPrice", fieldMap);
|
||||
Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", fieldMap);
|
||||
Double componentPrice = (Double) priceMap.get("price");
|
||||
Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound");
|
||||
double mult = 1;
|
||||
@@ -612,7 +611,7 @@ public class ProductConfigWrapper implements Serializable {
|
||||
price = componentPrice.doubleValue();
|
||||
} else {
|
||||
fieldMap.put("productPricePurposeId", "PURCHASE");
|
||||
Map purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap);
|
||||
Map<String, Object> purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap);
|
||||
Double purchasePrice = (Double) purchasePriceResultMap.get("price");
|
||||
if (purchasePrice != null) {
|
||||
price = purchasePrice.doubleValue();
|
||||
@@ -701,11 +700,11 @@ public class ProductConfigWrapper implements Serializable {
|
||||
available = newValue;
|
||||
}
|
||||
|
||||
public List getComponents() {
|
||||
public List<GenericValue> getComponents() {
|
||||
return componentList;
|
||||
}
|
||||
|
||||
public Map getComponentOptions() {
|
||||
public Map<String, String> getComponentOptions() {
|
||||
return componentOptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,31 +56,31 @@ public class ParametricSearch {
|
||||
* ProductCategory -> ProductFeatureCategoryAppl -> ProductFeatureCategory -> ProductFeature.
|
||||
* Returns a Map of Lists of ProductFeature GenericValue objects organized by productFeatureTypeId.
|
||||
*/
|
||||
public static Map makeCategoryFeatureLists(String productCategoryId, GenericDelegator delegator) {
|
||||
public static Map<String, List<GenericValue>> makeCategoryFeatureLists(String productCategoryId, GenericDelegator delegator) {
|
||||
return makeCategoryFeatureLists(productCategoryId, delegator, DEFAULT_PER_TYPE_MAX_SIZE);
|
||||
}
|
||||
|
||||
public static Map makeCategoryFeatureLists(String productCategoryId, GenericDelegator delegator, int perTypeMaxSize) {
|
||||
Map productFeaturesByTypeMap = FastMap.newInstance();
|
||||
public static Map<String, List<GenericValue>> makeCategoryFeatureLists(String productCategoryId, GenericDelegator delegator, int perTypeMaxSize) {
|
||||
Map<String, Map<String, GenericValue>> productFeaturesByTypeMap = FastMap.newInstance();
|
||||
try {
|
||||
List productFeatureCategoryAppls = delegator.findByAndCache("ProductFeatureCategoryAppl", UtilMisc.toMap("productCategoryId", productCategoryId));
|
||||
List<GenericValue> productFeatureCategoryAppls = delegator.findByAndCache("ProductFeatureCategoryAppl", UtilMisc.toMap("productCategoryId", productCategoryId));
|
||||
productFeatureCategoryAppls = EntityUtil.filterByDate(productFeatureCategoryAppls, true);
|
||||
if (productFeatureCategoryAppls != null) {
|
||||
Iterator pfcasIter = productFeatureCategoryAppls.iterator();
|
||||
Iterator<GenericValue> pfcasIter = productFeatureCategoryAppls.iterator();
|
||||
while (pfcasIter.hasNext()) {
|
||||
GenericValue productFeatureCategoryAppl = (GenericValue) pfcasIter.next();
|
||||
List productFeatures = delegator.findByAndCache("ProductFeature", UtilMisc.toMap("productFeatureCategoryId", productFeatureCategoryAppl.get("productFeatureCategoryId")));
|
||||
Iterator pfsIter = productFeatures.iterator();
|
||||
GenericValue productFeatureCategoryAppl = pfcasIter.next();
|
||||
List<GenericValue> productFeatures = delegator.findByAndCache("ProductFeature", UtilMisc.toMap("productFeatureCategoryId", productFeatureCategoryAppl.get("productFeatureCategoryId")));
|
||||
Iterator<GenericValue> pfsIter = productFeatures.iterator();
|
||||
while (pfsIter.hasNext()) {
|
||||
GenericValue productFeature = (GenericValue) pfsIter.next();
|
||||
GenericValue productFeature = pfsIter.next();
|
||||
String productFeatureTypeId = productFeature.getString("productFeatureTypeId");
|
||||
Map featuresByType = (Map) productFeaturesByTypeMap.get(productFeatureTypeId);
|
||||
Map<String, GenericValue> featuresByType = productFeaturesByTypeMap.get(productFeatureTypeId);
|
||||
if (featuresByType == null) {
|
||||
featuresByType = FastMap.newInstance();
|
||||
productFeaturesByTypeMap.put(productFeatureTypeId, featuresByType);
|
||||
}
|
||||
if (featuresByType.size() < perTypeMaxSize) {
|
||||
featuresByType.put(productFeature.get("productFeatureId"), productFeature);
|
||||
featuresByType.put(productFeature.getString("productFeatureId"), productFeature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,26 +90,26 @@ public class ParametricSearch {
|
||||
}
|
||||
|
||||
try {
|
||||
List productFeatureCatGrpAppls = delegator.findByAndCache("ProductFeatureCatGrpAppl", UtilMisc.toMap("productCategoryId", productCategoryId));
|
||||
List<GenericValue> productFeatureCatGrpAppls = delegator.findByAndCache("ProductFeatureCatGrpAppl", UtilMisc.toMap("productCategoryId", productCategoryId));
|
||||
productFeatureCatGrpAppls = EntityUtil.filterByDate(productFeatureCatGrpAppls, true);
|
||||
if (productFeatureCatGrpAppls != null) {
|
||||
Iterator pfcgasIter = productFeatureCatGrpAppls.iterator();
|
||||
Iterator<GenericValue> pfcgasIter = productFeatureCatGrpAppls.iterator();
|
||||
while (pfcgasIter.hasNext()) {
|
||||
GenericValue productFeatureCatGrpAppl = (GenericValue) pfcgasIter.next();
|
||||
List productFeatureGroupAppls = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureCatGrpAppl.get("productFeatureGroupId")));
|
||||
Iterator pfgaasIter = productFeatureGroupAppls.iterator();
|
||||
GenericValue productFeatureCatGrpAppl = pfcgasIter.next();
|
||||
List<GenericValue> productFeatureGroupAppls = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureCatGrpAppl.get("productFeatureGroupId")));
|
||||
Iterator<GenericValue> pfgaasIter = productFeatureGroupAppls.iterator();
|
||||
while (pfgaasIter.hasNext()) {
|
||||
GenericValue productFeatureGroupAppl = (GenericValue) pfgaasIter.next();
|
||||
GenericValue productFeatureGroupAppl = pfgaasIter.next();
|
||||
GenericValue productFeature = delegator.findByPrimaryKeyCache("ProductFeature", UtilMisc.toMap("productFeatureId", productFeatureGroupAppl.get("productFeatureId")));
|
||||
|
||||
String productFeatureTypeId = productFeature.getString("productFeatureTypeId");
|
||||
Map featuresByType = (Map) productFeaturesByTypeMap.get(productFeatureTypeId);
|
||||
Map<String, GenericValue> featuresByType = productFeaturesByTypeMap.get(productFeatureTypeId);
|
||||
if (featuresByType == null) {
|
||||
featuresByType = FastMap.newInstance();
|
||||
productFeaturesByTypeMap.put(productFeatureTypeId, featuresByType);
|
||||
}
|
||||
if (featuresByType.size() < perTypeMaxSize) {
|
||||
featuresByType.put(productFeature.get("productFeatureId"), productFeature);
|
||||
featuresByType.put(productFeature.getString("productFeatureId"), productFeature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,28 +119,29 @@ public class ParametricSearch {
|
||||
}
|
||||
|
||||
// now before returning, order the features in each list by description
|
||||
Iterator productFeatureTypeEntries = productFeaturesByTypeMap.entrySet().iterator();
|
||||
Map<String, List<GenericValue>> productFeaturesByTypeMapSorted = FastMap.newInstance();
|
||||
Iterator<Map.Entry<String, Map<String, GenericValue>>> productFeatureTypeEntries = productFeaturesByTypeMap.entrySet().iterator();
|
||||
while (productFeatureTypeEntries.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) productFeatureTypeEntries.next();
|
||||
List sortedFeatures = EntityUtil.orderBy(((Map) entry.getValue()).values(), UtilMisc.toList("description"));
|
||||
productFeaturesByTypeMap.put(entry.getKey(), sortedFeatures);
|
||||
Map.Entry<String, Map<String, GenericValue>> entry = productFeatureTypeEntries.next();
|
||||
List<GenericValue> sortedFeatures = EntityUtil.orderBy(entry.getValue().values(), UtilMisc.toList("description"));
|
||||
productFeaturesByTypeMapSorted.put(entry.getKey(), sortedFeatures);
|
||||
}
|
||||
|
||||
return productFeaturesByTypeMap;
|
||||
return productFeaturesByTypeMapSorted;
|
||||
}
|
||||
|
||||
public static Map getAllFeaturesByType(GenericDelegator delegator) {
|
||||
public static Map<String, List<GenericValue>> getAllFeaturesByType(GenericDelegator delegator) {
|
||||
return getAllFeaturesByType(delegator, DEFAULT_PER_TYPE_MAX_SIZE);
|
||||
}
|
||||
public static Map getAllFeaturesByType(GenericDelegator delegator, int perTypeMaxSize) {
|
||||
Map productFeaturesByTypeMap = FastMap.newInstance();
|
||||
public static Map<String, List<GenericValue>> getAllFeaturesByType(GenericDelegator delegator, int perTypeMaxSize) {
|
||||
Map<String, List<GenericValue>> productFeaturesByTypeMap = FastMap.newInstance();
|
||||
try {
|
||||
Set typesWithOverflowMessages = FastSet.newInstance();
|
||||
Set<String> typesWithOverflowMessages = FastSet.newInstance();
|
||||
EntityListIterator productFeatureEli = delegator.find("ProductFeature", null, null, null, UtilMisc.toList("description"), null);
|
||||
GenericValue productFeature = null;
|
||||
while ((productFeature = (GenericValue) productFeatureEli.next()) != null) {
|
||||
while ((productFeature = productFeatureEli.next()) != null) {
|
||||
String productFeatureTypeId = productFeature.getString("productFeatureTypeId");
|
||||
List featuresByType = (List) productFeaturesByTypeMap.get(productFeatureTypeId);
|
||||
List<GenericValue> featuresByType = productFeaturesByTypeMap.get(productFeatureTypeId);
|
||||
if (featuresByType == null) {
|
||||
featuresByType = FastList.newInstance();
|
||||
productFeaturesByTypeMap.put(productFeatureTypeId, featuresByType);
|
||||
@@ -161,19 +162,20 @@ public class ParametricSearch {
|
||||
return productFeaturesByTypeMap;
|
||||
}
|
||||
|
||||
public static Map makeFeatureIdByTypeMap(ServletRequest request) {
|
||||
Map parameters = UtilHttp.getParameterMap((HttpServletRequest) request);
|
||||
public static Map<String, String> makeFeatureIdByTypeMap(ServletRequest request) {
|
||||
Map<String, Object> parameters = UtilHttp.getParameterMap((HttpServletRequest) request);
|
||||
return makeFeatureIdByTypeMap(parameters);
|
||||
}
|
||||
|
||||
/** Handles parameters coming in prefixed with "pft_" where the text in the key following the prefix is a productFeatureTypeId and the value is a productFeatureId; meant to be used with drop-downs and such */
|
||||
public static Map makeFeatureIdByTypeMap(Map parameters) {
|
||||
Map featureIdByType = FastMap.newInstance();
|
||||
public static Map<String, String> makeFeatureIdByTypeMap(Map<String, Object> parameters) {
|
||||
Map<String, String> featureIdByType = FastMap.newInstance();
|
||||
if (parameters == null) return featureIdByType;
|
||||
|
||||
Iterator parameterNameIter = parameters.keySet().iterator();
|
||||
|
||||
Iterator<String> parameterNameIter = parameters.keySet().iterator();
|
||||
while (parameterNameIter.hasNext()) {
|
||||
String parameterName = (String) parameterNameIter.next();
|
||||
String parameterName = parameterNameIter.next();
|
||||
if (parameterName.startsWith("pft_")) {
|
||||
String productFeatureTypeId = parameterName.substring(4);
|
||||
String productFeatureId = (String) parameters.get(parameterName);
|
||||
@@ -187,13 +189,13 @@ public class ParametricSearch {
|
||||
}
|
||||
|
||||
/** Handles parameters coming in prefixed with "SEARCH_FEAT" where the parameter value is a productFeatureId; meant to be used with text entry boxes or check-boxes and such */
|
||||
public static List makeFeatureIdListFromPrefixed(Map parameters) {
|
||||
List featureIdList = FastList.newInstance();
|
||||
public static List<String> makeFeatureIdListFromPrefixed(Map<String, Object> parameters) {
|
||||
List<String> featureIdList = FastList.newInstance();
|
||||
if (parameters == null) return featureIdList;
|
||||
|
||||
Iterator parameterNameIter = parameters.keySet().iterator();
|
||||
Iterator<String> parameterNameIter = parameters.keySet().iterator();
|
||||
while (parameterNameIter.hasNext()) {
|
||||
String parameterName = (String) parameterNameIter.next();
|
||||
String parameterName = parameterNameIter.next();
|
||||
if (parameterName.startsWith("SEARCH_FEAT")) {
|
||||
String productFeatureId = (String) parameters.get(parameterName);
|
||||
if (productFeatureId != null && productFeatureId.length() > 0) {
|
||||
@@ -205,23 +207,23 @@ public class ParametricSearch {
|
||||
return featureIdList;
|
||||
}
|
||||
|
||||
public static String makeFeatureIdByTypeString(Map featureIdByType) {
|
||||
public static String makeFeatureIdByTypeString(Map<String, String> featureIdByType) {
|
||||
if (featureIdByType == null || featureIdByType.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder outSb = new StringBuilder();
|
||||
Iterator fbtIter = featureIdByType.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> fbtIter = featureIdByType.entrySet().iterator();
|
||||
while (fbtIter.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) fbtIter.next();
|
||||
String productFeatureTypeId = (String) entry.getKey();
|
||||
String productFeatureId = (String) entry.getValue();
|
||||
Map.Entry<String, String> entry = fbtIter.next();
|
||||
if (outSb.length() > 0) {
|
||||
outSb.append('&');
|
||||
}
|
||||
String productFeatureTypeId = entry.getKey();
|
||||
String productFeatureId = entry.getValue();
|
||||
outSb.append(productFeatureTypeId);
|
||||
outSb.append('=');
|
||||
outSb.append(productFeatureId);
|
||||
if (fbtIter.hasNext()) {
|
||||
outSb.append('&');
|
||||
}
|
||||
}
|
||||
|
||||
return outSb.toString();
|
||||
@@ -232,13 +234,13 @@ public class ParametricSearch {
|
||||
* where the parameter value is a productFeatureCategoryId;
|
||||
* meant to be used with text entry boxes or check-boxes and such
|
||||
**/
|
||||
public static List makeProductFeatureCategoryIdListFromPrefixed(Map parameters) {
|
||||
List prodFeatureCategoryIdList = FastList.newInstance();
|
||||
public static List<String> makeProductFeatureCategoryIdListFromPrefixed(Map<String, Object> parameters) {
|
||||
List<String> prodFeatureCategoryIdList = FastList.newInstance();
|
||||
if (parameters == null) return prodFeatureCategoryIdList;
|
||||
|
||||
Iterator parameterNameIter = parameters.keySet().iterator();
|
||||
Iterator<String> parameterNameIter = parameters.keySet().iterator();
|
||||
while (parameterNameIter.hasNext()) {
|
||||
String parameterName = (String) parameterNameIter.next();
|
||||
String parameterName = parameterNameIter.next();
|
||||
if (parameterName.startsWith("SEARCH_PROD_FEAT_CAT")) {
|
||||
String productFeatureCategoryId = (String) parameters.get(parameterName);
|
||||
if (productFeatureCategoryId != null && productFeatureCategoryId.length() > 0) {
|
||||
|
||||
@@ -22,11 +22,14 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
import javolution.util.FastSet;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilMisc;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
import org.ofbiz.entity.GenericDelegator;
|
||||
@@ -57,8 +60,8 @@ public class ProductFeatureServices {
|
||||
* the results are from ProductFeatureGroupAndAppl. Otherwise, if there is a productId, the results are from ProductFeatureAndAppl.
|
||||
* The optional productFeatureApplTypeId causes results to be filtered by this parameter--only used in conjunction with productId.
|
||||
*/
|
||||
public static Map getProductFeaturesByType(DispatchContext dctx, Map context) {
|
||||
Map results = FastMap.newInstance();
|
||||
public static Map<String, Object> getProductFeaturesByType(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Map<String, Object> results = FastMap.newInstance();
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
|
||||
/* because we might need to search either for product features or for product features of a product, the search code has to be generic.
|
||||
@@ -69,7 +72,7 @@ public class ProductFeatureServices {
|
||||
|
||||
String entityToSearch = "ProductFeature";
|
||||
String fieldToSearch = "productFeatureCategoryId";
|
||||
List orderBy = UtilMisc.toList("productFeatureTypeId", "description");
|
||||
List<String> orderBy = UtilMisc.toList("productFeatureTypeId", "description");
|
||||
|
||||
if (valueToSearch == null && context.get("productFeatureGroupId") != null) {
|
||||
entityToSearch = "ProductFeatureGroupAndAppl";
|
||||
@@ -89,24 +92,25 @@ public class ProductFeatureServices {
|
||||
|
||||
try {
|
||||
// get all product features in this feature category
|
||||
List allFeatures = delegator.findByAnd(entityToSearch, UtilMisc.toMap(fieldToSearch, valueToSearch), orderBy);
|
||||
List<GenericValue> allFeatures = delegator.findByAnd(entityToSearch, UtilMisc.toMap(fieldToSearch, valueToSearch), orderBy);
|
||||
|
||||
if (entityToSearch.equals("ProductFeatureAndAppl") && productFeatureApplTypeId != null)
|
||||
allFeatures = EntityUtil.filterByAnd(allFeatures, UtilMisc.toMap("productFeatureApplTypeId", productFeatureApplTypeId));
|
||||
|
||||
List featureTypes = FastList.newInstance(); // or LinkedList?
|
||||
Map featuresByType = new LinkedHashMap();
|
||||
List<String> featureTypes = FastList.newInstance();
|
||||
Map<String, List<GenericValue>> featuresByType = new LinkedHashMap<String, List<GenericValue>>();
|
||||
GenericValue feature = null;
|
||||
for (Iterator featuresIter = allFeatures.iterator(); featuresIter.hasNext(); ) {
|
||||
feature = (GenericValue) featuresIter.next();
|
||||
for (Iterator<GenericValue> featuresIter = allFeatures.iterator(); featuresIter.hasNext(); ) {
|
||||
feature = featuresIter.next();
|
||||
String featureType = feature.getString("productFeatureTypeId");
|
||||
if (!featureTypes.contains(featureType)) {
|
||||
featureTypes.add(featureType);
|
||||
}
|
||||
if (!featuresByType.containsKey(featureType)) {
|
||||
featuresByType.put(featureType, FastList.newInstance());
|
||||
List<GenericValue> features = featuresByType.get(featureType);
|
||||
if (features == null) {
|
||||
features = FastList.newInstance();
|
||||
featuresByType.put(featureType, features);
|
||||
}
|
||||
List features = (List)featuresByType.get(featureType);
|
||||
features.add(feature);
|
||||
}
|
||||
|
||||
@@ -124,13 +128,13 @@ public class ProductFeatureServices {
|
||||
* Parameter: productId, productFeatureAppls (a List of ProductFeatureAndAppl entities of features applied to productId)
|
||||
* Result: variantProductIds: a List of productIds of variants with those features
|
||||
*/
|
||||
public static Map getAllExistingVariants(DispatchContext dctx, Map context) {
|
||||
Map results = FastMap.newInstance();
|
||||
public static Map<String, Object> getAllExistingVariants(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Map<String, Object> results = FastMap.newInstance();
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
|
||||
String productId = (String) context.get("productId");
|
||||
List curProductFeatureAndAppls = (List) context.get("productFeatureAppls");
|
||||
List existingVariantProductIds = FastList.newInstance();
|
||||
List<String> curProductFeatureAndAppls = UtilGenerics.checkList(context.get("productFeatureAppls"));
|
||||
List<String> existingVariantProductIds = FastList.newInstance();
|
||||
|
||||
try {
|
||||
/*
|
||||
@@ -138,23 +142,23 @@ public class ProductFeatureServices {
|
||||
* see if it has every single feature in the list of productFeatureAppls as a STANDARD_FEATURE. If so, then
|
||||
* it qualifies and add it to the list of existingVariantProductIds.
|
||||
*/
|
||||
List productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
|
||||
Iterator productAssocIter = productAssocs.iterator();
|
||||
List<GenericValue> productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
|
||||
Iterator<GenericValue> productAssocIter = productAssocs.iterator();
|
||||
while (productAssocIter.hasNext()) {
|
||||
GenericEntity productAssoc = (GenericEntity) productAssocIter.next();
|
||||
GenericEntity productAssoc = productAssocIter.next();
|
||||
|
||||
//for each associated product, if it has all standard features, display it's productId
|
||||
boolean hasAllFeatures = true;
|
||||
Iterator curProductFeatureAndApplIter = curProductFeatureAndAppls.iterator();
|
||||
Iterator<String> curProductFeatureAndApplIter = curProductFeatureAndAppls.iterator();
|
||||
while (curProductFeatureAndApplIter.hasNext()) {
|
||||
String productFeatureAndAppl = (String) curProductFeatureAndApplIter.next();
|
||||
Map findByMap = UtilMisc.toMap("productId", productAssoc.getString("productIdTo"),
|
||||
String productFeatureAndAppl = curProductFeatureAndApplIter.next();
|
||||
Map<String, String> findByMap = UtilMisc.toMap("productId", productAssoc.getString("productIdTo"),
|
||||
"productFeatureId", productFeatureAndAppl,
|
||||
"productFeatureApplTypeId", "STANDARD_FEATURE");
|
||||
|
||||
//Debug.log("Using findByMap: " + findByMap);
|
||||
|
||||
List standardProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", findByMap));
|
||||
List<GenericValue> standardProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", findByMap));
|
||||
if (UtilValidate.isEmpty(standardProductFeatureAndAppls)) {
|
||||
// Debug.log("Does NOT have this standard feature");
|
||||
hasAllFeatures = false;
|
||||
@@ -166,7 +170,7 @@ public class ProductFeatureServices {
|
||||
|
||||
if (hasAllFeatures) {
|
||||
// add to list of existing variants: productId=productAssoc.productIdTo
|
||||
existingVariantProductIds.add(productAssoc.get("productIdTo"));
|
||||
existingVariantProductIds.add(productAssoc.getString("productIdTo"));
|
||||
}
|
||||
}
|
||||
results = ServiceUtil.returnSuccess();
|
||||
@@ -183,33 +187,33 @@ public class ProductFeatureServices {
|
||||
* Result: featureCombinations, a List of Maps containing, for each possible variant of the productid:
|
||||
* {defaultVariantProductId: id of this variant; curProductFeatureAndAppls: features applied to this variant; existingVariantProductIds: List of productIds which are already variants with these features }
|
||||
*/
|
||||
public static Map getVariantCombinations(DispatchContext dctx, Map context) {
|
||||
Map results = FastMap.newInstance();
|
||||
public static Map<String, Object> getVariantCombinations(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Map<String, Object> results = FastMap.newInstance();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
|
||||
String productId = (String) context.get("productId");
|
||||
|
||||
try {
|
||||
Map featuresResults = dispatcher.runSync("getProductFeaturesByType", UtilMisc.toMap("productId", productId));
|
||||
Map features = FastMap.newInstance();
|
||||
Map<String, Object> featuresResults = dispatcher.runSync("getProductFeaturesByType", UtilMisc.toMap("productId", productId));
|
||||
Map<String, List<GenericValue>> features;
|
||||
|
||||
if (featuresResults.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_SUCCESS)) {
|
||||
features = (Map) featuresResults.get("productFeaturesByType");
|
||||
features = UtilGenerics.checkMap(featuresResults.get("productFeaturesByType"));
|
||||
} else {
|
||||
return ServiceUtil.returnError((String) featuresResults.get(ModelService.ERROR_MESSAGE_LIST));
|
||||
}
|
||||
|
||||
// need to keep 2 lists, oldCombinations and newCombinations, and keep swapping them after each looping. Otherwise, you'll get a
|
||||
// concurrent modification exception
|
||||
List oldCombinations = FastList.newInstance();
|
||||
List<Map<String, Object>> oldCombinations = FastList.newInstance();
|
||||
|
||||
// loop through each feature type
|
||||
for (Iterator fi = features.keySet().iterator(); fi.hasNext(); ) {
|
||||
String currentFeatureType = (String) fi.next();
|
||||
List currentFeatures = (List) features.get(currentFeatureType);
|
||||
for (Iterator<String> fi = features.keySet().iterator(); fi.hasNext(); ) {
|
||||
String currentFeatureType = fi.next();
|
||||
List<GenericValue> currentFeatures = features.get(currentFeatureType);
|
||||
|
||||
List newCombinations = FastList.newInstance();
|
||||
List combinations;
|
||||
List<Map<String, Object>> newCombinations = FastList.newInstance();
|
||||
List<Map<String, Object>> combinations;
|
||||
|
||||
// start with either existing combinations or from scratch
|
||||
if (oldCombinations.size() > 0) {
|
||||
@@ -223,12 +227,12 @@ public class ProductFeatureServices {
|
||||
// of the next variant. just a matter of whether we're starting with an
|
||||
// existing list of features and id code or from scratch.
|
||||
if (combinations.size()==0) {
|
||||
for (Iterator cFi = currentFeatures.iterator(); cFi.hasNext(); ) {
|
||||
GenericEntity currentFeature = (GenericEntity) cFi.next();
|
||||
for (Iterator<GenericValue> cFi = currentFeatures.iterator(); cFi.hasNext(); ) {
|
||||
GenericValue currentFeature = cFi.next();
|
||||
if (currentFeature.getString("productFeatureApplTypeId").equals("SELECTABLE_FEATURE")) {
|
||||
Map newCombination = FastMap.newInstance();
|
||||
List newFeatures = FastList.newInstance();
|
||||
List newFeatureIds = FastList.newInstance();
|
||||
Map<String, Object> newCombination = FastMap.newInstance();
|
||||
List<GenericValue> newFeatures = FastList.newInstance();
|
||||
List<String> newFeatureIds = FastList.newInstance();
|
||||
if (currentFeature.getString("idCode") != null) {
|
||||
newCombination.put("defaultVariantProductId", productId + currentFeature.getString("idCode"));
|
||||
} else {
|
||||
@@ -242,16 +246,16 @@ public class ProductFeatureServices {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Iterator comboIt = combinations.iterator(); comboIt.hasNext(); ) {
|
||||
Map combination = (Map) comboIt.next();
|
||||
for (Iterator cFi = currentFeatures.iterator(); cFi.hasNext(); ) {
|
||||
GenericEntity currentFeature = (GenericEntity) cFi.next();
|
||||
for (Iterator<Map<String, Object>> comboIt = combinations.iterator(); comboIt.hasNext(); ) {
|
||||
Map<String, Object> combination = comboIt.next();
|
||||
for (Iterator<GenericValue> cFi = currentFeatures.iterator(); cFi.hasNext(); ) {
|
||||
GenericValue currentFeature = cFi.next();
|
||||
if (currentFeature.getString("productFeatureApplTypeId").equals("SELECTABLE_FEATURE")) {
|
||||
Map newCombination = FastMap.newInstance();
|
||||
Map<String, Object> newCombination = FastMap.newInstance();
|
||||
// .clone() is important, or you'll keep adding to the same List for all the variants
|
||||
// have to cast twice: once from get() and once from clone()
|
||||
List newFeatures = UtilMisc.makeListWritable((List) combination.get("curProductFeatureAndAppls"));
|
||||
List newFeatureIds = UtilMisc.makeListWritable((List) combination.get("curProductFeatureIds"));
|
||||
List<GenericValue> newFeatures = UtilMisc.makeListWritable(UtilGenerics.<GenericValue>checkList(combination.get("curProductFeatureAndAppls")));
|
||||
List<String> newFeatureIds = UtilMisc.makeListWritable(UtilGenerics.<String>checkList(combination.get("curProductFeatureIds")));
|
||||
if (currentFeature.getString("idCode") != null) {
|
||||
newCombination.put("defaultVariantProductId", combination.get("defaultVariantProductId") + currentFeature.getString("idCode"));
|
||||
} else {
|
||||
@@ -272,18 +276,18 @@ public class ProductFeatureServices {
|
||||
}
|
||||
|
||||
int defaultCodeCounter = 1;
|
||||
Map defaultVariantProductIds = FastMap.newInstance(); // this map will contain the codes already used (as keys)
|
||||
defaultVariantProductIds.put(productId, null);
|
||||
Set<String> defaultVariantProductIds = FastSet.newInstance(); // this map will contain the codes already used (as keys)
|
||||
defaultVariantProductIds.add(productId);
|
||||
|
||||
// now figure out which of these combinations already have productIds associated with them
|
||||
for (Iterator fCi = oldCombinations.iterator(); fCi.hasNext(); ) {
|
||||
Map combination = (Map) fCi.next();
|
||||
for (Iterator<Map<String, Object>> fCi = oldCombinations.iterator(); fCi.hasNext(); ) {
|
||||
Map<String, Object> combination = fCi.next();
|
||||
// Verify if the default code is already used, if so add a numeric suffix
|
||||
if (defaultVariantProductIds.containsKey(combination.get("defaultVariantProductId"))) {
|
||||
if (defaultVariantProductIds.contains((String) combination.get("defaultVariantProductId"))) {
|
||||
combination.put("defaultVariantProductId", combination.get("defaultVariantProductId") + (defaultCodeCounter < 10? "0" + defaultCodeCounter: "" + defaultCodeCounter));
|
||||
defaultCodeCounter++;
|
||||
}
|
||||
defaultVariantProductIds.put(combination.get("defaultVariantProductId"), null);
|
||||
defaultVariantProductIds.add((String) combination.get("defaultVariantProductId"));
|
||||
results = dispatcher.runSync("getAllExistingVariants", UtilMisc.toMap("productId", productId,
|
||||
"productFeatureAppls", combination.get("curProductFeatureIds")));
|
||||
combination.put("existingVariantProductIds", results.get("variantProductIds"));
|
||||
@@ -302,15 +306,15 @@ public class ProductFeatureServices {
|
||||
* Parameters: productCategoryId (String) and productFeatures (a List of ProductFeature GenericValues)
|
||||
* Result: products (a List of Product GenericValues)
|
||||
*/
|
||||
public static Map getCategoryVariantProducts(DispatchContext dctx, Map context) {
|
||||
Map results = FastMap.newInstance();
|
||||
public static Map<String, Object> getCategoryVariantProducts(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Map<String, Object> results = FastMap.newInstance();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
|
||||
List productFeatures = (List) context.get("productFeatures");
|
||||
List<GenericValue> productFeatures = UtilGenerics.checkList(context.get("productFeatures"));
|
||||
String productCategoryId = (String) context.get("productCategoryId");
|
||||
|
||||
// get all the product members of the product category
|
||||
Map result = FastMap.newInstance();
|
||||
Map result;
|
||||
try {
|
||||
result = dispatcher.runSync("getProductCategoryMembers", UtilMisc.toMap("categoryId", productCategoryId));
|
||||
} catch (GenericServiceException ex) {
|
||||
@@ -318,19 +322,19 @@ public class ProductFeatureServices {
|
||||
return ServiceUtil.returnError(ex.getMessage());
|
||||
}
|
||||
|
||||
List memberProducts = (List) result.get("categoryMembers");
|
||||
List<GenericValue> memberProducts = UtilGenerics.checkList(result.get("categoryMembers"));
|
||||
if ((memberProducts != null) && (memberProducts.size() > 0)) {
|
||||
// construct a Map of productFeatureTypeId -> productFeatureId from the productFeatures List
|
||||
Map featuresByType = FastMap.newInstance();
|
||||
for (Iterator pFi = productFeatures.iterator(); pFi.hasNext(); ) {
|
||||
GenericValue nextFeature = (GenericValue) pFi.next();
|
||||
Map<String, String> featuresByType = FastMap.newInstance();
|
||||
for (Iterator<GenericValue> pFi = productFeatures.iterator(); pFi.hasNext(); ) {
|
||||
GenericValue nextFeature = pFi.next();
|
||||
featuresByType.put(nextFeature.getString("productFeatureTypeId"), nextFeature.getString("productFeatureId"));
|
||||
}
|
||||
|
||||
List products = FastList.newInstance(); // final list of variant products
|
||||
for (Iterator mPi = memberProducts.iterator(); mPi.hasNext(); ) {
|
||||
List<GenericValue> products = FastList.newInstance(); // final list of variant products
|
||||
for (Iterator<GenericValue> mPi = memberProducts.iterator(); mPi.hasNext(); ) {
|
||||
// find variants for each member product of the category
|
||||
GenericValue memberProduct = (GenericValue) mPi.next();
|
||||
GenericValue memberProduct = mPi.next();
|
||||
|
||||
try {
|
||||
result = dispatcher.runSync("getProductVariant", UtilMisc.toMap("productId", memberProduct.getString("productId"), "selectedFeatures", featuresByType));
|
||||
@@ -339,7 +343,7 @@ public class ProductFeatureServices {
|
||||
return ServiceUtil.returnError(ex.getMessage());
|
||||
}
|
||||
|
||||
List variantProducts = (List) result.get("products");
|
||||
List<GenericValue> variantProducts = UtilGenerics.checkList(result.get("products"));
|
||||
if ((variantProducts != null) && (variantProducts.size() > 0)) {
|
||||
products.addAll(variantProducts);
|
||||
} else {
|
||||
|
||||
@@ -30,6 +30,7 @@ import javolution.util.FastMap;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilDateTime;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilMisc;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
import org.ofbiz.entity.GenericDelegator;
|
||||
@@ -54,7 +55,7 @@ public class InventoryServices {
|
||||
|
||||
public final static String module = InventoryServices.class.getName();
|
||||
|
||||
public static Map prepareInventoryTransfer(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> prepareInventoryTransfer(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
String inventoryItemId = (String) context.get("inventoryItemId");
|
||||
Double xferQty = (Double) context.get("xferQty");
|
||||
@@ -73,7 +74,7 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
try {
|
||||
Map results = ServiceUtil.returnSuccess();
|
||||
Map<String, Object> results = ServiceUtil.returnSuccess();
|
||||
|
||||
String inventoryType = inventoryItem.getString("inventoryItemTypeId");
|
||||
if (inventoryType.equals("NON_SERIAL_INV_ITEM")) {
|
||||
@@ -117,17 +118,17 @@ public class InventoryServices {
|
||||
results.put("inventoryItemId", newItem.get("inventoryItemId"));
|
||||
|
||||
// TODO: how do we get this here: "inventoryTransferId", inventoryTransferId
|
||||
Map createNewDetailMap = UtilMisc.toMap("availableToPromiseDiff", xferQty, "quantityOnHandDiff", xferQty,
|
||||
Map<String, Object> createNewDetailMap = UtilMisc.toMap("availableToPromiseDiff", xferQty, "quantityOnHandDiff", xferQty,
|
||||
"inventoryItemId", newItem.get("inventoryItemId"), "userLogin", userLogin);
|
||||
Map createUpdateDetailMap = UtilMisc.toMap("availableToPromiseDiff", negXferQty, "quantityOnHandDiff", negXferQty,
|
||||
Map<String, Object> createUpdateDetailMap = UtilMisc.toMap("availableToPromiseDiff", negXferQty, "quantityOnHandDiff", negXferQty,
|
||||
"inventoryItemId", inventoryItem.get("inventoryItemId"), "userLogin", userLogin);
|
||||
|
||||
try {
|
||||
Map resultNew = dctx.getDispatcher().runSync("createInventoryItemDetail", createNewDetailMap);
|
||||
Map<String, Object> resultNew = dctx.getDispatcher().runSync("createInventoryItemDetail", createNewDetailMap);
|
||||
if (ServiceUtil.isError(resultNew)) {
|
||||
return ServiceUtil.returnError("Inventory Item Detail create problem in prepare inventory transfer", null, null, resultNew);
|
||||
}
|
||||
Map resultUpdate = dctx.getDispatcher().runSync("createInventoryItemDetail", createUpdateDetailMap);
|
||||
Map<String, Object> resultUpdate = dctx.getDispatcher().runSync("createInventoryItemDetail", createUpdateDetailMap);
|
||||
if (ServiceUtil.isError(resultNew)) {
|
||||
return ServiceUtil.returnError("Inventory Item Detail create problem in prepare inventory transfer", null, null, resultUpdate);
|
||||
}
|
||||
@@ -152,10 +153,10 @@ public class InventoryServices {
|
||||
inventoryItemToClear.refresh();
|
||||
double atp = inventoryItemToClear.get("availableToPromiseTotal") == null ? 0 : inventoryItemToClear.getDouble("availableToPromiseTotal").doubleValue();
|
||||
if (atp != 0) {
|
||||
Map createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(-atp),
|
||||
Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(-atp),
|
||||
"inventoryItemId", inventoryItemToClear.get("inventoryItemId"), "userLogin", userLogin);
|
||||
try {
|
||||
Map result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap);
|
||||
Map<String, Object> result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap);
|
||||
if (ServiceUtil.isError(result)) {
|
||||
return ServiceUtil.returnError("Inventory Item Detail create problem in complete inventory transfer", null, null, result);
|
||||
}
|
||||
@@ -184,7 +185,7 @@ public class InventoryServices {
|
||||
}
|
||||
}
|
||||
|
||||
public static Map completeInventoryTransfer(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> completeInventoryTransfer(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
String inventoryTransferId = (String) context.get("inventoryTransferId");
|
||||
GenericValue inventoryTransfer = null;
|
||||
@@ -216,10 +217,10 @@ public class InventoryServices {
|
||||
// add an adjusting InventoryItemDetail so set ATP back to QOH: ATP = ATP + (QOH - ATP), diff = QOH - ATP
|
||||
double atp = inventoryItem.get("availableToPromiseTotal") == null ? 0 : inventoryItem.getDouble("availableToPromiseTotal").doubleValue();
|
||||
double qoh = inventoryItem.get("quantityOnHandTotal") == null ? 0 : inventoryItem.getDouble("quantityOnHandTotal").doubleValue();
|
||||
Map createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(qoh - atp),
|
||||
Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(qoh - atp),
|
||||
"inventoryItemId", inventoryItem.get("inventoryItemId"), "userLogin", userLogin);
|
||||
try {
|
||||
Map result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap);
|
||||
Map<String, Object> result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap);
|
||||
if (ServiceUtil.isError(result)) {
|
||||
return ServiceUtil.returnError("Inventory Item Detail create problem in complete inventory transfer", null, null, result);
|
||||
}
|
||||
@@ -234,7 +235,7 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
// set the fields on the item
|
||||
Map updateInventoryItemMap = UtilMisc.toMap("inventoryItemId", inventoryItem.getString("inventoryItemId"),
|
||||
Map<String, Object> updateInventoryItemMap = UtilMisc.toMap("inventoryItemId", inventoryItem.getString("inventoryItemId"),
|
||||
"facilityId", inventoryTransfer.get("facilityIdTo"),
|
||||
"containerId", inventoryTransfer.get("containerIdTo"),
|
||||
"locationSeqId", inventoryTransfer.get("locationSeqIdTo"),
|
||||
@@ -256,7 +257,7 @@ public class InventoryServices {
|
||||
}
|
||||
}
|
||||
try {
|
||||
Map result = dctx.getDispatcher().runSync("updateInventoryItem", updateInventoryItemMap);
|
||||
Map<String, Object> result = dctx.getDispatcher().runSync("updateInventoryItem", updateInventoryItemMap);
|
||||
if (ServiceUtil.isError(result)) {
|
||||
return ServiceUtil.returnError("Inventory item store problem", null, null, result);
|
||||
}
|
||||
@@ -277,7 +278,7 @@ public class InventoryServices {
|
||||
return ServiceUtil.returnSuccess();
|
||||
}
|
||||
|
||||
public static Map cancelInventoryTransfer(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> cancelInventoryTransfer(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
String inventoryTransferId = (String) context.get("inventoryTransferId");
|
||||
GenericValue inventoryTransfer = null;
|
||||
@@ -306,11 +307,11 @@ public class InventoryServices {
|
||||
// add an adjusting InventoryItemDetail so set ATP back to QOH: ATP = ATP + (QOH - ATP), diff = QOH - ATP
|
||||
double atp = inventoryItem.get("availableToPromiseTotal") == null ? 0 : inventoryItem.getDouble("availableToPromiseTotal").doubleValue();
|
||||
double qoh = inventoryItem.get("quantityOnHandTotal") == null ? 0 : inventoryItem.getDouble("quantityOnHandTotal").doubleValue();
|
||||
Map createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(qoh - atp),
|
||||
Map<String, Object> createDetailMap = UtilMisc.toMap("availableToPromiseDiff", Double.valueOf(qoh - atp),
|
||||
"inventoryItemId", inventoryItem.get("inventoryItemId"),
|
||||
"userLogin", userLogin);
|
||||
try {
|
||||
Map result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap);
|
||||
Map<String, Object> result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap);
|
||||
if (ServiceUtil.isError(result)) {
|
||||
return ServiceUtil.returnError("Inventory Item Detail create problem in cancel inventory transfer", null, null, result);
|
||||
}
|
||||
@@ -341,7 +342,7 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
/** In spite of the generic name this does the very specific task of checking availability of all back-ordered items and sends notices, etc */
|
||||
public static Map checkInventoryAvailability(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> checkInventoryAvailability(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
@@ -354,11 +355,11 @@ public class InventoryServices {
|
||||
}
|
||||
*/
|
||||
|
||||
Map ordersToUpdate = FastMap.newInstance();
|
||||
Map ordersToCancel = FastMap.newInstance();
|
||||
Map<String, Map<String, Timestamp>> ordersToUpdate = FastMap.newInstance();
|
||||
Map<String, Map<String, Timestamp>> ordersToCancel = FastMap.newInstance();
|
||||
|
||||
// find all inventory items w/ a negative ATP
|
||||
List inventoryItems = null;
|
||||
List<GenericValue> inventoryItems = null;
|
||||
try {
|
||||
EntityExpr ee = EntityCondition.makeCondition("availableToPromiseTotal", EntityOperator.LESS_THAN, Double.valueOf(0));
|
||||
inventoryItems = delegator.findList("InventoryItem", ee, null, null, null, false);
|
||||
@@ -374,12 +375,11 @@ public class InventoryServices {
|
||||
|
||||
Debug.log("OOS Inventory Items: " + inventoryItems.size(), module);
|
||||
|
||||
Iterator itemsIter = inventoryItems.iterator();
|
||||
Iterator<GenericValue> itemsIter = inventoryItems.iterator();
|
||||
while (itemsIter.hasNext()) {
|
||||
GenericValue inventoryItem = (GenericValue) itemsIter.next();
|
||||
|
||||
GenericValue inventoryItem = itemsIter.next();
|
||||
// get the incomming shipment information for the item
|
||||
List shipmentAndItems = null;
|
||||
List<GenericValue> shipmentAndItems = null;
|
||||
try {
|
||||
List<EntityExpr> exprs = FastList.newInstance();
|
||||
exprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, inventoryItem.get("productId")));
|
||||
@@ -395,7 +395,7 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
// get the reservations in order of newest first
|
||||
List reservations = null;
|
||||
List<GenericValue> reservations = null;
|
||||
try {
|
||||
reservations = inventoryItem.getRelated("OrderItemShipGrpInvRes", null, UtilMisc.toList("-reservedDatetime"));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -414,9 +414,9 @@ public class InventoryServices {
|
||||
double availableBeforeReserved = inventoryItem.getDouble("availableToPromiseTotal").doubleValue();
|
||||
|
||||
// go through all the reservations in order
|
||||
Iterator ri = reservations.iterator();
|
||||
Iterator<GenericValue> ri = reservations.iterator();
|
||||
while (ri.hasNext()) {
|
||||
GenericValue reservation = (GenericValue) ri.next();
|
||||
GenericValue reservation = ri.next();
|
||||
String orderId = reservation.getString("orderId");
|
||||
String orderItemSeqId = reservation.getString("orderItemSeqId");
|
||||
Timestamp promisedDate = reservation.getTimestamp("promisedDatetime");
|
||||
@@ -436,9 +436,9 @@ public class InventoryServices {
|
||||
// find the next possible ship date
|
||||
Timestamp nextShipDate = null;
|
||||
double availableAtTime = 0.00;
|
||||
Iterator si = shipmentAndItems.iterator();
|
||||
Iterator<GenericValue> si = shipmentAndItems.iterator();
|
||||
while (si.hasNext()) {
|
||||
GenericValue shipmentItem = (GenericValue) si.next();
|
||||
GenericValue shipmentItem = si.next();
|
||||
availableAtTime += shipmentItem.getDouble("quantity").doubleValue();
|
||||
if (availableAtTime >= availableBeforeReserved) {
|
||||
nextShipDate = shipmentItem.getTimestamp("estimatedArrivalDate");
|
||||
@@ -466,7 +466,7 @@ public class InventoryServices {
|
||||
} else {
|
||||
// we cannot ship by the promised date; need to notify the customer
|
||||
Debug.log("We won't ship on time, getting notification info", module);
|
||||
Map notifyItems = (Map) ordersToUpdate.get(orderId);
|
||||
Map<String, Timestamp> notifyItems = ordersToUpdate.get(orderId);
|
||||
if (notifyItems == null) {
|
||||
notifyItems = FastMap.newInstance();
|
||||
}
|
||||
@@ -494,7 +494,7 @@ public class InventoryServices {
|
||||
if (needToCancel) {
|
||||
// queue the item to be cancelled
|
||||
Debug.log("Flagging the item to auto-cancel", module);
|
||||
Map cancelItems = (Map) ordersToCancel.get(orderId);
|
||||
Map<String, Timestamp> cancelItems = ordersToCancel.get(orderId);
|
||||
if (cancelItems == null) {
|
||||
cancelItems = FastMap.newInstance();
|
||||
}
|
||||
@@ -518,17 +518,17 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
// all items to cancel will also be in the notify list so start with that
|
||||
List ordersToNotify = FastList.newInstance();
|
||||
Set orderSet = ordersToUpdate.keySet();
|
||||
Iterator orderIter = orderSet.iterator();
|
||||
List<String> ordersToNotify = FastList.newInstance();
|
||||
Set<String> orderSet = ordersToUpdate.keySet();
|
||||
Iterator<String> orderIter = orderSet.iterator();
|
||||
while (orderIter.hasNext()) {
|
||||
String orderId = (String) orderIter.next();
|
||||
Map backOrderedItems = (Map) ordersToUpdate.get(orderId);
|
||||
Map cancelItems = (Map) ordersToCancel.get(orderId);
|
||||
String orderId = orderIter.next();
|
||||
Map<String, Timestamp> backOrderedItems = ordersToUpdate.get(orderId);
|
||||
Map<String, Timestamp> cancelItems = ordersToCancel.get(orderId);
|
||||
boolean cancelAll = false;
|
||||
Timestamp cancelAllTime = null;
|
||||
|
||||
List orderItemShipGroups = null;
|
||||
List<GenericValue> orderItemShipGroups = null;
|
||||
try {
|
||||
orderItemShipGroups= delegator.findByAnd("OrderItemShipGroup",
|
||||
UtilMisc.toMap("orderId", orderId));
|
||||
@@ -536,11 +536,11 @@ public class InventoryServices {
|
||||
Debug.logError(e, "Cannot get OrderItemShipGroups from orderId" + orderId, module);
|
||||
}
|
||||
|
||||
Iterator orderItemShipGroupsIter = orderItemShipGroups.iterator();
|
||||
Iterator<GenericValue> orderItemShipGroupsIter = orderItemShipGroups.iterator();
|
||||
while (orderItemShipGroupsIter.hasNext()) {
|
||||
GenericValue orderItemShipGroup = (GenericValue)orderItemShipGroupsIter.next();
|
||||
List orderItems = new java.util.Vector();
|
||||
List orderItemShipGroupAssoc = null;
|
||||
GenericValue orderItemShipGroup = orderItemShipGroupsIter.next();
|
||||
List<GenericValue> orderItems = FastList.newInstance();
|
||||
List<GenericValue> orderItemShipGroupAssoc = null;
|
||||
try {
|
||||
orderItemShipGroupAssoc =
|
||||
delegator.findByAnd("OrderItemShipGroupAssoc",
|
||||
@@ -549,9 +549,9 @@ public class InventoryServices {
|
||||
"orderId",
|
||||
orderId));
|
||||
|
||||
Iterator assocIter = orderItemShipGroupAssoc.iterator();
|
||||
Iterator<GenericValue> assocIter = orderItemShipGroupAssoc.iterator();
|
||||
while (assocIter.hasNext()) {
|
||||
GenericValue assoc = (GenericValue)assocIter.next();
|
||||
GenericValue assoc = assocIter.next();
|
||||
GenericValue orderItem = assoc.getRelatedOne("OrderItem");
|
||||
if (orderItem != null) {
|
||||
orderItems.add(orderItem);
|
||||
@@ -581,10 +581,10 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
if (orderItems != null) {
|
||||
List toBeStored = FastList.newInstance();
|
||||
Iterator orderItemsIter = orderItems.iterator();
|
||||
List<GenericValue> toBeStored = FastList.newInstance();
|
||||
Iterator<GenericValue> orderItemsIter = orderItems.iterator();
|
||||
while (orderItemsIter.hasNext()) {
|
||||
GenericValue orderItem = (GenericValue) orderItemsIter.next();
|
||||
GenericValue orderItem = orderItemsIter.next();
|
||||
String orderItemSeqId = orderItem.getString("orderItemSeqId");
|
||||
Timestamp shipDate = (Timestamp) backOrderedItems.get(orderItemSeqId);
|
||||
Timestamp cancelDate = (Timestamp) cancelItems.get(orderItemSeqId);
|
||||
@@ -624,9 +624,9 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
// send off a notification for each order
|
||||
Iterator orderNotifyIter = ordersToNotify.iterator();
|
||||
Iterator<String> orderNotifyIter = ordersToNotify.iterator();
|
||||
while (orderNotifyIter.hasNext()) {
|
||||
String orderId = (String) orderNotifyIter.next();
|
||||
String orderId = orderNotifyIter.next();
|
||||
|
||||
try {
|
||||
dispatcher.runAsync("sendOrderBackorderNotification", UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin));
|
||||
@@ -643,9 +643,9 @@ public class InventoryServices {
|
||||
* Get Inventory Available for a Product based on the list of associated products. The final ATP and QOH will
|
||||
* be the minimum of all the associated products' inventory divided by their ProductAssoc.quantity
|
||||
* */
|
||||
public static Map getProductInventoryAvailableFromAssocProducts(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> getProductInventoryAvailableFromAssocProducts(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
List productAssocList = (List) context.get("assocProducts");
|
||||
List<GenericValue> productAssocList = UtilGenerics.checkList(context.get("assocProducts"));
|
||||
String facilityId = (String)context.get("facilityId");
|
||||
String statusId = (String)context.get("statusId");
|
||||
|
||||
@@ -659,7 +659,7 @@ public class InventoryServices {
|
||||
|
||||
// loop through each associated product.
|
||||
for (int i = 0; productAssocList.size() > i; i++) {
|
||||
GenericValue productAssoc = (GenericValue) productAssocList.get(i);
|
||||
GenericValue productAssoc = productAssocList.get(i);
|
||||
String productIdTo = productAssoc.getString("productIdTo");
|
||||
Double assocQuantity = productAssoc.getDouble("quantity");
|
||||
|
||||
@@ -670,9 +670,9 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
// figure out the inventory available for this associated product
|
||||
Map resultOutput = null;
|
||||
Map<String, Object> resultOutput = null;
|
||||
try {
|
||||
Map inputMap = UtilMisc.toMap("productId", productIdTo, "statusId", statusId);
|
||||
Map<String, String> inputMap = UtilMisc.toMap("productId", productIdTo, "statusId", statusId);
|
||||
if (facilityId != null) {
|
||||
inputMap.put("facilityId", facilityId);
|
||||
resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", inputMap);
|
||||
@@ -708,26 +708,26 @@ public class InventoryServices {
|
||||
availableToPromiseTotal = Double.valueOf(minAvailableToPromiseTotal);
|
||||
}
|
||||
|
||||
Map result = ServiceUtil.returnSuccess();
|
||||
Map<String, Object> result = ServiceUtil.returnSuccess();
|
||||
result.put("availableToPromiseTotal", availableToPromiseTotal);
|
||||
result.put("quantityOnHandTotal", quantityOnHandTotal);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static Map getProductInventorySummaryForItems(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> getProductInventorySummaryForItems(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
List orderItems = (List) context.get("orderItems");
|
||||
List<GenericValue> orderItems = UtilGenerics.checkList(context.get("orderItems"));
|
||||
String facilityId = (String) context.get("facilityId");
|
||||
Map atpMap = FastMap.newInstance();
|
||||
Map qohMap = FastMap.newInstance();
|
||||
Map mktgPkgAtpMap = FastMap.newInstance();
|
||||
Map mktgPkgQohMap = FastMap.newInstance();
|
||||
Map results = ServiceUtil.returnSuccess();
|
||||
Map<String, Double> atpMap = FastMap.newInstance();
|
||||
Map<String, Double> qohMap = FastMap.newInstance();
|
||||
Map<String, Double> mktgPkgAtpMap = FastMap.newInstance();
|
||||
Map<String, Double> mktgPkgQohMap = FastMap.newInstance();
|
||||
Map<String, Object> results = ServiceUtil.returnSuccess();
|
||||
|
||||
// get a list of all available facilities for looping
|
||||
List facilities = null;
|
||||
List<GenericValue> facilities = null;
|
||||
try {
|
||||
if (facilityId != null) {
|
||||
facilities = delegator.findByAnd("Facility", UtilMisc.toMap("facilityId", facilityId));
|
||||
@@ -739,9 +739,9 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
// loop through all the order items
|
||||
Iterator iter = orderItems.iterator();
|
||||
Iterator<GenericValue> iter = orderItems.iterator();
|
||||
while (iter.hasNext()) {
|
||||
GenericValue orderItem = (GenericValue) iter.next();
|
||||
GenericValue orderItem = iter.next();
|
||||
String productId = orderItem.getString("productId");
|
||||
|
||||
if ((productId == null) || productId.equals("")) continue;
|
||||
@@ -758,13 +758,13 @@ public class InventoryServices {
|
||||
double qoh = 0.0;
|
||||
double mktgPkgAtp = 0.0;
|
||||
double mktgPkgQoh = 0.0;
|
||||
Iterator facilityIter = facilities.iterator();
|
||||
Iterator<GenericValue> facilityIter = facilities.iterator();
|
||||
|
||||
// loop through all the facilities
|
||||
while (facilityIter.hasNext()) {
|
||||
GenericValue facility = (GenericValue) facilityIter.next();
|
||||
Map invResult = null;
|
||||
Map mktgPkgInvResult = null;
|
||||
GenericValue facility = facilityIter.next();
|
||||
Map<String, Object> invResult = null;
|
||||
Map<String, Object> mktgPkgInvResult = null;
|
||||
|
||||
// get both the real ATP/QOH available and the quantities available from marketing packages
|
||||
try {
|
||||
@@ -808,7 +808,7 @@ public class InventoryServices {
|
||||
}
|
||||
|
||||
|
||||
public static Map getProductInventoryAndFacilitySummary(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> getProductInventoryAndFacilitySummary(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Timestamp checkTime = (Timestamp)context.get("checkTime");
|
||||
@@ -817,10 +817,10 @@ public class InventoryServices {
|
||||
String minimumStock = (String)context.get("minimumStock");
|
||||
String statusId = (String)context.get("statusId");
|
||||
|
||||
Map result = FastMap.newInstance();
|
||||
Map resultOutput = FastMap.newInstance();
|
||||
Map<String, Object> result = FastMap.newInstance();
|
||||
Map<String, Object> resultOutput = FastMap.newInstance();
|
||||
|
||||
Map contextInput = UtilMisc.toMap("productId", productId, "facilityId", facilityId, "statusId", statusId);
|
||||
Map<String, String> contextInput = UtilMisc.toMap("productId", productId, "facilityId", facilityId, "statusId", statusId);
|
||||
GenericValue product = null;
|
||||
try {
|
||||
product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
|
||||
@@ -870,17 +870,17 @@ public class InventoryServices {
|
||||
result.put("offsetQOHQtyAvailable", Integer.valueOf(offsetQOHQtyAvailable));
|
||||
result.put("offsetATPQtyAvailable", Integer.valueOf(offsetATPQtyAvailable));
|
||||
|
||||
List productPrices = null;
|
||||
List<GenericValue> productPrices = null;
|
||||
try {
|
||||
productPrices = (List)delegator.findByAndCache("ProductPrice", UtilMisc.toMap("productId",productId), UtilMisc.toList("-fromDate"));
|
||||
productPrices = delegator.findByAndCache("ProductPrice", UtilMisc.toMap("productId",productId), UtilMisc.toList("-fromDate"));
|
||||
} catch (GenericEntityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Iterator pricesIt = productPrices.iterator();
|
||||
Iterator<GenericValue> pricesIt = productPrices.iterator();
|
||||
//change this for product price
|
||||
while (pricesIt.hasNext()) {
|
||||
GenericValue onePrice = (GenericValue)pricesIt.next();
|
||||
GenericValue onePrice = pricesIt.next();
|
||||
if(onePrice.getString("productPriceTypeId").equals("DEFAULT_PRICE")){ //defaultPrice
|
||||
result.put("defultPrice", onePrice.getDouble("price"));
|
||||
}else if(onePrice.getString("productPriceTypeId").equals("WHOLESALE_PRICE")){//
|
||||
@@ -951,7 +951,7 @@ public class InventoryServices {
|
||||
// Sum the sales usage quantities found
|
||||
double salesUsageQuantity = 0;
|
||||
GenericValue salesUsageItem = null;
|
||||
while((salesUsageItem = (GenericValue) salesUsageIt.next()) != null) {
|
||||
while((salesUsageItem = salesUsageIt.next()) != null) {
|
||||
if (salesUsageItem.get("quantity") != null) {
|
||||
try {
|
||||
salesUsageQuantity += salesUsageItem.getDouble("quantity").doubleValue();
|
||||
@@ -988,7 +988,7 @@ public class InventoryServices {
|
||||
// Sum the production usage quantities found
|
||||
double productionUsageQuantity = 0;
|
||||
GenericValue productionUsageItem = null;
|
||||
while((productionUsageItem = (GenericValue) productionUsageIt.next()) != null) {
|
||||
while((productionUsageItem = productionUsageIt.next()) != null) {
|
||||
if (productionUsageItem.get("quantity") != null) {
|
||||
try {
|
||||
productionUsageQuantity += productionUsageItem.getDouble("quantity").doubleValue();
|
||||
|
||||
@@ -47,9 +47,9 @@ public class InventoryWorker {
|
||||
* @param delegator
|
||||
* @return
|
||||
*/
|
||||
public static List getOutstandingPurchaseOrders(String productId, GenericDelegator delegator) {
|
||||
public static List<GenericValue> getOutstandingPurchaseOrders(String productId, GenericDelegator delegator) {
|
||||
try {
|
||||
List purchaseOrderConditions = UtilMisc.toList(EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"),
|
||||
List<EntityCondition> purchaseOrderConditions = UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"),
|
||||
EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED"),
|
||||
EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"),
|
||||
EntityCondition.makeCondition("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED"),
|
||||
@@ -57,7 +57,7 @@ public class InventoryWorker {
|
||||
EntityCondition.makeCondition("itemStatusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED"));
|
||||
purchaseOrderConditions.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER"));
|
||||
purchaseOrderConditions.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId));
|
||||
List purchaseOrders = delegator.findList("OrderHeaderAndItems", EntityCondition.makeCondition(purchaseOrderConditions, EntityOperator.AND),
|
||||
List<GenericValue> purchaseOrders = delegator.findList("OrderHeaderAndItems", EntityCondition.makeCondition(purchaseOrderConditions, EntityOperator.AND),
|
||||
null, UtilMisc.toList("estimatedDeliveryDate DESC", "orderDate"), null, false);
|
||||
return purchaseOrders;
|
||||
} catch (GenericEntityException ex) {
|
||||
@@ -74,12 +74,12 @@ public class InventoryWorker {
|
||||
*/
|
||||
public static double getOutstandingPurchasedQuantity(String productId, GenericDelegator delegator) {
|
||||
double qty = 0.0;
|
||||
List purchaseOrders = getOutstandingPurchaseOrders(productId, delegator);
|
||||
List<GenericValue> purchaseOrders = getOutstandingPurchaseOrders(productId, delegator);
|
||||
if (UtilValidate.isEmpty(purchaseOrders)) {
|
||||
return qty;
|
||||
} else {
|
||||
for (Iterator pOi = purchaseOrders.iterator(); pOi.hasNext();) {
|
||||
GenericValue nextOrder = (GenericValue) pOi.next();
|
||||
for (Iterator<GenericValue> pOi = purchaseOrders.iterator(); pOi.hasNext();) {
|
||||
GenericValue nextOrder = pOi.next();
|
||||
if (nextOrder.get("quantity") != null) {
|
||||
double itemQuantity = nextOrder.getDouble("quantity").doubleValue();
|
||||
double cancelQuantity = 0.0;
|
||||
@@ -106,9 +106,9 @@ public class InventoryWorker {
|
||||
* @param delegator The delegator to use
|
||||
* @return Map of productIds to quantities outstanding.
|
||||
*/
|
||||
public static Map getOutstandingProductQuantities(Collection productIds, String orderTypeId, GenericDelegator delegator) {
|
||||
Set fieldsToSelect = UtilMisc.toSet("productId", "quantityOpen");
|
||||
List condList = UtilMisc.toList(
|
||||
public static Map<String, Double> getOutstandingProductQuantities(Collection<String> productIds, String orderTypeId, GenericDelegator delegator) {
|
||||
Set<String> fieldsToSelect = UtilMisc.toSet("productId", "quantityOpen");
|
||||
List<EntityCondition> condList = UtilMisc.<EntityCondition>toList(
|
||||
EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, orderTypeId),
|
||||
EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"),
|
||||
EntityCondition.makeCondition("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"),
|
||||
@@ -122,11 +122,11 @@ public class InventoryWorker {
|
||||
condList.add(EntityCondition.makeCondition("orderItemStatusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED"));
|
||||
EntityConditionList conditions = EntityCondition.makeCondition(condList, EntityOperator.AND);
|
||||
|
||||
Map results = FastMap.newInstance();
|
||||
Map<String, Double> results = FastMap.newInstance();
|
||||
try {
|
||||
List orderedProducts = delegator.findList("OrderItemQuantityReportGroupByProduct", conditions, fieldsToSelect, null, null, false);
|
||||
for (Iterator iter = orderedProducts.iterator(); iter.hasNext(); ) {
|
||||
GenericValue value = (GenericValue) iter.next();
|
||||
List<GenericValue> orderedProducts = delegator.findList("OrderItemQuantityReportGroupByProduct", conditions, fieldsToSelect, null, null, false);
|
||||
for (Iterator<GenericValue> iter = orderedProducts.iterator(); iter.hasNext(); ) {
|
||||
GenericValue value = iter.next();
|
||||
results.put(value.getString("productId"), value.getDouble("quantityOpen"));
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -136,12 +136,12 @@ public class InventoryWorker {
|
||||
}
|
||||
|
||||
/** As above, but for sales orders */
|
||||
public static Map getOutstandingProductQuantitiesForSalesOrders(Collection productIds, GenericDelegator delegator) {
|
||||
public static Map<String, Double> getOutstandingProductQuantitiesForSalesOrders(Collection<String> productIds, GenericDelegator delegator) {
|
||||
return getOutstandingProductQuantities(productIds, "SALES_ORDER", delegator);
|
||||
}
|
||||
|
||||
/** As above, but for purhcase orders */
|
||||
public static Map getOutstandingProductQuantitiesForPurchaseOrders(Collection productIds, GenericDelegator delegator) {
|
||||
public static Map<String, Double> getOutstandingProductQuantitiesForPurchaseOrders(Collection<String> productIds, GenericDelegator delegator) {
|
||||
return getOutstandingProductQuantities(productIds, "PURCHASE_ORDER", delegator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import javolution.util.FastMap;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilDateTime;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilMisc;
|
||||
import org.ofbiz.base.util.UtilNumber;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
@@ -77,7 +78,7 @@ public class PriceServices {
|
||||
* <li>checkIncludeVat
|
||||
* </ul>
|
||||
*/
|
||||
public static Map calculateProductPrice(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> calculateProductPrice(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
boolean optimizeForLargeRuleSet = false;
|
||||
|
||||
// UtilTimer utilTimer = new UtilTimer();
|
||||
@@ -86,7 +87,7 @@ public class PriceServices {
|
||||
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Map result = FastMap.newInstance();
|
||||
Map<String, Object> result = FastMap.newInstance();
|
||||
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
|
||||
|
||||
GenericValue product = (GenericValue) context.get("product");
|
||||
@@ -95,7 +96,7 @@ public class PriceServices {
|
||||
String webSiteId = (String) context.get("webSiteId");
|
||||
String checkIncludeVat = (String) context.get("checkIncludeVat");
|
||||
String surveyResponseId = (String) context.get("surveyResponseId");
|
||||
Map customAttributes = (Map) context.get("customAttributes");
|
||||
Map<String, Object> customAttributes = UtilGenerics.checkMap(context.get("customAttributes"));
|
||||
|
||||
String findAllQuantityPricesStr = (String) context.get("findAllQuantityPrices");
|
||||
boolean findAllQuantityPrices = "Y".equals(findAllQuantityPricesStr);
|
||||
@@ -120,7 +121,7 @@ public class PriceServices {
|
||||
productStoreGroupId = productStore.getString("primaryStoreGroupId");
|
||||
} else {
|
||||
// no ProductStore.primaryStoreGroupId, try ProductStoreGroupMember
|
||||
List productStoreGroupMemberList = delegator.findByAndCache("ProductStoreGroupMember", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNum", "-fromDate"));
|
||||
List<GenericValue> productStoreGroupMemberList = delegator.findByAndCache("ProductStoreGroupMember", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNum", "-fromDate"));
|
||||
productStoreGroupMemberList = EntityUtil.filterByDate(productStoreGroupMemberList, true);
|
||||
if (productStoreGroupMemberList.size() > 0) {
|
||||
GenericValue productStoreGroupMember = EntityUtil.getFirst(productStoreGroupMemberList);
|
||||
@@ -169,7 +170,7 @@ public class PriceServices {
|
||||
}
|
||||
|
||||
// get prices for virtual product if one is found; get all ProductPrice entities for this productId and currencyUomId
|
||||
List virtualProductPrices = null;
|
||||
List<GenericValue> virtualProductPrices = null;
|
||||
if (virtualProductId != null) {
|
||||
try {
|
||||
virtualProductPrices = delegator.findByAndCache("ProductPrice", UtilMisc.toMap("productId", virtualProductId, "currencyUomId", currencyUomId, "productStoreGroupId", productStoreGroupId), UtilMisc.toList("-fromDate"));
|
||||
@@ -198,7 +199,7 @@ public class PriceServices {
|
||||
|
||||
Double amountDbl = (Double) context.get("amount");
|
||||
|
||||
List productPriceEcList = FastList.newInstance();
|
||||
List<EntityCondition> productPriceEcList = FastList.newInstance();
|
||||
productPriceEcList.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId));
|
||||
// this funny statement is for backward compatibility purposes; the productPricePurposeId is a new pk field on the ProductPrice entity and in order databases may not be populated, until the pk is updated and such; this will ease the transition somewhat
|
||||
if ("PURCHASE".equals(productPricePurposeId)) {
|
||||
@@ -217,7 +218,7 @@ public class PriceServices {
|
||||
EntityCondition productPriceEc = EntityCondition.makeCondition(productPriceEcList, EntityOperator.AND);
|
||||
|
||||
// for prices, get all ProductPrice entities for this productId and currencyUomId
|
||||
List productPrices = null;
|
||||
List<GenericValue> productPrices = null;
|
||||
try {
|
||||
productPrices = delegator.findList("ProductPrice", productPriceEc, null, UtilMisc.toList("-fromDate"), null, true);
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -226,13 +227,13 @@ public class PriceServices {
|
||||
productPrices = EntityUtil.filterByDate(productPrices, true);
|
||||
|
||||
// ===== get the prices we need: list, default, average cost, promo, min, max =====
|
||||
List listPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
|
||||
List<GenericValue> listPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
|
||||
GenericValue listPriceValue = EntityUtil.getFirst(listPrices);
|
||||
if (listPrices != null && listPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + listPriceValue.getDouble("price"), module);
|
||||
}
|
||||
|
||||
List defaultPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
List<GenericValue> defaultPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
GenericValue defaultPriceValue = EntityUtil.getFirst(defaultPrices);
|
||||
if (defaultPrices != null && defaultPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + defaultPriceValue.getDouble("price"), module);
|
||||
@@ -243,7 +244,7 @@ public class PriceServices {
|
||||
// ProductPrice entity.
|
||||
if (UtilValidate.isNotEmpty(agreementId)) {
|
||||
try {
|
||||
List agreementPrices = delegator.findByAnd("AgreementItemAndProductAppl", UtilMisc.toMap("agreementId", agreementId, "productId", productId, "currencyUomId", currencyUomId));
|
||||
List<GenericValue> agreementPrices = delegator.findByAnd("AgreementItemAndProductAppl", UtilMisc.toMap("agreementId", agreementId, "productId", productId, "currencyUomId", currencyUomId));
|
||||
GenericValue agreementPriceValue = EntityUtil.getFirst(agreementPrices);
|
||||
if (agreementPriceValue != null && agreementPriceValue.get("price") != null) {
|
||||
defaultPriceValue = agreementPriceValue;
|
||||
@@ -255,43 +256,43 @@ public class PriceServices {
|
||||
}
|
||||
}
|
||||
|
||||
List competitivePrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "COMPETITIVE_PRICE"));
|
||||
List<GenericValue> competitivePrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "COMPETITIVE_PRICE"));
|
||||
GenericValue competitivePriceValue = EntityUtil.getFirst(competitivePrices);
|
||||
if (competitivePrices != null && competitivePrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one COMPETITIVE_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + competitivePriceValue.getDouble("price"), module);
|
||||
}
|
||||
|
||||
List averageCosts = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
|
||||
List<GenericValue> averageCosts = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
|
||||
GenericValue averageCostValue = EntityUtil.getFirst(averageCosts);
|
||||
if (averageCosts != null && averageCosts.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + averageCostValue.getDouble("price"), module);
|
||||
}
|
||||
|
||||
List promoPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
|
||||
List<GenericValue> promoPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
|
||||
GenericValue promoPriceValue = EntityUtil.getFirst(promoPrices);
|
||||
if (promoPrices != null && promoPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + promoPriceValue.getDouble("price"), module);
|
||||
}
|
||||
|
||||
List minimumPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
|
||||
List<GenericValue> minimumPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
|
||||
GenericValue minimumPriceValue = EntityUtil.getFirst(minimumPrices);
|
||||
if (minimumPrices != null && minimumPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + minimumPriceValue.getDouble("price"), module);
|
||||
}
|
||||
|
||||
List maximumPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
|
||||
List<GenericValue> maximumPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
|
||||
GenericValue maximumPriceValue = EntityUtil.getFirst(maximumPrices);
|
||||
if (maximumPrices != null && maximumPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + maximumPriceValue.getDouble("price"), module);
|
||||
}
|
||||
|
||||
List wholesalePrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
|
||||
List<GenericValue> wholesalePrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
|
||||
GenericValue wholesalePriceValue = EntityUtil.getFirst(wholesalePrices);
|
||||
if (wholesalePrices != null && wholesalePrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + wholesalePriceValue.getDouble("price"), module);
|
||||
}
|
||||
|
||||
List specialPromoPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
|
||||
List<GenericValue> specialPromoPrices = EntityUtil.filterByAnd(productPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
|
||||
GenericValue specialPromoPriceValue = EntityUtil.getFirst(specialPromoPrices);
|
||||
if (specialPromoPrices != null && specialPromoPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + productId + ", using the latest found with price: " + specialPromoPriceValue.getDouble("price"), module);
|
||||
@@ -300,56 +301,56 @@ public class PriceServices {
|
||||
// if any of these prices is missing and this product is a variant, default to the corresponding price on the virtual product
|
||||
if (UtilValidate.isNotEmpty(virtualProductPrices)) {
|
||||
if (listPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
|
||||
listPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + listPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (defaultPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
defaultPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + defaultPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (averageCostValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
|
||||
averageCostValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + averageCostValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (promoPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
|
||||
promoPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + promoPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (minimumPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
|
||||
minimumPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + minimumPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (maximumPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
|
||||
maximumPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + maximumPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (wholesalePriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
|
||||
wholesalePriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + wholesalePriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (specialPromoPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(virtualProductPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
|
||||
specialPromoPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + virtualProductId + ", using the latest found with price: " + specialPromoPriceValue.getDouble("price"), module);
|
||||
@@ -365,16 +366,16 @@ public class PriceServices {
|
||||
|
||||
//use the cache to find the variant with the lowest default price
|
||||
try {
|
||||
List variantAssocList = EntityUtil.filterByDate(delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate")));
|
||||
Iterator variantAssocIter = variantAssocList.iterator();
|
||||
List<GenericValue> variantAssocList = EntityUtil.filterByDate(delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate")));
|
||||
Iterator<GenericValue> variantAssocIter = variantAssocList.iterator();
|
||||
double minDefaultPrice = Double.MAX_VALUE;
|
||||
List variantProductPrices = null;
|
||||
List<GenericValue> variantProductPrices = null;
|
||||
String variantProductId = null;
|
||||
while (variantAssocIter.hasNext()) {
|
||||
GenericValue variantAssoc = (GenericValue) variantAssocIter.next();
|
||||
GenericValue variantAssoc = variantAssocIter.next();
|
||||
String curVariantProductId = variantAssoc.getString("productIdTo");
|
||||
List curVariantPriceList = EntityUtil.filterByDate(delegator.findByAndCache("ProductPrice", UtilMisc.toMap("productId", curVariantProductId), UtilMisc.toList("-fromDate")), nowTimestamp);
|
||||
List tempDefaultPriceList = EntityUtil.filterByAnd(curVariantPriceList, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
List<GenericValue> curVariantPriceList = EntityUtil.filterByDate(delegator.findByAndCache("ProductPrice", UtilMisc.toMap("productId", curVariantProductId), UtilMisc.toList("-fromDate")), nowTimestamp);
|
||||
List<GenericValue> tempDefaultPriceList = EntityUtil.filterByAnd(curVariantPriceList, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
GenericValue curDefaultPriceValue = EntityUtil.getFirst(tempDefaultPriceList);
|
||||
if (curDefaultPriceValue != null) {
|
||||
Double curDefaultPrice = curDefaultPriceValue.getDouble("price");
|
||||
@@ -397,63 +398,63 @@ public class PriceServices {
|
||||
if (variantProductPrices != null) {
|
||||
// we have some other options, give 'em a go...
|
||||
if (listPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "LIST_PRICE"));
|
||||
listPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one LIST_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + listPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (defaultPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
defaultPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one DEFAULT_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + defaultPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (competitivePriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "COMPETITIVE_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "COMPETITIVE_PRICE"));
|
||||
competitivePriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one COMPETITIVE_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + competitivePriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (averageCostValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
|
||||
averageCostValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one AVERAGE_COST with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + averageCostValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (promoPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "PROMO_PRICE"));
|
||||
promoPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + promoPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (minimumPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "MINIMUM_PRICE"));
|
||||
minimumPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one MINIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + minimumPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (maximumPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "MAXIMUM_PRICE"));
|
||||
maximumPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one MAXIMUM_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + maximumPriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (wholesalePriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "WHOLESALE_PRICE"));
|
||||
wholesalePriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one WHOLESALE_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + wholesalePriceValue.getDouble("price"), module);
|
||||
}
|
||||
}
|
||||
if (specialPromoPriceValue == null) {
|
||||
List virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
|
||||
List<GenericValue> virtualTempPrices = EntityUtil.filterByAnd(variantProductPrices, UtilMisc.toMap("productPriceTypeId", "SPECIAL_PROMO_PRICE"));
|
||||
specialPromoPriceValue = EntityUtil.getFirst(virtualTempPrices);
|
||||
if (virtualTempPrices != null && virtualTempPrices.size() > 1) {
|
||||
if (Debug.infoOn()) Debug.logInfo("There is more than one SPECIAL_PROMO_PRICE with the currencyUomId " + currencyUomId + " and productId " + variantProductId + ", using the latest found with price: " + wholesalePriceValue.getDouble("price"), module);
|
||||
@@ -482,7 +483,7 @@ public class PriceServices {
|
||||
|
||||
boolean validPriceFound = false;
|
||||
double defaultPrice = 0;
|
||||
List orderItemPriceInfos = FastList.newInstance();
|
||||
List<GenericValue> orderItemPriceInfos = FastList.newInstance();
|
||||
if (defaultPriceValue != null) {
|
||||
// If a price calc formula (service) is specified, then use it to get the unit price
|
||||
if ("ProductPrice".equals(defaultPriceValue.getEntityName()) && UtilValidate.isNotEmpty(defaultPriceValue.getString("customPriceCalcService"))) {
|
||||
@@ -493,8 +494,8 @@ public class PriceServices {
|
||||
Debug.logError(gee, "An error occurred while getting the customPriceCalcService", module);
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(customMethod) && UtilValidate.isNotEmpty(customMethod.getString("customMethodName"))) {
|
||||
Map inMap = UtilMisc.toMap("userLogin", (GenericValue) context.get("userLogin"), "product", product);
|
||||
inMap.put("initialPrice", (Double)defaultPriceValue.get("price"));
|
||||
Map<String, Object> inMap = UtilMisc.toMap("userLogin", context.get("userLogin"), "product", product);
|
||||
inMap.put("initialPrice", defaultPriceValue.get("price"));
|
||||
inMap.put("currencyUomId", currencyUomId);
|
||||
inMap.put("quantity", quantityDbl);
|
||||
inMap.put("amount", amountDbl);
|
||||
@@ -505,10 +506,10 @@ public class PriceServices {
|
||||
inMap.put("customAttributes", customAttributes);
|
||||
}
|
||||
try {
|
||||
Map outMap = dispatcher.runSync(customMethod.getString("customMethodName"), inMap);
|
||||
Map<String, Object> outMap = dispatcher.runSync(customMethod.getString("customMethodName"), inMap);
|
||||
if (!ServiceUtil.isError(outMap)) {
|
||||
Double calculatedDefaultPrice = (Double)outMap.get("price");
|
||||
orderItemPriceInfos = (List)outMap.get("orderItemPriceInfos");
|
||||
orderItemPriceInfos = UtilGenerics.checkList(outMap.get("orderItemPriceInfos"));
|
||||
if (UtilValidate.isNotEmpty(calculatedDefaultPrice)) {
|
||||
defaultPrice = calculatedDefaultPrice.doubleValue();
|
||||
validPriceFound = true;
|
||||
@@ -554,30 +555,30 @@ public class PriceServices {
|
||||
result.put("isSale", Boolean.FALSE);
|
||||
result.put("orderItemPriceInfos", orderItemPriceInfos);
|
||||
|
||||
Map errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
Map<String, Object> errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
checkIncludeVat, currencyUomId, productId, quantity, partyId, dispatcher);
|
||||
if (errorResult != null) return errorResult;
|
||||
} else {
|
||||
try {
|
||||
List allProductPriceRules = makeProducePriceRuleList(delegator, optimizeForLargeRuleSet, productId, virtualProductId, prodCatalogId, productStoreGroupId, webSiteId, partyId, currencyUomId);
|
||||
List<GenericValue> allProductPriceRules = makeProducePriceRuleList(delegator, optimizeForLargeRuleSet, productId, virtualProductId, prodCatalogId, productStoreGroupId, webSiteId, partyId, currencyUomId);
|
||||
|
||||
List quantityProductPriceRules = null;
|
||||
List nonQuantityProductPriceRules = null;
|
||||
List<GenericValue> quantityProductPriceRules = null;
|
||||
List<GenericValue> nonQuantityProductPriceRules = null;
|
||||
if (findAllQuantityPrices) {
|
||||
// split into list with quantity conditions and list without, then iterate through each quantity cond one
|
||||
quantityProductPriceRules = FastList.newInstance();
|
||||
nonQuantityProductPriceRules = FastList.newInstance();
|
||||
Iterator productPriceRulesIter = allProductPriceRules.iterator();
|
||||
Iterator<GenericValue> productPriceRulesIter = allProductPriceRules.iterator();
|
||||
while (productPriceRulesIter.hasNext()) {
|
||||
GenericValue productPriceRule = (GenericValue) productPriceRulesIter.next();
|
||||
List productPriceCondList = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("productPriceRuleId", productPriceRule.get("productPriceRuleId")));
|
||||
GenericValue productPriceRule = productPriceRulesIter.next();
|
||||
List<GenericValue> productPriceCondList = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("productPriceRuleId", productPriceRule.get("productPriceRuleId")));
|
||||
|
||||
boolean foundQuantityInputParam = false;
|
||||
// only consider a rule if all conditions except the quantity condition are true
|
||||
boolean allExceptQuantTrue = true;
|
||||
Iterator productPriceCondIter = productPriceCondList.iterator();
|
||||
Iterator<GenericValue> productPriceCondIter = productPriceCondList.iterator();
|
||||
while (productPriceCondIter.hasNext()) {
|
||||
GenericValue productPriceCond = (GenericValue) productPriceCondIter.next();
|
||||
GenericValue productPriceCond = productPriceCondIter.next();
|
||||
if ("PRIP_QUANTITY".equals(productPriceCond.getString("inputParamEnumId"))) {
|
||||
foundQuantityInputParam = true;
|
||||
} else {
|
||||
@@ -596,23 +597,23 @@ public class PriceServices {
|
||||
}
|
||||
|
||||
if (findAllQuantityPrices) {
|
||||
List allQuantityPrices = FastList.newInstance();
|
||||
List<Map<String, Object>> allQuantityPrices = FastList.newInstance();
|
||||
|
||||
// if findAllQuantityPrices then iterate through quantityProductPriceRules
|
||||
// foreach create an entry in the out list and eval that rule and all nonQuantityProductPriceRules rather than a single rule
|
||||
Iterator quantityProductPriceRuleIter = quantityProductPriceRules.iterator();
|
||||
Iterator<GenericValue> quantityProductPriceRuleIter = quantityProductPriceRules.iterator();
|
||||
while (quantityProductPriceRuleIter.hasNext()) {
|
||||
GenericValue quantityProductPriceRule = (GenericValue) quantityProductPriceRuleIter.next();
|
||||
|
||||
List ruleListToUse = FastList.newInstance();
|
||||
GenericValue quantityProductPriceRule = quantityProductPriceRuleIter.next();
|
||||
|
||||
List<GenericValue> ruleListToUse = FastList.newInstance();
|
||||
ruleListToUse.add(quantityProductPriceRule);
|
||||
ruleListToUse.addAll(nonQuantityProductPriceRules);
|
||||
|
||||
Map quantCalcResults = calcPriceResultFromRules(ruleListToUse, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
|
||||
Map<String, Object> quantCalcResults = calcPriceResultFromRules(ruleListToUse, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, null, currencyUomId, delegator, nowTimestamp);
|
||||
Map quantErrorResult = addGeneralResults(quantCalcResults, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
Map<String, Object> quantErrorResult = addGeneralResults(quantCalcResults, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
checkIncludeVat, currencyUomId, productId, quantity, partyId, dispatcher);
|
||||
if (quantErrorResult != null) return quantErrorResult;
|
||||
|
||||
@@ -624,7 +625,7 @@ public class PriceServices {
|
||||
result.put("allQuantityPrices", allQuantityPrices);
|
||||
|
||||
// use a quantity 1 to get the main price, then fill in the quantity break prices
|
||||
Map calcResults = calcPriceResultFromRules(allProductPriceRules, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
|
||||
Map<String, Object> calcResults = calcPriceResultFromRules(allProductPriceRules, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, Double.valueOf(1.0), currencyUomId, delegator, nowTimestamp);
|
||||
@@ -632,17 +633,17 @@ public class PriceServices {
|
||||
// The orderItemPriceInfos out parameter requires a special treatment:
|
||||
// the list of OrderItemPriceInfos generated by the price rule is appended to
|
||||
// the existing orderItemPriceInfos list and the aggregated list is returned.
|
||||
List orderItemPriceInfosFromRule = (List)calcResults.get("orderItemPriceInfos");
|
||||
List<GenericValue> orderItemPriceInfosFromRule = UtilGenerics.checkList(calcResults.get("orderItemPriceInfos"));
|
||||
if (UtilValidate.isNotEmpty(orderItemPriceInfosFromRule)) {
|
||||
orderItemPriceInfos.addAll(orderItemPriceInfosFromRule);
|
||||
}
|
||||
result.put("orderItemPriceInfos", orderItemPriceInfos);
|
||||
|
||||
Map errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
Map<String, Object> errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
checkIncludeVat, currencyUomId, productId, quantity, partyId, dispatcher);
|
||||
if (errorResult != null) return errorResult;
|
||||
} else {
|
||||
Map calcResults = calcPriceResultFromRules(allProductPriceRules, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
|
||||
Map<String, Object> calcResults = calcPriceResultFromRules(allProductPriceRules, listPriceDbl.doubleValue(), defaultPrice, promoPrice,
|
||||
wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
|
||||
averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
|
||||
webSiteId, partyId, Double.valueOf(quantity), currencyUomId, delegator, nowTimestamp);
|
||||
@@ -650,13 +651,13 @@ public class PriceServices {
|
||||
// The orderItemPriceInfos out parameter requires a special treatment:
|
||||
// the list of OrderItemPriceInfos generated by the price rule is appended to
|
||||
// the existing orderItemPriceInfos list and the aggregated list is returned.
|
||||
List orderItemPriceInfosFromRule = (List)calcResults.get("orderItemPriceInfos");
|
||||
List<GenericValue> orderItemPriceInfosFromRule = UtilGenerics.checkList(calcResults.get("orderItemPriceInfos"));
|
||||
if (UtilValidate.isNotEmpty(orderItemPriceInfosFromRule)) {
|
||||
orderItemPriceInfos.addAll(orderItemPriceInfosFromRule);
|
||||
}
|
||||
result.put("orderItemPriceInfos", orderItemPriceInfos);
|
||||
|
||||
Map errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
Map<String, Object> errorResult = addGeneralResults(result, competitivePriceValue, specialPromoPriceValue, productStore,
|
||||
checkIncludeVat, currencyUomId, productId, quantity, partyId, dispatcher);
|
||||
if (errorResult != null) return errorResult;
|
||||
}
|
||||
@@ -670,7 +671,7 @@ public class PriceServices {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map addGeneralResults(Map result, GenericValue competitivePriceValue, GenericValue specialPromoPriceValue, GenericValue productStore,
|
||||
public static Map<String, Object> addGeneralResults(Map<String, Object> result, GenericValue competitivePriceValue, GenericValue specialPromoPriceValue, GenericValue productStore,
|
||||
String checkIncludeVat, String currencyUomId, String productId, double quantity, String partyId, LocalDispatcher dispatcher) {
|
||||
result.put("competitivePrice", competitivePriceValue != null ? competitivePriceValue.getDouble("price") : null);
|
||||
result.put("specialPromoPrice", specialPromoPriceValue != null ? specialPromoPriceValue.getDouble("price") : null);
|
||||
@@ -678,7 +679,7 @@ public class PriceServices {
|
||||
|
||||
// okay, now we have the calculated price, see if we should add in tax and if so do it
|
||||
if ("Y".equals(checkIncludeVat) && productStore != null && "Y".equals(productStore.getString("showPricesWithVatTax"))) {
|
||||
Map calcTaxForDisplayContext = UtilMisc.toMap("productStoreId", productStore.get("productStoreId"),
|
||||
Map<String, Object> calcTaxForDisplayContext = UtilMisc.toMap("productStoreId", productStore.get("productStoreId"),
|
||||
"productId", productId, "quantity", BigDecimal.valueOf(quantity),
|
||||
"basePrice", BigDecimal.valueOf(((Double) result.get("price")).doubleValue()));
|
||||
if (UtilValidate.isNotEmpty(partyId)) {
|
||||
@@ -686,7 +687,7 @@ public class PriceServices {
|
||||
}
|
||||
|
||||
try {
|
||||
Map calcTaxForDisplayResult = dispatcher.runSync("calcTaxForDisplay", calcTaxForDisplayContext);
|
||||
Map<String, Object> calcTaxForDisplayResult = dispatcher.runSync("calcTaxForDisplay", calcTaxForDisplayContext);
|
||||
if (ServiceUtil.isError(calcTaxForDisplayResult)) {
|
||||
return ServiceUtil.returnError("Error calculating VAT tax (with calcTaxForDisplay service)", null, null, calcTaxForDisplayResult);
|
||||
}
|
||||
@@ -721,8 +722,8 @@ public class PriceServices {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List makeProducePriceRuleList(GenericDelegator delegator, boolean optimizeForLargeRuleSet, String productId, String virtualProductId, String prodCatalogId, String productStoreGroupId, String webSiteId, String partyId, String currencyUomId) throws GenericEntityException {
|
||||
List productPriceRules = null;
|
||||
public static List<GenericValue> makeProducePriceRuleList(GenericDelegator delegator, boolean optimizeForLargeRuleSet, String productId, String virtualProductId, String prodCatalogId, String productStoreGroupId, String webSiteId, String partyId, String currencyUomId) throws GenericEntityException {
|
||||
List<GenericValue> productPriceRules = null;
|
||||
|
||||
// At this point we have two options: optimize for large ruleset, or optimize for small ruleset
|
||||
// NOTE: This only effects the way that the rules to be evaluated are selected.
|
||||
@@ -731,28 +732,28 @@ public class PriceServices {
|
||||
if (optimizeForLargeRuleSet) {
|
||||
// ========= find all rules that must be run for each input type; this is kind of like a pre-filter to slim down the rules to run =========
|
||||
// utilTimer.timerString("Before create rule id list", module);
|
||||
TreeSet productPriceRuleIds = new TreeSet();
|
||||
TreeSet<String> productPriceRuleIds = new TreeSet<String>();
|
||||
|
||||
// ------- These are all of the conditions that DON'T depend on the current inputs -------
|
||||
|
||||
// by productCategoryId
|
||||
// for we will always include any rules that go by category, shouldn't be too many to iterate through each time and will save on cache entries
|
||||
// note that we always want to put the category, quantity, etc ones that find all rules with these conditions in separate cache lists so that they can be easily cleared
|
||||
Collection productCategoryIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_CAT_ID"));
|
||||
Collection<GenericValue> productCategoryIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_CAT_ID"));
|
||||
if (UtilValidate.isNotEmpty(productCategoryIdConds)) {
|
||||
Iterator productCategoryIdCondsIter = productCategoryIdConds.iterator();
|
||||
Iterator<GenericValue> productCategoryIdCondsIter = productCategoryIdConds.iterator();
|
||||
while (productCategoryIdCondsIter.hasNext()) {
|
||||
GenericValue productCategoryIdCond = (GenericValue) productCategoryIdCondsIter.next();
|
||||
GenericValue productCategoryIdCond = productCategoryIdCondsIter.next();
|
||||
productPriceRuleIds.add(productCategoryIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
|
||||
// by productFeatureId
|
||||
Collection productFeatureIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_FEAT_ID"));
|
||||
Collection<GenericValue> productFeatureIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_FEAT_ID"));
|
||||
if (UtilValidate.isNotEmpty(productFeatureIdConds)) {
|
||||
Iterator productFeatureIdCondsIter = productFeatureIdConds.iterator();
|
||||
Iterator<GenericValue> productFeatureIdCondsIter = productFeatureIdConds.iterator();
|
||||
while (productFeatureIdCondsIter.hasNext()) {
|
||||
GenericValue productFeatureIdCond = (GenericValue) productFeatureIdCondsIter.next();
|
||||
GenericValue productFeatureIdCond = productFeatureIdCondsIter.next();
|
||||
productPriceRuleIds.add(productFeatureIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
@@ -760,21 +761,21 @@ public class PriceServices {
|
||||
// by quantity -- should we really do this one, ie is it necessary?
|
||||
// we could say that all rules with quantity on them must have one of these other values
|
||||
// but, no we'll do it the other way, any that have a quantity will always get compared
|
||||
Collection quantityConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_QUANTITY"));
|
||||
Collection<GenericValue> quantityConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_QUANTITY"));
|
||||
if (UtilValidate.isNotEmpty(quantityConds)) {
|
||||
Iterator quantityCondsIter = quantityConds.iterator();
|
||||
Iterator<GenericValue> quantityCondsIter = quantityConds.iterator();
|
||||
while (quantityCondsIter.hasNext()) {
|
||||
GenericValue quantityCond = (GenericValue) quantityCondsIter.next();
|
||||
GenericValue quantityCond = quantityCondsIter.next();
|
||||
productPriceRuleIds.add(quantityCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
|
||||
// by roleTypeId
|
||||
Collection roleTypeIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_ROLE_TYPE"));
|
||||
Collection<GenericValue> roleTypeIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_ROLE_TYPE"));
|
||||
if (UtilValidate.isNotEmpty(roleTypeIdConds)) {
|
||||
Iterator roleTypeIdCondsIter = roleTypeIdConds.iterator();
|
||||
Iterator<GenericValue> roleTypeIdCondsIter = roleTypeIdConds.iterator();
|
||||
while (roleTypeIdCondsIter.hasNext()) {
|
||||
GenericValue roleTypeIdCond = (GenericValue) roleTypeIdCondsIter.next();
|
||||
GenericValue roleTypeIdCond = roleTypeIdCondsIter.next();
|
||||
productPriceRuleIds.add(roleTypeIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
@@ -784,11 +785,11 @@ public class PriceServices {
|
||||
// later: (by partyClassificationTypeId)
|
||||
|
||||
// by listPrice
|
||||
Collection listPriceConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_LIST_PRICE"));
|
||||
Collection<GenericValue> listPriceConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_LIST_PRICE"));
|
||||
if (UtilValidate.isNotEmpty(listPriceConds)) {
|
||||
Iterator listPriceCondsIter = listPriceConds.iterator();
|
||||
Iterator<GenericValue> listPriceCondsIter = listPriceConds.iterator();
|
||||
while (listPriceCondsIter.hasNext()) {
|
||||
GenericValue listPriceCond = (GenericValue) listPriceCondsIter.next();
|
||||
GenericValue listPriceCond = listPriceCondsIter.next();
|
||||
productPriceRuleIds.add(listPriceCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
@@ -796,22 +797,22 @@ public class PriceServices {
|
||||
// ------- These are all of them that DO depend on the current inputs -------
|
||||
|
||||
// by productId
|
||||
Collection productIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", productId));
|
||||
Collection<GenericValue> productIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", productId));
|
||||
if (UtilValidate.isNotEmpty(productIdConds)) {
|
||||
Iterator productIdCondsIter = productIdConds.iterator();
|
||||
Iterator<GenericValue> productIdCondsIter = productIdConds.iterator();
|
||||
while (productIdCondsIter.hasNext()) {
|
||||
GenericValue productIdCond = (GenericValue) productIdCondsIter.next();
|
||||
GenericValue productIdCond = productIdCondsIter.next();
|
||||
productPriceRuleIds.add(productIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
|
||||
// by virtualProductId, if not null
|
||||
if (virtualProductId != null) {
|
||||
Collection virtualProductIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", virtualProductId));
|
||||
Collection<GenericValue> virtualProductIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PRODUCT_ID", "condValue", virtualProductId));
|
||||
if (UtilValidate.isNotEmpty(virtualProductIdConds)) {
|
||||
Iterator virtualProductIdCondsIter = virtualProductIdConds.iterator();
|
||||
Iterator<GenericValue> virtualProductIdCondsIter = virtualProductIdConds.iterator();
|
||||
while (virtualProductIdCondsIter.hasNext()) {
|
||||
GenericValue virtualProductIdCond = (GenericValue) virtualProductIdCondsIter.next();
|
||||
GenericValue virtualProductIdCond = virtualProductIdCondsIter.next();
|
||||
productPriceRuleIds.add(virtualProductIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
@@ -819,11 +820,11 @@ public class PriceServices {
|
||||
|
||||
// by prodCatalogId - which is optional in certain cases
|
||||
if (UtilValidate.isNotEmpty(prodCatalogId)) {
|
||||
Collection prodCatalogIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_CLG_ID", "condValue", prodCatalogId));
|
||||
Collection<GenericValue> prodCatalogIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_CLG_ID", "condValue", prodCatalogId));
|
||||
if (UtilValidate.isNotEmpty(prodCatalogIdConds)) {
|
||||
Iterator prodCatalogIdCondsIter = prodCatalogIdConds.iterator();
|
||||
Iterator<GenericValue> prodCatalogIdCondsIter = prodCatalogIdConds.iterator();
|
||||
while (prodCatalogIdCondsIter.hasNext()) {
|
||||
GenericValue prodCatalogIdCond = (GenericValue) prodCatalogIdCondsIter.next();
|
||||
GenericValue prodCatalogIdCond = prodCatalogIdCondsIter.next();
|
||||
productPriceRuleIds.add(prodCatalogIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
@@ -831,11 +832,11 @@ public class PriceServices {
|
||||
|
||||
// by productStoreGroupId
|
||||
if (UtilValidate.isNotEmpty(productStoreGroupId)) {
|
||||
Collection storeGroupConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_SGRP_ID", "condValue", productStoreGroupId));
|
||||
Collection<GenericValue> storeGroupConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PROD_SGRP_ID", "condValue", productStoreGroupId));
|
||||
if (UtilValidate.isNotEmpty(storeGroupConds)) {
|
||||
Iterator storeGroupCondsIter = storeGroupConds.iterator();
|
||||
Iterator<GenericValue> storeGroupCondsIter = storeGroupConds.iterator();
|
||||
while (storeGroupCondsIter.hasNext()) {
|
||||
GenericValue storeGroupCond = (GenericValue) storeGroupCondsIter.next();
|
||||
GenericValue storeGroupCond = storeGroupCondsIter.next();
|
||||
productPriceRuleIds.add(storeGroupCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
@@ -843,11 +844,11 @@ public class PriceServices {
|
||||
|
||||
// by webSiteId
|
||||
if (UtilValidate.isNotEmpty(webSiteId)) {
|
||||
Collection webSiteIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_WEBSITE_ID", "condValue", webSiteId));
|
||||
Collection<GenericValue> webSiteIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_WEBSITE_ID", "condValue", webSiteId));
|
||||
if (UtilValidate.isNotEmpty(webSiteIdConds)) {
|
||||
Iterator webSiteIdCondsIter = webSiteIdConds.iterator();
|
||||
Iterator<GenericValue> webSiteIdCondsIter = webSiteIdConds.iterator();
|
||||
while (webSiteIdCondsIter.hasNext()) {
|
||||
GenericValue webSiteIdCond = (GenericValue) webSiteIdCondsIter.next();
|
||||
GenericValue webSiteIdCond = webSiteIdCondsIter.next();
|
||||
productPriceRuleIds.add(webSiteIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
@@ -855,30 +856,30 @@ public class PriceServices {
|
||||
|
||||
// by partyId
|
||||
if (UtilValidate.isNotEmpty(partyId)) {
|
||||
Collection partyIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PARTY_ID", "condValue", partyId));
|
||||
Collection<GenericValue> partyIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_PARTY_ID", "condValue", partyId));
|
||||
if (UtilValidate.isNotEmpty(partyIdConds)) {
|
||||
Iterator partyIdCondsIter = partyIdConds.iterator();
|
||||
Iterator<GenericValue> partyIdCondsIter = partyIdConds.iterator();
|
||||
while (partyIdCondsIter.hasNext()) {
|
||||
GenericValue partyIdCond = (GenericValue) partyIdCondsIter.next();
|
||||
GenericValue partyIdCond = partyIdCondsIter.next();
|
||||
productPriceRuleIds.add(partyIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// by currencyUomId
|
||||
Collection currencyUomIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_CURRENCY_UOMID", "condValue", currencyUomId));
|
||||
Collection<GenericValue> currencyUomIdConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("inputParamEnumId", "PRIP_CURRENCY_UOMID", "condValue", currencyUomId));
|
||||
if (UtilValidate.isNotEmpty(currencyUomIdConds)) {
|
||||
Iterator currencyUomIdCondsIter = currencyUomIdConds.iterator();
|
||||
Iterator<GenericValue> currencyUomIdCondsIter = currencyUomIdConds.iterator();
|
||||
while (currencyUomIdCondsIter.hasNext()) {
|
||||
GenericValue currencyUomIdCond = (GenericValue) currencyUomIdCondsIter.next();
|
||||
GenericValue currencyUomIdCond = currencyUomIdCondsIter.next();
|
||||
productPriceRuleIds.add(currencyUomIdCond.getString("productPriceRuleId"));
|
||||
}
|
||||
}
|
||||
|
||||
productPriceRules = FastList.newInstance();
|
||||
Iterator productPriceRuleIdsIter = productPriceRuleIds.iterator();
|
||||
Iterator<String> productPriceRuleIdsIter = productPriceRuleIds.iterator();
|
||||
while (productPriceRuleIdsIter.hasNext()) {
|
||||
String productPriceRuleId = (String) productPriceRuleIdsIter.next();
|
||||
String productPriceRuleId = productPriceRuleIdsIter.next();
|
||||
GenericValue productPriceRule = delegator.findByPrimaryKeyCache("ProductPriceRule", UtilMisc.toMap("productPriceRuleId", productPriceRuleId));
|
||||
if (productPriceRule == null) continue;
|
||||
productPriceRules.add(productPriceRule);
|
||||
@@ -896,14 +897,14 @@ public class PriceServices {
|
||||
return productPriceRules;
|
||||
}
|
||||
|
||||
public static Map calcPriceResultFromRules(List productPriceRules, double listPrice, double defaultPrice, double promoPrice,
|
||||
public static Map<String, Object> calcPriceResultFromRules(List<GenericValue> productPriceRules, double listPrice, double defaultPrice, double promoPrice,
|
||||
double wholesalePrice, GenericValue maximumPriceValue, GenericValue minimumPriceValue, boolean validPriceFound,
|
||||
GenericValue averageCostValue, String productId, String virtualProductId, String prodCatalogId, String productStoreGroupId,
|
||||
String webSiteId, String partyId, Double quantity, String currencyUomId, GenericDelegator delegator, Timestamp nowTimestamp) throws GenericEntityException {
|
||||
|
||||
Map calcResults = FastMap.newInstance();
|
||||
Map<String, Object> calcResults = FastMap.newInstance();
|
||||
|
||||
List orderItemPriceInfos = FastList.newInstance();
|
||||
List<GenericValue> orderItemPriceInfos = FastList.newInstance();
|
||||
boolean isSale = false;
|
||||
|
||||
// ========= go through each price rule by id and eval all conditions =========
|
||||
@@ -919,9 +920,9 @@ public class PriceServices {
|
||||
// calculate running sum based on listPrice and rules found
|
||||
double price = listPrice;
|
||||
|
||||
Iterator productPriceRulesIter = productPriceRules.iterator();
|
||||
Iterator<GenericValue> productPriceRulesIter = productPriceRules.iterator();
|
||||
while (productPriceRulesIter.hasNext()) {
|
||||
GenericValue productPriceRule = (GenericValue) productPriceRulesIter.next();
|
||||
GenericValue productPriceRule = productPriceRulesIter.next();
|
||||
String productPriceRuleId = productPriceRule.getString("productPriceRuleId");
|
||||
|
||||
// check from/thru dates
|
||||
@@ -940,11 +941,11 @@ public class PriceServices {
|
||||
// check all conditions
|
||||
boolean allTrue = true;
|
||||
StringBuilder condsDescription = new StringBuilder();
|
||||
List productPriceConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("productPriceRuleId", productPriceRuleId));
|
||||
Iterator productPriceCondsIter = UtilMisc.toIterator(productPriceConds);
|
||||
List<GenericValue> productPriceConds = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("productPriceRuleId", productPriceRuleId));
|
||||
Iterator<GenericValue> productPriceCondsIter = UtilMisc.toIterator(productPriceConds);
|
||||
|
||||
while (productPriceCondsIter != null && productPriceCondsIter.hasNext()) {
|
||||
GenericValue productPriceCond = (GenericValue) productPriceCondsIter.next();
|
||||
GenericValue productPriceCond = productPriceCondsIter.next();
|
||||
|
||||
totalConds++;
|
||||
|
||||
@@ -985,11 +986,11 @@ public class PriceServices {
|
||||
isSale = true;
|
||||
}
|
||||
|
||||
Collection productPriceActions = delegator.findByAndCache("ProductPriceAction", UtilMisc.toMap("productPriceRuleId", productPriceRuleId));
|
||||
Iterator productPriceActionsIter = UtilMisc.toIterator(productPriceActions);
|
||||
Collection<GenericValue> productPriceActions = delegator.findByAndCache("ProductPriceAction", UtilMisc.toMap("productPriceRuleId", productPriceRuleId));
|
||||
Iterator<GenericValue> productPriceActionsIter = UtilMisc.toIterator(productPriceActions);
|
||||
|
||||
while (productPriceActionsIter != null && productPriceActionsIter.hasNext()) {
|
||||
GenericValue productPriceAction = (GenericValue) productPriceActionsIter.next();
|
||||
GenericValue productPriceAction = productPriceActionsIter.next();
|
||||
|
||||
totalActions++;
|
||||
|
||||
@@ -1109,10 +1110,9 @@ public class PriceServices {
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("Unchecked Calculated price: " + price, module);
|
||||
Debug.logVerbose("PriceInfo:", module);
|
||||
Iterator orderItemPriceInfosIter = orderItemPriceInfos.iterator();
|
||||
Iterator<GenericValue> orderItemPriceInfosIter = orderItemPriceInfos.iterator();
|
||||
while (orderItemPriceInfosIter.hasNext()) {
|
||||
GenericValue orderItemPriceInfo = (GenericValue) orderItemPriceInfosIter.next();
|
||||
|
||||
GenericValue orderItemPriceInfo = orderItemPriceInfosIter.next();
|
||||
Debug.logVerbose(" --- " + orderItemPriceInfo.toString(), module);
|
||||
}
|
||||
}
|
||||
@@ -1164,7 +1164,7 @@ public class PriceServices {
|
||||
} else if ("PRIP_PROD_CAT_ID".equals(productPriceCond.getString("inputParamEnumId"))) {
|
||||
// if a ProductCategoryMember exists for this productId and the specified productCategoryId
|
||||
String productCategoryId = productPriceCond.getString("condValue");
|
||||
List productCategoryMembers = delegator.findByAndCache("ProductCategoryMember",
|
||||
List<GenericValue> productCategoryMembers = delegator.findByAndCache("ProductCategoryMember",
|
||||
UtilMisc.toMap("productId", productId, "productCategoryId", productCategoryId));
|
||||
// and from/thru date within range
|
||||
productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, nowTimestamp, null, null, true);
|
||||
@@ -1179,7 +1179,7 @@ public class PriceServices {
|
||||
// NOTE: this is important becuase of the common scenario where a virtual product is a member of a category but the variants will typically NOT be
|
||||
// NOTE: we may want to parameterize this in the future, ie with an indicator on the ProductPriceCond entity
|
||||
if (compare == 1 && UtilValidate.isNotEmpty(virtualProductId)) {
|
||||
List virtualProductCategoryMembers = delegator.findByAndCache("ProductCategoryMember",
|
||||
List<GenericValue> virtualProductCategoryMembers = delegator.findByAndCache("ProductCategoryMember",
|
||||
UtilMisc.toMap("productId", virtualProductId, "productCategoryId", productCategoryId));
|
||||
// and from/thru date within range
|
||||
virtualProductCategoryMembers = EntityUtil.filterByDate(virtualProductCategoryMembers, nowTimestamp, null, null, true);
|
||||
@@ -1193,7 +1193,7 @@ public class PriceServices {
|
||||
|
||||
// if a ProductFeatureAppl exists for this productId and the specified productFeatureId
|
||||
String productFeatureId = productPriceCond.getString("condValue");
|
||||
List productFeatureAppls = delegator.findByAndCache("ProductFeatureAppl",
|
||||
List<GenericValue> productFeatureAppls = delegator.findByAndCache("ProductFeatureAppl",
|
||||
UtilMisc.toMap("productId", productId, "productFeatureId", productFeatureId));
|
||||
// and from/thru date within range
|
||||
productFeatureAppls = EntityUtil.filterByDate(productFeatureAppls, nowTimestamp, null, null, true);
|
||||
@@ -1245,7 +1245,7 @@ public class PriceServices {
|
||||
compare = 0;
|
||||
} else {
|
||||
// look for PartyRelationship with partyRelationshipTypeId=GROUP_ROLLUP, the partyIdTo is the group member, so the partyIdFrom is the groupPartyId
|
||||
List partyRelationshipList = delegator.findByAndCache("PartyRelationship", UtilMisc.toMap("partyIdFrom", groupPartyId, "partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP"));
|
||||
List<GenericValue> partyRelationshipList = delegator.findByAndCache("PartyRelationship", UtilMisc.toMap("partyIdFrom", groupPartyId, "partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP"));
|
||||
// and from/thru date within range
|
||||
partyRelationshipList = EntityUtil.filterByDate(partyRelationshipList, nowTimestamp, null, null, true);
|
||||
// then 0 (equals), otherwise 1 (not equals)
|
||||
@@ -1253,7 +1253,7 @@ public class PriceServices {
|
||||
compare = 0;
|
||||
} else {
|
||||
// before setting 1 try one more query: look for a 2 hop relationship
|
||||
List partyRelationshipTwoHopList = delegator.findByAndCache("PartyRelationshipToFrom", UtilMisc.toMap("onePartyIdFrom", groupPartyId, "twoPartyIdTo", partyId, "onePartyRelationshipTypeId", "GROUP_ROLLUP", "twoPartyRelationshipTypeId", "GROUP_ROLLUP"));
|
||||
List<GenericValue> partyRelationshipTwoHopList = delegator.findByAndCache("PartyRelationshipToFrom", UtilMisc.toMap("onePartyIdFrom", groupPartyId, "twoPartyIdTo", partyId, "onePartyRelationshipTypeId", "GROUP_ROLLUP", "twoPartyRelationshipTypeId", "GROUP_ROLLUP"));
|
||||
partyRelationshipTwoHopList = EntityUtil.filterByDate(partyRelationshipTwoHopList, nowTimestamp, "oneFromDate", "oneThruDate", true);
|
||||
partyRelationshipTwoHopList = EntityUtil.filterByDate(partyRelationshipTwoHopList, nowTimestamp, "twoFromDate", "twoThruDate", true);
|
||||
if (UtilValidate.isNotEmpty(partyRelationshipTwoHopList)) {
|
||||
@@ -1270,7 +1270,7 @@ public class PriceServices {
|
||||
} else {
|
||||
String partyClassificationGroupId = productPriceCond.getString("condValue");
|
||||
// find any PartyClassification
|
||||
List partyClassificationList = delegator.findByAndCache("PartyClassification", UtilMisc.toMap("partyId", partyId, "partyClassificationGroupId", partyClassificationGroupId));
|
||||
List<GenericValue> partyClassificationList = delegator.findByAndCache("PartyClassification", UtilMisc.toMap("partyId", partyId, "partyClassificationGroupId", partyClassificationGroupId));
|
||||
// and from/thru date within range
|
||||
partyClassificationList = EntityUtil.filterByDate(partyClassificationList, nowTimestamp, null, null, true);
|
||||
// then 0 (equals), otherwise 1 (not equals)
|
||||
@@ -1330,12 +1330,12 @@ public class PriceServices {
|
||||
/**
|
||||
* Calculates the purchase price of a product
|
||||
*/
|
||||
public static Map calculatePurchasePrice(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> calculatePurchasePrice(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Map result = FastMap.newInstance();
|
||||
Map<String, Object> result = FastMap.newInstance();
|
||||
|
||||
List orderItemPriceInfos = FastList.newInstance();
|
||||
List<GenericValue> orderItemPriceInfos = FastList.newInstance();
|
||||
boolean validPriceFound = false;
|
||||
double price = 0.0;
|
||||
|
||||
@@ -1350,23 +1350,23 @@ public class PriceServices {
|
||||
|
||||
// b) If no price can be found, get the lastPrice from the SupplierProduct entity
|
||||
if (!validPriceFound) {
|
||||
Map priceContext = UtilMisc.toMap("currencyUomId", currencyUomId, "partyId", partyId, "productId", productId, "quantity", quantity);
|
||||
List productSuppliers = null;
|
||||
Map<String, Object> priceContext = UtilMisc.toMap("currencyUomId", currencyUomId, "partyId", partyId, "productId", productId, "quantity", quantity);
|
||||
List<GenericValue> productSuppliers = null;
|
||||
try {
|
||||
Map priceResult = dispatcher.runSync("getSuppliersForProduct", priceContext);
|
||||
Map<String, Object> priceResult = dispatcher.runSync("getSuppliersForProduct", priceContext);
|
||||
if (ServiceUtil.isError(priceResult)) {
|
||||
String errMsg = ServiceUtil.getErrorMessage(priceResult);
|
||||
Debug.logError(errMsg, module);
|
||||
return ServiceUtil.returnError(errMsg);
|
||||
}
|
||||
productSuppliers = (List) priceResult.get("supplierProducts");
|
||||
productSuppliers = UtilGenerics.checkList(priceResult.get("supplierProducts"));
|
||||
} catch(GenericServiceException gse) {
|
||||
Debug.logError(gse, module);
|
||||
return ServiceUtil.returnError(gse.getMessage());
|
||||
}
|
||||
if (productSuppliers != null) {
|
||||
for (int i = 0; i < productSuppliers.size(); i++) {
|
||||
GenericValue productSupplier = (GenericValue) productSuppliers.get(i);
|
||||
GenericValue productSupplier = productSuppliers.get(i);
|
||||
if (!validPriceFound) {
|
||||
price = ((Double)productSupplier.get("lastPrice")).doubleValue();
|
||||
validPriceFound = true;
|
||||
@@ -1375,8 +1375,8 @@ public class PriceServices {
|
||||
StringBuilder priceInfoDescription = new StringBuilder();
|
||||
priceInfoDescription.append("SupplierProduct ");
|
||||
priceInfoDescription.append("[minimumOrderQuantity:");
|
||||
priceInfoDescription.append("" + productSupplier.getDouble("minimumOrderQuantity").doubleValue());
|
||||
priceInfoDescription.append(", lastPrice: " + productSupplier.getDouble("lastPrice").doubleValue());
|
||||
priceInfoDescription.append(productSupplier.getDouble("minimumOrderQuantity"));
|
||||
priceInfoDescription.append(", lastPrice: ").append(productSupplier.getDouble("lastPrice"));
|
||||
priceInfoDescription.append("]");
|
||||
GenericValue orderItemPriceInfo = delegator.makeValue("OrderItemPriceInfo");
|
||||
//orderItemPriceInfo.set("productPriceRuleId", productPriceAction.get("productPriceRuleId"));
|
||||
@@ -1395,7 +1395,7 @@ public class PriceServices {
|
||||
|
||||
// c) If no price can be found, get the averageCost from the ProductPrice entity
|
||||
if (!validPriceFound) {
|
||||
List prices = null;
|
||||
List<GenericValue> prices = null;
|
||||
try {
|
||||
prices = delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", productId,
|
||||
"productPricePurposeId", "PURCHASE"), UtilMisc.toList("-fromDate"));
|
||||
@@ -1418,7 +1418,7 @@ public class PriceServices {
|
||||
prices = EntityUtil.filterByDate(prices);
|
||||
|
||||
// first check for the AVERAGE_COST price type
|
||||
List pricesToUse = EntityUtil.filterByAnd(prices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
|
||||
List<GenericValue> pricesToUse = EntityUtil.filterByAnd(prices, UtilMisc.toMap("productPriceTypeId", "AVERAGE_COST"));
|
||||
if (pricesToUse == null || pricesToUse.size() == 0) {
|
||||
// next go with default price
|
||||
pricesToUse = EntityUtil.filterByAnd(prices, UtilMisc.toMap("productPriceTypeId", "DEFAULT_PRICE"));
|
||||
|
||||
@@ -48,7 +48,7 @@ public class PromoServices {
|
||||
|
||||
public final static String module = PromoServices.class.getName();
|
||||
|
||||
public static Map createProductPromoCodeSet(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> createProductPromoCodeSet(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
//GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Long quantity = (Long) context.get("quantity");
|
||||
@@ -59,7 +59,7 @@ public class PromoServices {
|
||||
|
||||
StringBuilder bankOfNumbers = new StringBuilder();
|
||||
for (long i = 0; i < quantity.longValue(); i++) {
|
||||
Map createProductPromoCodeMap = null;
|
||||
Map<String, Object> createProductPromoCodeMap = null;
|
||||
try {
|
||||
createProductPromoCodeMap = dispatcher.runSync("createProductPromoCode", dctx.makeValidContext("createProductPromoCode", "IN", context));
|
||||
} catch (GenericServiceException err) {
|
||||
@@ -76,12 +76,12 @@ public class PromoServices {
|
||||
return ServiceUtil.returnSuccess(bankOfNumbers.toString());
|
||||
}
|
||||
|
||||
public static Map purgeOldStoreAutoPromos(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> purgeOldStoreAutoPromos(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
String productStoreId = (String) context.get("productStoreId");
|
||||
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
|
||||
|
||||
List condList = FastList.newInstance();
|
||||
List<EntityCondition> condList = FastList.newInstance();
|
||||
if (UtilValidate.isEmpty(productStoreId)) {
|
||||
condList.add(EntityCondition.makeCondition("productStoreId", EntityOperator.EQUALS, productStoreId));
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class PromoServices {
|
||||
try {
|
||||
EntityListIterator eli = delegator.find("ProductStorePromoAndAppl", cond, null, null, null, null);
|
||||
GenericValue productStorePromoAndAppl = null;
|
||||
while ((productStorePromoAndAppl = (GenericValue) eli.next()) != null) {
|
||||
while ((productStorePromoAndAppl = eli.next()) != null) {
|
||||
GenericValue productStorePromo = delegator.makeValue("ProductStorePromoAppl");
|
||||
productStorePromo.setAllFields(productStorePromoAndAppl, true, null, null);
|
||||
productStorePromo.remove();
|
||||
@@ -108,7 +108,7 @@ public class PromoServices {
|
||||
return ServiceUtil.returnSuccess();
|
||||
}
|
||||
|
||||
public static Map importPromoCodesFromFile(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> importPromoCodesFromFile(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
|
||||
// check the uploaded file
|
||||
@@ -127,11 +127,11 @@ public class PromoServices {
|
||||
}
|
||||
|
||||
// make a temp context for invocations
|
||||
Map invokeCtx = promoModel.makeValid(context, ModelService.IN_PARAM);
|
||||
Map<String, Object> invokeCtx = promoModel.makeValid(context, ModelService.IN_PARAM);
|
||||
|
||||
// read the bytes into a reader
|
||||
BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper)));
|
||||
List errors = FastList.newInstance();
|
||||
List<Object> errors = FastList.newInstance();
|
||||
int lines = 0;
|
||||
String line;
|
||||
|
||||
@@ -142,10 +142,10 @@ public class PromoServices {
|
||||
if (line.length() > 0 && !line.startsWith("#")) {
|
||||
if (line.length() > 0 && line.length() <= 20) {
|
||||
// valid promo code
|
||||
Map inContext = FastMap.newInstance();
|
||||
Map<String, Object> inContext = FastMap.newInstance();
|
||||
inContext.putAll(invokeCtx);
|
||||
inContext.put("productPromoCodeId", line);
|
||||
Map result = dispatcher.runSync("createProductPromoCode", inContext);
|
||||
Map<String, Object> result = dispatcher.runSync("createProductPromoCode", inContext);
|
||||
if (result != null && ServiceUtil.isError(result)) {
|
||||
errors.add(line + ": " + ServiceUtil.getErrorMessage(result));
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class PromoServices {
|
||||
return ServiceUtil.returnSuccess();
|
||||
}
|
||||
|
||||
public static Map importPromoCodeEmailsFromFile(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> importPromoCodeEmailsFromFile(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
|
||||
String productPromoCodeId = (String) context.get("productPromoCodeId");
|
||||
@@ -193,7 +193,7 @@ public class PromoServices {
|
||||
|
||||
// read the bytes into a reader
|
||||
BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper)));
|
||||
List errors = FastList.newInstance();
|
||||
List<Object> errors = FastList.newInstance();
|
||||
int lines = 0;
|
||||
String line;
|
||||
|
||||
@@ -203,7 +203,7 @@ public class PromoServices {
|
||||
if (line.length() > 0 && !line.startsWith("#")) {
|
||||
if (UtilValidate.isEmail(line)) {
|
||||
// valid email address
|
||||
Map result = dispatcher.runSync("createProductPromoCodeEmail", UtilMisc.<String, Object>toMap("productPromoCodeId",
|
||||
Map<String, Object> result = dispatcher.runSync("createProductPromoCodeEmail", UtilMisc.<String, Object>toMap("productPromoCodeId",
|
||||
productPromoCodeId, "emailAddress", line, "userLogin", userLogin));
|
||||
if (result != null && ServiceUtil.isError(result)) {
|
||||
errors.add(line + ": " + ServiceUtil.getErrorMessage(result));
|
||||
|
||||
+4
-4
@@ -34,8 +34,8 @@ public class ImportProductHelper {
|
||||
static String module = ImportProductHelper.class.getName();
|
||||
|
||||
// prepare the product map
|
||||
public static Map prepareProduct(String productId) {
|
||||
Map fields = FastMap.newInstance();
|
||||
public static Map<String, Object> prepareProduct(String productId) {
|
||||
Map<String, Object> fields = FastMap.newInstance();
|
||||
fields.put("productId", productId);
|
||||
fields.put("productTypeId", "FINISHED_GOOD");
|
||||
fields.put("internalName", "Product_" + productId);
|
||||
@@ -45,9 +45,9 @@ public class ImportProductHelper {
|
||||
}
|
||||
|
||||
// prepare the inventoryItem map
|
||||
public static Map prepareInventoryItem(String productId,
|
||||
public static Map<String, Object> prepareInventoryItem(String productId,
|
||||
double quantityOnHand, String inventoryItemId) {
|
||||
Map fields = FastMap.newInstance();
|
||||
Map<String, Object> fields = FastMap.newInstance();
|
||||
fields.put("inventoryItemId", inventoryItemId);
|
||||
fields.put("inventoryItemTypeId", "NON_SERIAL_INV_ITEM");
|
||||
fields.put("productId", productId);
|
||||
|
||||
+8
-8
@@ -57,13 +57,13 @@ public class ImportProductServices {
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static Map productImportFromSpreadsheet(DispatchContext dctx, Map context) {
|
||||
public static Map<String, Object> productImportFromSpreadsheet(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
Map responseMsgs = FastMap.newInstance();
|
||||
Map<String, Object> responseMsgs = FastMap.newInstance();
|
||||
// System.getProperty("user.dir") returns the path upto ofbiz home
|
||||
// directory
|
||||
String path = System.getProperty("user.dir") + "/spreadsheet";
|
||||
List fileItems = FastList.newInstance();
|
||||
List<File> fileItems = FastList.newInstance();
|
||||
|
||||
if (path != null && path.length() > 0) {
|
||||
File importDir = new File(path);
|
||||
@@ -92,9 +92,9 @@ public class ImportProductServices {
|
||||
|
||||
for (int i = 0; i < fileItems.size(); i++) {
|
||||
// read all xls file and create workbook one by one.
|
||||
File item = (File) fileItems.get(i);
|
||||
List products = FastList.newInstance();
|
||||
List inventoryItems = FastList.newInstance();
|
||||
File item = fileItems.get(i);
|
||||
List<Map<String, Object>> products = FastList.newInstance();
|
||||
List<Map<String, Object>> inventoryItems = FastList.newInstance();
|
||||
POIFSFileSystem fs = null;
|
||||
HSSFWorkbook wb = null;
|
||||
try {
|
||||
@@ -146,8 +146,8 @@ public class ImportProductServices {
|
||||
// create and store values in "Product" and "InventoryItem" entity
|
||||
// in database
|
||||
for (int j = 0; j < products.size(); j++) {
|
||||
GenericValue productGV = delegator.makeValue("Product", (Map) products.get(j));
|
||||
GenericValue inventoryItemGV = delegator.makeValue("InventoryItem", (Map) inventoryItems.get(j));
|
||||
GenericValue productGV = delegator.makeValue("Product", products.get(j));
|
||||
GenericValue inventoryItemGV = delegator.makeValue("InventoryItem", inventoryItems.get(j));
|
||||
if (!ImportProductHelper.checkProductExists(productGV.getString("productId"), delegator)) {
|
||||
try {
|
||||
delegator.create(productGV);
|
||||
|
||||
@@ -166,7 +166,7 @@ public class ProductStoreWorker {
|
||||
if (anyServiceType) {
|
||||
if (storePayment == null) {
|
||||
try {
|
||||
List storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId));
|
||||
List<GenericValue> storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId));
|
||||
storePayment = EntityUtil.getFirst(storePayments);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Problems looking up store payment settings", module);
|
||||
@@ -175,7 +175,7 @@ public class ProductStoreWorker {
|
||||
|
||||
if (storePayment == null) {
|
||||
try {
|
||||
List storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId));
|
||||
List<GenericValue> storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId));
|
||||
storePayment = EntityUtil.getFirst(storePayments);
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Problems looking up store payment settings", module);
|
||||
@@ -186,13 +186,13 @@ public class ProductStoreWorker {
|
||||
return storePayment;
|
||||
}
|
||||
|
||||
public static List getProductStoreShipmentMethods(GenericDelegator delegator, String productStoreId,
|
||||
public static List<GenericValue> getProductStoreShipmentMethods(GenericDelegator delegator, String productStoreId,
|
||||
String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId) {
|
||||
// check for an external service call
|
||||
Map storeFields = UtilMisc.toMap("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId,
|
||||
Map<String, String> storeFields = UtilMisc.toMap("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId,
|
||||
"partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId);
|
||||
|
||||
List storeShipMethods = null;
|
||||
List<GenericValue> storeShipMethods = null;
|
||||
try {
|
||||
storeShipMethods = delegator.findByAndCache("ProductStoreShipmentMeth", storeFields);
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -209,11 +209,11 @@ public class ProductStoreWorker {
|
||||
return EntityUtil.getFirst(getProductStoreShipmentMethods(delegator, productStoreId, shipmentMethodTypeId, carrierPartyId, carrierRoleTypeId));
|
||||
}
|
||||
|
||||
public static List getAvailableStoreShippingMethods(GenericDelegator delegator, String productStoreId, GenericValue shippingAddress, List itemSizes, Map featureIdMap, double weight, double orderTotal) {
|
||||
public static List<GenericValue> getAvailableStoreShippingMethods(GenericDelegator delegator, String productStoreId, GenericValue shippingAddress, List<Double> itemSizes, Map<String, Double> featureIdMap, double weight, double orderTotal) {
|
||||
if (featureIdMap == null) {
|
||||
featureIdMap = FastMap.newInstance();
|
||||
}
|
||||
List shippingMethods = null;
|
||||
List<GenericValue> shippingMethods = null;
|
||||
try {
|
||||
shippingMethods = delegator.findByAndCache("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNumber"));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -222,12 +222,12 @@ public class ProductStoreWorker {
|
||||
}
|
||||
|
||||
// clone the list for concurrent modification
|
||||
List returnShippingMethods = UtilMisc.makeListWritable(shippingMethods);
|
||||
List<GenericValue> returnShippingMethods = UtilMisc.makeListWritable(shippingMethods);
|
||||
|
||||
if (shippingMethods != null) {
|
||||
Iterator i = shippingMethods.iterator();
|
||||
Iterator<GenericValue> i = shippingMethods.iterator();
|
||||
while (i.hasNext()) {
|
||||
GenericValue method = (GenericValue) i.next();
|
||||
GenericValue method = i.next();
|
||||
//Debug.logInfo("Checking Shipping Method : " + method.getString("shipmentMethodTypeId"), module);
|
||||
|
||||
// test min/max weight first
|
||||
@@ -265,9 +265,9 @@ public class ProductStoreWorker {
|
||||
boolean allMatch = false;
|
||||
if (itemSizes != null) {
|
||||
allMatch = true;
|
||||
Iterator isi = itemSizes.iterator();
|
||||
Iterator<Double> isi = itemSizes.iterator();
|
||||
while (isi.hasNext()) {
|
||||
Double size = (Double) isi.next();
|
||||
Double size = isi.next();
|
||||
if (size.doubleValue() < minSize.doubleValue()) {
|
||||
allMatch = false;
|
||||
}
|
||||
@@ -283,9 +283,9 @@ public class ProductStoreWorker {
|
||||
boolean allMatch = false;
|
||||
if (itemSizes != null) {
|
||||
allMatch = true;
|
||||
Iterator isi = itemSizes.iterator();
|
||||
Iterator<Double> isi = itemSizes.iterator();
|
||||
while (isi.hasNext()) {
|
||||
Double size = (Double) isi.next();
|
||||
Double size = isi.next();
|
||||
if (size.doubleValue() > maxSize.doubleValue()) {
|
||||
allMatch = false;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ public class ProductStoreWorker {
|
||||
}
|
||||
}
|
||||
if (includeGeoId != null && includeGeoId.length() > 0) {
|
||||
List includeGeoGroup = GeoWorker.expandGeoGroup(includeGeoId, delegator);
|
||||
List<GenericValue> includeGeoGroup = GeoWorker.expandGeoGroup(includeGeoId, delegator);
|
||||
if (!GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("countryGeoId"), delegator) &&
|
||||
!GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator) &&
|
||||
!GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("postalCodeGeoId"), delegator)) {
|
||||
@@ -361,7 +361,7 @@ public class ProductStoreWorker {
|
||||
}
|
||||
}
|
||||
if (excludeGeoId != null && excludeGeoId.length() > 0) {
|
||||
List excludeGeoGroup = GeoWorker.expandGeoGroup(excludeGeoId, delegator);
|
||||
List<GenericValue> excludeGeoGroup = GeoWorker.expandGeoGroup(excludeGeoId, delegator);
|
||||
if (GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("countryGeoId"), delegator) ||
|
||||
GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator) ||
|
||||
GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("postalCodeGeoId"), delegator)) {
|
||||
@@ -376,7 +376,7 @@ public class ProductStoreWorker {
|
||||
String includeFeatures = method.getString("includeFeatureGroup");
|
||||
String excludeFeatures = method.getString("excludeFeatureGroup");
|
||||
if (includeFeatures != null && includeFeatures.length() > 0) {
|
||||
List includedFeatures = null;
|
||||
List<GenericValue> includedFeatures = null;
|
||||
try {
|
||||
includedFeatures = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", includeFeatures));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -384,9 +384,9 @@ public class ProductStoreWorker {
|
||||
}
|
||||
if (includedFeatures != null) {
|
||||
boolean foundOne = false;
|
||||
Iterator ifet = includedFeatures.iterator();
|
||||
Iterator<GenericValue> ifet = includedFeatures.iterator();
|
||||
while (ifet.hasNext()) {
|
||||
GenericValue appl = (GenericValue) ifet.next();
|
||||
GenericValue appl = ifet.next();
|
||||
if (featureIdMap.containsKey(appl.getString("productFeatureId"))) {
|
||||
foundOne = true;
|
||||
break;
|
||||
@@ -400,16 +400,16 @@ public class ProductStoreWorker {
|
||||
}
|
||||
}
|
||||
if (excludeFeatures != null && excludeFeatures.length() > 0) {
|
||||
List excludedFeatures = null;
|
||||
List<GenericValue> excludedFeatures = null;
|
||||
try {
|
||||
excludedFeatures = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", excludeFeatures));
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + excludeFeatures, module);
|
||||
}
|
||||
if (excludedFeatures != null) {
|
||||
Iterator ifet = excludedFeatures.iterator();
|
||||
Iterator<GenericValue> ifet = excludedFeatures.iterator();
|
||||
while (ifet.hasNext()) {
|
||||
GenericValue appl = (GenericValue) ifet.next();
|
||||
GenericValue appl = ifet.next();
|
||||
if (featureIdMap.containsKey(appl.getString("productFeatureId"))) {
|
||||
returnShippingMethods.remove(method);
|
||||
//Debug.logInfo("Removed shipping method due to an exluded feature being found : " + appl.getString("productFeatureId"), module);
|
||||
@@ -437,34 +437,34 @@ public class ProductStoreWorker {
|
||||
}
|
||||
|
||||
String partyId = userLogin != null ? userLogin.getString("partyId") : null;
|
||||
Map passThruFields = UtilHttp.getParameterMap(((HttpServletRequest)request));
|
||||
Map<String, Object> passThruFields = UtilHttp.getParameterMap(((HttpServletRequest)request));
|
||||
|
||||
return getRandomSurveyWrapper(productStore.getDelegator(), productStore.getString("productStoreId"), groupName, partyId, passThruFields);
|
||||
}
|
||||
|
||||
public static ProductStoreSurveyWrapper getRandomSurveyWrapper(GenericDelegator delegator, String productStoreId, String groupName, String partyId, Map passThruFields) {
|
||||
List randomSurveys = getSurveys(delegator, productStoreId, groupName, null, "RANDOM_POLL", null);
|
||||
public static ProductStoreSurveyWrapper getRandomSurveyWrapper(GenericDelegator delegator, String productStoreId, String groupName, String partyId, Map<String, Object> passThruFields) {
|
||||
List<GenericValue> randomSurveys = getSurveys(delegator, productStoreId, groupName, null, "RANDOM_POLL", null);
|
||||
if (!UtilValidate.isEmpty(randomSurveys)) {
|
||||
Random rand = new Random();
|
||||
int index = rand.nextInt(randomSurveys.size());
|
||||
GenericValue appl = (GenericValue) randomSurveys.get(index);
|
||||
GenericValue appl = randomSurveys.get(index);
|
||||
return new ProductStoreSurveyWrapper(appl, partyId, passThruFields);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static List getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId) {
|
||||
public static List<GenericValue> getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId) {
|
||||
return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId, null);
|
||||
}
|
||||
|
||||
public static List getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId, String parentProductId) {
|
||||
public static List<GenericValue> getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId, String parentProductId) {
|
||||
return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId,parentProductId);
|
||||
}
|
||||
|
||||
public static List getSurveys(GenericDelegator delegator, String productStoreId, String groupName, String productId, String surveyApplTypeId, String parentProductId) {
|
||||
List surveys = FastList.newInstance();
|
||||
List storeSurveys = null;
|
||||
public static List<GenericValue> getSurveys(GenericDelegator delegator, String productStoreId, String groupName, String productId, String surveyApplTypeId, String parentProductId) {
|
||||
List<GenericValue> surveys = FastList.newInstance();
|
||||
List<GenericValue> storeSurveys = null;
|
||||
try {
|
||||
storeSurveys = delegator.findByAndCache("ProductStoreSurveyAppl", UtilMisc.toMap("productStoreId", productStoreId, "surveyApplTypeId", surveyApplTypeId), UtilMisc.toList("sequenceNum"));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -483,9 +483,9 @@ public class ProductStoreWorker {
|
||||
Debug.log("getSurvey for product " + productId,module);
|
||||
// limit by product
|
||||
if (!UtilValidate.isEmpty(productId) && !UtilValidate.isEmpty(storeSurveys)) {
|
||||
Iterator ssi = storeSurveys.iterator();
|
||||
Iterator<GenericValue> ssi = storeSurveys.iterator();
|
||||
while (ssi.hasNext()) {
|
||||
GenericValue surveyAppl = (GenericValue) ssi.next();
|
||||
GenericValue surveyAppl = ssi.next();
|
||||
GenericValue product = null;
|
||||
String virtualProductId = null;
|
||||
|
||||
@@ -513,16 +513,16 @@ public class ProductStoreWorker {
|
||||
surveys.add(surveyAppl);
|
||||
}
|
||||
} else if (surveyAppl.get("productCategoryId") != null) {
|
||||
List categoryMembers = null;
|
||||
List<GenericValue> categoryMembers = null;
|
||||
try {
|
||||
categoryMembers = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", surveyAppl.get("productCategoryId")));
|
||||
} catch (GenericEntityException e) {
|
||||
Debug.logError(e, "Unable to get ProductCategoryMemebr records for survey application : " + surveyAppl, module);
|
||||
}
|
||||
if (categoryMembers != null) {
|
||||
Iterator cmi = categoryMembers.iterator();
|
||||
Iterator<GenericValue> cmi = categoryMembers.iterator();
|
||||
while (cmi.hasNext()) {
|
||||
GenericValue member = (GenericValue) cmi.next();
|
||||
GenericValue member = cmi.next();
|
||||
if (productId != null && productId.equals(member.getString("productId"))) {
|
||||
surveys.add(surveyAppl);
|
||||
break;
|
||||
@@ -559,7 +559,7 @@ public class ProductStoreWorker {
|
||||
return -1;
|
||||
}
|
||||
|
||||
List surveyResponse = null;
|
||||
List<GenericValue> surveyResponse = null;
|
||||
try {
|
||||
surveyResponse = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("surveyId", surveyId, "partyId", partyId));
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -611,7 +611,7 @@ public class ProductStoreWorker {
|
||||
try {
|
||||
Boolean requiredOkay = null;
|
||||
if (wantRequired != null) {
|
||||
Map invReqResult = dispatcher.runSync("isStoreInventoryRequired", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore));
|
||||
Map<String, Object> invReqResult = dispatcher.runSync("isStoreInventoryRequired", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore));
|
||||
if (ServiceUtil.isError(invReqResult)) {
|
||||
Debug.logError("Error calling isStoreInventoryRequired service, result is: " + invReqResult, module);
|
||||
return false;
|
||||
@@ -621,7 +621,7 @@ public class ProductStoreWorker {
|
||||
|
||||
Boolean availableOkay = null;
|
||||
if (wantAvailable != null) {
|
||||
Map invAvailResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore, "quantity", quantity));
|
||||
Map<String, Object> invAvailResult = dispatcher.runSync("isStoreInventoryAvailable", UtilMisc.toMap("productStoreId", productStoreId, "productId", product.get("productId"), "product", product, "productStore", productStore, "quantity", quantity));
|
||||
if (ServiceUtil.isError(invAvailResult)) {
|
||||
Debug.logError("Error calling isStoreInventoryAvailable service, result is: " + invAvailResult, module);
|
||||
return false;
|
||||
@@ -690,7 +690,7 @@ public class ProductStoreWorker {
|
||||
|
||||
} else {
|
||||
GenericValue product = productConfig.getProduct();
|
||||
List productFacilities = null;
|
||||
List<GenericValue> productFacilities = null;
|
||||
|
||||
try {
|
||||
productFacilities = delegator.getRelatedCache("ProductFacility", product);
|
||||
@@ -700,11 +700,11 @@ public class ProductStoreWorker {
|
||||
}
|
||||
|
||||
if (UtilValidate.isNotEmpty(productFacilities)) {
|
||||
Iterator pfIter = productFacilities.iterator();
|
||||
Iterator<GenericValue> pfIter = productFacilities.iterator();
|
||||
|
||||
while (pfIter.hasNext()) {
|
||||
try {
|
||||
GenericValue pfValue = (GenericValue) pfIter.next();
|
||||
GenericValue pfValue = pfIter.next();
|
||||
|
||||
isInventoryAvailable = ProductWorker.isProductInventoryAvailableByFacility(productConfig, pfValue.getString("facilityId"), quantity, dispatcher);
|
||||
if (isInventoryAvailable == true) {
|
||||
@@ -720,7 +720,7 @@ public class ProductStoreWorker {
|
||||
}
|
||||
}
|
||||
|
||||
protected static Map defaultProductStoreEmailScreenLocation = FastMap.newInstance();
|
||||
protected static Map<String, String> defaultProductStoreEmailScreenLocation = FastMap.newInstance();
|
||||
|
||||
static {
|
||||
defaultProductStoreEmailScreenLocation.put("PRDS_ODR_CONFIRM", "component://ecommerce/widget/EmailOrderScreens.xml#OrderConfirmNotice");
|
||||
@@ -747,6 +747,6 @@ public class ProductStoreWorker {
|
||||
}
|
||||
|
||||
public static String getDefaultProductStoreEmailScreenLocation(String emailType) {
|
||||
return (String) defaultProductStoreEmailScreenLocation.get(emailType);
|
||||
return defaultProductStoreEmailScreenLocation.get(emailType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SubscriptionServices {
|
||||
|
||||
public static final String module = SubscriptionServices.class.getName();
|
||||
|
||||
public static Map processExtendSubscription(DispatchContext dctx, Map context) throws GenericServiceException{
|
||||
public static Map<String, Object> processExtendSubscription(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
|
||||
@@ -65,14 +65,14 @@ public class SubscriptionServices {
|
||||
|
||||
GenericValue lastSubscription = null;
|
||||
try {
|
||||
Map subscriptionFindMap = UtilMisc.toMap("partyId", partyId, "subscriptionResourceId", subscriptionResourceId);
|
||||
Map<String, String> subscriptionFindMap = UtilMisc.toMap("partyId", partyId, "subscriptionResourceId", subscriptionResourceId);
|
||||
// if this subscription is attached to something the customer owns, filter by that too
|
||||
if (UtilValidate.isNotEmpty(inventoryItemId)) subscriptionFindMap.put("inventoryItemId", inventoryItemId);
|
||||
List subscriptionList = delegator.findByAnd("Subscription", subscriptionFindMap);
|
||||
List<GenericValue> subscriptionList = delegator.findByAnd("Subscription", subscriptionFindMap);
|
||||
// DEJ20070718 DON'T filter by date, we want to consider all subscriptions: List listFiltered = EntityUtil.filterByDate(subscriptionList, true);
|
||||
List listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate"));
|
||||
List<GenericValue> listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate"));
|
||||
if (listOrdered.size() > 0) {
|
||||
lastSubscription = (GenericValue) listOrdered.get(0);
|
||||
lastSubscription = listOrdered.get(0);
|
||||
}
|
||||
} catch (GenericEntityException e) {
|
||||
return ServiceUtil.returnError(e.toString());
|
||||
@@ -125,32 +125,32 @@ public class SubscriptionServices {
|
||||
thruDate = new Timestamp(calendar.getTimeInMillis());
|
||||
newSubscription.set("thruDate", thruDate);
|
||||
|
||||
Map result = ServiceUtil.returnSuccess();
|
||||
Map<String, Object> result = ServiceUtil.returnSuccess();
|
||||
try {
|
||||
if (lastSubscription != null && !alwaysCreateNewRecord) {
|
||||
Map updateSubscriptionMap = dctx.getModelService("updateSubscription").makeValid(newSubscription, ModelService.IN_PARAM);
|
||||
Map<String, Object> updateSubscriptionMap = dctx.getModelService("updateSubscription").makeValid(newSubscription, ModelService.IN_PARAM);
|
||||
updateSubscriptionMap.put("userLogin", delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system")));
|
||||
|
||||
Map updateSubscriptionResult = dispatcher.runSync("updateSubscription", updateSubscriptionMap);
|
||||
Map<String, Object> updateSubscriptionResult = dispatcher.runSync("updateSubscription", updateSubscriptionMap);
|
||||
result.put("subscriptionId", updateSubscriptionMap.get("subscriptionId"));
|
||||
if (ServiceUtil.isError(updateSubscriptionResult)) {
|
||||
return ServiceUtil.returnError("Error processing subscription update with ID [" + updateSubscriptionMap.get("subscriptionId") + "]", null, null, updateSubscriptionResult);
|
||||
}
|
||||
} else {
|
||||
Map createPartyRoleMap = FastMap.newInstance();
|
||||
Map<String, Object> createPartyRoleMap = FastMap.newInstance();
|
||||
if (UtilValidate.isNotEmpty(roleTypeId)) {
|
||||
createPartyRoleMap.put("partyId", partyId);
|
||||
createPartyRoleMap.put("roleTypeId", roleTypeId);
|
||||
createPartyRoleMap.put("userLogin", userLogin);
|
||||
Map createPartyRoleResult = dispatcher.runSync("createPartyRole", createPartyRoleMap);
|
||||
Map<String, Object> createPartyRoleResult = dispatcher.runSync("createPartyRole", createPartyRoleMap);
|
||||
if (ServiceUtil.isError(createPartyRoleResult)) {
|
||||
return ServiceUtil.returnError("Error creating new PartyRole while processing subscription update with resource ID [" + subscriptionResourceId + "]", null, null, createPartyRoleResult);
|
||||
}
|
||||
}
|
||||
Map createSubscriptionMap = dctx.getModelService("createSubscription").makeValid(newSubscription, ModelService.IN_PARAM);
|
||||
Map<String, Object> createSubscriptionMap = dctx.getModelService("createSubscription").makeValid(newSubscription, ModelService.IN_PARAM);
|
||||
createSubscriptionMap.put("userLogin", delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system")));
|
||||
|
||||
Map createSubscriptionResult = dispatcher.runSync("createSubscription", createSubscriptionMap);
|
||||
Map<String, Object> createSubscriptionResult = dispatcher.runSync("createSubscription", createSubscriptionMap);
|
||||
if (ServiceUtil.isError(createSubscriptionResult)) {
|
||||
return ServiceUtil.returnError("Error creating subscription while processing with resource ID [" + subscriptionResourceId + "]", null, null, createSubscriptionResult);
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class SubscriptionServices {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map processExtendSubscriptionByProduct(DispatchContext dctx, Map context) throws GenericServiceException{
|
||||
public static Map<String, Object> processExtendSubscriptionByProduct(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
String productId = (String) context.get("productId");
|
||||
@@ -178,7 +178,7 @@ public class SubscriptionServices {
|
||||
orderCreatedDate = UtilDateTime.nowTimestamp();
|
||||
}
|
||||
try {
|
||||
List productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId));
|
||||
List<GenericValue> productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId));
|
||||
productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, null, null, true);
|
||||
productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, "purchaseFromDate", "purchaseThruDate", true);
|
||||
|
||||
@@ -188,25 +188,25 @@ public class SubscriptionServices {
|
||||
return ServiceUtil.returnError(msg);
|
||||
}
|
||||
|
||||
Iterator productSubscriptionResourceIter = productSubscriptionResourceList.iterator();
|
||||
Iterator<GenericValue> productSubscriptionResourceIter = productSubscriptionResourceList.iterator();
|
||||
while (productSubscriptionResourceIter.hasNext()) {
|
||||
GenericValue productSubscriptionResource = (GenericValue) productSubscriptionResourceIter.next();
|
||||
|
||||
Long useTime = (Long) productSubscriptionResource.get("useTime");
|
||||
GenericValue productSubscriptionResource = productSubscriptionResourceIter.next();
|
||||
Long useTime = productSubscriptionResource.getLong("useTime");
|
||||
Integer newUseTime = Integer.valueOf(0);
|
||||
if (useTime != null) {
|
||||
newUseTime = Integer.valueOf(useTime.intValue() * qty.intValue());
|
||||
}
|
||||
context.put("useTime", newUseTime);
|
||||
context.put("useTimeUomId", productSubscriptionResource.get("useTimeUomId"));
|
||||
context.put("useRoleTypeId", productSubscriptionResource.get("useRoleTypeId"));
|
||||
context.put("subscriptionResourceId", productSubscriptionResource.get("subscriptionResourceId"));
|
||||
context.put("automaticExtend", productSubscriptionResource.get("automaticExtend"));
|
||||
context.put("canclAutmExtTime", productSubscriptionResource.get("canclAutmExtTime"));
|
||||
context.put("canclAutmExtTimeUomId", productSubscriptionResource.get("canclAutmExtTimeUomId"));
|
||||
Map<String, Object> subContext = UtilMisc.makeMapWritable(context);
|
||||
subContext.put("useTime", newUseTime);
|
||||
subContext.put("useTimeUomId", productSubscriptionResource.get("useTimeUomId"));
|
||||
subContext.put("useRoleTypeId", productSubscriptionResource.get("useRoleTypeId"));
|
||||
subContext.put("subscriptionResourceId", productSubscriptionResource.get("subscriptionResourceId"));
|
||||
subContext.put("automaticExtend", productSubscriptionResource.get("automaticExtend"));
|
||||
subContext.put("canclAutmExtTime", productSubscriptionResource.get("canclAutmExtTime"));
|
||||
subContext.put("canclAutmExtTimeUomId", productSubscriptionResource.get("canclAutmExtTimeUomId"));
|
||||
|
||||
Map ctx = dctx.getModelService("processExtendSubscription").makeValid(context, ModelService.IN_PARAM);
|
||||
Map processExtendSubscriptionResult = dispatcher.runSync("processExtendSubscription", ctx);
|
||||
Map<String, Object> ctx = dctx.getModelService("processExtendSubscription").makeValid(subContext, ModelService.IN_PARAM);
|
||||
Map<String, Object> processExtendSubscriptionResult = dispatcher.runSync("processExtendSubscription", ctx);
|
||||
if (ServiceUtil.isError(processExtendSubscriptionResult)) {
|
||||
return ServiceUtil.returnError("Error processing subscriptions for Product with ID [" + productId + "]", null, null, processExtendSubscriptionResult);
|
||||
}
|
||||
@@ -219,20 +219,21 @@ public class SubscriptionServices {
|
||||
return ServiceUtil.returnSuccess();
|
||||
}
|
||||
|
||||
public static Map processExtendSubscriptionByOrder(DispatchContext dctx, Map context) throws GenericServiceException{
|
||||
public static Map<String, Object> processExtendSubscriptionByOrder(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Map<String, Object> subContext = UtilMisc.makeMapWritable(context);
|
||||
String orderId = (String) context.get("orderId");
|
||||
|
||||
Debug.logInfo("In processExtendSubscriptionByOrder service with orderId: " + orderId, module);
|
||||
|
||||
GenericValue orderHeader = null;
|
||||
try {
|
||||
List orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER"));
|
||||
List<GenericValue> orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER"));
|
||||
if (orderRoleList.size() > 0 ) {
|
||||
GenericValue orderRole = (GenericValue)orderRoleList.get(0);
|
||||
GenericValue orderRole = orderRoleList.get(0);
|
||||
String partyId = (String) orderRole.get("partyId");
|
||||
context.put("partyId", partyId);
|
||||
subContext.put("partyId", partyId);
|
||||
} else {
|
||||
String msg = "No OrderRole found for orderId:" + orderId;
|
||||
return ServiceUtil.returnFailure(msg);
|
||||
@@ -243,27 +244,27 @@ public class SubscriptionServices {
|
||||
return ServiceUtil.returnError(msg);
|
||||
}
|
||||
Timestamp orderCreatedDate = (Timestamp) orderHeader.get("orderDate");
|
||||
context.put("orderCreatedDate", orderCreatedDate);
|
||||
List orderItemList = orderHeader.getRelated("OrderItem");
|
||||
Iterator orderItemIter = orderItemList.iterator();
|
||||
subContext.put("orderCreatedDate", orderCreatedDate);
|
||||
List<GenericValue> orderItemList = orderHeader.getRelated("OrderItem");
|
||||
Iterator<GenericValue> orderItemIter = orderItemList.iterator();
|
||||
while (orderItemIter.hasNext()) {
|
||||
GenericValue orderItem = (GenericValue)orderItemIter.next();
|
||||
Double qty = (Double) orderItem.get("quantity");
|
||||
String productId = (String) orderItem.get("productId");
|
||||
GenericValue orderItem = orderItemIter.next();
|
||||
Double qty = orderItem.getDouble("quantity");
|
||||
String productId = orderItem.getString("productId");
|
||||
if (UtilValidate.isEmpty(productId)) {
|
||||
continue;
|
||||
}
|
||||
List productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId));
|
||||
List productSubscriptionResourceListFiltered = EntityUtil.filterByDate(productSubscriptionResourceList, true);
|
||||
List<GenericValue> productSubscriptionResourceList = delegator.findByAndCache("ProductSubscriptionResource", UtilMisc.toMap("productId", productId));
|
||||
List<GenericValue> productSubscriptionResourceListFiltered = EntityUtil.filterByDate(productSubscriptionResourceList, true);
|
||||
if (productSubscriptionResourceListFiltered.size() > 0) {
|
||||
context.put("subscriptionTypeId", "PRODUCT_SUBSCR");
|
||||
context.put("productId", productId);
|
||||
context.put("orderId", orderId);
|
||||
context.put("orderItemSeqId", orderItem.get("orderItemSeqId"));
|
||||
context.put("inventoryItemId", orderItem.get("fromInventoryItemId"));
|
||||
context.put("quantity", Integer.valueOf(qty.intValue()));
|
||||
Map ctx = dctx.getModelService("processExtendSubscriptionByProduct").makeValid(context, ModelService.IN_PARAM);
|
||||
Map thisResult = dispatcher.runSync("processExtendSubscriptionByProduct", ctx);
|
||||
subContext.put("subscriptionTypeId", "PRODUCT_SUBSCR");
|
||||
subContext.put("productId", productId);
|
||||
subContext.put("orderId", orderId);
|
||||
subContext.put("orderItemSeqId", orderItem.get("orderItemSeqId"));
|
||||
subContext.put("inventoryItemId", orderItem.get("fromInventoryItemId"));
|
||||
subContext.put("quantity", Integer.valueOf(qty.intValue()));
|
||||
Map<String, Object> ctx = dctx.getModelService("processExtendSubscriptionByProduct").makeValid(subContext, ModelService.IN_PARAM);
|
||||
Map<String, Object> thisResult = dispatcher.runSync("processExtendSubscriptionByProduct", ctx);
|
||||
if (ServiceUtil.isError(thisResult)) {
|
||||
return ServiceUtil.returnError("Error processing subscriptions for Order with ID [" + orderId + "]", null, null, thisResult);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import javolution.util.FastMap;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilDateTime;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilMisc;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
import org.ofbiz.entity.GenericDelegator;
|
||||
@@ -54,8 +55,8 @@ public class SupplierProductServices {
|
||||
* Result: a List of SupplierProduct entities for productId,
|
||||
* filtered by date and optionally by partyId, ordered with lowest price first
|
||||
*/
|
||||
public static Map getSuppliersForProduct(DispatchContext dctx, Map context) {
|
||||
Map results = FastMap.newInstance();
|
||||
public static Map<String, Object> getSuppliersForProduct(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Map<String, Object> results = FastMap.newInstance();
|
||||
GenericDelegator delegator = dctx.getDelegator();
|
||||
|
||||
GenericValue product = null;
|
||||
@@ -71,7 +72,7 @@ public class SupplierProductServices {
|
||||
results.put("supplierProducts",null);
|
||||
return results;
|
||||
}
|
||||
List supplierProducts = product.getRelatedCache("SupplierProduct");
|
||||
List<GenericValue> supplierProducts = product.getRelatedCache("SupplierProduct");
|
||||
|
||||
// if there were no related SupplierProduct entities and the item is a variant, then get the SupplierProducts of the virtual parent product
|
||||
if (supplierProducts.size() == 0 && product.getString("isVariant") != null && product.getString("isVariant").equals("Y")) {
|
||||
@@ -126,23 +127,23 @@ public class SupplierProductServices {
|
||||
* Service will convert each feature in the Collection, changing their idCode and description based on the
|
||||
* SupplierProduct entity for that supplier party and feature, and return it as convertedProductFeatures
|
||||
*/
|
||||
public static Map convertFeaturesForSupplier(DispatchContext dctx, Map context) {
|
||||
Map results = FastMap.newInstance();
|
||||
public static Map<String, Object> convertFeaturesForSupplier(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
Map<String, Object> results = FastMap.newInstance();
|
||||
String partyId = (String) context.get("partyId");
|
||||
Collection features = (Collection) context.get("productFeatures");
|
||||
Collection<GenericValue> features = UtilGenerics.checkList(context.get("productFeatures"));
|
||||
|
||||
try {
|
||||
if (partyId != null && UtilValidate.isNotEmpty(features)) {
|
||||
// loop through all the features, find the related SupplierProductFeature for the given partyId, and
|
||||
// substitue description and idCode
|
||||
for (Iterator fI = features.iterator(); fI.hasNext(); ) {
|
||||
GenericValue nextFeature = (GenericValue) fI.next();
|
||||
List supplierFeatures = EntityUtil.filterByAnd(nextFeature.getRelated("SupplierProductFeature"),
|
||||
for (Iterator<GenericValue> fI = features.iterator(); fI.hasNext(); ) {
|
||||
GenericValue nextFeature = fI.next();
|
||||
List<GenericValue> supplierFeatures = EntityUtil.filterByAnd(nextFeature.getRelated("SupplierProductFeature"),
|
||||
UtilMisc.toMap("partyId", partyId));
|
||||
GenericValue supplierFeature = null;
|
||||
|
||||
if ((supplierFeatures != null) && (supplierFeatures.size() > 0)) {
|
||||
supplierFeature = (GenericValue) supplierFeatures.get(0);
|
||||
supplierFeature = supplierFeatures.get(0);
|
||||
if (supplierFeature.get("description") != null) {
|
||||
nextFeature.put("description", supplierFeature.get("description"));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class InventoryItemTransferTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testCreateInventoryItemsTransfer() throws Exception {
|
||||
Map ctx = FastMap.newInstance();
|
||||
Map<String, Object> ctx = FastMap.newInstance();
|
||||
String statusId = "IXF_REQUESTED";
|
||||
String inventoryItemId = "9005";
|
||||
ctx.put("inventoryItemId", inventoryItemId);
|
||||
@@ -61,22 +61,22 @@ public class InventoryItemTransferTest extends TestCase {
|
||||
ctx.put("facilityId", "WebStoreWarehouse");
|
||||
ctx.put("facilityIdTo", "WebStoreWarehouse");
|
||||
ctx.put("receiveDate", UtilDateTime.nowTimestamp());
|
||||
ctx.put("xferQty", new Double (transferQty));
|
||||
ctx.put("xferQty", Double.valueOf(transferQty));
|
||||
ctx.put("userLogin", userLogin);
|
||||
Map resp = dispatcher.runSync("createInventoryTransfer", ctx);
|
||||
Map<String, Object> resp = dispatcher.runSync("createInventoryTransfer", ctx);
|
||||
inventoryTransferId = (String) resp.get("inventoryTransferId");
|
||||
assertNotNull(inventoryTransferId);
|
||||
}
|
||||
|
||||
public void testUpdateInventoryItemTransfer() throws Exception {
|
||||
Map ctx = FastMap.newInstance();
|
||||
Map<String, Object> ctx = FastMap.newInstance();
|
||||
String statusId = "IXF_COMPLETE";
|
||||
ctx.put("inventoryTransferId", inventoryTransferId);
|
||||
String inventoryItemId = delegator.findByPrimaryKey("InventoryTransfer", UtilMisc.toMap("inventoryTransferId", inventoryTransferId)).getString("inventoryItemId");
|
||||
ctx.put("inventoryItemId", inventoryItemId);
|
||||
ctx.put("statusId", statusId);
|
||||
ctx.put("userLogin", userLogin);
|
||||
Map resp = dispatcher.runSync("updateInventoryTransfer", ctx);
|
||||
Map<String, Object> resp = dispatcher.runSync("updateInventoryTransfer", ctx);
|
||||
String respMsg = (String) resp.get("responseMessage");
|
||||
assertNotSame("error", respMsg);
|
||||
}
|
||||
|
||||
@@ -55,13 +55,13 @@ public class StockMovesTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testStockMoves() throws Exception {
|
||||
Map fsmnCtx = FastMap.newInstance();
|
||||
Map<String, Object> fsmnCtx = FastMap.newInstance();
|
||||
Map stockMoveHandled = null;
|
||||
List warningList = FastList.newInstance();
|
||||
|
||||
fsmnCtx.put("facilityId", "WebStoreWarehouse");
|
||||
fsmnCtx.put("userLogin", userLogin);
|
||||
Map respMap1 = dispatcher.runSync("findStockMovesNeeded", fsmnCtx);
|
||||
Map<String, Object> respMap1 = dispatcher.runSync("findStockMovesNeeded", fsmnCtx);
|
||||
stockMoveHandled = (Map) respMap1.get("stockMoveHandled");
|
||||
warningList = (List) respMap1.get("warningMessageList");
|
||||
assertNull(warningList);
|
||||
@@ -69,17 +69,17 @@ public class StockMovesTest extends TestCase {
|
||||
if (stockMoveHandled != null) {
|
||||
fsmnCtx.put("stockMoveHandled", stockMoveHandled);
|
||||
}
|
||||
Map respMap2 = dispatcher.runSync("findStockMovesRecommended", fsmnCtx);
|
||||
Map<String, Object> respMap2 = dispatcher.runSync("findStockMovesRecommended", fsmnCtx);
|
||||
warningList = (List) respMap2.get("warningMessageList");
|
||||
assertNull(warningList);
|
||||
|
||||
Map ppsmCtx = FastMap.newInstance();
|
||||
Map<String, Object> ppsmCtx = FastMap.newInstance();
|
||||
ppsmCtx.put("productId", "GZ-2644");
|
||||
ppsmCtx.put("facilityId", "WebStoreWarehouse");
|
||||
ppsmCtx.put("locationSeqId","TLTLTLUL01" );
|
||||
ppsmCtx.put("targetLocationSeqId", "TLTLTLLL01");
|
||||
ppsmCtx.put("quantityMoved", Double.valueOf(5));
|
||||
ppsmCtx.put("userLogin", userLogin);
|
||||
Map respMap3 = dispatcher.runSync("processPhysicalStockMove", ppsmCtx);
|
||||
Map<String, Object> respMap3 = dispatcher.runSync("processPhysicalStockMove", ppsmCtx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user