You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2021/04/08 09:51:39 UTC
[ofbiz-framework] 01/02: Fixed: Service calls of
"createPartyContactMech" now include the needed contactMechTypeId
(OFBIZ-12175) (#292)
This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch release17.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit 8ef589607710368d7657c8e0a3285fe2e681abcf
Author: bjugl <61...@users.noreply.github.com>
AuthorDate: Thu Apr 8 11:05:38 2021 +0200
Fixed: Service calls of "createPartyContactMech" now include the needed contactMechTypeId (OFBIZ-12175) (#292)
This was broken by OFBIZ-8358 where, as well explained at OFBIZ-12175,
"createPartyContactMech Service has been changed to expect an
OUT contactMechTypeId paramter and the call on this end has not been modified."
Conflicts handled by hand in PartyServices.java
I let the changes coming from trunk, too much to revert by hand
---
.../apache/ofbiz/party/party/PartyServices.java | 816 +++++++++++----------
1 file changed, 442 insertions(+), 374 deletions(-)
diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
index 7b0442e..460a3bd 100644
--- a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
+++ b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
@@ -67,9 +67,9 @@ import org.apache.ofbiz.service.ServiceUtil;
*/
public class PartyServices {
- public static final String module = PartyServices.class.getName();
- public static final String resource = "PartyUiLabels";
- public static final String resourceError = "PartyErrorUiLabels";
+ private static final String MODULE = PartyServices.class.getName();
+ private static final String RESOURCE = "PartyUiLabels";
+ private static final String RES_ERROR = "PartyErrorUiLabels";
/**
* Creates a Person.
@@ -92,7 +92,7 @@ public class PartyServices {
// if specified partyId starts with a number, return an error
if (UtilValidate.isNotEmpty(partyId) && partyId.matches("\\d+")) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"party.id_is_digit", locale));
}
@@ -101,7 +101,7 @@ public class PartyServices {
try {
partyId = delegator.getNextSeqId("Party");
} catch (IllegalArgumentException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"party.id_generation_failure", locale));
}
}
@@ -112,12 +112,12 @@ public class PartyServices {
try {
party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();
} catch (GenericEntityException e) {
- Debug.logWarning(e.getMessage(), module);
+ Debug.logWarning(e.getMessage(), MODULE);
}
if (party != null) {
if (!"PERSON".equals(party.getString("partyTypeId"))) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"person.create.party_exists_not_person_type", locale));
}
} else {
@@ -126,7 +126,8 @@ public class PartyServices {
if (statusId == null) {
statusId = "PARTY_ENABLED";
}
- Map<String, Object> newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", "PERSON", "description", description, "createdDate", now, "lastModifiedDate", now, "statusId", statusId);
+ Map<String, Object> newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", "PERSON", "description", description,
+ "createdDate", now, "lastModifiedDate", now, "statusId", statusId);
String preferredCurrencyUomId = (String) context.get("preferredCurrencyUomId");
if (UtilValidate.isNotEmpty(preferredCurrencyUomId)) {
newPartyMap.put("preferredCurrencyUomId", preferredCurrencyUomId);
@@ -156,11 +157,11 @@ public class PartyServices {
try {
person = EntityQuery.use(delegator).from("Person").where("partyId", partyId).queryOne();
} catch (GenericEntityException e) {
- Debug.logWarning(e.getMessage(), module);
+ Debug.logWarning(e.getMessage(), MODULE);
}
if (person != null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"person.create.person_exists", locale));
}
@@ -171,9 +172,9 @@ public class PartyServices {
try {
delegator.storeAll(toBeStored);
} catch (GenericEntityException e) {
- Debug.logWarning(e.getMessage(), module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
- "person.create.db_error", new Object[] { e.getMessage() }, locale));
+ Debug.logWarning(e.getMessage(), MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
+ "person.create.db_error", new Object[] {e.getMessage() }, locale));
}
result.put("partyId", partyId);
@@ -207,24 +208,22 @@ public class PartyServices {
party.set("statusId", statusId);
oldStatusId = party.getString("statusId");
} else {
-
- // check that status is defined as a valid change
- GenericValue statusValidChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId", party.getString("statusId"), "statusIdTo", statusId).queryOne();
- if (statusValidChange == null) {
- String errorMsg = "Cannot change party status from " + party.getString("statusId") + " to " + statusId;
- Debug.logWarning(errorMsg, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
- "PartyStatusCannotBeChanged",
- UtilMisc.toMap("partyFromStatusId", party.getString("statusId"),
- "partyToStatusId", statusId), locale));
- }
-
- party.set("statusId", statusId);
+ // check that status is defined as a valid change
+ GenericValue statusValidChange = EntityQuery.use(delegator).from("StatusValidChange").where("statusId",
+ party.getString("statusId"), "statusIdTo", statusId).queryOne();
+ if (statusValidChange == null) {
+ String errorMsg = "Cannot change party status from " + party.getString("statusId") + " to " + statusId;
+ Debug.logWarning(errorMsg, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "PartyStatusCannotBeChanged",
+ UtilMisc.toMap("partyFromStatusId", party.getString("statusId"), "partyToStatusId", statusId), locale));
+ }
+ party.set("statusId", statusId);
}
party.store();
// record this status change in PartyStatus table
- GenericValue partyStatus = delegator.makeValue("PartyStatus", UtilMisc.toMap("partyId", partyId, "statusId", statusId, "statusDate", statusDate));
+ GenericValue partyStatus = delegator.makeValue("PartyStatus", UtilMisc.toMap("partyId", partyId, "statusId", statusId,
+ "statusDate", statusDate));
if (loggedInUserLogin != null) {
partyStatus.put("changeByUserLoginId", loggedInUserLogin.get("userLoginId"));
}
@@ -234,9 +233,8 @@ public class PartyServices {
if (("PARTY_DISABLED").equals(statusId)) {
EntityCondition cond = EntityCondition.makeCondition(
EntityCondition.makeCondition("partyId", partyId),
- EntityCondition.makeCondition("enabled", EntityOperator.NOT_EQUAL, "N")
- );
- List <GenericValue> userLogins = EntityQuery.use(delegator).from("UserLogin").where(cond).queryList();
+ EntityCondition.makeCondition("enabled", EntityOperator.NOT_EQUAL, "N"));
+ List<GenericValue> userLogins = EntityQuery.use(delegator).from("UserLogin").where(cond).queryList();
for (GenericValue userLogin : userLogins) {
userLogin.set("enabled", "N");
userLogin.set("disabledDateTime", UtilDateTime.nowTimestamp());
@@ -249,9 +247,9 @@ public class PartyServices {
results.put("oldStatusId", oldStatusId);
return results;
} catch (GenericEntityException e) {
- Debug.logError(e, e.getMessage(), module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
- "person.update.write_failure", new Object[] { e.getMessage() }, locale));
+ Debug.logError(e, e.getMessage(), MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
+ "person.update.write_failure", new Object[] {e.getMessage() }, locale));
}
}
@@ -280,13 +278,13 @@ public class PartyServices {
person = EntityQuery.use(delegator).from("Person").where("partyId", partyId).queryOne();
party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();
} catch (GenericEntityException e) {
- Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
- "person.update.read_failure", new Object[] { e.getMessage() }, locale));
+ Debug.logWarning(e, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
+ "person.update.read_failure", new Object[] {e.getMessage() }, locale));
}
if (person == null || party == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"person.update.not_found", locale));
}
@@ -305,24 +303,28 @@ public class PartyServices {
person.store();
party.store();
} catch (GenericEntityException e) {
- Debug.logWarning(e.getMessage(), module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
- "person.update.write_failure", new Object[] { e.getMessage() }, locale));
+ Debug.logWarning(e.getMessage(), MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
+ "person.update.write_failure", new Object[] {e.getMessage() }, locale));
}
if (UtilValidate.isNotEmpty(context.get("statusId")) && !context.get("statusId").equals(oldStatusId)) {
try {
- dispatcher.runSync("setPartyStatus", UtilMisc.toMap("partyId", partyId, "statusId", context.get("statusId"), "userLogin", context.get("userLogin")));
+ Map<String, Object> serviceResult = dispatcher.runSync("setPartyStatus", UtilMisc.toMap("partyId", partyId, "statusId",
+ context.get("statusId"), "userLogin", context.get("userLogin")));
+ if (ServiceUtil.isError(serviceResult)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
+ }
} catch (GenericServiceException e) {
- Debug.logWarning(e.getMessage(), module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
- "person.update.write_failure", new Object[] { e.getMessage() }, locale));
+ Debug.logWarning(e.getMessage(), MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
+ "person.update.write_failure", new Object[] {e.getMessage() }, locale));
}
}
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
result.put(ModelService.SUCCESS_MESSAGE,
- UtilProperties.getMessage(resourceError, "person.update.success", locale));
+ UtilProperties.getMessage(RES_ERROR, "person.update.success", locale));
return result;
}
@@ -347,13 +349,13 @@ public class PartyServices {
try {
partyId = delegator.getNextSeqId("Party");
} catch (IllegalArgumentException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_create_party_group_generation_failure", locale));
}
} else {
// if specified partyId starts with a number, return an error
if (partyId.matches("\\d+")) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_create_party_ID_digit", locale));
}
}
@@ -364,7 +366,7 @@ public class PartyServices {
GenericValue partyGroupPartyType = EntityQuery.use(delegator).from("PartyType").where("partyTypeId", "PARTY_GROUP").cache().queryOne();
if (partyGroupPartyType == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.partyservices.party_type_not_found_in_database_cannot_create_party_group", locale));
}
@@ -372,7 +374,7 @@ public class PartyServices {
GenericValue partyType = party.getRelatedOne("PartyType", true);
if (!EntityTypeUtil.isType(partyType, partyGroupPartyType)) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.partyservices.cannot_create_party_group_already_exists_not_PARTY_GROUP_type", locale));
}
} else {
@@ -380,16 +382,18 @@ public class PartyServices {
String partyTypeId = "PARTY_GROUP";
if (UtilValidate.isNotEmpty(context.get("partyTypeId"))) {
- GenericValue desiredPartyType = EntityQuery.use(delegator).from("PartyType").where("partyTypeId", context.get("partyTypeId")).cache().queryOne();
+ GenericValue desiredPartyType = EntityQuery.use(delegator).from("PartyType").where("partyTypeId", context.get("partyTypeId"))
+ .cache().queryOne();
if (desiredPartyType != null && EntityTypeUtil.isType(desiredPartyType, partyGroupPartyType)) {
partyTypeId = desiredPartyType.getString("partyTypeId");
} else {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyPartyTypeIdNotFound", UtilMisc.toMap("partyTypeId", context.get("partyTypeId")), locale));
}
}
- Map<String, Object> newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", partyTypeId, "createdDate", now, "lastModifiedDate", now);
+ Map<String, Object> newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", partyTypeId, "createdDate", now,
+ "lastModifiedDate", now);
if (userLogin != null) {
newPartyMap.put("createdByUserLogin", userLogin.get("userLoginId"));
newPartyMap.put("lastModifiedByUserLogin", userLogin.get("userLoginId"));
@@ -416,7 +420,7 @@ public class PartyServices {
GenericValue partyGroup = EntityQuery.use(delegator).from("PartyGroup").where("partyId", partyId).queryOne();
if (partyGroup != null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_create_party_group_already_exists", locale));
}
@@ -425,8 +429,8 @@ public class PartyServices {
partyGroup.create();
} catch (GenericEntityException e) {
- Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ Debug.logWarning(e, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.data_source_error_adding_party_group",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
@@ -461,14 +465,14 @@ public class PartyServices {
partyGroup = EntityQuery.use(delegator).from("PartyGroup").where("partyId", partyId).queryOne();
party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();
} catch (GenericEntityException e) {
- Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ Debug.logWarning(e, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_update_party_information_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
if (partyGroup == null || party == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_update_party_information_not_found", locale));
}
@@ -483,19 +487,23 @@ public class PartyServices {
partyGroup.store();
party.store();
} catch (GenericEntityException e) {
- Debug.logWarning(e.getMessage(), module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ Debug.logWarning(e.getMessage(), MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_update_party_information_write",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
if (UtilValidate.isNotEmpty(context.get("statusId")) && !context.get("statusId").equals(oldStatusId)) {
try {
- dispatcher.runSync("setPartyStatus", UtilMisc.toMap("partyId", partyId, "statusId", context.get("statusId"), "userLogin", context.get("userLogin")));
+ Map<String, Object> serviceResult = dispatcher.runSync("setPartyStatus", UtilMisc.toMap("partyId", partyId,
+ "statusId", context.get("statusId"), "userLogin", context.get("userLogin")));
+ if (ServiceUtil.isError(serviceResult)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
+ }
} catch (GenericServiceException e) {
- Debug.logWarning(e.getMessage(), module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
- "person.update.write_failure", new Object[] { e.getMessage() }, locale));
+ Debug.logWarning(e.getMessage(), MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
+ "person.update.write_failure", new Object[] {e.getMessage() }, locale));
}
}
@@ -519,7 +527,7 @@ public class PartyServices {
// if specified partyId starts with a number, return an error
if (UtilValidate.isNotEmpty(partyId) && partyId.matches("\\d+")) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_create_affiliate_digit", locale));
}
@@ -528,7 +536,7 @@ public class PartyServices {
try {
partyId = delegator.getNextSeqId("Party");
} catch (IllegalArgumentException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_create_affiliate_generation_failure", locale));
}
}
@@ -539,11 +547,11 @@ public class PartyServices {
try {
party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();
} catch (GenericEntityException e) {
- Debug.logWarning(e.getMessage(), module);
+ Debug.logWarning(e.getMessage(), MODULE);
}
if (party == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_create_affiliate_no_party_entity", locale));
}
@@ -552,11 +560,11 @@ public class PartyServices {
try {
affiliate = EntityQuery.use(delegator).from("Affiliate").where("partyId", partyId).queryOne();
} catch (GenericEntityException e) {
- Debug.logWarning(e.getMessage(), module);
+ Debug.logWarning(e.getMessage(), MODULE);
}
if (affiliate != null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_create_affiliate_ID_already_exists", locale));
}
@@ -567,8 +575,8 @@ public class PartyServices {
try {
delegator.create(affiliate);
} catch (GenericEntityException e) {
- Debug.logWarning(e.getMessage(), module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ Debug.logWarning(e.getMessage(), MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_add_affiliate_info_write",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
@@ -599,14 +607,14 @@ public class PartyServices {
try {
affiliate = EntityQuery.use(delegator).from("Affiliate").where("partyId", partyId).queryOne();
} catch (GenericEntityException e) {
- Debug.logWarning(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ Debug.logWarning(e, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_update_affiliate_information_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
if (affiliate == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_update_affiliate_information_not_found", locale));
}
@@ -615,7 +623,7 @@ public class PartyServices {
try {
affiliate.store();
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.could_not_update_affiliate_information_write",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
@@ -644,11 +652,11 @@ public class PartyServices {
try {
GenericValue value = EntityQuery.use(delegator).from("NoteData").where("noteId", noteId).queryOne();
if (value == null) {
- Debug.logError("ERROR: Note id does not exist for : " + noteId + ", autogenerating." , module);
+ Debug.logError("ERROR: Note id does not exist for : " + noteId + ", autogenerating.", MODULE);
noteId = null;
}
} catch (GenericEntityException e) {
- Debug.logError(e, "ERROR: Note id does not exist for : " + noteId + ", autogenerating." , module);
+ Debug.logError(e, "ERROR: Note id does not exist for : " + noteId + ", autogenerating.", MODULE);
noteId = null;
}
}
@@ -659,9 +667,12 @@ public class PartyServices {
try {
noteRes = dispatcher.runSync("createNote", UtilMisc.toMap("partyId", userLogin.getString("partyId"),
"note", noteString, "userLogin", userLogin, "locale", locale, "noteName", noteName));
+ if (ServiceUtil.isError(noteRes)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(noteRes));
+ }
} catch (GenericServiceException e) {
- Debug.logError(e, e.getMessage(), module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ Debug.logError(e, e.getMessage(), MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyNoteCreationError", UtilMisc.toMap("errorString", e.getMessage()), locale));
}
@@ -672,7 +683,7 @@ public class PartyServices {
noteId = (String) noteRes.get("noteId");
if (UtilValidate.isEmpty(noteId)) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.problem_creating_note_no_noteId_returned", locale));
}
}
@@ -685,14 +696,14 @@ public class PartyServices {
delegator.create(v);
} catch (GenericEntityException ee) {
- Debug.logError(ee, module);
+ Debug.logError(ee, MODULE);
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
- result.put(ModelService.ERROR_MESSAGE, UtilProperties.getMessage(resourceError,
+ result.put(ModelService.ERROR_MESSAGE, UtilProperties.getMessage(RES_ERROR,
"partyservices.problem_associating_note_with_party",
UtilMisc.toMap("errMessage", ee.getMessage()), locale));
}
result.put(ModelService.SUCCESS_MESSAGE,
- UtilProperties.getMessage(resource, "PartyNoteCreatedSuccessfully", locale));
+ UtilProperties.getMessage(RESOURCE, "PartyNoteCreatedSuccessfully", locale));
return result;
}
@@ -709,37 +720,37 @@ public class PartyServices {
String email = (String) context.get("email");
Locale locale = (Locale) context.get("locale");
- if (email.length() == 0) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ if (email.isEmpty()) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.required_parameter_email_cannot_be_empty", locale));
}
try {
List<GenericValue> c = EntityQuery.use(delegator).from("PartyAndContactMech")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase(Locale.getDefault()))))
- .orderBy("infoString")
- .filterByDate()
- .queryList();
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase(Locale.getDefault()))))
+ .orderBy("infoString").filterByDate().queryList();
if (Debug.verboseOn()) {
- Debug.logVerbose("List: " + c, module);
+ Debug.logVerbose("List: " + c, MODULE);
}
if (Debug.infoOn()) {
- Debug.logInfo("PartyFromEmail number found: " + c.size(), module);
+ Debug.logInfo("PartyFromEmail number found: " + c.size(), MODULE);
}
if (c != null) {
for (GenericValue pacm: c) {
- GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", pacm.get("partyId"), "partyTypeId", pacm.get("partyTypeId")));
+ GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", pacm.get("partyId"),
+ "partyTypeId", pacm.get("partyTypeId")));
parties.add(UtilMisc.<String, GenericValue>toMap("party", party));
}
}
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_get_party_entities_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
- if (parties.size() > 0) {
+ if (!parties.isEmpty()) {
result.put("parties", parties);
}
return result;
@@ -752,37 +763,37 @@ public class PartyServices {
String email = (String) context.get("email");
Locale locale = (Locale) context.get("locale");
- if (email.length() == 0) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ if (email.isEmpty()) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.required_parameter_email_cannot_be_empty", locale));
}
try {
List<GenericValue> c = EntityQuery.use(delegator).from("PartyAndContactMech")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER(("%" + email.toUpperCase(Locale.getDefault())) + "%")))
- .orderBy("infoString")
- .filterByDate()
- .queryList();
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE,
+ EntityFunction.UPPER(("%" + email.toUpperCase(Locale.getDefault())) + "%")))
+ .orderBy("infoString").filterByDate().queryList();
if (Debug.verboseOn()) {
- Debug.logVerbose("List: " + c, module);
+ Debug.logVerbose("List: " + c, MODULE);
}
if (Debug.infoOn()) {
- Debug.logInfo("PartyFromEmail number found: " + c.size(), module);
+ Debug.logInfo("PartyFromEmail number found: " + c.size(), MODULE);
}
if (c != null) {
for (GenericValue pacm: c) {
- GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", pacm.get("partyId"), "partyTypeId", pacm.get("partyTypeId")));
+ GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", pacm.get("partyId"),
+ "partyTypeId", pacm.get("partyTypeId")));
parties.add(UtilMisc.<String, GenericValue>toMap("party", party));
}
}
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_get_party_entities_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
- if (parties.size() > 0) {
+ if (!parties.isEmpty()) {
result.put("parties", parties);
}
return result;
@@ -795,39 +806,38 @@ public class PartyServices {
* @return Map with the result of the service, the output parameters.
*/
public static Map<String, Object> getPartiesFromPartOfUserloginId(DispatchContext dctx, Map<String, ? extends Object> context) {
- Debug.logWarning("Running the getPartiesFromPartOfUserloginId Service...", module);
+ Debug.logWarning("Running the getPartiesFromPartOfUserloginId Service...", MODULE);
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
Collection<Map<String, GenericValue>> parties = new LinkedList<>();
String userLoginId = (String) context.get("userLoginId");
Locale locale = (Locale) context.get("locale");
- if (userLoginId.length() == 0) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ if (userLoginId.isEmpty()) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyCannotGetUserLoginFromParty", locale));
}
try {
Collection<GenericValue> ulc = EntityQuery.use(delegator).from("PartyAndUserLogin")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId.toUpperCase(Locale.getDefault()) + "%")))
- .orderBy("userLoginId")
- .queryList();
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + userLoginId.toUpperCase(Locale.getDefault()) + "%"))).orderBy("userLoginId").queryList();
if (Debug.verboseOn()) {
- Debug.logVerbose("Collection: " + ulc, module);
+ Debug.logVerbose("Collection: " + ulc, MODULE);
}
if (Debug.infoOn()) {
- Debug.logInfo("PartyFromUserLogin number found: " + ulc.size(), module);
+ Debug.logInfo("PartyFromUserLogin number found: " + ulc.size(), MODULE);
}
if (ulc != null) {
for (GenericValue ul: ulc) {
- GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", ul.get("partyId"), "partyTypeId", ul.get("partyTypeId")));
-
+ GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", ul.get("partyId"),
+ "partyTypeId", ul.get("partyTypeId")));
parties.add(UtilMisc.<String, GenericValue>toMap("party", party));
}
}
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_get_party_entities_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
@@ -857,8 +867,8 @@ public class PartyServices {
if (lastName == null) {
lastName = "";
}
- if (firstName.length() == 0 && lastName.length() == 0) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ if (firstName.isEmpty() && lastName.isEmpty()) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.both_names_cannot_be_empty", locale));
}
@@ -868,24 +878,26 @@ public class PartyServices {
EntityFunction.UPPER("%" + firstName.toUpperCase(Locale.getDefault()) + "%")),
EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE,
EntityFunction.UPPER("%" + lastName.toUpperCase(Locale.getDefault()) + "%")));
- Collection<GenericValue> pc = EntityQuery.use(delegator).from("Person").where(ecl).orderBy("lastName", "firstName", "partyId").queryList();
+ 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);
+ Debug.logInfo("PartyFromPerson number found: " + pc.size(), MODULE);
}
if (pc != null) {
for (GenericValue person: pc) {
- GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", person.get("partyId"), "partyTypeId", "PERSON"));
+ GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId",
+ person.get("partyId"), "partyTypeId", "PERSON"));
parties.add(UtilMisc.<String, GenericValue>toMap("person", person, "party", party));
}
}
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_get_party_entities_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
- if (parties.size() > 0) {
+ if (!parties.isEmpty()) {
result.put("parties", parties);
}
return result;
@@ -904,33 +916,35 @@ public class PartyServices {
String groupName = (String) context.get("groupName");
Locale locale = (Locale) context.get("locale");
- if (groupName.length() == 0) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ if (groupName.isEmpty()) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyCannotgetPartiesFromPartyGroup", locale));
}
try {
Collection<GenericValue> pc = EntityQuery.use(delegator).from("PartyGroup")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName.toUpperCase(Locale.getDefault()) + "%")))
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + groupName.toUpperCase(Locale.getDefault()) + "%")))
.orderBy("groupName", "partyId")
.queryList();
if (Debug.infoOn()) {
- Debug.logInfo("PartyFromGroup number found: " + pc.size(), module);
+ Debug.logInfo("PartyFromGroup number found: " + pc.size(), MODULE);
}
if (pc != null) {
for (GenericValue group: pc) {
- GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", group.get("partyId"), "partyTypeId", "PARTY_GROUP"));
+ GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId",
+ group.get("partyId"), "partyTypeId", "PARTY_GROUP"));
parties.add(UtilMisc.<String, GenericValue>toMap("partyGroup", group, "party", party));
}
}
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_get_party_entities_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
- if (parties.size() > 0) {
+ if (!parties.isEmpty()) {
result.put("parties", parties);
}
return result;
@@ -951,11 +965,12 @@ public class PartyServices {
try {
parties = EntityQuery.use(delegator).from("Party")
- .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("externalId"), EntityOperator.EQUALS, EntityFunction.UPPER(externalId)))
+ .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("externalId"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(externalId)))
.orderBy("externalId", "partyId")
.queryList();
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_get_party_entities_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
@@ -973,7 +988,7 @@ public class PartyServices {
try {
person = EntityQuery.use(delegator).from("Person").where("partyId", partyId).cache().queryOne();
} catch (GenericEntityException e) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR,
"partyservices.cannot_get_party_entities_read",
UtilMisc.toMap("errMessage", e.getMessage()), locale));
}
@@ -983,29 +998,6 @@ public class PartyServices {
return result;
}
- public static Map<String, Object> createRoleType(DispatchContext dctx, Map<String, ? extends Object> context) {
- Map<String, Object> result = new HashMap<>();
- Delegator delegator = dctx.getDelegator();
- Locale locale = (Locale) context.get("locale");
- GenericValue roleType = null;
-
- try {
- roleType = delegator.makeValue("RoleType");
- roleType.setPKFields(context);
- roleType.setNonPKFields(context);
- roleType = delegator.create(roleType);
- } catch (GenericEntityException e) {
- Debug.logError(e, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
- "PartyCannotCreateRoleTypeEntity",
- UtilMisc.toMap("errMessage", e.getMessage()), locale));
- }
- if (roleType != null) {
- result.put("roleType", roleType);
- }
- return result;
- }
-
@Deprecated // migration from ftl to widget in process.
public static Map<String, Object> findParty(DispatchContext dctx, Map<String, ? extends Object> context) {
Map<String, Object> result = ServiceUtil.returnSuccess();
@@ -1021,8 +1013,8 @@ public class PartyServices {
result.put("roleTypes", roleTypes);
} catch (GenericEntityException e) {
String errMsg = "Error looking up RoleTypes: " + e.toString();
- Debug.logError(e, errMsg, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ Debug.logError(e, errMsg, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyLookupRoleTypeError",
UtilMisc.toMap("errMessage", e.toString()), locale));
}
@@ -1037,8 +1029,8 @@ public class PartyServices {
}
} catch (GenericEntityException e) {
String errMsg = "Error looking up current RoleType: " + e.toString();
- Debug.logError(e, errMsg, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ Debug.logError(e, errMsg, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyLookupRoleTypeError",
UtilMisc.toMap("errMessage", e.toString()), locale));
}
@@ -1049,8 +1041,8 @@ public class PartyServices {
result.put("partyTypes", partyTypes);
} catch (GenericEntityException e) {
String errMsg = "Error looking up PartyTypes: " + e.toString();
- Debug.logError(e, errMsg, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ Debug.logError(e, errMsg, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyLookupPartyTypeError",
UtilMisc.toMap("errMessage", e.toString()), locale));
}
@@ -1065,8 +1057,8 @@ public class PartyServices {
}
} catch (GenericEntityException e) {
String errMsg = "Error looking up current PartyType: " + e.toString();
- Debug.logError(e, errMsg, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ Debug.logError(e, errMsg, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyLookupPartyTypeError",
UtilMisc.toMap("errMessage", e.toString()), locale));
}
@@ -1081,8 +1073,8 @@ public class PartyServices {
}
} catch (GenericEntityException e) {
String errMsg = "Error looking up current stateProvinceGeo: " + e.toString();
- Debug.logError(e, errMsg, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ Debug.logError(e, errMsg, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyLookupStateProvinceGeoError",
UtilMisc.toMap("errMessage", e.toString()), locale));
}
@@ -1094,7 +1086,7 @@ public class PartyServices {
} catch (Exception e) {
viewIndex = 0;
}
- result.put("viewIndex", Integer.valueOf(viewIndex));
+ result.put("viewIndex", viewIndex);
int viewSize = 20;
try {
@@ -1102,7 +1094,7 @@ public class PartyServices {
} catch (Exception e) {
viewSize = 20;
}
- result.put("viewSize", Integer.valueOf(viewSize));
+ result.put("viewSize", viewSize);
// get the lookup flag
String lookupFlag = (String) context.get("lookupFlag");
@@ -1158,7 +1150,8 @@ public class PartyServices {
if (UtilValidate.isEmpty(ownerPartyIds)) {
String partyIdFrom = userLogin.getString("partyId");
paramList = paramList + "&partyIdFrom=" + partyIdFrom;
- relationshipCond = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyIdFrom"), EntityOperator.EQUALS, EntityFunction.UPPER(partyIdFrom));
+ relationshipCond = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyIdFrom"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(partyIdFrom));
} else {
relationshipCond = EntityCondition.makeCondition("partyIdFrom", EntityOperator.IN, ownerPartyIds);
}
@@ -1166,7 +1159,8 @@ public class PartyServices {
// add the expr
andExprs.add(EntityCondition.makeCondition(
relationshipCond, EntityOperator.AND,
- EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyRelationshipTypeId"), EntityOperator.EQUALS, EntityFunction.UPPER(partyRelationshipTypeId))));
+ EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyRelationshipTypeId"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(partyRelationshipTypeId))));
fieldsToSelect.add("partyIdTo");
}
@@ -1182,7 +1176,8 @@ public class PartyServices {
// check for a partyId
if (UtilValidate.isNotEmpty(partyId)) {
paramList = paramList + "&partyId=" + partyId;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyId"), EntityOperator.LIKE, EntityFunction.UPPER("%"+partyId+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyId"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + partyId + "%")));
}
// now the statusId - send ANY for all statuses; leave null for just enabled; or pass a specific status
@@ -1193,12 +1188,14 @@ public class PartyServices {
}
} else {
// NOTE: _must_ explicitly allow null as it is not included in a not equal in many databases... odd but true
- andExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED")));
+ andExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, null),
+ EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED")));
}
// check for partyTypeId
if (partyTypeId != null && !"ANY".equals(partyTypeId)) {
paramList = paramList + "&partyTypeId=" + partyTypeId;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyTypeId"), EntityOperator.LIKE, EntityFunction.UPPER("%"+partyTypeId+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyTypeId"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + partyTypeId + "%")));
}
// ----
@@ -1215,7 +1212,8 @@ public class PartyServices {
dynamicView.addViewLink("PT", "UL", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%"+userLoginId+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId + "%")));
fieldsToSelect.add("userLoginId");
}
@@ -1234,7 +1232,8 @@ public class PartyServices {
dynamicView.addViewLink("PT", "PG", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+groupName+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName + "%")));
fieldsToSelect.add("groupName");
}
@@ -1259,13 +1258,15 @@ public class PartyServices {
// filter on firstName
if (UtilValidate.isNotEmpty(firstName)) {
paramList = paramList + "&firstName=" + firstName;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+firstName+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + firstName + "%")));
}
// filter on lastName
if (UtilValidate.isNotEmpty(lastName)) {
paramList = paramList + "&lastName=" + lastName;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+lastName+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + lastName + "%")));
}
// ----
@@ -1295,10 +1296,7 @@ public class PartyServices {
String inventoryItemId = (String) context.get("inventoryItemId");
String serialNumber = (String) context.get("serialNumber");
String softIdentifier = (String) context.get("softIdentifier");
- if (UtilValidate.isNotEmpty(inventoryItemId) ||
- UtilValidate.isNotEmpty(serialNumber) ||
- UtilValidate.isNotEmpty(softIdentifier)) {
-
+ if (UtilValidate.isNotEmpty(inventoryItemId) || UtilValidate.isNotEmpty(serialNumber) || UtilValidate.isNotEmpty(softIdentifier)) {
// add role to view
dynamicView.addMemberEntity("II", "InventoryItem");
dynamicView.addAlias("II", "ownerPartyId");
@@ -1308,21 +1306,24 @@ public class PartyServices {
paramList = paramList + "&inventoryItemId=" + inventoryItemId;
dynamicView.addAlias("II", "inventoryItemId");
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("inventoryItemId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + inventoryItemId + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("inventoryItemId"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + inventoryItemId + "%")));
fieldsToSelect.add("inventoryItemId");
}
if (UtilValidate.isNotEmpty(serialNumber)) {
paramList = paramList + "&serialNumber=" + serialNumber;
dynamicView.addAlias("II", "serialNumber");
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("serialNumber"), EntityOperator.LIKE, EntityFunction.UPPER("%" + serialNumber + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("serialNumber"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + serialNumber + "%")));
fieldsToSelect.add("serialNumber");
}
if (UtilValidate.isNotEmpty(softIdentifier)) {
paramList = paramList + "&softIdentifier=" + softIdentifier;
dynamicView.addAlias("II", "softIdentifier");
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("softIdentifier"), EntityOperator.LIKE, EntityFunction.UPPER("%" + softIdentifier + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("softIdentifier"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + softIdentifier + "%")));
fieldsToSelect.add("softIdentifier");
}
@@ -1347,21 +1348,24 @@ public class PartyServices {
String address1 = (String) context.get("address1");
if (UtilValidate.isNotEmpty(address1)) {
paramList = paramList + "&address1=" + address1;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address1"), EntityOperator.LIKE, EntityFunction.UPPER("%" + address1 + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address1"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + address1 + "%")));
}
// filter on address2
String address2 = (String) context.get("address2");
if (UtilValidate.isNotEmpty(address2)) {
paramList = paramList + "&address2=" + address2;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address2"), EntityOperator.LIKE, EntityFunction.UPPER("%" + address2 + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address2"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + address2 + "%")));
}
// filter on city
String city = (String) context.get("city");
if (UtilValidate.isNotEmpty(city)) {
paramList = paramList + "&city=" + city;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("city"), EntityOperator.LIKE, EntityFunction.UPPER("%" + city + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("city"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + city + "%")));
}
// filter on state geo
@@ -1374,7 +1378,8 @@ public class PartyServices {
String postalCode = (String) context.get("postalCode");
if (UtilValidate.isNotEmpty(postalCode)) {
paramList = paramList + "&postalCode=" + postalCode;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("postalCode"), EntityOperator.LIKE, EntityFunction.UPPER("%" + postalCode + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("postalCode"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + postalCode + "%")));
}
fieldsToSelect.add("postalCode");
@@ -1398,7 +1403,8 @@ public class PartyServices {
String infoString = (String) context.get("infoString");
if (UtilValidate.isNotEmpty(infoString)) {
paramList = paramList + "&infoString=" + infoString;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER("%"+infoString+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"),
+ EntityOperator.LIKE, EntityFunction.UPPER("%" + infoString + "%")));
fieldsToSelect.add("infoString");
}
@@ -1422,21 +1428,24 @@ public class PartyServices {
String countryCode = (String) context.get("countryCode");
if (UtilValidate.isNotEmpty(countryCode)) {
paramList = paramList + "&countryCode=" + countryCode;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("countryCode"), EntityOperator.EQUALS, EntityFunction.UPPER(countryCode)));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("countryCode"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(countryCode)));
}
// filter on areaCode
String areaCode = (String) context.get("areaCode");
if (UtilValidate.isNotEmpty(areaCode)) {
paramList = paramList + "&areaCode=" + areaCode;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("areaCode"), EntityOperator.EQUALS, EntityFunction.UPPER(areaCode)));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("areaCode"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(areaCode)));
}
// filter on contact number
String contactNumber = (String) context.get("contactNumber");
if (UtilValidate.isNotEmpty(contactNumber)) {
paramList = paramList + "&contactNumber=" + contactNumber;
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("contactNumber"), EntityOperator.EQUALS, EntityFunction.UPPER(contactNumber)));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("contactNumber"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(contactNumber)));
}
fieldsToSelect.add("contactNumber");
@@ -1446,15 +1455,15 @@ public class PartyServices {
// ---- End of Dynamic View Creation
// build the main condition
- if (andExprs.size() > 0) {
+ if (!andExprs.isEmpty()) {
mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
}
}
- Debug.logInfo("In findParty mainCond=" + mainCond, module);
+ Debug.logInfo("In findParty mainCond=" + mainCond, MODULE);
String sortField = (String) context.get("sortField");
- if(UtilValidate.isNotEmpty(sortField)){
+ if (UtilValidate.isNotEmpty(sortField)) {
orderBy.add(sortField);
}
@@ -1485,8 +1494,8 @@ public class PartyServices {
} catch (GenericEntityException e) {
String errMsg = "Failure in party find operation, rolling back transaction: " + e.toString();
- Debug.logError(e, errMsg, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ Debug.logError(e, errMsg, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyLookupPartyError",
UtilMisc.toMap("errMessage", e.toString()), locale));
}
@@ -1499,10 +1508,10 @@ public class PartyServices {
partyList = new LinkedList<>();
}
result.put("partyList", partyList);
- result.put("partyListSize", Integer.valueOf(partyListSize));
+ result.put("partyListSize", partyListSize);
result.put("paramList", paramList);
- result.put("highIndex", Integer.valueOf(highIndex));
- result.put("lowIndex", Integer.valueOf(lowIndex));
+ result.put("highIndex", highIndex);
+ result.put("lowIndex", lowIndex);
return result;
}
@@ -1539,7 +1548,7 @@ public class PartyServices {
List<String> orderBy = new ArrayList<>();
String sortField = (String) context.get("sortField");
- if(UtilValidate.isNotEmpty(sortField)){
+ if (UtilValidate.isNotEmpty(sortField)) {
orderBy.add(sortField);
}
List<String> fieldsToSelect = new ArrayList<>();
@@ -1563,7 +1572,8 @@ public class PartyServices {
EntityCondition relationshipCond = null;
if (UtilValidate.isEmpty(ownerPartyIds)) {
String partyIdFrom = userLogin.getString("partyId");
- relationshipCond = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyIdFrom"), EntityOperator.EQUALS, EntityFunction.UPPER(partyIdFrom));
+ relationshipCond = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyIdFrom"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(partyIdFrom));
} else {
relationshipCond = EntityCondition.makeCondition("partyIdFrom", EntityOperator.IN, ownerPartyIds);
}
@@ -1571,7 +1581,8 @@ public class PartyServices {
// add the expr
andExprs.add(EntityCondition.makeCondition(
relationshipCond, EntityOperator.AND,
- EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyRelationshipTypeId"), EntityOperator.EQUALS, EntityFunction.UPPER(partyRelationshipTypeId))));
+ EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyRelationshipTypeId"), EntityOperator.EQUALS,
+ EntityFunction.UPPER(partyRelationshipTypeId))));
fieldsToSelect.add("partyIdTo");
}
@@ -1588,7 +1599,8 @@ public class PartyServices {
// check for a partyId
if (UtilValidate.isNotEmpty(partyId)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyId"), EntityOperator.LIKE, EntityFunction.UPPER("%"+partyId+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyId"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + partyId + "%")));
}
// now the statusId - send ANY for all statuses; leave null for just enabled; or pass a specific status
@@ -1596,7 +1608,8 @@ public class PartyServices {
andExprs.add(EntityCondition.makeCondition("statusId", statusId));
} else {
// NOTE: _must_ explicitly allow null as it is not included in a not equal in many databases... odd but true
- andExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("statusId", GenericEntity.NULL_FIELD), EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED")));
+ andExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("statusId", GenericEntity.NULL_FIELD),
+ EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED")));
}
// check for partyTypeId
if (UtilValidate.isNotEmpty(partyTypeId)) {
@@ -1619,7 +1632,8 @@ public class PartyServices {
dynamicView.addViewLink("PT", "UL", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%"+userLoginId+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + userLoginId + "%")));
fieldsToSelect.add("userLoginId");
}
@@ -1636,7 +1650,8 @@ public class PartyServices {
dynamicView.addViewLink("PT", "PG", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+groupName+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + groupName + "%")));
fieldsToSelect.add("groupName");
}
@@ -1659,12 +1674,14 @@ public class PartyServices {
// filter on firstName
if (UtilValidate.isNotEmpty(firstName)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+firstName+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + firstName + "%")));
}
// filter on lastName
if (UtilValidate.isNotEmpty(lastName)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+lastName+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + lastName + "%")));
}
// ----
@@ -1688,7 +1705,7 @@ public class PartyServices {
// PartyClassificationGroup Fields
// ----
- List<String> partyClassificationGroupIds = (List) context.get("partyClassificationGroupId");
+ List<String> partyClassificationGroupIds = UtilGenerics.cast(context.get("partyClassificationGroupId"));
if (UtilValidate.isNotEmpty(partyClassificationGroupIds)) {
// add PartyClassification to view
dynamicView.addMemberEntity("PC", "PartyClassification");
@@ -1706,10 +1723,7 @@ public class PartyServices {
String idValue = (String) context.get("idValue");
String partyIdentificationTypeId = (String) context.get("partyIdentificationTypeId");
- if ("I".equals(extInfo) ||
- UtilValidate.isNotEmpty(idValue) ||
- UtilValidate.isNotEmpty(partyIdentificationTypeId)) {
-
+ if ("I".equals(extInfo) || UtilValidate.isNotEmpty(idValue) || UtilValidate.isNotEmpty(partyIdentificationTypeId)) {
// add role to view
dynamicView.addMemberEntity("PAI", "PartyIdentification");
dynamicView.addAlias("PAI", "idValue");
@@ -1718,7 +1732,8 @@ public class PartyServices {
fieldsToSelect.add("idValue");
fieldsToSelect.add("partyIdentificationTypeId");
if (UtilValidate.isNotEmpty(idValue)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("idValue"), EntityOperator.LIKE, EntityFunction.UPPER("%".concat(idValue).concat("%"))));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("idValue"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%".concat(idValue).concat("%"))));
}
if (UtilValidate.isNotEmpty(partyIdentificationTypeId)) {
andExprs.add(EntityCondition.makeCondition("partyIdentificationTypeId", partyIdentificationTypeId));
@@ -1733,9 +1748,9 @@ public class PartyServices {
String inventoryItemId = (String) context.get("inventoryItemId");
String serialNumber = (String) context.get("serialNumber");
String softIdentifier = (String) context.get("softIdentifier");
- if (UtilValidate.isNotEmpty(inventoryItemId) ||
- UtilValidate.isNotEmpty(serialNumber) ||
- UtilValidate.isNotEmpty(softIdentifier)) {
+ if (UtilValidate.isNotEmpty(inventoryItemId)
+ || UtilValidate.isNotEmpty(serialNumber)
+ || UtilValidate.isNotEmpty(softIdentifier)) {
// add role to view
dynamicView.addMemberEntity("II", "InventoryItem");
@@ -1745,19 +1760,22 @@ public class PartyServices {
if (UtilValidate.isNotEmpty(inventoryItemId)) {
dynamicView.addAlias("II", "inventoryItemId");
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("inventoryItemId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + inventoryItemId + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("inventoryItemId"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + inventoryItemId + "%")));
fieldsToSelect.add("inventoryItemId");
}
if (UtilValidate.isNotEmpty(serialNumber)) {
dynamicView.addAlias("II", "serialNumber");
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("serialNumber"), EntityOperator.LIKE, EntityFunction.UPPER("%" + serialNumber + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("serialNumber"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + serialNumber + "%")));
fieldsToSelect.add("serialNumber");
}
if (UtilValidate.isNotEmpty(softIdentifier)) {
dynamicView.addAlias("II", "softIdentifier");
// add the expr
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("softIdentifier"), EntityOperator.LIKE, EntityFunction.UPPER("%" + softIdentifier + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("softIdentifier"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + softIdentifier + "%")));
fieldsToSelect.add("softIdentifier");
}
@@ -1765,10 +1783,10 @@ public class PartyServices {
// PostalAddress fields
// ----
String stateProvinceGeoId = (String) context.get("stateProvinceGeoId");
- if ( "P".equals(extInfo) ||
- UtilValidate.isNotEmpty(context.get("address1"))|| UtilValidate.isNotEmpty(context.get("address2"))||
- UtilValidate.isNotEmpty(context.get("city"))|| UtilValidate.isNotEmpty(context.get("postalCode"))||
- UtilValidate.isNotEmpty(context.get("countryGeoId"))|| (UtilValidate.isNotEmpty(stateProvinceGeoId))) {
+ if ("P".equals(extInfo)
+ || UtilValidate.isNotEmpty(context.get("address1")) || UtilValidate.isNotEmpty(context.get("address2"))
+ || UtilValidate.isNotEmpty(context.get("city")) || UtilValidate.isNotEmpty(context.get("postalCode"))
+ || UtilValidate.isNotEmpty(context.get("countryGeoId")) || (UtilValidate.isNotEmpty(stateProvinceGeoId))) {
// add address to dynamic view
dynamicView.addMemberEntity("PC", "PartyContactMech");
dynamicView.addMemberEntity("PA", "PostalAddress");
@@ -1785,19 +1803,22 @@ public class PartyServices {
// filter on address1
String address1 = (String) context.get("address1");
if (UtilValidate.isNotEmpty(address1)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address1"), EntityOperator.LIKE, EntityFunction.UPPER("%" + address1 + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address1"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + address1 + "%")));
}
// filter on address2
String address2 = (String) context.get("address2");
if (UtilValidate.isNotEmpty(address2)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address2"), EntityOperator.LIKE, EntityFunction.UPPER("%" + address2 + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("address2"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + address2 + "%")));
}
// filter on city
String city = (String) context.get("city");
if (UtilValidate.isNotEmpty(city)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("city"), EntityOperator.LIKE, EntityFunction.UPPER("%" + city + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("city"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + city + "%")));
}
// filter on state geo
@@ -1808,7 +1829,8 @@ public class PartyServices {
// filter on postal code
String postalCode = (String) context.get("postalCode");
if (UtilValidate.isNotEmpty(postalCode)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("postalCode"), EntityOperator.LIKE, EntityFunction.UPPER("%" + postalCode + "%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("postalCode"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + postalCode + "%")));
}
fieldsToSelect.add("postalCode");
@@ -1831,7 +1853,8 @@ public class PartyServices {
// filter on infoString
String infoString = (String) context.get("infoString");
if (UtilValidate.isNotEmpty(infoString)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER("%"+infoString+"%")));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE,
+ EntityFunction.UPPER("%" + infoString + "%")));
fieldsToSelect.add("infoString");
}
}
@@ -1856,19 +1879,22 @@ public class PartyServices {
// filter on countryCode
String countryCode = (String) context.get("countryCode");
if (UtilValidate.isNotEmpty(countryCode)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("countryCode"), EntityOperator.EQUALS, EntityFunction.UPPER(countryCode)));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("countryCode"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(countryCode)));
}
// filter on areaCode
String areaCode = (String) context.get("areaCode");
if (UtilValidate.isNotEmpty(areaCode)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("areaCode"), EntityOperator.EQUALS, EntityFunction.UPPER(areaCode)));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("areaCode"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(areaCode)));
}
// filter on contact number
String contactNumber = (String) context.get("contactNumber");
if (UtilValidate.isNotEmpty(contactNumber)) {
- andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("contactNumber"), EntityOperator.EQUALS, EntityFunction.UPPER(contactNumber)));
+ andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("contactNumber"),
+ EntityOperator.EQUALS, EntityFunction.UPPER(contactNumber)));
}
fieldsToSelect.add("contactNumber");
fieldsToSelect.add("areaCode");
@@ -1883,12 +1909,12 @@ public class PartyServices {
mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
}
if (Debug.infoOn()) {
- Debug.logInfo("In findParty mainCond=" + mainCond, module);
+ Debug.logInfo("In findParty mainCond=" + mainCond, MODULE);
}
// do the lookup
- if (UtilValidate.isNotEmpty(noConditionFind) &&
- ("Y".equals(noConditionFind) || andExprs.size()>1)) { //exclude on condition the status expr
+ if (UtilValidate.isNotEmpty(noConditionFind) && ("Y".equals(noConditionFind) || andExprs.size() > 1)) {
+ //exclude on condition the status expr
try {
// set distinct on so we only get one row per party
// using list iterator
@@ -1901,8 +1927,8 @@ public class PartyServices {
.queryIterator();
} catch (GenericEntityException e) {
String errMsg = "Failure in party find operation, rolling back transaction: " + e.toString();
- Debug.logError(e, errMsg, module);
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ Debug.logError(e, errMsg, MODULE);
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyLookupPartyError",
UtilMisc.toMap("errMessage", e.toString()), locale));
}
@@ -1915,14 +1941,12 @@ public class PartyServices {
* Changes the association of contact mechs, purposes, notes, orders and attributes from
* one party to another for the purpose of merging records together. Flags the from party
* as disabled so it no longer appears in a search.
- *
* @param dctx the dispatch context
* @param context the context
* @return the result of the service execution
*/
public static Map<String, Object> linkParty(DispatchContext dctx, Map<String, ? extends Object> context) {
- Delegator _delegator = dctx.getDelegator();
- Delegator delegator = _delegator.cloneDelegator();
+ Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
delegator.setEntityEcaHandler(null);
@@ -1931,7 +1955,7 @@ public class PartyServices {
Timestamp now = UtilDateTime.nowTimestamp();
if (partyIdTo.equals(partyId)) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyCannotLinkPartyToItSelf", locale));
}
@@ -1940,15 +1964,15 @@ public class PartyServices {
try {
partyTo = EntityQuery.use(delegator).from("Party").where("partyId", partyIdTo).queryOne();
} catch (GenericEntityException e) {
- Debug.logInfo(e, module);
+ Debug.logInfo(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
if (partyTo == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyPartyToDoesNotExists", locale));
}
if ("PARTY_DISABLED".equals(partyTo.get("statusId"))) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyCannotMergeDisabledParty", locale));
}
@@ -1956,11 +1980,11 @@ public class PartyServices {
try {
party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();
} catch (GenericEntityException e) {
- Debug.logInfo(e, module);
+ Debug.logInfo(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
if (party == null) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyPartyFromDoesNotExists", locale));
}
@@ -1969,7 +1993,7 @@ public class PartyServices {
delegator.storeByCondition("PartyContactMech", UtilMisc.<String, Object>toMap("partyId", partyIdTo, "thruDate", now),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -1978,7 +2002,7 @@ public class PartyServices {
delegator.storeByCondition("PartyContactMechPurpose", UtilMisc.<String, Object>toMap("partyId", partyIdTo, "thruDate", now),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -1987,7 +2011,7 @@ public class PartyServices {
delegator.storeByCondition("PartyNote", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -1996,7 +2020,7 @@ public class PartyServices {
delegator.storeByCondition("InventoryItem", UtilMisc.toMap("ownerPartyId", partyIdTo),
EntityCondition.makeCondition("ownerPartyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2005,7 +2029,7 @@ public class PartyServices {
delegator.storeByCondition("Subscription", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2014,7 +2038,7 @@ public class PartyServices {
delegator.storeByCondition("UserLogin", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2023,7 +2047,7 @@ public class PartyServices {
try {
rolesToMove = EntityQuery.use(delegator).from("PartyRole").where("partyId", partyId).queryList();
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2034,7 +2058,7 @@ public class PartyServices {
attr.create();
}
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
}
@@ -2044,7 +2068,7 @@ public class PartyServices {
delegator.storeByCondition("OrderRole", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2053,16 +2077,16 @@ public class PartyServices {
delegator.storeByCondition("InvoiceRole", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
- // data resource role
+ // data RESOURCE role
try {
delegator.storeByCondition("DataResourceRole", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2071,7 +2095,7 @@ public class PartyServices {
delegator.storeByCondition("ContentRole", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2080,7 +2104,7 @@ public class PartyServices {
delegator.storeByCondition("FinAccountRole", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2089,7 +2113,7 @@ public class PartyServices {
delegator.storeByCondition("ProductStoreRole", UtilMisc.<String, Object>toMap("partyId", partyIdTo, "thruDate", now),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2098,7 +2122,7 @@ public class PartyServices {
delegator.storeByCondition("CommunicationEventRole", UtilMisc.toMap("partyId", partyIdTo),
EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2106,7 +2130,7 @@ public class PartyServices {
try {
delegator.removeByAnd("PartyRole", UtilMisc.toMap("partyId", partyId));
} catch (GenericEntityException e) {
- Debug.logWarning(e, module);
+ Debug.logWarning(e, MODULE);
// if this fails no problem
}
@@ -2115,7 +2139,7 @@ public class PartyServices {
try {
attrsToMove = EntityQuery.use(delegator).from("PartyAttribute").where("partyId", partyId).queryList();
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2126,14 +2150,14 @@ public class PartyServices {
attr.create();
}
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
}
try {
delegator.removeByAnd("PartyAttribute", UtilMisc.toMap("partyId", partyId));
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2145,7 +2169,7 @@ public class PartyServices {
try {
delegator.create(linkAttr);
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2157,7 +2181,7 @@ public class PartyServices {
try {
party.store();
} catch (GenericEntityException e) {
- Debug.logError(e, "Error setting disable mode on partyId: " + partyId, module);
+ Debug.logError(e, "Error setting disable mode on partyId: " + partyId, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
}
@@ -2181,7 +2205,7 @@ public class PartyServices {
String str = records[i].trim();
String[] map = str.split(",");
if (map.length != 2 && map.length != 3) {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyImportInvalidCsvFile", locale));
}
GenericValue addrMap = delegator.makeValue("AddressMatchMap");
@@ -2200,21 +2224,21 @@ public class PartyServices {
try {
seq = Integer.parseInt(map[2]);
} catch (Throwable t) {
- Debug.logWarning(t, "Unable to parse number", module);
+ Debug.logWarning(t, "Unable to parse number", MODULE);
}
}
}
- addrMap.put("sequenceNum", Long.valueOf(seq));
- Debug.logInfo("Creating map entry: " + addrMap, module);
+ addrMap.put("sequenceNum", (long) seq);
+ Debug.logInfo("Creating map entry: " + addrMap, MODULE);
try {
delegator.create(addrMap);
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
} else {
- return ServiceUtil.returnError(UtilProperties.getMessage(resource,
+ return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"PartyImportNoRecordsFoundInFile", locale));
}
}
@@ -2232,8 +2256,6 @@ public class PartyServices {
}
return partyId;
}
-
-
/**
* Finds partyId(s) corresponding to a party reference, partyId or a GoodIdentification idValue
* @param ctx the dispatch context
@@ -2248,14 +2270,14 @@ public class PartyServices {
String searchAllIdContext = (String) context.get("searchAllId");
boolean searchPartyFirst = UtilValidate.isNotEmpty(searchPartyFirstContext) && "N".equals(searchPartyFirstContext) ? false : true;
- boolean searchAllId = UtilValidate.isNotEmpty(searchAllIdContext)&& "Y".equals(searchAllIdContext) ? true : false;
+ boolean searchAllId = UtilValidate.isNotEmpty(searchAllIdContext) && "Y".equals(searchAllIdContext) ? true : false;
GenericValue party = null;
List<GenericValue> partiesFound = null;
try {
partiesFound = PartyWorker.findPartiesById(delegator, idToFind, partyIdentificationTypeId, searchPartyFirst, searchAllId);
} catch (GenericEntityException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -2281,7 +2303,6 @@ public class PartyServices {
ByteBuffer fileBytes = (ByteBuffer) context.get("uploadedFile");
String encoding = System.getProperty("file.encoding");
String csvString = Charset.forName(encoding).decode(fileBytes).toString();
- final BufferedReader csvReader = new BufferedReader(new StringReader(csvString));
CSVFormat fmt = CSVFormat.DEFAULT.withHeader();
List<String> errMsgs = new LinkedList<>();
List<String> newErrMsgs = new LinkedList<>();
@@ -2308,13 +2329,13 @@ public class PartyServices {
String lastContactMechPurposeTypeId = null;
String currentContactMechPurposeTypeId = null;
- Boolean addParty = false; // when modify party, contact mech not added again
+ boolean addParty = false; // when modify party, contact mech not added again
- try {
+ try (BufferedReader csvReader = new BufferedReader(new StringReader(csvString))) {
for (final CSVRecord rec : fmt.parse(csvReader)) {
if (UtilValidate.isNotEmpty(rec.get("partyId"))) {
- currentPartyId = rec.get("partyId");
+ currentPartyId = rec.get("partyId");
}
if (lastPartyId == null || !currentPartyId.equals(lastPartyId)) {
newPartyId = null;
@@ -2331,38 +2352,46 @@ public class PartyServices {
lastContactNumber = null;
// party validation
- List <GenericValue> currencyCheck = EntityQuery.use(delegator).from("Uom")
+ 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.isNotEmpty(rec.get("preferredCurrencyUomId")) && currencyCheck.isEmpty()) {
+ 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....");
+ newErrMsgs.add("Line number " + rec.getRecordNumber()
+ + ": Mandatory roletype is missing, possible values: CUSTOMER, SUPPLIER, EMPLOYEE and more....");
} 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") );
+ newErrMsgs.add("Line number " + rec.getRecordNumber() + ": RoletypeId is not valid: " + rec.get("roleTypeId"));
}
- if (UtilValidate.isNotEmpty(rec.get("contactMechTypeId")) &&
- EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", rec.get("contactMechTypeId")).cache().queryOne() == null) {
- newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + " contactMechTypeId code not found for: " + rec.get("contactMechTypeId"));
+ if (UtilValidate.isNotEmpty(rec.get("contactMechTypeId"))
+ && EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", rec.get("contactMechTypeId"))
+ .cache().queryOne() == null) {
+ newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId
+ + " contactMechTypeId code not found for: "
+ + rec.get("contactMechTypeId"));
}
- if (UtilValidate.isNotEmpty(rec.get("contactMechPurposeTypeId")) &&
- EntityQuery.use(delegator).from("ContactMechPurposeType").where("contactMechPurposeTypeId", rec.get("contactMechPurposeTypeId")).cache().queryOne() == null) {
- newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + "contactMechPurposeTypeId code not found for: " + rec.get("contactMechPurposeTypeId"));
+ if (UtilValidate.isNotEmpty(rec.get("contactMechPurposeTypeId"))
+ && EntityQuery.use(delegator).from("ContactMechPurposeType").where("contactMechPurposeTypeId",
+ rec.get("contactMechPurposeTypeId")).cache().queryOne() == null) {
+ newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId
+ + "contactMechPurposeTypeId code not found for: " + rec.get("contactMechPurposeTypeId"));
}
if (UtilValidate.isNotEmpty(rec.get("contactMechTypeId")) && "POSTAL_ADDRESS".equals(rec.get("contactMechTypeId"))) {
if (UtilValidate.isEmpty(rec.get("countryGeoId"))) {
newErrMsgs.add("Line number " + rec.getRecordNumber() + ": partyId: " + currentPartyId + "Country code missing");
} else {
- List <GenericValue> countryCheck = EntityQuery.use(delegator).from("Geo")
+ 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"));
+ if (countryCheck.isEmpty()) {
+ newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId + " Invalid Country code: "
+ + rec.get("countryGeoId"));
}
}
@@ -2371,11 +2400,12 @@ public class PartyServices {
}
if (UtilValidate.isNotEmpty(rec.get("stateProvinceGeoId"))) {
- List <GenericValue> stateCheck = EntityQuery.use(delegator).from("Geo")
+ 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"));
+ if (stateCheck.isEmpty()) {
+ newErrMsgs.add("Line number " + rec.getRecordNumber() + " partyId: " + currentPartyId
+ + " Invalid stateProvinceGeoId code: " + rec.get("countryGeoId"));
}
}
}
@@ -2392,11 +2422,11 @@ public class PartyServices {
}
}
- if (errMsgs.size() == 0) {
- List <GenericValue> partyCheck = EntityQuery.use(delegator).from("PartyIdentification")
+ if (errMsgs.isEmpty()) {
+ List<GenericValue> partyCheck = EntityQuery.use(delegator).from("PartyIdentification")
.where("partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId"))
.queryList();
- addParty = partyCheck.size() == 0;
+ addParty = partyCheck.isEmpty();
if (!addParty) { // update party
newPartyId = EntityUtil.getFirst(partyCheck).getString("partyId");
@@ -2405,9 +2435,11 @@ public class PartyServices {
"partyId", newPartyId,
"preferredCurrencyUomId", rec.get("preferredCurrencyUomId"),
"groupName", rec.get("groupName"),
- "userLogin", userLogin
- );
+ "userLogin", userLogin);
result = dispatcher.runSync("updatePartyGroup", partyGroup);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
} else { // person
Map<String, Object> person = UtilMisc.toMap(
"partyId", newPartyId,
@@ -2415,9 +2447,11 @@ public class PartyServices {
"middleName", rec.get("middleName"),
"lastName", rec.get("lastName"),
"preferredCurrencyUomId", rec.get("preferredCurrencyUomId"),
- "userLogin", userLogin
- );
+ "userLogin", userLogin);
result = dispatcher.runSync("updatePerson", person);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
}
} else { // create new party
@@ -2426,9 +2460,11 @@ public class PartyServices {
"preferredCurrencyUomId", rec.get("preferredCurrencyUomId"),
"groupName", rec.get("groupName"),
"userLogin", userLogin,
- "statusId", "PARTY_ENABLED"
- );
+ "statusId", "PARTY_ENABLED");
result = dispatcher.runSync("createPartyGroup", partyGroup);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
} else { // person
Map<String, Object> person = UtilMisc.toMap(
"firstName", rec.get("firstName"),
@@ -2436,64 +2472,63 @@ public class PartyServices {
"lastName", rec.get("lastName"),
"preferredCurrencyUomId", rec.get("preferredCurrencyUomId"),
"statusId", "PARTY_ENABLED",
- "userLogin", userLogin
- );
+ "userLogin", userLogin);
result = dispatcher.runSync("createPerson", person);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
}
newPartyId = (String) result.get("partyId");
- Map<String, Object> partyIdentification = UtilMisc.toMap(
- "partyId", newPartyId,
- "partyIdentificationTypeId", "PARTY_IMPORT",
- "idValue", rec.get("partyId"),
- "userLogin", userLogin
- );
+ Map<String, Object> partyIdentification = UtilMisc.toMap("partyId", newPartyId,
+ "partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId"), "userLogin", userLogin);
result = dispatcher.runSync("createPartyIdentification", partyIdentification);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
- Map<String, Object> partyRole = UtilMisc.toMap(
- "partyId", newPartyId,
- "roleTypeId", rec.get("roleTypeId"),
- "userLogin", userLogin
- );
+ Map<String, Object> partyRole = UtilMisc.toMap("partyId", newPartyId, "roleTypeId", rec.get("roleTypeId"),
+ "userLogin", userLogin);
dispatcher.runSync("createPartyRole", partyRole);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
if (UtilValidate.isNotEmpty(rec.get("companyPartyId"))) {
- List <GenericValue> companyCheck = EntityQuery.use(delegator).from("PartyIdentification")
+ List<GenericValue> companyCheck = EntityQuery.use(delegator).from("PartyIdentification")
.where("partyIdentificationTypeId", "PARTY_IMPORT", "idValue", rec.get("partyId"))
.queryList();
- if (companyCheck.size() == 0) { // update party group
+ if (companyCheck.isEmpty()) { // update party group
// company does not exist so create
Map<String, Object> companyPartyGroup = UtilMisc.toMap(
- "partyId", newCompanyPartyId,
- "statusId", "PARTY_ENABLED",
- "userLogin", userLogin
- );
+ "partyId", newCompanyPartyId, "statusId", "PARTY_ENABLED", "userLogin", userLogin);
result = dispatcher.runSync("createPartyGroup", companyPartyGroup);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
newCompanyPartyId = (String) result.get("partyId");
} else {
newCompanyPartyId = EntityUtil.getFirst(companyCheck).getString("partyId");
}
Map<String, Object> companyRole = UtilMisc.toMap(
- "partyId", newCompanyPartyId,
- "roleTypeId", "ACCOUNT",
- "userLogin", userLogin
- );
- dispatcher.runSync("createPartyRole", companyRole);
+ "partyId", newCompanyPartyId, "roleTypeId", "ACCOUNT", "userLogin", userLogin);
+ Map<String, Object> serviceResult = dispatcher.runSync("createPartyRole", companyRole);
+ if (ServiceUtil.isError(serviceResult)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
+ }
// company exist, so create link
- Map<String, Object> partyRelationship = UtilMisc.toMap(
- "partyIdTo", newPartyId,
- "partyIdFrom", newCompanyPartyId,
- "roleTypeIdFrom", "ACCOUNT",
- "partyRelationshipTypeId", "EMPLOYMENT",
- "userLogin", userLogin
- );
+ Map<String, Object> partyRelationship = UtilMisc.toMap("partyIdTo", newPartyId, "partyIdFrom", newCompanyPartyId,
+ "roleTypeIdFrom", "ACCOUNT", "partyRelationshipTypeId", "EMPLOYMENT", "userLogin", userLogin);
result = dispatcher.runSync("createPartyRelationship", partyRelationship);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
}
}
- Debug.logInfo(" =========================================================party created id: " + newPartyId, module);
+ Debug.logInfo(" New party created with id: " + newPartyId, MODULE);
partiesCreated++;
} else {
errMsgs.addAll(newErrMsgs);
@@ -2507,97 +2542,129 @@ public class PartyServices {
if (newPartyId != null && addParty && UtilValidate.isNotEmpty(currentContactMechTypeId)) {
// fill maps and check changes
- Map<String, Object> emailAddress = UtilMisc.toMap(
- "contactMechTypeId", "EMAIL_ADDRESS",
- "userLogin", userLogin
- );
- Boolean emailAddressChanged = false;
+ Map<String, Object> emailAddress = UtilMisc.toMap("contactMechTypeId", "EMAIL_ADDRESS", "userLogin", userLogin);
+ boolean emailAddressChanged = false;
if ("EMAIL_ADDRESS".equals(currentContactMechTypeId)) {
emailAddress.put("infoString", rec.get("emailAddress"));
emailAddressChanged = lastEmailAddress == null || !lastEmailAddress.equals(rec.get("emailAddress"));
lastEmailAddress = rec.get("emailAddress");
}
- Map<String, Object> postalAddress = UtilMisc.toMap("userLogin", (Object) userLogin); // casting is here necessary for some compiler versions
+ Map<String, Object> postalAddress = UtilMisc.toMap("userLogin", (Object) userLogin);
+ // casting is here necessary for some compiler versions
- Boolean postalAddressChanged = false;
+ boolean postalAddressChanged = false;
if ("POSTAL_ADDRESS".equals(currentContactMechTypeId)) {
postalAddress.put("address1", rec.get("address1"));
postalAddress.put("address2", rec.get("address2"));
- postalAddress.put("city", rec.get("city"));
+ postalAddress.put("city", rec.get("city"));
postalAddress.put("stateProvinceGeoId", rec.get("stateProvinceGeoId"));
postalAddress.put("countryGeoId", rec.get("countryGeoId"));
postalAddress.put("postalCode", rec.get("postalCode"));
postalAddressChanged =
- lastAddress1 == null || !lastAddress1.equals(postalAddress.get("address1")) ||
- lastAddress2 == null || !lastAddress2.equals(postalAddress.get("address2")) ||
- lastCity == null || !lastCity.equals(postalAddress.get("city")) ||
- lastCountryGeoId == null || !lastCountryGeoId.equals(postalAddress.get("countryGeoId"));
+ lastAddress1 == null || !lastAddress1.equals(postalAddress.get("address1"))
+ || lastAddress2 == null || !lastAddress2.equals(postalAddress.get("address2"))
+ || lastCity == null || !lastCity.equals(postalAddress.get("city"))
+ || lastCountryGeoId == null || !lastCountryGeoId.equals(postalAddress.get("countryGeoId"));
lastAddress1 = (String) postalAddress.get("address1");
lastAddress2 = (String) postalAddress.get("address2");
lastCity = (String) postalAddress.get("city");
lastCountryGeoId = (String) postalAddress.get("countryGeoId");
}
- Map<String, Object> telecomNumber = UtilMisc.toMap("userLogin", (Object) userLogin); // casting is here necessary for some compiler versions
+ Map<String, Object> telecomNumber = UtilMisc.toMap("userLogin", (Object) userLogin);
+ // casting is here necessary for some compiler versions
- Boolean telecomNumberChanged = false;
+ boolean telecomNumberChanged = false;
if ("TELECOM_NUMBER".equals(currentContactMechTypeId)) {
telecomNumber.put("countryCode", rec.get("telCountryCode"));
telecomNumber.put("areaCode", rec.get("telAreaCode"));
telecomNumber.put("contactNumber", rec.get("telContactNumber"));
telecomNumberChanged =
- lastCountryCode == null || !lastCountryCode.equals(telecomNumber.get("countryCode")) ||
- lastAreaCode == null || !lastAreaCode.equals(telecomNumber.get("areaCode")) ||
- lastContactNumber == null || !lastContactNumber.equals(telecomNumber.get("contactNumber"));
+ lastCountryCode == null || !lastCountryCode.equals(telecomNumber.get("countryCode"))
+ || lastAreaCode == null || !lastAreaCode.equals(telecomNumber.get("areaCode"))
+ || lastContactNumber == null || !lastContactNumber.equals(telecomNumber.get("contactNumber"));
lastCountryCode = (String) telecomNumber.get("countryCode");
lastAreaCode = (String) telecomNumber.get("areaCode");
lastContactNumber = (String) telecomNumber.get("contactNumber");
}
Map<String, Object> partyContactMechPurpose = UtilMisc.toMap("partyId", newPartyId, "userLogin", userLogin);
- Boolean partyContactMechPurposeChanged = false;
+ boolean partyContactMechPurposeChanged = false;
currentContactMechPurposeTypeId = rec.get("contactMechPurposeTypeId");
- if (currentContactMechPurposeTypeId != null && ("TELECOM_NUMBER".equals(currentContactMechTypeId) || "POSTAL_ADDRESS".equals(currentContactMechTypeId) ||"EMAIL_ADDRESS".equals(currentContactMechTypeId))) {
+ if (currentContactMechPurposeTypeId != null && ("TELECOM_NUMBER".equals(currentContactMechTypeId)
+ || "POSTAL_ADDRESS".equals(currentContactMechTypeId) || "EMAIL_ADDRESS".equals(currentContactMechTypeId))) {
partyContactMechPurpose.put("contactMechPurposeTypeId", currentContactMechPurposeTypeId);
- partyContactMechPurposeChanged = (lastContactMechPurposeTypeId == null || !lastContactMechPurposeTypeId.equals(currentContactMechPurposeTypeId)) && !telecomNumberChanged && !postalAddressChanged && !emailAddressChanged;
- Debug.logInfo("===================================last:" + lastContactMechPurposeTypeId + " current: " + currentContactMechPurposeTypeId + " t :" + telecomNumberChanged + " p: " + postalAddressChanged + " e: " + emailAddressChanged + " result: " + partyContactMechPurposeChanged, module);
+ partyContactMechPurpose.put("contactMechTypeId", currentContactMechTypeId);
+ partyContactMechPurposeChanged = (lastContactMechPurposeTypeId == null
+ || !lastContactMechPurposeTypeId.equals(currentContactMechPurposeTypeId)) && !telecomNumberChanged
+ && !postalAddressChanged && !emailAddressChanged;
+ Debug.logInfo("Last:" + lastContactMechPurposeTypeId + " current: " + currentContactMechPurposeTypeId + " t :"
+ + telecomNumberChanged + " p: " + postalAddressChanged + " e: " + emailAddressChanged + " result: "
+ + partyContactMechPurposeChanged, MODULE);
}
lastContactMechPurposeTypeId = currentContactMechPurposeTypeId;
// update
- if (errMsgs.size() == 0) {
+ if (errMsgs.isEmpty()) {
if (postalAddressChanged) {
result = dispatcher.runSync("createPostalAddress", postalAddress);
- newContactMechId = (String) result.get("contactMechId");
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
+ newContactMechId = (String) result.get("contactMechId");
if (currentContactMechPurposeTypeId == null) {
currentContactMechPurposeTypeId = "GENERAL_LOCATION";
}
- dispatcher.runSync("createPartyContactMech", UtilMisc.toMap("partyId", newPartyId, "contactMechId", newContactMechId, "contactMechPurposeTypeId", currentContactMechPurposeTypeId, "userLogin", userLogin));
+ Map<String, Object> serviceResult = dispatcher.runSync("createPartyContactMech", UtilMisc.toMap("partyId", newPartyId,
+ "contactMechId", newContactMechId, "contactMechTypeId", currentContactMechTypeId, "contactMechPurposeTypeId", currentContactMechPurposeTypeId,
+ "userLogin", userLogin));
+ if (ServiceUtil.isError(serviceResult)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
+ }
}
if (telecomNumberChanged) {
result = dispatcher.runSync("createTelecomNumber", telecomNumber);
- newContactMechId = (String) result.get("contactMechId");
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
+ newContactMechId = (String) result.get("contactMechId");
if (currentContactMechPurposeTypeId == null) {
- currentContactMechPurposeTypeId= "PHONE_WORK";
+ currentContactMechPurposeTypeId = "PHONE_WORK";
+ }
+ Map<String, Object> resultMap = dispatcher.runSync("createPartyContactMech", UtilMisc.toMap("partyId", newPartyId,
+ "contactMechId", newContactMechId, "contactMechTypeId", currentContactMechTypeId, "contactMechPurposeTypeId", currentContactMechPurposeTypeId,
+ "userLogin", userLogin));
+ if (ServiceUtil.isError(resultMap)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
}
- dispatcher.runSync("createPartyContactMech", UtilMisc.toMap("partyId", newPartyId, "contactMechId", newContactMechId, "contactMechPurposeTypeId", currentContactMechPurposeTypeId, "userLogin", userLogin));
}
if (emailAddressChanged) {
result = dispatcher.runSync("createContactMech", emailAddress);
- newContactMechId = (String) result.get("contactMechId");
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
+ newContactMechId = (String) result.get("contactMechId");
if (currentContactMechPurposeTypeId == null) {
currentContactMechPurposeTypeId = "PRIMARY_EMAIL";
}
- dispatcher.runSync("createPartyContactMech", UtilMisc.toMap("partyId", newPartyId, "contactMechId", newContactMechId, "contactMechPurposeTypeId", currentContactMechPurposeTypeId, "userLogin", userLogin));
+ Map<String, Object> resultMap = dispatcher.runSync("createPartyContactMech", UtilMisc.toMap("partyId", newPartyId,
+ "contactMechId", newContactMechId, "contactMechTypeId", currentContactMechTypeId, "contactMechPurposeTypeId", currentContactMechPurposeTypeId, "userLogin",
+ userLogin));
+ if (ServiceUtil.isError(resultMap)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
}
if (partyContactMechPurposeChanged) {
partyContactMechPurpose.put("contactMechId", newContactMechId);
result = dispatcher.runSync("createPartyContactMechPurpose", partyContactMechPurpose);
+ if (ServiceUtil.isError(result)) {
+ return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
}
lastPartyId = currentPartyId;
errMsgs.addAll(newErrMsgs);
@@ -2606,15 +2673,16 @@ public class PartyServices {
}
}
} catch (GenericServiceException | GenericEntityException | IOException e) {
- Debug.logError(e, module);
+ Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
- if (errMsgs.size() > 0) {
+ if (!errMsgs.isEmpty()) {
return ServiceUtil.returnError(errMsgs);
}
- result = ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "PartyNewPartiesCreated", UtilMisc.toMap("partiesCreated", partiesCreated), locale));
+ result = ServiceUtil.returnSuccess(UtilProperties.getMessage(RESOURCE, "PartyNewPartiesCreated",
+ UtilMisc.toMap("partiesCreated", partiesCreated), locale));
return result;
}
}