You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by as...@apache.org on 2014/11/22 12:26:21 UTC
svn commit: r1641044 [3/4] - in
/ofbiz/trunk/applications/product/src/org/ofbiz: product/catalog/
product/category/ product/config/ product/feature/ product/imagemanagement/
product/inventory/ product/price/ product/product/ product/promo/
product/spre...
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java Sat Nov 22 11:26:20 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/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java Sat Nov 22 11:26:20 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/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java Sat Nov 22 11:26:20 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/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java Sat Nov 22 11:26:20 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/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java Sat Nov 22 11:26:20 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/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreEvents.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreEvents.java Sat Nov 22 11:26:20 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/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java Sat Nov 22 11:26:20 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/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java Sat Nov 22 11:26:20 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/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Sat Nov 22 11:26:20 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");
}
}
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSessionLine.java Sat Nov 22 11:26:20 2014
@@ -28,6 +28,7 @@ import org.ofbiz.base.util.UtilFormatOut
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
@@ -212,7 +213,10 @@ public class PackingSessionLine implemen
itemLookup.put("orderItemSeqId", this.getOrderItemSeqId());
itemLookup.put("shipGroupSeqId", this.getShipGroupSeqId());
itemLookup.put("inventoryItemId", this.getInventoryItemId());
- GenericValue plItem = delegator.findOne("PicklistItem", itemLookup, false);
+ GenericValue plItem = EntityQuery.use(delegator)
+ .from("PicklistItem")
+ .where(itemLookup)
+ .queryOne();
if (plItem != null) {
Debug.logInfo("Found picklist bin: " + plItem, module);
BigDecimal itemQty = plItem.getBigDecimal("quantity");
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java Sat Nov 22 11:26:20 2014
@@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericEntityExc
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityQuery;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
@@ -66,11 +67,12 @@ public class PickListServices {
EntityCondition idCond = EntityCondition.makeCondition(conditionList1, EntityOperator.OR);
conditionList2.add(idCond);
- EntityCondition cond = EntityCondition.makeCondition(conditionList2, EntityOperator.AND);
-
// run the query
try {
- orderHeaderList = delegator.findList("OrderHeader", cond, null, UtilMisc.toList("+orderDate"), null, false);
+ orderHeaderList = EntityQuery.use(delegator).from("OrderHeader")
+ .where(conditionList2)
+ .orderBy("orderDate")
+ .queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -89,7 +91,7 @@ public class PickListServices {
// lookup the items in the bin
List<GenericValue> items;
try {
- items = delegator.findByAnd("PicklistItem", UtilMisc.toMap("picklistBinId", picklistBinId), null, false);
+ items = EntityQuery.use(delegator).from("PicklistItem").where("picklistBinId", picklistBinId).queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
throw e;
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Sat Nov 22 11:26:20 2014
@@ -273,7 +273,10 @@ public class ShipmentServices {
Collection<GenericValue> estimates = null;
try {
- estimates = delegator.findList("ShipmentCostEstimate", estFieldsCond, null, null, null, true);
+ estimates = EntityQuery.use(delegator).from("ShipmentCostEstimate")
+ .where(estFieldsCond)
+ .cache(true)
+ .queryList();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
@@ -302,8 +305,10 @@ public class ShipmentServices {
} else if (shippingPostalCode != null) {
String countryGeoId = null;
try {
- EntityCondition cond =EntityCondition.makeCondition(UtilMisc.toMap("geoTypeId", "COUNTRY", "geoCode", shippingCountryCode));
- GenericValue countryGeo = EntityUtil.getFirst(delegator.findList("Geo", cond, null, null, null, true));
+ GenericValue countryGeo = EntityQuery.use(delegator).from("Geo")
+ .where("geoTypeId", "COUNTRY", "geoCode", shippingCountryCode)
+ .cache(true)
+ .queryFirst();
if (countryGeo != null) {
countryGeoId = countryGeo.getString("geoId");
}
@@ -562,9 +567,11 @@ public class ShipmentServices {
GenericValue appl = null;
Map<String, String> fields = UtilMisc.toMap("productFeatureGroupId", featureGroupId, "productFeatureId", featureId);
try {
- List<GenericValue> appls = delegator.findByAnd("ProductFeatureGroupAppl", fields, null, true);
- appls = EntityUtil.filterByDate(appls);
- appl = EntityUtil.getFirst(appls);
+ appl = EntityQuery.use(delegator).from("ProductFeatureGroupAppl")
+ .where("productFeatureGroupId", featureGroupId, "productFeatureId", featureId)
+ .cache(true)
+ .filterByDate()
+ .queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to lookup feature/group" + fields, module);
}
@@ -722,20 +729,18 @@ public class ShipmentServices {
Delegator delegator = dctx.getDelegator();
GenericValue userLogin = (GenericValue) context.get("userLogin");
Locale locale = (Locale) context.get("locale");
- List<String> orderBy = UtilMisc.toList("shipmentId", "shipmentPackageSeqId", "voidIndicator");
Map<String, String> shipmentMap = FastMap.newInstance();
EntityListIterator eli = null;
try {
- eli = delegator.find("OdbcPackageIn", null, null, null, orderBy, null);
+ eli = EntityQuery.use(delegator).from("OdbcPackageIn").orderBy("shipmentId", "shipmentPackageSeqId", "voidIndicator").queryIterator();
GenericValue pkgInfo;
while ((pkgInfo = eli.next()) != null) {
String packageSeqId = pkgInfo.getString("shipmentPackageSeqId");
String shipmentId = pkgInfo.getString("shipmentId");
// locate the shipment package
- GenericValue shipmentPackage = delegator.findOne("ShipmentPackage",
- UtilMisc.toMap("shipmentId", shipmentId, "shipmentPackageSeqId", packageSeqId), false);
+ GenericValue shipmentPackage = EntityQuery.use(delegator).from("ShipmentPackage").where("shipmentId", shipmentId, "shipmentPackageSeqId", packageSeqId).queryOne();
if (shipmentPackage != null) {
if ("00001".equals(packageSeqId)) {
@@ -777,7 +782,9 @@ public class ShipmentServices {
// first update the weight of the package
GenericValue pkg = null;
try {
- pkg = delegator.findOne("ShipmentPackage", pkgCtx, false);
+ pkg = EntityQuery.use(delegator).from("ShipmentPackage")
+ .where(pkgCtx)
+ .queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -802,7 +809,7 @@ public class ShipmentServices {
pkgCtx.put("shipmentRouteSegmentId", "00001");
GenericValue pkgRtSeg = null;
try {
- pkgRtSeg = delegator.findOne("ShipmentPackageRouteSeg", pkgCtx, false);
+ pkgRtSeg = EntityQuery.use(delegator).from("ShipmentPackageRouteSeg").where(pkgCtx).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
@@ -910,7 +917,7 @@ public class ShipmentServices {
GenericValue userLogin = (GenericValue) context.get("userLogin");
try {
- List<GenericValue> shipmentReceipts = delegator.findByAnd("ShipmentReceipt", UtilMisc.toMap("shipmentId", shipmentId), null, false);
+ List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).from("ShipmentReceipt").where("shipmentId", shipmentId).queryList();
if (shipmentReceipts.size() == 0) return ServiceUtil.returnSuccess();
// If there are shipment receipts, the shipment must have been shipped, so set the shipment status to PURCH_SHIP_SHIPPED if it's only PURCH_SHIP_CREATED
@@ -922,7 +929,7 @@ public class ShipmentServices {
}
}
- List<GenericValue> shipmentAndItems = delegator.findByAnd("ShipmentAndItem", UtilMisc.toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED"), null, false);
+ List<GenericValue> shipmentAndItems = EntityQuery.use(delegator).from("ShipmentAndItem").where("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED").queryList();
if (shipmentAndItems.size() == 0) {
return ServiceUtil.returnSuccess();
}
@@ -1018,8 +1025,10 @@ public class ShipmentServices {
// get the carrierPartyId
try {
- GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment",
- UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), true);
+ GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment")
+ .where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId)
+ .cache(true)
+ .queryOne();
carrierPartyId = shipmentRouteSegment.getString("carrierPartyId");
} catch (GenericEntityException e) {
Debug.logError(e, module);
@@ -1083,7 +1092,7 @@ public class ShipmentServices {
return ServiceUtil.returnError(errorMessage);
}
- List<GenericValue> packageContents = delegator.findByAnd("PackedQtyVsOrderItemQuantity", UtilMisc.toMap("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId), null, false);
+ List<GenericValue> packageContents = EntityQuery.use(delegator).from("PackedQtyVsOrderItemQuantity").where("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId).queryList();
for (GenericValue packageContent: packageContents) {
String orderId = packageContent.getString("orderId");
String orderItemSeqId = packageContent.getString("orderItemSeqId");
@@ -1244,14 +1253,10 @@ public class ShipmentServices {
String shipmentMethodTypeId = primaryOrderItemShipGroup.getString("shipmentMethodTypeId");
String carrierPartyId = primaryOrderItemShipGroup.getString("carrierPartyId");
String carrierRoleTypeId = primaryOrderItemShipGroup.getString("carrierRoleTypeId");
- List<EntityCondition> conditions = FastList.newInstance();
- conditions.add(EntityCondition.makeCondition("productStoreId", EntityOperator.EQUALS, productStoreId));
- conditions.add(EntityCondition.makeCondition("shipmentMethodTypeId", EntityOperator.EQUALS, shipmentMethodTypeId));
- conditions.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, carrierPartyId));
- conditions.add(EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, carrierRoleTypeId));
- EntityConditionList<EntityCondition> ecl = EntityCondition.makeCondition(conditions, EntityOperator.AND);
- List<GenericValue> productStoreShipmentMeths = delegator.findList("ProductStoreShipmentMeth", ecl, null, null, null, false);
- GenericValue productStoreShipmentMeth = EntityUtil.getFirst(productStoreShipmentMeths);
+ GenericValue productStoreShipmentMeth = EntityQuery.use(delegator).from("ProductStoreShipmentMeth")
+ .where("productStoreId",productStoreId, "shipmentMethodTypeId", shipmentMethodTypeId,
+ "partyId", carrierPartyId, "roleTypeId", carrierRoleTypeId)
+ .queryFirst();
if (UtilValidate.isNotEmpty(productStoreShipmentMeth)) {
shipmentGatewayConfig.put("shipmentGatewayConfigId", productStoreShipmentMeth.getString("shipmentGatewayConfigId"));
shipmentGatewayConfig.put("configProps", productStoreShipmentMeth.getString("configProps"));
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java Sat Nov 22 11:26:20 2014
@@ -170,8 +170,9 @@ public class DhlServices {
// translate shipmentMethodTypeId to DHL service code
String dhlShipmentDetailCode = null;
try {
- GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId,
- "partyId", carrierPartyId, "roleTypeId", "CARRIER"), false);
+ GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
+ .where("shipmentMethodTypeId", shipmentMethodTypeId, "partyId", carrierPartyId, "roleTypeId", "CARRIER")
+ .queryOne();
if (carrierShipmentMethod == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"FacilityShipmentDhlNoCarrierShipmentMethod",
@@ -711,8 +712,9 @@ public class DhlServices {
// translate shipmentMethodTypeId to DHL service code
String shipmentMethodTypeId = shipmentRouteSegment.getString("shipmentMethodTypeId");
String dhlShipmentDetailCode = null;
- GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId,
- "partyId", "DHL", "roleTypeId", "CARRIER"), false);
+ GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod")
+ .where("shipmentMethodTypeId", shipmentMethodTypeId, "partyId", "DHL", "roleTypeId", "CARRIER")
+ .queryOne();
if (carrierShipmentMethod == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
"FacilityShipmentDhlNoCarrierShipmentMethod",
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java?rev=1641044&r1=1641043&r2=1641044&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java Sat Nov 22 11:26:20 2014
@@ -203,9 +203,10 @@ public class FedexServices {
}
// Get the contact information for the company
- List<GenericValue> partyContactDetails = delegator.findByAnd("PartyContactDetailByPurpose", UtilMisc.toMap("partyId", companyPartyId), null, false);
- partyContactDetails = EntityUtil.filterByDate(partyContactDetails);
- partyContactDetails = EntityUtil.filterByDate(partyContactDetails, UtilDateTime.nowTimestamp(), "purposeFromDate", "purposeThruDate", true);
+ List<GenericValue> partyContactDetails = EntityQuery.use(delegator).from("PartyContactDetailByPurpose")
+ .where("partyId", companyPartyId)
+ .filterByDate(UtilDateTime.nowTimestamp(), "fromDate", "thruDate", "purposeFromDate", "purposeThruDate")
+ .queryList();
// Get the first valid postal address (address1, city, postalCode and countryGeoId are required by Fedex)
List<EntityCondition> postalAddressConditions = FastList.newInstance();