use of org.eclipse.bpmn2.InclusiveGateway in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyGatewayProperties.
protected void applyGatewayProperties(Gateway gateway, Map<String, String> properties) {
if (properties.get("name") != null && properties.get("name").length() > 0) {
gateway.setName(StringEscapeUtils.escapeXml(properties.get("name")).replaceAll("\\r\\n|\\r|\\n", " "));
// add unescaped and untouched name value as extension element as well
Utils.setMetaDataExtensionValue(gateway, "elementname", wrapInCDATABlock(properties.get("name").replaceAll("\\\\n", "\n")));
} else {
gateway.setName("");
}
if (properties.get("defaultgate") != null && (gateway instanceof InclusiveGateway || gateway instanceof ExclusiveGateway)) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "dg", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("defaultgate"));
gateway.getAnyAttribute().add(extensionEntry);
}
}
use of org.eclipse.bpmn2.InclusiveGateway in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setDefaultGateway.
private void setDefaultGateway(FlowElement fe, List<SequenceFlow> sqList) {
Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("dg")) {
for (SequenceFlow newFlow : sqList) {
String entryValue = (String) entry.getValue();
String entryValueId = "";
String[] entryValueParts = entryValue.split(" : ");
if (entryValueParts.length == 1) {
entryValueId = entryValueParts[0];
} else if (entryValueParts.length > 1) {
entryValueId = entryValueParts[1];
}
if (newFlow.getId().equals(entryValueId)) {
if (fe instanceof ExclusiveGateway) {
((ExclusiveGateway) fe).setDefault(newFlow);
} else if (fe instanceof InclusiveGateway) {
((InclusiveGateway) fe).setDefault(newFlow);
}
if (newFlow.getConditionExpression() == null) {
FormalExpression expr = Bpmn2Factory.eINSTANCE.createFormalExpression();
expr.setBody("");
newFlow.setConditionExpression(expr);
}
}
}
}
}
}
use of org.eclipse.bpmn2.InclusiveGateway in project kie-wb-common by kiegroup.
the class GatewayPropertyWriterTest method testSetTargetForInclusiveGateway.
@Test
public void testSetTargetForInclusiveGateway() {
InclusiveGateway inclusiveGateway = mockGateway(InclusiveGateway.class, ID);
prepareTestSetSourceOrTarget(inclusiveGateway);
propertyWriter.setTarget(anotherPropertyWriter);
verify(inclusiveGateway).setDefault(sequenceFlow);
}
use of org.eclipse.bpmn2.InclusiveGateway in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setGatewayInfo.
private void setGatewayInfo(FlowElementsContainer container) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof Gateway) {
Gateway gateway = (Gateway) fe;
int incoming = gateway.getIncoming() == null ? 0 : gateway.getIncoming().size();
int outgoing = gateway.getOutgoing() == null ? 0 : gateway.getOutgoing().size();
if (incoming <= 1 && outgoing > 1) {
gateway.setGatewayDirection(GatewayDirection.DIVERGING);
} else if (incoming > 1 && outgoing <= 1) {
gateway.setGatewayDirection(GatewayDirection.CONVERGING);
} else // temp. removing support for mixed gateway direction (not supported by runtime yet)
// else if (incoming > 1 && outgoing > 1) {
// gateway.setGatewayDirection(GatewayDirection.MIXED);
// }
// else if (incoming == 1 && outgoing == 1) {
// // this handles the 1:1 case of the diverging gateways
// }
{
gateway.setGatewayDirection(GatewayDirection.UNSPECIFIED);
}
}
if (fe instanceof InclusiveGateway) {
InclusiveGateway ig = (InclusiveGateway) fe;
List<SequenceFlow> sqList = new ArrayList<SequenceFlow>();
if (ig.getIncoming() != null) {
sqList.addAll(ig.getIncoming());
}
if (ig.getOutgoing() != null) {
sqList.addAll(ig.getOutgoing());
}
setDefaultGateway(fe, sqList);
}
if (fe instanceof ExclusiveGateway) {
ExclusiveGateway eg = (ExclusiveGateway) fe;
List<SequenceFlow> sqList = new ArrayList<SequenceFlow>();
if (eg.getIncoming() != null) {
sqList.addAll(eg.getIncoming());
}
if (eg.getOutgoing() != null) {
sqList.addAll(eg.getOutgoing());
}
setDefaultGateway(fe, sqList);
}
if (fe instanceof FlowElementsContainer) {
setGatewayInfo((FlowElementsContainer) fe);
}
}
}
use of org.eclipse.bpmn2.InclusiveGateway in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method marshallInclusiveGateway.
protected void marshallInclusiveGateway(InclusiveGateway gateway, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, Map<String, Object> flowElementProperties) throws JsonGenerationException, IOException {
if (gateway.getDefault() != null) {
SequenceFlow defsf = gateway.getDefault();
String defGatewayStr = defsf.getId();
flowElementProperties.put("defaultgate", defGatewayStr);
}
marshallNode(gateway, flowElementProperties, "InclusiveGateway", plane, generator, xOffset, yOffset);
}
Aggregations