blob: 09dbefcaeac93ab3dd1ebd66a8b11540ab2be813 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" ?>
<!--
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.
-->
<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
<simple-method method-name="createSystemInfoNote" short-description="Create a system to to a specific party">
<set field="partyId" from-field="parameters.partyId" default-value="userLogin.partyId"/>
<!-- new communication events -->
<if-compare field="parameters.entityName" value="CommunicationEvent" operator="equals">
<entity-one entity-name="CommunicationEvent" value-field="comm">
<field-map field-name="communicationEventId" from-field="parameters.entityNameId"/>
</entity-one>
<entity-and entity-name="CommunicationEventRole" list="roles">
<field-map field-name="communicationEventId" from-field="parameters.entityNameId"/>
</entity-and>
<if-not-empty field="roles">
<make-value value-field="noteData" entity-name="NoteData"/>
<now-timestamp field="noteData.noteDateTime"/>
<set field="noteData.noteName" value="SYSTEMNOTE"/>
<set field="noteData.noteInfo" value="New incoming communication event: ${comm.subject} from ${comm.partyIdFrom}"/>
<set field="noteData.moreInfoPortletId" value="MyCommunications"/>
<iterate entry="role" list="roles">
<if-compare field="role.statusId" value="COM_ROLE_CREATED" operator="equals">
<set field="partyId" from-field="role.partyId"/>
<call-simple-method method-name="getPortletAttributeMap"/>
<if>
<condition>
<and><!-- check for 'all' notifications flag off -->
<if-compare field="haveUserLogin" value="true" operator="equals"/>
<if-compare field="attributeMap.allNotifications" value="Y" operator="not-equals"/>
<or>
<and><!-- incoming email for known parties, no notifications for unknown parties -->
<if-compare field="attributeMap.incomingEmail" value="Y" operator="not-equals"/>
<if-compare field="comm.communicationEventTypeId" value="AUTO_EMAIL_COM" operator="equals"/>
</and>
<and><!-- internal sent email -->
<if-compare field="attributeMap.email" value="Y" operator="not-equals"/>
<or>
<if-compare field="comm.communicationEventTypeId" value="AUTO_EMAIL_COMM" operator="equals"/>
<if-compare field="comm.communicationEventTypeId" value="EMAIL_COMMUNICATION" operator="equals"/>
</or>
</and>
<and><!-- internal notes -->
<if-compare field="attributeMap.internalNotes" value="Y" operator="not-equals"/>
<if-compare field="comm.communicationEventTypeId" value="COMMENT_NOTE" operator="equals"/>
</and>
</or>
</and>
</condition>
<then>
<sequenced-id sequence-name="NoteData" field="noteData.noteId"/>
<set field="noteData.noteParty" from-field="role.partyId"/>
<create-value value-field="noteData"/>
</then>
</if>
</if-compare>
</iterate>
</if-not-empty>
</if-compare>
<!-- new task assignments for the logged on user -->
<if-compare field="parameters.entityName" value="WorkEffortPartyAssignment" operator="equals">
<entity-one entity-name="WorkEffort" value-field="workEffort">
<field-map field-name="workEffortId" from-field="parameters.entityNameId"/>
</entity-one>
<if-compare field="workEffort.workEffortTypeId" value="TASK" operator="equals">
<call-simple-method method-name="getPortletAttributeMap"/>
<if-compare field="haveUserLogin" value="true" operator="equals">
<if-compare field="attributeMap.taskAssignment" value="Y" operator="not-equals">
<entity-and entity-name="WorkEffortPartyAssignment" list="assigns" filter-by-date="true">
<field-map field-name="workEffortId" from-field="parameters.entityNameId"/>
<order-by field-name="-fromDate"/>
</entity-and>
<first-from-list entry="assign" list="assigns"/>
<make-value value-field="noteData" entity-name="NoteData"/>
<now-timestamp field="noteData.noteDateTime"/>
<sequenced-id sequence-name="NoteData" field="noteData.noteId"/>
<set field="noteData.noteParty" from-field="assign.partyId"/>
<set field="noteData.noteName" value="SYSTEMNOTE"/>
<set field="noteData.noteInfo" value="New task assignment '${workEffort.workEffortName}' [${workEffort.workEffortId}]"/>
<set field="noteData.moreInfoPortletId" value="ViewProjectTask"/>
<set field="noteData.moreInfoItemId" from-field="workEffort.workEffortId"/>
<create-value value-field="noteData"/>
</if-compare>
</if-compare>
</if-compare>
</if-compare>
<!-- Create a system info note to all customer request participants if a note was added to the customer request
the originator of the customer request will get already a email so does not need to be notified-->
<if-compare field="parameters.entityName" value="CustRequestItemNote" operator="equals">
<!-- find related customer request originator -->
<entity-and entity-name="CustRequestItemNoteView" list="custRequesItems">
<field-map field-name="noteId" from-field="parameters.entityNameId"/>
</entity-and>
<first-from-list entry="custRequesItem" list="custRequesItems"/>
<entity-one entity-name="CustRequest" value-field="custRequest">
<field-map field-name="custRequestId" from-field="custRequesItem.custRequestId"/>
<select-field field-name="fromPartyId"/>
<select-field field-name="custRequestName"/>
</entity-one>
<!-- find all parties who have added a note to this request item excluding the originator (he already gets email)-->
<entity-condition entity-name="CustRequestItemNoteView" list="custRequestParties" distinct="true">
<condition-list combine="and">
<condition-expr field-name="partyId" operator="not-equals" from-field="custRequest.fromPartyId"/>
<condition-expr field-name="custRequestId" from-field="custRequesItem.custRequestId"/>
<condition-expr field-name="custRequestItemSeqId" from-field="custRequesItem.custRequestItemSeqId"/>
</condition-list>
<select-field field-name="partyId"/>
<select-field field-name="custRequestId"/>
<select-field field-name="custRequestItemSeqId"/>
</entity-condition>
<make-value value-field="noteData" entity-name="NoteData"/>
<now-timestamp field="noteData.noteDateTime"/>
<set field="noteData.noteName" value="SYSTEMNOTE"/>
<set field="noteData.moreInfoPortletId" value="ViewCustRequest"/>
<set field="noteData.moreInfoItemId" from-field="custRequest.custRequestId"/>
<set field="noteData.noteInfo" value="A note has been added to customer request ${custRequest.custRequestName} [${custRequest.custRequestId}]"/>
<iterate entry="custRequestParty" list="custRequestParties">
<sequenced-id sequence-name="NoteData" field="noteData.noteId"/>
<set field="noteData.noteParty" from-field="custRequestParty.partyId"/>
<create-value value-field="noteData"/>
</iterate>
</if-compare>
<!-- public message -->
<if-compare field="parameters.entityName" value="PublicMessage" operator="equals">
<if-has-permission permission="COMMONEXT_PUBLMSG">
<!-- get all recent visitors logged on the last 3 weeks -->
<set field="lastDate" value="${groovy:org.ofbiz.base.util.UtilDateTime.addDaysToTimestamp(org.ofbiz.base.util.UtilDateTime.nowTimestamp(), -21)}" type="Timestamp"/>
<entity-condition list="parties" entity-name="PartyNameVisitView" distinct="true">
<condition-expr field-name="fromDate" operator="greater" from-field="lastDate"/>
<select-field field-name="partyId"/>
</entity-condition>
<iterate entry="party" list="parties">
<make-value value-field="noteData" entity-name="NoteData"/>
<now-timestamp field="noteData.noteDateTime"/>
<sequenced-id sequence-name="NoteData" field="noteData.noteId"/>
<set field="noteData.noteParty" from-field="party.partyId"/>
<set field="noteData.noteName" value="SYSTEMNOTE"/>
<set field="noteData.noteInfo" from-field="parameters.noteInfo"/>
<create-value value-field="noteData"/>
</iterate>
<set field="noteData.noteParty" value="_NA_"/><!-- message for not logged in users -->
<sequenced-id sequence-name="NoteData" field="noteData.noteId"/>
<create-value value-field="noteData"/>
</if-has-permission>
</if-compare>
</simple-method>
<simple-method method-name="getPortletAttributeMap" short-description="get the attributes of the SystemInfoNotes portlet for a userlogin">
<!-- get the portlet settings: works only if portlet is used only one time and the user only has a single userLogin -->
<entity-and entity-name="UserLogin" list="ulList">
<field-map field-name="partyId" from-field="partyId"/>
</entity-and>
<if-not-empty field="ulList">
<set field="haveUserLogin" value="true"/>
<first-from-list entry="userLogin" list="ulList"/>
<set field="paMap.ownerUserLoginId" from-field="userLogin.userLoginId"/>
<set field="paMap.portalPortletId" value="SystemInfoNotes"/>
<call-service service-name="getPortletAttributes" in-map-name="paMap">
<result-to-field result-name="attributeMap" field="attributeMap"/>
</call-service>
</if-not-empty>
</simple-method>
<simple-method method-name="deleteAllSystemNotes" short-description="delete all system notes from a particular user">
<set field="removeData.noteParty" from-field="parameters.userLogin.partyId"/>
<set field="removeData.noteName" value="SYSTEMNOTE"/>
<remove-by-and entity-name="NoteData" map="removeData"/>
</simple-method>
<simple-method method-name="getSystemInfoStatus" short-description="">
<!-- communication events -->
<entity-count entity-name="CommunicationEventRole" count-field="comCount">
<condition-list combine="and">
<condition-expr field-name="partyId" from-field="userLogin.partyId"/>
<condition-expr field-name="statusId" operator="not-equals" value="COM_ROLE_COMPLETED"/>
</condition-list>
</entity-count>
<entity-condition entity-name="CommunicationEventAndRole" list="comms">
<condition-list combine="and">
<condition-expr field-name="partyId" from-field="userLogin.partyId"/>
<condition-expr field-name="statusId" operator="not-equals" value="COM_ROLE_COMPLETED"/>
</condition-list>
<order-by field-name="-entryDate"/>
</entity-condition>
<if-compare field="comCount" value="0" operator="greater">
<set field="status.noteInfo" value="Open communication events: ${comCount}"/>
<first-from-list entry="comm" list="comms"/>
<set field="status.noteDateTime" from-field="comm.entryDate"/>
<set field="status.moreInfoPortletId" value="MyCommunications"/>
<field-to-list field="status" list="systemInfoStatus"/>
<clear-field field="status"/>
</if-compare>
<!-- assigned tasks -->
<entity-and entity-name="WorkEffortAndPartyAssign" list="assigns" filter-by-date="true">
<field-map field-name="partyId" from-field="parameters.userLogin.partyId"/>
<field-map field-name="statusId" value="PAS_ASSIGNED"/>
<field-map field-name="workEffortTypeId" value="TASK"/>
<order-by field-name="-fromDate"/>
</entity-and>
<entity-count entity-name="WorkEffortAndPartyAssign" count-field="assignCount">
<condition-list combine="and">
<condition-expr field-name="partyId" operator="equals" from-field="parameters.userLogin.partyId"/>
<condition-expr field-name="statusId" operator="equals" value="PAS_ASSIGNED"/>
<condition-expr field-name="workEffortTypeId" operator="equals" value="TASK"/>
</condition-list>
</entity-count>
<if-compare field="assignCount" value="0" operator="greater">
<set field="status.noteInfo" value="Assigned and not completed tasks: ${assignCount}"/>
<first-from-list entry="assign" list="assigns"/>
<set field="status.noteDateTime" from-field="assign.fromDate"/>
<set field="status.moreInfoPortletId" value="mytasks"/>
<field-to-list field="status" list="systemInfoStatus"/>
</if-compare>
<!-- return result -->
<if-not-empty field="systemInfoStatus">
<field-to-result field="systemInfoStatus"/>
</if-not-empty>
</simple-method>
<simple-method method-name="getSystemInfoNotes" short-description="">
<entity-and entity-name="NoteData" list="systemInfoNotes">
<field-map field-name="noteParty" from-field="parameters.userLogin.partyId"/>
<field-map field-name="noteName" value="SYSTEMNOTE"/>
<order-by field-name="-noteDateTime"/>
</entity-and>
<if-not-empty field="systemInfoNotes">
<field-to-result field="systemInfoNotes"/>
</if-not-empty>
</simple-method>
<simple-method method-name="getLastSystemInfoNote"
short-description="Get the last 3 system info notes"
login-required="false">
<if-not-empty field="parameters.userLogin">
<entity-and entity-name="NoteData" list="systemInfoNotes">
<field-map field-name="noteParty"
from-field="parameters.userLogin.partyId"/>
<field-map field-name="noteName" value="SYSTEMNOTE"/>
<order-by field-name="-noteDateTime"/>
</entity-and>
<else>
<entity-and entity-name="NoteData" list="systemInfoNotes">
<field-map field-name="noteParty" value="_NA_"/>
<field-map field-name="noteName" value="SYSTEMNOTE"/>
<order-by field-name="-noteDateTime"/>
</entity-and>
</else>
</if-not-empty>
<if-not-empty field="systemInfoNotes">
<set field="lastSystemInfoNote1" from-field="systemInfoNotes[0]"/>
<field-to-result field="lastSystemInfoNote1"/>
<if-not-empty field="systemInfoNotes[2]">
<set field="lastSystemInfoNote2" from-field="systemInfoNotes[1]"/>
<field-to-result field="lastSystemInfoNote2"/>
</if-not-empty>
<if-not-empty field="systemInfoNotes[3]">
<set field="lastSystemInfoNote3" from-field="systemInfoNotes[2]"/>
<field-to-result field="lastSystemInfoNote3"/>
</if-not-empty>
</if-not-empty>
</simple-method>
</simple-methods>