svn commit: r1818425 - in /ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact: ContactHelper.java ContactMechServices.java ContactMechWorker.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1818425 - in /ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact: ContactHelper.java ContactMechServices.java ContactMechWorker.java

mbrohl
Author: mbrohl
Date: Sat Dec 16 15:42:18 2017
New Revision: 1818425

URL: http://svn.apache.org/viewvc?rev=1818425&view=rev
Log:
Improved: General refactoring and code improvements, package
org.apache.ofbiz.party.contact.
(OFBIZ-10067)

Thanks Julian Leichert for reporting and providing the patches.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java
    ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java
    ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java

Modified: ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java?rev=1818425&r1=1818424&r2=1818425&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactHelper.java Sat Dec 16 15:42:18 2017
@@ -51,7 +51,9 @@ public class ContactHelper {
     }
 
     public static Collection<GenericValue> getContactMech(GenericValue party, String contactMechPurposeTypeId, String contactMechTypeId, boolean includeOld) {
-        if (party == null) return null;
+        if (party == null) {
+            return null;
+        }
         try {
             List<GenericValue> partyContactMechList;
 
@@ -72,9 +74,8 @@ public class ContactHelper {
             partyContactMechList = EntityUtil.orderBy(partyContactMechList, UtilMisc.toList("fromDate DESC"));
             if (contactMechTypeId == null) {
                 return EntityUtil.getRelated("ContactMech", null, partyContactMechList, false);
-            } else {
-                return EntityUtil.getRelated("ContactMech", UtilMisc.toMap("contactMechTypeId", contactMechTypeId), partyContactMechList, false);
             }
+            return EntityUtil.getRelated("ContactMech", UtilMisc.toMap("contactMechTypeId", contactMechTypeId), partyContactMechList, false);
         } catch (GenericEntityException gee) {
             Debug.logWarning(gee, module);
             return Collections.emptyList();

Modified: ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java?rev=1818425&r1=1818424&r2=1818425&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechServices.java Sat Dec 16 15:42:18 2017
@@ -69,18 +69,19 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> createContactMech(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
         Timestamp now = UtilDateTime.nowTimestamp();
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE");
 
-        if (result.size() > 0)
+        if (result.size() > 0) {
             return result;
+        }
 
         String contactMechTypeId = (String) context.get("contactMechTypeId");
 
@@ -88,7 +89,7 @@ public class ContactMechServices {
         try {
             newCmId = delegator.getNextSeqId("ContactMech");
         } catch (IllegalArgumentException e) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                     "contactmechservices.could_not_create_contact_info_id_generation_failure", locale));
         }
 
@@ -132,19 +133,20 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> updateContactMech(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
         Timestamp now = UtilDateTime.nowTimestamp();
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         boolean isModified = false;
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE");
-        
-        if (result.size() > 0)
+
+        if (result.size() > 0) {
             return result;
+        }
 
         String newCmId = null;
         try {
@@ -176,9 +178,8 @@ public class ContactMechServices {
                 if (partyContactMech == null) {
                     return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                             "contactmechservices.cannot_update_specified_contact_info_not_corresponds", locale));
-                } else {
-                    toBeStored.add(partyContactMech);
                 }
+                toBeStored.add(partyContactMech);
             } catch (GenericEntityException e) {
                 Debug.logWarning(e.getMessage(), module);
                 contactMech = null;
@@ -208,8 +209,12 @@ public class ContactMechServices {
         newPartyContactMech.set("roleTypeId", context.get("roleTypeId"));
         newPartyContactMech.set("allowSolicitation", context.get("allowSolicitation"));
 
-        if (!newContactMech.equals(contactMech)) isModified = true;
-        if (!newPartyContactMech.equals(partyContactMech)) isModified = true;
+        if (!newContactMech.equals(contactMech)) {
+            isModified = true;
+        }
+        if (!newPartyContactMech.equals(partyContactMech)) {
+            isModified = true;
+        }
 
         toBeStored.add(newContactMech);
         toBeStored.add(newPartyContactMech);
@@ -242,7 +247,7 @@ public class ContactMechServices {
             } catch (GenericEntityException e) {
                 Debug.logWarning(e.toString(), module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                        "contactmechservices.could_not_change_contact_info_write",
+                        "contactmechservices.could_not_change_contact_info_write",
                         UtilMisc.toMap("errMessage", e.getMessage()), locale));
             }
         } else {
@@ -266,16 +271,17 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> deleteContactMech(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
-        
+
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_DELETE");
-        
-        if (result.size() > 0)
+
+        if (result.size() > 0) {
             return result;
+        }
 
         // never delete a contact mechanism, just put a to date on the link to the party
         String contactMechId = (String) context.get("contactMechId");
@@ -324,18 +330,19 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> createPostalAddress(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
         Timestamp now = UtilDateTime.nowTimestamp();
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE");
-        
-        if (result.size() > 0)
+
+        if (result.size() > 0) {
             return result;
+        }
 
         String contactMechTypeId = "POSTAL_ADDRESS";
 
@@ -396,17 +403,17 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> updatePostalAddress(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
         Timestamp now = UtilDateTime.nowTimestamp();
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         boolean isModified = false;
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE");
-        
+
         if (result.size() > 0) {
             return result;
         }
@@ -441,9 +448,8 @@ public class ContactMechServices {
                 if (partyContactMech == null) {
                     return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
                             "contactmechservices.cannot_update_specified_contact_info_not_corresponds", locale));
-                } else {
-                    toBeStored.add(partyContactMech);
                 }
+                toBeStored.add(partyContactMech);
             } catch (GenericEntityException e) {
                 Debug.logWarning(e.getMessage(), module);
                 contactMech = null;
@@ -457,8 +463,9 @@ public class ContactMechServices {
         // never change a contact mech, just create a new one with the changes
         GenericValue newContactMech = GenericValue.create(contactMech);
         GenericValue newPartyContactMech = null;
-        if (partyContactMech != null)
+        if (partyContactMech != null) {
             newPartyContactMech = GenericValue.create(partyContactMech);
+        }
         GenericValue relatedEntityToSet = null;
 
         if ("POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId"))) {
@@ -488,7 +495,7 @@ public class ContactMechServices {
             relatedEntityToSet.set("contactMechId", newCmId);
         } else {
             return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                    "contactmechservices.could_not_update_contact_as_POSTAL_ADDRESS_specified",
+                    "contactmechservices.could_not_update_contact_as_POSTAL_ADDRESS_specified",
                     UtilMisc.toMap("contactMechTypeId", contactMech.getString("contactMechTypeId")), locale));
         }
 
@@ -497,12 +504,17 @@ public class ContactMechServices {
             newPartyContactMech.set("allowSolicitation", context.get("allowSolicitation"));
         }
 
-        if (!newContactMech.equals(contactMech)) isModified = true;
-        if (newPartyContactMech != null && !newPartyContactMech.equals(partyContactMech)) isModified = true;
+        if (!newContactMech.equals(contactMech)) {
+            isModified = true;
+        }
+        if (newPartyContactMech != null && !newPartyContactMech.equals(partyContactMech)) {
+            isModified = true;
+        }
 
         toBeStored.add(newContactMech);
-        if (newPartyContactMech != null)
+        if (newPartyContactMech != null) {
             toBeStored.add(newPartyContactMech);
+        }
 
         if (isModified) {
             toBeStored.add(relatedEntityToSet);
@@ -525,7 +537,7 @@ public class ContactMechServices {
                 } catch (GenericEntityException e) {
                     Debug.logWarning(e.toString(), module);
                     return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                            "contactmechservices.could_not_change_contact_info_read",
+                            "contactmechservices.could_not_change_contact_info_read",
                             UtilMisc.toMap("errMessage", e.getMessage()), locale));
                 }
 
@@ -537,7 +549,7 @@ public class ContactMechServices {
             } catch (GenericEntityException e) {
                 Debug.logWarning(e.toString(), module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                        "contactmechservices.could_not_change_contact_info_write",
+                        "contactmechservices.could_not_change_contact_info_write",
                         UtilMisc.toMap("errMessage", e.getMessage()), locale));
             }
         } else {
@@ -564,18 +576,19 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> createTelecomNumber(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
         Timestamp now = UtilDateTime.nowTimestamp();
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE");
-        
-        if (result.size() > 0)
+
+        if (result.size() > 0) {
             return result;
+        }
 
         String contactMechTypeId = "TELECOM_NUMBER";
 
@@ -618,19 +631,20 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> updateTelecomNumber(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
         Timestamp now = UtilDateTime.nowTimestamp();
-        List<GenericValue> toBeStored = new LinkedList<GenericValue>();
+        List<GenericValue> toBeStored = new LinkedList<>();
         boolean isModified = false;
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE");
-        
-        if (result.size() > 0)
+
+        if (result.size() > 0) {
             return result;
+        }
 
         String newCmId = null;
         try {
@@ -693,15 +707,19 @@ public class ContactMechServices {
             newPartyContactMech.set("extension", context.get("extension"));
         } else {
             return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                    "contactmechservices.could_not_update_contact_as_TELECOM_NUMBER_specified",
+                    "contactmechservices.could_not_update_contact_as_TELECOM_NUMBER_specified",
                     UtilMisc.toMap("contactMechTypeId", contactMech.getString("contactMechTypeId")), locale));
         }
 
         newPartyContactMech.set("roleTypeId", context.get("roleTypeId"));
         newPartyContactMech.set("allowSolicitation", context.get("allowSolicitation"));
 
-        if (!newContactMech.equals(contactMech)) isModified = true;
-        if (!newPartyContactMech.equals(partyContactMech)) isModified = true;
+        if (!newContactMech.equals(contactMech)) {
+            isModified = true;
+        }
+        if (!newPartyContactMech.equals(partyContactMech)) {
+            isModified = true;
+        }
 
         toBeStored.add(newContactMech);
         toBeStored.add(newPartyContactMech);
@@ -726,7 +744,7 @@ public class ContactMechServices {
             } catch (GenericEntityException e) {
                 Debug.logWarning(e.toString(), module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                        "contactmechservices.could_not_change_contact_info_read",
+                        "contactmechservices.could_not_change_contact_info_read",
                         UtilMisc.toMap("errMessage", e.getMessage()), locale));
             }
 
@@ -736,7 +754,7 @@ public class ContactMechServices {
             } catch (GenericEntityException e) {
                 Debug.logWarning(e.toString(), module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                        "contactmechservices.could_not_change_contact_info_write",
+                        "contactmechservices.could_not_change_contact_info_write",
                         UtilMisc.toMap("errMessage", e.getMessage()), locale));
             }
         } else {
@@ -798,7 +816,7 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> createPartyContactMechPurpose(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -837,20 +855,19 @@ public class ContactMechServices {
                        "contactmechservices.could_not_create_new_purpose_already_exists", locale);
             errMsg += ": " + tempVal.getPrimaryKey().toString();
             return ServiceUtil.returnError(errMsg);
-        } else {
-            // no entry with a valid date range exists, create new with open thruDate
-            GenericValue newPartyContactMechPurpose = delegator.makeValue("PartyContactMechPurpose",
-                    UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId,
-                        "fromDate", fromDate));
+        }
+        // no entry with a valid date range exists, create new with open thruDate
+        GenericValue newPartyContactMechPurpose = delegator.makeValue("PartyContactMechPurpose",
+                UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId,
+                    "fromDate", fromDate));
 
