Modified: ofbiz/branches/json-integration-refactoring/applications/party/src/org/ofbiz/party/party/PartyWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/party/src/org/ofbiz/party/party/PartyWorker.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/party/src/org/ofbiz/party/party/PartyWorker.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/party/src/org/ofbiz/party/party/PartyWorker.java Thu Oct 30 06:10:58 2014 @@ -43,6 +43,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityFunction; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.ModelEntity; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; /** @@ -58,7 +59,7 @@ public class PartyWorker { Delegator delegator = (Delegator) request.getAttribute("delegator"); Map<String, GenericValue> result = FastMap.newInstance(); try { - GenericValue party = delegator.findOne("Party", UtilMisc.toMap("partyId", partyId), false); + GenericValue party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne(); if (party != null) result.put(partyAttr, party); @@ -67,7 +68,7 @@ public class PartyWorker { } try { - GenericValue person = delegator.findOne("Person", UtilMisc.toMap("partyId", partyId), false); + GenericValue person = EntityQuery.use(delegator).from("Person").where("partyId", partyId).queryOne(); if (person != null) result.put(personAttr, person); @@ -76,7 +77,7 @@ public class PartyWorker { } try { - GenericValue partyGroup = delegator.findOne("PartyGroup", UtilMisc.toMap("partyId", partyId), false); + GenericValue partyGroup = EntityQuery.use(delegator).from("PartyGroup").where("partyId", partyId).queryOne(); if (partyGroup != null) result.put(partyGroupAttr, partyGroup); @@ -260,7 +261,7 @@ public class PartyWorker { for (GenericValue partyAndAddr: validFound) { String partyId = partyAndAddr.getString("partyId"); if (UtilValidate.isNotEmpty(partyId)) { - GenericValue p = delegator.findOne("Person", UtilMisc.toMap("partyId", partyId), false); + GenericValue p = EntityQuery.use(delegator).from("Person").where("partyId", partyId).queryOne(); if (p != null) { String fName = p.getString("firstName"); String lName = p.getString("lastName"); @@ -493,7 +494,7 @@ public class PartyWorker { // 1) look if the idToFind given is a real partyId if (searchPartyFirst) { - party = delegator.findOne("Party", UtilMisc.toMap("partyId", idToFind), true); + party = EntityQuery.use(delegator).from("Party").where("partyId", idToFind).cache().queryOne(); } if (searchAllId || (searchPartyFirst && UtilValidate.isEmpty(party))) { @@ -506,7 +507,7 @@ public class PartyWorker { } if (! searchPartyFirst) { - party = delegator.findOne("Party", UtilMisc.toMap("partyId", idToFind), true); + party = EntityQuery.use(delegator).from("Party").where("partyId", idToFind).cache().queryOne(); } if (UtilValidate.isNotEmpty(party)) { @@ -549,7 +550,7 @@ public class PartyWorker { GenericValue partyToAdd = party; //retreive party GV if the actual genericValue came from viewEntity if (! "Party".equals(party.getEntityName())) { - partyToAdd = delegator.findOne("Party", UtilMisc.toMap("partyId", party.get("partyId")), true); + partyToAdd = EntityQuery.use(delegator).from("Party").where("partyId", party.get("partyId")).cache().queryOne(); } if (UtilValidate.isEmpty(parties)) {
Modified: ofbiz/branches/json-integration-refactoring/applications/product/script/org/ofbiz/product/product/ProductServices.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/script/org/ofbiz/product/product/ProductServices.xml?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/script/org/ofbiz/product/product/ProductServices.xml (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/script/org/ofbiz/product/product/ProductServices.xml Thu Oct 30 06:10:58 2014 @@ -445,35 +445,7 @@ under the License. <call-service service-name="countProductView" in-map-name="callSubMap"></call-service> </if-not-empty> </simple-method> - <simple-method method-name="countProductQuantityOrdered" short-description="Count Product Quantity Ordered" login-required="true"> - <if-empty field="parameters.quantity"> - <calculate field="parameters.quantity" type="BigDecimal"><number value="1"/></calculate> - </if-empty> - <entity-one entity-name="ProductCalculatedInfo" value-field="productCalculatedInfo"/> - <if-empty field="productCalculatedInfo"> - <!-- go ahead and create it --> - <make-value value-field="productCalculatedInfo" entity-name="ProductCalculatedInfo"/> - <set from-field="parameters.productId" field="productCalculatedInfo.productId"/> - <set from-field="parameters.quantity" field="productCalculatedInfo.totalQuantityOrdered"/> - <create-value value-field="productCalculatedInfo"/> - <else> - <set field="productCalculatedInfo.totalQuantityOrdered" value="${productCalculatedInfo.totalQuantityOrdered + parameters.quantity}" type="BigDecimal"/> - <store-value value-field="productCalculatedInfo"/> - </else> - </if-empty> - - <!-- do the same for the virtual product... --> - <entity-one entity-name="Product" value-field="product" use-cache="true"/> - <call-class-method class-name="org.ofbiz.product.product.ProductWorker" method-name="getVariantVirtualId" ret-field="virtualProductId"> - <field field="product" type="GenericValue"/> - </call-class-method> - <if-not-empty field="virtualProductId"> - <set from-field="virtualProductId" field="callSubMap.productId"/> - <set from-field="parameters.quantity" field="callSubMap.quantity"/> - <call-service service-name="countProductQuantityOrdered" in-map-name="callSubMap"></call-service> - </if-not-empty> - </simple-method> - + <simple-method method-name="createProductReview" short-description="Create a ProductReview" login-required="false"> <make-value value-field="newEntity" entity-name="ProductReview"/> <set-nonpk-fields map="parameters" value-field="newEntity"/> Modified: ofbiz/branches/json-integration-refactoring/applications/product/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/servicedef/services.xml?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/servicedef/services.xml (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/servicedef/services.xml Thu Oct 30 06:10:58 2014 @@ -175,13 +175,7 @@ under the License. <attribute name="productId" type="String" mode="IN" optional="false"/> <attribute name="weight" type="Long" mode="IN" optional="true"/> </service> - <service name="countProductQuantityOrdered" engine="simple" - location="component://product/script/org/ofbiz/product/product/ProductServices.xml" invoke="countProductQuantityOrdered" auth="true"> - <description>count Product Quantity Ordered</description> - <attribute name="productId" type="String" mode="IN" optional="false"/> - <attribute name="quantity" type="BigDecimal" mode="IN" optional="false"/> - </service> - + <service name="createProductReview" engine="simple" location="component://product/script/org/ofbiz/product/product/ProductServices.xml" invoke="createProductReview" auth="true"> <description>Create a product review entity</description> Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java Thu Oct 30 06:10:58 2014 @@ -37,6 +37,7 @@ import org.ofbiz.webapp.website.WebSiteW 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.product.category.CategoryWorker; import org.ofbiz.product.store.ProductStoreWorker; @@ -213,7 +214,7 @@ public class CatalogWorker { Delegator delegator = (Delegator) request.getAttribute("delegator"); try { - GenericValue prodCatalog = delegator.findOne("ProdCatalog", UtilMisc.toMap("prodCatalogId", prodCatalogId), true); + GenericValue prodCatalog = EntityQuery.use(delegator).from("ProdCatalog").where("prodCatalogId", prodCatalogId).cache().queryOne(); if (prodCatalog != null) { return prodCatalog.getString("catalogName"); @@ -252,7 +253,7 @@ public class CatalogWorker { Delegator delegator = (Delegator) request.getAttribute("delegator"); try { - return delegator.findOne("ProdCatalog", UtilMisc.toMap("prodCatalogId", prodCatalogId), true); + return EntityQuery.use(delegator).from("ProdCatalog").where("prodCatalogId", prodCatalogId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up name for prodCatalog with id " + prodCatalogId, module); return null; @@ -347,7 +348,7 @@ public class CatalogWorker { Delegator delegator = (Delegator) request.getAttribute("delegator"); try { - GenericValue prodCatalog = delegator.findOne("ProdCatalog", UtilMisc.toMap("prodCatalogId", prodCatalogId), true); + GenericValue prodCatalog = EntityQuery.use(delegator).from("ProdCatalog").where("prodCatalogId", prodCatalogId).cache().queryOne(); if (prodCatalog != null) { return "Y".equals(prodCatalog.getString("useQuickAdd")); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CatalogUrlFilter.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CatalogUrlFilter.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CatalogUrlFilter.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CatalogUrlFilter.java Thu Oct 30 06:10:58 2014 @@ -43,6 +43,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; import org.ofbiz.product.product.ProductContentWrapper; import org.ofbiz.webapp.control.ContextFilter; @@ -339,7 +340,7 @@ public class CatalogUrlFilter extends Co public static String makeCategoryUrl(HttpServletRequest request, String previousCategoryId, String productCategoryId, String productId, String viewSize, String viewIndex, String viewSort, String searchString) { Delegator delegator = (Delegator) request.getAttribute("delegator"); try { - GenericValue productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", productCategoryId), true); + GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).cache().queryOne(); CategoryContentWrapper wrapper = new CategoryContentWrapper(productCategory, request); List<String> trail = CategoryWorker.getTrail(request); return makeCategoryUrl(delegator, wrapper, trail, request.getContextPath(), previousCategoryId, productCategoryId, productId, viewSize, viewIndex, viewSort, searchString); @@ -414,7 +415,7 @@ public class CatalogUrlFilter extends Co Delegator delegator = (Delegator) request.getAttribute("delegator"); String url = null; try { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); ProductContentWrapper wrapper = new ProductContentWrapper(product, request); List<String> trail = CategoryWorker.getTrail(request); url = makeProductUrl(delegator, wrapper, trail, request.getContextPath(), previousCategoryId, productCategoryId, productId); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java Thu Oct 30 06:10:58 2014 @@ -42,6 +42,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericValue; 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; @@ -129,7 +130,7 @@ public class CategoryContentWrapper impl ModelEntity categoryModel = delegator.getModelEntity("ProductCategory"); if (categoryModel.isField(candidateFieldName)) { if (productCategory == null) { - productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", productCategoryId), true); + productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).cache().queryOne(); } if (productCategory != null) { String candidateValue = productCategory.getString(candidateFieldName); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryServices.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryServices.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryServices.java Thu Oct 30 06:10:58 2014 @@ -44,6 +44,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.product.catalog.CatalogWorker; import org.ofbiz.product.product.ProductWorker; @@ -67,7 +68,7 @@ public class CategoryServices { List<GenericValue> members = null; try { - productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", categoryId), true); + productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", categoryId).cache().queryOne(); members = EntityUtil.filterByDate(productCategory.getRelated("ProductCategoryMember", null, UtilMisc.toList("sequenceNum"), true), true); if (Debug.verboseOn()) Debug.logVerbose("Category: " + productCategory + " Member Size: " + members.size() + " Members: " + members, module); } catch (GenericEntityException e) { @@ -103,7 +104,7 @@ public class CategoryServices { GenericValue productCategory; List<GenericValue> productCategoryMembers; try { - productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", categoryId), true); + productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", categoryId).cache().queryOne(); productCategoryMembers = delegator.findByAnd(entityName, UtilMisc.toMap("productCategoryId", categoryId), orderByFields, true); } catch (GenericEntityException e) { Debug.logInfo(e, "Error finding previous/next product info: " + e.toString(), module); @@ -253,7 +254,7 @@ public class CategoryServices { 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.logWarning(e.getMessage(), module); productCategory = null; Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryWorker.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryWorker.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/CategoryWorker.java Thu Oct 30 06:10:58 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.EntityUtil; import org.ofbiz.product.product.ProductWorker; import org.ofbiz.service.DispatchContext; @@ -366,7 +367,7 @@ public class CategoryWorker { UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId), null, true), true); if (UtilValidate.isEmpty(productCategoryMembers)) { //before giving up see if this is a variant product, and if so look up the virtual product and check it... - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); List<GenericValue> productAssocs = ProductWorker.getVariantVirtualAssocs(product); //this does take into account that a product could be a variant of multiple products, but this shouldn't ever really happen... if (productAssocs != null) { Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java Thu Oct 30 06:10:58 2014 @@ -31,6 +31,7 @@ import org.ofbiz.base.util.template.Free import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.product.product.ProductContentWrapper; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webapp.OfbizUrlBuilder; @@ -131,11 +132,11 @@ public class OfbizCatalogAltUrlTransform LocalDispatcher dispatcher = FreeMarkerWorker.getWrappedObject("dispatcher", env); Locale locale = (Locale) args.get("locale"); if (UtilValidate.isNotEmpty(productId)) { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); ProductContentWrapper wrapper = new ProductContentWrapper(dispatcher, product, locale, "text/html"); url = CatalogUrlFilter.makeProductUrl(delegator, wrapper, null, ((StringModel) prefix).getAsString(), previousCategoryId, productCategoryId, productId); } else { - GenericValue productCategory = delegator.findOne("ProductCategory", UtilMisc.toMap("productCategoryId", productCategoryId), false); + GenericValue productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", productCategoryId).queryOne(); CategoryContentWrapper wrapper = new CategoryContentWrapper(dispatcher, productCategory, locale, "text/html"); url = CatalogUrlFilter.makeCategoryUrl(delegator, wrapper, null, ((StringModel) prefix).getAsString(), previousCategoryId, productCategoryId, productId, viewSize, viewIndex, viewSort, searchString); } Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java Thu Oct 30 06:10:58 2014 @@ -40,6 +40,7 @@ import org.ofbiz.entity.DelegatorFactory import org.ofbiz.entity.GenericValue; 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; import org.ofbiz.service.ServiceContainer; @@ -150,7 +151,7 @@ public class ProductConfigItemContentWra ModelEntity productConfigItemModel = delegator.getModelEntity("ProductConfigItem"); if (productConfigItemModel.isField(candidateFieldName)) { if (productConfigItem == null) { - productConfigItem = delegator.findOne("ProductConfigItem", UtilMisc.toMap("configItemId", configItemId), true); + productConfigItem = EntityQuery.use(delegator).from("ProductConfigItem").where("configItemId", configItemId).cache().queryOne(); } if (productConfigItem != null) { String candidateValue = productConfigItem.getString(candidateFieldName); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java Thu Oct 30 06:10:58 2014 @@ -38,6 +38,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.service.LocalDispatcher; import org.ofbiz.service.ServiceContainer; @@ -96,7 +97,7 @@ public class ProductConfigWrapper implem } private void init(Delegator delegator, LocalDispatcher dispatcher, String productId, String productStoreId, String catalogId, String webSiteId, String currencyUomId, Locale locale, GenericValue autoUserLogin) throws Exception { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); if (product == null || !product.getString("productTypeId").equals("AGGREGATED") && !product.getString("productTypeId").equals("AGGREGATED_SERVICE")) { throw new ProductConfigWrapperException("Product " + productId + " is not an AGGREGATED product."); } @@ -624,7 +625,7 @@ public class ProductConfigWrapper implem String variantProductId = componentOptions.get(oneComponent.getString("productId")); if (UtilValidate.isNotEmpty(variantProductId)) { - oneComponentProduct = pcw.delegator.findOne("Product", UtilMisc.toMap("productId", variantProductId), false); + oneComponentProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne(); } // Get the component's price Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java Thu Oct 30 06:10:58 2014 @@ -37,6 +37,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; /** @@ -92,7 +93,7 @@ public class ParametricSearch { for (GenericValue productFeatureCatGrpAppl: productFeatureCatGrpAppls) { List<GenericValue> productFeatureGroupAppls = delegator.findByAnd("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", productFeatureCatGrpAppl.get("productFeatureGroupId")), null, true); for (GenericValue productFeatureGroupAppl: productFeatureGroupAppls) { - GenericValue productFeature = delegator.findOne("ProductFeature", UtilMisc.toMap("productFeatureId", productFeatureGroupAppl.get("productFeatureId")), true); + GenericValue productFeature = EntityQuery.use(delegator).from("ProductFeature").where("productFeatureId", productFeatureGroupAppl.get("productFeatureId")).cache().queryOne(); String productFeatureTypeId = productFeature.getString("productFeatureTypeId"); Map<String, GenericValue> featuresByType = productFeaturesByTypeMap.get(productFeatureTypeId); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java Thu Oct 30 06:10:58 2014 @@ -54,6 +54,7 @@ import org.ofbiz.base.util.string.Flexib import org.ofbiz.content.layout.LayoutWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -97,7 +98,7 @@ public class FrameImage { String frameImageName = null; try { - GenericValue contentDataResourceView = delegator.findOne("ContentDataResourceView", UtilMisc.toMap("contentId", frameContentId, "drDataResourceId", frameDataResourceId), false); + GenericValue contentDataResourceView = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", frameContentId, "drDataResourceId", frameDataResourceId).queryOne(); frameImageName = contentDataResourceView.getString("contentName"); } catch (Exception e) { Debug.logError(e, module); @@ -357,7 +358,7 @@ public class FrameImage { String frameImageName = null; try { - GenericValue contentDataResourceView = delegator.findOne("ContentDataResourceView", UtilMisc.toMap("contentId", frameContentId, "drDataResourceId", frameDataResourceId), false); + GenericValue contentDataResourceView = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", frameContentId, "drDataResourceId", frameDataResourceId).queryOne(); frameImageName = contentDataResourceView.getString("contentName"); } catch (Exception e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java Thu Oct 30 06:10:58 2014 @@ -47,6 +47,7 @@ import org.ofbiz.common.image.ImageTrans 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.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -451,7 +452,7 @@ public class ImageManagementServices { 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()); @@ -818,7 +819,7 @@ public class ImageManagementServices { } 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()); @@ -877,7 +878,7 @@ public class ImageManagementServices { } GenericValue contentAssocUp = null; try { - contentAssocUp = delegator.findOne("Content", UtilMisc.toMap("contentId", contentAssoc.get("contentIdTo")), false); + contentAssocUp = EntityQuery.use(delegator).from("Content").where("contentId", contentAssoc.get("contentIdTo")).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageUrlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageUrlServlet.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageUrlServlet.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/ImageUrlServlet.java Thu Oct 30 06:10:58 2014 @@ -36,6 +36,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; /** * ControlServlet.java - Master servlet for the web application. @@ -89,11 +90,11 @@ public class ImageUrlServlet extends Htt GenericValue content = null; try { - GenericValue contentResult = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false); + GenericValue contentResult = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); if (contentResult == null) { - content = delegator.findOne("Content", UtilMisc.toMap("contentId", sizeTagElement), false); + content = EntityQuery.use(delegator).from("Content").where("contentId", sizeTagElement).queryOne(); } else { - 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); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java Thu Oct 30 06:10:58 2014 @@ -48,6 +48,7 @@ import org.ofbiz.base.util.string.Flexib 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; import org.ofbiz.service.ServiceUtil; @@ -280,7 +281,7 @@ public class WatermarkImage{ 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/json-integration-refactoring/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java Thu Oct 30 06:10:58 2014 @@ -46,6 +46,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.model.DynamicViewEntity; import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityTypeUtil; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -73,7 +74,7 @@ public class InventoryServices { Locale locale = (Locale) context.get("locale"); try { - inventoryItem = delegator.findOne("InventoryItem", UtilMisc.toMap("inventoryItemId", inventoryItemId), false); + inventoryItem = EntityQuery.use(delegator).from("InventoryItem").where("inventoryItemId", inventoryItemId).queryOne(); } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductNotFindInventoryItemWithId", locale) + inventoryItemId); @@ -875,7 +876,7 @@ public class InventoryServices { Map<String, String> contextInput = UtilMisc.toMap("productId", productId, "facilityId", facilityId, "statusId", statusId); 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) { // TODO Auto-generated catch block e.printStackTrace(); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/price/PriceServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/price/PriceServices.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/price/PriceServices.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/price/PriceServices.java Thu Oct 30 06:10:58 2014 @@ -41,6 +41,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.product.product.ProductWorker; @@ -109,7 +110,7 @@ public class PriceServices { GenericValue productStore = null; try { // we have a productStoreId, if the corresponding ProductStore.primaryStoreGroupId is not empty, use that - 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, "Error getting product store info from the database while calculating price" + e.toString(), module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, @@ -277,7 +278,7 @@ public class PriceServices { BigDecimal curDefaultPrice = curDefaultPriceValue.getBigDecimal("price"); if (minDefaultPrice == null || curDefaultPrice.compareTo(minDefaultPrice) < 0) { // check to see if the product is discontinued for sale before considering it the lowest price - GenericValue curVariantProduct = delegator.findOne("Product", UtilMisc.toMap("productId", curVariantProductId), true); + GenericValue curVariantProduct = EntityQuery.use(delegator).from("Product").where("productId", curVariantProductId).cache().queryOne(); if (curVariantProduct != null) { Timestamp salesDiscontinuationDate = curVariantProduct.getTimestamp("salesDiscontinuationDate"); if (salesDiscontinuationDate == null || salesDiscontinuationDate.after(nowTimestamp)) { @@ -769,7 +770,7 @@ public class PriceServices { productPriceRules = FastList.newInstance(); for (String productPriceRuleId: productPriceRuleIds) { - GenericValue productPriceRule = delegator.findOne("ProductPriceRule", UtilMisc.toMap("productPriceRuleId", productPriceRuleId), true); + GenericValue productPriceRule = EntityQuery.use(delegator).from("ProductPriceRule").where("productPriceRuleId", productPriceRuleId).cache().queryOne(); if (productPriceRule == null) continue; productPriceRules.add(productPriceRule); } Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java Thu Oct 30 06:10:58 2014 @@ -43,6 +43,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericValue; 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; @@ -152,7 +153,7 @@ public class ProductContentWrapper imple String candidateFieldName = ModelUtil.dbNameToVarName(productContentTypeId); ModelEntity productModel = delegator.getModelEntity("Product"); if (product == null) { - product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); + product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); } if (UtilValidate.isEmpty(product)) { Debug.logWarning("No Product entity found for productId: " + productId, module); Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductEvents.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductEvents.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductEvents.java Thu Oct 30 06:10:58 2014 @@ -52,6 +52,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.transaction.GenericTransactionException; import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.security.Security; @@ -230,11 +231,11 @@ public class ProductEvents { Timestamp fromDate = null; try { - if (delegator.findOne("Product", UtilMisc.toMap("productId", productId), false) == null) { + if (EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne() == null) { Map<String, String> messageMap = UtilMisc.toMap("productId", productId); errMsgList.add(UtilProperties.getMessage(resource,"productevents.product_with_id_not_found", messageMap, UtilHttp.getLocale(request))); } - if (delegator.findOne("Product", UtilMisc.toMap("productId", productIdTo), false) == null) { + if (EntityQuery.use(delegator).from("Product").where("productId", productIdTo).queryOne() == null) { Map<String, String> messageMap = UtilMisc.toMap("productIdTo", productIdTo); errMsgList.add(UtilProperties.getMessage(resource,"productevents.product_To_with_id_not_found", messageMap, UtilHttp.getLocale(request))); } @@ -433,7 +434,7 @@ public class ProductEvents { if (variantProductId == null) { // only single product to update String productId = request.getParameter("productId"); - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); product.set("lastModifiedDate", nowTimestamp); product.setString("lastModifiedByUserLogin", userLogin.getString("userLoginId")); try { @@ -472,7 +473,7 @@ public class ProductEvents { int attribIdx = 0; String productId = variantProductId; do { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); try { product.set("productHeight", parseBigDecimalForEntity(request.getParameter("productHeight" + attribIdx))); product.set("productWidth", parseBigDecimalForEntity(request.getParameter("productWidth" + attribIdx))); @@ -533,8 +534,8 @@ public class ProductEvents { private static void setOrCreateProdFeature(Delegator delegator, String productId, List<GenericValue> currentProductFeatureAndAppls, String uomId, String productFeatureTypeId, BigDecimal numberSpecified) throws GenericEntityException { - GenericValue productFeatureType = delegator.findOne("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId), false); - GenericValue uom = delegator.findOne("Uom", UtilMisc.toMap("uomId", uomId), false); + GenericValue productFeatureType = EntityQuery.use(delegator).from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeId).queryOne(); + GenericValue uom = EntityQuery.use(delegator).from("Uom").where("uomId", uomId).queryOne(); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); @@ -572,7 +573,7 @@ public class ProductEvents { // if there is a productFeatureCategory with the same id as the productFeatureType, use that category. // otherwise, use a default category from the configuration - if (delegator.findOne("ProductFeatureCategory", UtilMisc.toMap("productFeatureCategoryId", productFeatureTypeId), false) == null) { + if (EntityQuery.use(delegator).from("ProductFeatureCategory").where("productFeatureCategoryId", productFeatureTypeId).queryOne() == null) { GenericValue productFeatureCategory = delegator.makeValue("ProductFeatureCategory"); productFeatureCategory.set("productFeatureCategoryId", productFeatureTypeId); productFeatureCategory.set("description", productFeatureType.get("description")); @@ -605,7 +606,7 @@ public class ProductEvents { try { boolean beganTransaction = TransactionUtil.begin(); try { - GenericValue productFeatureType = delegator.findOne("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId), false); + GenericValue productFeatureType = EntityQuery.use(delegator).from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeId).queryOne(); if (productFeatureType == null) { String errMsg = "Error: the ProductFeature Type specified was not valid and one is require to add or update variant features."; request.setAttribute("_ERROR_MESSAGE_", errMsg); @@ -616,9 +617,9 @@ public class ProductEvents { if (variantProductId != null) { // multiple products, so use a numeric suffix to get them all int attribIdx = 0; - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); do { - GenericValue variantProduct = delegator.findOne("Product", UtilMisc.toMap("productId", variantProductId), false); + GenericValue variantProduct = EntityQuery.use(delegator).from("Product").where("productId", variantProductId).queryOne(); String description = request.getParameter("description" + attribIdx); // blank means null, which means delete the feature application if ((description != null) && (description.trim().length() < 1)) { @@ -736,7 +737,7 @@ public class ProductEvents { // if there is a productFeatureCategory with the same id as the productFeatureType, use that category. // otherwise, create a category for the feature type - if (delegator.findOne("ProductFeatureCategory", UtilMisc.toMap("productFeatureCategoryId", productFeatureTypeId), false) == null) { + if (EntityQuery.use(delegator).from("ProductFeatureCategory").where("productFeatureCategoryId", productFeatureTypeId).queryOne() == null) { GenericValue productFeatureCategory = delegator.makeValue("ProductFeatureCategory"); productFeatureCategory.set("productFeatureCategoryId", productFeatureTypeId); productFeatureCategory.set("description", productFeatureType.get("description")); @@ -768,7 +769,7 @@ public class ProductEvents { String productFeatureTypeId = request.getParameter("productFeatureTypeId"); try { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), false); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne(); // get all the variants List<GenericValue> variantAssocs = product.getRelated("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), null, false); variantAssocs = EntityUtil.filterByDate(variantAssocs); @@ -1194,7 +1195,7 @@ public class ProductEvents { GenericValue userLogin = null; try { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); } catch (GenericEntityException e) { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; Modified: ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductPromoContentWrapper.java Thu Oct 30 06:10:58 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/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductSearch.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductSearch.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductSearch.java Thu Oct 30 06:10:58 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/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductServices.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductServices.java Thu Oct 30 06:10:58 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/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java Thu Oct 30 06:10:58 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/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductWorker.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/ProductWorker.java Thu Oct 30 06:10:58 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/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/VariantEvents.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/VariantEvents.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/VariantEvents.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/product/VariantEvents.java Thu Oct 30 06:10:58 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/json-integration-refactoring/applications/product/src/org/ofbiz/product/promo/PromoServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/promo/PromoServices.java?rev=1635399&r1=1635398&r2=1635399&view=diff ============================================================================== --- ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/promo/PromoServices.java (original) +++ ofbiz/branches/json-integration-refactoring/applications/product/src/org/ofbiz/product/promo/PromoServices.java Thu Oct 30 06:10:58 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);