Author: lektran Date: Fri Oct 10 20:30:30 2014 New Revision: 1630980 URL: http://svn.apache.org/r1630980 Log: Complete conversion of accounting java files from delegator to EntityQuery
Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/ideal/IdealEvents.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/period/PeriodServices.java Fri Oct 10 20:30:30 2014 @@ -28,11 +28,13 @@ import java.util.Map; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; +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.condition.EntityCondition; import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.ServiceUtil; @@ -65,27 +67,26 @@ public class PeriodServices { List<EntityCondition> findClosedConditions = UtilMisc.toList(EntityCondition.makeConditionMap("organizationPartyId", organizationPartyId), EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN_EQUAL_TO, findDate), EntityCondition.makeConditionMap("isClosed", "Y")); - if ((periodTypeId != null) && !(periodTypeId.equals(""))) { + if (UtilValidate.isNotEmpty(periodTypeId)) { // if a periodTypeId was supplied, use it findClosedConditions.add(EntityCondition.makeConditionMap("periodTypeId", periodTypeId)); } - List<GenericValue> closedTimePeriods = delegator.findList("CustomTimePeriod", EntityCondition.makeCondition(findClosedConditions), - UtilMisc.toSet("customTimePeriodId", "periodTypeId", "isClosed", "fromDate", "thruDate"), - UtilMisc.toList("thruDate DESC"), null, false); + GenericValue closedTimePeriod = EntityQuery.use(delegator).select("customTimePeriodId", "periodTypeId", "isClosed", "fromDate", "thruDate") + .where(findClosedConditions).orderBy("thruDate DESC").queryFirst(); - if ((closedTimePeriods != null) && (closedTimePeriods.size() > 0) && (closedTimePeriods.get(0).get("thruDate") != null)) { - lastClosedTimePeriod = closedTimePeriods.get(0); + if (closedTimePeriod != null && closedTimePeriod.get("thruDate") != null) { + lastClosedTimePeriod = closedTimePeriod; lastClosedDate = UtilDateTime.toTimestamp(lastClosedTimePeriod.getDate("thruDate")); } else { // uh oh, no time periods have been closed? in that case, just find the earliest beginning of a time period for this organization // and optionally, for this period type Map<String, String> findParams = UtilMisc.toMap("organizationPartyId", organizationPartyId); - if ((periodTypeId != null) && !(periodTypeId.equals(""))) { + if (UtilValidate.isNotEmpty(periodTypeId)) { findParams.put("periodTypeId", periodTypeId); } - List<GenericValue> timePeriods = delegator.findByAnd("CustomTimePeriod", findParams, UtilMisc.toList("fromDate ASC"), false); - if ((timePeriods != null) && (timePeriods.size() > 0) && (timePeriods.get(0).get("fromDate") != null)) { - lastClosedDate = UtilDateTime.toTimestamp(timePeriods.get(0).getDate("fromDate")); + GenericValue timePeriod = EntityQuery.use(delegator).from("CustomTimePeriod").where(findParams).orderBy("fromDate ASC").queryFirst(); + if (timePeriod != null && timePeriod.get("fromDate") != null) { + lastClosedDate = UtilDateTime.toTimestamp(timePeriod.getDate("fromDate")); } else { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "AccountingPeriodCannotGet", locale)); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java Fri Oct 10 20:30:30 2014 @@ -42,7 +42,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.EntityUtil; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.party.contact.ContactMechWorker; import org.ofbiz.product.product.ProductWorker; import org.ofbiz.service.DispatchContext; @@ -82,8 +82,8 @@ public class TaxAuthorityServices { if (shippingPrice != null) priceWithTax = priceWithTax.add(shippingPrice); try { - GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true); - GenericValue productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), true); + GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); + GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).cache().queryOne(); if (productStore == null) { throw new IllegalArgumentException("Could not find ProductStore with ID [" + productStoreId + "] for tax calculation"); } @@ -91,10 +91,11 @@ public class TaxAuthorityServices { if ("Y".equals(productStore.getString("showPricesWithVatTax"))) { Set<GenericValue> taxAuthoritySet = FastSet.newInstance(); if (productStore.get("vatTaxAuthPartyId") == null) { - List<GenericValue> taxAuthorityRawList = delegator.findList("TaxAuthority", EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.EQUALS, productStore.get("vatTaxAuthGeoId")), null, null, null, true); + List<GenericValue> taxAuthorityRawList = EntityQuery.use(delegator).from("TaxAuthority") + .where("taxAuthGeoId", productStore.get("vatTaxAuthGeoId")).cache().queryList(); taxAuthoritySet.addAll(taxAuthorityRawList); } else { - GenericValue taxAuthority = delegator.findOne("TaxAuthority", UtilMisc.toMap("taxAuthGeoId", productStore.get("vatTaxAuthGeoId"), "taxAuthPartyId", productStore.get("vatTaxAuthPartyId")), true); + GenericValue taxAuthority = EntityQuery.use(delegator).from("TaxAuthority").where("taxAuthGeoId", productStore.get("vatTaxAuthGeoId"), "taxAuthPartyId", productStore.get("vatTaxAuthPartyId")).cache().queryOne(); taxAuthoritySet.add(taxAuthority); } @@ -154,10 +155,10 @@ public class TaxAuthorityServices { GenericValue facility = null; try { if (productStoreId != null) { - productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), false); + productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne(); } if (facilityId != null) { - facility = delegator.findOne("Facility", UtilMisc.toMap("facilityId", facilityId), false); + facility = EntityQuery.use(delegator).from("Facility").where("facilityId", facilityId).queryOne(); } } catch (GenericEntityException e) { Debug.logError(e, "Data error getting tax settings: " + e.toString(), module); @@ -173,8 +174,7 @@ public class TaxAuthorityServices { try { GenericValue facilityContactMech = ContactMechWorker.getFacilityContactMechByPurpose(delegator, facilityId, UtilMisc.toList("SHIP_ORIG_LOCATION", "PRIMARY_LOCATION")); if (facilityContactMech != null) { - shippingAddress = delegator.findOne("PostalAddress", - UtilMisc.toMap("contactMechId", facilityContactMech.getString("contactMechId")), false); + shippingAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", facilityContactMech.get("contactMechId")).queryOne(); } } catch (GenericEntityException e) { Debug.logError(e, "Data error getting tax settings: " + e.toString(), module); @@ -258,7 +258,8 @@ public class TaxAuthorityServices { geoIdByTypeMap = GeoWorker.expandGeoRegionDeep(geoIdByTypeMap, delegator); //Debug.logInfo("Tax calc geoIdByTypeMap after expand:" + geoIdByTypeMap, module); - List<GenericValue> taxAuthorityRawList = delegator.findList("TaxAuthority", EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.IN, geoIdByTypeMap.values()), null, null, null, true); + List<GenericValue> taxAuthorityRawList = EntityQuery.use(delegator) + .from("TaxAuthority").where(EntityCondition.makeCondition("taxAuthGeoId", EntityOperator.IN, geoIdByTypeMap.values())).cache().queryList(); taxAuthoritySet.addAll(taxAuthorityRawList); //Debug.logInfo("Tax calc taxAuthoritySet after expand:" + taxAuthoritySet, module); } @@ -325,8 +326,9 @@ public class TaxAuthorityServices { } else { productIdCond = EntityCondition.makeCondition("productId", EntityOperator.EQUALS, product.getString("productId")); } - List<GenericValue> pcmList = delegator.findList("ProductCategoryMember", productIdCond, UtilMisc.toSet("productCategoryId", "fromDate", "thruDate"), null, null, true); - pcmList = EntityUtil.filterByDate(pcmList, true); + List<GenericValue> pcmList = EntityQuery.use(delegator).select("productCategoryId", "fromDate", "thruDate") + .from("ProductCategoryMember") + .where(productIdCond).cache().filterByDate().queryList(); for (GenericValue pcm : pcmList) { productCategoryIdSet.add(pcm.getString("productCategoryId")); } @@ -376,20 +378,17 @@ public class TaxAuthorityServices { mainExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("minPurchase", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("minPurchase", EntityOperator.LESS_THAN_EQUAL_TO, itemAmount))); EntityCondition mainCondition = EntityCondition.makeCondition(mainExprs, EntityOperator.AND); - // create the orderby clause - List<String> orderList = UtilMisc.<String>toList("minItemPrice", "minPurchase", "fromDate"); - // finally ready... do the rate query - List<GenericValue> lookupList = delegator.findList("TaxAuthorityRateProduct", mainCondition, null, orderList, null, false); - List<GenericValue> filteredList = EntityUtil.filterByDate(lookupList, true); + List<GenericValue> lookupList = EntityQuery.use(delegator).from("TaxAuthorityRateProduct") + .where(mainCondition).orderBy("minItemPrice", "minPurchase", "fromDate").filterByDate().queryList(); - if (filteredList.size() == 0) { + if (lookupList.size() == 0) { Debug.logWarning("In TaxAuthority Product Rate no records were found for condition:" + mainCondition.toString(), module); return adjustments; } // find the right entry(s) based on purchase amount - for (GenericValue taxAuthorityRateProduct : filteredList) { + for (GenericValue taxAuthorityRateProduct : lookupList) { BigDecimal taxRate = taxAuthorityRateProduct.get("taxPercentage") != null ? taxAuthorityRateProduct.getBigDecimal("taxPercentage") : ZERO_BASE; BigDecimal taxable = ZERO_BASE; @@ -415,7 +414,8 @@ public class TaxAuthorityServices { String taxAuthPartyId = taxAuthorityRateProduct.getString("taxAuthPartyId"); // get glAccountId from TaxAuthorityGlAccount entity using the payToPartyId as the organizationPartyId - GenericValue taxAuthorityGlAccount = delegator.findOne("TaxAuthorityGlAccount", UtilMisc.toMap("taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId, "organizationPartyId", payToPartyId), false); + GenericValue taxAuthorityGlAccount = EntityQuery.use(delegator).from("TaxAuthorityGlAccount") + .where("taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId, "organizationPartyId", payToPartyId).queryOne(); String taxAuthGlAccountId = null; if (taxAuthorityGlAccount != null) { taxAuthGlAccountId = taxAuthorityGlAccount.getString("glAccountId"); @@ -426,15 +426,13 @@ public class TaxAuthorityServices { GenericValue productPrice = null; if (product != null && taxAuthPartyId != null && taxAuthGeoId != null) { // find a ProductPrice for the productId and taxAuth* values, and see if it has a priceWithTax value - Map<String, String> priceFindMap = UtilMisc.toMap("productId", product.getString("productId"), - "taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId, - "productPricePurposeId", "PURCHASE"); - List<GenericValue> productPriceList = delegator.findByAnd("ProductPrice", priceFindMap, UtilMisc.toList("-fromDate"), false); - productPriceList = EntityUtil.filterByDate(productPriceList, true); - productPrice = (productPriceList != null && productPriceList.size() > 0) ? productPriceList.get(0): null; + productPrice = EntityQuery.use(delegator).from("ProductPrice") + .where("productId", product.get("productId"), + "taxAuthPartyId", taxAuthPartyId, "taxAuthGeoId", taxAuthGeoId, + "productPricePurposeId", "PURCHASE") + .orderBy("-fromDate").filterByDate().queryFirst(); //Debug.logInfo("=================== productId=" + product.getString("productId"), module); //Debug.logInfo("=================== productPrice=" + productPrice, module); - } GenericValue taxAdjValue = delegator.makeValue("OrderAdjustment"); @@ -468,7 +466,10 @@ public class TaxAuthorityServices { // look for PartyRelationship with partyRelationshipTypeId=GROUP_ROLLUP, the partyIdTo is the group member, so the partyIdFrom is the groupPartyId Set<String> billToPartyIdSet = FastSet.newInstance(); billToPartyIdSet.add(billToPartyId); - List<GenericValue> partyRelationshipList = EntityUtil.filterByDate(delegator.findByAnd("PartyRelationship", UtilMisc.toMap("partyIdTo", billToPartyId, "partyRelationshipTypeId", "GROUP_ROLLUP"), null, true), true); + List<GenericValue> partyRelationshipList = EntityQuery.use(delegator).from("PartyRelationship") + .where("partyIdTo", billToPartyId, "partyRelationshipTypeId", "GROUP_ROLLUP") + .cache().filterByDate().queryList(); + for (GenericValue partyRelationship : partyRelationshipList) { billToPartyIdSet.add(partyRelationship.getString("partyIdFrom")); } @@ -543,11 +544,10 @@ public class TaxAuthorityServices { ptiConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, nowTimestamp))); EntityCondition ptiCondition = EntityCondition.makeCondition(ptiConditionList, EntityOperator.AND); // sort by -fromDate to get the newest (largest) first, just in case there is more than one, we only want the most recent valid one, should only be one per jurisdiction... - List<GenericValue> partyTaxInfos = delegator.findList("PartyTaxAuthInfo", ptiCondition, null, UtilMisc.toList("-fromDate"), null, false); + GenericValue partyTaxInfo = EntityQuery.use(delegator).from("PartyTaxAuthInfo").where(ptiCondition).orderBy("-fromDate").queryFirst(); boolean foundExemption = false; - if (partyTaxInfos.size() > 0) { - GenericValue partyTaxInfo = partyTaxInfos.get(0); + if (partyTaxInfo != null) { adjValue.set("customerReferenceId", partyTaxInfo.get("partyTaxId")); if ("Y".equals(partyTaxInfo.getString("isExempt"))) { adjValue.set("amount", BigDecimal.ZERO); @@ -559,11 +559,9 @@ public class TaxAuthorityServices { // if no exceptions were found for the current; try the parent if (!foundExemption) { // try the "parent" TaxAuthority - List<GenericValue> taxAuthorityAssocList = delegator.findByAnd("TaxAuthorityAssoc", - UtilMisc.toMap("toTaxAuthGeoId", taxAuthGeoId, "toTaxAuthPartyId", taxAuthPartyId, "taxAuthorityAssocTypeId", "EXEMPT_INHER"), - UtilMisc.toList("-fromDate"), true); - taxAuthorityAssocList = EntityUtil.filterByDate(taxAuthorityAssocList, true); - GenericValue taxAuthorityAssoc = EntityUtil.getFirst(taxAuthorityAssocList); + GenericValue taxAuthorityAssoc = EntityQuery.use(delegator).from("TaxAuthorityAssoc") + .where("toTaxAuthGeoId", taxAuthGeoId, "toTaxAuthPartyId", taxAuthPartyId, "taxAuthorityAssocTypeId", "EXEMPT_INHER") + .orderBy("-fromDate").filterByDate().queryFirst(); // Debug.logInfo("Parent assoc to " + taxAuthGeoId + " : " + taxAuthorityAssoc, module); if (taxAuthorityAssoc != null) { handlePartyTaxExempt(adjValue, billToPartyIdSet, taxAuthorityAssoc.getString("taxAuthGeoId"), taxAuthorityAssoc.getString("taxAuthPartyId"), taxAmount, nowTimestamp, delegator); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java Fri Oct 10 20:30:30 2014 @@ -25,6 +25,7 @@ import java.util.Map; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.service.ServiceUtil; import org.ofbiz.service.testtools.OFBizTestCase; @@ -38,7 +39,7 @@ public class FinAccountTests extends OFB } public void testFinAccountOperations() throws Exception { - GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); Map<String, Object> ctx = new HashMap<String, Object>(); ctx.put("finAccountId", "TESTACCOUNT1"); ctx.put("finAccountName", "Test Financial Account"); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java Fri Oct 10 20:30:30 2014 @@ -40,6 +40,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.DispatchContext; import org.ofbiz.service.ModelService; import org.ofbiz.service.ServiceUtil; @@ -790,7 +791,7 @@ public class AIMPaymentServices { String returnValue = ""; if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue payflowPro = delegator.findOne("PaymentGatewayAuthorizeNet", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + GenericValue payflowPro = EntityQuery.use(delegator).from("PaymentGatewayAuthorizeNet").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(payflowPro)) { Object payflowProField = payflowPro.get(paymentGatewayConfigParameterName); if (payflowProField != null) { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/cybersource/IcsPaymentServices.java Fri Oct 10 20:30:30 2014 @@ -673,7 +673,7 @@ public class IcsPaymentServices { String returnValue = ""; if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue cyberSource = delegator.findOne("PaymentGatewayCyberSource", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + GenericValue cyberSource = EntityQuery.use(delegator).from("PaymentGatewayCyberSource").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(cyberSource)) { Object cyberSourceField = cyberSource.get(paymentGatewayConfigParameterName); if (cyberSourceField != null) { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/eway/EwayServices.java Fri Oct 10 20:30:30 2014 @@ -30,6 +30,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.DispatchContext; import org.ofbiz.service.ServiceUtil; @@ -267,8 +268,9 @@ public class EwayServices { String returnValue = ""; if (UtilValidate.isNotEmpty(cfgId)) { try { - GenericValue gv = delegator.findOne("PaymentGatewayEway", true, "paymentGatewayConfigId", cfgId); - if (UtilValidate.isNotEmpty(gv)) { + GenericValue gv = EntityQuery.use(delegator).from("PaymentGatewayEway") + .where("paymantGatewayConfigId", cfgId).cache().queryOne(); + if (gv != null) { Object field = gv.get(cfgParamName); if (field != null) { returnValue = field.toString().trim(); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/gosoftware/RitaServices.java Fri Oct 10 20:30:30 2014 @@ -38,6 +38,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.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -364,9 +365,8 @@ public class RitaServices { Timestamp orderDate = orderHeader.getTimestamp("orderDate"); GenericValue terminalState = null; try { - List<GenericValue> states = delegator.findByAnd("PosTerminalState", UtilMisc.toMap("posTerminalId", terminalId), null, false); - states = EntityUtil.filterByDate(states, UtilDateTime.nowTimestamp(), "openedDate", "closedDate", true); - terminalState = EntityUtil.getFirst(states); + terminalState = EntityQuery.use(delegator).from("PosTerminalState") + .where("posTerminalId", terminalId).filterByDate("openedDate", "closedDate").queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -405,7 +405,7 @@ public class RitaServices { GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference"); GenericValue creditCard = (GenericValue) context.get("creditCard"); if (creditCard == null) { - creditCard = delegator.findOne("CreditCard", UtilMisc.toMap("paymentMethodId", orderPaymentPreference.getString("paymentMethodId")), false); + creditCard = EntityQuery.use(delegator).from("CreditCard").where("paymentMethodId", orderPaymentPreference.getString("paymentMethodId")).queryOne(); } if (creditCard != null) { List<String> expDateList = StringUtil.split(creditCard.getString("expireDate"), "/"); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/ideal/IdealEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/ideal/IdealEvents.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/ideal/IdealEvents.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/ideal/IdealEvents.java Fri Oct 10 20:30:30 2014 @@ -48,6 +48,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 org.ofbiz.order.order.OrderChangeHelper; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.GenericServiceException; @@ -83,8 +84,8 @@ public class IdealEvents { GenericValue orderHeader = null; List<GenericValue> orderItemList = null; try { - orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); - orderItemList = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId)); + orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); + orderItemList = EntityQuery.use(delegator).from("OrderItem").where("orderId", orderId).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get the order header for order: " + orderId, module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "idealEvents.problemsGettingOrderHeader", locale)); @@ -225,7 +226,7 @@ public class IdealEvents { if (userLogin == null) { String userLoginId = "system"; try { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get UserLogin for: " + userLoginId + "; cannot continue", module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "idealEvents.problemsGettingAuthenticationUser", locale)); @@ -236,7 +237,7 @@ public class IdealEvents { GenericValue orderHeader = null; if (UtilValidate.isNotEmpty(orderId)) { try { - orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); + orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get the order header for order: " + orderId, module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "idealEvents.problemsGettingOrderHeader", locale)); @@ -311,8 +312,8 @@ public class IdealEvents { Debug.logVerbose("Setting payment prefrences..", module); List <GenericValue> paymentPrefs = null; try { - Map <String, String> paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED"); - paymentPrefs = delegator.findByAnd("OrderPaymentPreference", paymentFields); + paymentPrefs = EntityQuery.use(delegator).from("OrderPaymentPreference") + .where("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED").queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module); return false; @@ -374,7 +375,7 @@ public class IdealEvents { GenericValue userLoginId = null; try { - userLoginId = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false); + userLoginId = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); } catch (GenericEntityException e) { return false; } @@ -405,7 +406,7 @@ public class IdealEvents { String returnValue = ""; if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue ideal = delegator.findOne("PaymentGatewayiDEAL", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + GenericValue ideal = EntityQuery.use(delegator).from("PaymentGatewayiDEAL").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(ideal)) { Object idealField = ideal.get(paymentGatewayConfigParameterName); if (idealField != null) { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/orbital/OrbitalPaymentServices.java Fri Oct 10 20:30:30 2014 @@ -34,6 +34,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.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.ModelService; @@ -291,7 +292,7 @@ public class OrbitalPaymentServices { String returnValue = ""; if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue paymentGatewayOrbital = delegator.findOne("PaymentGatewayOrbital", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + GenericValue paymentGatewayOrbital = EntityQuery.use(delegator).from("PaymentGatewayOrbital").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(paymentGatewayOrbital)) { Object paymentGatewayOrbitalField = paymentGatewayOrbital.get(paymentGatewayConfigParameterName); if (UtilValidate.isNotEmpty(paymentGatewayOrbitalField)) { @@ -630,13 +631,12 @@ public class OrbitalPaymentServices { private static String getShippingRefForOrder(String orderId, Delegator delegator) { String shippingRef = ""; try { - GenericValue orderHeader = delegator.findOne("OrderHeader", false, UtilMisc.toMap("orderId", orderId)); - GenericValue trackingCodeOrder = EntityUtil.getFirst(orderHeader.getRelated("TrackingCodeOrder", null, null, false)); + GenericValue trackingCodeOrder = EntityQuery.use(delegator).from("TrackingCodeOrder").where("orderId", orderId).queryFirst(); GenericValue trackingCode = null; - if (UtilValidate.isNotEmpty(trackingCodeOrder)) { + if (trackingCodeOrder != null) { trackingCode = trackingCodeOrder.getRelatedOne("TrackingCode", false); } - if (UtilValidate.isNotEmpty(trackingCode) && UtilValidate.isNotEmpty(trackingCode.getString("description"))) { + if (trackingCode != null && UtilValidate.isNotEmpty(trackingCode.getString("description"))) { // get tracking code description and provide it into shipping reference. shippingRef = trackingCode.getString("trackingCodeId") + "====" + trackingCode.getString("description"); } else { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalEvents.java Fri Oct 10 20:30:30 2014 @@ -48,6 +48,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 org.ofbiz.order.order.OrderChangeHelper; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.GenericServiceException; @@ -74,7 +75,7 @@ public class PayPalEvents { // get the order header GenericValue orderHeader = null; try { - orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); + orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get the order header for order: " + orderId, module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingOrderHeader", locale)); @@ -260,7 +261,7 @@ public class PayPalEvents { // get the system user GenericValue userLogin = null; try { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), false); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get UserLogin for: system; cannot continue", module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingAuthenticationUser", locale)); @@ -274,7 +275,7 @@ public class PayPalEvents { GenericValue orderHeader = null; if (UtilValidate.isNotEmpty(orderId)) { try { - orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); + orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get the order header for order: " + orderId, module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "payPalEvents.problemsGettingOrderHeader", locale)); @@ -405,8 +406,7 @@ public class PayPalEvents { Debug.logVerbose("Setting payment prefrences..", module); List <GenericValue> paymentPrefs = null; try { - Map <String, String> paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED"); - paymentPrefs = delegator.findByAnd("OrderPaymentPreference", paymentFields, null, false); + paymentPrefs = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED").queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module); return false; @@ -509,11 +509,11 @@ public class PayPalEvents { String returnValue = ""; if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue payPal = delegator.findOne("PaymentGatewayPayPal", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); - if (UtilValidate.isNotEmpty(payPal)) { - Object payPalField = payPal.get(paymentGatewayConfigParameterName); + GenericValue payPal = EntityQuery.use(delegator).from("PaymentGatewayPayPal").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); + if (payPal != null) { + String payPalField = payPal.getString(paymentGatewayConfigParameterName); if (payPalField != null) { - returnValue = payPalField.toString().trim(); + returnValue = payPalField.trim(); } } } catch (GenericEntityException e) { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/paypal/PayPalServices.java Fri Oct 10 20:30:30 2014 @@ -54,6 +54,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityFunction; import org.ofbiz.entity.transaction.GenericTransactionException; import org.ofbiz.entity.transaction.TransactionUtil; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.order.order.OrderReadHelper; import org.ofbiz.order.shoppingcart.CartItemModifyException; @@ -205,7 +206,7 @@ public class PayPalServices { inMap.put("postalCode", paramMap.get("SHIPTOZIP")); try { - GenericValue userLogin = delegator.findOne("UserLogin", true, UtilMisc.toMap("userLoginId", "system")); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne(); inMap.put("userLogin", userLogin); } catch (GenericEntityException e) { Debug.logError(e, module); @@ -286,9 +287,9 @@ public class PayPalServices { // Remove the temporary ship address try { - GenericValue postalAddress = delegator.findOne("PostalAddress", false, UtilMisc.toMap("contactMechId", contactMechId)); + GenericValue postalAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", contactMechId).queryOne(); postalAddress.remove(); - GenericValue contactMech = delegator.findOne("ContactMech", false, UtilMisc.toMap("contactMechId", contactMechId)); + GenericValue contactMech = EntityQuery.use(delegator).from("ContactMech").where("contactMechId", contactMechId).queryOne(); contactMech.remove(); } catch (GenericEntityException e) { Debug.logError(e, module); @@ -383,7 +384,7 @@ public class PayPalServices { if (cart.getUserLogin() == null) { try { - GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "anonymous"); + GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "anonymous").queryOne(); try { cart.setUserLogin(userLogin, dispatcher); } catch (CartItemModifyException e) { @@ -406,7 +407,7 @@ public class PayPalServices { if (partyId != null) { GenericValue party = null; try { - party = delegator.findOne("Party", false, "partyId", partyId); + party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -449,22 +450,23 @@ public class PayPalServices { if (!newParty) { EntityCondition cond = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition(UtilMisc.toMap("partyId", partyId, "contactMechTypeId", "EMAIL_ADDRESS")), - EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityComparisonOperator.EQUALS, EntityFunction.UPPER(emailAddress)), - EntityUtil.getFilterByDateExpr() + EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityComparisonOperator.EQUALS, EntityFunction.UPPER(emailAddress)) )); try { - GenericValue matchingEmail = EntityUtil.getFirst(delegator.findList("PartyAndContactMech", cond, null, UtilMisc.toList("fromDate"), null, false)); + GenericValue matchingEmail = EntityQuery.use(delegator).from("PartyAndContactMech").where(cond).orderBy("fromDate").filterByDate().queryFirst(); if (matchingEmail != null) { emailContactMechId = matchingEmail.getString("contactMechId"); } else { // No email found so we'll need to create one but first check if it should be PRIMARY or just BILLING - cond = EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition(UtilMisc.toMap("partyId", partyId, "contactMechTypeId", "EMAIL_ADDRESS", "contactMechPurposeTypeId", "PRIMARY_EMAIL")), - EntityCondition.makeConditionDate("contactFromDate", "contactThruDate"), - EntityCondition.makeConditionDate("purposeFromDate", "purposeThruDate"))); - List<GenericValue> primaryEmails = delegator.findList("PartyContactWithPurpose", cond, null, null, null, false); - if (UtilValidate.isNotEmpty(primaryEmails)) emailContactPurposeTypeId = "BILLING_EMAIL"; + long primaryEmails = EntityQuery.use(delegator) + .from("PartyContactWithPurpose") + .where("partyId", partyId, + "contactMechTypeId", "EMAIL_ADDRESS", + "contactMechPurposeTypeId", "PRIMARY_EMAIL") + .filterByDate("contactFromDate", "contactThruDate", "purposeFromDate", "purposeThruDate") + .queryCount(); + if (primaryEmails > 0) emailContactPurposeTypeId = "BILLING_EMAIL"; } } catch (GenericEntityException e) { Debug.logError(e, module); @@ -535,18 +537,16 @@ public class PayPalServices { EntityCondition cond = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition(postalMap), EntityCondition.makeCondition(UtilMisc.toMap("attnName", null, "directions", null, "postalCodeExt", null,"postalCodeGeoId", null)), - EntityUtil.getFilterByDateExpr(), EntityCondition.makeCondition("partyId", partyId) )); try { - GenericValue postalMatch = EntityUtil.getFirst(delegator.findList("PartyAndPostalAddress", cond, null, UtilMisc.toList("fromDate"), null, false)); + GenericValue postalMatch = EntityQuery.use(delegator).from("PartyAndPostalAddress") + .where(cond).orderBy("fromDate").filterByDate().queryFirst(); if (postalMatch != null) { postalContactId = postalMatch.getString("contactMechId"); - EntityCondition purposeCond = EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition(UtilMisc.toMap("partyId", partyId, "contactMechId", postalContactId)), - EntityUtil.getFilterByDateExpr() - )); - List<GenericValue> postalPurposes = delegator.findList("PartyContactMechPurpose", purposeCond, null, null, null, false); + List<GenericValue> postalPurposes = EntityQuery.use(delegator).from("PartyContactMechPurpose") + .where("partyId", partyId, "contactMechId", postalContactId) + .filterByDate().queryList(); List<Object> purposeStrings = EntityUtil.getFieldListFromEntityList(postalPurposes, "contactMechPurposeTypeId", false); if (UtilValidate.isNotEmpty(purposeStrings) && purposeStrings.contains("SHIPPING_LOCATION")) { needsShippingPurpose = false; @@ -601,10 +601,13 @@ public class PayPalServices { cart.setAllCarrierPartyId(shipMethodSplit[0]); String shippingMethodTypeDesc = StringUtils.join(shipMethodSplit, " - ", 1, shipMethodSplit.length); try { - EntityCondition cond = EntityCondition.makeCondition( - UtilMisc.toMap("productStoreId", cart.getProductStoreId(), "partyId", shipMethodSplit[0], "roleTypeId", "CARRIER", "description", shippingMethodTypeDesc) - ); - GenericValue shipmentMethod = EntityUtil.getFirst(delegator.findList("ProductStoreShipmentMethView", cond, null, null, null, false)); + GenericValue shipmentMethod = EntityQuery.use(delegator) + .from("ProductStoreShipmentMethView") + .where("productStoreId", cart.getProductStoreId(), + "partyId", shipMethodSplit[0], + "roleTypeId", "CARRIER", + "description", shippingMethodTypeDesc) + .queryFirst(); cart.setAllShipmentMethodTypeId(shipmentMethod.getString("shipmentMethodTypeId")); } catch (GenericEntityException e1) { Debug.logError(e1, module); @@ -983,7 +986,7 @@ public class PayPalServices { } if (paymentGatewayConfigId != null) { try { - payPalGatewayConfig = delegator.findOne("PaymentGatewayPayPal", true, "paymentGatewayConfigId", paymentGatewayConfigId); + payPalGatewayConfig = EntityQuery.use(delegator).from("PaymentGatewayPayPal").where("paymentGatewayConfigId", paymentGatewayConfigId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -1019,8 +1022,8 @@ public class PayPalServices { private static String getCountryGeoIdFromGeoCode(String geoCode, Delegator delegator) { String geoId = null; try { - EntityCondition cond =EntityCondition.makeCondition(UtilMisc.toMap("geoTypeId", "COUNTRY", "geoCode", geoCode)); - GenericValue countryGeo = EntityUtil.getFirst(delegator.findList("Geo", cond, null, null, null, true)); + GenericValue countryGeo = EntityQuery.use(delegator).from("Geo") + .where("geoTypeId", "COUNTRY", "geoCode", geoCode).cache().queryFirst(); if (countryGeo != null) { geoId = countryGeo.getString("geoId"); } @@ -1045,7 +1048,8 @@ public class PayPalServices { EntityCondition cond = EntityCondition.makeCondition(conditionList); GenericValue geoAssocAndGeoTo = null; try { - geoAssocAndGeoTo = EntityUtil.getFirst(delegator.findList("GeoAssocAndGeoTo", cond, null, null, null, true)); + geoAssocAndGeoTo = EntityQuery.use(delegator).from("GeoAssocAndGeoTo").where(cond).cache().queryFirst(); + } catch (GenericEntityException e) { Debug.logError(e, module); } Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java Fri Oct 10 20:30:30 2014 @@ -303,7 +303,7 @@ public class SagePayPaymentServices { Debug.logInfo("SagePay ccRefund captureTransaction : " + captureTransaction, module); GenericValue creditCard = null; try { - creditCard = delegator.getRelatedOne("CreditCard", orderPaymentPreference, false); + creditCard = orderPaymentPreference.getRelatedOne("CreditCard", false); } catch (GenericEntityException e) { Debug.logError(e, "Error getting CreditCard for OrderPaymentPreference : " + orderPaymentPreference, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "AccountingPaymentUnableToGetCCInfo", locale) + " " + orderPaymentPreference); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayServices.java Fri Oct 10 20:30:30 2014 @@ -38,6 +38,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.DispatchContext; import org.ofbiz.service.ModelService; import org.ofbiz.service.ServiceUtil; @@ -55,7 +56,7 @@ public class SagePayServices if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue sagePay = delegator.findOne("PaymentGatewaySagePay", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + GenericValue sagePay = EntityQuery.use(delegator).from("PaymentGatewaySagePay").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(sagePay)) { Map<String, Object> tmp = sagePay.getAllFields(); Set<String> keys = tmp.keySet(); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayPaymentServices.java Fri Oct 10 20:30:30 2014 @@ -32,6 +32,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.DispatchContext; import org.ofbiz.service.ServiceUtil; @@ -298,17 +299,13 @@ public class SecurePayPaymentServices { "AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale)); } - List<GenericValue> paymentGatewayResponse = null; String referenceNum = null; try { - paymentGatewayResponse = delegator.findByAnd("PaymentGatewayResponse", UtilMisc.toMap( - "orderPaymentPreferenceId", authTransaction.getString("orderPaymentPreferenceId"), - "paymentServiceTypeEnumId", "PRDS_PAY_CAPTURE")); - if (paymentGatewayResponse.size() > 0) { - referenceNum = (String) paymentGatewayResponse.get(0).get("referenceNum"); - } else { - referenceNum = authTransaction.getString("referenceNum"); - } + GenericValue paymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse") + .where("orderPaymentPreferenceId", authTransaction.get("orderPaymentPreferenceId"), + "paymentServiceTypeEnumId", "PRDS_PAY_CAPTURE") + .queryFirst(); + referenceNum = paymentGatewayResponse != null ? paymentGatewayResponse.get("referenceNum") : authTransaction.getString("referenceNum"); } catch (GenericEntityException e) { e.printStackTrace(); } @@ -483,7 +480,7 @@ public class SecurePayPaymentServices { String returnValue = ""; if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue securePay = delegator.findOne("PaymentGatewaySecurePay", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + GenericValue securePay = EntityQuery.use(delegator).from("PaymentGatewaySecurePay").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(securePay)) { Object securePayField = securePay.get(paymentGatewayConfigParameterName); if (securePayField != null) { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java Fri Oct 10 20:30:30 2014 @@ -104,7 +104,7 @@ public class SecurePayServiceTest extend "maxAmount", new BigDecimal("200.00"), "statusId", "PAYMENT_AUTHORIZED")); - GenericValue checkOrderPaymentPreference = delegator.findOne("OrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", "testOrder1000_01"), false); + GenericValue checkOrderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", "testOrder1000_01").queryOne(); if (UtilValidate.isEmpty(checkOrderPaymentPreference)) { orderPaymentPreference.create(); } @@ -151,7 +151,7 @@ public class SecurePayServiceTest extend "paymentServiceTypeEnumId", "PRDS_PAY_AUTH", "currencyUomId", "AUD" )); - GenericValue checkPaymentGatewayResponse = delegator.findOne("PaymentGatewayResponse", UtilMisc.toMap("paymentGatewayResponseId", "testOrder1000_01"), false); + GenericValue checkPaymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne(); if (UtilValidate.isEmpty(checkPaymentGatewayResponse)) { paymentGatewayResponse.create(); } @@ -163,7 +163,7 @@ public class SecurePayServiceTest extend public void testdoCapture() throws Exception { Debug.logInfo("=====[testdoCapture] starting....", module); - GenericValue paymentGatewayResponse = delegator.findOne("PaymentGatewayResponse", UtilMisc.toMap("paymentGatewayResponseId", "testOrder1000_01"), false); + GenericValue paymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne(); try { Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap( "paymentConfig", configFile, @@ -185,7 +185,7 @@ public class SecurePayServiceTest extend TestCase.fail("Returned messages:" + result.get("internalRespMsgs")); } else { String captureRefNum = (String) result.get("captureRefNum"); - GenericValue checkPaymentGatewayResponse = delegator.findOne("PaymentGatewayResponse", UtilMisc.toMap("paymentGatewayResponseId", "testOrder1000_01"), false); + GenericValue checkPaymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne(); checkPaymentGatewayResponse.set("referenceNum", captureRefNum); checkPaymentGatewayResponse.store(); Debug.logInfo("[testdoCapture] Result from SecurePay: " + result, module); Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkApi.java Fri Oct 10 20:30:30 2014 @@ -66,6 +66,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; /** * ValueLinkApi - Implementation of ValueLink Encryption & Transport @@ -739,7 +740,7 @@ public class ValueLinkApi { public GenericValue getGenericValue() { GenericValue value = null; try { - value = delegator.findOne("ValueLinkKey", UtilMisc.toMap("merchantId", merchantId), true); + value = EntityQuery.use(delegator).from("ValueLinkKey").where("merchantId", merchantId).cache().queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/valuelink/ValueLinkServices.java Fri Oct 10 20:30:30 2014 @@ -33,10 +33,10 @@ import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.base.util.collections.ResourceBundleMapWrapper; 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.entity.util.EntityUtilProperties; import org.ofbiz.order.order.OrderReadHelper; @@ -1099,11 +1099,11 @@ public class ValueLinkServices { // get the productFeature type TYPE (VL promo code) GenericValue typeFeature = null; try { - Map<String, Object> fields = UtilMisc.toMap("productId", product.get("productId"), "productFeatureTypeId", "TYPE"); - List<String> order = UtilMisc.toList("-fromDate"); - List<GenericValue> featureAppls = delegator.findByAnd("ProductFeatureAndAppl", fields, order, true); - featureAppls = EntityUtil.filterByDate(featureAppls); - typeFeature = EntityUtil.getFirst(featureAppls); + typeFeature = EntityQuery.use(delegator) + .from("ProductFeatureAndAppl") + .where("productId", product.get("productId"), + "productFeatureTypeId", "TYPE") + .orderBy("-fromDate").filterByDate().queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, @@ -1128,12 +1128,11 @@ public class ValueLinkServices { // get the survey response GenericValue surveyResponse = null; try { - Map<String, Object> fields = UtilMisc.<String, Object>toMap("orderId", orderId, - "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId); - List<String> order = UtilMisc.toList("-responseDate"); - List<GenericValue> responses = delegator.findByAnd("SurveyResponse", fields, order, false); - // there should be only one - surveyResponse = EntityUtil.getFirst(responses); + surveyResponse = EntityQuery.use(delegator).from("SurveyResponse") + .where("orderId", orderId, + "orderItemSeqId", orderItem.get("orderItemSeqId"), + "surveyId", surveyId) + .queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -1254,7 +1253,7 @@ public class ValueLinkServices { GenericValue productStoreEmail = null; String emailType = "PRDS_GC_PURCHASE"; try { - productStoreEmail = delegator.findOne("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", productStoreId, "emailType", emailType), false); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get product store email setting for gift card purchase", module); } @@ -1374,12 +1373,11 @@ public class ValueLinkServices { // get the survey response GenericValue surveyResponse = null; try { - Map<String, Object> fields = UtilMisc.toMap("orderId", orderId, - "orderItemSeqId", orderItem.get("orderItemSeqId"), "surveyId", surveyId); - List<String> order = UtilMisc.toList("-responseDate"); - List<GenericValue> responses = delegator.findByAnd("SurveyResponse", fields, order, false); - // there should be only one - surveyResponse = EntityUtil.getFirst(responses); + surveyResponse = EntityQuery.use(delegator).from("SurveyResponse") + .where("orderId", orderId, + "orderItemSeqId", orderItem.get("orderItemSeqId"), + "surveyId", surveyId).orderBy("-responseDate") + .queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -1502,7 +1500,7 @@ public class ValueLinkServices { GenericValue productStoreEmail = null; String emailType = "PRDS_GC_RELOAD"; try { - productStoreEmail = delegator.findOne("ProductStoreEmailSetting", UtilMisc.toMap("productStoreId", productStoreId, "emailType", emailType), false); + productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting").where("productStoreId", productStoreId, "emailType", emailType).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Unable to get product store email setting for gift card purchase", module); } Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/verisign/PayflowPro.java Fri Oct 10 20:30:30 2014 @@ -921,7 +921,7 @@ public class PayflowPro { String returnValue = ""; if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue payflowPro = delegator.findOne("PaymentGatewayPayflowPro", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + GenericValue payflowPro = EntityQuery.use(delegator).from("PaymentGatewayPayflowPro").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(payflowPro)) { Object payflowProField = payflowPro.get(paymentGatewayConfigParameterName); if (payflowProField != null) { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/worldpay/WorldPayEvents.java Fri Oct 10 20:30:30 2014 @@ -20,12 +20,10 @@ package org.ofbiz.accounting.thirdparty. import java.io.IOException; import java.math.BigDecimal; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -44,7 +42,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.EntityUtil; +import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.order.order.OrderChangeHelper; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.GenericServiceException; @@ -69,7 +67,7 @@ public class WorldPayEvents { // get the order header GenericValue orderHeader = null; try { - orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); + orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get the order header for order: " + orderId, module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingOrderHeader", locale)); @@ -108,16 +106,15 @@ public class WorldPayEvents { // get the contact address to pass over GenericValue contactAddress = null; GenericValue contactAddressShip = null; - List<GenericValue> addresses = null; - List<GenericValue> shippingAddresses = null; + GenericValue addressOcm = null; + GenericValue shippingAddress = null; try { - addresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "BILLING_LOCATION"), null, false); - shippingAddresses = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "SHIPPING_LOCATION"), null, false); - if (addresses.size() == 0) { - addresses = shippingAddresses; + addressOcm = EntityQuery.use(delegator).from("OrderContactMech").where("orderId", orderId, "contactMechPurposeTypeId", "BILLING_LOCATION").queryFirst(); + shippingAddress = EntityQuery.use(delegator).from("OrderContactMech").where("orderId", orderId, "contactMechPurposeTypeId", "SHIPPING_LOCATION").queryFirst(); + if (addressOcm == null) { + addressOcm = shippingAddress; } - GenericValue contactMech = EntityUtil.getFirst(addresses); - contactAddress = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", contactMech.getString("contactMechId")), false); + contactAddress = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", addressOcm.getString("contactMechId")).queryOne(); } catch (GenericEntityException e) { Debug.logWarning(e, "Problems getting order contact information", module); } @@ -175,9 +172,8 @@ public class WorldPayEvents { String emailAddress = null; GenericValue emailContact = null; try { - List<GenericValue> emails = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId, "contactMechPurposeTypeId", "ORDER_EMAIL"), null, false); - GenericValue firstEmail = EntityUtil.getFirst(emails); - emailContact = delegator.findOne("ContactMech", UtilMisc.toMap("contactMechId", firstEmail.getString("contactMechId")), false); + GenericValue emailOcm = EntityQuery.use(delegator).from("OrderContactMech").where("orderId", orderId, "contactMechPurposeTypeId", "ORDER_EMAIL").queryFirst(); + emailContact = emailOcm.getRelatedOne("ContactMech", false); emailAddress = emailContact.getString("infoString"); } catch (GenericEntityException e) { Debug.logWarning(e, "Problems getting order email address", module); @@ -186,10 +182,9 @@ public class WorldPayEvents { StringBuilder shipAddress = new StringBuilder(); String shipPostalCode = ""; String shipName = ""; - if (shippingAddresses != null) { + if (shippingAddress != null) { try { - GenericValue contactMechShip = EntityUtil.getFirst(shippingAddresses); - contactAddressShip = delegator.findOne("PostalAddress", UtilMisc.toMap("contactMechId", contactMechShip.getString("contactMechId")), false); + contactAddressShip = EntityQuery.use(delegator).from("PostalAddress").where("contactMechId", shippingAddress.get("contactMechId")).queryOne(); if (UtilValidate.isNotEmpty(contactAddressShip)) { if (UtilValidate.isNotEmpty(contactAddressShip.getString("attnName"))) { shipName = contactAddressShip.getString("attnName"); @@ -324,7 +319,7 @@ public class WorldPayEvents { if (userLogin == null) { String userLoginId = "system"; try { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false); + userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get UserLogin for: " + userLoginId + "; cannot continue", module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingAuthenticationUser", locale)); @@ -335,7 +330,7 @@ public class WorldPayEvents { GenericValue orderHeader = null; if (UtilValidate.isNotEmpty(orderId)) { try { - orderHeader = delegator.findOne("OrderHeader", UtilMisc.toMap("orderId", orderId), false); + orderHeader = EntityQuery.use(delegator).from("OrderHeader").where("orderId", orderId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get the order header for order: " + orderId, module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.problemsGettingOrderHeader", locale)); @@ -410,8 +405,8 @@ public class WorldPayEvents { Debug.logVerbose("Setting payment preferences..", module); List<GenericValue> paymentPrefs = null; try { - Map<String, String> paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED"); - paymentPrefs = delegator.findByAnd("OrderPaymentPreference", paymentFields, null, false); + paymentPrefs = EntityQuery.use(delegator).from("OrderPaymentPreference") + .where("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED").queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module); return false; @@ -501,7 +496,7 @@ public class WorldPayEvents { String returnValue = ""; if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) { try { - GenericValue worldPay = delegator.findOne("PaymentGatewayWorldPay", UtilMisc.toMap("paymentGatewayConfigId", paymentGatewayConfigId), false); + GenericValue worldPay = EntityQuery.use(delegator).from("PaymentGatewayWorldPay").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne(); if (UtilValidate.isNotEmpty(worldPay)) { Object worldPayField = worldPay.get(paymentGatewayConfigParameterName); if (worldPayField != null) { Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java?rev=1630980&r1=1630979&r2=1630980&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/util/UtilAccounting.java Fri Oct 10 20:30:30 2014 @@ -30,6 +30,7 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityQuery; public class UtilAccounting { @@ -55,8 +56,9 @@ public class UtilAccounting { GenericValue account = null; try { // first try to find the account in ProductGlAccount - account = delegator.findOne("ProductGlAccount", - UtilMisc.toMap("productId", productId, "glAccountTypeId", glAccountTypeId, "organizationPartyId", organizationPartyId), true); + account = EntityQuery.use(delegator).from("ProductGlAccount") + .where("productId", productId, "glAccountTypeId", glAccountTypeId, "organizationPartyId", organizationPartyId) + .cache().queryOne(); } catch (GenericEntityException e) { throw new AccountingException("Failed to find a ProductGLAccount for productId [" + productId + "], organization [" + organizationPartyId + "], and productGlAccountTypeId [" + glAccountTypeId + "].", e); } @@ -64,7 +66,7 @@ public class UtilAccounting { // otherwise try the default accounts if (account == null) { try { - account = delegator.findOne("GlAccountTypeDefault", UtilMisc.toMap("glAccountTypeId", glAccountTypeId, "organizationPartyId", organizationPartyId), true); + account = EntityQuery.use(delegator).from("GlAccountTypeDefault").where("glAccountTypeId", glAccountTypeId, "organizationPartyId", organizationPartyId).cache().queryOne(); } catch (GenericEntityException e) { throw new AccountingException("Failed to find a GlAccountTypeDefault for glAccountTypeId [" + glAccountTypeId + "] and organizationPartyId [" + organizationPartyId+ "].", e); }