-            try {
-                delegator.create(newPartyContactMechPurpose);
-            } catch (GenericEntityException e) {
-                Debug.logWarning(e.getMessage(), module);
-                return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                        "contactmechservices.could_not_add_purpose_write",
-                        UtilMisc.toMap("errMessage", e.getMessage()), locale));
-            }
+        try {
+            delegator.create(newPartyContactMechPurpose);
+        } catch (GenericEntityException e) {
+            Debug.logWarning(e.getMessage(), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+                    "contactmechservices.could_not_add_purpose_write",
+                    UtilMisc.toMap("errMessage", e.getMessage()), locale));
         }
 
         result.put("fromDate", fromDate);
@@ -859,14 +876,14 @@ public class ContactMechServices {
     }
 
     public static Map<String, Object> deletePartyContactMechPurposeIfExists(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_DELETE");
-        
+
         if (result.size() > 0) {
             return result;
         }
@@ -899,7 +916,7 @@ public class ContactMechServices {
             } catch (GenericServiceException e) {
                 Debug.logWarning(e.getMessage(), module);
                 return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
-                        "contactmechservices.could_not_delete_purpose_from_contact_mechanism_read",
+                        "contactmechservices.could_not_delete_purpose_from_contact_mechanism_read",
                         UtilMisc.toMap("errMessage", e.getMessage()), locale));
             }
         }
