From d37e6c4ce91352ff750caec7ea02b61c27d916ab Mon Sep 17 00:00:00 2001 From: jaise-aot Date: Tue, 19 Sep 2023 09:57:13 -0700 Subject: [PATCH 1/4] integrated email templates into sir --- .../processes/Common/CommonEmailWorkflow.bpmn | 125 ++++--- .../processes/Common/email-template.dmn | 28 +- .../processes/SIR/SIRWorkflow.bpmn | 350 +++++++++++++++++- .../templates/sir_application_approved.ftl | 69 ++++ 4 files changed, 519 insertions(+), 53 deletions(-) create mode 100644 forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/Common/CommonEmailWorkflow.bpmn b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/Common/CommonEmailWorkflow.bpmn index b8fdaa08..5ffa2b91 100644 --- a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/Common/CommonEmailWorkflow.bpmn +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/Common/CommonEmailWorkflow.bpmn @@ -1,5 +1,5 @@ - + Flow_15fflso @@ -39,9 +39,12 @@ authUrl; Flow_0cog7s9 - Flow_0w1xi39 + Flow_1v2p747 var system = java.lang.System; -system.out.println ("token: "+token); +system.out.println ("token: "+token); + +system.out.println ("category: "+category); +system.out.println ("name: "+name); @@ -58,18 +61,18 @@ system.out.println ("token: "+token); var p = { "bcc": [], "bodyType": "html", - "body": "You have an update to your application, please log in to review. The status is: " + execution.getVariable('applicationStatus'), + "body": execution.getVariable("text"), "cc": [], "delayTS": 0, "encoding": "utf-8", "from": "NOREPLYEPD@gov.bc.ca", "priority": "normal", - "subject": "EPD Application Update", + "subject": execution.getVariable("subject"), "to": [], "tag": "", "attachments": [] } -p.to.push(clientEmail) +p.to.push(execution.getVariable("emailTo")) console.log("Payload") console.log(JSON.stringify(p)) JSON.stringify(p) @@ -81,8 +84,17 @@ JSON.stringify(p) http-connector + + + new String(execution.getVariable("mailContent")) + + ${dmnResult.get("subject")} + + execution.getVariable("emailTo") + + - Flow_0jqov5w + Flow_0tc827u Flow_093urcj @@ -90,12 +102,6 @@ JSON.stringify(p) - - Flow_0w1xi39 - Flow_0jqov5w - - - @@ -104,61 +110,94 @@ JSON.stringify(p) var system = java.lang.System; system.out.println ("result: "+result); + + + + ${category} + + dmnResult.get("support") + + + + Flow_1v2p747 + Flow_1uskeb8 + + + + + + + + + + Flow_1uskeb8 + Flow_0tc827u + templateFile.getBytes("UTF-8") + + + + - + - + - + - - - - - - - - + + - + - + - - - + + + + + + + + + + + + - - - - - - - - - - + - - + + - - + + + + + + + + + + + + + + diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/Common/email-template.dmn b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/Common/email-template.dmn index dbf41c83..cd140f9b 100644 --- a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/Common/email-template.dmn +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/Common/email-template.dmn @@ -31,7 +31,7 @@ - "SIR Application Rejected" + "Site Information Request Rejected" "templates/sir_application_rejected.ftl" @@ -40,6 +40,32 @@ "epd-support@gov.bc.ca" + + + "sir_status_approved" + + + + + + "NOREPLYEPD@gov.bc.ca" + + + + + + + + + "Site Information Request Approved" + + + "templates/sir_application_approved.ftl" + + + "epd-support@gov.bc.ca" + + diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/SIR/SIRWorkflow.bpmn b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/SIR/SIRWorkflow.bpmn index c5011e05..f787552b 100644 --- a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/SIR/SIRWorkflow.bpmn +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/processes/SIR/SIRWorkflow.bpmn @@ -1,12 +1,344 @@ -Activity_1ozfgidEvent_02fetttTask_05ulff4Activity_06nypz0Activity_16ugfrtActivity_1os7sysEvent_1lsroftActivity_08g50qyActivity_16vi0ykActivity_1cdhp59Activity_0w5t5avActivity_0ro66ytActivity_04t1ow5Event_0ml6v2texecution.setVariable('applicationStatus', 'New');["applicationId", "applicationStatus"]execution.setVariable('applicationStatus', 'Resubmitted');["applicationId", "applicationStatus"]Flow_1la2yudFlow_07ndmfwFlow_0unffchvar system = java.lang.System; + + + + + + + + Activity_1ozfgid + Event_02fettt + Task_05ulff4 + + + Activity_06nypz0 + Activity_16ugfrt + Activity_1os7sys + Event_1lsroft + Activity_08g50qy + Activity_1cdhp59 + Activity_0w5t5av + Activity_0ro66yt + Activity_04t1ow5 + Event_0ml6v2t + Activity_1lbc6o5 + + + + + + + execution.setVariable('applicationStatus', 'New'); + + + + + ["applicationId", "applicationStatus"] + + + + + + + + + execution.setVariable('applicationStatus', 'Resubmitted'); + + + + + ["applicationId", "applicationStatus"] + + + + + + Flow_1la2yud + Flow_07ndmfw + Flow_0unffch + var system = java.lang.System; system.out.println ("simpleemail"+execution.getVariable('simpleemail')); var clientEmail = execution.getVariable('simpleemail'); -execution.setVariable('clientEmail',clientEmail); -var clientEmail2= execution.getVariable('applicantEmailForInvoice'); -execution.setVariable('clientEmail2',clientEmail2); -system.out.println ("clientEmail"+clientEmail); -system.out.println ("clientEmail2"+clientEmail2);Flow_1la2yudtask.execution.setVariable('applicationStatus', task.execution.getVariable('action')); -Flow_0unffchFlow_1ua4w6mFlow_036aw17Flow_1e1420i${action == 'Resubmit'}["applicationId","applicationStatus"]Flow_1ua4w6mFlow_0gywvcwexecution.setVariable('applicationStatus', "Resubmit");["applicationId", "applicationStatus"]Flow_0gywvcwFlow_07ndmfw${action == 'Rejected'}Flow_0c55q6wFlow_00vwzxvFlow_00vwzxvFlow_036aw17Flow_0c55q6wvar system = java.lang.System; -system.out.println ("Reviewed by SDM");${action == 'Accepted'}Flow_1e1420iFlow_1uqf688task.execution.setVariable('applicationStatus', task.execution.getVariable('action')); -Flow_1uqf688Flow_18ztndkFlow_18ztndkFlow_0x1z3oyFlow_0x1z3oyFlow_04l5mhwFlow_04l5mhwFlow_17vvo0lFlow_17vvo0l \ No newline at end of file +execution.setVariable('emailTo',clientEmail); +system.out.println ("emailTo"+execution.getVariable('emailTo')); +system.out.println ("firstname "+execution.getVariable('s1-firstname')); +var firstname=execution.getVariable('s1-firstname'); +system.out.println ("firstname"+firstname); +execution.setVariable('name',firstname); + + + + Flow_1la2yud + + + + + task.execution.setVariable('applicationStatus', task.execution.getVariable('action')); + + + + + + + Flow_0unffch + Flow_1ua4w6m + Flow_036aw17 + Flow_1e1420i + + + ${action == 'Resubmit'} + + + + + + + + ["applicationId","applicationStatus"] + + + + + Flow_1ua4w6m + Flow_0gywvcw + + + + + execution.setVariable('applicationStatus', "Resubmit"); + + + + + + ["applicationId", "applicationStatus"] + + + + Flow_0gywvcw + Flow_07ndmfw + + + ${action == 'Rejected'} + + + + + + + sir_status_rejected + + + Flow_0c55q6w + Flow_00vwzxv + + + Flow_00vwzxv + + + Flow_036aw17 + Flow_0c55q6w + var system = java.lang.System; +system.out.println ("Reviewed by SDM"); + + + + + + ${action == 'Approved'} + + + + + + + task.execution.setVariable('applicationStatus', task.execution.getVariable('action')); + + + + + + + Flow_1d66let + Flow_18ztndk + + + Flow_18ztndk + Flow_0x1z3oy + + + Flow_0x1z3oy + Flow_04l5mhw + + + + + + Flow_04l5mhw + Flow_17vvo0l + + + Flow_17vvo0l + + + + + + + sir_status_approved + + + Flow_1e1420i + Flow_1d66let + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl new file mode 100644 index 00000000..ebd43ce1 --- /dev/null +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + +
+ + + Site Remediation System +
+ + + + + + + + + + + + + + + + + + + +
+
+
+

