Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java Mon Nov 24 10:06:26 2014 @@ -43,6 +43,7 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.transaction.GenericTransactionException; import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.product.product.ProductSearch.ProductSearchContext; import org.ofbiz.product.product.ProductSearch.ResultSortOrder; @@ -143,7 +144,7 @@ public class ProductSearchEvents { while ((searchResultView = eli.next()) != null) { String productId = searchResultView.getString("mainProductId"); //get all tuples that match product and category - List<GenericValue> pcmList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId), null, false); + List<GenericValue> pcmList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", productCategoryId, "productId", productId).queryList(); //set those thrudate to that specificed maybe remove then add new one for (GenericValue pcm: pcmList) { @@ -413,15 +414,11 @@ public class ProductSearchEvents { String productId = searchResultView.getString("mainProductId"); productMap.put("productId", productId); - List<GenericValue> productFeaturesCustomRaw = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureTypeId", "HAZMAT"), null, false); - List<GenericValue> productFeaturesCustom = EntityUtil.filterByDate(productFeaturesCustomRaw); - productMap.put("productFeatureCustom", EntityUtil.getFirst(productFeaturesCustom)); + productMap.put("productFeatureCustom", EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureTypeId", "HAZMAT").filterByDate().queryFirst()); - List<GenericValue> productCategoriesRaw = delegator.findByAnd("ProductCategoryAndMember", UtilMisc.toMap("productId", productId), null, false); - List<GenericValue> productCategories = EntityUtil.filterByDate(productCategoriesRaw); + List<GenericValue> productCategories = EntityQuery.use(delegator).from("ProductCategoryAndMember").where("productId", productId).filterByDate().queryList(); productMap.put("productCategories", productCategories); - List<GenericValue> productFeaturesRaw = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId), null, false); - List<GenericValue> productFeatures = EntityUtil.filterByDate(productFeaturesRaw); + List<GenericValue> productFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId).filterByDate().queryList(); productMap.put("productFeatures", productFeatures); productExportList.add(productMap); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Mon Nov 24 10:06:26 2014 @@ -53,6 +53,7 @@ import org.ofbiz.entity.model.DynamicVie import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.product.catalog.CatalogWorker; import org.ofbiz.product.category.CategoryWorker; @@ -400,8 +401,7 @@ public class ProductSearchSession { if (keywords.size() > 0) { List<GenericValue> productStoreKeywordOvrdList = null; try { - productStoreKeywordOvrdList = delegator.findByAnd("ProductStoreKeywordOvrd", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("-fromDate"), true); - productStoreKeywordOvrdList = EntityUtil.filterByDate(productStoreKeywordOvrdList, true); + productStoreKeywordOvrdList = EntityQuery.use(delegator).from("ProductStoreKeywordOvrd").where("productStoreId", productStoreId).orderBy("-fromDate").cache(true).filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Error reading ProductStoreKeywordOvrd list, not doing keyword override", module); } @@ -930,11 +930,16 @@ public class ProductSearchSession { addOnTopProdCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, now))); addOnTopProdCondList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, now)); addOnTopProdCondList.add(EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, addOnTopProdCategoryId)); - EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); - findOpts.setMaxRows(highIndex); EntityListIterator pli = null; try { - pli = delegator.find("ProductCategoryMember", EntityCondition.makeCondition(addOnTopProdCondList, EntityOperator.AND), null, UtilMisc.toSet("productId", "sequenceNum"), UtilMisc.toList("sequenceNum"), findOpts); + pli = EntityQuery.use(delegator).select(UtilMisc.toSet("productId", "sequenceNum")) + .from("ProductCategoryMember") + .where(addOnTopProdCondList) + .orderBy("sequenceNum") + .cursorScrollInsensitive() + .distinct() + .maxRows(highIndex) + .queryIterator(); addOnTopProductCategoryMembers = pli.getPartialList(lowIndex, viewSize); addOnTopListSize = addOnTopProductCategoryMembers.size(); for (GenericValue alwaysAddProductCategoryMember: addOnTopProductCategoryMembers) { @@ -1219,7 +1224,6 @@ public class ProductSearchSession { DynamicViewEntity dynamicViewEntity = productSearchContext.dynamicViewEntity; List<EntityCondition> entityConditionList = productSearchContext.entityConditionList; - List<String> fieldsToSelect = FastList.newInstance(); dynamicViewEntity.addMemberEntity("PFAC", "ProductFeatureAppl"); dynamicViewEntity.addAlias("PFAC", "pfacProductFeatureId", "productFeatureId", null, null, Boolean.TRUE, null); @@ -1227,8 +1231,6 @@ public class ProductSearchSession { dynamicViewEntity.addAlias("PFAC", "pfacThruDate", "thruDate", null, null, null, null); dynamicViewEntity.addAlias("PFAC", "featureCount", "productId", null, null, null, "count-distinct"); dynamicViewEntity.addViewLink("PROD", "PFAC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId")); - fieldsToSelect.add("pfacProductFeatureId"); - fieldsToSelect.add("featureCount"); entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("pfacThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("pfacThruDate", EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp()))); entityConditionList.add(EntityCondition.makeCondition("pfacFromDate", EntityOperator.LESS_THAN, UtilDateTime.nowTimestamp())); @@ -1236,18 +1238,17 @@ public class ProductSearchSession { dynamicViewEntity.addAlias("PFC", "pfcProductFeatureTypeId", "productFeatureTypeId", null, null, Boolean.TRUE, null); dynamicViewEntity.addAlias("PFC", "pfcDescription", "description", null, null, Boolean.TRUE, null); dynamicViewEntity.addViewLink("PFAC", "PFC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productFeatureId")); - fieldsToSelect.add("pfcDescription"); - fieldsToSelect.add("pfcProductFeatureTypeId"); entityConditionList.add(EntityCondition.makeCondition("pfcProductFeatureTypeId", EntityOperator.EQUALS, productFeatureTypeId)); - EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND); - - EntityFindOptions efo = new EntityFindOptions(); - efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE); - EntityListIterator eli = null; try { - eli = delegator.findListIteratorByCondition(dynamicViewEntity, whereCondition, null, fieldsToSelect, productSearchContext.orderByList, efo); + eli = EntityQuery.use(delegator) + .select(UtilMisc.toSet("pfacProductFeatureId", "featureCount", "pfcDescription", "pfcProductFeatureTypeId")) + .from(dynamicViewEntity) + .where(entityConditionList) + .orderBy(productSearchContext.orderByList) + .cursorScrollInsensitive() + .queryIterator(); } catch (GenericEntityException e) { Debug.logError(e, "Error in product search", module); return null; @@ -1318,14 +1319,14 @@ public class ProductSearchSession { entityConditionList.add(EntityCondition.makeCondition("ppcPrice", EntityOperator.LESS_THAN_EQUAL_TO, priceHigh)); entityConditionList.add(EntityCondition.makeCondition("ppcProductPriceTypeId", EntityOperator.EQUALS, "LIST_PRICE")); - EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND); - - EntityFindOptions efo = new EntityFindOptions(); - efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE); - EntityListIterator eli = null; try { - eli = delegator.findListIteratorByCondition(dynamicViewEntity, whereCondition, null, fieldsToSelect, productSearchContext.orderByList, efo); + eli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect)) + .from(dynamicViewEntity) + .where(entityConditionList) + .orderBy(productSearchContext.orderByList) + .cursorScrollInsensitive() + .queryIterator(); } catch (GenericEntityException e) { Debug.logError(e, "Error in product search", module); return 0; @@ -1384,14 +1385,14 @@ public class ProductSearchSession { ProductSearch.getAllSubCategoryIds(productCategoryId, productCategoryIdSet, delegator, productSearchContext.nowTimestamp); entityConditionList.add(EntityCondition.makeCondition("pcmcProductCategoryId", EntityOperator.IN, productCategoryIdSet)); - EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND); - - EntityFindOptions efo = new EntityFindOptions(); - efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE); - EntityListIterator eli = null; try { - eli = delegator.findListIteratorByCondition(dynamicViewEntity, whereCondition, null, fieldsToSelect, productSearchContext.orderByList, efo); + eli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect)) + .from(dynamicViewEntity) + .where(entityConditionList) + .orderBy(productSearchContext.orderByList) + .cursorScrollInsensitive() + .queryIterator(); } catch (GenericEntityException e) { Debug.logError(e, "Error in product search", module); return 0; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductServices.java Mon Nov 24 10:06:26 2014 @@ -165,9 +165,7 @@ public class ProductServices { Set<String> featureSet = new LinkedHashSet<String>(); try { - Map<String, String> fields = UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", productFeatureApplTypeId); - List<String> order = UtilMisc.toList("sequenceNum", "productFeatureTypeId"); - List<GenericValue> features = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true); + List<GenericValue> features = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", productFeatureApplTypeId).orderBy("sequenceNum", "productFeatureTypeId").cache(true).queryList(); for (GenericValue v: features) { featureSet.add(v.getString("productFeatureTypeId")); } @@ -297,11 +295,7 @@ public class ProductServices { // Make the selectable feature list List<GenericValue> selectableFeatures = null; try { - Map<String, String> fields = UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "SELECTABLE_FEATURE"); - List<String> sort = UtilMisc.toList("sequenceNum"); - - selectableFeatures = delegator.findByAnd("ProductFeatureAndAppl", fields, sort, true); - selectableFeatures = EntityUtil.filterByDate(selectableFeatures, true); + selectableFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", "SELECTABLE_FEATURE").orderBy("sequenceNum").cache(true).filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -374,11 +368,10 @@ public class ProductServices { try { Map<String, String> fields = UtilMisc.toMap("productId", productId); - List<String> order = UtilMisc.toList("sequenceNum", "productFeatureTypeId"); if (distinct != null) fields.put("productFeatureTypeId", distinct); if (type != null) fields.put("productFeatureApplTypeId", type); - features = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true); + features = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where(fields).orderBy("sequenceNum", "productFeatureTypeId").cache(true).queryList(); result.put("productFeatures", features); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); } catch (GenericEntityException e) { @@ -517,8 +510,7 @@ public class ProductServices { EntityCondition.makeCondition("productId", productId), EntityCondition.makeCondition("productIdTo", productId) ), EntityJoinOperator.OR); - cond = EntityCondition.makeCondition(cond, EntityCondition.makeCondition("productAssocTypeId", type)); - productAssocs = delegator.findList("ProductAssoc", cond, null, orderBy, null, true); + productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where(EntityCondition.makeCondition(cond, EntityCondition.makeCondition("productAssocTypeId", type))).orderBy(orderBy).cache(true).queryList(); } else { if (productIdTo == null) { productAssocs = product.getRelated("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", type), orderBy, true); @@ -584,13 +576,13 @@ public class ProductServices { List<GenericValue> features = null; try { - Map<String, String> fields = UtilMisc.toMap("productId", thisItem, "productFeatureTypeId", orderKey, - "productFeatureApplTypeId", "STANDARD_FEATURE"); - List<String> sort = UtilMisc.toList("sequenceNum"); - // get the features and filter out expired dates - features = delegator.findByAnd("ProductFeatureAndAppl", fields, sort, true); - features = EntityUtil.filterByDate(features, true); + features = EntityQuery.use(delegator).from("ProductFeatureAndAppl") + .where("productId", thisItem, "productFeatureTypeId", orderKey, "productFeatureApplTypeId", "STANDARD_FEATURE") + .orderBy("sequenceNum") + .cache(true) + .filterByDate() + .queryList(); } catch (GenericEntityException e) { throw new IllegalStateException("Problem reading relation: " + e.getMessage()); } @@ -661,20 +653,19 @@ public class ProductServices { List<GenericValue> features = null; try { - Map<String, String> fields = UtilMisc.toMap("productId", productId, "productFeatureTypeId", feature, - "productFeatureApplTypeId", "STANDARD_FEATURE"); - List<String> sort = UtilMisc.toList("sequenceNum", "description"); - // get the features and filter out expired dates - features = delegator.findByAnd("ProductFeatureAndAppl", fields, sort, true); - features = EntityUtil.filterByDate(features, true); + features = EntityQuery.use(delegator).from("ProductFeatureAndAppl") + .where("productId", productId, "productFeatureTypeId", feature, "productFeatureApplTypeId", "STANDARD_FEATURE") + .orderBy("sequenceNum", "description") + .cache(true) + .filterByDate() + .queryList(); } catch (GenericEntityException e) { throw new IllegalStateException("Problem reading relation: " + e.getMessage()); } for (GenericValue featureAppl: features) { try { - GenericValue product = delegator.findOne("Product", - UtilMisc.toMap("productId", productId), true); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache(true).queryOne(); tempSample.put(featureAppl.getString("description"), product); } catch (GenericEntityException e) { @@ -715,7 +706,7 @@ public class ProductServices { return result; } // check if product exists - GenericValue variantProduct = delegator.findOne("Product",UtilMisc.toMap("productId", variantProductId), false); + GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne(); boolean variantProductExists = (variantProduct != null); if (variantProduct == null) { //if product does not exist @@ -847,7 +838,7 @@ public class ProductServices { variantProductsById.put(variantProductId, variantProduct); } else { // is a GoodIdentification.idValue? - List<GenericValue> goodIdentificationList = delegator.findByAnd("GoodIdentification", UtilMisc.toMap("idValue", variantProductId), null, false); + List<GenericValue> goodIdentificationList = EntityQuery.use(delegator).from("GoodIdentification").where("idValue", variantProductId).queryList(); if (UtilValidate.isEmpty(goodIdentificationList)) { // whoops, nothing found... return error return ServiceUtil.returnError(UtilProperties.getMessage(resource, @@ -950,7 +941,7 @@ public class ProductServices { // refresh the product so we can update it GenericValue productToUpdate = null; try { - productToUpdate = delegator.findOne("Product", product.getPrimaryKey(), false); + productToUpdate = EntityQuery.use(delegator).from("Product").where(product.getPrimaryKey()).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -1006,7 +997,7 @@ public class ProductServices { List<GenericValue> fileExtension = FastList.newInstance(); try { - fileExtension = delegator.findByAnd("FileExtension", UtilMisc.toMap("mimeTypeId", (String) context.get("_uploadedFile_contentType")), null, false); + fileExtension = EntityQuery.use(delegator).from("FileExtension").where("mimeTypeId", (String) context.get("_uploadedFile_contentType")).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -1294,7 +1285,7 @@ public class ProductServices { List<GenericValue> fileExtension = FastList.newInstance(); try { - fileExtension = delegator.findList("FileExtension", EntityCondition.makeCondition("mimeTypeId", EntityOperator.EQUALS, (String) context.get("_uploadedFile_contentType")), null, null, null, false); + fileExtension = EntityQuery.use(delegator).from("FileExtension").where("mimeTypeId", EntityOperator.EQUALS, (String) context.get("_uploadedFile_contentType")).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java Mon Nov 24 10:06:26 2014 @@ -74,7 +74,7 @@ public class ProductUtilServices { EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.NOT_EQUAL, null), EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp) ), EntityOperator.AND); - EntityListIterator eliOne = delegator.find("Product", conditionOne, null, null, null, null); + EntityListIterator eliOne = EntityQuery.use(delegator).from("Product").where(conditionOne).queryIterator(); GenericValue productOne = null; int numSoFarOne = 0; while ((productOne = eliOne.next()) != null) { @@ -83,8 +83,10 @@ public class ProductUtilServices { if (virtualProduct == null) { continue; } - List<GenericValue> passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), null, false); - passocList = EntityUtil.filterByDate(passocList); + List<GenericValue> passocList = EntityQuery.use(delegator).from("ProductAssoc") + .where("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT") + .filterByDate() + .queryList(); if (passocList.size() > 0) { for (GenericValue passoc: passocList) { passoc.set("thruDate", nowTimestamp); @@ -104,12 +106,11 @@ public class ProductUtilServices { EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, "Y"), EntityCondition.makeCondition(EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp)) ), EntityOperator.AND); - EntityListIterator eli = delegator.find("Product", condition, null, null, null, null); + EntityListIterator eli = EntityQuery.use(delegator).from("Product").where(condition).queryIterator(); GenericValue product = null; int numSoFar = 0; while ((product = eli.next()) != null) { - List<GenericValue> passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), null, false); - passocList = EntityUtil.filterByDate(passocList); + List<GenericValue> passocList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); if (passocList.size() == 0) { product.set("salesDiscontinuationDate", nowTimestamp); delegator.store(product); @@ -143,12 +144,12 @@ public class ProductUtilServices { EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.NOT_EQUAL, null), EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp) ), EntityOperator.AND); - EntityListIterator eli = delegator.find("Product", condition, null, null, null, null); + EntityListIterator eli = EntityQuery.use(delegator).from("Product").where(condition).queryIterator(); GenericValue product = null; int numSoFar = 0; while ((product = eli.next()) != null) { String productId = product.getString("productId"); - List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", productId), null, false); + List<GenericValue> productCategoryMemberList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", productId).queryList(); if (productCategoryMemberList.size() > 0) { for (GenericValue productCategoryMember: productCategoryMemberList) { // coded this way rather than a removeByAnd so it can be easily changed... @@ -192,11 +193,11 @@ public class ProductUtilServices { EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null) ), EntityOperator.AND); EntityCondition havingCond = EntityCondition.makeCondition("productIdCount", EntityOperator.GREATER_THAN, Long.valueOf(1)); - EntityListIterator eli = delegator.findListIteratorByCondition(dve, condition, havingCond, UtilMisc.toList("productId", "productCategoryId", "productIdCount"), null, null); + EntityListIterator eli = EntityQuery.use(delegator).select("productId", "productCategoryId", "productIdCount").from(dve).where(condition).having(havingCond).queryIterator(); GenericValue pcm = null; int numSoFar = 0; while ((pcm = eli.next()) != null) { - List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", pcm.get("productId"), "productCategoryId", pcm.get("productCategoryId")), null, false); + List<GenericValue> productCategoryMemberList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productId", pcm.get("productId"), "productCategoryId", pcm.get("productCategoryId")).queryList(); if (productCategoryMemberList.size() > 1) { // remove all except the first... productCategoryMemberList.remove(0); @@ -251,7 +252,10 @@ public class ProductUtilServices { EntityCondition.makeCondition(EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.GREATER_THAN, nowTimestamp)) ), EntityOperator.AND); EntityCondition havingCond = EntityCondition.makeCondition("productIdToCount", EntityOperator.EQUALS, Long.valueOf(1)); - EntityListIterator eliOne = delegator.findListIteratorByCondition(dve, condition, havingCond, UtilMisc.toList("productId", "productIdToCount"), null, null); + EntityListIterator eliOne = EntityQuery.use(delegator).select("productId", "productIdToCount").from(dve) + .where(condition) + .having(havingCond) + .queryIterator(); List<GenericValue> valueList = eliOne.getCompleteList(); eliOne.close(); @@ -261,8 +265,7 @@ public class ProductUtilServices { for (GenericValue value: valueList) { // has only one variant period, is it valid? should already be discontinued if not String productId = value.getString("productId"); - List<GenericValue> paList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false); - paList = EntityUtil.filterByDate(paList); + List<GenericValue> paList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); // verify the query; tested on a bunch, looks good if (paList.size() != 1) { Debug.logInfo("Virtual product with ID " + productId + " should have 1 assoc, has " + paList.size(), module); @@ -286,7 +289,10 @@ public class ProductUtilServices { EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp), EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp)) ), EntityOperator.AND); - EntityListIterator eliMulti = delegator.findListIteratorByCondition(dve, conditionWithDates, havingCond, UtilMisc.toList("productId", "productIdToCount"), null, null); + EntityListIterator eliMulti = EntityQuery.use(delegator).select("productId", "productIdToCount").from(dve) + .where(conditionWithDates) + .having(havingCond) + .queryIterator(); List<GenericValue> valueMultiList = eliMulti.getCompleteList(); eliMulti.close(); @@ -297,7 +303,7 @@ public class ProductUtilServices { // has only one valid variant String productId = value.getString("productId"); - List<GenericValue> paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false)); + List<GenericValue> paList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); // verify the query; tested on a bunch, looks good if (paList.size() != 1) { @@ -349,7 +355,7 @@ public class ProductUtilServices { GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); Debug.logInfo("Processing virtual product with one variant with ID: " + productId + " and name: " + product.getString("internalName"), module); - List<GenericValue> paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false)); + List<GenericValue> paList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); if (paList.size() > 1) { Map<String, String> messageMap = UtilMisc.toMap("productId", productId); errMsg = UtilProperties.getMessage(resourceError,"productutilservices.found_more_than_one_valid_variant_for_virtual_ID", messageMap, locale); @@ -457,7 +463,7 @@ public class ProductUtilServices { // can't just set to null, need to remove the value so it isn't a constraint in the query //findValue.set("fromDate", null); findValue.remove("fromDate"); - List<GenericValue> existingValueList = EntityUtil.filterByDate(delegator.findByAnd(relatedEntityName, findValue, null, false), nowTimestamp); + List<GenericValue> existingValueList = EntityQuery.use(delegator).from(relatedEntityName).where(findValue).filterByDate(nowTimestamp).queryList(); if (existingValueList.size() > 0) { if (test) { Debug.logInfo("Found " + existingValueList.size() + " existing values for related entity name: " + relatedEntityName + ", not copying, findValue is: " + findValue, module); @@ -467,7 +473,7 @@ public class ProductUtilServices { newRelatedValue.set("fromDate", nowTimestamp); } - if (delegator.findCountByCondition(relatedEntityName, EntityCondition.makeCondition(newRelatedValue.getPrimaryKey(), EntityOperator.AND), null, null) == 0) { + if (EntityQuery.use(delegator).from(relatedEntityName).where(EntityCondition.makeCondition(newRelatedValue.getPrimaryKey(), EntityOperator.AND)).queryCount() == 0) { if (test) { Debug.logInfo("Test mode, would create: " + newRelatedValue, module); } else { @@ -501,7 +507,7 @@ public class ProductUtilServices { } try { - EntityListIterator eli = delegator.find("Product", null, null, null, null, null); + EntityListIterator eli = EntityQuery.use(delegator).from("Product").queryIterator(); GenericValue product = null; int numSoFar = 0; while ((product = eli.next()) != null) { @@ -513,7 +519,7 @@ public class ProductUtilServices { if ("Y".equals(product.getString("isVirtual"))) { // find the first variant, use it's ID for the names... - List<GenericValue> productAssocList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"), null, false)); + List<GenericValue> productAssocList = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT").filterByDate().queryList(); if (productAssocList.size() > 0) { GenericValue productAssoc = EntityUtil.getFirst(productAssocList); smallMap.put("productId", productAssoc.getString("productIdTo")); @@ -557,7 +563,7 @@ public class ProductUtilServices { String errMsg = null; try { - EntityListIterator eli = delegator.find("Product", EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, "Y"), null, null, null, null); + EntityListIterator eli = EntityQuery.use(delegator).from("Product").where("isVirtual", "Y").queryIterator(); GenericValue product = null; int numSoFar = 0; while ((product = eli.next()) != null) { @@ -654,7 +660,7 @@ while (allCatIter.hasNext()) { } // do sub-categories first so all feature groups will be in place - List<GenericValue> subCategoryList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId", productCategoryId), null, false); + List<GenericValue> subCategoryList = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", productCategoryId).queryList(); if (doSubCategories) { for (GenericValue productCategoryRollup: subCategoryList) { attachProductFeaturesToCategory(productCategoryRollup.getString("productCategoryId"), productFeatureTypeIdsToInclude, productFeatureTypeIdsToExclude, delegator, true, nowTimestamp); @@ -663,7 +669,7 @@ while (allCatIter.hasNext()) { // now get all features for this category and make associated feature groups Map<String, Set<String>> productFeatureIdByTypeIdSetMap = FastMap.newInstance(); - List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId), null, false); + List<GenericValue> productCategoryMemberList = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", productCategoryId).queryList(); for (GenericValue productCategoryMember: productCategoryMemberList) { String productId = productCategoryMember.getString("productId"); EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList( @@ -671,7 +677,7 @@ while (allCatIter.hasNext()) { EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp), EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp)) ), EntityOperator.AND); - EntityListIterator productFeatureAndApplEli = delegator.find("ProductFeatureAndAppl", condition, null, null, null, null); + EntityListIterator productFeatureAndApplEli = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where(condition).queryIterator(); GenericValue productFeatureAndAppl = null; while ((productFeatureAndAppl = productFeatureAndApplEli.next()) != null) { String productFeatureId = productFeatureAndAppl.getString("productFeatureId"); @@ -721,7 +727,7 @@ while (allCatIter.hasNext()) { EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp), EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp)) ), EntityOperator.AND); - if (delegator.findCountByCondition("ProductFeatureGroupAppl", condition, null, null) == 0) { + if (EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where(condition).queryCount() == 0) { // if no valid ones, create one GenericValue productFeatureGroupAppl = delegator.makeValue("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureGroupId, "productFeatureId", productFeatureId, "fromDate", nowTimestamp)); productFeatureGroupAppl.create(); @@ -737,7 +743,7 @@ while (allCatIter.hasNext()) { EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp), EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp)) ), EntityOperator.AND); - EntityListIterator productFeatureCatGrpApplEli = delegator.find("ProductFeatureCatGrpAppl", condition, null, null, null, null); + EntityListIterator productFeatureCatGrpApplEli = EntityQuery.use(delegator).from("ProductFeatureCatGrpAppl").where(condition).queryIterator(); GenericValue productFeatureCatGrpAppl = null; while ((productFeatureCatGrpAppl = productFeatureCatGrpApplEli.next()) != null) { String productFeatureGroupId = productFeatureCatGrpAppl.getString("productFeatureGroupId"); @@ -747,7 +753,7 @@ while (allCatIter.hasNext()) { EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp), EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp)) ), EntityOperator.AND); - if (delegator.findCountByCondition("ProductFeatureCatGrpAppl", checkCondition, null, null) == 0) { + if (EntityQuery.use(delegator).from("ProductFeatureCatGrpAppl").where(checkCondition).queryCount() == 0) { // if no valid ones, create one GenericValue productFeatureGroupAppl = delegator.makeValue("ProductFeatureCatGrpAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureGroupId, "productCategoryId", productCategoryId, "fromDate", nowTimestamp)); productFeatureGroupAppl.create(); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductWorker.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductWorker.java Mon Nov 24 10:06:26 2014 @@ -281,7 +281,7 @@ public class ProductWorker { // find all selectable features on the virtual product that are also standard features on the variant Set<GenericValue> distFeatures = FastSet.newInstance(); - List<GenericValue> variantDistinguishingFeatures = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "DISTINGUISHING_FEAT"), null, true); + List<GenericValue> variantDistinguishingFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "DISTINGUISHING_FEAT").cache(true).queryList(); // Debug.logInfo("Found variantDistinguishingFeatures: " + variantDistinguishingFeatures, module); for (GenericValue variantDistinguishingFeature: EntityUtil.filterByDate(variantDistinguishingFeatures)) { @@ -290,7 +290,7 @@ public class ProductWorker { distFeatures.add(dummyFeature); } - List<GenericValue> virtualSelectableFeatures = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", virtualProductId, "productFeatureApplTypeId", "SELECTABLE_FEATURE"), null, true); + List<GenericValue> virtualSelectableFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", virtualProductId, "productFeatureApplTypeId", "SELECTABLE_FEATURE").cache(true).queryList(); // Debug.logInfo("Found virtualSelectableFeatures: " + virtualSelectableFeatures, module); Set<String> virtualSelectableFeatureIds = FastSet.newInstance(); @@ -298,7 +298,7 @@ public class ProductWorker { virtualSelectableFeatureIds.add(virtualSelectableFeature.getString("productFeatureId")); } - List<GenericValue> variantStandardFeatures = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE"), null, true); + List<GenericValue> variantStandardFeatures = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE").cache(true).queryList(); // Debug.logInfo("Found variantStandardFeatures: " + variantStandardFeatures, module); for (GenericValue variantStandardFeature: EntityUtil.filterByDate(variantStandardFeatures)) { @@ -427,10 +427,14 @@ public class ProductWorker { List <List<Map<String,String>>> featureTypeFeatures = FastList.newInstance(); try { Delegator delegator = product.getDelegator(); - Map<String,String> fields = UtilMisc.toMap("productId", product.getString("productId"), "productFeatureApplTypeId", "SELECTABLE_FEATURE"); - List<String> order = UtilMisc.toList("productFeatureTypeId", "sequenceNum"); - List<GenericValue> features = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true); - List<GenericValue> featuresSorted = EntityUtil.orderBy(features, order); + //List<GenericValue> features = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true); + //List<GenericValue> featuresSorted = EntityUtil.orderBy(features, order); + List<GenericValue> featuresSorted = EntityQuery.use(delegator) + .from("ProductFeatureAndAppl") + .where("productId", product.getString("productId"), "productFeatureApplTypeId", "SELECTABLE_FEATURE") + .orderBy("productFeatureTypeId", "sequenceNum") + .cache(true) + .queryList(); String oldType = null; List<Map<String,String>> featureList = FastList.newInstance(); for (GenericValue productFeatureAppl: featuresSorted) { @@ -440,8 +444,7 @@ public class ProductWorker { featureTypeFeatures.add(featureList); featureList = FastList.newInstance(); } - GenericValue productFeatureType = delegator.findOne("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId", - productFeatureAppl.getString("productFeatureTypeId")), false); + GenericValue productFeatureType = EntityQuery.use(delegator).from("ProductFeatureType").where("productFeatureTypeId", productFeatureAppl.getString("productFeatureTypeId")).queryOne(); featureList.add(UtilMisc.<String, String>toMap("productFeatureTypeId", productFeatureAppl.getString("productFeatureTypeId"), "description", productFeatureType.getString("description"))); oldType = productFeatureAppl.getString("productFeatureTypeId"); @@ -453,8 +456,10 @@ public class ProductWorker { } else { featureData.put("description", productFeatureAppl.getString("productFeatureId")); } - List<GenericValue> productFeaturePrices = EntityUtil.filterByDate(delegator.findByAnd("ProductFeaturePrice", - UtilMisc.toMap("productFeatureId", productFeatureAppl.getString("productFeatureId"), "productPriceTypeId", "DEFAULT_PRICE"), null, false)); + List<GenericValue> productFeaturePrices = EntityQuery.use(delegator).from("ProductFeaturePrice") + .where("productFeatureId", productFeatureAppl.getString("productFeatureId"), "productPriceTypeId", "DEFAULT_PRICE") + .filterByDate() + .queryList(); if (UtilValidate.isNotEmpty(productFeaturePrices)) { GenericValue productFeaturePrice = productFeaturePrices.get(0); if (UtilValidate.isNotEmpty(productFeaturePrice.get("price"))) { @@ -511,7 +516,7 @@ public class ProductWorker { List<GenericValue> productFeatureAppls = null; try { - productFeatureAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "OPTIONAL_FEATURE"), UtilMisc.toList("productFeatureTypeId", "sequenceNum"), false); + productFeatureAppls = EntityQuery.use(delegator).from("ProductFeatureAndAppl").where("productId", productId, "productFeatureApplTypeId", "OPTIONAL_FEATURE").orderBy("productFeatureTypeId", "sequenceNum").queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -709,12 +714,20 @@ public class ProductWorker { } try { - List<GenericValue> virtualProductAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate"), true); - virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs); + List<GenericValue> virtualProductAssocs = EntityQuery.use(delegator).from("ProductAssoc") + .where("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT") + .orderBy("-fromDate") + .cache(true) + .filterByDate() + .queryList(); if (UtilValidate.isEmpty(virtualProductAssocs)) { //okay, not a variant, try a UNIQUE_ITEM - virtualProductAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "UNIQUE_ITEM"), UtilMisc.toList("-fromDate"), true); - virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs); + virtualProductAssocs = EntityQuery.use(delegator).from("ProductAssoc") + .where("productIdTo", productId, "productAssocTypeId", "UNIQUE_ITEM") + .orderBy("-fromDate") + .cache(true) + .filterByDate() + .queryList(); } if (UtilValidate.isNotEmpty(virtualProductAssocs)) { //found one, set this first as the parent product @@ -873,7 +886,7 @@ public class ProductWorker { if (UtilValidate.isNotEmpty(goodIdentificationTypeId)) { conditions.put("goodIdentificationTypeId", goodIdentificationTypeId); } - productsFound = delegator.findByAnd("GoodIdentificationAndProduct", conditions, UtilMisc.toList("productId"), true); + productsFound = EntityQuery.use(delegator).from("GoodIdentificationAndProduct").where(conditions).orderBy("productId").cache(true).queryList(); } if (! searchProductFirst) { @@ -971,15 +984,13 @@ public class ProductWorker { Set<String> productIdSet = FastSet.newInstance(); // find associated refurb items, we want serial number for main item or any refurb items too - List<GenericValue> refubProductAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", - UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_REFURB"), null, false)); + List<GenericValue> refubProductAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId", "PRODUCT_REFURB").filterByDate().queryList(); for (GenericValue refubProductAssoc: refubProductAssocs) { productIdSet.add(refubProductAssoc.getString("productIdTo")); } // see if this is a refurb productId to, and find product(s) it is a refurb of - List<GenericValue> refubProductToAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", - UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_REFURB"), null, false)); + List<GenericValue> refubProductToAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productIdTo", productId, "productAssocTypeId", "PRODUCT_REFURB").filterByDate().queryList(); for (GenericValue refubProductToAssoc: refubProductToAssocs) { productIdSet.add(refubProductToAssoc.getString("productId")); } @@ -995,8 +1006,8 @@ public class ProductWorker { for (String paramValue: selectedFeatures) { // find incompatibilities.. - List<GenericValue> incompatibilityVariants = delegator.findByAnd("ProductFeatureIactn", UtilMisc.toMap("productId", productId, - "productFeatureIactnTypeId","FEATURE_IACTN_INCOMP"), null, true); + List<GenericValue> incompatibilityVariants = EntityQuery.use(delegator).from("ProductFeatureIactn") + .where("productId", productId, "productFeatureIactnTypeId","FEATURE_IACTN_INCOMP").cache(true).queryList(); for (GenericValue incompatibilityVariant: incompatibilityVariants) { String featur = incompatibilityVariant.getString("productFeatureId"); if (paramValue.equals(featur)) { @@ -1011,8 +1022,8 @@ public class ProductWorker { } } // find dependencies.. - List<GenericValue> dependenciesVariants = delegator.findByAnd("ProductFeatureIactn", UtilMisc.toMap("productId", productId, - "productFeatureIactnTypeId","FEATURE_IACTN_DEPEND"), null, true); + List<GenericValue> dependenciesVariants = EntityQuery.use(delegator).from("ProductFeatureIactn") + .where("productId", productId, "productFeatureIactnTypeId","FEATURE_IACTN_DEPEND").cache(true).queryList(); for (GenericValue dpVariant: dependenciesVariants) { String featur = dpVariant.getString("productFeatureId"); if (paramValue.equals(featur)) { @@ -1033,12 +1044,12 @@ public class ProductWorker { } // find variant // Debug.logInfo("=====try to find variant for product: " + productId + " and features: " + selectedFeatures); - List<GenericValue> productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId","PRODUCT_VARIANT"), null, false)); + List<GenericValue> productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId, "productAssocTypeId","PRODUCT_VARIANT").filterByDate().queryList(); boolean productFound = false; nextProd: for (GenericValue productAssoc: productAssocs) { for (String featureId: selectedFeatures) { - List<GenericValue> pAppls = delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productAssoc.getString("productIdTo"), "productFeatureId", featureId, "productFeatureApplTypeId","STANDARD_FEATURE"), null, true); + List<GenericValue> pAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productAssoc.getString("productIdTo"), "productFeatureId", featureId, "productFeatureApplTypeId","STANDARD_FEATURE").cache(true).queryList(); if (UtilValidate.isEmpty(pAppls)) { continue nextProd; } @@ -1071,7 +1082,7 @@ nextProd: productFeatureAppl.create(); } //add standard features too - List<GenericValue> stdFeaturesAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE"), null, false)); + List<GenericValue> stdFeaturesAppls = EntityQuery.use(delegator).from("ProductFeatureAppl").where("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryList(); for (GenericValue stdFeaturesAppl: stdFeaturesAppls) { stdFeaturesAppl.put("productId", product.getString("productId")); stdFeaturesAppl.create(); @@ -1080,11 +1091,12 @@ nextProd: * take the default price from the vitual product, go to the productfeature table and retrieve all the prices for the difFerent features * add these to the price of the virtual product, store the result as the default price on the variant you created. */ - List<GenericValue> productPrices = EntityUtil.filterByDate(delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", productId), null, false)); + List<GenericValue> productPrices = EntityQuery.use(delegator).from("ProductPrice").where("productId", productId).filterByDate().queryList(); for (GenericValue productPrice: productPrices) { for (String selectedFeaturedId: selectedFeatures) { - List<GenericValue> productFeaturePrices = EntityUtil.filterByDate(delegator.findByAnd("ProductFeaturePrice", - UtilMisc.toMap("productFeatureId", selectedFeaturedId, "productPriceTypeId", productPrice.getString("productPriceTypeId")), null, false)); + List<GenericValue> productFeaturePrices = EntityQuery.use(delegator).from("ProductFeaturePrice") + .where("productFeatureId", selectedFeaturedId, "productPriceTypeId", productPrice.getString("productPriceTypeId")) + .filterByDate().queryList(); if (UtilValidate.isNotEmpty(productFeaturePrices)) { GenericValue productFeaturePrice = productFeaturePrices.get(0); if (UtilValidate.isNotEmpty(productFeaturePrice)) { @@ -1105,14 +1117,14 @@ nextProd: Debug.logInfo("set the productId to: " + product.getString("productId"), module); // copy the supplier - List<GenericValue> supplierProducts = delegator.findByAnd("SupplierProduct", UtilMisc.toMap("productId", productId), null, true); + List<GenericValue> supplierProducts = EntityQuery.use(delegator).from("SupplierProduct").where("productId", productId).cache(true).queryList(); for (GenericValue supplierProduct: supplierProducts) { supplierProduct.set("productId", product.getString("productId")); supplierProduct.create(); } // copy the content - List<GenericValue> productContents = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", productId), null, true); + List<GenericValue> productContents = EntityQuery.use(delegator).from("ProductContent").where("productId", productId).cache(true).queryList(); for (GenericValue productContent: productContents) { productContent.set("productId", product.getString("productId")); productContent.create(); @@ -1143,7 +1155,7 @@ nextProd: condList.add(EntityCondition.makeCondition("productId", virtualVariantId)); } condList.add(EntityCondition.makeCondition("productAssocTypeId", "ALTERNATIVE_PACKAGE")); - alternativePackingProds = delegator.findList("ProductAssoc", EntityCondition.makeCondition(condList, EntityOperator.AND), null, null, null, true); + alternativePackingProds = EntityQuery.use(delegator).from("ProductAssoc").where(condList).cache(true).queryList(); if(UtilValidate.isNotEmpty(alternativePackingProds)) isAlternativePacking = true; } catch (GenericEntityException e) { Debug.logWarning(e, "Could not found alternative product: " + e.getMessage(), module); @@ -1157,11 +1169,10 @@ nextProd: if (isAlternativePacking) { List<GenericValue> productAssocs = null; try { - productAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE"), null, false); + productAssocs = EntityQuery.use(delegator).from("ProductAssoc").where("productId", productId , "productAssocTypeId", "ALTERNATIVE_PACKAGE").filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); } - productAssocs = EntityUtil.filterByDate(productAssocs); if (productAssocs != null) { GenericValue productAssoc = EntityUtil.getFirst(productAssocs); @@ -1187,8 +1198,8 @@ nextProd: if(UtilValidate.isEmpty(productStoreId)){ return Boolean.TRUE; } - String allowDecimalStore = delegator.findOne("ProductStore", Boolean.TRUE, UtilMisc.toMap("productStoreId", productStoreId)).getString("orderDecimalQuantity"); - String allowDecimalProduct = delegator.findOne("Product", Boolean.TRUE, UtilMisc.toMap("productId", productId)).getString("orderDecimalQuantity"); + String allowDecimalStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).cache(true).queryOne().getString("orderDecimalQuantity"); + String allowDecimalProduct = EntityQuery.use(delegator).from("Product").where("productId", productId).cache(true).queryOne().getString("orderDecimalQuantity"); if("N".equals(allowDecimalProduct) || (UtilValidate.isEmpty(allowDecimalProduct) && "N".equals(allowDecimalStore))){ return Boolean.FALSE; @@ -1216,7 +1227,7 @@ nextProd: for (GenericValue genericRecord : productsToFilter) { String productId = genericRecord.getString("productId"); GenericValue product = null; - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache(true).queryOne(); Boolean isMarketingPackage = EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.getString("productTypeId"), "parentTypeId", "MARKETING_PKG"); if ( UtilValidate.isNotEmpty(isMarketingPackage) && isMarketingPackage) { @@ -1229,7 +1240,7 @@ nextProd: productsInStock.add(genericRecord); } } else { - List<GenericValue> facilities = delegator.findList("ProductFacility", EntityCondition.makeCondition("productId",EntityOperator.EQUALS, productId), null, null, null, false); + List<GenericValue> facilities = EntityQuery.use(delegator).from("ProductFacility").where("productId", productId).queryList(); BigDecimal availableInventory = BigDecimal.ZERO; if (UtilValidate.isNotEmpty(facilities)) { for (GenericValue facility : facilities) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/VariantEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/VariantEvents.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/VariantEvents.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/VariantEvents.java Mon Nov 24 10:06:26 2014 @@ -95,7 +95,7 @@ public class VariantEvents { } // check if product exists - GenericValue variantProduct = delegator.findOne("Product",UtilMisc.toMap("productId", variantProductId), false); + GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne(); if (variantProduct == null) { //if product does not exist variantProduct = GenericValue.create(product); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/promo/PromoServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/promo/PromoServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/promo/PromoServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/promo/PromoServices.java Mon Nov 24 10:06:26 2014 @@ -138,10 +138,9 @@ public class PromoServices { condList.add(EntityCondition.makeCondition("userEntered", EntityOperator.EQUALS, "Y")); condList.add(EntityCondition.makeCondition("thruDate", EntityOperator.NOT_EQUAL, null)); condList.add(EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN, nowTimestamp)); - EntityCondition cond = EntityCondition.makeCondition(condList, EntityOperator.AND); try { - EntityListIterator eli = delegator.find("ProductStorePromoAndAppl", cond, null, null, null, null); + EntityListIterator eli = EntityQuery.use(delegator).from("ProductStorePromoAndAppl").where(condList).queryIterator(); GenericValue productStorePromoAndAppl = null; while ((productStorePromoAndAppl = eli.next()) != null) { GenericValue productStorePromo = delegator.makeValue("ProductStorePromoAppl"); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java Mon Nov 24 10:06:26 2014 @@ -29,6 +29,7 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; public class ImportProductHelper { @@ -65,8 +66,7 @@ public class ImportProductHelper { GenericValue tmpProductGV; boolean productExists = false; try { - tmpProductGV = delegator.findOne("Product", UtilMisc - .toMap("productId", productId), false); + tmpProductGV = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); if (tmpProductGV != null && productId.equals(tmpProductGV.getString("productId"))) productExists = true; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/store/ProductStoreEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/store/ProductStoreEvents.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/store/ProductStoreEvents.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/store/ProductStoreEvents.java Mon Nov 24 10:06:26 2014 @@ -33,6 +33,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; public class ProductStoreEvents { @@ -51,18 +52,16 @@ public class ProductStoreEvents { List<String> sortList = org.ofbiz.base.util.UtilMisc.toList("sequenceNum"); try { - GenericValue productStoreGroup = delegator.findOne("ProductStoreGroup" ,UtilMisc.toMap("productStoreGroupId", parentGroupId), true); + GenericValue productStoreGroup = EntityQuery.use(delegator).from("ProductStoreGroup").where("productStoreGroupId", parentGroupId).cache(true).queryOne(); if (UtilValidate.isNotEmpty(productStoreGroup)) { - children = EntityUtil.filterByDate(delegator.findList("ProductStoreGroupRollupAndChild", - EntityCondition.makeCondition("parentGroupId", parentGroupId), null, null, null, true)); + children = EntityQuery.use(delegator).from("ProductStoreGroupRollupAndChild").where("parentGroupId", parentGroupId).cache(true).filterByDate().queryList(); if (UtilValidate.isNotEmpty(children)) { for (GenericValue child : children ) { String productStoreGroupId = child.getString("productStoreGroupId"); Map josonMap = FastMap.newInstance(); List<GenericValue> childList = null; // Get the child list of chosen category - childList = EntityUtil.filterByDate(delegator.findList("ProductStoreGroupRollupAndChild", - EntityCondition.makeCondition("parentGroupId", productStoreGroupId), null, null, null, true)); + childList = EntityQuery.use(delegator).from("ProductStoreGroupRollupAndChild").where("parentGroupId", productStoreGroupId).cache(true).filterByDate().queryList(); if (UtilValidate.isNotEmpty(childList)) { josonMap.put("state", "closed"); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java Mon Nov 24 10:06:26 2014 @@ -175,8 +175,7 @@ public class ProductStoreWorker { if (anyServiceType) { if (storePayment == null) { try { - List<GenericValue> storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId), null, false); - storePayment = EntityUtil.getFirst(storePayments); + storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId).queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up store payment settings", module); } @@ -184,8 +183,7 @@ public class ProductStoreWorker { if (storePayment == null) { try { - List<GenericValue> storePayments = delegator.findByAnd("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId), null, false); - storePayment = EntityUtil.getFirst(storePayments); + storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId).queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up store payment settings", module); } @@ -198,12 +196,14 @@ public class ProductStoreWorker { public static List<GenericValue> getProductStoreShipmentMethods(Delegator delegator, String productStoreId, String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId) { // check for an external service call - Map<String, String> storeFields = UtilMisc.toMap("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId, - "partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId); List<GenericValue> storeShipMethods = null; try { - storeShipMethods = delegator.findByAnd("ProductStoreShipmentMeth", storeFields, null, true); + storeShipMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMeth") + .where("productStoreId", productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId, + "partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId) + .cache(true) + .queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -224,7 +224,7 @@ public class ProductStoreWorker { } List<GenericValue> shippingMethods = null; try { - shippingMethods = delegator.findByAnd("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNumber"), true); + shippingMethods = EntityQuery.use(delegator).from("ProductStoreShipmentMethView").where("productStoreId", productStoreId).orderBy("sequenceNumber").cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductStore shipping methods", module); return null; @@ -380,7 +380,7 @@ public class ProductStoreWorker { if (UtilValidate.isNotEmpty(includeFeatures)) { List<GenericValue> includedFeatures = null; try { - includedFeatures = delegator.findByAnd("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", includeFeatures), null, true); + includedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", includeFeatures).cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + includeFeatures, module); } @@ -402,7 +402,7 @@ public class ProductStoreWorker { if (UtilValidate.isNotEmpty(excludeFeatures)) { List<GenericValue> excludedFeatures = null; try { - excludedFeatures = delegator.findByAnd("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", excludeFeatures), null, true); + excludedFeatures = EntityQuery.use(delegator).from("ProductFeatureGroupAppl").where("productFeatureGroupId", excludeFeatures).cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + excludeFeatures, module); } @@ -465,7 +465,7 @@ public class ProductStoreWorker { List<GenericValue> surveys = FastList.newInstance(); List<GenericValue> storeSurveys = null; try { - storeSurveys = delegator.findByAnd("ProductStoreSurveyAppl", UtilMisc.toMap("productStoreId", productStoreId, "surveyApplTypeId", surveyApplTypeId), UtilMisc.toList("sequenceNum"), true); + storeSurveys = EntityQuery.use(delegator).from("ProductStoreSurveyAppl").where("productStoreId", productStoreId, "surveyApplTypeId", surveyApplTypeId).orderBy("sequenceNum").cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductStoreSurveyAppl for store : " + productStoreId, module); return surveys; @@ -512,7 +512,7 @@ public class ProductStoreWorker { } else if (surveyAppl.get("productCategoryId") != null) { List<GenericValue> categoryMembers = null; try { - categoryMembers = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", surveyAppl.get("productCategoryId")), null, true); + categoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", surveyAppl.get("productCategoryId")).cache(true).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get ProductCategoryMember records for survey application : " + surveyAppl, module); } @@ -556,7 +556,7 @@ public class ProductStoreWorker { List<GenericValue> surveyResponse = null; try { - surveyResponse = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("surveyId", surveyId, "partyId", partyId), null, false); + surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyId", surveyId, "partyId", partyId).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return -1; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java Mon Nov 24 10:06:26 2014 @@ -78,7 +78,7 @@ public class SubscriptionServices { 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<GenericValue> subscriptionList = delegator.findByAnd("Subscription", subscriptionFindMap, null, false); + List<GenericValue> subscriptionList = EntityQuery.use(delegator).from("Subscription").where(subscriptionFindMap).queryList(); // DEJ20070718 DON'T filter by date, we want to consider all subscriptions: List listFiltered = EntityUtil.filterByDate(subscriptionList, true); List<GenericValue> listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate")); if (listOrdered.size() > 0) { @@ -198,9 +198,11 @@ public class SubscriptionServices { orderCreatedDate = UtilDateTime.nowTimestamp(); } try { - List<GenericValue> productSubscriptionResourceList = delegator.findByAnd("ProductSubscriptionResource", UtilMisc.toMap("productId", productId), null, true); - productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, null, null, true); - productSubscriptionResourceList = EntityUtil.filterByDate(productSubscriptionResourceList, orderCreatedDate, "purchaseFromDate", "purchaseThruDate", true); + List<GenericValue> productSubscriptionResourceList = EntityQuery.use(delegator).from("ProductSubscriptionResource") + .where("productId", productId) + .cache(true) + .filterByDate(orderCreatedDate, "fromDate", "thruDate", "purchaseFromDate", "purchaseThruDate") + .queryList(); if (productSubscriptionResourceList.size() == 0) { Debug.logError("No ProductSubscriptionResource found for productId: " + productId, module); @@ -254,7 +256,7 @@ public class SubscriptionServices { GenericValue orderHeader = null; try { - List<GenericValue> orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER"), null, false); + List<GenericValue> orderRoleList = EntityQuery.use(delegator).from("OrderRole").where("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER").queryList(); if (orderRoleList.size() > 0) { GenericValue orderRole = orderRoleList.get(0); String partyId = (String) orderRole.get("partyId"); @@ -279,8 +281,7 @@ public class SubscriptionServices { if (UtilValidate.isEmpty(productId)) { continue; } - List<GenericValue> productSubscriptionResourceList = delegator.findByAnd("ProductSubscriptionResource", UtilMisc.toMap("productId", productId), null, true); - List<GenericValue> productSubscriptionResourceListFiltered = EntityUtil.filterByDate(productSubscriptionResourceList, true); + List<GenericValue> productSubscriptionResourceListFiltered = EntityQuery.use(delegator).from("ProductSubscriptionResource").where("productId", productId).cache(true).filterByDate().queryList(); if (productSubscriptionResourceListFiltered.size() > 0) { subContext.put("subscriptionTypeId", "PRODUCT_SUBSCR"); subContext.put("productId", productId); @@ -322,7 +323,7 @@ public class SubscriptionServices { EntityCondition cond2 = EntityCondition.makeCondition("automaticExtend", EntityOperator.EQUALS, null); EntityCondition cond = EntityCondition.makeCondition(UtilMisc.toList(cond1, cond2), EntityOperator.OR); List<GenericValue> subscriptionList = null; - subscriptionList = delegator.findList("Subscription", cond, null,null, null, false); + subscriptionList = EntityQuery.use(delegator).from("Subscription").where(cond).queryList(); if (subscriptionList != null) { for (GenericValue subscription : subscriptionList) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Mon Nov 24 10:06:26 2014 @@ -728,13 +728,13 @@ public class PackingSession implements j newShipment.put("picklistBinId", picklistBinId); newShipment.put("additionalShippingCharge", additionalShippingCharge); newShipment.put("userLogin", userLogin); - GenericValue orderRoleShipTo = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "SHIP_TO_CUSTOMER"), null, false)); + GenericValue orderRoleShipTo = EntityQuery.use(delegator).from("OrderRole").where("orderId", primaryOrderId, "roleTypeId", "SHIP_TO_CUSTOMER").queryFirst(); if (UtilValidate.isNotEmpty(orderRoleShipTo)) { newShipment.put("partyIdTo", orderRoleShipTo.getString("partyId")); } String partyIdFrom = null; if (primaryOrderId != null) { - GenericValue orderItemShipGroup = EntityUtil.getFirst(delegator.findByAnd("OrderItemShipGroup", UtilMisc.toMap("orderId", primaryOrderId, "shipGroupSeqId", primaryShipGrp), null, false)); + GenericValue orderItemShipGroup = EntityQuery.use(delegator).from("OrderItemShipGroup").where("orderId", primaryOrderId, "shipGroupSeqId", primaryShipGrp).queryFirst(); if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("vendorPartyId"))) { partyIdFrom = orderItemShipGroup.getString("vendorPartyId"); } else if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("facilityId"))) { @@ -744,11 +744,11 @@ public class PackingSession implements j } } if (UtilValidate.isEmpty(partyIdFrom)) { - GenericValue orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "SHIP_FROM_VENDOR"), null, false)); + GenericValue orderRoleShipFrom = EntityQuery.use(delegator).from("OrderRole").where("orderId", primaryOrderId, "roleTypeId", "SHIP_FROM_VENDOR").queryFirst(); if (UtilValidate.isNotEmpty(orderRoleShipFrom)) { partyIdFrom = orderRoleShipFrom.getString("partyId"); } else { - orderRoleShipFrom = EntityUtil.getFirst(delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", primaryOrderId, "roleTypeId", "BILL_FROM_VENDOR"), null, false)); + orderRoleShipFrom = EntityQuery.use(delegator).from("OrderRole").where("orderId", primaryOrderId, "roleTypeId", "BILL_FROM_VENDOR").queryFirst(); partyIdFrom = orderRoleShipFrom.getString("partyId"); } } |
Free forum by Nabble | Edit this page |