@@ -915,16 +932,17 @@ public class ContactMechServices {
      *@return Map with the result of the service, the output parameters
      */
     public static Map<String, Object> deletePartyContactMechPurpose(DispatchContext ctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Delegator delegator = ctx.getDelegator();
         Security security = ctx.getSecurity();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
 
         String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_DELETE");
-        
-        if (result.size() > 0)
+
+        if (result.size() > 0) {
             return result;
+        }
 
         // required parameters
         String contactMechId = (String) context.get("contactMechId");
@@ -1035,7 +1053,7 @@ public class ContactMechServices {
         } catch (GenericServiceException e) {
             Debug.logError(e, e.getMessage(), module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,
-                    "PartyCannotCopyPartyContactMech",
+                    "PartyCannotCopyPartyContactMech",
                     UtilMisc.toMap("errorString", e.getMessage()), locale));
         }
         return ServiceUtil.returnSuccess();

Modified: ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java?rev=1818425&r1=1818424&r2=1818425&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/contact/ContactMechWorker.java Sat Dec 16 15:42:18 2017
@@ -57,14 +57,14 @@ public class ContactMechWorker {
     }
 
     public static List<Map<String, Object>> getPartyContactMechValueMaps(Delegator delegator, String partyId, boolean showOld, String contactMechTypeId) {
-        List<Map<String, Object>> partyContactMechValueMaps = new LinkedList<Map<String,Object>>();
+        List<Map<String, Object>> partyContactMechValueMaps = new LinkedList<>();
 
         List<GenericValue> allPartyContactMechs = null;
 
         try {
             List<GenericValue> tempCol = EntityQuery.use(delegator).from("PartyContactMech").where("partyId", partyId).queryList();
             if (contactMechTypeId != null) {
-                List<GenericValue> tempColTemp = new LinkedList<GenericValue>();
+                List<GenericValue> tempColTemp = new LinkedList<>();
                 for (GenericValue partyContactMech: tempCol) {
                     GenericValue contactMech = delegator.getRelatedOne("ContactMech", partyContactMech, false);
                     if (contactMech != null && contactMechTypeId.equals(contactMech.getString("contactMechTypeId"))) {
@@ -74,13 +74,17 @@ public class ContactMechWorker {
                 }
                 tempCol = tempColTemp;
             }
-            if (!showOld) tempCol = EntityUtil.filterByDate(tempCol, true);
+            if (!showOld) {
+                tempCol = EntityUtil.filterByDate(tempCol, true);
+            }
             allPartyContactMechs = tempCol;
         } catch (GenericEntityException e) {
             Debug.logWarning(e, module);
         }
 
-        if (allPartyContactMechs == null) return partyContactMechValueMaps;
+        if (allPartyContactMechs == null) {
+            return partyContactMechValueMaps;
+        }
 
         for (GenericValue partyContactMech: allPartyContactMechs) {
             GenericValue contactMech = null;
@@ -91,7 +95,7 @@ public class ContactMechWorker {
                 Debug.logWarning(e, module);
             }
             if (contactMech != null) {
-                Map<String, Object> partyContactMechValueMap = new HashMap<String, Object>();
+                Map<String, Object> partyContactMechValueMap = new HashMap<>();
 
                 partyContactMechValueMaps.add(partyContactMechValueMap);
                 partyContactMechValueMap.put("contactMech", contactMech);
@@ -106,7 +110,9 @@ public class ContactMechWorker {
                 try {
                     List<GenericValue> partyContactMechPurposes = partyContactMech.getRelated("PartyContactMechPurpose", null, null, false);
 
-                    if (!showOld) partyContactMechPurposes = EntityUtil.filterByDate(partyContactMechPurposes, true);
+                    if (!showOld) {
+                        partyContactMechPurposes = EntityUtil.filterByDate(partyContactMechPurposes, true);
+                    }
                     partyContactMechValueMap.put("partyContactMechPurposes", partyContactMechPurposes);
                 } catch (GenericEntityException e) {
                     Debug.logWarning(e, module);
@@ -128,14 +134,14 @@ public class ContactMechWorker {
     }
 
     public static List<Map<String, Object>> getFacilityContactMechValueMaps(Delegator delegator, String facilityId, boolean showOld, String contactMechTypeId) {
-        List<Map<String, Object>> facilityContactMechValueMaps = new LinkedList<Map<String,Object>>();
+        List<Map<String, Object>> facilityContactMechValueMaps = new LinkedList<>();
 
         List<GenericValue> allFacilityContactMechs = null;
 
         try {
             List<GenericValue> tempCol = EntityQuery.use(delegator).from("FacilityContactMech").where("facilityId", facilityId).queryList();
             if (contactMechTypeId != null) {
-                List<GenericValue> tempColTemp = new LinkedList<GenericValue>();
+                List<GenericValue> tempColTemp = new LinkedList<>();
                 for (GenericValue partyContactMech: tempCol) {
                     GenericValue contactMech = delegator.getRelatedOne("ContactMech", partyContactMech, false);
                     if (contactMech != null && contactMechTypeId.equals(contactMech.getString("contactMechTypeId"))) {
@@ -145,13 +151,17 @@ public class ContactMechWorker {
                 }
                 tempCol = tempColTemp;
             }
-            if (!showOld) tempCol = EntityUtil.filterByDate(tempCol, true);
+            if (!showOld) {
+                tempCol = EntityUtil.filterByDate(tempCol, true);
+            }
             allFacilityContactMechs = tempCol;
         } catch (GenericEntityException e) {
             Debug.logWarning(e, module);
         }
 
-        if (allFacilityContactMechs == null) return facilityContactMechValueMaps;
+        if (allFacilityContactMechs == null) {
+            return facilityContactMechValueMaps;
+        }
 
         for (GenericValue facilityContactMech: allFacilityContactMechs) {
             GenericValue contactMech = null;
@@ -162,7 +172,7 @@ public class ContactMechWorker {
                 Debug.logWarning(e, module);
             }
             if (contactMech != null) {
-                Map<String, Object> facilityContactMechValueMap = new HashMap<String, Object>();
+                Map<String, Object> facilityContactMechValueMap = new HashMap<>();
 
                 facilityContactMechValueMaps.add(facilityContactMechValueMap);
                 facilityContactMechValueMap.put("contactMech", contactMech);
@@ -177,7 +187,9 @@ public class ContactMechWorker {
                 try {
                     List<GenericValue> facilityContactMechPurposes = facilityContactMech.getRelated("FacilityContactMechPurpose", null, null, false);
 
-                    if (!showOld) facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMechPurposes, true);
+                    if (!showOld) {
+                        facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMechPurposes, true);
+                    }
                     facilityContactMechValueMap.put("facilityContactMechPurposes", facilityContactMechPurposes);
                 } catch (GenericEntityException e) {
                     Debug.logWarning(e, module);
@@ -200,7 +212,7 @@ public class ContactMechWorker {
 
 
     public static List<Map<String, GenericValue>> getOrderContactMechValueMaps(Delegator delegator, String orderId) {
-        List<Map<String, GenericValue>> orderContactMechValueMaps = new LinkedList<Map<String,GenericValue>>();
+        List<Map<String, GenericValue>> orderContactMechValueMaps = new LinkedList<>();
 
         List<GenericValue> allOrderContactMechs = null;
 
@@ -213,7 +225,9 @@ public class ContactMechWorker {
             Debug.logWarning(e, module);
         }
 
-        if (allOrderContactMechs == null) return orderContactMechValueMaps;
+        if (allOrderContactMechs == null) {
+            return orderContactMechValueMaps;
+        }
 
         for (GenericValue orderContactMech: allOrderContactMechs) {
             GenericValue contactMech = null;
@@ -224,7 +238,7 @@ public class ContactMechWorker {
                 Debug.logWarning(e, module);
             }
             if (contactMech != null) {
-                Map<String, GenericValue> orderContactMechValueMap = new HashMap<String, GenericValue>();
+                Map<String, GenericValue> orderContactMechValueMap = new HashMap<>();
 
                 orderContactMechValueMaps.add(orderContactMechValueMap);
                 orderContactMechValueMap.put("contactMech", contactMech);
@@ -260,7 +274,7 @@ public class ContactMechWorker {
     }
 
     public static Collection<Map<String, GenericValue>> getWorkEffortContactMechValueMaps(Delegator delegator, String workEffortId) {
-        Collection<Map<String, GenericValue>> workEffortContactMechValueMaps = new LinkedList<Map<String,GenericValue>>();
+        Collection<Map<String, GenericValue>> workEffortContactMechValueMaps = new LinkedList<>();
 
         List<GenericValue> allWorkEffortContactMechs = null;
 
@@ -273,7 +287,9 @@ public class ContactMechWorker {
             Debug.logWarning(e, module);
         }
 
-        if (allWorkEffortContactMechs == null) return null;
+        if (allWorkEffortContactMechs == null) {
+            return null;
+        }
 
         for (GenericValue workEffortContactMech: allWorkEffortContactMechs) {
             GenericValue contactMech = null;
@@ -284,7 +300,7 @@ public class ContactMechWorker {
                 Debug.logWarning(e, module);
             }
             if (contactMech != null) {
-                Map<String, GenericValue> workEffortContactMechValueMap = new HashMap<String, GenericValue>();
+                Map<String, GenericValue> workEffortContactMechValueMap = new HashMap<>();
 
                 workEffortContactMechValueMaps.add(workEffortContactMechValueMap);
                 workEffortContactMechValueMap.put("contactMech", contactMech);
@@ -315,24 +331,36 @@ public class ContactMechWorker {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
 
         boolean tryEntity = true;
-        if (request.getAttribute("_ERROR_MESSAGE_") != null) tryEntity = false;
-        if ("true".equals(request.getParameter("tryEntity"))) tryEntity = true;
+        if (request.getAttribute("_ERROR_MESSAGE_") != null) {
+            tryEntity = false;
+        }
+        if ("true".equals(request.getParameter("tryEntity"))) {
+            tryEntity = true;
+        }
 
         String donePage = request.getParameter("DONE_PAGE");
-        if (donePage == null) donePage = (String) request.getAttribute("DONE_PAGE");
-        if (UtilValidate.isEmpty(donePage)) donePage = "viewprofile";
+        if (donePage == null) {
+            donePage = (String) request.getAttribute("DONE_PAGE");
+        }
+        if (UtilValidate.isEmpty(donePage)) {
+            donePage = "viewprofile";
+        }
         target.put("donePage", donePage);
 
         String contactMechTypeId = request.getParameter("preContactMechTypeId");
 
-        if (contactMechTypeId == null) contactMechTypeId = (String) request.getAttribute("preContactMechTypeId");
-        if (contactMechTypeId != null)
+        if (contactMechTypeId == null) {
+            contactMechTypeId = (String) request.getAttribute("preContactMechTypeId");
+        }
+        if (contactMechTypeId != null) {
             tryEntity = false;
+        }
 
         String contactMechId = request.getParameter("contactMechId");
 
-        if (request.getAttribute("contactMechId") != null)
+        if (request.getAttribute("contactMechId") != null) {
             contactMechId = (String) request.getAttribute("contactMechId");
+        }
 
         GenericValue contactMech = null;
 
@@ -363,8 +391,9 @@ public class ContactMechWorker {
                 } catch (GenericEntityException e) {
                     Debug.logWarning(e, module);
                 }
-                if (UtilValidate.isNotEmpty(partyContactMechPurposes))
+                if (UtilValidate.isNotEmpty(partyContactMechPurposes)) {
                     target.put("partyContactMechPurposes", partyContactMechPurposes);
+                }
             }
 
             try {
@@ -385,13 +414,14 @@ public class ContactMechWorker {
             try {
                 GenericValue contactMechType = EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", contactMechTypeId).queryOne();
 
-                if (contactMechType != null)
+                if (contactMechType != null) {
                     target.put("contactMechType", contactMechType);
+                }
             } catch (GenericEntityException e) {
                 Debug.logWarning(e, module);
             }
 
-            Collection<GenericValue> purposeTypes = new LinkedList<GenericValue>();
+            Collection<GenericValue> purposeTypes = new LinkedList<>();
             Iterator<GenericValue> typePurposes = null;
 
             try {
@@ -414,8 +444,9 @@ public class ContactMechWorker {
                     purposeTypes.add(contactMechPurposeType);
                 }
             }
-            if (purposeTypes.size() > 0)
+            if (purposeTypes.size() > 0) {
                 target.put("purposeTypes", purposeTypes);
+            }
         }
 
         String requestName;
@@ -453,23 +484,33 @@ public class ContactMechWorker {
             GenericValue postalAddress = null;
 
             try {
-                if (contactMech != null) postalAddress = contactMech.getRelatedOne("PostalAddress", false);
+                if (contactMech != null) {
+                    postalAddress = contactMech.getRelatedOne("PostalAddress", false);
+                }
             } catch (GenericEntityException e) {
                 Debug.logWarning(e, module);
             }
-            if (postalAddress != null) target.put("postalAddress", postalAddress);
+            if (postalAddress != null) {
+                target.put("postalAddress", postalAddress);
+            }
         } else if ("TELECOM_NUMBER".equals(contactMechTypeId)) {
             GenericValue telecomNumber = null;
 
             try {
-                if (contactMech != null) telecomNumber = contactMech.getRelatedOne("TelecomNumber", false);
+                if (contactMech != null) {
+                    telecomNumber = contactMech.getRelatedOne("TelecomNumber", false);
+                }
             } catch (GenericEntityException e) {
                 Debug.logWarning(e, module);
             }
-            if (telecomNumber != null) target.put("telecomNumber", telecomNumber);
+            if (telecomNumber != null) {
+                target.put("telecomNumber", telecomNumber);
+            }
         }
 
-        if ("true".equals(request.getParameter("useValues"))) tryEntity = true;
+        if ("true".equals(request.getParameter("useValues"))) {
+            tryEntity = true;
+        }
         target.put("tryEntity", Boolean.valueOf(tryEntity));
 
         try {
@@ -490,12 +531,16 @@ public class ContactMechWorker {
      * @return returns the first valid FacilityContactMech found based on the given facilityId and a prioritized list of purposes
      */
     public static GenericValue getFacilityContactMechByPurpose(Delegator delegator, String facilityId, List<String> purposeTypes) {
-        if (UtilValidate.isEmpty(facilityId)) return null;
-        if (UtilValidate.isEmpty(purposeTypes)) return null;
+        if (UtilValidate.isEmpty(facilityId)) {
+            return null;
+        }
+        if (UtilValidate.isEmpty(purposeTypes)) {
+            return null;
+        }
 
         for (String purposeType: purposeTypes) {
             List<GenericValue> facilityContactMechPurposes = null;
-            List<EntityCondition> conditionList = new LinkedList<EntityCondition>();
+            List<EntityCondition> conditionList = new LinkedList<>();
             conditionList.add(EntityCondition.makeCondition("facilityId", facilityId));
             conditionList.add(EntityCondition.makeCondition("contactMechPurposeTypeId", purposeType));
             EntityCondition entityCondition = EntityCondition.makeCondition(conditionList);
@@ -513,7 +558,7 @@ public class ContactMechWorker {
             for (GenericValue facilityContactMechPurpose: facilityContactMechPurposes) {
                 String contactMechId = facilityContactMechPurpose.getString("contactMechId");
                 List<GenericValue> facilityContactMechs = null;
-                conditionList = new LinkedList<EntityCondition>();
+                conditionList = new LinkedList<>();
                 conditionList.add(EntityCondition.makeCondition("facilityId", facilityId));
                 conditionList.add(EntityCondition.makeCondition("contactMechId", contactMechId));
                 entityCondition = EntityCondition.makeCondition(conditionList);
@@ -540,24 +585,36 @@ public class ContactMechWorker {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
 
         boolean tryEntity = true;
-        if (request.getAttribute("_ERROR_MESSAGE") != null) tryEntity = false;
-        if ("true".equals(request.getParameter("tryEntity"))) tryEntity = true;
+        if (request.getAttribute("_ERROR_MESSAGE") != null) {
+            tryEntity = false;
+        }
+        if ("true".equals(request.getParameter("tryEntity"))) {
+            tryEntity = true;
+        }
 
         String donePage = request.getParameter("DONE_PAGE");
-        if (donePage == null) donePage = (String) request.getAttribute("DONE_PAGE");
-        if (UtilValidate.isEmpty(donePage)) donePage = "viewprofile";
+        if (donePage == null) {
+            donePage = (String) request.getAttribute("DONE_PAGE");
+        }
+        if (UtilValidate.isEmpty(donePage)) {
+            donePage = "viewprofile";
+        }
         target.put("donePage", donePage);
 
         String contactMechTypeId = request.getParameter("preContactMechTypeId");
 
-        if (contactMechTypeId == null) contactMechTypeId = (String) request.getAttribute("preContactMechTypeId");
-        if (contactMechTypeId != null)
+        if (contactMechTypeId == null) {
+            contactMechTypeId = (String) request.getAttribute("preContactMechTypeId");
+        }
+        if (contactMechTypeId != null) {
             tryEntity = false;
+        }
 
         String contactMechId = request.getParameter("contactMechId");
 
-        if (request.getAttribute("contactMechId") != null)
+        if (request.getAttribute("contactMechId") != null) {
             contactMechId = (String) request.getAttribute("contactMechId");
+        }
 
         GenericValue contactMech = null;
 
@@ -588,8 +645,9 @@ public class ContactMechWorker {
                 } catch (GenericEntityException e) {
                     Debug.logWarning(e, module);
                 }
-                if (UtilValidate.isNotEmpty(facilityContactMechPurposes))
+                if (UtilValidate.isNotEmpty(facilityContactMechPurposes)) {
                     target.put("facilityContactMechPurposes", facilityContactMechPurposes);
+                }
             }
 
             try {
@@ -610,13 +668,14 @@ public class ContactMechWorker {
             try {
                 GenericValue contactMechType = EntityQuery.use(delegator).from("ContactMechType").where("contactMechTypeId", contactMechTypeId).queryOne();
 
-                if (contactMechType != null)
+                if (contactMechType != null) {
                     target.put("contactMechType", contactMechType);
+                }
             } catch (GenericEntityException e) {
                 Debug.logWarning(e, module);
             }
 
-            Collection<GenericValue> purposeTypes = new LinkedList<GenericValue>();
+            Collection<GenericValue> purposeTypes = new LinkedList<>();
             Iterator<GenericValue> typePurposes = null;
 
             try {
@@ -639,8 +698,9 @@ public class ContactMechWorker {
                     purposeTypes.add(contactMechPurposeType);
                 }
             }
-            if (purposeTypes.size() > 0)
+            if (purposeTypes.size() > 0) {
                 target.put("purposeTypes", purposeTypes);
+            }
         }
 
         String requestName;
@@ -678,23 +738,33 @@ public class ContactMechWorker {
             GenericValue postalAddress = null;
 
             try {
-                if (contactMech != null) postalAddress = contactMech.getRelatedOne("PostalAddress", false);
+                if (contactMech != null) {
+                    postalAddress = contactMech.getRelatedOne("PostalAddress", false);
+                }
             } catch (GenericEntityException e) {
                 Debug.logWarning(e, module);
             }
-            if (postalAddress != null) target.put("postalAddress", postalAddress);
+            if (postalAddress != null) {
+                target.put("postalAddress", postalAddress);
+            }
         } else if ("TELECOM_NUMBER".equals(contactMechTypeId)) {
             GenericValue telecomNumber = null;
 
             try {
-                if (contactMech != null) telecomNumber = contactMech.getRelatedOne("TelecomNumber", false);
+                if (contactMech != null) {
+                    telecomNumber = contactMech.getRelatedOne("TelecomNumber", false);
+                }
             } catch (GenericEntityException e) {
                 Debug.logWarning(e, module);
             }
-            if (telecomNumber != null) target.put("telecomNumber", telecomNumber);
+            if (telecomNumber != null) {
+                target.put("telecomNumber", telecomNumber);
+            }
         }
 
-        if ("true".equals(request.getParameter("useValues"))) tryEntity = true;
+        if ("true".equals(request.getParameter("useValues"))) {
+            tryEntity = true;
+        }
         target.put("tryEntity", Boolean.valueOf(tryEntity));
 
         try {
@@ -710,7 +780,7 @@ public class ContactMechWorker {
 
     public static List<Map<String, Object>> getPartyPostalAddresses(ServletRequest request, String partyId, String curContactMechId) {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
-        List<Map<String, Object>> postalAddressInfos = new LinkedList<Map<String,Object>>();
+        List<Map<String, Object>> postalAddressInfos = new LinkedList<>();
 
         List<GenericValue> allPartyContactMechs = null;
 
@@ -720,7 +790,9 @@ public class ContactMechWorker {
             Debug.logWarning(e, module);
         }
 
-        if (allPartyContactMechs == null) return postalAddressInfos;
+        if (allPartyContactMechs == null) {
+            return postalAddressInfos;
+        }
 
         for (GenericValue partyContactMech: allPartyContactMechs) {
             GenericValue contactMech = null;
@@ -731,7 +803,7 @@ public class ContactMechWorker {
                 Debug.logWarning(e, module);
             }
             if (contactMech != null && "POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId")) && !contactMech.getString("contactMechId").equals(curContactMechId)) {
-                Map<String, Object> postalAddressInfo = new HashMap<String, Object>();
+                Map<String, Object> postalAddressInfo = new HashMap<>();
 
                 postalAddressInfos.add(postalAddressInfo);
                 postalAddressInfo.put("contactMech", contactMech);
@@ -758,7 +830,7 @@ public class ContactMechWorker {
 
     public static Map<String, Object> getCurrentPostalAddress(ServletRequest request, String partyId, String curContactMechId) {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
-        Map<String, Object> results = new HashMap<String, Object>();
+        Map<String, Object> results = new HashMap<>();
 
         if (curContactMechId != null) {
             List<GenericValue> partyContactMechs = null;
@@ -869,7 +941,7 @@ public class ContactMechWorker {
 
         // get all company addresses
         Delegator delegator = postalAddress.getDelegator();
-        List<GenericValue> postalAddresses = new LinkedList<GenericValue>();
+        List<GenericValue> postalAddresses = new LinkedList<>();
         try {
             List<GenericValue> partyContactMechs = EntityQuery.use(delegator).from("PartyContactMech")
                     .where("partyId", companyPartyId)
@@ -978,7 +1050,7 @@ public class ContactMechWorker {
 
     /**
      * Returns a <b>PostalAddress</b> <code>GenericValue</code> as a URL encoded <code>String</code>.
-     *
+     *
      * @param postalAddress A <b>PostalAddress</b> <code>GenericValue</code>.
      * @return A URL encoded <code>String</code>.
      * @throws GenericEntityException