Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java Mon Nov 24 10:06:26 2014 @@ -58,9 +58,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.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityUtil; @@ -303,15 +301,14 @@ public class CommunicationEventServices EntityCondition.makeCondition("preferredContactMechId", EntityOperator.NOT_EQUAL, null), EntityUtil.getFilterByDateExpr(), EntityUtil.getFilterByDateExpr("contactFromDate", "contactThruDate")); - EntityConditionList<EntityCondition> conditions = EntityCondition.makeCondition(conditionList, EntityOperator.AND); - Set<String> fieldsToSelect = UtilMisc.toSet("partyId", "preferredContactMechId", "fromDate", "infoString"); - - eli = delegator.find("ContactListPartyAndContactMech", conditions, null, fieldsToSelect, null, - new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true)); + eli = EntityQuery.use(delegator).select("partyId", "preferredContactMechId", "fromDate", "infoString") + .from("ContactListPartyAndContactMech") + .where(EntityCondition.makeCondition(conditionList, EntityOperator.AND)) + .cursorScrollInsensitive() + .distinct() + .queryIterator(); // Send an email to each contact list member - List<String> orderBy = UtilMisc.toList("-fromDate"); - // loop through the list iterator for (GenericValue contactListPartyAndContactMech; (contactListPartyAndContactMech = eli.next()) != null;) { Debug.logInfo("Contact info: " + contactListPartyAndContactMech, module); @@ -336,10 +333,12 @@ public class CommunicationEventServices // only the most recent valid one via ContactListPartyAndContactMech. List<EntityCondition> clpConditionList = UtilMisc.makeListWritable(conditionList); clpConditionList.add(EntityCondition.makeCondition("infoString", EntityOperator.EQUALS, emailAddress)); - EntityConditionList<EntityCondition> clpConditions = EntityCondition.makeCondition(clpConditionList, EntityOperator.AND); - List<GenericValue> emailCLPaCMs = delegator.findList("ContactListPartyAndContactMech", clpConditions, null, orderBy, null, true); - GenericValue lastContactListPartyACM = EntityUtil.getFirst(emailCLPaCMs); + GenericValue lastContactListPartyACM = EntityQuery.use(delegator).from("ContactListPartyAndContactMech") + .where(EntityCondition.makeCondition(clpConditionList, EntityOperator.AND)) + .orderBy("-fromDate") + .cache(true) + .queryFirst(); if (lastContactListPartyACM == null) continue; String partyId = lastContactListPartyACM.getString("partyId"); @@ -356,7 +355,9 @@ public class CommunicationEventServices // Retrieve a record for this contactMechId from ContactListCommStatus Map<String, String> contactListCommStatusRecordMap = UtilMisc.toMap("contactListId", contactListId, "communicationEventId", communicationEventId, "contactMechId", lastContactListPartyACM.getString("preferredContactMechId")); - GenericValue contactListCommStatusRecord = delegator.findOne("ContactListCommStatus", contactListCommStatusRecordMap, false); + GenericValue contactListCommStatusRecord = EntityQuery.use(delegator).from("ContactListCommStatus") + .where(contactListCommStatusRecordMap) + .queryOne(); if (contactListCommStatusRecord == null) { // No attempt has been made previously to send to this address, so create a record to reflect @@ -378,8 +379,9 @@ public class CommunicationEventServices Map<String, Object> tmpResult = null; // Retrieve a contact list party status - List<GenericValue> contactListPartyStatuses = delegator.findByAnd("ContactListPartyStatus", UtilMisc.toMap("contactListId", contactListId, "partyId", contactListPartyAndContactMech.getString("partyId"), "fromDate", contactListPartyAndContactMech.getTimestamp("fromDate"), "statusId", "CLPT_ACCEPTED"), null, false); - GenericValue contactListPartyStatus = EntityUtil.getFirst(contactListPartyStatuses); + GenericValue contactListPartyStatus = EntityQuery.use(delegator).from("ContactListPartyStatus") + .where("contactListId", contactListId, "partyId", contactListPartyAndContactMech.getString("partyId"), "fromDate", contactListPartyAndContactMech.getTimestamp("fromDate"), "statusId", "CLPT_ACCEPTED") + .queryFirst(); if (UtilValidate.isNotEmpty(contactListPartyStatus)) { // prepare body parameters Map<String, Object> bodyParameters = new HashMap<String, Object>(); @@ -546,9 +548,7 @@ public class CommunicationEventServices String partyIdFrom = null; GenericValue fromCm; try { - List<GenericValue> fromCms = delegator.findByAnd("PartyAndContactMech", UtilMisc.toMap("infoString", sendFrom), UtilMisc.toList("-fromDate"), false); - fromCms = EntityUtil.filterByDate(fromCms); - fromCm = EntityUtil.getFirst(fromCms); + fromCm = EntityQuery.use(delegator).from("PartyAndContactMech").where("infoString", sendFrom).orderBy("-fromDate").filterByDate().queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -562,9 +562,7 @@ public class CommunicationEventServices String contactMechIdTo = null; GenericValue toCm; try { - List<GenericValue> toCms = delegator.findByAnd("PartyAndContactMech", UtilMisc.toMap("infoString", sendTo, "partyId", partyId), UtilMisc.toList("-fromDate"), false); - toCms = EntityUtil.filterByDate(toCms); - toCm = EntityUtil.getFirst(toCms); + toCm = EntityQuery.use(delegator).from("PartyAndContactMech").where("infoString", sendTo, "partyId", partyId).orderBy("-fromDate").filterByDate().queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -739,7 +737,7 @@ public class CommunicationEventServices // make sure this isn't a duplicate List<GenericValue> commEvents; try { - commEvents = delegator.findByAnd("CommunicationEvent", UtilMisc.toMap("messageId", messageId), null, false); + commEvents = EntityQuery.use(delegator).from("CommunicationEvent").where("messageId", messageId).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -835,8 +833,7 @@ public class CommunicationEventServices if (inReplyTo != null && inReplyTo[0] != null) { GenericValue parentCommEvent = null; try { - List<GenericValue> events = delegator.findByAnd("CommunicationEvent", UtilMisc.toMap("messageId", inReplyTo[0].replaceAll("[<>]", "")), null, false); - parentCommEvent = EntityUtil.getFirst(events); + parentCommEvent = EntityQuery.use(delegator).from("CommunicationEvent").where("messageId", inReplyTo[0].replaceAll("[<>]", "")).queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -1030,8 +1027,9 @@ public class CommunicationEventServices try { for (Map<String, Object> result : parties) { String partyId = (String) result.get("partyId"); - GenericValue commEventRole = delegator.findOne("CommunicationEventRole", - UtilMisc.toMap("communicationEventId", communicationEventId, "partyId", partyId, "roleTypeId", roleTypeId), false); + GenericValue commEventRole = EntityQuery.use(delegator).from("CommunicationEventRole") + .where("communicationEventId", communicationEventId, "partyId", partyId, "roleTypeId", roleTypeId) + .queryOne(); if (commEventRole == null) { Map<String, Object> input = UtilMisc.toMap("communicationEventId", communicationEventId, "partyId", partyId, "roleTypeId", roleTypeId, "userLogin", userLogin, @@ -1215,7 +1213,7 @@ public class CommunicationEventServices if (messageId != null) { List<GenericValue> values; try { - values = delegator.findByAnd("CommunicationEvent", UtilMisc.toMap("messageId", messageId), null, false); + values = EntityQuery.use(delegator).from("CommunicationEvent").where("messageId", messageId).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -1246,8 +1244,7 @@ public class CommunicationEventServices // no communication events found for that message ID; possible this is a NEWSLETTER try { - values = delegator.findByAnd("ContactListCommStatus", UtilMisc.toMap("messageId", - messageId), null, false); + values = EntityQuery.use(delegator).from("ContactListCommStatus").where("messageId", messageId).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java Mon Nov 24 10:06:26 2014 @@ -167,8 +167,11 @@ public class ContactMechServices { if (!partyId.equals("_NA_")) { // try to find a PartyContactMech with a valid date range try { - List<GenericValue> partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate"), false), true); - partyContactMech = EntityUtil.getFirst(partyContactMechs); + partyContactMech = EntityQuery.use(delegator).from("PartyContactMech") + .where("partyId", partyId, "contactMechId", contactMechId) + .orderBy("fromDate") + .filterByDate() + .queryFirst(); if (partyContactMech == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "contactmechservices.cannot_update_specified_contact_info_not_corresponds", locale)); @@ -279,9 +282,11 @@ public class ContactMechServices { try { // try to find a PartyContactMech with a valid date range - List<GenericValue> partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate"), false), true); - - partyContactMech = EntityUtil.getFirst(partyContactMechs); + partyContactMech = EntityQuery.use(delegator).from("PartyContactMech") + .where("partyId", partyId, "contactMechId", contactMechId) + .orderBy("fromDate") + .filterByDate() + .queryFirst(); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, @@ -427,8 +432,11 @@ public class ContactMechServices { if (!partyId.equals("_NA_")) { // try to find a PartyContactMech with a valid date range try { - List<GenericValue> partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate"), false), true); - partyContactMech = EntityUtil.getFirst(partyContactMechs); + partyContactMech = EntityQuery.use(delegator).from("PartyContactMech") + .where("partyId", partyId, "contactMechId", contactMechId) + .orderBy("fromDate") + .filterByDate() + .queryFirst(); if (partyContactMech == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, "contactmechservices.cannot_update_specified_contact_info_not_corresponds", locale)); @@ -638,9 +646,11 @@ public class ContactMechServices { try { contactMech = EntityQuery.use(delegator).from("ContactMech").where("contactMechId", contactMechId).queryOne(); // try to find a PartyContactMech with a valid date range - List<GenericValue> partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate"), false), true); - - partyContactMech = EntityUtil.getFirst(partyContactMechs); + partyContactMech = EntityQuery.use(delegator).from("PartyContactMech") + .where("partyId", partyId, "contactMechId", contactMechId) + .orderBy("fromDate") + .filterByDate() + .queryFirst(); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); contactMech = null; @@ -808,13 +818,10 @@ public class ContactMechServices { GenericValue tempVal = null; try { - Map<String, String> pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId); - //Debug.logInfo("pcmpFindMap = " + pcmpFindMap, module); - List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", pcmpFindMap, null, false); - allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true); - allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true); - - tempVal = EntityUtil.getFirst(allPCWPs); + tempVal = EntityQuery.use(delegator).from("PartyContactWithPurpose") + .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId) + .filterByDate("contactFromDate", "contactThruDate", "purposeFromDate", "purposeThruDate") + .queryFirst(); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); tempVal = null; @@ -871,13 +878,10 @@ public class ContactMechServices { GenericValue tempVal = null; try { - Map<String, String> pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId); - //Debug.logInfo("pcmpFindMap = " + pcmpFindMap, module); - List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", pcmpFindMap, null, false); - allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true); - allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true); - - tempVal = EntityUtil.getFirst(allPCWPs); + tempVal = EntityQuery.use(delegator).from("PartyContactWithPurpose") + .where("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId) + .filterByDate("contactFromDate", "contactThruDate", "purposeFromDate", "purposeThruDate") + .queryFirst(); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); tempVal = null; @@ -1061,7 +1065,7 @@ public class ContactMechServices { verifyHash = HashCrypt.digestHash("MD5", Long.toString(random).getBytes()); List<GenericValue> emailAddVerifications = null; try { - emailAddVerifications = delegator.findByAnd("EmailAddressVerification", UtilMisc.toMap("verifyHash", verifyHash), null, false); + emailAddVerifications = EntityQuery.use(delegator).from("EmailAddressVerification").where("verifyHash", verifyHash).queryList(); } catch (GenericEntityException e) { Debug.logError(e.getMessage(), module); return ServiceUtil.returnError(e.getMessage()); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java Mon Nov 24 10:06:26 2014 @@ -62,7 +62,7 @@ public class ContactMechWorker { List<GenericValue> allPartyContactMechs = null; try { - List<GenericValue> tempCol = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId), null, false); + List<GenericValue> tempCol = EntityQuery.use(delegator).from("PartyContactMech").where("partyId", partyId).queryList(); if (contactMechTypeId != null) { List<GenericValue> tempColTemp = FastList.newInstance(); for (GenericValue partyContactMech: tempCol) { @@ -133,7 +133,7 @@ public class ContactMechWorker { List<GenericValue> allFacilityContactMechs = null; try { - List<GenericValue> tempCol = delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId), null, false); + List<GenericValue> tempCol = EntityQuery.use(delegator).from("FacilityContactMech").where("facilityId", facilityId).queryList(); if (contactMechTypeId != null) { List<GenericValue> tempColTemp = FastList.newInstance(); for (GenericValue partyContactMech: tempCol) { @@ -205,7 +205,10 @@ public class ContactMechWorker { List<GenericValue> allOrderContactMechs = null; try { - allOrderContactMechs = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId), UtilMisc.toList("contactMechPurposeTypeId"), false); + allOrderContactMechs = EntityQuery.use(delegator).from("OrderContactMech") + .where("orderId", orderId) + .orderBy("contactMechPurposeTypeId") + .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -262,8 +265,10 @@ public class ContactMechWorker { List<GenericValue> allWorkEffortContactMechs = null; try { - List<GenericValue> workEffortContactMechs = delegator.findByAnd("WorkEffortContactMech", UtilMisc.toMap("workEffortId", workEffortId), null, false); - allWorkEffortContactMechs = EntityUtil.filterByDate(workEffortContactMechs); + allWorkEffortContactMechs = EntityQuery.use(delegator).from("WorkEffortContactMech") + .where("workEffortId", workEffortId) + .filterByDate() + .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -338,7 +343,10 @@ public class ContactMechWorker { List<GenericValue> partyContactMechs = null; try { - partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), null, false), true); + partyContactMechs = EntityQuery.use(delegator).from("PartyContactMech") + .where("partyId", partyId, "contactMechId", contactMechId) + .filterByDate() + .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -387,7 +395,9 @@ public class ContactMechWorker { Iterator<GenericValue> typePurposes = null; try { - typePurposes = UtilMisc.toIterator(delegator.findByAnd("ContactMechTypePurpose", UtilMisc.toMap("contactMechTypeId", contactMechTypeId), null, false)); + typePurposes = UtilMisc.toIterator(EntityQuery.use(delegator).from("ContactMechTypePurpose") + .where("contactMechTypeId", contactMechTypeId) + .queryList()); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -463,7 +473,7 @@ public class ContactMechWorker { target.put("tryEntity", Boolean.valueOf(tryEntity)); try { - Collection<GenericValue> contactMechTypes = delegator.findList("ContactMechType", null, null, null, null, true); + Collection<GenericValue> contactMechTypes = EntityQuery.use(delegator).from("ContactMechType").cache(true).queryList(); if (contactMechTypes != null) { target.put("contactMechTypes", contactMechTypes); @@ -490,8 +500,12 @@ public class ContactMechWorker { conditionList.add(EntityCondition.makeCondition("contactMechPurposeTypeId", purposeType)); EntityCondition entityCondition = EntityCondition.makeCondition(conditionList); try { - facilityContactMechPurposes = delegator.findList("FacilityContactMechPurpose", entityCondition, null, UtilMisc.toList("-fromDate"), null, true); - facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMechPurposes); + facilityContactMechPurposes = EntityQuery.use(delegator).from("FacilityContactMechPurpose") + .where(entityCondition) + .orderBy("-fromDate") + .cache(true) + .filterByDate() + .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); continue; @@ -504,8 +518,12 @@ public class ContactMechWorker { conditionList.add(EntityCondition.makeCondition("contactMechId", contactMechId)); entityCondition = EntityCondition.makeCondition(conditionList); try { - facilityContactMechs = delegator.findList("FacilityContactMech", entityCondition, null, UtilMisc.toList("-fromDate"), null, true); - facilityContactMechs = EntityUtil.filterByDate(facilityContactMechs); + facilityContactMechs = EntityQuery.use(delegator).from("FacilityContactMech") + .where(entityCondition) + .orderBy("-fromDate") + .cache(true) + .filterByDate() + .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -550,7 +568,10 @@ public class ContactMechWorker { List<GenericValue> facilityContactMechs = null; try { - facilityContactMechs = EntityUtil.filterByDate(delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId, "contactMechId", contactMechId), null, false), true); + facilityContactMechs = EntityQuery.use(delegator).from("FacilityContactMech") + .where("facilityId", facilityId, "contactMechId", contactMechId) + .filterByDate() + .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -599,7 +620,9 @@ public class ContactMechWorker { Iterator<GenericValue> typePurposes = null; try { - typePurposes = UtilMisc.toIterator(delegator.findByAnd("ContactMechTypePurpose", UtilMisc.toMap("contactMechTypeId", contactMechTypeId), null, false)); + typePurposes = UtilMisc.toIterator(EntityQuery.use(delegator).from("ContactMechTypePurpose") + .where("contactMechTypeId", contactMechTypeId) + .queryList()); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -675,7 +698,7 @@ public class ContactMechWorker { target.put("tryEntity", Boolean.valueOf(tryEntity)); try { - Collection<GenericValue> contactMechTypes = delegator.findList("ContactMechType", null, null, null, null, true); + Collection<GenericValue> contactMechTypes = EntityQuery.use(delegator).from("ContactMechType").cache(true).queryList(); if (contactMechTypes != null) { target.put("contactMechTypes", contactMechTypes); @@ -692,7 +715,7 @@ public class ContactMechWorker { List<GenericValue> allPartyContactMechs = null; try { - allPartyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId), null, false), true); + allPartyContactMechs = EntityQuery.use(delegator).from("PartyContactMech").where("partyId", partyId).filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -741,7 +764,10 @@ public class ContactMechWorker { List<GenericValue> partyContactMechs = null; try { - partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", curContactMechId), null, false), true); + partyContactMechs = EntityQuery.use(delegator).from("PartyContactMech") + .where("partyId", partyId, "contactMechId", curContactMechId) + .filterByDate() + .queryList(); } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -845,8 +871,10 @@ public class ContactMechWorker { Delegator delegator = postalAddress.getDelegator(); List<GenericValue> postalAddresses = FastList.newInstance(); try { - List<GenericValue> partyContactMechs = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", companyPartyId), null, false); - partyContactMechs = EntityUtil.filterByDate(partyContactMechs); + List<GenericValue> partyContactMechs = EntityQuery.use(delegator).from("PartyContactMech") + .where("partyId", companyPartyId) + .filterByDate() + .queryList(); if (partyContactMechs != null) { for (GenericValue pcm: partyContactMechs) { GenericValue addr = pcm.getRelatedOne("PostalAddress", false); @@ -927,9 +955,10 @@ public class ContactMechWorker { } // no shortcut, try the longcut to see if there is something with a geoCode associated to the countryGeoId - List<GenericValue> geoAssocAndGeoToList = delegator.findByAnd("GeoAssocAndGeoTo", - UtilMisc.toMap("geoIdFrom", postalAddress.getString("countryGeoId"), "geoCode", postalAddress.getString("postalCode"), "geoAssocTypeId", "REGIONS"), null, true); - GenericValue geoAssocAndGeoTo = EntityUtil.getFirst(geoAssocAndGeoToList); + GenericValue geoAssocAndGeoTo = EntityQuery.use(delegator).from("GeoAssocAndGeoTo") + .where("geoIdFrom", postalAddress.getString("countryGeoId"), "geoCode", postalAddress.getString("postalCode"), "geoAssocTypeId", "REGIONS") + .cache(true) + .queryFirst(); if (geoAssocAndGeoTo != null) { // save the value to the database for quicker future reference if (postalAddress.isMutable()) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java Mon Nov 24 10:06:26 2014 @@ -232,8 +232,12 @@ public class PartyContentWrapper impleme } public static List<String> getPartyContentTextList(GenericValue party, String partyContentTypeId, Locale locale, String mimeTypeId, Delegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { - List<GenericValue> partyContentList = delegator.findByAnd("PartyContent", UtilMisc.toMap("partyId", party.getString("partyId"), "partyContentTypeId", partyContentTypeId), UtilMisc.toList("-fromDate"), true); - partyContentList = EntityUtil.filterByDate(partyContentList); + List<GenericValue> partyContentList = EntityQuery.use(delegator).from("PartyContent") + .where("partyId", party.getString("partyId"), "partyContentTypeId", partyContentTypeId) + .orderBy("-fromDate") + .cache(true) + .filterByDate() + .queryList(); List<String> contentList = FastList.newInstance(); if (partyContentList != null) { @@ -265,7 +269,11 @@ public class PartyContentWrapper impleme List<GenericValue> partyContentList = null; try { - partyContentList = delegator.findByAnd("PartyContent", UtilMisc.toMap("partyId", partyId, "partyContentTypeId", partyContentTypeId), UtilMisc.toList("-fromDate"), true); + partyContentList = EntityQuery.use(delegator).from("PartyContent") + .where("partyId", partyId, "partyContentTypeId", partyContentTypeId) + .orderBy("-fromDate") + .cache(true) + .queryList(); } catch (GeneralException e) { Debug.logError(e, module); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyRelationshipHelper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyRelationshipHelper.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyRelationshipHelper.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyRelationshipHelper.java Mon Nov 24 10:06:26 2014 @@ -34,6 +34,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; /** * PartyRelationshipHelper @@ -71,7 +72,7 @@ public class PartyRelationshipHelper { List<GenericValue> partyRelationships = null; try { - partyRelationships = delegator.findList("PartyRelationship", condition, null, null, null, false); + partyRelationships = EntityQuery.use(delegator).from("PartyRelationship").where(condition).queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Problem finding PartyRelationships. ", module); return null; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java Mon Nov 24 10:06:26 2014 @@ -79,7 +79,7 @@ public class PartyRelationshipServices { partyRelationshipType.set("partyRelationshipName", context.get("partyRelationshipName"), false); try { - if (delegator.findOne(partyRelationshipType.getEntityName(), partyRelationshipType.getPrimaryKey(), false) != null) { + if ((EntityQuery.use(delegator).from(partyRelationshipType.getEntityName()).where(partyRelationshipType.getPrimaryKey()).queryOne()) != null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "PartyRelationshipTypeAlreadyExists", locale)); } @@ -142,13 +142,11 @@ public class PartyRelationshipServices { // Check if there is already a partyRelationship of that type with another party from the side indicated String sideChecked = partyIdFrom.equals(partyId)? "partyIdFrom" : "partyIdTo"; - partyRelationShipList = delegator.findByAnd("PartyRelationship", UtilMisc.toMap(sideChecked, partyId, - "roleTypeIdFrom", roleTypeIdFrom, - "roleTypeIdTo", roleTypeIdTo, - "partyRelationshipTypeId", partyRelationshipTypeId), null, false); // We consider the last one (in time) as sole active (we try to maintain a unique relationship and keep changes history) - partyRelationShipList = EntityUtil.filterByDate(partyRelationShipList); - GenericValue oldPartyRelationShip = EntityUtil.getFirst(partyRelationShipList); + GenericValue oldPartyRelationShip = EntityQuery.use(delegator).from("PartyRelationship") + .where(sideChecked, partyId, "roleTypeIdFrom", roleTypeIdFrom, "roleTypeIdTo", roleTypeIdTo, "partyRelationshipTypeId", partyRelationshipTypeId) + .filterByDate() + .queryFirst(); if (UtilValidate.isNotEmpty(oldPartyRelationShip)) { oldPartyRelationShip.setFields(UtilMisc.toMap("thruDate", UtilDateTime.nowTimestamp())); // Current becomes inactive oldPartyRelationShip.store(); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyServices.java Mon Nov 24 10:06:26 2014 @@ -56,6 +56,7 @@ import org.ofbiz.entity.util.EntityListI import org.ofbiz.entity.util.EntityQuery; import org.ofbiz.entity.util.EntityTypeUtil; import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.entity.util.EntityUtilProperties; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -253,7 +254,7 @@ public class PartyServices { // disable all userlogins for this user when the new status is disabled if (("PARTY_DISABLED").equals(statusId)) { - List <GenericValue> userLogins = delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId), null, false); + List <GenericValue> userLogins = EntityQuery.use(delegator).from("UserLogin").where("partyId", partyId).queryList(); for (GenericValue userLogin : userLogins) { if (!"N".equals(userLogin.getString("enabled"))) { userLogin.set("enabled", "N"); @@ -728,8 +729,11 @@ public class PartyServices { } try { - EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase())); - List<GenericValue> c = EntityUtil.filterByDate(delegator.findList("PartyAndContactMech", ee, null, UtilMisc.toList("infoString"), null, false), true); + List<GenericValue> c = EntityQuery.use(delegator).from("PartyAndContactMech") + .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase()))) + .orderBy("infoString") + .filterByDate() + .queryList(); if (Debug.verboseOn()) Debug.logVerbose("List: " + c, module); if (Debug.infoOn()) Debug.logInfo("PartyFromEmail number found: " + c.size(), module); @@ -763,8 +767,11 @@ public class PartyServices { } try { - EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER(("%" + email.toUpperCase()) + "%")); - List<GenericValue> c = EntityUtil.filterByDate(delegator.findList("PartyAndContactMech", ee, null, UtilMisc.toList("infoString"), null, false), true); + List<GenericValue> c = EntityQuery.use(delegator).from("PartyAndContactMech") + .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER(("%" + email.toUpperCase()) + "%"))) + .orderBy("infoString") + .filterByDate() + .queryList(); if (Debug.verboseOn()) Debug.logVerbose("List: " + c, module); if (Debug.infoOn()) Debug.logInfo("PartyFromEmail number found: " + c.size(), module); @@ -804,8 +811,10 @@ public class PartyServices { "PartyCannotGetUserLoginFromParty", locale)); try { - EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId.toUpperCase() + "%")); - Collection<GenericValue> ulc = delegator.findList("PartyAndUserLogin", ee, null, UtilMisc.toList("userLoginId"), null, false); + Collection<GenericValue> ulc = EntityQuery.use(delegator).from("PartyAndUserLogin") + .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId.toUpperCase() + "%"))) + .orderBy("userLoginId") + .queryList(); if (Debug.verboseOn()) Debug.logVerbose("Collection: " + ulc, module); if (Debug.infoOn()) Debug.logInfo("PartyFromUserLogin number found: " + ulc.size(), module); @@ -856,7 +865,7 @@ public class PartyServices { EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(EntityOperator.AND, EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + firstName.toUpperCase() + "%")), EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + lastName.toUpperCase() + "%"))); - Collection<GenericValue> pc = delegator.findList("Person", ecl, null, UtilMisc.toList("lastName", "firstName", "partyId"), null, false); + Collection<GenericValue> pc = EntityQuery.use(delegator).from("Person").where(ecl).orderBy("lastName", "firstName", "partyId").queryList(); if (Debug.infoOn()) Debug.logInfo("PartyFromPerson number found: " + pc.size(), module); if (pc != null) { @@ -896,8 +905,10 @@ public class PartyServices { } try { - EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName.toUpperCase() + "%")); - Collection<GenericValue> pc = delegator.findList("PartyGroup", ee, null, UtilMisc.toList("groupName", "partyId"), null, false); + Collection<GenericValue> pc = EntityQuery.use(delegator).from("PartyGroup") + .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName.toUpperCase() + "%"))) + .orderBy("groupName", "partyId") + .queryList(); if (Debug.infoOn()) Debug.logInfo("PartyFromGroup number found: " + pc.size(), module); if (pc != null) { @@ -1011,7 +1022,7 @@ public class PartyServices { // get the role types try { - List<GenericValue> roleTypes = delegator.findList("RoleType", null, null, UtilMisc.toList("description"), null, false); + List<GenericValue> roleTypes = EntityQuery.use(delegator).from("RoleType").orderBy("description").queryList(); result.put("roleTypes", roleTypes); } catch (GenericEntityException e) { String errMsg = "Error looking up RoleTypes: " + e.toString(); @@ -1039,7 +1050,7 @@ public class PartyServices { //get party types try { - List<GenericValue> partyTypes = delegator.findList("PartyType", null, null, UtilMisc.toList("description"), null, false); + List<GenericValue> partyTypes = EntityQuery.use(delegator).from("PartyType").orderBy("description").queryList(); result.put("partyTypes", partyTypes); } catch (GenericEntityException e) { String errMsg = "Error looking up PartyTypes: " + e.toString(); @@ -1458,9 +1469,14 @@ public class PartyServices { highIndex = (viewIndex + 1) * viewSize; // set distinct on so we only get one row per order - EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, -1, highIndex, true); // using list iterator - EntityListIterator pli = delegator.findListIteratorByCondition(dynamicView, mainCond, null, fieldsToSelect, orderBy, findOpts); + EntityListIterator pli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect)) + .from(dynamicView) + .orderBy(orderBy) + .cursorScrollInsensitive() + .fetchSize(highIndex) + .distinct() + .queryIterator(); // get the partial list for this page partyList = pli.getPartialList(lowIndex, viewSize); @@ -1605,7 +1621,7 @@ public class PartyServices { // update the non-existing party roles List<GenericValue> rolesToMove; try { - rolesToMove = delegator.findByAnd("PartyRole", UtilMisc.toMap("partyId", partyId), null, false); + rolesToMove = EntityQuery.use(delegator).from("PartyRole").where("partyId", partyId).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -1614,7 +1630,7 @@ public class PartyServices { for (GenericValue attr: rolesToMove) { attr.set("partyId", partyIdTo); try { - if (delegator.findOne("PartyRole", attr.getPrimaryKey(), false) == null) { + if (EntityQuery.use(delegator).from("PartyRole").where(attr.getPrimaryKey()).queryOne() == null) { attr.create(); } } catch (GenericEntityException e) { @@ -1697,7 +1713,7 @@ public class PartyServices { // update the non-existing attributes List<GenericValue> attrsToMove; try { - attrsToMove = delegator.findByAnd("PartyAttribute", UtilMisc.toMap("partyId", partyId), null, false); + attrsToMove = EntityQuery.use(delegator).from("PartyAttribute").where("partyId", partyId).queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); @@ -1706,7 +1722,7 @@ public class PartyServices { for (GenericValue attr: attrsToMove) { attr.set("partyId", partyIdTo); try { - if (delegator.findOne("PartyAttribute", attr.getPrimaryKey(), false) == null) { + if (EntityQuery.use(delegator).from("PartyAttribute").where(attr.getPrimaryKey()).queryOne() == null) { attr.create(); } } catch (GenericEntityException e) { @@ -1918,14 +1934,16 @@ public class PartyServices { lastContactNumber = null; // party validation - List <GenericValue> currencyCheck = delegator.findByAnd("Uom", UtilMisc.toMap("abbreviation", rec.get("preferredCurrencyUomId"), "uomTypeId", "CURRENCY_MEASURE"), null, false); + List <GenericValue> currencyCheck = EntityQuery.use(delegator).from("Uom") + .where("abbreviation", rec.get("preferredCurrencyUomId"), "uomTypeId", "CURRENCY_MEASURE") + .queryList(); if (UtilValidate.isNotEmpty(rec.get("preferredCurrencyUomId")) && currencyCheck.size() == 0) { newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + "Currency code not found for: " + rec.get("preferredCurrencyUomId")); } if (UtilValidate.isEmpty(rec.get("roleTypeId"))) { newErrMsgs.add("Line number " + rec.getRecordNumber() + ": Mandatory roletype is missing, possible values: CUSTOMER, SUPPLIER, EMPLOYEE and more...."); - } else if (delegator.findOne("RoleType", UtilMisc.<String, Object>toMap("roleTypeId", rec.get("roleTypeId")), true) == null) { + } else if (EntityQuery.use(delegator).from("RoleType").where("roleTypeId", rec.get("roleTypeId")).queryOne() == null) { newErrMsgs.add("Line number " + rec.getRecordNumber() + ": RoletypeId is not valid: " + rec.get("roleTypeId") ); } @@ -1943,7 +1961,9 @@ public class PartyServices { if (UtilValidate.isEmpty(rec.get("countryGeoId"))) { newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + "Country code missing"); } else { - List <GenericValue> countryCheck = delegator.findByAnd("Geo", UtilMisc.toMap("geoTypeId", "COUNTRY", "abbreviation", rec.get("countryGeoId")), null, false); + List <GenericValue> countryCheck = EntityQuery.use(delegator).from("Geo") + .where("geoTypeId", "COUNTRY", "abbreviation", rec.get("countryGeoId")) + .queryList(); if (countryCheck.size() == 0) { newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + " Invalid Country code: " + rec.get("countryGeoId")); } @@ -1954,7 +1974,9 @@ public class PartyServices { } if (UtilValidate.isNotEmpty(rec.get("stateProvinceGeoId"))) { - List <GenericValue> stateCheck = delegator.findByAnd("Geo", UtilMisc.toMap("geoTypeId", "STATE", "abbreviation", rec.get("stateProvinceGeoId")), null, false); + List <GenericValue> stateCheck = EntityQuery.use(delegator).from("Geo") + .where("geoTypeId", "STATE", "abbreviation", rec.get("stateProvinceGeoId")) + .queryList(); if (stateCheck.size() == 0) { newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + " Invalid stateProvinceGeoId code: " + rec.get("countryGeoId")); } @@ -1974,7 +1996,9 @@ public class PartyServices { } if (errMsgs.size() == 0) { - List <GenericValue> partyCheck = delegator.findByAnd("PartyIdentification", UtilMisc.toMap("partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId")), null, false); + List <GenericValue> partyCheck = EntityQuery.use(delegator).from("PartyIdentification") + .where("partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId")) + .queryList(); addParty = partyCheck.size() == 0; if (!addParty) { // update party newPartyId = EntityUtil.getFirst(partyCheck).getString("partyId"); @@ -2038,7 +2062,9 @@ public class PartyServices { dispatcher.runSync("createPartyRole", partyRole); if (UtilValidate.isNotEmpty(rec.get("companyPartyId"))) { - List <GenericValue> companyCheck = delegator.findByAnd("PartyIdentification", UtilMisc.toMap("partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId")), null, false); + List <GenericValue> companyCheck = EntityQuery.use(delegator).from("PartyIdentification") + .where("partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId")) + .queryList(); if (companyCheck.size() == 0) { // update party group // company does not exist so create Map<String, Object> companyPartyGroup = UtilMisc.toMap( Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyWorker.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/party/src/org/ofbiz/party/party/PartyWorker.java Mon Nov 24 10:06:26 2014 @@ -111,9 +111,11 @@ public class PartyWorker { public static GenericValue findPartyLatestContactMech(String partyId, String contactMechTypeId, Delegator delegator) { try { - List<GenericValue> cmList = delegator.findByAnd("PartyAndContactMech", UtilMisc.toMap("partyId", partyId, "contactMechTypeId", contactMechTypeId), UtilMisc.toList("-fromDate"), false); - cmList = EntityUtil.filterByDate(cmList); - return EntityUtil.getFirst(cmList); + return EntityQuery.use(delegator).from("PartyAndContactMech") + .where("partyId", partyId, "contactMechTypeId", contactMechTypeId) + .orderBy("-fromDate") + .filterByDate() + .queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, "Error while finding latest ContactMech for party with ID [" + partyId + "] TYPE [" + contactMechTypeId + "]: " + e.toString(), module); return null; @@ -162,8 +164,7 @@ public class PartyWorker { public static GenericValue findPartyLatestUserLogin(String partyId, Delegator delegator) { try { - List<GenericValue> userLoginList = delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId), UtilMisc.toList("-" + ModelEntity.STAMP_FIELD), false); - return EntityUtil.getFirst(userLoginList); + return EntityQuery.use(delegator).from("UserLogin").where("partyId", partyId).orderBy("-" + ModelEntity.STAMP_FIELD).queryFirst(); } catch (GenericEntityException e) { Debug.logError(e, "Error while finding latest UserLogin for party with ID [" + partyId + "]: " + e.toString(), module); return null; @@ -172,8 +173,7 @@ public class PartyWorker { public static Timestamp findPartyLastLoginTime(String partyId, Delegator delegator) { try { - List<GenericValue> loginHistory = delegator.findByAnd("UserLoginHistory", UtilMisc.toMap("partyId", partyId), UtilMisc.toList("-fromDate"), false); - GenericValue v = EntityUtil.getFirst(loginHistory); + GenericValue v = EntityQuery.use(delegator).from("UserLoginHistory").where("partyId", partyId).orderBy("-fromDate").queryFirst(); if (v != null) { return v.getTimestamp("fromDate"); } else { @@ -357,9 +357,11 @@ public class PartyWorker { addrExprs.add(EntityCondition.makeCondition("partyTypeId", EntityOperator.EQUALS, partyTypeId)); } - List<String> sort = UtilMisc.toList("-fromDate"); - EntityCondition addrCond = EntityCondition.makeCondition(addrExprs, EntityOperator.AND); - List<GenericValue> addresses = EntityUtil.filterByDate(delegator.findList("PartyAndPostalAddress", addrCond, null, sort, null, false)); + List<GenericValue> addresses = EntityQuery.use(delegator).from("PartyAndPostalAddress") + .where(EntityCondition.makeCondition(addrExprs, EntityOperator.AND)) + .orderBy("-fromDate") + .filterByDate() + .queryList(); //Debug.logInfo("Checking for matching address: " + addrCond.toString() + "[" + addresses.size() + "]", module); if (UtilValidate.isEmpty(addresses)) { @@ -425,7 +427,7 @@ public class PartyWorker { // replace mapped words List<GenericValue> addressMap = null; try { - addressMap = delegator.findList("AddressMatchMap", null, null, UtilMisc.toList("sequenceNum"), null, false); + addressMap = EntityQuery.use(delegator).from("AddressMatchMap").orderBy("sequenceNum").queryList(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -447,7 +449,7 @@ public class PartyWorker { EntityConditionList<EntityExpr> baseExprs = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("partyIdFrom", partyIdFrom), EntityCondition.makeCondition("partyRelationshipTypeId", partyRelationshipTypeId)), EntityOperator.AND); - List<GenericValue> associatedParties = delegator.findList("PartyRelationship", baseExprs, null, null, null, true); + List<GenericValue> associatedParties = EntityQuery.use(delegator).from("PartyRelationship").where(baseExprs).cache(true).queryList(); partyList.addAll(associatedParties); while (UtilValidate.isNotEmpty(associatedParties)) { List<GenericValue> currentAssociatedParties = FastList.newInstance(); @@ -455,7 +457,7 @@ public class PartyWorker { EntityConditionList<EntityExpr> innerExprs = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("partyIdFrom", associatedParty.get("partyIdTo")), EntityCondition.makeCondition("partyRelationshipTypeId", partyRelationshipTypeId)), EntityOperator.AND); - List<GenericValue> associatedPartiesChilds = delegator.findList("PartyRelationship", innerExprs, null, null, null, true); + List<GenericValue> associatedPartiesChilds = EntityQuery.use(delegator).from("PartyRelationship").where(innerExprs).cache(true).queryList(); if (UtilValidate.isNotEmpty(associatedPartiesChilds)) { currentAssociatedParties.addAll(associatedPartiesChilds); } @@ -503,7 +505,7 @@ public class PartyWorker { if (UtilValidate.isNotEmpty(partyIdentificationTypeId)) { conditions.put("partyIdentificationTypeId", partyIdentificationTypeId); } - partiesFound = delegator.findByAnd("PartyIdentificationAndParty", conditions, UtilMisc.toList("partyId"), true); + partiesFound = EntityQuery.use(delegator).from("PartyIdentificationAndParty").where(conditions).orderBy("partyId").cache(true).queryList(); } if (! searchPartyFirst) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java Mon Nov 24 10:06:26 2014 @@ -73,7 +73,7 @@ public class CatalogWorker { List<GenericValue> catalogs = null; Delegator delegator = (Delegator) request.getAttribute("delegator"); try { - catalogs = delegator.findList("ProdCatalog", null, null, UtilMisc.toList("catalogName"), null, false); + catalogs = EntityQuery.use(delegator).from("ProdCatalog").orderBy("catalogName").queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up all catalogs", module); } @@ -93,7 +93,7 @@ public class CatalogWorker { public static List<GenericValue> getStoreCatalogs(Delegator delegator, String productStoreId) { try { - return EntityUtil.filterByDate(delegator.findByAnd("ProductStoreCatalog", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNum", "prodCatalogId"), true), true); + return EntityQuery.use(delegator).from("ProductStoreCatalog").where("productStoreId", productStoreId).orderBy("sequenceNum", "prodCatalogId").cache(true).filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up store catalogs for store with id " + productStoreId, module); } @@ -117,7 +117,7 @@ public class CatalogWorker { } try { - return EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "CUSTOMER"), UtilMisc.toList("sequenceNum", "prodCatalogId"), true), true); + return EntityQuery.use(delegator).from("ProdCatalogRole").where("partyId", partyId, "roleTypeId", "CUSTOMER").orderBy("sequenceNum", "prodCatalogId").cache(true).filterByDate().queryList(); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up ProdCatalog Roles for party with id " + partyId, module); } @@ -131,9 +131,12 @@ public class CatalogWorker { public static List<GenericValue> getProdCatalogCategories(Delegator delegator, String prodCatalogId, String prodCatalogCategoryTypeId) { try { - List<GenericValue> prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogCategory", - UtilMisc.toMap("prodCatalogId", prodCatalogId), - UtilMisc.toList("sequenceNum", "productCategoryId"), true), true); + List<GenericValue> prodCatalogCategories = EntityQuery.use(delegator).from("ProdCatalogCategory") + .where("prodCatalogId", prodCatalogId) + .orderBy("sequenceNum", "productCategoryId") + .cache(true) + .filterByDate() + .queryList(); if (UtilValidate.isNotEmpty(prodCatalogCategoryTypeId) && prodCatalogCategories != null) { prodCatalogCategories = EntityUtil.filterByAnd(prodCatalogCategories, Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CatalogUrlServlet.java Mon Nov 24 10:06:26 2014 @@ -36,6 +36,7 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.util.EntityQuery; /** * ControlServlet.java - Master servlet for the web application. @@ -84,7 +85,7 @@ public class CatalogUrlServlet extends H String productId = null; try { String lastPathElement = pathElements.get(pathElements.size() - 1); - if (lastPathElement.startsWith("p_") || delegator.findOne("Product", UtilMisc.toMap("productId", lastPathElement), true) != null) { + if (lastPathElement.startsWith("p_") || EntityQuery.use(delegator).from("Product").where("productId", lastPathElement).cache(true).queryOne() != null) { if (lastPathElement.startsWith("p_")) { productId = lastPathElement.substring(2); } else { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java Mon Nov 24 10:06:26 2014 @@ -141,7 +141,7 @@ public class CategoryContentWrapper impl } } - List<GenericValue> categoryContentList = delegator.findByAnd("ProductCategoryContent", UtilMisc.toMap("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId), UtilMisc.toList("-fromDate"), true); + List<GenericValue> categoryContentList = EntityQuery.use(delegator).from("ProductCategoryContent").where("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId).orderBy("-fromDate").cache(true).queryList(); categoryContentList = EntityUtil.filterByDate(categoryContentList); GenericValue categoryContent = EntityUtil.getFirst(categoryContentList); if (categoryContent != null) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryServices.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryServices.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryServices.java Mon Nov 24 10:06:26 2014 @@ -105,7 +105,7 @@ public class CategoryServices { List<GenericValue> productCategoryMembers; try { productCategory = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId", categoryId).cache().queryOne(); - productCategoryMembers = delegator.findByAnd(entityName, UtilMisc.toMap("productCategoryId", categoryId), orderByFields, true); + productCategoryMembers = EntityQuery.use(delegator).from(entityName).where("productCategoryId", categoryId).orderBy(orderByFields).cache(true).queryList(); } catch (GenericEntityException e) { Debug.logInfo(e, "Error finding previous/next product info: " + e.toString(), module); return ServiceUtil.returnFailure(UtilProperties.getMessage(resourceError, "categoryservices.error_find_next_products", UtilMisc.toMap("errMessage", e.getMessage()), locale)); @@ -276,7 +276,7 @@ public class CategoryServices { try { String productStoreId = (String) context.get("productStoreId"); if (UtilValidate.isNotEmpty(productStoreId)) { - GenericValue productStore = delegator.findOne("ProductStore", UtilMisc.toMap("productStoreId", productStoreId), false); + GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne(); if (productStore != null && "N".equals(productStore.getString("showOutOfStockProducts"))) { filterOutOfStock = true; } @@ -288,7 +288,7 @@ public class CategoryServices { if (productCategory != null) { try { if (useCacheForMembers) { - productCategoryMembers = delegator.findByAnd(entityName, UtilMisc.toMap("productCategoryId", productCategoryId), orderByFields, true); + productCategoryMembers = EntityQuery.use(delegator).from(entityName).where("productCategoryId", productCategoryId).orderBy(orderByFields).cache(true).queryList(); if (activeOnly) { productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, true); } @@ -351,10 +351,8 @@ public class CategoryServices { EntityCondition mainCond = EntityCondition.makeCondition(mainCondList, EntityOperator.AND); // set distinct on - EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, false); - findOpts.setMaxRows(highIndex); // using list iterator - EntityListIterator pli = delegator.find(entityName, mainCond, null, null, orderByFields, findOpts); + EntityListIterator pli = EntityQuery.use(delegator).from(entityName).where(mainCond).orderBy(orderByFields).cursorScrollInsensitive().maxRows(highIndex).queryIterator(); // get the partial list for this page if (limitView) { @@ -455,17 +453,16 @@ public class CategoryServices { List<String> sortList = org.ofbiz.base.util.UtilMisc.toList("sequenceNum", "title"); try { - GenericValue category = delegator.findOne(entityName ,UtilMisc.toMap(primaryKeyName, productCategoryId), false); + GenericValue category = EntityQuery.use(delegator).from(entityName).where(primaryKeyName, productCategoryId).queryOne(); if (UtilValidate.isNotEmpty(category)) { if (isCatalog.equals("true") && isCategoryType.equals("false")) { CategoryWorker.getRelatedCategories(request, "ChildCatalogList", CatalogWorker.getCatalogTopCategoryId(request, productCategoryId), true); childOfCats = EntityUtil.filterByDate((List<GenericValue>) request.getAttribute("ChildCatalogList")); } else if(isCatalog.equals("false") && isCategoryType.equals("false")){ - childOfCats = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryRollupAndChild", UtilMisc.toMap( - "parentProductCategoryId", productCategoryId ), null, false)); + childOfCats = EntityQuery.use(delegator).from("ProductCategoryRollupAndChild").where("parentProductCategoryId", productCategoryId).filterByDate().queryList(); } else { - childOfCats = EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogCategory", UtilMisc.toMap("prodCatalogId", productCategoryId), null, false)); + childOfCats = EntityQuery.use(delegator).from("ProdCatalogCategory").where("prodCatalogId", productCategoryId).filterByDate().queryList(); } if (UtilValidate.isNotEmpty(childOfCats)) { @@ -481,11 +478,10 @@ public class CategoryServices { List<GenericValue> childList = null; // Get the child list of chosen category - childList = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap( - "parentProductCategoryId", catId), null, false)); + childList = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", catId).filterByDate().queryList(); // Get the chosen category information for the categoryContentWrapper - GenericValue cate = delegator.findOne("ProductCategory" ,UtilMisc.toMap("productCategoryId",catId), false); + GenericValue cate = EntityQuery.use(delegator).from("ProductCategory").where("productCategoryId",catId).queryOne(); // If chosen category's child exists, then put the arrow before category icon if (UtilValidate.isNotEmpty(childList)) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryWorker.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/category/CategoryWorker.java Mon Nov 24 10:06:26 2014 @@ -90,7 +90,7 @@ public class CategoryWorker { Collection<GenericValue> results = FastList.newInstance(); try { - Collection<GenericValue> allCategories = delegator.findList("ProductCategory", null, null, null, null, false); + Collection<GenericValue> allCategories = EntityQuery.use(delegator).from("ProductCategory").queryList(); for (GenericValue curCat: allCategories) { Collection<GenericValue> parentCats = curCat.getRelated("CurrentProductCategoryRollup", null, null, true); @@ -148,9 +148,7 @@ public class CategoryWorker { List<GenericValue> rollups = null; try { - rollups = delegator.findByAnd("ProductCategoryRollup", - UtilMisc.toMap("parentProductCategoryId", parentId), - UtilMisc.toList("sequenceNum"), true); + rollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", parentId).orderBy("sequenceNum").cache(true).queryList(); if (limitView) { rollups = EntityUtil.filterByDate(rollups, true); } @@ -213,7 +211,7 @@ public class CategoryWorker { Delegator delegator = category.getDelegator(); long count = 0; try { - count = delegator.findCountByCondition("ProductCategoryMember", buildCountCondition("productCategoryId", category.getString("productCategoryId")), null, null); + count = EntityQuery.use(delegator).from("ProductCategoryMember").where("productCategoryId", category.getString("productCategoryId")).queryCount(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -225,7 +223,7 @@ public class CategoryWorker { Delegator delegator = category.getDelegator(); long count = 0; try { - count = delegator.findCountByCondition("ProductCategoryRollup", buildCountCondition("parentProductCategoryId", category.getString("productCategoryId")), null, null); + count = EntityQuery.use(delegator).from("ProductCategoryRollup").where("parentProductCategoryId", category.getString("productCategoryId")).queryCount(); } catch (GenericEntityException e) { Debug.logError(e, module); } @@ -363,8 +361,11 @@ public class CategoryWorker { if (productCategoryId == null) return false; if (UtilValidate.isEmpty(productId)) return false; - List<GenericValue> productCategoryMembers = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryMember", - UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId), null, true), true); + List<GenericValue> productCategoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember") + .where("productCategoryId", productCategoryId, "productId", productId) + .cache(true) + .filterByDate() + .queryList(); 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 = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne(); @@ -451,8 +452,7 @@ public class CategoryWorker { List<EntityCondition> rolllupConds = FastList.newInstance(); rolllupConds.add(EntityCondition.makeCondition("productCategoryId", parentProductCategoryId)); rolllupConds.add(EntityUtil.getFilterByDateExpr()); - List<GenericValue> productCategoryRollups = delegator.findList("ProductCategoryRollup", - EntityCondition.makeCondition(rolllupConds), null, UtilMisc.toList("sequenceNum"), null, true); + List<GenericValue> productCategoryRollups = EntityQuery.use(delegator).from("ProductCategoryRollup").where(rolllupConds).orderBy("sequenceNum").cache(true).queryList(); if (UtilValidate.isNotEmpty(productCategoryRollups)) { // add only categories that belong to the top category to trail for (GenericValue productCategoryRollup : productCategoryRollups) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java Mon Nov 24 10:06:26 2014 @@ -162,9 +162,12 @@ public class ProductConfigItemContentWra } } - List<GenericValue> productConfigItemContentList = delegator.findByAnd("ProdConfItemContent", UtilMisc.toMap("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId), UtilMisc.toList("-fromDate"), true); - productConfigItemContentList = EntityUtil.filterByDate(productConfigItemContentList); - GenericValue productConfigItemContent = EntityUtil.getFirst(productConfigItemContentList); + GenericValue productConfigItemContent = EntityQuery.use(delegator).from("ProdConfItemContent") + .where("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId) + .orderBy("-fromDate") + .cache(true) + .filterByDate() + .queryFirst(); if (productConfigItemContent != null) { // when rendering the product config item content, always include the ProductConfigItem and ProdConfItemContent records that this comes from Map<String, Object> inContext = FastMap.newInstance(); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java Mon Nov 24 10:06:26 2014 @@ -22,6 +22,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Enumeration; + import javax.servlet.http.HttpServletRequest; import javolution.util.FastList; @@ -35,6 +36,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.product.catalog.CatalogWorker; import org.ofbiz.product.config.ProductConfigWrapper.ConfigItem; import org.ofbiz.product.config.ProductConfigWrapper.ConfigOption; @@ -210,7 +212,7 @@ public class ProductConfigWorker { configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); try { - List<GenericValue> configs = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configItemId",configItemId,"sequenceNum", sequenceNum), null, false); + List<GenericValue> configs = EntityQuery.use(delegator).from("ProductConfigConfig").where("configItemId",configItemId,"sequenceNum", sequenceNum).queryList(); for (GenericValue productConfigConfig: configs) { for (ConfigOption oneOption: selectedOptions) { String configOptionId = oneOption.configOption.getString("configOptionId"); @@ -233,9 +235,9 @@ public class ProductConfigWorker { for (GenericValue productConfigConfig: configsToCheck) { String tempConfigId = productConfigConfig.getString("configId"); try { - List<GenericValue> tempResult = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId",tempConfigId), null, false); + List<GenericValue> tempResult = EntityQuery.use(delegator).from("ProductConfigConfig").where("configId",tempConfigId).queryList(); if (tempResult.size() == selectedOptionSize && configsToCheck.containsAll(tempResult)) { - List<GenericValue> configOptionProductOptions = delegator.findByAnd("ConfigOptionProductOption", UtilMisc.toMap("configId",tempConfigId), null, false); + List<GenericValue> configOptionProductOptions = EntityQuery.use(delegator).from("ConfigOptionProductOption").where("configId",tempConfigId).queryList(); if (UtilValidate.isNotEmpty(configOptionProductOptions)) { // check for variant product equality Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java?rev=1641348&r1=1641347&r2=1641348&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java Mon Nov 24 10:06:26 2014 @@ -125,8 +125,7 @@ public class ProductConfigWrapper implem } questions = FastList.newInstance(); if ("AGGREGATED".equals(product.getString("productTypeId")) || "AGGREGATED_SERVICE".equals(product.getString("productTypeId"))) { - List<GenericValue> questionsValues = delegator.findByAnd("ProductConfig", UtilMisc.toMap("productId", productId), UtilMisc.toList("sequenceNum"), false); - questionsValues = EntityUtil.filterByDate(questionsValues); + List<GenericValue> questionsValues = EntityQuery.use(delegator).from("ProductConfig").where("productId", productId).orderBy("sequenceNum").filterByDate().queryList(); Set<String> itemIds = FastSet.newInstance(); for (GenericValue questionsValue: questionsValues) { ConfigItem oneQuestion = new ConfigItem(questionsValue); @@ -137,7 +136,7 @@ public class ProductConfigWrapper implem itemIds.add(oneQuestion.getConfigItem().getString("configItemId")); } questions.add(oneQuestion); - List<GenericValue> configOptions = delegator.findByAnd("ProductConfigOption", UtilMisc.toMap("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")), UtilMisc.toList("sequenceNum"), false); + List<GenericValue> configOptions = EntityQuery.use(delegator).from("ProductConfigOption").where("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")).orderBy("sequenceNum").queryList(); for (GenericValue configOption: configOptions) { ConfigOption option = new ConfigOption(delegator, dispatcher, configOption, oneQuestion, catalogId, webSiteId, currencyUomId, autoUserLogin); oneQuestion.addOption(option); @@ -151,7 +150,7 @@ public class ProductConfigWrapper implem //configure ProductConfigWrapper according to ProductConfigConfig entity if (UtilValidate.isNotEmpty(configId)) { this.configId = configId; - List<GenericValue> productConfigConfig = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId", configId), null, false); + List<GenericValue> productConfigConfig = EntityQuery.use(delegator).from("ProductConfigConfig").where("configId", configId).queryList(); if (UtilValidate.isNotEmpty(productConfigConfig)) { for (GenericValue pcc: productConfigConfig) { String configItemId = pcc.getString("configItemId"); |
Free forum by Nabble | Edit this page |