+ Site Information request. +

+
+

+ Hello ${name}, +

+

+ Your site information request has been accepted by site information officer for further processing. We will process your application and send the requested documents over email within 60 days. +

+
+

+ If you need any help, don’t hesitate to reach out to us at ${support} +

+
+
+
+ +

EPD will never send an email that asks you to provide, confirm or verify personal, log on or account information. + DO NOT reply to this email as it was sent from an unmonitored account. +

+
+ + \ No newline at end of file From 43928706956a3ebd09ada82ea60024d3038cc43f Mon Sep 17 00:00:00 2001 From: jaise-aot Date: Tue, 19 Sep 2023 12:17:55 -0700 Subject: [PATCH 2/4] point formsflow to ee version --- .../forms-flow-bpm/Dockerfile | 27 +++++++++++++++---- .../templates/sir_application_approved.ftl | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/Dockerfile b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/Dockerfile index 11ddb893..4a82cf1f 100644 --- a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/Dockerfile +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/Dockerfile @@ -6,17 +6,34 @@ FROM maven:3.8.1-openjdk-17-slim AS MAVEN_TOOL_CHAIN RUN apt-get update \ && apt-get install -y git +# expect a build-time variable +ARG FORMFLOW_SOURCE_REPO_URL +# expect ssh private key +ARG ssh_prv_key +# expect ssh public key +ARG ssh_pub_key # expect a build-time variable ARG FORMFLOW_SOURCE_REPO_BRANCH # use the value to set the ENV var default -ENV FORMFLOW_SOURCE_REPO_BRANCH v5.1.0 -# expect a build-time variable -ARG FORMFLOW_SOURCE_REPO_URL +ENV FORMFLOW_SOURCE_REPO_BRANCH epd-ff-ee-5.2.0 # use the value to set the ENV var default -ENV FORMFLOW_SOURCE_REPO_URL https://github.com/AOT-Technologies/forms-flow-ai +ENV FORMFLOW_SOURCE_REPO_URL git@github.com:AOT-Technologies/forms-flow-ai-ee.git + +RUN mkdir -p /root/.ssh && \ + chmod 0700 /root/.ssh && \ + echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config + +COPY id_rsa_epd /root/.ssh/id_rsa +COPY id_rsa_epd.pub /root/.ssh/id_rsa.pub + +RUN chmod 600 /root/.ssh/id_rsa + +RUN chmod 600 /root/.ssh/id_rsa.pub + +RUN mkdir -p /root/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts # Clone code -RUN git clone -b ${FORMFLOW_SOURCE_REPO_BRANCH} ${FORMFLOW_SOURCE_REPO_URL} /bpm/ +RUN git clone ${FORMFLOW_SOURCE_REPO_URL} -b ${FORMFLOW_SOURCE_REPO_BRANCH} /bpm/ RUN cp /bpm/forms-flow-bpm/pom*.xml /tmp/ RUN cp /bpm/forms-flow-bpm/settings-docker.xml /usr/share/maven/ref/ diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl index ebd43ce1..f9e46512 100644 --- a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl @@ -38,7 +38,7 @@ Hello ${name},

