-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XIVY-13085 Add a new business notification demo
Add a new demo process 'OrderProcess' that demonstrates the different use cases how the BusinessNotification API can be used. Add a test for the new process
- Loading branch information
Showing
30 changed files
with
1,140 additions
and
18 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
workflow/workflow-demos-test/src_test/test/bpm/TestOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package test.bpm; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import ch.ivyteam.ivy.bpm.engine.client.BpmClient; | ||
import ch.ivyteam.ivy.bpm.engine.client.element.BpmElement; | ||
import ch.ivyteam.ivy.bpm.engine.client.element.BpmProcess; | ||
import ch.ivyteam.ivy.bpm.exec.client.IvyProcessTest; | ||
import ch.ivyteam.ivy.environment.Ivy; | ||
import ch.ivyteam.ivy.notification.impl.NotificationRepository; | ||
import ch.ivyteam.ivy.notification.query.NotificationQuery; | ||
import ch.ivyteam.ivy.scripting.objects.Tuple; | ||
import ch.ivyteam.ivy.workflow.CaseState; | ||
import workflow.order.Order; | ||
import workflow.order.Person; | ||
|
||
@IvyProcessTest | ||
public class TestOrder | ||
{ | ||
private static final BpmProcess ORDER_PROCESS = BpmProcess.name("OrderProcess"); | ||
|
||
private static final BpmElement START_ORDER = ORDER_PROCESS.elementName("startOrder"); | ||
private static final BpmElement INPUT_ORDER = ORDER_PROCESS.elementName("Input Order"); | ||
private static final BpmElement PROCESS_ORDER = ORDER_PROCESS.elementName("Process Order"); | ||
private static final BpmElement DELIVER_ORDER = ORDER_PROCESS.elementName("Deliver Order"); | ||
private static final BpmElement SEND_INVOICE = ORDER_PROCESS.elementName("Send Invoice"); | ||
private static final BpmElement BOOK_PAYMENT = ORDER_PROCESS.elementName("Book Payment"); | ||
|
||
private static final Person CUSTOMER = new Person(); | ||
private static final Order ORDER = new Order(); | ||
|
||
static | ||
{ | ||
CUSTOMER.setName("Doe"); | ||
CUSTOMER.setSurname("John"); | ||
ORDER.setProduct("Ferrari Testarossa"); | ||
} | ||
|
||
@Test | ||
void runProcess(BpmClient bpmClient) | ||
{ | ||
bpmClient.mock().uiOf(INPUT_ORDER).with(this::inputOrder); | ||
bpmClient.mock().uiOf(PROCESS_ORDER).withNoAction(); | ||
bpmClient.mock().uiOf(DELIVER_ORDER).withNoAction(); | ||
bpmClient.mock().uiOf(DELIVER_ORDER).withNoAction(); | ||
bpmClient.mock().uiOf(SEND_INVOICE).withNoAction(); | ||
bpmClient.mock().uiOf(BOOK_PAYMENT).withNoAction(); | ||
|
||
NotificationQuery nofiticationQuery = NotificationRepository.of(Ivy.wf().getSecurityContext()).query(); | ||
var notifications = nofiticationQuery.executor().count(); | ||
|
||
var result = bpmClient.start().process(START_ORDER) | ||
.as().everybody().execute(); | ||
bpmClient.start().anyActiveTask(result).as().role("Processor").execute(); | ||
bpmClient.start().anyActiveTask(result).as().role("Deliverer").execute(); | ||
bpmClient.start().anyActiveTask(result).as().role("Finance").execute(); | ||
bpmClient.start().anyActiveTask(result).as().role("Finance").execute(); | ||
|
||
assertThat(result.workflow().activeCase().getState()).isEqualTo(CaseState.DONE); | ||
assertThat(nofiticationQuery.executor().count()).isEqualTo(notifications + 9); | ||
} | ||
|
||
private void inputOrder(Tuple parameters, Tuple results) | ||
{ | ||
try | ||
{ | ||
results.set("customer", CUSTOMER); | ||
results.set("order", ORDER); | ||
} | ||
catch (NoSuchFieldException ex) | ||
{ | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
workflow/workflow-demos/cms/Notification/business/Templates/Order/mail/Content.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<html> | ||
<body> | ||
<img class="logo" src="<%= ivy.branding.ref("logo_mail") %>"/> | ||
<h1><%= ivy.cm.co("/Notification/business/Templates/Order/Labels/Title") %></h1> | ||
<p><%= ivy.cm.co("/Notification/business/Templates/Order/Labels/Greeting") %> <%= ivy.session.getSessionUser().getFullName() %></p> | ||
<table> | ||
<tr> | ||
<th><%= ivy.cm.co("/Notification/business/Templates/Order/Labels/Message") %><th> | ||
<td><%= ivy.html.escape(message) %></td> | ||
</tr> | ||
<tr> | ||
<th><%= ivy.cm.co("/Notification/business/Templates/Order/Labels/Customer") %></th> | ||
<td><i style="color: red;"> <%= ivy.html.escape(payload.get("surname")) %> <%= ivy.html.escape(payload.get("name")) %> </i></td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
Categories: | ||
notification: | ||
cssIcon: si si-messages-bubble | ||
name: 8. Notification | ||
Dialogs: | ||
agileBPM: | ||
define_WF: | ||
|
@@ -107,15 +111,14 @@ Dialogs: | |
selectParkingLot: Parkplatz auswählen | ||
Emails: | ||
accepted: akzeptiert | ||
confirmParkingLot: "<H1>\r\nHallo <%=in.name%>\r\n</H1>\r\n<P>\r\nDer Parkplatz Nr. <%=in.selectedParkingLotNr%> wurde für Sie reserviert. \r\n</P>\r\n<P>\r\nWir wünschen Ihnen einen schönen Tag.\r\n</P>\r\n" | ||
confirmParkingLot: "<H1>\nHallo <%=in.name%>\n</H1>\n<P>\nDer Parkplatz Nr. <%=in.selectedParkingLotNr%> wurde für Sie reserviert. \n</P>\n<P>\nWir wünschen Ihnen einen schönen Tag.\n</P>\n" | ||
declined: abgelehnt | ||
parkingLotReservationHeader: Ihr Parkplatz wurde reserviert | ||
procurementRequestNotification: "<H1>\r\nHallo <%=in.requester.fullName%> \r\n</H1>\r\n<P>\r\nIhr Antrag wurde <%=(in.accepted ? \"angenommen\" : \"abgelehnt\")%>: \r\n</P>\r\n<P>\r\n<%=in.amount%> Stück '<%=in.description%>' zum Gesamtpreis von <%=in.totalPrice%> <%=ivy.cms.co(\"/Dialogs/procurementRequest/currencySymbol\"\ | ||
)%> \r\n</P>\r\n<P>\r\nFreundliche Grüsse \r\n</P>\r\n" | ||
procurementRequestNotification: "<H1>\nHallo <%=in.requester.fullName%> \n</H1>\n<P>\nIhr Antrag wurde <%=(in.accepted ? \"angenommen\" : \"abgelehnt\")%>: \n</P>\n<P>\n<%=in.amount%> Stück '<%=in.description%>' zum Gesamtpreis von <%=in.totalPrice%> <%=ivy.cms.co(\"/Dialogs/procurementRequest/currencySymbol\"\ | ||
)%> \n</P>\n<P>\nFreundliche Grüsse \n</P>\n" | ||
senderMail: [email protected] | ||
welcomeHeader: Willkommen | ||
welcomeMail: "<H1>\r\nHallo <%=in.name%> \r\n</H1>\r\n<P>\r\nWillkommen in unserem Unternehmen. Wir freuen uns, Sie bei uns begrüssen zu dürfen! \r\n</P>\r\n<P>\r\nWenn Sie Fragen haben, wenden Sie sich bitte an Ihren Teamleiter oder an Ihren HR Manager. \r\n</P>\r\n<P>\r\nWir wünschen Ihnen einen schö\ | ||
nen Tag! \r\n</P>\r\n" | ||
welcomeMail: "<H1>\nHallo <%=in.name%> \n</H1>\n<P>\nWillkommen in unserem Unternehmen. Wir freuen uns, Sie bei uns begrüssen zu dürfen! \n</P>\n<P>\nWenn Sie Fragen haben, wenden Sie sich bitte an Ihren Teamleiter oder an Ihren HR Manager. \n</P>\n<P>\nWir wünschen Ihnen einen schönen Tag! \n</P>\n" | ||
yourRequestHasBeen: 'Ihre Anfrage wurde ' | ||
Labels: | ||
AdhocWorkflow: Beschreiben Sie Ihren Workflow | ||
|
@@ -125,6 +128,19 @@ Labels: | |
InsertTheTask: Aufgabe einfügen | ||
TaskUser-Explain: Komma getrennte Liste von Benutzern | ||
title: Self Service Ad-Hoc Workflow | ||
Notification: | ||
Messages: | ||
InvoiceSent: Die Rechnung für die Bestellung {0} wurde versendet | ||
OrderDelivered: Bestellung {0} wurde an Kunde {1} {2} ausgeliefert | ||
OrderFinished: Die Bestellung {0} wurde erfolgreich abgeschlossen | ||
business: | ||
Templates: | ||
Order: | ||
Labels: | ||
Customer: Kunde | ||
Greeting: 'Hallo ' | ||
Message: Meldung | ||
Title: Bestellungsinformation | ||
TaskDescriptions: | ||
DeliverKeyCardDesc: Bitte liefern Sie die Schlüsselkarte aus für | ||
acceptRequest: Antrag annehmen | ||
|
@@ -138,8 +154,11 @@ TaskDescriptions: | |
verifyRequest: Prüfe Antrag | ||
Texts: | ||
Adhoc-Explain: '<P> <B>Geben Sie Ihren Kommentar ein </B>und drücken Sie <B>Senden</B> um weiterzufahren. </P> ' | ||
AdhocWF-Explain: "<P>\r\nDefinieren und starten Sie einen Workflow auf Knopfdruck. \r\n</P>\r\n" | ||
Approval-Explain: "<P>\r\n<B>Treffen Sie Ihre Entscheidung</B> und klicken Sie auf <B>Senden </B>um weiterzufahren. \r\n</P>\r\n" | ||
QA-Explain: "<P>\r\nBeantworten Sie die Frage und <B>Senden </B>Sie Ihre Antwort an den Fragesteller zurück.\r\n</P>\r\n" | ||
AdhocWF-Explain: "<P>\nDefinieren und starten Sie einen Workflow auf Knopfdruck. \n</P>\n" | ||
Approval-Explain: "<P>\n<B>Treffen Sie Ihre Entscheidung</B> und klicken Sie auf <B>Senden </B>um weiterzufahren. \n</P>\n" | ||
QA-Explain: | | ||
<P> | ||
Beantworten Sie die Frage und <B>Senden </B>Sie Ihre Antwort an den Fragesteller zurück. | ||
</P> | ||
QAresponse-Explain: '<P> Sie können eine Anschlussfrage <B>Zurücksenden</B> oder den Workflow <B>Beenden</B>.</P> ' | ||
ToDo-Explain: '<P> Bestätigen Sie, dass das <B> TODO Erledigt</B> wurde oder lehnen Sie es ab.</P> ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ Categories: | |
cssIcon: si si-multiple-neutral-1 | ||
name: 2. Human Tasks | ||
tooltip: How to integrate humans into workflows | ||
notification: | ||
cssIcon: si si-messages-bubble | ||
name: 8. Notification | ||
signal: | ||
cssIcon: si si-network-signal | ||
name: 3. Signals | ||
|
@@ -138,14 +141,46 @@ Dialogs: | |
selectParkingLot: Select parking lot | ||
Emails: | ||
accepted: accepted | ||
confirmParkingLot: "<H1>\r\nHello <%=in.name%>\r\n</H1>\r\n<P>\r\nWe reserved the parking lot nr. <%=in.selectedParkingLotNr%> for you.\r\n</P>\r\n<P>\r\nHave a nice day.\r\n</P>\r\n" | ||
confirmParkingLot: | | ||
<H1> | ||
Hello <%=in.name%> | ||
</H1> | ||
<P> | ||
We reserved the parking lot nr. <%=in.selectedParkingLotNr%> for you. | ||
</P> | ||
<P> | ||
Have a nice day. | ||
</P> | ||
declined: declined | ||
parkingLotReservationHeader: Your parking lot has been reserved | ||
procurementRequestNotification: "<H1>\r\nHello <%=in.requester.fullName%>\r\n</H1>\r\n<P>\r\nYour request has been <%=(in.accepted ? \"accepted\" : \"declined\")%>:\r\n</P>\r\n<P>\r\n<%=in.amount%> pieces of '<%=in.description%>' for a total of <%=in.totalPrice%> <%=ivy.cms.co(\"/Dialogs/procurementRequest/currencySymbol\"\ | ||
)%>\r\n</P>\r\n<P>\r\nKind regards\r\n</P>\r\n" | ||
procurementRequestNotification: | | ||
<H1> | ||
Hello <%=in.requester.fullName%> | ||
</H1> | ||
<P> | ||
Your request has been <%=(in.accepted ? "accepted" : "declined")%>: | ||
</P> | ||
<P> | ||
<%=in.amount%> pieces of '<%=in.description%>' for a total of <%=in.totalPrice%> <%=ivy.cms.co("/Dialogs/procurementRequest/currencySymbol")%> | ||
</P> | ||
<P> | ||
Kind regards | ||
</P> | ||
senderMail: [email protected] | ||
welcomeHeader: Welcome | ||
welcomeMail: "<H1>\r\nHello <%=in.name%>\r\n</H1>\r\n<P>\r\nWelcome at our company. It is a great pleasure to have you here!\r\n</P>\r\n<P>\r\nIf you have any question, please don't hesitate to contact your teamleader or your HR Manager.\r\n</P>\r\n<P>\r\nHave a nice day!\r\n</P>\r\n" | ||
welcomeMail: | | ||
<H1> | ||
Hello <%=in.name%> | ||
</H1> | ||
<P> | ||
Welcome at our company. It is a great pleasure to have you here! | ||
</P> | ||
<P> | ||
If you have any question, please don't hesitate to contact your teamleader or your HR Manager. | ||
</P> | ||
<P> | ||
Have a nice day! | ||
</P> | ||
yourRequestHasBeen: Your request has been | ||
Labels: | ||
AdhocWorkflow: Describe your Workflow | ||
|
@@ -155,6 +190,23 @@ Labels: | |
InsertTheTask: Insert the task | ||
TaskUser-Explain: Comma separated list of users | ||
title: Self Service Ad-hoc Workflow | ||
Notification: | ||
Messages: | ||
InvoiceSent: The invoice for order {0} was sent | ||
OrderDelivered: Order {0} delivered to customer {1} {2} | ||
OrderFinished: The order {0} successfully finished | ||
business: | ||
Templates: | ||
Order: | ||
Labels: | ||
Customer: Customer | ||
Greeting: Hello | ||
Message: Message | ||
Title: Order Information | ||
web: | ||
Subject: |- | ||
<%= ivy.html.escape(message) %><br> | ||
<%= ivy.cm.co("/Notification/business/Templates/Order/Labels/Customer") %> <i style="color:red;"><%= ivy.html.escape(payload.get("surname")) %> <%= ivy.html.escape(payload.get("name")) %> </i> | ||
ProcessDescriptions: | ||
AdHocDescription: 'Self Service Process: Launch an ad-hoc Workflow based on a predefined flow pattern.' | ||
AdHocName: Ad-hoc Process | ||
|
@@ -194,9 +246,21 @@ TaskDescriptions: | |
setupWorkstationDesc: 'Please set up the workstation for ' | ||
verifyRequest: Verify Request | ||
Texts: | ||
Adhoc-Explain: "<P>\r\n<B>Enter your comment </B>and press <B>Send</B> to proceed the workflow.\r\n</P>\r\n" | ||
AdhocWF-Explain: "<P>\r\nDefine and launch a Workflow at your fingertip: Select a flow pattern, add some tasks and start the Workflow. \r\n</P>\r\n<P>\r\n\r\n</P>\r\n" | ||
Approval-Explain: "<P>\r\n<B>Enter your decision</B> and press <B>Send </B>to proceed the workflow.\r\n</P>\r\n" | ||
QA-Explain: "<P>\r\nAnswer the question and <B>Send </B>your answer back to the caller. \r\n</P>\r\n" | ||
QAresponse-Explain: "<P>\r\nYou can <B>Send</B> back a follow-up question or <B>Finish</B> the Workflow.\r\n</P>\r\n" | ||
ToDo-Explain: "<P>\r\nConfirm that the<B> TODO </B>is <B>Done</B> or decline it.\r\n</P>\r\n" | ||
Adhoc-Explain: | | ||
<P> | ||
<B>Enter your comment </B>and press <B>Send</B> to proceed the workflow. | ||
</P> | ||
AdhocWF-Explain: "<P>\nDefine and launch a Workflow at your fingertip: Select a flow pattern, add some tasks and start the Workflow. \n</P>\n<P>\n\n</P>\n" | ||
Approval-Explain: | | ||
<P> | ||
<B>Enter your decision</B> and press <B>Send </B>to proceed the workflow. | ||
</P> | ||
QA-Explain: "<P>\nAnswer the question and <B>Send </B>your answer back to the caller. \n</P>\n" | ||
QAresponse-Explain: | | ||
<P> | ||
You can <B>Send</B> back a follow-up question or <B>Finish</B> the Workflow. | ||
</P> | ||
ToDo-Explain: | | ||
<P> | ||
Confirm that the<B> TODO </B>is <B>Done</B> or decline it. | ||
</P> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
<role>IT Manager</role> | ||
<role>Office Manager</role> | ||
<role>Executive Manager</role> | ||
<role>Processor</role> | ||
</user> | ||
<user> | ||
<username>wt</username> | ||
|
@@ -41,6 +42,7 @@ | |
<fullName>James Bond</fullName> | ||
<emailAddress>[email protected]</emailAddress> | ||
<role>Office Manager</role> | ||
<role>Deliverer</role> | ||
</user> | ||
<user> | ||
<username>hf</username> | ||
|
@@ -53,5 +55,6 @@ | |
<fullName>Benjamin Franklin</fullName> | ||
<emailAddress>[email protected]</emailAddress> | ||
<role>Executive Manager</role> | ||
<role>Finance</role> | ||
</user> | ||
</userConfig> |
4 changes: 4 additions & 0 deletions
4
workflow/workflow-demos/dataclasses/workflow/order/Order.ivyClass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Order #class | ||
workflow.order #namespace | ||
product String #field | ||
product PERSISTENT #fieldModifier |
6 changes: 6 additions & 0 deletions
6
workflow/workflow-demos/dataclasses/workflow/order/OrderData.ivyClass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
OrderData #class | ||
workflow.order #namespace | ||
customer workflow.order.Person #field | ||
customer PERSISTENT #fieldModifier | ||
order workflow.order.Order #field | ||
order PERSISTENT #fieldModifier |
6 changes: 6 additions & 0 deletions
6
workflow/workflow-demos/dataclasses/workflow/order/Person.ivyClass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Person #class | ||
workflow.order #namespace | ||
name String #field | ||
name PERSISTENT #fieldModifier | ||
surname String #field | ||
surname PERSISTENT #fieldModifier |
Oops, something went wrong.