Skip to content

Commit

Permalink
Kapitel 5
Browse files Browse the repository at this point in the history
  • Loading branch information
scepbjoern committed Sep 13, 2018
1 parent 0202aa5 commit 70d0aae
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package ch.zhaw.gpi.twitterreview.delegates;

import javax.inject.Named;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;

/**
* Implementation des Send Task "Mitarbeiter benachrichtigen"
*
* @author scep
*/
@Named("notifyEmployeeAdapter")
public class NotifyEmployeeDelegate implements JavaDelegate {

/**
* Mockt das Senden einer Benachrichtigung per Mail
*
* 1. Die benötigten Prozessvariablen auslesen
* 2. Die E-Mail-Nachricht zusammenstellen
* 3. Die E-Mail in der Konsole ausgeben
*
* @param de
* @throws Exception
*/
@Override
public void execute(DelegateExecution de) throws Exception {
// Prozessvariablen auslesen
String email = (String) de.getVariable("email");
String tweetContent = (String) de.getVariable("tweetContent");
String checkResult = (String) de.getVariable("checkResult");
String checkResultComment = (String) de.getVariable("checkResultComment");

// Die E-Mail-Nachricht zusammenbauen
String mailHauptteil;
if(checkResult.equals("rejected")){
mailHauptteil = "Leider wurde diese Tweet-Anfrage abgelehnt mit " +
"folgender Begründung:\n" + checkResultComment;
} else {
mailHauptteil = "Dein Tweet wurde geposted. Herzlichen Dank für Deinen Beitrag.";
}

// Mail-Text zusammenbauen
String mailBody = "Hallo Mitarbeiter\n\n" + "Du hast folgenden Text zum " +
"Veröffentlichen als Tweet vorgeschlagen:\n" + tweetContent + "\n\n" +
mailHauptteil + "\n\n" + "Deine Kommunikationsabteilung";

// Mail in Konsole ausgeben
System.out.println("########### BEGIN MAIL ##########################");
System.out.println("############################### Mail-Empfänger: " + email);
System.out.println(mailBody);
System.out.println("########### END MAIL ############################");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ch.zhaw.gpi.twitterreview.delegates;

import javax.inject.Named;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;

/**
* Implementation des Service Task "Tweet senden"
*
* @author scep
*/
@Named("sendTweetAdapter")
public class SendTweetDelegate implements JavaDelegate {

/**
* Mockt das Senden eines Tweeets
*
* 1. Die Prozessvariable tweetContent wird ausgelesen
* 2. Dieser Text wird in der Console ausgegeben
*
* @param de Objekt, welches die Verknüpfung zur Process Engine und zur aktuellen Execution enthält
* @throws Exception
*/
@Override
public void execute(DelegateExecution de) throws Exception {
String tweetContent = (String) de.getVariable("tweetContent");
System.out.println("!!!!!!!!!!!!!!!! Folgender Tweet wird veröffentlicht: " + tweetContent);
}

}
40 changes: 20 additions & 20 deletions src/main/resources/twitter-review.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<bpmn:flowNodeRef>ExclusiveGateway_0fj9kmh</bpmn:flowNodeRef>
<bpmn:flowNodeRef>TweetAnfrageBehandelt</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Pruefergebnis</bpmn:flowNodeRef>
<bpmn:flowNodeRef>MitarbeiterKuerzelExtrahieren</bpmn:flowNodeRef>
<bpmn:flowNodeRef>TweetSenden</bpmn:flowNodeRef>
<bpmn:flowNodeRef>MitarbeiterBenachrichtigen</bpmn:flowNodeRef>
<bpmn:flowNodeRef>MitarbeiterKuerzelExtrahieren</bpmn:flowNodeRef>
</bpmn:lane>
</bpmn:laneSet>
<bpmn:sequenceFlow id="SequenceFlow_1vqcip2" sourceRef="TweetAnfrageEingereicht" targetRef="MitarbeiterKuerzelExtrahieren" />
Expand Down Expand Up @@ -51,19 +51,6 @@
<bpmn:endEvent id="TweetAnfrageBehandelt" name="Tweet-Anfrage&#10;behandelt">
<bpmn:incoming>SequenceFlow_0wkf2cr</bpmn:incoming>
</bpmn:endEvent>
<bpmn:task id="TweetSenden" name="Tweet senden">
<bpmn:extensionElements>
<camunda:properties>
<camunda:property name="KPI-Ratio" value="Tweet Rejected" />
</camunda:properties>
</bpmn:extensionElements>
<bpmn:incoming>Genehmigt</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_13w0jnd</bpmn:outgoing>
</bpmn:task>
<bpmn:task id="MitarbeiterBenachrichtigen" name="Mitarbeiter benachrichtigen">
<bpmn:incoming>SequenceFlow_0akgqts</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0wkf2cr</bpmn:outgoing>
</bpmn:task>
<bpmn:userTask id="TweetAnfragePruefen" name="Tweet-Anfrage prüfen" camunda:candidateGroups="kommunikationsabteilung">
<bpmn:extensionElements>
<camunda:formData>
Expand Down Expand Up @@ -110,6 +97,19 @@
<bpmn:script>emailAdress = execution.getVariable("email");
execution.setVariable("alias", emailAdress.substring(0,4));</bpmn:script>
</bpmn:scriptTask>
<bpmn:serviceTask id="TweetSenden" name="Tweet senden" camunda:asyncBefore="true" camunda:delegateExpression="#{sendTweetAdapter}">
<bpmn:extensionElements>
<camunda:properties>
<camunda:property name="KPI-Ratio" value="Tweet Rejected" />
</camunda:properties>
</bpmn:extensionElements>
<bpmn:incoming>Genehmigt</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_13w0jnd</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sendTask id="MitarbeiterBenachrichtigen" name="Mitarbeiter benachrichtigen" camunda:asyncBefore="true" camunda:delegateExpression="#{notifyEmployeeAdapter}">
<bpmn:incoming>SequenceFlow_0akgqts</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0wkf2cr</bpmn:outgoing>
</bpmn:sendTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1y44tdo">
Expand Down Expand Up @@ -200,12 +200,6 @@ execution.setVariable("alias", emailAdress.substring(0,4));</bpmn:script>
<bpmndi:BPMNShape id="Lane_1d0re29_di" bpmnElement="Lane_1d0re29">
<dc:Bounds x="32" y="284" width="1059" height="234" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_19ckxfd_di" bpmnElement="TweetSenden">
<dc:Bounds x="612" y="418" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1ighy8a_di" bpmnElement="MitarbeiterBenachrichtigen">
<dc:Bounds x="857" y="311" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTask_1o2fmod_di" bpmnElement="TweetAnfragePruefen">
<dc:Bounds x="361" y="172" width="100" height="80" />
</bpmndi:BPMNShape>
Expand All @@ -227,6 +221,12 @@ execution.setVariable("alias", emailAdress.substring(0,4));</bpmn:script>
<bpmndi:BPMNShape id="ScriptTask_0oeqqmr_di" bpmnElement="MitarbeiterKuerzelExtrahieren">
<dc:Bounds x="139" y="311" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_1fbdslq_di" bpmnElement="TweetSenden">
<dc:Bounds x="612" y="418" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SendTask_169hbwy_di" bpmnElement="MitarbeiterBenachrichtigen">
<dc:Bounds x="857" y="311" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit 70d0aae

Please sign in to comment.