- Your site information request has been accepted by site information officer for further processing. We will process your application and send the requested documents over email within 60 days. + Your site information request has been accepted by site information officer for further processing. We will process your application and send the requested documents over email.

From a2a8e9931ba6b7d4b06eba2e1a0c7e256c1bdbf0 Mon Sep 17 00:00:00 2001 From: jaise-aot Date: Tue, 19 Sep 2023 16:40:23 -0700 Subject: [PATCH 3/4] read private and pub keys from args --- .../forms-flow-bpm/Dockerfile | 10 +-- .../forms-flow-bpm/readme.dockerfile.md | 73 +++++++++++++++++++ 2 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/readme.dockerfile.md diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/Dockerfile b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/Dockerfile index 4a82cf1f..e7b4d4c8 100644 --- a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/Dockerfile +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/Dockerfile @@ -23,12 +23,10 @@ RUN mkdir -p /root/.ssh && \ chmod 0700 /root/.ssh && \ echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config -COPY id_rsa_epd /root/.ssh/id_rsa -COPY id_rsa_epd.pub /root/.ssh/id_rsa.pub - -RUN chmod 600 /root/.ssh/id_rsa - -RUN chmod 600 /root/.ssh/id_rsa.pub +RUN echo "$ssh_prv_key" | sed 's/\\n/\n/g' > /root/.ssh/id_rsa && \ + echo "$ssh_pub_key" | sed 's/\\n/\n/g' > /root/.ssh/id_rsa.pub && \ + chmod 600 /root/.ssh/id_rsa && \ + chmod 600 /root/.ssh/id_rsa.pub RUN mkdir -p /root/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/readme.dockerfile.md b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/readme.dockerfile.md new file mode 100644 index 00000000..2385fd4d --- /dev/null +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/readme.dockerfile.md @@ -0,0 +1,73 @@ +# Readme SSH Deploy Key + +1. Create deploy key +2. Upload to github repo + +```bash + +## Create deploy Key +ssh-keygen -t ed25519 -C "adam.coard@aot-technologies.com" -f /Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd +``` + + +## Docker build command - note, update paths to deploy key as appropriate + +```bash +docker build -t ff-ee-web --build-arg ssh_prv_key="$(cat /Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd)" --build-arg ssh_pub_key="$(cat /Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd.pub)" . + +## Docker build with resources +## Use this if you start running into out of memory issues +docker build --build-arg NODE_OPTIONS=--max-old-space-size=6144 --memory=7144m --memory-swap=-1 --cpu-period=100000 --cpu-quota=50000 -t ff-ee-web --build-arg ssh_prv_key="$(cat /Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd)" --build-arg ssh_pub_key="$(cat /Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd.pub)" . + +# # DEBUG ONLY REMOVE +# docker build -t ff-ee-web --build-arg ssh_prv_key="$(cat /Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd_newlines)" --build-arg ssh_pub_key="$(cat /Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd.pub)" . + +## Run command +docker run --name ff-ee-web -p 3004:8080 --rm ff-ee-web + + +# Debug container +docker run --name ff-ee-web --rm -p 8080:8080 ff-ee-web cat /etc/nginx/nginx.conf +``` + + + +## Upload SSH Key to OpenShift + +IN TOOLS ENVIRONMENT + +```bash + +oc create secret generic ff-ee-deploy-key \ + --from-file=ssh-privatekey=/Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd \ + --type=kubernetes.io/ssh-auth + +oc create secret generic ff-ee-deploy-key-pub \ + --from-file=ssh-privatekey=/Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd.pub \ + --type=kubernetes.io/ssh-auth + +``` + +Patch yaml: + +```yaml + + dockerStrategy: + env: + - name: ssh_prv_key + valueFrom: + secretKeyRef: + name: ff-ee-deploy-key + key: ssh-privatekey + - name: ssh_pub_key + valueFrom: + secretKeyRef: + name: ff-ee-deploy-key-pub + key: ssh-privatekey + +``` + +## Strip newlines from ssh key + +sed 's/\\n/\n/g' /Users/adamcoard/Dev/nr-epd-digital-services/notes/id_rsa_epd_newlines > test +sed 's/\\n/\n/g' test > test2 \ No newline at end of file From df523332d49102252a6a4eff038e191673357f6b Mon Sep 17 00:00:00 2001 From: jaise-aot Date: Wed, 20 Sep 2023 12:27:09 -0700 Subject: [PATCH 4/4] label changes --- .../forms-flow-bpm/templates/sir_application_approved.ftl | 2 +- .../forms-flow-bpm/templates/sir_application_rejected.ftl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl index f9e46512..3818bed2 100644 --- a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_approved.ftl @@ -15,7 +15,7 @@ - Site Remediation System + Site Remediation Services diff --git a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_rejected.ftl b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_rejected.ftl index 8686ff8e..e45788bc 100644 --- a/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_rejected.ftl +++ b/forms-flow-ai/forms-flow-ai-ee/forms-flow-bpm/templates/sir_application_rejected.ftl @@ -15,7 +15,7 @@ - Site Remediation System + Site Remediation Services