diff --git a/.liquibase/Data_alias/basic/workflows/blob/allowEmailCommunication.png b/.liquibase/Data_alias/basic/workflows/blob/allowEmailCommunication.png index ee6a4a4c79bda85b0b2c969d7d3ab25fb08f1eb1..12db2e903164dce7914024ec8144b1a532760ec7 100644 Binary files a/.liquibase/Data_alias/basic/workflows/blob/allowEmailCommunication.png and b/.liquibase/Data_alias/basic/workflows/blob/allowEmailCommunication.png differ diff --git a/.liquibase/Data_alias/basic/workflows/blob/allowEmailCommunication.xml b/.liquibase/Data_alias/basic/workflows/blob/allowEmailCommunication.xml index 4937c55902839c033854d6a405c9d23e24463777..72752198cb3f4955c4e481fb48ff007377b3f3ef 100644 --- a/.liquibase/Data_alias/basic/workflows/blob/allowEmailCommunication.xml +++ b/.liquibase/Data_alias/basic/workflows/blob/allowEmailCommunication.xml @@ -15,7 +15,18 @@ </serviceTask> <endEvent id="sid-A28ACC77-98D5-418A-B2DA-70EED93C00AD"></endEvent> <sequenceFlow id="sid-D6DD7380-3B51-4F31-B5BC-41EFAD3B02E4" sourceRef="startEvent1" targetRef="sid-81F27FC6-FB34-404B-8AA8-84384A1CFAED"></sequenceFlow> - <sequenceFlow id="sid-5EC260F6-7456-4576-92C5-5C536D14E339" sourceRef="sid-81F27FC6-FB34-404B-8AA8-84384A1CFAED" targetRef="sid-A28ACC77-98D5-418A-B2DA-70EED93C00AD"></sequenceFlow> + <serviceTask id="sid-FF1C6322-7046-44BC-A2AF-3A122A7CCE1B" name="Set Default Interests" flowable:class="de.adito.aditoweb.server.neon.workflow.WorkflowServiceTask"> + <extensionElements> + <flowable:field name="jditoProcess"> + <flowable:string><![CDATA[SetInterestLink_workflowService]]></flowable:string> + </flowable:field> + <flowable:field name="taskVariables"> + <flowable:string><![CDATA[{"status":{"value":"INTERESTLINK_SUBSCRIBED"},"interestId":{"value":""},"setDefaultInterests":{"value":true}}]]></flowable:string> + </flowable:field> + </extensionElements> + </serviceTask> + <sequenceFlow id="sid-101F9FEB-D73B-47F6-B378-C5A3122F4A1F" sourceRef="sid-81F27FC6-FB34-404B-8AA8-84384A1CFAED" targetRef="sid-FF1C6322-7046-44BC-A2AF-3A122A7CCE1B"></sequenceFlow> + <sequenceFlow id="sid-52D8F089-0ED2-4ADB-9A76-A6996E0AC72B" sourceRef="sid-FF1C6322-7046-44BC-A2AF-3A122A7CCE1B" targetRef="sid-A28ACC77-98D5-418A-B2DA-70EED93C00AD"></sequenceFlow> </process> <bpmndi:BPMNDiagram id="BPMNDiagram_allowEmailCommunication"> <bpmndi:BPMNPlane bpmnElement="allowEmailCommunication" id="BPMNPlane_allowEmailCommunication"> @@ -26,15 +37,22 @@ <omgdc:Bounds height="80.0" width="100.0" x="210.0" y="136.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="sid-A28ACC77-98D5-418A-B2DA-70EED93C00AD" id="BPMNShape_sid-A28ACC77-98D5-418A-B2DA-70EED93C00AD"> - <omgdc:Bounds height="28.0" width="28.0" x="375.0" y="164.0"></omgdc:Bounds> + <omgdc:Bounds height="28.0" width="28.0" x="510.0" y="162.0"></omgdc:Bounds> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape bpmnElement="sid-FF1C6322-7046-44BC-A2AF-3A122A7CCE1B" id="BPMNShape_sid-FF1C6322-7046-44BC-A2AF-3A122A7CCE1B"> + <omgdc:Bounds height="80.0" width="100.0" x="345.0" y="136.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="sid-D6DD7380-3B51-4F31-B5BC-41EFAD3B02E4" id="BPMNEdge_sid-D6DD7380-3B51-4F31-B5BC-41EFAD3B02E4"> <omgdi:waypoint x="129.94860715897664" y="177.7931227241285"></omgdi:waypoint> <omgdi:waypoint x="209.9999999999986" y="176.6889655172414"></omgdi:waypoint> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="sid-5EC260F6-7456-4576-92C5-5C536D14E339" id="BPMNEdge_sid-5EC260F6-7456-4576-92C5-5C536D14E339"> - <omgdi:waypoint x="309.95000000000005" y="176.77441860465117"></omgdi:waypoint> - <omgdi:waypoint x="375.00104904016473" y="177.78297128864668"></omgdi:waypoint> + <bpmndi:BPMNEdge bpmnElement="sid-52D8F089-0ED2-4ADB-9A76-A6996E0AC72B" id="BPMNEdge_sid-52D8F089-0ED2-4ADB-9A76-A6996E0AC72B"> + <omgdi:waypoint x="444.95000000000005" y="176.0"></omgdi:waypoint> + <omgdi:waypoint x="510.0" y="176.0"></omgdi:waypoint> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge bpmnElement="sid-101F9FEB-D73B-47F6-B378-C5A3122F4A1F" id="BPMNEdge_sid-101F9FEB-D73B-47F6-B378-C5A3122F4A1F"> + <omgdi:waypoint x="309.95000000000005" y="176.0"></omgdi:waypoint> + <omgdi:waypoint x="345.0" y="176.0"></omgdi:waypoint> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/process/SetInterestLink_workflowService/SetInterestLink_workflowService.aod b/process/SetInterestLink_workflowService/SetInterestLink_workflowService.aod index b86df5e7047ab1a0cc534a1f4dfbad242e2d94a7..a9034d207df0f6b504094a0b5da0bdbecc3cde91 100644 --- a/process/SetInterestLink_workflowService/SetInterestLink_workflowService.aod +++ b/process/SetInterestLink_workflowService/SetInterestLink_workflowService.aod @@ -4,6 +4,7 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <process>%aditoprj%/process/SetInterestLink_workflowService/process.js</process> <alias>Data_alias</alias> + <serviceTaskParameterProcess>%aditoprj%/process/SetInterestLink_workflowService/serviceTaskParameterProcess.js</serviceTaskParameterProcess> <variants> <element>WORKFLOW</element> </variants> diff --git a/process/SetInterestLink_workflowService/process.js b/process/SetInterestLink_workflowService/process.js index b66a48e570ae73bc4fc57e2bd4a01744826ad76f..17d4913a89e2912202b7979898ff187fd140dfc0 100644 --- a/process/SetInterestLink_workflowService/process.js +++ b/process/SetInterestLink_workflowService/process.js @@ -6,17 +6,34 @@ import("Sql_lib"); var variables = JSON.parse(vars.get("$local.value")); var contactId = variables.contactId || variables.targetId; var interestId = variables.interestId; +var setDefaultInterests = variables.setDefaultInterests || false; if (!interestId && variables.mailLogId) { - interestId = newSelect("MAIL_RUN.INTERESTID") + interestId = newSelect("MAIL_RUN.INTEREST_ID") .from("MAIL_LOG") .join("MAIL_RUN", "MAIL_LOG.MAIL_RUN_ID = MAIL_RUN.MAIL_RUNID") .where("MAIL_LOG.MAIL_LOGID", variables.mailLogId) .cell(); } var status = variables.status || $KeywordRegistry.interestLinkStatus$notSubscribed(); +var interestIds = []; -var interestLinkId = new SqlBuilder() +if(setDefaultInterests) +{ + interestIds = newSelect("INTERESTID") + .from("INTEREST") + .where("INTEREST.IS_DEFAULT",1) + .and("INTEREST.STATUS",$KeywordRegistry.interestStatus$active()) + .arrayColumn(); +} + +if (interestId && !interestIds.includes(interestId)) +{ + interestIds.push(interestId); +} + +interestIds.forEach(function (interestId){ + var interestLinkId = new SqlBuilder() .select("INTERESTLINKID") .from("INTERESTLINK") .where("INTERESTLINK.CONTACT_ID", contactId) @@ -24,19 +41,20 @@ var interestLinkId = new SqlBuilder() .and("INTERESTLINK.STATUS", status) .cell(); -if (interestLinkId) -{ - newWhere("INTERESTLINK.INTERESTLINKID", interestLinkId) - .updateFields({"STATUS": status}); -} -else -{ - new SqlBuilder() - .tableName("INTERESTLINK") - .insertFields({ - "INTERESTLINKID": util.getNewUUID(), - "INTEREST_ID": interestId, - "CONTACT_ID": contactId, - "STATUS": status - }); -} \ No newline at end of file + if (interestLinkId) + { + newWhere("INTERESTLINK.INTERESTLINKID", interestLinkId) + .updateFields({"STATUS": status}); + } + else + { + new SqlBuilder() + .tableName("INTERESTLINK") + .insertFields({ + "INTERESTLINKID": util.getNewUUID(), + "INTEREST_ID": interestId, + "CONTACT_ID": contactId, + "STATUS": status + }); + } +}); diff --git a/process/SetInterestLink_workflowService/serviceTaskParameterProcess.js b/process/SetInterestLink_workflowService/serviceTaskParameterProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..0c2a60178b60e85ee0c50e391639d1dfbf0dd502 --- /dev/null +++ b/process/SetInterestLink_workflowService/serviceTaskParameterProcess.js @@ -0,0 +1,31 @@ +import("Keyword_lib"); +import("system.result"); +import("system.vars"); +import("Sql_lib"); +import("Workflow_lib"); +import("KeywordRegistry_basic"); + +var interests = newSelect(["INTERESTID", "TITLE"]) + .from("INTEREST") + .where("INTEREST.STATUS",$KeywordRegistry.interestStatus$active()) + .table() + .map(function ([id, name]) + { + return { + id: id, + name: name + }; + }); + +var parameters = [ + new WorkflowServiceTaskParameter("status", "Subscription Status", WorkflowServiceTaskParameter.ENUM(), _getKeywords($KeywordRegistry.interestLinkStatus())), + new WorkflowServiceTaskParameter("interestId", "Interest", WorkflowServiceTaskParameter.ENUM(), interests), + new WorkflowServiceTaskParameter("setDefaultInterests","Set Default Interests",WorkflowServiceTaskParameter.BOOLEAN()) +]; + +result.object(parameters); + +function _getKeywords (pContainer) +{ + return KeywordUtils.getEntryArray(pContainer).map(function (item) {return {id : item[0], name : item[1]};}); +} \ No newline at end of file