-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb99ee4
commit 0bbf7ae
Showing
82 changed files
with
2,146 additions
and
55 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<role> | ||
<identifier>Everybody</identifier> | ||
<role> | ||
<identifier>Leader</identifier> | ||
</role> | ||
<role> | ||
<identifier>Member</identifier> | ||
</role> | ||
</role> |
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,2 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<userConfig/> | ||
<userConfig> | ||
<user> | ||
<username>leader</username> | ||
<password>leader</password> | ||
<fullName>Leader</fullName> | ||
<emailAddress>[email protected]</emailAddress> | ||
<role>Leader</role> | ||
</user> | ||
<user> | ||
<username>member</username> | ||
<password>member</password> | ||
<fullName>Member</fullName> | ||
<emailAddress>[email protected]</emailAddress> | ||
<role>Member</role> | ||
</user> | ||
</userConfig> |
1 change: 1 addition & 0 deletions
1
...-connector-demo/dataclasses/com/axonivy/connector/mattermost/connector/demo/Data.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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Data #class | ||
com.axonivy.connector.mattermost.connector.demo #namespace | ||
result List<com.your.mattermost.url.client.ChannelMember> #field |
6 changes: 6 additions & 0 deletions
6
...m/axonivy/connector/mattermost/connector/demo/MattermostConnectorWebhookDemoData.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 @@ | ||
MattermostConnectorWebhookDemoData #class | ||
com.axonivy.connector.mattermost.connector.demo #namespace | ||
message String #field | ||
message PERSISTENT #fieldModifier | ||
channelId String #field | ||
channelId PERSISTENT #fieldModifier |
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
107 changes: 107 additions & 0 deletions
107
mattermost-connector-demo/processes/MattermostConnectorWebhookDemo.p.json
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,107 @@ | ||
{ | ||
"format" : "10.0.0", | ||
"id" : "18F952928A1574A7", | ||
"config" : { | ||
"data" : "com.axonivy.connector.mattermost.connector.demo.MattermostConnectorWebhookDemoData" | ||
}, | ||
"elements" : [ { | ||
"id" : "f0", | ||
"type" : "SignalStartEvent", | ||
"name" : "Check Team Absences", | ||
"config" : { | ||
"signalCode" : "CheckTeamAbsences", | ||
"output" : { | ||
"map" : { | ||
"out.channelId" : "signal.getSignalData() as String" | ||
}, | ||
"code" : [ | ||
"import com.axonivy.connector.mattermost.enums.CustomField;", | ||
"ivy.case.customFields().stringField(CustomField.CHANNEL_ID.getFieldName()).set(out.channelId);" | ||
] | ||
}, | ||
"attachToBusinessCase" : "false", | ||
"tags" : "demo" | ||
}, | ||
"visual" : { | ||
"at" : { "x" : 104, "y" : 112 }, | ||
"labelOffset" : { "x" : 17, "y" : -23 } | ||
}, | ||
"connect" : { "id" : "f3", "to" : "f2" } | ||
}, { | ||
"id" : "f1", | ||
"type" : "TaskEnd", | ||
"visual" : { | ||
"at" : { "x" : 784, "y" : 112 } | ||
} | ||
}, { | ||
"id" : "f2", | ||
"type" : "TaskSwitchEvent", | ||
"name" : "Check team absences", | ||
"config" : { | ||
"task" : { | ||
"name" : "Check Team Absences", | ||
"responsible" : { | ||
"role" : "Leader" | ||
} | ||
} | ||
}, | ||
"visual" : { | ||
"at" : { "x" : 232, "y" : 112 }, | ||
"labelOffset" : { "x" : 14, "y" : 34 } | ||
}, | ||
"connect" : { "id" : "f6", "to" : "f5" } | ||
}, { | ||
"id" : "f5", | ||
"type" : "DialogCall", | ||
"name" : "TeamAbsences", | ||
"config" : { | ||
"dialogId" : "com.axonivy.connector.mattermost.connector.demo.TeamAbsences", | ||
"startMethod" : "start()", | ||
"output" : { | ||
"map" : { | ||
"out" : "in", | ||
"out.message" : "result.message" | ||
} | ||
} | ||
}, | ||
"visual" : { | ||
"at" : { "x" : 360, "y" : 112 } | ||
}, | ||
"connect" : { "id" : "f17", "to" : "f16" } | ||
}, { | ||
"id" : "f7", | ||
"type" : "Script", | ||
"name" : "Send message to channel", | ||
"config" : { | ||
"output" : { | ||
"code" : [ | ||
"import com.axonivy.connector.mattermost.bo.IncomingWebhookParameter;", | ||
"import com.axonivy.connector.mattermost.demo.service.MattermostWebhookService;", | ||
"MattermostWebhookService service = new MattermostWebhookService();", | ||
"service.sendMessageToMattermostChannel(in.channelId, \"Absence Summary: \" + in.message);" | ||
] | ||
} | ||
}, | ||
"visual" : { | ||
"at" : { "x" : 648, "y" : 112 } | ||
}, | ||
"connect" : { "id" : "f4", "to" : "f1" } | ||
}, { | ||
"id" : "f16", | ||
"type" : "TaskSwitchEvent", | ||
"name" : "Send message to channel", | ||
"config" : { | ||
"task" : { | ||
"name" : "Send message to channel", | ||
"responsible" : { | ||
"role" : "SYSTEM" | ||
} | ||
} | ||
}, | ||
"visual" : { | ||
"at" : { "x" : 504, "y" : 112 }, | ||
"labelOffset" : { "x" : 14, "y" : 34 } | ||
}, | ||
"connect" : { "id" : "f8", "to" : "f7" } | ||
} ] | ||
} |
34 changes: 34 additions & 0 deletions
34
...demo/src/com/axonivy/connector/mattermost/demo/service/MattermostSlashCommandService.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,34 @@ | ||
package com.axonivy.connector.mattermost.demo.service; | ||
|
||
import javax.annotation.security.PermitAll; | ||
import javax.ws.rs.BeanParam; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
|
||
import com.axonivy.connector.mattermost.bo.SlashCommandGetRequestParameter; | ||
import com.axonivy.connector.mattermost.bo.SlashCommandResponse; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import ch.ivyteam.ivy.environment.Ivy; | ||
import ch.ivyteam.ivy.process.model.value.SignalCode; | ||
|
||
@Path("/mattermost/slashCommand") | ||
@PermitAll | ||
public class MattermostSlashCommandService { | ||
@GET | ||
public String startProcess(@BeanParam SlashCommandGetRequestParameter parameter) { | ||
SlashCommandResponse response = new SlashCommandResponse(); | ||
response.setResponseType("in_channel"); | ||
response.setText(String.format("Process CheckTeamAbsences has been started by %s", parameter.getUserName())); | ||
Ivy.wf().signals().send(new SignalCode("CheckTeamAbsences"), parameter.getChannelId()); | ||
ObjectMapper mapper = new ObjectMapper(); | ||
try { | ||
return mapper.writeValueAsString(response); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return StringUtils.EMPTY; | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ctor-demo/src/com/axonivy/connector/mattermost/demo/service/MattermostWebhookService.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,45 @@ | ||
package com.axonivy.connector.mattermost.demo.service; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
|
||
import com.axonivy.connector.mattermost.bo.IncomingWebhookParameter; | ||
import com.axonivy.connector.mattermost.service.ChannelService; | ||
import com.axonivy.connector.mattermost.service.IncomingWebhookService; | ||
import com.axonivy.connector.mattermost.service.TeamService; | ||
import com.your.mattermost.url.client.Channel; | ||
import com.your.mattermost.url.client.IncomingWebhook; | ||
|
||
import ch.ivyteam.ivy.environment.Ivy; | ||
|
||
public class MattermostWebhookService { | ||
public MattermostWebhookService() { | ||
} | ||
|
||
public void sendMessageToMattermostChannel(String channelId, String message) { | ||
String teamId = TeamService.getTeamIdByTeamName(Ivy.var().get("mattermost.teamName")); | ||
if (StringUtils.isBlank(teamId)) { | ||
return; | ||
} | ||
|
||
IncomingWebhook webhook = IncomingWebhookService.getIncommingWebhookId(channelId, teamId); | ||
if (webhook == null || StringUtils.isBlank(webhook.getId())) { | ||
return; | ||
} | ||
|
||
Channel channel = ChannelService.getChannelById(channelId); | ||
if (channel == null || StringUtils.isBlank(channel.getId())) { | ||
return; | ||
} | ||
|
||
sendIncomingWebhook(channel, webhook.getId(), message); | ||
} | ||
|
||
private void sendIncomingWebhook(Channel channel, String webhookId, String message) { | ||
try { | ||
IncomingWebhookParameter parameter = new IncomingWebhookParameter(channel.getName(), message); | ||
IncomingWebhookService.sendIncomingWebhook(parameter, webhookId); | ||
} catch (Exception ex) { | ||
Ivy.log().error("Failed to notify channel Id {0}: {1}", channel.getId(), ex); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...hd/com/axonivy/connector/mattermost/connector/demo/TeamAbsences/TeamAbsences.rddescriptor
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<richDialogDescriptor> | ||
<property> | ||
<name>viewTechnology</name> | ||
<value>JSF</value> | ||
</property> | ||
</richDialogDescriptor> |
28 changes: 28 additions & 0 deletions
28
...mo/src_hd/com/axonivy/connector/mattermost/connector/demo/TeamAbsences/TeamAbsences.xhtml
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,28 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" | ||
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
xmlns:ic="http://ivyteam.ch/jsf/component" xmlns:p="http://primefaces.org/ui" | ||
xmlns:pe="http://primefaces.org/ui/extensions"> | ||
<h:body> | ||
<ui:composition template="/layouts/frame-10.xhtml"> | ||
<ui:define name="title">Team Absences</ui:define> | ||
<ui:define name="content"> | ||
|
||
<h3> | ||
Report team absences | ||
</h3> | ||
|
||
<h:form id="form"> | ||
<p:messages /> | ||
<h:inputTextarea value="#{data.message}"></h:inputTextarea> | ||
<br /> | ||
<div class="command-btns"> | ||
<p:commandLink id="cancel" actionListener="#{ivyWorkflowView.cancel()}" process="@this" value="Cancel" /> | ||
<p:commandButton id="proceed" actionListener="#{logic.close}" value="Proceed" update="form" icon="pi pi-check" /> | ||
</div> | ||
</h:form> | ||
|
||
</ui:define> | ||
</ui:composition> | ||
</h:body> | ||
|
||
</html> |
4 changes: 4 additions & 0 deletions
4
...hd/com/axonivy/connector/mattermost/connector/demo/TeamAbsences/TeamAbsencesData.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 @@ | ||
TeamAbsencesData #class | ||
com.axonivy.connector.mattermost.connector.demo.TeamAbsences #namespace | ||
message String #field | ||
message PERSISTENT #fieldModifier |
52 changes: 52 additions & 0 deletions
52
...d/com/axonivy/connector/mattermost/connector/demo/TeamAbsences/TeamAbsencesProcess.p.json
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,52 @@ | ||
{ | ||
"format" : "10.0.0", | ||
"id" : "18F953D50A711458", | ||
"kind" : "HTML_DIALOG", | ||
"config" : { | ||
"data" : "com.axonivy.connector.mattermost.connector.demo.TeamAbsences.TeamAbsencesData" | ||
}, | ||
"elements" : [ { | ||
"id" : "f0", | ||
"type" : "HtmlDialogStart", | ||
"name" : "start()", | ||
"config" : { | ||
"callSignature" : "start", | ||
"result" : { | ||
"params" : [ | ||
{ "name" : "message", "type" : "String" } | ||
], | ||
"map" : { | ||
"result.message" : "in.message" | ||
} | ||
}, | ||
"guid" : "18F953D50A7ED10A" | ||
}, | ||
"visual" : { | ||
"at" : { "x" : 96, "y" : 64 } | ||
}, | ||
"connect" : { "id" : "f2", "to" : "f1" } | ||
}, { | ||
"id" : "f1", | ||
"type" : "HtmlDialogEnd", | ||
"visual" : { | ||
"at" : { "x" : 224, "y" : 64 } | ||
} | ||
}, { | ||
"id" : "f3", | ||
"type" : "HtmlDialogEventStart", | ||
"name" : "close", | ||
"config" : { | ||
"guid" : "18F953D50A9D7F2B" | ||
}, | ||
"visual" : { | ||
"at" : { "x" : 96, "y" : 160 } | ||
}, | ||
"connect" : { "id" : "f5", "to" : "f4" } | ||
}, { | ||
"id" : "f4", | ||
"type" : "HtmlDialogExit", | ||
"visual" : { | ||
"at" : { "x" : 224, "y" : 160 } | ||
} | ||
} ] | ||
} |
Oops, something went wrong.