|
Modified: ofbiz/branches/20120329_portletWidget/applications/party/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/servicedef/services.xml?rev=1403874&r1=1403873&r2=1403874&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/applications/party/servicedef/services.xml (original) +++ ofbiz/branches/20120329_portletWidget/applications/party/servicedef/services.xml Tue Oct 30 21:19:31 2012 @@ -1355,4 +1355,180 @@ under the License. <attribute name="userLoginId" type="String" mode="IN" optional="false"/> <attribute name="productStoreId" type="String" mode="IN" optional="false"/> </service> + + <!--#Bam# contactMechMgmtPortlet--> + <service name="removePartyContactMechPurpose" engine="java" + location="org.ofbiz.party.contact.ContactMechServices" invoke="removePartyContactMechPurpose" auth="true"> + <description>Remove a Party ContactMech Purpose from database</description> + <attribute name="partyId" type="String" mode="IN" optional="true"/> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/> + </service> + + <service name="updatePartyContactMechPurpose" engine="java" + location="org.ofbiz.party.contact.ContactMechServices" invoke="updatePartyContactMechPurpose" auth="true"> + <description>Update a Party ContactMech Purpose</description> + <attribute name="partyId" type="String" mode="IN" optional="true"/> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/> + <attribute name="thruDate" type="Timestamp" mode="IN" optional="true"/> + </service> + + <service name="createGivenTelecomNumber" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="createGivenTelecomNumber" auth="true"> + <description>Create telecom number for given 'entity' and given 'primaryId'</description> + <auto-attributes entity-name="TelecomNumber" include="all" mode="IN" optional="true"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="allowSolicitation" type="String" mode="IN" optional="true"/> + <attribute name="extension" type="String" mode="IN" optional="true"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="true"/> + </service> + + <service name="updateGivenTelecomNumber" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="updateGivenTelecomNumber" auth="true"> + <description>Update telecom number for given 'entity' and given 'primaryId'</description> + <auto-attributes entity-name="TelecomNumber" include="all" mode="IN" optional="true"/> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="allowSolicitation" type="String" mode="IN" optional="true"/> + <attribute name="extension" type="String" mode="IN" optional="true"/> + </service> + + <service name="createContactMechEntity" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="createContactMechEntity" auth="true"> + <description>Create contactMech for given 'entity' and given 'primaryId'</description> + <auto-attributes entity-name="ContactMech" include="all" mode="IN" optional="true"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="allowSolicitation" type="String" mode="IN" optional="true"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="true"/> + </service> + + <service name="updateContactMechEntity" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="updateContactMechEntity" auth="true"> + <description>Update contactMech for given 'entity' and given 'primaryId'</description> + <auto-attributes entity-name="ContactMech" include="all" mode="IN" optional="true"/> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/> + <attribute name="thruDate" type="Timestamp" mode="IN" optional="true"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="allowSolicitation" type="String" mode="IN" optional="true"/> + </service> + + <service name="createGivenPostalAddress" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="createGivenPostalAddress" auth="true"> + <description>Create telecom number for given 'entity' and given 'primaryId'</description> + <auto-attributes entity-name="PostalAddress" include="all" mode="IN" optional="true"/> + <attribute name="cityGeoId" type="String" mode="IN" optional="true"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="allowSolicitation" type="String" mode="IN" optional="true"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="true"/> + </service> + + <service name="updateGivenPostalAddress" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="updateGivenPostalAddress" auth="true"> + <description>Update telecom number for given 'entity' and given 'primaryId'</description> + <auto-attributes entity-name="PostalAddress" include="all" mode="IN" optional="true"/> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="cityGeoId" type="String" mode="IN" optional="true"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="allowSolicitation" type="String" mode="IN" optional="true"/> + </service> + + <service name="createGivenEmailAddress" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="createGivenEmailAddress" auth="true"> + <description>Create telecom number for given 'entity' and given 'primaryId'</description> + <attribute name="emailAddress" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="allowSolicitation" type="String" mode="IN" optional="true"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="true"/> + </service> + + <service name="updateGivenEmailAddress" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="updateGivenEmailAddress" auth="true"> + <description>Update telecom number for given 'entity' and given 'primaryId'</description> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="emailAddress" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="allowSolicitation" type="String" mode="IN" optional="true"/> + </service> + + <service name="deleteGivenContactMech" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="deleteGivenContactMech" auth="true"> + <description>Delete contactMech for given 'entity' and given 'primaryId'</description> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="String" mode="IN" optional="true"/> + </service> + + <service name="updateGivenContactMech" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="updateGivenContactMech" auth="true"> + <description>Update contactMech for given 'entity' and given 'primaryId'</description> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="String" mode="IN" optional="false"/> + <attribute name="thruDate" type="String" mode="IN" optional="true"/> + </service> + + <service name="removeGivenContactMech" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="removeGivenContactMech" auth="true"> + <description>Delete contactMech for given 'entity' and given 'primaryId'</description> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="String" mode="IN" optional="true"/> + </service> + + <service name="createGivenContactMechPurpose" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="createGivenContactMechPurpose" auth="true"> + <description>Create contactMechPurpose for given 'entity' and given 'primaryId'</description> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + </service> + + <service name="updateGivenContactMechPurpose" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="updateGivenContactMechPurpose" auth="true"> + <description>Update contactMechPurpose for given 'entity' and given 'primaryId'</description> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="String" mode="IN" optional="false"/> + <attribute name="thruDate" type="String" mode="IN" optional="true"/> + </service> + + <service name="deleteGivenContactMechPurpose" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="deleteGivenContactMechPurpose" auth="true"> + <description>Deactivate contactMechPurpose for given 'entity' and given 'primaryId'</description> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/> + </service> + + <service name="removeGivenContactMechPurpose" engine="simple" + location="component://party/script/org/ofbiz/party/contact/ContactMechPortletServices.xml" invoke="removeGivenContactMechPurpose" auth="true"> + <description>Remove contactMechPurpose for given 'entity' and given 'primaryId'</description> + <attribute name="contactMechId" type="String" mode="IN" optional="false"/> + <attribute name="contactMechPurposeTypeId" type="String" mode="IN" optional="false"/> + <attribute name="primaryId" type="String" mode="IN" optional="false"/> + <attribute name="entity" type="String" mode="IN" optional="false"/> + <attribute name="fromDate" type="String" mode="IN" optional="false"/> + </service> + <!--#Eam# contactMechMgmtPortlet--> </services> Modified: ofbiz/branches/20120329_portletWidget/applications/party/servicedef/services_view.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/servicedef/services_view.xml?rev=1403874&r1=1403873&r2=1403874&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/applications/party/servicedef/services_view.xml (original) +++ ofbiz/branches/20120329_portletWidget/applications/party/servicedef/services_view.xml Tue Oct 30 21:19:31 2012 @@ -25,15 +25,24 @@ under the License. <version>1.0</version> <!-- Party view services --> + <!--#Bam# portlet-party --> + <!-- <service name="findParty" engine="java" location="org.ofbiz.party.party.PartyServices" invoke="findParty"> <description>General Party Find Service, Used in the findparty page in the Party Manager, etc</description> <attribute name="extInfo" type="String" mode="IN" optional="true"/> - <attribute name="roleTypeId" type="String" mode="IN" optional="true"/> <!-- can be null or ANY to include any --> + <attribute name="roleTypeId" type="String" mode="IN" optional="true"/> --><!-- can be null or ANY to include any --> + <!-- <attribute name="VIEW_INDEX" type="String" mode="IN" optional="true"/> <attribute name="VIEW_SIZE" type="String" mode="IN" optional="true"/> + --> + <service name="interfaceFindParty" engine="interface"> + <!--#Eam# portlet-party --> <attribute name="lookupFlag" type="String" mode="IN" optional="true"/> + <!--#Bam# portlet-party <attribute name="showAll" type="String" mode="IN" optional="true"/> + --> + <attribute name="roleTypeId" type="String" mode="IN" optional="true"/> <!-- can be null or ANY to include any --> <attribute name="partyId" type="String" mode="IN" optional="true"/> <!-- does a LIKE compare on this, can do partial, case insensitive, etc --> <attribute name="partyTypeId" type="String" mode="IN" optional="true"/> <attribute name="userLoginId" type="String" mode="IN" optional="true"/> <!-- does a LIKE compare on this, can do partial, case insensitive, etc --> @@ -55,6 +64,23 @@ under the License. <attribute name="partyRelationshipTypeId" type="String" mode="IN" optional="true"/> <attribute name="ownerPartyIds" type="List" mode="IN" optional="true"/><!-- Lead Owners Parties --> <attribute name="sortField" type="String" mode="IN" optional="true"/> + <!--#Bam# portlet-party --> + <attribute name="statusId" type="String" mode="IN" optional="true"/> + <attribute name="roleTypeGroupId" type="String" mode="IN" optional="true"/> + <attribute name="contactName" type="String" mode="IN" optional="true"/> + <attribute name="countryGeoId" type="String" mode="IN" optional="true"/> + <attribute name="partyClassificationGroupId" type="List" mode="IN" optional="true"/> + <attribute name="comments" type="String" mode="IN" optional="true"/> + </service> + <service name="findParty" engine="java" + location="org.ofbiz.party.party.PartyServices" invoke="findParty"> + <description>General Party Find Service, Used in the findparty page in the Party Manager, etc</description> + <implements service="interfaceFindParty" optional="true"/> + <attribute name="extInfo" type="String" mode="IN" optional="true"/> + <attribute name="VIEW_INDEX" type="String" mode="IN" optional="true"/> + <attribute name="VIEW_SIZE" type="String" mode="IN" optional="true"/> + <attribute name="showAll" type="String" mode="IN" optional="true"/> + <!--#Eam# portlet-party --> <attribute name="roleTypes" type="List" mode="OUT" optional="false"/> <attribute name="partyTypes" type="List" mode="OUT" optional="false"/> @@ -71,6 +97,22 @@ under the License. <attribute name="sortField" type="String" mode="OUT" optional="true"/> </service> + <!--#Bam# portlet-party --> + <service name="performFindParty" engine="java" + location="org.ofbiz.party.party.PartyServices" invoke="performFindParty"> + <description>General Party Find Service, Used in the findparty page in the Party Manager, etc</description> + <implements service="interfaceFindParty" optional="true"/> + <attribute name="viewSize" type="Integer" mode="IN" optional="true"/> + <attribute name="viewIndex" type="Integer" mode="IN" optional="true"/> + <attribute name="orderBy" type="String" mode="IN" optional="true"/> + + <attribute name="listIt" type="org.ofbiz.entity.util.EntityListIterator" mode="OUT" optional="true"/> + <attribute name="listSize" type="Integer" mode="OUT" optional="true"/> + <attribute name="queryString" type="String" mode="OUT" optional="true"/> + <attribute name="queryStringMap" type="java.util.Map" mode="OUT" optional="true"/> + </service> + <!--#Eam# portlet-party --> + <service name="getPartyContactMechValueMaps" engine="java" transaction-timeout="7200" location="org.ofbiz.party.contact.ContactMechServices" invoke="getPartyContactMechValueMaps" auth="true"> Modified: ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java?rev=1403874&r1=1403873&r2=1403874&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java (original) +++ ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java Tue Oct 30 21:19:31 2012 @@ -257,13 +257,27 @@ public class ContactMechWorker { } public static Collection<Map<String, GenericValue>> getWorkEffortContactMechValueMaps(Delegator delegator, String workEffortId) { + //#Bam# ContactMechMgmtPortlet + return getWorkEffortContactMechValueMaps(delegator, workEffortId, false); + } + + public static Collection<Map<String, GenericValue>> getWorkEffortContactMechValueMaps(Delegator delegator, String workEffortId, boolean showOld) { + //#Eam# ContactMechMgmtPortlet Collection<Map<String, GenericValue>> workEffortContactMechValueMaps = FastList.newInstance(); List<GenericValue> allWorkEffortContactMechs = null; try { List<GenericValue> workEffortContactMechs = delegator.findByAnd("WorkEffortContactMech", UtilMisc.toMap("workEffortId", workEffortId), null, false); +// #Bam# ContactMechMgmtPortlet + /* allWorkEffortContactMechs = EntityUtil.filterByDate(workEffortContactMechs); + */if (!showOld) { + allWorkEffortContactMechs = EntityUtil.filterByDate(workEffortContactMechs); + } else { + allWorkEffortContactMechs = workEffortContactMechs; + } +// #Eam# ContactMechMgmtPortlet } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -305,8 +319,147 @@ public class ContactMechWorker { return workEffortContactMechValueMaps.size() > 0 ? workEffortContactMechValueMaps : null; } + +// #Bam# ContactMechMgmtPortlet + @SuppressWarnings("deprecation") + public static void getWorkEffortContactMechAndRelated(ServletRequest request, String workEffortId, Map<String, Object> target, boolean showOld) { + 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; + + String donePage = request.getParameter("DONE_PAGE"); + if (donePage == null) donePage = (String) request.getAttribute("DONE_PAGE"); + if (donePage == null || donePage.length() <= 0) donePage = "viewprofile"; + target.put("donePage", donePage); + + String contactMechTypeId = request.getParameter("preContactMechTypeId"); + if (contactMechTypeId == null) contactMechTypeId = (String) request.getAttribute("preContactMechTypeId"); + if (contactMechTypeId != null) + tryEntity = false; + + String contactMechId = request.getParameter("contactMechId"); + if (request.getAttribute("contactMechId") != null) + contactMechId = (String) request.getAttribute("contactMechId"); + + GenericValue contactMech = null; + if (contactMechId != null) { + target.put("contactMechId", contactMechId); + + // try to find a WorkEffortContactMech with a valid date range + List<GenericValue> workEffortContactMechs = null; + + try { + workEffortContactMechs = delegator.findByAnd("WorkEffortContactMech", UtilMisc.toMap("workEffortId", workEffortId, "contactMechId", contactMechId), null, false); + if (!showOld) workEffortContactMechs = EntityUtil.filterByDate(workEffortContactMechs, true); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + + GenericValue workEffortContactMech = EntityUtil.getFirst(workEffortContactMechs); + if (workEffortContactMech != null) { + target.put("workEffortContactMech", workEffortContactMech); + } + + try { + contactMech = delegator.findOne("ContactMech", UtilMisc.toMap("contactMechId", contactMechId), false); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + + if (contactMech != null) { + target.put("contactMech", contactMech); + contactMechTypeId = contactMech.getString("contactMechTypeId"); + } + } + + if (contactMechTypeId != null) { + target.put("contactMechTypeId", contactMechTypeId); + + try { + GenericValue contactMechType = delegator.findOne("ContactMechType", UtilMisc.toMap("contactMechTypeId", contactMechTypeId), false); + + if (contactMechType != null) + target.put("contactMechType", contactMechType); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + } + + String requestName; + if (contactMech == null) { + // create + if ("POSTAL_ADDRESS".equals(contactMechTypeId)) { + if (request.getParameter("contactMechPurposeTypeId") != null || request.getAttribute("contactMechPurposeTypeId") != null) { + requestName = "createPostalAddressAndPurpose"; + } else { + requestName = "createPostalAddress"; + } + } else if ("TELECOM_NUMBER".equals(contactMechTypeId)) { + requestName = "createTelecomNumber"; + } else if ("EMAIL_ADDRESS".equals(contactMechTypeId)) { + requestName = "createEmailAddress"; + } else { + requestName = "createContactMech"; + } + } else { + // update + if ("POSTAL_ADDRESS".equals(contactMechTypeId)) { + requestName = "updatePostalAddress"; + } else if ("TELECOM_NUMBER".equals(contactMechTypeId)) { + requestName = "updateTelecomNumber"; + } else if ("EMAIL_ADDRESS".equals(contactMechTypeId)) { + requestName = "updateEmailAddress"; + } else { + requestName = "updateContactMech"; + } + } + target.put("requestName", requestName); + + if ("POSTAL_ADDRESS".equals(contactMechTypeId)) { + GenericValue postalAddress = null; + + try { + if (contactMech != null) postalAddress = contactMech.getRelatedOne("PostalAddress", false); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + 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); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + if (telecomNumber != null) target.put("telecomNumber", telecomNumber); + } + + if ("true".equals(request.getParameter("useValues"))) tryEntity = true; + target.put("tryEntity", Boolean.valueOf(tryEntity)); + try { + Collection<GenericValue> contactMechTypes = delegator.findList("ContactMechType", null, null, null, null, true); + + if (contactMechTypes != null) { + target.put("contactMechTypes", contactMechTypes); + } + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + } +// #Eam# ContactMechMgmtPortlet + public static void getContactMechAndRelated(ServletRequest request, String partyId, Map<String, Object> target) { +// #Bam# ContactMechMgmtPortlet + getContactMechAndRelated(request, partyId, target, false); + } + + @SuppressWarnings("deprecation") + public static void getContactMechAndRelated(ServletRequest request, String partyId, Map<String, Object> target, boolean showOld) { +// #Eam# ContactMechMgmtPortlet Delegator delegator = (Delegator) request.getAttribute("delegator"); boolean tryEntity = true; @@ -338,7 +491,13 @@ public class ContactMechWorker { List<GenericValue> partyContactMechs = null; try { +// #Bam# ContactMechMgmtPortlet + /* partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), null, false), true); + */ + partyContactMechs = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), null, false); + if (!showOld) partyContactMechs = EntityUtil.filterByDate(partyContactMechs, true); +// #Eam# ContactMechMgmtPortlet } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -351,7 +510,13 @@ public class ContactMechWorker { Collection<GenericValue> partyContactMechPurposes = null; try { +// #Bam# ContactMechMgmtPortlet + /* partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose", null, null, false), true); + */ + partyContactMechPurposes = partyContactMech.getRelated("PartyContactMechPurpose", null, null, false); + if (!showOld) partyContactMechPurposes = EntityUtil.filterByDate((List<GenericValue>) partyContactMechPurposes, true); +// #Eam# ContactMechMgmtPortlet } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -519,6 +684,13 @@ public class ContactMechWorker { } public static void getFacilityContactMechAndRelated(ServletRequest request, String facilityId, Map<String, Object> target) { +// #Bam# ContactMechMgmtPortlet + getFacilityContactMechAndRelated(request, facilityId, target, false); + } + + @SuppressWarnings("deprecation") + public static void getFacilityContactMechAndRelated(ServletRequest request, String facilityId, Map<String, Object> target, boolean showOld) { +// #Bam# ContactMechMgmtPortlet Delegator delegator = (Delegator) request.getAttribute("delegator"); boolean tryEntity = true; @@ -550,7 +722,13 @@ public class ContactMechWorker { List<GenericValue> facilityContactMechs = null; try { +// #Bam# ContactMechMgmtPortlet + /* facilityContactMechs = EntityUtil.filterByDate(delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId, "contactMechId", contactMechId), null, false), true); + */ + facilityContactMechs = delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId, "contactMechId", contactMechId), null, false); + if (!showOld) facilityContactMechs = EntityUtil.filterByDate(facilityContactMechs, true); +// #Eam# ContactMechMgmtPortlet } catch (GenericEntityException e) { Debug.logWarning(e, module); } @@ -563,7 +741,13 @@ public class ContactMechWorker { Collection<GenericValue> facilityContactMechPurposes = null; try { +// #Bam# ContactMechMgmtPortlet + /* facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMech.getRelated("FacilityContactMechPurpose", null, null, false), true); + */ + facilityContactMechPurposes = facilityContactMech.getRelated("FacilityContactMechPurpose", null, null, false); + if (!showOld) facilityContactMechPurposes = EntityUtil.filterByDate((List<GenericValue>) facilityContactMechPurposes, true); +// #Eam# ContactMechMgmtPortlet } catch (GenericEntityException e) { Debug.logWarning(e, module); } Modified: ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/party/PartyServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/party/PartyServices.java?rev=1403874&r1=1403873&r2=1403874&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/party/PartyServices.java (original) +++ ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/party/PartyServices.java Tue Oct 30 21:19:31 2012 @@ -21,6 +21,7 @@ package org.ofbiz.party.party; import java.sql.Timestamp; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -33,6 +34,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; @@ -45,7 +47,6 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityFunction; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.DynamicViewEntity; -import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.entity.util.EntityTypeUtil; @@ -993,12 +994,89 @@ public class PartyServices { return ServiceUtil.returnSuccess(); } + // #Bam# Portlet-Party + public static Map<String, Object> performFindParty(DispatchContext dctx, Map<String, ? extends Object> context) { + Map<String, Object> result = ServiceUtil.returnSuccess(); + Delegator delegator = dctx.getDelegator(); + GenericValue userLogin = (GenericValue) context.get("userLogin"); + Locale locale = (Locale) context.get("locale"); + List<String> orderBy = null; + if (context.containsKey("orderBy")) orderBy = UtilMisc.toList((String)context.get("orderBy")); + boolean lookupFlag = "Y".equals(context.get("lookupFlag")); + Integer viewSize = (Integer) context.get("viewSize"); + Integer viewIndex = (Integer) context.get("viewIndex"); + Integer maxRows = null; + if (viewSize != null && viewIndex != null) { + maxRows = viewSize * (viewIndex + 1); + } else { + maxRows = -1; + } + + Map<String, ? extends Object> prepareFind = null; + EntityListIterator listIt = null; + int listSize = 0; + try { + prepareFind = PartyWorker.preparePartyDynamicViewAndCondition(delegator, context, userLogin); + + // set distinct on so we only get one row per order + EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, -1, maxRows, true); + + //Retrieve search elements + DynamicViewEntity dynamicView = (DynamicViewEntity) prepareFind.get("dynamicView"); + List<String> fieldsToSelect = UtilGenerics.checkList( prepareFind.get("fieldsToSelect") ); + EntityCondition mainCond = (EntityCondition) prepareFind.get("conditions"); + + //filter orderBy field only on available field selected + if (UtilValidate.isNotEmpty(orderBy) && UtilValidate.isNotEmpty(fieldsToSelect)) { + List<String> availableField = FastList.newInstance(); + for (String orderField : orderBy) { + String fieldToOrder = orderField; + if (orderField.startsWith("-")) { + fieldToOrder = orderField.replace("-",""); + } + if (fieldsToSelect.contains(fieldToOrder)) { + availableField.add(orderField); + } + } + orderBy = availableField; + } + if (lookupFlag) { + // using list iterator + listIt = delegator.findListIteratorByCondition(dynamicView, mainCond, null, fieldsToSelect, orderBy, findOpts); + listSize = listIt.getResultsSizeAfterPartialList(); + } + } 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, + "PartyLookupPartyError", + UtilMisc.toMap("errMessage", e.toString()), locale)); + } + + if (listSize > 0) { + Map<String, Object> queryMap = FastMap.newInstance(); + queryMap.putAll(context); + queryMap.remove("locale"); + queryMap.remove("userLogin"); + queryMap.remove("timeZone"); + result.put("queryString", UtilHttp.urlEncodeArgs(queryMap, true)); + result.put("queryStringMap", queryMap); + } + result.put("listIt", listIt); + result.put("listSize", listSize); + return result; + } + //#Eam# Portlet-Party + public static Map<String, Object> findParty(DispatchContext dctx, Map<String, ? extends Object> context) { Map<String, Object> result = ServiceUtil.returnSuccess(); Delegator delegator = dctx.getDelegator(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Locale locale = (Locale) context.get("locale"); + + // #Bam# Portlet-Party + /* String extInfo = (String) context.get("extInfo"); // get the role types @@ -1486,6 +1564,184 @@ public class PartyServices { return result; } + */ + // get the role types + try { + List<GenericValue> roleTypes = delegator.findList("RoleType", null, null, UtilMisc.toList("description"), null, false); + 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, + "PartyLookupRoleTypeError", + UtilMisc.toMap("errMessage", e.toString()), locale)); + } + // current role type + String roleTypeId; + try { + roleTypeId = (String) context.get("roleTypeId"); + if (UtilValidate.isNotEmpty(roleTypeId)) { + GenericValue currentRole = delegator.findOne("RoleType", UtilMisc.toMap("roleTypeId", roleTypeId), true); + result.put("currentRole", currentRole); + } + } catch (GenericEntityException e) { + String errMsg = "Error looking up current RoleType: " + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "PartyLookupRoleTypeError", + UtilMisc.toMap("errMessage", e.toString()), locale)); + } + + //get party types + try { + List<GenericValue> partyTypes = delegator.findList("PartyType", null, null, UtilMisc.toList("description"), null, false); + 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, + "PartyLookupPartyTypeError", + UtilMisc.toMap("errMessage", e.toString()), locale)); + } + + // current party type + String partyTypeId; + try { + partyTypeId = (String) context.get("partyTypeId"); + if (UtilValidate.isNotEmpty(partyTypeId)) { + GenericValue currentPartyType = delegator.findOne("PartyType", UtilMisc.toMap("partyTypeId", partyTypeId), true); + result.put("currentPartyType", currentPartyType); + } + } catch (GenericEntityException e) { + String errMsg = "Error looking up current PartyType: " + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "PartyLookupPartyTypeError", + UtilMisc.toMap("errMessage", e.toString()), locale)); + } + + // current state + String stateProvinceGeoId; + try { + stateProvinceGeoId = (String) context.get("stateProvinceGeoId"); + if (UtilValidate.isNotEmpty(stateProvinceGeoId)) { + GenericValue currentStateGeo = delegator.findOne("Geo", UtilMisc.toMap("geoId", stateProvinceGeoId), true); + result.put("currentStateGeo", currentStateGeo); + } + } catch (GenericEntityException e) { + String errMsg = "Error looking up current stateProvinceGeo: " + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "PartyLookupStateProvinceGeoError", + UtilMisc.toMap("errMessage", e.toString()), locale)); + } + + // set the page parameters + int viewIndex = 0; + try { + viewIndex = Integer.parseInt((String) context.get("VIEW_INDEX")); + } catch (Exception e) { + viewIndex = 0; + } + result.put("viewIndex", Integer.valueOf(viewIndex)); + + int viewSize = 20; + try { + viewSize = Integer.parseInt((String) context.get("VIEW_SIZE")); + } catch (Exception e) { + viewSize = 20; + } + result.put("viewSize", Integer.valueOf(viewSize)); + + // get the lookup flag + String lookupFlag = (String) context.get("lookupFlag"); + + // prepare param list + Map<String, Object> queryMap = FastMap.newInstance(); + queryMap.putAll(context); + queryMap.remove("locale"); + queryMap.remove("userLogin"); + queryMap.remove("timeZone"); + queryMap.remove("VIEW_SIZE"); + queryMap.remove("VIEW_INDEX"); + String paramList = "&" + UtilHttp.urlEncodeArgs(queryMap, false); + + List<GenericValue> partyList = null; + int partyListSize = 0; + int lowIndex = 0; + int highIndex = 0; + + List<String> orderBy = FastList.newInstance(); + if ("Y".equals(lookupFlag)) { + String showAll = (context.get("showAll") != null ? (String) context.get("showAll") : "N"); + Map<String, ? extends Object> prepareFind = null; + Map<String, ? extends Object> transmitMap = showAll.equals("N")?context : new HashMap<String, Object>(); + try { + prepareFind = PartyWorker.preparePartyDynamicViewAndCondition(delegator, transmitMap, userLogin); + } 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, + "PartyLookupPartyError", + UtilMisc.toMap("errMessage", e.toString()), locale)); + } + + if (!"Y".equals(showAll)) { + // check for a partyId + if (UtilValidate.isNotEmpty(context.get("firstName")) || UtilValidate.isNotEmpty(context.get("lastName"))) { + orderBy.add("lastName"); + orderBy.add("firstName"); + } + } + + // do the lookup + EntityCondition mainCond = (EntityCondition) prepareFind.get("conditions"); + if (mainCond != null || "Y".equals(showAll)) { + try { + // get the indexes for the partial list + lowIndex = viewIndex * viewSize + 1; + highIndex = (viewIndex + 1) * viewSize; + + // set distinct on so we only get one row per order + EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, -1, highIndex, true); + // using list iterator + DynamicViewEntity dynamicView = (DynamicViewEntity) prepareFind.get("dynamicView"); + List<String> fieldsToSelect = UtilGenerics.checkList( prepareFind.get("fieldsToSelect") ); + EntityListIterator pli = delegator.findListIteratorByCondition(dynamicView, mainCond, null, fieldsToSelect, orderBy, findOpts); + + // get the partial list for this page + partyList = pli.getPartialList(lowIndex, viewSize); + + // attempt to get the full size + partyListSize = pli.getResultsSizeAfterPartialList(); + if (highIndex > partyListSize) { + highIndex = partyListSize; + } + + // close the list iterator + pli.close(); + } 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, + "PartyLookupPartyError", + UtilMisc.toMap("errMessage", e.toString()), locale)); + } + } else { + partyListSize = 0; + } + } + + if (partyList == null) partyList = FastList.newInstance(); + result.put("partyList", partyList); + result.put("partyListSize", Integer.valueOf(partyListSize)); + result.put("paramList", paramList); + result.put("highIndex", Integer.valueOf(highIndex)); + result.put("lowIndex", Integer.valueOf(lowIndex)); + + return result; + } + // #Eam# Portlet-Party /** * Changes the association of contact mechs, purposes, notes, orders and attributes from Modified: ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/party/PartyWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/party/PartyWorker.java?rev=1403874&r1=1403873&r2=1403874&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/party/PartyWorker.java (original) +++ ofbiz/branches/20120329_portletWidget/applications/party/src/org/ofbiz/party/party/PartyWorker.java Tue Oct 30 21:19:31 2012 @@ -44,6 +44,14 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.util.EntityUtil; +//#Bam# Portlet-Party +import org.ofbiz.base.util.StringUtil; +import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.entity.condition.EntityDateFilterCondition; +import org.ofbiz.entity.model.DynamicViewEntity; +import org.ofbiz.entity.model.ModelKeyMap; +//#Eam# Portlet-Party /** * Worker methods for Party Information @@ -108,6 +116,471 @@ public class PartyWorker { return clubId; } + // #Bam# Portlet-Party + public static Map<String, ? extends Object> preparePartyDynamicViewAndCondition(Delegator delegator, Map<String, ? extends Object> context, GenericValue userLogin) + throws GenericEntityException { + + List<String> orderBy = FastList.newInstance(); + List<String> fieldsToSelect = FastList.newInstance(); + DynamicViewEntity dynamicView = new DynamicViewEntity(); + + // default view settings + dynamicView.addMemberEntity("PT", "Party"); + dynamicView.addAlias("PT", "partyId"); + dynamicView.addAlias("PT", "statusId"); + dynamicView.addAlias("PT", "partyTypeId"); + dynamicView.addRelation("one-nofk", "", "PartyType", ModelKeyMap.makeKeyMapList("partyTypeId")); + dynamicView.addRelation("many", "", "UserLogin", ModelKeyMap.makeKeyMapList("partyId")); + + // define the main condition & expression list + List<EntityCondition> andExprs = FastList.newInstance(); + + // fields we need to select; will be used to set distinct + fieldsToSelect.add("partyId"); + fieldsToSelect.add("statusId"); + fieldsToSelect.add("partyTypeId"); + + // filter on parties that have relationship with logged in user + String partyRelationshipTypeId = (String) context.get("partyRelationshipTypeId"); + if (UtilValidate.isNotEmpty(partyRelationshipTypeId)) { + // add relation to view + dynamicView.addMemberEntity("PRSHP", "PartyRelationship"); + dynamicView.addAlias("PRSHP", "partyIdTo"); + dynamicView.addAlias("PRSHP", "partyRelationshipTypeId"); + dynamicView.addViewLink("PT", "PRSHP", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId", "partyIdTo")); + List<String> ownerPartyIds = UtilGenerics.cast(context.get("ownerPartyIds")); + EntityCondition relationshipCond = null; + if (UtilValidate.isEmpty(ownerPartyIds)) { + String partyIdFrom = userLogin.getString("partyId"); + relationshipCond = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyIdFrom"), EntityOperator.EQUALS, EntityFunction.UPPER(partyIdFrom)); + } else { + relationshipCond = EntityCondition.makeCondition("partyIdFrom", EntityOperator.IN, ownerPartyIds); + } + dynamicView.addAlias("PRSHP", "partyIdFrom"); + // add the expr + andExprs.add(EntityCondition.makeCondition( + relationshipCond, EntityOperator.AND, + EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyRelationshipTypeId"), EntityOperator.EQUALS, EntityFunction.UPPER(partyRelationshipTypeId)))); + fieldsToSelect.add("partyIdTo"); + } + + String contactName = (String) context.get("contactName"); + if (UtilValidate.isNotEmpty(contactName)) { + // add relation to view + dynamicView.addMemberEntity("PRSHPC", "PartyRelationship"); + dynamicView.addAlias("PRSHPC", "contactPartyId","partyIdTo","contactPartyId",Boolean.FALSE,Boolean.FALSE,null); + dynamicView.addAlias("PRSHPC", "contactRelationshipTypeId","partyRelationshipTypeId","contactRelationshipTypeId",Boolean.FALSE,Boolean.FALSE,null); + dynamicView.addAlias("PRSHPC", "contactThruDate","thruDate","contactThruDate",Boolean.FALSE,Boolean.FALSE,null); + dynamicView.addViewLink("PT", "PRSHPC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId", "partyIdFrom")); + + dynamicView.addMemberEntity("PRSHPPTY", "Party"); + dynamicView.addViewLink("PRSHPC", "PRSHPPTY", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyIdTo", "partyId")); + + dynamicView.addMemberEntity("PRSHPPSN", "Person"); + dynamicView.addAlias("PRSHPPSN", "contactName","lastName","contactName",Boolean.FALSE,Boolean.FALSE,null); + dynamicView.addViewLink("PRSHPPTY", "PRSHPPSN", Boolean.TRUE, ModelKeyMap.makeKeyMapList("partyId")); + + dynamicView.addMemberEntity("PRSHPPTG", "PartyGroup"); + dynamicView.addAlias("PRSHPPTG", "contactGroupName","groupName","contactGroupName",Boolean.FALSE,Boolean.FALSE,null); + dynamicView.addViewLink("PRSHPPTY", "PRSHPPTG", Boolean.TRUE, ModelKeyMap.makeKeyMapList("partyId")); + + //add condition + EntityCondition contactNameCondition = EntityCondition.makeCondition( + EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("contactName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+contactName+"%")), EntityOperator.OR, + EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("contactGroupName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+contactName+"%"))); + fieldsToSelect.add("contactName"); + fieldsToSelect.add("contactGroupName"); + + // add the expr + andExprs.add(EntityCondition.makeCondition( + EntityCondition.makeCondition( + EntityCondition.makeCondition("contactThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, + EntityCondition.makeCondition("contactThruDate", EntityOperator.GREATER_THAN_EQUAL_TO, UtilDateTime.nowTimestamp())), + EntityOperator.AND, + contactNameCondition)); + } + + // get the params + String partyId = (String) context.get("partyId"); + String statusId = (String) context.get("statusId"); + String userLoginId = (String) context.get("userLoginId"); + String firstName = (String) context.get("firstName"); + String lastName = (String) context.get("lastName"); + String groupName = (String) context.get("groupName"); + String partyTypeId = (String) context.get("partyTypeId"); + String roleTypeId = (String) context.get("roleTypeId"); + String stateProvinceGeoId = (String) context.get("stateProvinceGeoId"); + + // check for a partyId + if (UtilValidate.isNotEmpty(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 + if (statusId != null) { + if (!"ANY".equalsIgnoreCase(statusId)) { + andExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, 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", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED"))); + } + // check for partyTypeId + if (partyTypeId != null && !"ANY".equals(partyTypeId)) { + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyTypeId"), EntityOperator.LIKE, EntityFunction.UPPER("%"+partyTypeId+"%"))); + } + + // ---- + // UserLogin Fields + // ---- + + // filter on user login + if (UtilValidate.isNotEmpty(userLoginId)) { + + // modify the dynamic view + dynamicView.addMemberEntity("UL", "UserLogin"); + dynamicView.addAlias("UL", "userLoginId"); + 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+"%"))); + + fieldsToSelect.add("userLoginId"); + + } + + // ---- + // PartyGroup Fields + // ---- + + // filter on groupName + if (UtilValidate.isNotEmpty(groupName)) { + + // modify the dynamic view + dynamicView.addMemberEntity("PG", "PartyGroup"); + dynamicView.addAlias("PG", "groupName"); + 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+"%"))); + + fieldsToSelect.add("groupName"); + } + + // ---- + // Person Fields + // ---- + + // modify the dynamic view + if (UtilValidate.isNotEmpty(firstName) || UtilValidate.isNotEmpty(lastName)) { + dynamicView.addMemberEntity("PE", "Person"); + dynamicView.addAlias("PE", "firstName"); + dynamicView.addAlias("PE", "lastName"); + dynamicView.addViewLink("PT", "PE", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); + + fieldsToSelect.add("firstName"); + fieldsToSelect.add("lastName"); + orderBy.add("lastName"); + orderBy.add("firstName"); + } + + // filter on firstName + if (UtilValidate.isNotEmpty(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+"%"))); + } + + // ---- + // RoleType Fields + // ---- + + // filter on role member + if (roleTypeId != null && !"ANY".equals(roleTypeId)) { + + // add role to view + dynamicView.addMemberEntity("PR", "PartyRole"); + dynamicView.addAlias("PR", "roleTypeId"); + dynamicView.addViewLink("PT", "PR", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); + + // add the expr + andExprs.add(EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, roleTypeId)); + + fieldsToSelect.add("roleTypeId"); + } + //Begin addon modification : portlet-party + else if (UtilValidate.isNotEmpty(context.get("roleTypeGroupId"))) { + String roleTypeGroupId = (String) context.get("roleTypeGroupId"); + + //retrieve related roles + List<GenericValue> roles = delegator.findByAnd("RoleType", UtilMisc.toMap("parentTypeId", roleTypeGroupId),null,false); + if (UtilValidate.isNotEmpty(roles)) { + // add role to view + dynamicView.addMemberEntity("PR", "PartyRole"); + dynamicView.addAlias("PR", "roleTypeId"); + dynamicView.addViewLink("PT", "PR", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); + + // add the expr + List<String> roleTypeIds = FastList.newInstance(); + for (GenericValue role : roles) { + roleTypeIds.add(role.getString("roleTypeId")); + } + andExprs.add(EntityCondition.makeCondition("roleTypeId", EntityOperator.IN, roleTypeIds)); + } + } + //End addon modification : portlet-party + + // ---- + // InventoryItem Fields + // ---- + + // filter on inventory item's fields + 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)) { + + // add role to view + dynamicView.addMemberEntity("II", "InventoryItem"); + dynamicView.addAlias("II", "ownerPartyId"); + dynamicView.addViewLink("PT", "II", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId", "ownerPartyId")); + } + if (UtilValidate.isNotEmpty(inventoryItemId)) { + dynamicView.addAlias("II", "inventoryItemId"); + // add the expr + 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 + "%"))); + 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 + "%"))); + fieldsToSelect.add("softIdentifier"); + } + + // ---- + // PostalAddress fields + // ---- + //Begin addon modification : portlet-party + /* + if ("P".equals(extInfo)) { + */ + String extInfo = (String) context.get("extInfo"); + 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)) { + //End addon modification : portlet-party + // add address to dynamic view + dynamicView.addMemberEntity("PC", "PartyContactMech"); + dynamicView.addMemberEntity("PA", "PostalAddress"); + dynamicView.addAlias("PC", "contactMechId"); + dynamicView.addAlias("PA", "address1"); + dynamicView.addAlias("PA", "address2"); + dynamicView.addAlias("PA", "city"); + dynamicView.addAlias("PA", "stateProvinceGeoId"); + dynamicView.addAlias("PA", "countryGeoId"); + dynamicView.addAlias("PA", "postalCode"); + dynamicView.addViewLink("PT", "PC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); + dynamicView.addViewLink("PC", "PA", Boolean.FALSE, ModelKeyMap.makeKeyMapList("contactMechId")); + + // 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 + "%"))); + } + + // 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 + "%"))); + } + + // 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 + "%"))); + } + + // filter on state geo + if (stateProvinceGeoId != null && !"ANY".equals(stateProvinceGeoId)) { + andExprs.add(EntityCondition.makeCondition("stateProvinceGeoId", EntityOperator.EQUALS, stateProvinceGeoId)); + } + + // filter on country geo + String countryGeoId = (String) context.get("countryGeoId"); + if (UtilValidate.isNotEmpty(countryGeoId)) { + andExprs.add(EntityCondition.makeCondition("countryGeoId", EntityOperator.EQUALS, countryGeoId)); + fieldsToSelect.add("countryGeoId"); + } + + // 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 + "%"))); + } + + fieldsToSelect.add("postalCode"); + fieldsToSelect.add("city"); + fieldsToSelect.add("stateProvinceGeoId"); + } + + // ---- + // Generic CM Fields + // ---- + //Begin addon modification : portlet-party + /* + if ("O".equals(extInfo)) { + */ + if ("O".equals(extInfo) || UtilValidate.isNotEmpty(context.get("infoString"))) { + //End addon modification : portlet-party + // add info to dynamic view + dynamicView.addMemberEntity("PC", "PartyContactMech"); + dynamicView.addMemberEntity("CM", "ContactMech"); + dynamicView.addAlias("PC", "contactMechId"); + dynamicView.addAlias("CM", "infoString"); + dynamicView.addViewLink("PT", "PC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); + dynamicView.addViewLink("PC", "CM", Boolean.FALSE, ModelKeyMap.makeKeyMapList("contactMechId")); + + // 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+"%"))); + fieldsToSelect.add("infoString"); + } + + } + + // ---- + // TelecomNumber Fields + // ---- + //Begin addon modification : portlet-party + /* + if ("T".equals(extInfo)) { + */ + if ("T".equals(extInfo) || + UtilValidate.isNotEmpty(context.get("countryCode")) + || UtilValidate.isNotEmpty(context.get("areaCode")) + || UtilValidate.isNotEmpty(context.get("contactNumber"))) { + // add telecom to dynamic view + dynamicView.addMemberEntity("PC", "PartyContactMech"); + dynamicView.addMemberEntity("TM", "TelecomNumber"); + dynamicView.addAlias("PC", "contactMechId"); + dynamicView.addAlias("TM", "countryCode"); + dynamicView.addAlias("TM", "areaCode"); + dynamicView.addAlias("TM", "contactNumber"); + dynamicView.addViewLink("PT", "PC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); + dynamicView.addViewLink("PC", "TM", Boolean.FALSE, ModelKeyMap.makeKeyMapList("contactMechId")); + + // 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))); + } + + // 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))); + } + + // filter on contact number + String contactNumber = (String) context.get("contactNumber"); + //remove non alphanumeric + if (UtilValidate.isNotEmpty(contactNumber)) { + contactNumber = StringUtil.removeNonNumeric(contactNumber); + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("contactNumber"), EntityOperator.EQUALS, EntityFunction.UPPER(contactNumber))); + } + + fieldsToSelect.add("contactNumber"); + fieldsToSelect.add("areaCode"); + } + + //Begin addon modification : portlet-party + List<String> partyClassificationGroupId = UtilGenerics.checkList( context.get("partyClassificationGroupId") ); + if (UtilValidate.isNotEmpty(partyClassificationGroupId)) { + List<EntityCondition> classCond = FastList.newInstance(); + int i = 0; + for (String classificationGroupId : partyClassificationGroupId) { + GenericValue partyClass = null; + partyClass = delegator.findOne("PartyClassificationGroup", true, UtilMisc.toMap("partyClassificationGroupId", classificationGroupId)); + if (partyClass == null) continue; + + // modify the dynamic view + dynamicView.addMemberEntity("PCL" + i, "PartyClassification"); + dynamicView.addAlias("PCL" + i, "partyClassificationGroupId" + i, "partyClassificationGroupId", "partyClassificationGroupId" + i, Boolean.FALSE, Boolean.FALSE, null); + dynamicView.addAlias("PCL" + i, "partyClassificationFromDate" + i, "fromDate", "partyClassificationFromDate" + i, Boolean.FALSE, Boolean.FALSE, null); + dynamicView.addAlias("PCL" + i, "partyClassificationThruDate" + i, "thruDate", "partyClassificationThruDate" + i, Boolean.FALSE, Boolean.FALSE, null); + dynamicView.addViewLink("PT", "PCL" + i, Boolean.TRUE, ModelKeyMap.makeKeyMapList("partyId")); + + dynamicView.addMemberEntity("PCLG" + i, "PartyClassificationGroup"); + dynamicView.addAlias("PCLG" + i, "partyClassificationTypeId" + i, "partyClassificationTypeId", "partyClassificationTypeId" + i, Boolean.FALSE, Boolean.FALSE, null); + dynamicView.addViewLink("PCL" + i, "PCLG" + i, Boolean.TRUE, ModelKeyMap.makeKeyMapList("partyClassificationGroupId")); + + classCond.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyClassificationGroupId" + i), EntityOperator.EQUALS, classificationGroupId)); + classCond.add(EntityDateFilterCondition.makeCondition(UtilDateTime.nowTimestamp(), "partyClassificationFromDate" + i, "partyClassificationThruDate" + i)); + classCond.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("partyClassificationTypeId" + i), EntityOperator.EQUALS, partyClass.get("partyClassificationTypeId"))); + i++; + } + // add the expr + andExprs.add(EntityCondition.makeCondition(classCond)); + //fieldsToSelect.add("partyClassificationGroupId"); + } + + String comments = (String) context.get("comments"); + if (UtilValidate.isNotEmpty(comments) && UtilValidate.isNotEmpty(partyTypeId)) { + if ("PERSON".equals(partyTypeId)) { + // modify the dynamic view + if (UtilValidate.isEmpty(firstName) && UtilValidate.isEmpty(lastName)) { + //Add memberEntity if necessary + dynamicView.addMemberEntity("PE", "Person"); + dynamicView.addViewLink("PT", "PE", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); + } + dynamicView.addAlias("PE", "comments","comments","comments",Boolean.FALSE,Boolean.FALSE,null); + + } else if ("PARTY_GROUP".equals(partyTypeId)) { + // modify the dynamic view + if (UtilValidate.isEmpty(groupName)) { + //Add memberEntity if necessary + dynamicView.addMemberEntity("PG", "PartyGroup"); + dynamicView.addViewLink("PT", "PG", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); + } + dynamicView.addAlias("PG", "comments","comments","comments",Boolean.FALSE,Boolean.FALSE,null); + } + + // add the expr + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("comments"), EntityOperator.LIKE, EntityFunction.UPPER("%"+comments+"%"))); + + fieldsToSelect.add("comments"); + } + + if (context.containsKey("roleTypeGroupId")) { + dynamicView.setGroupBy(fieldsToSelect); + } + + // ---- End of Dynamic View Creation + + // build the main condition + Map<String, Object> result = FastMap.newInstance(); + if (andExprs.size() > 0) result.put("conditions", EntityCondition.makeCondition(andExprs, EntityOperator.AND)); + + result.put("dynamicView", dynamicView); + result.put("fieldsToSelect", fieldsToSelect); + return result; + } + // #Eam# Portlet-Party + public static GenericValue findPartyLatestContactMech(String partyId, String contactMechTypeId, Delegator delegator) { try { List<GenericValue> cmList = delegator.findByAnd("PartyAndContactMech", UtilMisc.toMap("partyId", partyId, "contactMechTypeId", contactMechTypeId), UtilMisc.toList("-fromDate"), false); Added: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/EditGivenContactMech.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/EditGivenContactMech.groovy?rev=1403874&view=auto ============================================================================== --- ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/EditGivenContactMech.groovy (added) +++ ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/EditGivenContactMech.groovy Tue Oct 30 21:19:31 2012 @@ -0,0 +1,47 @@ + +import org.ofbiz.party.contact.*; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.util.EntityUtil; + +//this script is a mix between EditContactMech.groovy from party and from facility + +primaryId = parameters.primaryId; +context.primaryId = primaryId; +boolean showOld = Boolean.valueOf(parameters.SHOW_OLD); +if (UtilValidate.isEmpty(showOld)) { + showOld = false; +} + +mechMap = [:]; //Map mechMap = new HashMap(); + +if ( parameters.entity == "Facility") { + facility = delegator.findOne("Facility", [facilityId : primaryId], false); + context.facility = facility; + ContactMechWorker.getFacilityContactMechAndRelated(request, primaryId, mechMap, showOld); + context.mechMap = mechMap; + +} +else if (parameters.entity == "Party") { + ContactMechWorker.getContactMechAndRelated(request, primaryId, mechMap, showOld); +} else if (parameters.entity == "WorkEffort") { + ContactMechWorker.getWorkEffortContactMechAndRelated(request, primaryId, mechMap, showOld); +} + +context.mechMap = mechMap; + +context.contactMechId = mechMap.contactMechId; +context.preContactMechTypeId = parameters.preContactMechTypeId; +context.paymentMethodId = parameters.paymentMethodId; + +cmNewPurposeTypeId = parameters.contactMechPurposeTypeId; +if (cmNewPurposeTypeId) { + contactMechPurposeType = delegator.findByPrimaryKey("ContactMechPurposeType", [contactMechPurposeTypeId : cmNewPurposeTypeId]); + if (contactMechPurposeType) { + context.contactMechPurposeType = contactMechPurposeType; + } else { + cmNewPurposeTypeId = null; + } + context.cmNewPurposeTypeId = cmNewPurposeTypeId; +} +//context.donePage = parameters.DONE_PAGE ?:"viewprofile?party_id=" + partyId + "&partyId=" + partyId; Propchange: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/EditGivenContactMech.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/EditGivenContactMech.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/EditGivenContactMech.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/FormatCreditCardNumber.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/FormatCreditCardNumber.groovy?rev=1403874&view=auto ============================================================================== --- ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/FormatCreditCardNumber.groovy (added) +++ ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/FormatCreditCardNumber.groovy Tue Oct 30 21:19:31 2012 @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.ofbiz.base.util.UtilValidate; + +//Display only last four digits from card number +if (UtilValidate.isNotEmpty(creditCard) && UtilValidate.isNotEmpty(creditCard.cardNumber)) { + cardNumberDisplay = ""; + cardNumber = creditCard.cardNumber; + size = cardNumber.size() - 4; + if (size >0) { + for (int i = 0; i < size; i++) { + cardNumberDisplay += "*"; + } + cardNumberDisplay += cardNumber[size .. size + 3]; + context.cardNumber = cardNumberDisplay; + } +} \ No newline at end of file Propchange: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/FormatCreditCardNumber.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/FormatCreditCardNumber.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/FormatCreditCardNumber.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain |
| Free forum by Nabble | Edit this page |
