Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java Mon Nov 3 06:54:16 2014 @@ -47,6 +47,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelUtil; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.LocalDispatcher; @@ -157,7 +158,7 @@ public class ProductPromoContentWrapper ModelEntity productModel = delegator.getModelEntity("ProductPromo"); if (productModel.isField(candidateFieldName)) { if (UtilValidate.isEmpty(productPromo)) { - productPromo = delegator.findOne("ProductPromo", UtilMisc.toMap("productPromoId", productPromoId), true); + productPromo = EntityQuery.use(delegator).from("ProductPromo").where("productPromoId", productPromoId).cache().queryOne(); } if (UtilValidate.isNotEmpty(productPromo)) { String candidateValue = productPromo.getString(candidateFieldName); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearch.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearch.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/product/ProductSearch.java Mon Nov 3 06:54:16 2014 @@ -56,6 +56,7 @@ import org.ofbiz.entity.transaction.Gene import org.ofbiz.entity.transaction.TransactionUtil; 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.party.party.PartyHelper; import org.ofbiz.product.category.CategoryContentWrapper; @@ -888,7 +889,7 @@ public class ProductSearch { public String prettyPrintConstraint(Delegator delegator, boolean detailed, Locale locale) { GenericValue prodCatalog = null; try { - prodCatalog = delegator.findOne("ProdCatalog", UtilMisc.toMap("prodCatalogId", prodCatalogId), true); + prodCatalog = EntityQuery.use(delegator).from("ProdCatalog").where("prodCatalogId", prodCatalogId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error finding ProdCatalog information for constraint pretty print", module); } @@ -969,7 +970,7 @@ public class ProductSearch { public String prettyPrintConstraint(Delegator delegator, boolean detailed, Locale locale) { GenericValue productCategory = null; try { - productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", productCategoryId), true); + productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error finding ProductCategory information for constraint pretty print", module); } @@ -1054,7 +1055,7 @@ public class ProductSearch { GenericValue productFeature = null; GenericValue productFeatureType = null; try { - productFeature = delegator.findOne("ProductFeature", UtilMisc.toMap("productFeatureId", productFeatureId), true); + productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", productFeatureId).cache().queryOne(); productFeatureType = productFeature == null ? null : productFeature.getRelatedOne("ProductFeatureType", false); } catch (GenericEntityException e) { Debug.logError(e, "Error finding ProductFeature and Type information for constraint pretty print", module); @@ -1136,7 +1137,7 @@ public class ProductSearch { public String prettyPrintConstraint(Delegator delegator, boolean detailed, Locale locale) { GenericValue productFeatureCategory = null; try { - productFeatureCategory = delegator.findOne("ProductFeatureCategory", UtilMisc.toMap("productFeatureCategoryId", productFeatureCategoryId), true); + productFeatureCategory = EntityQuery.use(delegator).from("ProductFeatureCategory").where("productFeatureCategoryId", productFeatureCategoryId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error finding ProductFeatureCategory and Type information for constraint pretty print", module); } @@ -1217,7 +1218,7 @@ public class ProductSearch { public String prettyPrintConstraint(Delegator delegator, boolean detailed, Locale locale) { GenericValue productFeatureGroup = null; try { - productFeatureGroup = delegator.findOne("ProductFeatureGroup", UtilMisc.toMap("productFeatureGroupId", productFeatureGroupId), true); + productFeatureGroup = EntityQuery.use(delegator).from("ProductFeatureGroup").where("productFeatureGroupId", productFeatureGroupId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error finding ProductFeatureGroup and Type information for constraint pretty print", module); } @@ -1311,7 +1312,7 @@ public class ProductSearch { if (infoOut.length() > 0) { infoOut.append(", "); } - GenericValue productFeature = delegator.findOne("ProductFeature", UtilMisc.toMap("productFeatureId", featureId), true); + GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", featureId).cache().queryOne(); GenericValue productFeatureType = productFeature == null ? null : productFeature.getRelatedOne("ProductFeatureType", true); if (productFeatureType == null) { infoOut.append(UtilProperties.getMessage(resource, "ProductFeature", locale)).append(": "); 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -54,6 +54,7 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityJoinOperator; import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.entity.util.EntityUtilProperties; import org.ofbiz.product.catalog.CatalogWorker; @@ -123,7 +124,7 @@ public class ProductServices { } if (variantFound) { try { - products.add(delegator.findOne("Product", UtilMisc.toMap("productId", oneVariant.getString("productIdTo")), false)); + products.add(EntityQuery.use(delegator).from("Product").where("productId", oneVariant.getString("productIdTo")).queryOne()); } catch (GenericEntityException e) { Map<String, String> messageMap = UtilMisc.toMap("errProductFeatures", e.toString()); String errMsg = UtilProperties.getMessage(resourceError,"productservices.problem_reading_product_features_errors", messageMap, locale); @@ -226,7 +227,7 @@ public class ProductServices { GenericValue productTo = null; try { - productTo = delegator.findOne("Product", UtilMisc.toMap("productId", productIdTo), true); + productTo = EntityQuery.use(delegator).from("Product").where("productId", productIdTo).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); Map<String, String> messageMap = UtilMisc.toMap("productIdTo", productIdTo, "errMessage", e.toString()); @@ -410,7 +411,7 @@ public class ProductServices { } try { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); GenericValue mainProduct = product; if (product.get("isVariant") != null && product.getString("isVariant").equalsIgnoreCase("Y")) { @@ -482,7 +483,7 @@ public class ProductServices { GenericValue product = null; try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); } catch (GenericEntityException e) { Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resourceError, @@ -704,7 +705,7 @@ public class ProductServices { try { // read the product, duplicate it with the given id - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); if (product == null) { Map<String, String> messageMap = UtilMisc.toMap("productId", productId); errMsg = UtilProperties.getMessage(resourceError, @@ -756,7 +757,7 @@ public class ProductServices { while (st.hasMoreTokens()) { String productFeatureId = st.nextToken(); - GenericValue productFeature = delegator.findOne("ProductFeature", UtilMisc.toMap("productFeatureId", productFeatureId), false); + GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", productFeatureId).queryOne(); GenericValue productFeatureAppl = delegator.makeValue("ProductFeatureAppl", UtilMisc.toMap("productId", variantProductId, "productFeatureId", productFeatureId, @@ -841,7 +842,7 @@ public class ProductServices { continue; } // is a Product.productId? - GenericValue variantProduct = delegator.findOne("Product", UtilMisc.toMap("productId", variantProductId), false); + GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne(); if (variantProduct != null) { variantProductsById.put(variantProductId, variantProduct); } else { @@ -917,7 +918,7 @@ public class ProductServices { GenericValue inventoryItem = null; try { - inventoryItem = delegator.findOne("InventoryItem", UtilMisc.toMap("inventoryItemId", inventoryItemId), true); + inventoryItem = EntityQuery.use(delegator).from("InventoryItem").where("inventoryItemId", inventoryItemId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -927,7 +928,7 @@ public class ProductServices { String productId = inventoryItem.getString("productId"); GenericValue product = null; try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -1137,7 +1138,7 @@ public class ProductServices { if (UtilValidate.isNotEmpty(contentId)) { GenericValue content = null; try { - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false); + content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -1343,7 +1344,7 @@ public class ProductServices { if (UtilValidate.isNotEmpty(contentId)) { GenericValue content = null; try { - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false); + content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); } 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -44,6 +44,7 @@ import org.ofbiz.entity.model.DynamicVie import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.entity.util.EntityUtilProperties; import org.ofbiz.service.DispatchContext; @@ -78,7 +79,7 @@ public class ProductUtilServices { int numSoFarOne = 0; while ((productOne = eliOne.next()) != null) { String virtualProductId = ProductWorker.getVariantVirtualId(productOne); - GenericValue virtualProduct = delegator.findOne("Product", UtilMisc.toMap("productId", virtualProductId), false); + GenericValue virtualProduct = EntityQuery.use(delegator).from("Product").where("productId", virtualProductId).queryOne(); if (virtualProduct == null) { continue; } @@ -345,7 +346,7 @@ public class ProductUtilServices { } try { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + 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)); @@ -383,7 +384,7 @@ public class ProductUtilServices { String variantProductId = productAssoc.getString("productIdTo"); // Product - GenericValue variantProduct = delegator.findOne("Product", UtilMisc.toMap("productId", variantProductId), false); + GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne(); Debug.logInfo("--variant has ID: " + variantProductId + " and name: " + variantProduct.getString("internalName"), module); @@ -701,7 +702,7 @@ while (allCatIter.hasNext()) { productFeatureGroupId = productFeatureGroupId.substring(0, 20); } - GenericValue productFeatureGroup = delegator.findOne("ProductFeatureGroup", UtilMisc.toMap("productFeatureGroupId", productFeatureGroupId), false); + GenericValue productFeatureGroup = EntityQuery.use(delegator).from("ProductFeatureGroup").where("productFeatureGroupId", productFeatureGroupId).queryOne(); if (productFeatureGroup == null) { // auto-create the group String description = "Feature Group for type [" + productFeatureTypeId + "] features in category [" + productCategoryId + "]"; 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -43,6 +43,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.entity.util.EntityTypeUtil; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.product.config.ProductConfigWrapper; @@ -149,7 +150,7 @@ public class ProductWorker { } public static String getInstanceAggregatedId(Delegator delegator, String instanceProductId) throws GenericEntityException { - GenericValue instanceProduct = delegator.findOne("Product", UtilMisc.toMap("productId", instanceProductId), false); + GenericValue instanceProduct = EntityQuery.use(delegator).from("Product").where("productId", instanceProductId).queryOne(); if (UtilValidate.isNotEmpty(instanceProduct) && EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", instanceProduct.getString("productTypeId"), "parentTypeId", "AGGREGATED")) { GenericValue productAssoc = EntityUtil.getFirst(EntityUtil.filterByDate(instanceProduct.getRelated("AssocProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_CONF"), null, false))); @@ -174,7 +175,7 @@ public class ProductWorker { } public static List<GenericValue> getAggregatedAssocs(Delegator delegator, String aggregatedProductId) throws GenericEntityException { - GenericValue aggregatedProduct = delegator.findOne("Product", UtilMisc.toMap("productId", aggregatedProductId), false); + GenericValue aggregatedProduct = EntityQuery.use(delegator).from("Product").where("productId", aggregatedProductId).queryOne(); if (UtilValidate.isNotEmpty(aggregatedProduct) && ("AGGREGATED".equals(aggregatedProduct.getString("productTypeId")) || "AGGREGATED_SERVICE".equals(aggregatedProduct.getString("productTypeId")))) { List<GenericValue> productAssocs = EntityUtil.filterByDate(aggregatedProduct.getRelated("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_CONF"), null, false)); @@ -317,7 +318,7 @@ public class ProductWorker { */ public static String getGwpAlternativeOptionName(LocalDispatcher dispatcher, Delegator delegator, String alternativeOptionProductId, Locale locale) { try { - GenericValue alternativeOptionProduct = delegator.findOne("Product", UtilMisc.toMap("productId", alternativeOptionProductId), true); + GenericValue alternativeOptionProduct = EntityQuery.use(delegator).from("Product").where("productId", alternativeOptionProductId).cache().queryOne(); if (alternativeOptionProduct != null) { if ("Y".equals(alternativeOptionProduct.getString("isVariant"))) { Set<GenericValue> distFeatures = getVariantDistinguishingFeatures(alternativeOptionProduct); @@ -366,7 +367,7 @@ public class ProductWorker { return null; } try { - return getProductFeaturesByApplTypeId(delegator.findOne("Product", UtilMisc.toMap("productId", productId), false), + return getProductFeaturesByApplTypeId(EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(), productFeatureApplTypeId); } catch (GenericEntityException e) { Debug.logError(e, module); @@ -402,7 +403,7 @@ public class ProductWorker { public static String getProductVirtualVariantMethod(Delegator delegator, String productId) { GenericValue product = null; try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -596,7 +597,7 @@ public class ProductWorker { public static BigDecimal getAverageProductRating(Delegator delegator, String productId, String productStoreId) { GenericValue product = null; try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -678,7 +679,7 @@ public class ProductWorker { public static List<GenericValue> getCurrentProductCategories(Delegator delegator, String productId) { GenericValue product = null; try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -758,7 +759,7 @@ public class ProductWorker { public static boolean isVirtual(Delegator delegator, String productI) { try { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productI), true); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productI).cache().queryOne(); if (product != null) { return "Y".equals(product.getString("isVirtual")); } @@ -771,7 +772,7 @@ public class ProductWorker { public static boolean isAmountRequired(Delegator delegator, String productI) { try { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productI), true); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productI).cache().queryOne(); if (product != null) { return "Y".equals(product.getString("requireAmount")); } @@ -784,7 +785,7 @@ public class ProductWorker { public static String getProductTypeId(Delegator delegator, String productId) { try { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); if (product != null) { return product.getString("productTypeId"); } @@ -863,7 +864,7 @@ public class ProductWorker { // 1) look if the idToFind given is a real productId if (searchProductFirst) { - product = delegator.findOne("Product", UtilMisc.toMap("productId", idToFind), true); + product = EntityQuery.use(delegator).from("Product").where("productId", idToFind).cache().queryOne(); } if (searchAllId || (searchProductFirst && UtilValidate.isEmpty(product))) { @@ -876,7 +877,7 @@ public class ProductWorker { } if (! searchProductFirst) { - product = delegator.findOne("Product", UtilMisc.toMap("productId", idToFind), true); + product = EntityQuery.use(delegator).from("Product").where("productId", idToFind).cache().queryOne(); } if (UtilValidate.isNotEmpty(product)) { @@ -919,7 +920,7 @@ public class ProductWorker { GenericValue productToAdd = product; //retreive product GV if the actual genericValue came from viewEntity if (! "Product".equals(product.getEntityName())) { - productToAdd = delegator.findOne("Product", UtilMisc.toMap("productId", product.get("productId")), true); + productToAdd = EntityQuery.use(delegator).from("Product").where("productId", product.get("productId")).cache().queryOne(); } if (UtilValidate.isEmpty(products)) { @@ -1055,7 +1056,7 @@ nextProd: */ if (!productFound) { // copy product to be variant - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); product.put("isVariant", "Y"); product.put("isVirtual", "N"); product.put("productId", delegator.getNextSeqId("Product")); @@ -1197,7 +1198,7 @@ nextProd: public static boolean isAggregateService(Delegator delegator, String aggregatedProductId) { try { - GenericValue aggregatedProduct = delegator.findOne("Product", UtilMisc.toMap("productId", aggregatedProductId), true); + GenericValue aggregatedProduct = EntityQuery.use(delegator).from("Product").where("productId", aggregatedProductId).cache().queryOne(); if (UtilValidate.isNotEmpty(aggregatedProduct) && "AGGREGATED_SERVICE".equals(aggregatedProduct.getString("productTypeId"))) { return true; } 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -32,6 +32,7 @@ import org.ofbiz.entity.GenericEntityExc import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.transaction.GenericTransactionException; import org.ofbiz.entity.transaction.TransactionUtil; +import org.ofbiz.entity.util.EntityQuery; import java.util.Map; @@ -84,7 +85,7 @@ public class VariantEvents { try { // read the product, duplicate it with the given id - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); if (product == null) { Map<String, String> messageMap = UtilMisc.toMap("productId", productId); errMsg = UtilProperties.getMessage(resource,"variantevents.product_not_found_with_ID", messageMap, UtilHttp.getLocale(request)); @@ -130,7 +131,7 @@ public class VariantEvents { return "error"; } - GenericValue productFeature = delegator.findOne("ProductFeature", UtilMisc.toMap("productFeatureId", productFeatureId), false); + GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", productFeatureId).queryOne(); GenericValue productFeatureAppl = delegator.makeValue("ProductFeatureAppl", UtilMisc.toMap("productId", variantProductId, "productFeatureId", productFeatureId, 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -43,6 +43,7 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -92,7 +93,7 @@ public class PromoServices { } GenericValue existingPromoCode = null; try { - existingPromoCode = delegator.findOne("ProductPromoCode", UtilMisc.toMap("productPromoCodeId", newPromoCodeId), true); + existingPromoCode = EntityQuery.use(delegator).from("ProductPromoCode").where("productPromoCodeId", newPromoCodeId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logWarning("Could not find ProductPromoCode for just generated ID: " + newPromoCodeId, module); 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -18,9 +18,6 @@ *******************************************************************************/ package org.ofbiz.product.store; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.io.Writer; import java.util.List; import java.util.Map; @@ -30,9 +27,6 @@ import javax.servlet.http.HttpServletRes import javolution.util.FastList; import javolution.util.FastMap; -import net.sf.json.JSONObject; - -import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; @@ -47,7 +41,7 @@ public class ProductStoreEvents { // Please note : the structure of map in this function is according to the JSON data map of the jsTree @SuppressWarnings("unchecked") - public static void getChildProductStoreGroupTree(HttpServletRequest request, HttpServletResponse response){ + public static String getChildProductStoreGroupTree(HttpServletRequest request, HttpServletResponse response){ Delegator delegator = (Delegator) request.getAttribute("delegator"); String parentGroupId = request.getParameter("parentGroupId"); String onclickFunction = request.getParameter("onclickFunction"); @@ -92,41 +86,13 @@ public class ProductStoreEvents { productStoreGroupList.add(josonMap); } List<Map<Object, Object>> sortedProductStoreGroupList = UtilMisc.sortMaps(productStoreGroupList, sortList); - toJsonObjectList(sortedProductStoreGroupList,response); + request.setAttribute("storeGroupTree", sortedProductStoreGroupList); } } } catch (GenericEntityException e) { e.printStackTrace(); + return "error"; } - } - - @SuppressWarnings("unchecked") - public static void toJsonObjectList(List attrList, HttpServletResponse response){ - String jsonStr = "["; - for (Object attrMap : attrList) { - JSONObject json = JSONObject.fromObject(attrMap); - jsonStr = jsonStr + json.toString() + ','; - } - jsonStr = jsonStr + "{ } ]"; - if (UtilValidate.isEmpty(jsonStr)) { - Debug.logError("JSON Object was empty; fatal error!",module); - } - // set the X-JSON content type - response.setContentType("application/json"); - // jsonStr.length is not reliable for unicode characters - try { - response.setContentLength(jsonStr.getBytes("UTF8").length); - } catch (UnsupportedEncodingException e) { - Debug.logError("Problems with Json encoding",module); - } - // return the JSON String - Writer out; - try { - out = response.getWriter(); - out.write(jsonStr); - out.flush(); - } catch (IOException e) { - Debug.logError("Unable to get response writer",module); - } + return "success"; } } 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -39,6 +39,7 @@ import org.ofbiz.common.geo.GeoWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.party.contact.ContactMechWorker; import org.ofbiz.product.config.ProductConfigWrapper; @@ -61,7 +62,7 @@ public class ProductStoreWorker { } GenericValue productStore = null; try { - productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), true); + productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting ProductStore entity", module); } @@ -115,7 +116,7 @@ public class ProductStoreWorker { public static String determineSingleFacilityForStore(Delegator delegator, String productStoreId) { GenericValue productStore = null; try { - productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), false); + productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -166,7 +167,7 @@ public class ProductStoreWorker { public static GenericValue getProductStorePaymentSetting(Delegator delegator, String productStoreId, String paymentMethodTypeId, String paymentServiceTypeEnumId, boolean anyServiceType) { GenericValue storePayment = null; try { - storePayment = delegator.findOne("ProductStorePaymentSetting", UtilMisc.toMap("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId, "paymentServiceTypeEnumId", paymentServiceTypeEnumId), true); + storePayment = EntityQuery.use(delegator).from("ProductStorePaymentSetting").where("productStoreId", productStoreId, "paymentMethodTypeId", paymentMethodTypeId, "paymentServiceTypeEnumId", paymentServiceTypeEnumId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Problems looking up store payment settings", module); } @@ -487,7 +488,7 @@ public class ProductStoreWorker { // if the item is a variant, get its virtual productId try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); if ((product != null) && ("Y".equals(product.get("isVariant")))) { if (parentProductId != null) { virtualProductId = parentProductId; 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -38,6 +38,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.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -138,7 +139,7 @@ public class SubscriptionServices { try { if (lastSubscription != null && !alwaysCreateNewRecord) { Map<String, Object> updateSubscriptionMap = dctx.getModelService("updateSubscription").makeValid(newSubscription, ModelService.IN_PARAM); - updateSubscriptionMap.put("userLogin", delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false)); + updateSubscriptionMap.put("userLogin", EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne()); Map<String, Object> updateSubscriptionResult = dispatcher.runSync("updateSubscription", updateSubscriptionMap); result.put("subscriptionId", updateSubscriptionMap.get("subscriptionId")); @@ -163,7 +164,7 @@ public class SubscriptionServices { } } Map<String, Object> createSubscriptionMap = dctx.getModelService("createSubscription").makeValid(newSubscription, ModelService.IN_PARAM); - createSubscriptionMap.put("userLogin", delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false)); + createSubscriptionMap.put("userLogin", EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne()); Map<String, Object> createSubscriptionResult = dispatcher.runSync("createSubscription", createSubscriptionMap); if (ServiceUtil.isError(createSubscriptionResult)) { @@ -263,7 +264,7 @@ public class SubscriptionServices { "OrderErrorCannotGetOrderRoleEntity", UtilMisc.toMap("itemMsgInfo", orderId), locale)); } - orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); + orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); if (orderHeader == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceOrderError, "OrderErrorNoValidOrderHeaderFoundForOrderId", @@ -331,7 +332,7 @@ public class SubscriptionServices { int field = Calendar.MONTH; String subscriptionResourceId = subscription.getString("subscriptionResourceId"); GenericValue subscriptionResource = null; - subscriptionResource = delegator.findOne("SubscriptionResource", UtilMisc.toMap("subscriptionResourceId", subscriptionResourceId), false); + subscriptionResource = EntityQuery.use(delegator).from("SubscriptionResource").where("subscriptionResourceId", subscriptionResourceId).queryOne(); subscriptionId = subscription.getString("subscriptionId"); gracePeriodOnExpiry = subscription.getString("gracePeriodOnExpiry"); gracePeriodOnExpiryUomId = subscription.getString("gracePeriodOnExpiryUomId"); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java Mon Nov 3 06:54:16 2014 @@ -36,6 +36,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.entity.util.EntityUtil; import org.ofbiz.product.product.ProductWorker; import org.ofbiz.service.DispatchContext; @@ -65,7 +66,7 @@ public class SupplierProductServices { BigDecimal quantity =(BigDecimal) context.get("quantity"); String canDropShip = (String) context.get("canDropShip"); try { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); if (product == null) { results = ServiceUtil.returnSuccess(); results.put("supplierProducts",null); @@ -76,7 +77,7 @@ public class SupplierProductServices { // if there were no related SupplierProduct entities and the item is a variant, then get the SupplierProducts of the virtual parent product if (supplierProducts.size() == 0 && product.getString("isVariant") != null && product.getString("isVariant").equals("Y")) { String virtualProductId = ProductWorker.getVariantVirtualId(product); - GenericValue virtualProduct = delegator.findOne("Product", UtilMisc.toMap("productId", virtualProductId), true); + GenericValue virtualProduct = EntityQuery.use(delegator).from("Product").where("productId", virtualProductId).cache().queryOne(); if (virtualProduct != null) { supplierProducts = virtualProduct.getRelated("SupplierProduct", null, null, true); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java Mon Nov 3 06:54:16 2014 @@ -27,6 +27,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.service.testtools.OFBizTestCase; public class InventoryItemTransferTest extends OFBizTestCase { @@ -41,7 +42,7 @@ public class InventoryItemTransferTest e @Override protected void setUp() throws Exception { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); } @Override Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/test/StockMovesTest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/test/StockMovesTest.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/test/StockMovesTest.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/test/StockMovesTest.java Mon Nov 3 06:54:16 2014 @@ -29,6 +29,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.service.testtools.OFBizTestCase; /** @@ -44,7 +45,7 @@ public class StockMovesTest extends OFBi @Override protected void setUp() throws Exception { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); } @Override 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=1636282&r1=1636281&r2=1636282&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 3 06:54:16 2014 @@ -39,6 +39,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.product.product.ProductWorker; import org.ofbiz.service.GenericServiceException; @@ -737,7 +738,7 @@ public class PackingSession implements j if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("vendorPartyId"))) { partyIdFrom = orderItemShipGroup.getString("vendorPartyId"); } else if (UtilValidate.isNotEmpty(orderItemShipGroup.getString("facilityId"))) { - GenericValue facility = delegator.findOne("Facility", UtilMisc.toMap("facilityId", orderItemShipGroup.getString("facilityId")), false); + GenericValue facility = EntityQuery.use(delegator).from("Facility").where("facilityId", orderItemShipGroup.getString("facilityId")).queryOne(); if (UtilValidate.isNotEmpty(facility.getString("ownerPartyId"))) { partyIdFrom = facility.getString("ownerPartyId"); } @@ -752,7 +753,7 @@ public class PackingSession implements j } } } else if (this.facilityId != null) { - GenericValue facility = delegator.findOne("Facility", UtilMisc.toMap("facilityId", this.facilityId), false); + GenericValue facility = EntityQuery.use(delegator).from("Facility").where("facilityId", this.facilityId).queryOne(); if (UtilValidate.isNotEmpty(facility.getString("ownerPartyId"))) { partyIdFrom = facility.getString("ownerPartyId"); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/shipment/ShipmentEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/shipment/ShipmentEvents.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/shipment/ShipmentEvents.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/shipment/ShipmentEvents.java Mon Nov 3 06:54:16 2014 @@ -31,6 +31,7 @@ import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -51,7 +52,7 @@ public class ShipmentEvents { GenericValue shipmentPackageRouteSeg = null; try { - shipmentPackageRouteSeg = delegator.findOne("ShipmentPackageRouteSeg", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentPackageSeqId", shipmentPackageSeqId), false); + shipmentPackageRouteSeg = EntityQuery.use(delegator).from("ShipmentPackageRouteSeg").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentPackageSeqId", shipmentPackageSeqId).queryOne(); } catch (GenericEntityException e) { String errorMsg = "Error looking up ShipmentPackageRouteSeg: " + e.toString(); Debug.logError(e, errorMsg, module); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Mon Nov 3 06:54:16 2014 @@ -43,6 +43,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.party.party.PartyWorker; import org.ofbiz.service.DispatchContext; @@ -73,7 +74,7 @@ public class ShipmentServices { GenericValue productStoreShipMeth = null; try { - productStoreShipMeth = delegator.findOne("ProductStoreShipmentMeth", UtilMisc.toMap("productStoreShipMethId", productStoreShipMethId), false); + productStoreShipMeth = EntityQuery.use(delegator).from("ProductStoreShipmentMeth").where("productStoreShipMethId", productStoreShipMethId).queryOne(); } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductStoreShipmentMethodCannotRetrieve", @@ -147,7 +148,7 @@ public class ShipmentServices { GenericValue estimate = null; try { - estimate = delegator.findOne("ShipmentCostEstimate", UtilMisc.toMap("shipmentCostEstimateId", shipmentCostEstimateId), false); + estimate = EntityQuery.use(delegator).from("ShipmentCostEstimate").where("shipmentCostEstimateId", shipmentCostEstimateId).queryOne(); estimate.remove(); } catch (GenericEntityException e) { Debug.logError(e, module); @@ -292,7 +293,7 @@ public class ShipmentServices { GenericValue shipAddress = null; if (shippingContactMechId != null) { try { - shipAddress = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", shippingContactMechId), false); + shipAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", shippingContactMechId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, @@ -617,7 +618,7 @@ public class ShipmentServices { GenericValue shipment = null; if (shipmentId != null) { try { - shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); + shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -741,7 +742,7 @@ public class ShipmentServices { // only need to do this for the first package GenericValue rtSeg = null; try { - rtSeg = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", "00001"), false); + rtSeg = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", "00001").queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -913,7 +914,7 @@ public class ShipmentServices { 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 - GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); + GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); if ((! UtilValidate.isEmpty(shipment)) && "PURCH_SHIP_CREATED".equals(shipment.getString("statusId"))) { Map<String, Object> updateShipmentMap = dispatcher.runSync("updateShipment", UtilMisc.<String, Object>toMap("shipmentId", shipmentId, "statusId", "PURCH_SHIP_SHIPPED", "userLogin", userLogin)); if (ServiceUtil.isError(updateShipmentMap)) { @@ -972,7 +973,7 @@ public class ShipmentServices { Map<String, Object> results = ServiceUtil.returnSuccess(); try { - GenericValue shipmentRouteSeg = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false); + GenericValue shipmentRouteSeg = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSeg == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductShipmentRouteSegmentNotFound", @@ -1068,14 +1069,14 @@ public class ShipmentServices { GenericValue shipmentPackage = null; try { - shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); + shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); if (UtilValidate.isEmpty(shipment)) { String errorMessage = UtilProperties.getMessage(resource, "ProductShipmentNotFoundId", locale); Debug.logError(errorMessage, module); return ServiceUtil.returnError(errorMessage); } - shipmentPackage = delegator.findOne("ShipmentPackage", UtilMisc.toMap("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId), false); + shipmentPackage = EntityQuery.use(delegator).from("ShipmentPackage").where("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId).queryOne(); if (UtilValidate.isEmpty(shipmentPackage)) { String errorMessage = UtilProperties.getMessage(resource, "ProductShipmentPackageNotFound", context, locale); Debug.logError(errorMessage, module); @@ -1140,14 +1141,14 @@ public class ShipmentServices { GenericValue shipment = null ; GenericValue orderHeader = null; try { - shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); - orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", shipment.getString("primaryOrderId")), false); + shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); + orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", shipment.getString("primaryOrderId")).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting info from database", module); } GenericValue productStoreEmail = null; try { - productStoreEmail = delegator.findOne("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", orderHeader.get("productStoreId"), "emailType", "PRDS_ODR_SHIP_COMPLT"), false); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", orderHeader.get("productStoreId"), "emailType", "PRDS_ODR_SHIP_COMPLT").queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting the ProductStoreEmailSetting for productStoreId =" + orderHeader.get("productStoreId") + " and emailType = PRDS_ODR_SHIP_COMPLT", module); } @@ -1217,7 +1218,7 @@ public class ShipmentServices { public static Map<String, Object> getShipmentGatewayConfigFromShipment(Delegator delegator, String shipmentId, Locale locale) { Map<String, Object> shipmentGatewayConfig = ServiceUtil.returnSuccess(); try { - GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); + GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); if (shipment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductShipmentNotFoundId", locale) + shipmentId); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/test/IssuanceTest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/test/IssuanceTest.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/test/IssuanceTest.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/test/IssuanceTest.java Mon Nov 3 06:54:16 2014 @@ -25,6 +25,7 @@ import java.util.List; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.shipment.packing.PackingSession; import org.ofbiz.service.testtools.OFBizTestCase; @@ -41,7 +42,7 @@ public class IssuanceTest extends OFBizT @Override protected void setUp() throws Exception { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); } @Override @@ -61,7 +62,7 @@ public class IssuanceTest extends OFBizT BigDecimal.valueOf(1000L), false); String shipmentId = packSession.complete(false); - GenericValue orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), true); + GenericValue orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).cache().queryOne(); // Test the OrderShipment is correct List<GenericValue> orderShipments = orderHeader.getRelated("OrderShipment", null, null, false); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java Mon Nov 3 06:54:16 2014 @@ -45,6 +45,7 @@ import org.ofbiz.content.content.Content import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -198,7 +199,7 @@ public class DhlServices { GenericValue shipToAddress = null; if (shippingContactMechId != null) { try { - shipToAddress = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", shippingContactMechId), false); + shipToAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", shippingContactMechId).queryOne(); if (shipToAddress == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUnableFoundShipToAddresss", locale)); @@ -522,12 +523,12 @@ public class DhlServices { String shipmentConfirmResponseString = null; try { - GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); + GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); if (shipment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentNotFoundId", locale) + shipmentId); } - GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false); + GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSegment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentRouteSegmentNotFound", @@ -956,7 +957,7 @@ public class DhlServices { String returnValue = ""; if (UtilValidate.isNotEmpty(shipmentGatewayConfigId)) { try { - GenericValue dhl = delegator.findOne("ShipmentGatewayDhl", UtilMisc.toMap("shipmentGatewayConfigId", shipmentGatewayConfigId), false); + GenericValue dhl = EntityQuery.use(delegator).from("ShipmentGatewayDhl").where("shipmentGatewayConfigId", shipmentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(dhl)) { Object dhlField = dhl.get(shipmentGatewayConfigParameterName); if (dhlField != null) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java Mon Nov 3 06:54:16 2014 @@ -45,6 +45,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.entity.util.EntityUtil; import org.ofbiz.entity.util.EntityUtilProperties; import org.ofbiz.party.party.PartyHelper; @@ -182,7 +183,7 @@ public class FedexServices { String emailAddress = null; try { // Make sure the company exists - GenericValue companyParty = delegator.findOne("Party", UtilMisc.toMap("partyId", companyPartyId), true); + GenericValue companyParty = EntityQuery.use(delegator).from("Party").where("partyId", companyPartyId).cache().queryOne(); if (companyParty == null) { String errorMessage = "Party with partyId " + companyPartyId + " does not exist"; Debug.logError(errorMessage, module); @@ -237,12 +238,12 @@ public class FedexServices { "FacilityShipmentFedexCompanyPartyHasNotPostalAddress", UtilMisc.toMap("companyPartyId", companyPartyId), locale)); } - GenericValue countryGeo = delegator.findOne("Geo", UtilMisc.toMap("geoId", postalAddress.getString("countryGeoId")), true); + GenericValue countryGeo = EntityQuery.use(delegator).from("Geo").where("geoId", postalAddress.getString("countryGeoId")).cache().queryOne(); String countryCode = countryGeo.getString("geoCode"); String stateOrProvinceCode = null; // Only add the StateOrProvinceCode element if the address is in USA or Canada if (countryCode.equals("CA") || countryCode.equals("US")) { - GenericValue stateProvinceGeo = delegator.findOne("Geo", UtilMisc.toMap("geoId", postalAddress.getString("stateProvinceGeoId")), true); + GenericValue stateProvinceGeo = EntityQuery.use(delegator).from("Geo").where("geoId", postalAddress.getString("stateProvinceGeoId")).cache().queryOne(); stateOrProvinceCode = stateProvinceGeo.getString("geoCode"); } @@ -470,12 +471,12 @@ public class FedexServices { Map<String, Object> shipRequestContext = FastMap.newInstance(); // Get the shipment and the shipmentRouteSegment - GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); + GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); if (UtilValidate.isEmpty(shipment)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentNotFoundId", locale) + shipmentId); } - GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false); + GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (UtilValidate.isEmpty(shipmentRouteSegment)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentRouteSegmentNotFound", @@ -499,7 +500,7 @@ public class FedexServices { // Translate shipmentMethodTypeId to Fedex service code and carrier code String shipmentMethodTypeId = shipmentRouteSegment.getString("shipmentMethodTypeId"); - GenericValue carrierShipmentMethod = delegator.findOne("CarrierShipmentMethod", UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId, "partyId", "FEDEX", "roleTypeId", "CARRIER"), false); + GenericValue carrierShipmentMethod = EntityQuery.use(delegator).from("CarrierShipmentMethod").where("shipmentMethodTypeId", shipmentMethodTypeId, "partyId", "FEDEX", "roleTypeId", "CARRIER").queryOne(); if (UtilValidate.isEmpty(carrierShipmentMethod)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentFedexRouteSegmentCarrierShipmentMethodNotFound", @@ -558,7 +559,7 @@ public class FedexServices { UtilMisc.toMap("contactMechId", originPostalAddress.getString("contactMechId"), "shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } - GenericValue stateProvinceGeo = delegator.findOne("Geo", UtilMisc.toMap("geoId", originPostalAddress.getString("stateProvinceGeoId")), true); + GenericValue stateProvinceGeo = EntityQuery.use(delegator).from("Geo").where("geoId", originPostalAddress.getString("stateProvinceGeoId")).cache().queryOne(); originAddressStateOrProvinceCode = stateProvinceGeo.getString("geoCode"); } @@ -633,7 +634,7 @@ public class FedexServices { UtilMisc.toMap("contactMechId", destinationPostalAddress.getString("contactMechId"), "shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } - GenericValue stateProvinceGeo = delegator.findOne("Geo", UtilMisc.toMap("geoId", destinationPostalAddress.getString("stateProvinceGeoId")), true); + GenericValue stateProvinceGeo = EntityQuery.use(delegator).from("Geo").where("geoId", destinationPostalAddress.getString("stateProvinceGeoId")).cache().queryOne(); destinationAddressStateOrProvinceCode = stateProvinceGeo.getString("geoCode"); } @@ -659,7 +660,7 @@ public class FedexServices { "FacilityShipmentFedexPartyToRequired", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); } - GenericValue partyTo = delegator.findOne("Party", UtilMisc.toMap("partyId", destinationPartyId), false); + GenericValue partyTo = EntityQuery.use(delegator).from("Party").where("partyId", destinationPartyId).queryOne(); String destinationContactKey = "PERSON".equals(partyTo.getString("partyTypeId")) ? "DestinationContactPersonName" : "DestinationContactCompanyName"; String destinationContactName = PartyHelper.getPartyName(partyTo, false); if (UtilValidate.isEmpty(destinationContactName)) { @@ -795,7 +796,7 @@ public class FedexServices { } // Make sure that the packaging type is valid for FedEx - GenericValue carrierShipmentBoxType = delegator.findOne("CarrierShipmentBoxType", UtilMisc.toMap("partyId", "FEDEX", "shipmentBoxTypeId", packaging), false); + GenericValue carrierShipmentBoxType = EntityQuery.use(delegator).from("CarrierShipmentBoxType").where("partyId", "FEDEX", "shipmentBoxTypeId", packaging).queryOne(); if (UtilValidate.isEmpty(carrierShipmentBoxType)) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentFedexPackingTypeInvalid", @@ -1063,7 +1064,7 @@ public class FedexServices { String returnValue = ""; if (UtilValidate.isNotEmpty(shipmentGatewayConfigId)) { try { - GenericValue fedex = delegator.findOne("ShipmentGatewayFedex", UtilMisc.toMap("shipmentGatewayConfigId", shipmentGatewayConfigId), false); + GenericValue fedex = EntityQuery.use(delegator).from("ShipmentGatewayFedex").where("shipmentGatewayConfigId", shipmentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(fedex)) { Object fedexField = fedex.get(shipmentGatewayConfigParameterName); if (fedexField != null) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java?rev=1636282&r1=1636281&r2=1636282&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java Mon Nov 3 06:54:16 2014 @@ -55,6 +55,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.entity.util.EntityUtil; import org.ofbiz.entity.util.EntityUtilProperties; import org.ofbiz.party.contact.ContactMechWorker; @@ -122,11 +123,11 @@ public class UpsServices { String shipmentConfirmResponseString = null; try { - GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); + GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); if (shipment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentNotFoundId", locale) + " " + shipmentId); } - GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false); + GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSegment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentRouteSegmentNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); @@ -846,8 +847,8 @@ public class UpsServices { String shipmentAcceptResponseString = null; try { - //GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); - GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false); + //GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); + GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (!"UPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUpsNotRouteSegmentCarrier", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); @@ -1283,8 +1284,8 @@ public class UpsServices { String voidShipmentResponseString = null; try { - //GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); - GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false); + //GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); + GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (!"UPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUpsNotRouteSegmentCarrier", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); @@ -1488,8 +1489,8 @@ public class UpsServices { String trackResponseString = null; try { - //GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); - GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false); + //GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); + GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (!"UPS".equals(shipmentRouteSegment.getString("carrierPartyId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUpsNotRouteSegmentCarrier", UtilMisc.toMap("shipmentRouteSegmentId", shipmentRouteSegmentId, "shipmentId", shipmentId), locale)); @@ -1716,7 +1717,7 @@ public class UpsServices { GenericValue shipToAddress = null; if (shippingContactMechId != null) { try { - shipToAddress = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", shippingContactMechId), false); + shipToAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", shippingContactMechId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -1729,7 +1730,7 @@ public class UpsServices { GenericValue shipFromAddress = null; if (shippingOriginContactMechId != null) { try { - shipFromAddress = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", shippingOriginContactMechId), false); + shipFromAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", shippingOriginContactMechId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "FacilityShipmentUnableFoundShipToAddresssForDropShipping", locale)); @@ -2060,7 +2061,7 @@ public class UpsServices { GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, productStore.getString("inventoryFacilityId"), UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); if (facilityContactMech != null) { try { - shipFromAddress = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId")), false); + shipFromAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", facilityContactMech.getString("contactMechId")).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -2411,11 +2412,11 @@ public class UpsServices { String shipmentConfirmResponseString = null; try { - GenericValue shipment = delegator.findOne("Shipment", UtilMisc.toMap("shipmentId", shipmentId), false); + GenericValue shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne(); if (shipment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentNotFoundId", locale) + " " + shipmentId); } - GenericValue shipmentRouteSegment = delegator.findOne("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), false); + GenericValue shipmentRouteSegment = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId).queryOne(); if (shipmentRouteSegment == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "ProductShipmentRouteSegmentNotFound", UtilMisc.toMap("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegmentId), locale)); @@ -3184,7 +3185,7 @@ public class UpsServices { String returnValue = ""; if (UtilValidate.isNotEmpty(shipmentGatewayConfigId)) { try { - GenericValue ups = delegator.findOne("ShipmentGatewayUps", UtilMisc.toMap("shipmentGatewayConfigId", shipmentGatewayConfigId), false); + GenericValue ups = EntityQuery.use(delegator).from("ShipmentGatewayUps").where("shipmentGatewayConfigId", shipmentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(ups)) { Object upsField = ups.get(shipmentGatewayConfigParameterName); if (upsField != null) { |
Free forum by Nabble | Edit this page |