Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/pinussilvestrus/bncl int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
Niklas Kiefer committed Jun 17, 2016
2 parents 2dafb2e + ac602ac commit da93bf5
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/main/java/de/niklaskiefer/bpmnncl/BPMNModelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance;
import org.camunda.bpm.model.bpmn.instance.Definitions;
import org.camunda.bpm.model.bpmn.instance.EventDefinition;
import org.camunda.bpm.model.bpmn.instance.ExclusiveGateway;
import org.camunda.bpm.model.bpmn.instance.FlowNode;
import org.camunda.bpm.model.bpmn.instance.Gateway;
import org.camunda.bpm.model.bpmn.instance.ParallelGateway;
import org.camunda.bpm.model.bpmn.instance.Process;
import org.camunda.bpm.model.bpmn.instance.SequenceFlow;
Expand Down Expand Up @@ -73,8 +75,8 @@ public SequenceFlow createSequenceFlow(Process process, String idFrom, String id
return null;
}

public ParallelGateway createParallelGateway(Process process, Map<String, String> attributes) {
return createElement(process, ParallelGateway.class, attributes);
public Gateway createGateway(Process process, Map<String, String> attributes, Class type) {
return (Gateway) createElement(process, type, attributes);
}

public SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/niklaskiefer/bpmnncl/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MainApplication {
"errorevent signed event1 called 3 Stunden vergangen with " +
"scripttask signed usertask1 called dosomething with " +
"usertask signed usertask2 with " +
"parallelgateway signed gateway1 with " +
"inclusivegateway signed gateway1 with " +
"parallelgateway signed gateway2 with " +
"sequenceflow comesfrom startevent1 goesto event1 with " +
"sequenceflow comesfrom event1 goesto gateway1 with " +
Expand Down
64 changes: 51 additions & 13 deletions src/main/java/de/niklaskiefer/bpmnncl/parser/BnclGatewayParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

import de.niklaskiefer.bpmnncl.BPMNModelBuilder;

import org.camunda.bpm.model.bpmn.instance.EventBasedGateway;
import org.camunda.bpm.model.bpmn.instance.ExclusiveGateway;
import org.camunda.bpm.model.bpmn.instance.Gateway;
import org.camunda.bpm.model.bpmn.instance.InclusiveGateway;
import org.camunda.bpm.model.bpmn.instance.ParallelGateway;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand All @@ -12,33 +17,66 @@
*/
public class BnclGatewayParser extends BnclElementParser {

// types
public static final String PARALLEL_GATEWAY = "parallelgateway";
private List<GatewayType> gatewayTypes = new ArrayList<>();

public BnclGatewayParser(BPMNModelBuilder builder) {
super(builder);
initGatewayTypes();
}

public Gateway parseGateway(String elementString) throws Exception {
List<String> withoutSpaces = BnclParser.getWordsWithoutSpaces(elementString);

/**for (String word : withoutSpaces) {
logger().info(word);
}**/

String id;
Class type;

if (!BnclParser.checkWords(withoutSpaces)) {
return null;
}

switch (withoutSpaces.get(0).toLowerCase()) {
case PARALLEL_GATEWAY:
String first = withoutSpaces.get(0).toLowerCase();
for (GatewayType gatewayType : gatewayTypes) {
if (first.equals(gatewayType.getKeyword())) {
Map<String, String> attributes = parseAttributes(withoutSpaces);
return builder.createParallelGateway(builder.getProcess(), attributes);
default:
return null;
return builder.createGateway(builder.getProcess(), attributes, gatewayType.getType());
}
}

return null;
}

private void initGatewayTypes() {
gatewayTypes.add(new GatewayType("parallelgateway", ParallelGateway.class));
gatewayTypes.add(new GatewayType("exclusivegateway", ExclusiveGateway.class));
gatewayTypes.add(new GatewayType("inclusivegateway", InclusiveGateway.class));
gatewayTypes.add(new GatewayType("eventbasedgateway", EventBasedGateway.class));
}

public List<GatewayType> getGatewayTypes() {
return gatewayTypes;
}

private static class GatewayType {
private String keyword;
private Class type;

private GatewayType(String keyword, Class type) {
this.keyword = keyword;
this.type = type;
}

public String getKeyword() {
return keyword;
}

public void setKeyword(String keyword) {
this.keyword = keyword;
}

public Class getType() {
return type;
}

public void setType(Class type) {
this.type = type;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class BnclToXmlWriterTest {
private BnclEventParser eventParser;
private BnclTaskParser taskParser;

private final String testBncl = "lets create a process with startevent signed startEvent1 called startevent1 with usertask signed usertask1 called dosomething with usertask signed usertask2 with parallelgateway signed gateway1 with parallelgateway signed gateway2 with sequenceflow comesfrom startevent1 goesto gateway1 with sequenceflow comesfrom gateway1 goesto usertask1 with sequenceflow comesfrom gateway1 goesto usertask2 with sequenceflow comesfrom usertask1 goesto gateway2 with sequenceflow comesfrom usertask2 goesto gateway2 with endevent signed endevent1 called terminated with sequenceflow comesfrom gateway2 goesto endevent1";
private final String testBncl = "lets create a process with startevent signed startEvent1 called startevent1 with usertask signed usertask1 called dosomething with usertask signed usertask2 with parallelgateway signed gateway1 with exclusivegateway signed gateway2 with sequenceflow comesfrom startevent1 goesto gateway1 with sequenceflow comesfrom gateway1 goesto usertask1 with sequenceflow comesfrom gateway1 goesto usertask2 with sequenceflow comesfrom usertask1 goesto gateway2 with sequenceflow comesfrom usertask2 goesto gateway2 with endevent signed endevent1 called terminated with sequenceflow comesfrom gateway2 goesto endevent1";

@Before
public void setUp() {
Expand Down

0 comments on commit da93bf5

Please sign in to comment.