Applied party component patch from jira issue - OFBIZ-5844 - Convert java files to EntityQuery.
Thanks Arun for the contribution. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1641043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+26
-29
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -232,8 +232,12 @@ public class PartyContentWrapper implements ContentWrapper {
|
||||
}
|
||||
|
||||
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 implements ContentWrapper {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.ofbiz.entity.util.EntityListIterator;
|
||||
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(
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user