use of org.eclipse.bpmn2.ConditionalEventDefinition in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method setCatchEventProperties.
private void setCatchEventProperties(CatchEvent event, Map<String, Object> properties, Definitions def) {
if (event.getOutputSet() != null) {
List<DataOutput> dataOutputs = event.getOutputSet().getDataOutputRefs();
StringBuffer doutbuff = new StringBuffer();
for (DataOutput dout : dataOutputs) {
doutbuff.append(dout.getName());
String dtype = getAnyAttributeValue(dout, "dtype");
if (dtype != null && !dtype.isEmpty()) {
doutbuff.append(":").append(dtype);
}
doutbuff.append(",");
}
if (doutbuff.length() > 0) {
doutbuff.setLength(doutbuff.length() - 1);
}
String dataoutput = doutbuff.toString();
properties.put(DATAOUTPUT, dataoutput);
List<DataOutputAssociation> outputAssociations = event.getDataOutputAssociation();
StringBuffer doutassociationbuff = new StringBuffer();
for (DataOutputAssociation doa : outputAssociations) {
String doaName = ((DataOutput) doa.getSourceRef().get(0)).getName();
if (doaName != null && doaName.length() > 0) {
doutassociationbuff.append("[dout]" + ((DataOutput) doa.getSourceRef().get(0)).getName());
doutassociationbuff.append("->");
doutassociationbuff.append(doa.getTargetRef().getId());
doutassociationbuff.append(",");
}
}
if (doutassociationbuff.length() > 0) {
doutassociationbuff.setLength(doutassociationbuff.length() - 1);
}
String assignments = doutassociationbuff.toString();
properties.put(DATAOUTPUTASSOCIATIONS, assignments);
setAssignmentsInfoProperty(null, null, dataoutput, null, assignments, properties);
}
// event definitions
List<EventDefinition> eventdefs = event.getEventDefinitions();
for (EventDefinition ed : eventdefs) {
if (ed instanceof TimerEventDefinition) {
setTimerEventProperties((TimerEventDefinition) ed, properties);
} else if (ed instanceof SignalEventDefinition) {
if (((SignalEventDefinition) ed).getSignalRef() != null) {
// find signal with the corresponding id
boolean foundSignalRef = false;
List<RootElement> rootElements = def.getRootElements();
for (RootElement re : rootElements) {
if (re instanceof Signal) {
if (re.getId().equals(((SignalEventDefinition) ed).getSignalRef())) {
properties.put("signalref", ((Signal) re).getName());
foundSignalRef = true;
}
}
}
if (!foundSignalRef) {
properties.put(SIGNALREF, "");
}
} else {
properties.put(SIGNALREF, "");
}
} else if (ed instanceof ErrorEventDefinition) {
if (((ErrorEventDefinition) ed).getErrorRef() != null && ((ErrorEventDefinition) ed).getErrorRef().getErrorCode() != null) {
properties.put(ERRORREF, ((ErrorEventDefinition) ed).getErrorRef().getErrorCode());
} else {
properties.put(ERRORREF, "");
}
} else if (ed instanceof ConditionalEventDefinition) {
FormalExpression conditionalExp = (FormalExpression) ((ConditionalEventDefinition) ed).getCondition();
if (conditionalExp != null) {
setConditionExpressionProperties(conditionalExp, properties, "drools");
}
} else if (ed instanceof EscalationEventDefinition) {
if (((EscalationEventDefinition) ed).getEscalationRef() != null) {
Escalation esc = ((EscalationEventDefinition) ed).getEscalationRef();
if (esc.getEscalationCode() != null && esc.getEscalationCode().length() > 0) {
properties.put(ESCALATIONCODE, esc.getEscalationCode());
} else {
properties.put(ESCALATIONCODE, "");
}
}
} else if (ed instanceof MessageEventDefinition) {
if (((MessageEventDefinition) ed).getMessageRef() != null) {
Message msg = ((MessageEventDefinition) ed).getMessageRef();
properties.put(MESSAGEREF, msg.getName());
}
} else if (ed instanceof CompensateEventDefinition) {
if (((CompensateEventDefinition) ed).getActivityRef() != null) {
Activity act = ((CompensateEventDefinition) ed).getActivityRef();
properties.put(ACTIVITYREF, act.getName());
}
}
}
}
use of org.eclipse.bpmn2.ConditionalEventDefinition in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method marshallBoundaryEvent.
protected void marshallBoundaryEvent(BoundaryEvent boundaryEvent, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, Map<String, Object> catchEventProperties) throws JsonGenerationException, IOException {
List<EventDefinition> eventDefinitions = boundaryEvent.getEventDefinitions();
if (boundaryEvent.isCancelActivity()) {
catchEventProperties.put(BOUNDARYCANCELACTIVITY, "true");
} else {
catchEventProperties.put(BOUNDARYCANCELACTIVITY, "false");
}
// simulation properties
setSimulationProperties(boundaryEvent.getId(), catchEventProperties);
if (eventDefinitions.size() == 1) {
EventDefinition eventDefinition = eventDefinitions.get(0);
if (eventDefinition instanceof SignalEventDefinition) {
marshallNode(boundaryEvent, catchEventProperties, "IntermediateSignalEventCatching", plane, generator, xOffset, yOffset);
} else if (eventDefinition instanceof EscalationEventDefinition) {
marshallNode(boundaryEvent, catchEventProperties, "IntermediateEscalationEvent", plane, generator, xOffset, yOffset);
} else if (eventDefinition instanceof ErrorEventDefinition) {
marshallNode(boundaryEvent, catchEventProperties, "IntermediateErrorEvent", plane, generator, xOffset, yOffset);
} else if (eventDefinition instanceof TimerEventDefinition) {
marshallNode(boundaryEvent, catchEventProperties, "IntermediateTimerEvent", plane, generator, xOffset, yOffset);
} else if (eventDefinition instanceof CompensateEventDefinition) {
marshallNode(boundaryEvent, catchEventProperties, "IntermediateCompensationEventCatching", plane, generator, xOffset, yOffset);
} else if (eventDefinition instanceof ConditionalEventDefinition) {
marshallNode(boundaryEvent, catchEventProperties, "IntermediateConditionalEvent", plane, generator, xOffset, yOffset);
} else if (eventDefinition instanceof MessageEventDefinition) {
marshallNode(boundaryEvent, catchEventProperties, "IntermediateMessageEventCatching", plane, generator, xOffset, yOffset);
} else {
throw new UnsupportedOperationException("Event definition not supported: " + eventDefinition);
}
} else {
throw new UnsupportedOperationException("None or multiple event definitions not supported for boundary event");
}
}
use of org.eclipse.bpmn2.ConditionalEventDefinition in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyCatchEventProperties.
protected void applyCatchEventProperties(CatchEvent event, Map<String, String> properties) {
parseAssignmentsInfo(properties);
if (properties.get("dataoutput") != null && !"".equals(properties.get("dataoutput"))) {
String[] allDataOutputs = properties.get("dataoutput").split(",\\s*");
OutputSet outSet = Bpmn2Factory.eINSTANCE.createOutputSet();
for (String dataOutput : allDataOutputs) {
if (dataOutput.trim().length() > 0) {
DataOutput nextOutput = Bpmn2Factory.eINSTANCE.createDataOutput();
String[] doutputParts = dataOutput.split(":\\s*");
if (doutputParts.length == 2) {
nextOutput.setId(event.getId() + "_" + doutputParts[0]);
nextOutput.setName(doutputParts[0]);
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "dtype", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, doutputParts[1]);
nextOutput.getAnyAttribute().add(extensionEntry);
} else {
nextOutput.setId(event.getId() + "_" + dataOutput);
nextOutput.setName(dataOutput);
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "dtype", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, "Object");
nextOutput.getAnyAttribute().add(extensionEntry);
}
event.getDataOutputs().add(nextOutput);
outSet.getDataOutputRefs().add(nextOutput);
}
}
event.setOutputSet(outSet);
}
if (properties.get("boundarycancelactivity") != null) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "boundaryca", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("boundarycancelactivity"));
event.getAnyAttribute().add(extensionEntry);
}
// data output associations
if (properties.get("dataoutputassociations") != null && !"".equals(properties.get("dataoutputassociations"))) {
String[] allAssociations = properties.get("dataoutputassociations").split(",\\s*");
for (String association : allAssociations) {
// data outputs are uni-directional
String[] associationParts = association.split("->\\s*");
String fromPart = associationParts[0];
if (fromPart.startsWith("[dout]")) {
fromPart = fromPart.substring(6, fromPart.length());
}
DataOutputAssociation doa = Bpmn2Factory.eINSTANCE.createDataOutputAssociation();
// for source refs we loop through already defined data outputs
List<DataOutput> dataOutputs = event.getDataOutputs();
if (dataOutputs != null) {
for (DataOutput ddo : dataOutputs) {
if (ddo.getId().equals(event.getId() + "_" + fromPart)) {
doa.getSourceRef().add(ddo);
}
}
}
// since we dont have the process vars defined yet..need to improvise
ItemAwareElement e = Bpmn2Factory.eINSTANCE.createItemAwareElement();
e.setId(associationParts[1]);
doa.setTargetRef(e);
event.getDataOutputAssociation().add(doa);
}
}
try {
if (event.getEventDefinitions() != null && event.getEventDefinitions().size() > 0) {
EventDefinition ed = event.getEventDefinitions().get(0);
if (ed instanceof TimerEventDefinition) {
applyTimerEventProperties((TimerEventDefinition) ed, properties);
} else if (ed instanceof SignalEventDefinition) {
if (properties.get("signalref") != null && !"".equals(properties.get("signalref"))) {
((SignalEventDefinition) ed).setSignalRef(properties.get("signalref"));
// ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
// EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
// "http://www.jboss.org/drools", "signalrefname", false, false);
// EStructuralFeatureImpl.SimpleFeatureMapEntry extensionEntry = new EStructuralFeatureImpl.SimpleFeatureMapEntry(extensionAttribute,
// properties.get("signalref"));
// ((SignalEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
} else if (ed instanceof ErrorEventDefinition) {
if (properties.get("errorref") != null && !"".equals(properties.get("errorref"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "erefname", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("errorref"));
((ErrorEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
} else if (ed instanceof ConditionalEventDefinition) {
applyConditionalEventProperties((ConditionalEventDefinition) ed, properties);
} else if (ed instanceof EscalationEventDefinition) {
if (properties.get("escalationcode") != null && !"".equals(properties.get("escalationcode"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "esccode", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("escalationcode"));
((EscalationEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
} else if (ed instanceof MessageEventDefinition) {
if (properties.get("messageref") != null && !"".equals(properties.get("messageref"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "msgref", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("messageref"));
((MessageEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
} else if (ed instanceof CompensateEventDefinition) {
if (properties.get("activityref") != null && !"".equals(properties.get("activityref"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "actrefname", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("activityref"));
((CompensateEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
}
}
} catch (Exception e) {
_logger.warn(e.getMessage());
}
// simulation
if (properties.get("distributiontype") != null && properties.get("distributiontype").length() > 0) {
TimeParameters timeParams = BpsimFactory.eINSTANCE.createTimeParameters();
Parameter processingTimeParam = BpsimFactory.eINSTANCE.createParameter();
if (properties.get("distributiontype").equals("normal")) {
NormalDistributionType normalDistributionType = BpsimFactory.eINSTANCE.createNormalDistributionType();
normalDistributionType.setStandardDeviation(Double.valueOf(properties.get("standarddeviation")));
normalDistributionType.setMean(Double.valueOf(properties.get("mean")));
processingTimeParam.getParameterValue().add(normalDistributionType);
} else if (properties.get("distributiontype").equals("uniform")) {
UniformDistributionType uniformDistributionType = BpsimFactory.eINSTANCE.createUniformDistributionType();
uniformDistributionType.setMax(Double.valueOf(properties.get("max")));
uniformDistributionType.setMin(Double.valueOf(properties.get("min")));
processingTimeParam.getParameterValue().add(uniformDistributionType);
// random distribution type not supported in bpsim 1.0
// } else if(properties.get("distributiontype").equals("random")) {
// RandomDistributionType randomDistributionType = DroolsFactory.eINSTANCE.createRandomDistributionType();
// randomDistributionType.setMax(Double.valueOf(properties.get("max")));
// randomDistributionType.setMin(Double.valueOf(properties.get("min")));
// processingTimeParam.getParameterValue().add(randomDistributionType);
} else if (properties.get("distributiontype").equals("poisson")) {
PoissonDistributionType poissonDistributionType = BpsimFactory.eINSTANCE.createPoissonDistributionType();
poissonDistributionType.setMean(Double.valueOf(properties.get("mean")));
processingTimeParam.getParameterValue().add(poissonDistributionType);
}
// no specific time unit available in 1.0 bpsim - use global
// if(properties.get("timeunit") != null) {
// timeParams.setTimeUnit(TimeUnit.getByName(properties.get("timeunit")));
// }
timeParams.setProcessingTime(processingTimeParam);
if (_simulationElementParameters.containsKey(event.getId())) {
_simulationElementParameters.get(event.getId()).add(timeParams);
} else {
List<EObject> values = new ArrayList<EObject>();
values.add(timeParams);
_simulationElementParameters.put(event.getId(), values);
}
}
if (properties.get("probability") != null && properties.get("probability").length() > 0) {
ControlParameters controlParams = BpsimFactory.eINSTANCE.createControlParameters();
Parameter probParam = BpsimFactory.eINSTANCE.createParameter();
FloatingParameterType probParamValueParam = BpsimFactory.eINSTANCE.createFloatingParameterType();
DecimalFormat twoDForm = new DecimalFormat("#.##");
probParamValueParam.setValue(Double.valueOf(twoDForm.format(Double.valueOf(properties.get("probability")))));
probParam.getParameterValue().add(probParamValueParam);
controlParams.setProbability(probParam);
if (_simulationElementParameters.containsKey(event.getId())) {
_simulationElementParameters.get(event.getId()).add(controlParams);
} else {
List<EObject> values = new ArrayList<EObject>();
values.add(controlParams);
_simulationElementParameters.put(event.getId(), values);
}
}
}
use of org.eclipse.bpmn2.ConditionalEventDefinition in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyThrowEventProperties.
protected void applyThrowEventProperties(ThrowEvent event, Map<String, String> properties) {
parseAssignmentsInfo(properties);
if (properties.get("datainput") != null && properties.get("datainput").trim().length() > 0) {
String[] allDataInputs = properties.get("datainput").split(",\\s*");
InputSet inset = Bpmn2Factory.eINSTANCE.createInputSet();
for (String dataInput : allDataInputs) {
if (dataInput.trim().length() > 0) {
DataInput nextInput = Bpmn2Factory.eINSTANCE.createDataInput();
String[] dataInputParts = dataInput.split(":\\s*");
if (dataInputParts.length == 2) {
nextInput.setId(event.getId() + "_" + dataInputParts[0] + (dataInputParts[0].endsWith("InputX") ? "" : "InputX"));
nextInput.setName(dataInputParts[0]);
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "dtype", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, dataInputParts[1]);
nextInput.getAnyAttribute().add(extensionEntry);
} else {
nextInput.setId(event.getId() + "_" + dataInput + (dataInput.endsWith("InputX") ? "" : "InputX"));
nextInput.setName(dataInput);
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "dtype", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, "Object");
nextInput.getAnyAttribute().add(extensionEntry);
}
event.getDataInputs().add(nextInput);
inset.getDataInputRefs().add(nextInput);
}
}
event.setInputSet(inset);
}
if (properties.get("datainputassociations") != null && properties.get("datainputassociations").length() > 0) {
String[] allAssignments = properties.get("datainputassociations").split(",\\s*");
for (String assignment : allAssignments) {
if (assignment.contains("=")) {
String[] assignmentParts = assignment.split("=\\s*");
String fromPart = assignmentParts[0];
if (fromPart.startsWith("[din]")) {
fromPart = fromPart.substring(5, fromPart.length());
}
DataInputAssociation dia = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
if (event.getInputSet() != null) {
List<DataInput> dataInputs = event.getInputSet().getDataInputRefs();
for (DataInput di : dataInputs) {
if (di.getId().equals(event.getId() + "_" + fromPart + (fromPart.endsWith("InputX") ? "" : "InputX"))) {
dia.setTargetRef(di);
}
}
}
Assignment a = Bpmn2Factory.eINSTANCE.createAssignment();
FormalExpression fromExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
if (assignmentParts.length > 1) {
String replacer = decodeAssociationValue(assignmentParts[1]);
fromExpression.setBody(wrapInCDATABlock(replacer));
} else {
fromExpression.setBody("");
}
FormalExpression toExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
toExpression.setBody(dia.getTargetRef().getId());
a.setFrom(fromExpression);
a.setTo(toExpression);
dia.getAssignment().add(a);
event.getDataInputAssociation().add(dia);
} else if (assignment.contains("->")) {
String[] assignmentParts = assignment.split("->\\s*");
String fromPart = assignmentParts[0];
boolean isDataInput = false;
boolean isDataOutput = false;
if (fromPart.startsWith("[din]")) {
fromPart = fromPart.substring(5, fromPart.length());
isDataInput = true;
}
if (isDataInput) {
DataInputAssociation dia = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
// association from process var to dataInput var
ItemAwareElement ie = Bpmn2Factory.eINSTANCE.createItemAwareElement();
ie.setId(fromPart);
dia.getSourceRef().add(ie);
List<DataInput> dataInputs = event.getInputSet().getDataInputRefs();
for (DataInput di : dataInputs) {
if (di.getId().equals(event.getId() + "_" + assignmentParts[1] + (assignmentParts[1].endsWith("InputX") ? "" : "InputX"))) {
dia.setTargetRef(di);
break;
}
}
event.getDataInputAssociation().add(dia);
}
} else {
// TODO throw exception here?
}
}
}
// signal scope metadata
if (properties.get("signalscope") != null && properties.get("signalscope").length() > 0 && !properties.get("signalscope").equals("default")) {
Utils.setMetaDataExtensionValue(event, "customScope", wrapInCDATABlock(properties.get("signalscope")));
}
try {
EventDefinition ed = event.getEventDefinitions().get(0);
if (ed instanceof TimerEventDefinition) {
applyTimerEventProperties((TimerEventDefinition) ed, properties);
} else if (ed instanceof SignalEventDefinition) {
if (properties.get("signalref") != null && !"".equals(properties.get("signalref"))) {
((SignalEventDefinition) ed).setSignalRef(properties.get("signalref"));
// ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
// EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
// "http://www.jboss.org/drools", "signalrefname", false, false);
// EStructuralFeatureImpl.SimpleFeatureMapEntry extensionEntry = new EStructuralFeatureImpl.SimpleFeatureMapEntry(extensionAttribute,
// properties.get("signalref"));
// ((SignalEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
} else if (ed instanceof ErrorEventDefinition) {
if (properties.get("errorref") != null && !"".equals(properties.get("errorref"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "erefname", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("errorref"));
((ErrorEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
} else if (ed instanceof ConditionalEventDefinition) {
applyConditionalEventProperties((ConditionalEventDefinition) ed, properties);
} else if (ed instanceof EscalationEventDefinition) {
if (properties.get("escalationcode") != null && !"".equals(properties.get("escalationcode"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "esccode", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("escalationcode"));
((EscalationEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
} else if (ed instanceof MessageEventDefinition) {
if (properties.get("messageref") != null && !"".equals(properties.get("messageref"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "msgref", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("messageref"));
((MessageEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
} else if (ed instanceof CompensateEventDefinition) {
if (properties.get("activityref") != null && !"".equals(properties.get("activityref"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "actrefname", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("activityref"));
((CompensateEventDefinition) event.getEventDefinitions().get(0)).getAnyAttribute().add(extensionEntry);
}
}
} catch (IndexOutOfBoundsException e) {
// TODO we dont want to barf here as test for example do not define event definitions in the bpmn2....
}
// simulation
if (properties.get("distributiontype") != null && properties.get("distributiontype").length() > 0) {
TimeParameters timeParams = BpsimFactory.eINSTANCE.createTimeParameters();
Parameter processingTimeParam = BpsimFactory.eINSTANCE.createParameter();
if (properties.get("distributiontype").equals("normal")) {
NormalDistributionType normalDistributionType = BpsimFactory.eINSTANCE.createNormalDistributionType();
normalDistributionType.setStandardDeviation(Double.valueOf(properties.get("standarddeviation")));
normalDistributionType.setMean(Double.valueOf(properties.get("mean")));
processingTimeParam.getParameterValue().add(normalDistributionType);
} else if (properties.get("distributiontype").equals("uniform")) {
UniformDistributionType uniformDistributionType = BpsimFactory.eINSTANCE.createUniformDistributionType();
uniformDistributionType.setMax(Double.valueOf(properties.get("max")));
uniformDistributionType.setMin(Double.valueOf(properties.get("min")));
processingTimeParam.getParameterValue().add(uniformDistributionType);
// random distribution type not supported in bpsim 1.0
// } else if(properties.get("distributiontype").equals("random")) {
// RandomDistributionType randomDistributionType = DroolsFactory.eINSTANCE.createRandomDistributionType();
// randomDistributionType.setMax(Double.valueOf(properties.get("max")));
// randomDistributionType.setMin(Double.valueOf(properties.get("min")));
// processingTimeParam.getParameterValue().add(randomDistributionType);
} else if (properties.get("distributiontype").equals("poisson")) {
PoissonDistributionType poissonDistributionType = BpsimFactory.eINSTANCE.createPoissonDistributionType();
poissonDistributionType.setMean(Double.valueOf(properties.get("mean")));
processingTimeParam.getParameterValue().add(poissonDistributionType);
}
// no specific time unit available in 1.0 bpsim - use global
// if(properties.get("timeunit") != null) {
// timeParams.setTimeUnit(TimeUnit.getByName(properties.get("timeunit")));
// }
timeParams.setProcessingTime(processingTimeParam);
if (_simulationElementParameters.containsKey(event.getId())) {
_simulationElementParameters.get(event.getId()).add(timeParams);
} else {
List<EObject> values = new ArrayList<EObject>();
values.add(timeParams);
_simulationElementParameters.put(event.getId(), values);
}
}
}
use of org.eclipse.bpmn2.ConditionalEventDefinition in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyConditionalEventProperties.
protected void applyConditionalEventProperties(ConditionalEventDefinition event, Map<String, String> properties) {
FormalExpression conditionExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
ScriptTypeValue value = new ScriptTypeTypeSerializer().parse(properties.get("conditionexpression"));
if (value.getLanguage() != null && !value.getLanguage().isEmpty()) {
String languageFormat = Utils.getScriptLanguageFormat(value.getLanguage());
if (languageFormat == null) {
// default to drools
languageFormat = "http://www.jboss.org/drools/rule";
}
conditionExpression.setLanguage(languageFormat);
}
if (value.getScript() != null && !value.getScript().isEmpty()) {
String scriptStr = value.getScript().replaceAll("\\\\n", "\n");
conditionExpression.setBody(wrapInCDATABlock(scriptStr));
}
event.setCondition(conditionExpression);
}
Aggregations