use of bpsim.ControlParameters in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applySequenceFlowProperties.
protected void applySequenceFlowProperties(SequenceFlow sequenceFlow, Map<String, String> properties) {
// sequence flow name is options
if (properties.get("name") != null && !"".equals(properties.get("name"))) {
sequenceFlow.setName(StringEscapeUtils.escapeXml(properties.get("name")).replaceAll("\\r\\n|\\r|\\n", " "));
// add unescaped and untouched name value as extension eleent as well
Utils.setMetaDataExtensionValue(sequenceFlow, "elementname", wrapInCDATABlock(properties.get("name").replaceAll("\\\\n", "\n")));
}
if (properties.get("bgcolor") != null && properties.get("bgcolor").length() > 0) {
if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("bgcolor:" + properties.get("bgcolor"));
_elementColors.put(sequenceFlow.getId(), colorsList);
} else {
_elementColors.get(sequenceFlow.getId()).add("bgcolor:" + properties.get("bgcolor"));
}
}
if (properties.get("bordercolor") != null && properties.get("bordercolor").length() > 0) {
if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("bordercolor:" + properties.get("bordercolor"));
_elementColors.put(sequenceFlow.getId(), colorsList);
} else {
_elementColors.get(sequenceFlow.getId()).add("bordercolor:" + properties.get("bordercolor"));
}
}
if (properties.get("fontsize") != null && properties.get("fontsize").length() > 0) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "fontsize", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("fontsize"));
sequenceFlow.getAnyAttribute().add(extensionEntry);
}
if (properties.get("fontcolor") != null && properties.get("fontcolor").length() > 0) {
if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("fontcolor:" + properties.get("fontcolor"));
_elementColors.put(sequenceFlow.getId(), colorsList);
} else {
_elementColors.get(sequenceFlow.getId()).add("fontcolor:" + properties.get("fontcolor"));
}
}
// Custom extended auto connection property for Stunner.
String sourceConnAutoPropertyName = Bpmn2OryxManager.MAGNET_AUTO_CONNECTION + Bpmn2OryxManager.SOURCE;
String sourceConnAutoRaw = properties.get(sourceConnAutoPropertyName);
if (null != sourceConnAutoRaw && Boolean.TRUE.equals(Boolean.parseBoolean(sourceConnAutoRaw))) {
Utils.setMetaDataExtensionValue(sequenceFlow, sourceConnAutoPropertyName, Boolean.toString(true));
}
String targetConnAutoPropertyName = Bpmn2OryxManager.MAGNET_AUTO_CONNECTION + Bpmn2OryxManager.TARGET;
String targetConnAutoRaw = properties.get(targetConnAutoPropertyName);
if (null != targetConnAutoRaw && Boolean.TRUE.equals(Boolean.parseBoolean(targetConnAutoRaw))) {
Utils.setMetaDataExtensionValue(sequenceFlow, targetConnAutoPropertyName, Boolean.toString(true));
}
if (properties.get("isselectable") != null && properties.get("isselectable").length() > 0) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "selectable", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("isselectable"));
sequenceFlow.getAnyAttribute().add(extensionEntry);
}
if (properties.get("auditing") != null && !"".equals(properties.get("auditing"))) {
Auditing audit = Bpmn2Factory.eINSTANCE.createAuditing();
audit.getDocumentation().add(createDocumentation(properties.get("auditing")));
sequenceFlow.setAuditing(audit);
}
applySequenceFlowCondition(sequenceFlow, properties);
if (properties.get("priority") != null && !"".equals(properties.get("priority"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl priorityElement = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "priority", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(priorityElement, properties.get("priority"));
sequenceFlow.getAnyAttribute().add(extensionEntry);
}
if (properties.get("monitoring") != null && !"".equals(properties.get("monitoring"))) {
Monitoring monitoring = Bpmn2Factory.eINSTANCE.createMonitoring();
monitoring.getDocumentation().add(createDocumentation(properties.get("monitoring")));
sequenceFlow.setMonitoring(monitoring);
}
sequenceFlow.setIsImmediate(Boolean.parseBoolean(properties.get("isimmediate")));
// simulation properties
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(sequenceFlow.getId())) {
_simulationElementParameters.get(sequenceFlow.getId()).add(controlParams);
} else {
List<EObject> values = new ArrayList<EObject>();
values.add(controlParams);
_simulationElementParameters.put(sequenceFlow.getId(), values);
}
}
}
use of bpsim.ControlParameters 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 bpsim.ControlParameters in project jbpm by kiegroup.
the class ElementParametersImpl method basicSetControlParameters.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetControlParameters(ControlParameters newControlParameters, NotificationChain msgs) {
ControlParameters oldControlParameters = controlParameters;
controlParameters = newControlParameters;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BpsimPackage.ELEMENT_PARAMETERS__CONTROL_PARAMETERS, oldControlParameters, newControlParameters);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of bpsim.ControlParameters in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method addSimulation.
public void addSimulation(Definitions def) {
Relationship relationship = Bpmn2Factory.eINSTANCE.createRelationship();
relationship.getSources().add(def);
relationship.getTargets().add(def);
relationship.setType(defaultRelationshipType);
BPSimDataType simDataType = BpsimFactory.eINSTANCE.createBPSimDataType();
// currently support single scenario
Scenario defaultScenario = BpsimFactory.eINSTANCE.createScenario();
// single scenario suppoert
defaultScenario.setId("default");
// single scenario support
defaultScenario.setName("Simulationscenario");
defaultScenario.setScenarioParameters(_simulationScenarioParameters);
if (_simulationElementParameters.size() > 0) {
Iterator<String> iter = _simulationElementParameters.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
ElementParameters etype = BpsimFactory.eINSTANCE.createElementParameters();
etype.setElementRef(key);
List<EObject> params = _simulationElementParameters.get(key);
for (EObject np : params) {
if (np instanceof ControlParameters) {
etype.setControlParameters((ControlParameters) np);
} else if (np instanceof CostParameters) {
etype.setCostParameters((CostParameters) np);
} else if (np instanceof PriorityParameters) {
etype.setPriorityParameters((PriorityParameters) np);
} else if (np instanceof ResourceParameters) {
etype.setResourceParameters((ResourceParameters) np);
} else if (np instanceof TimeParameters) {
etype.setTimeParameters((TimeParameters) np);
}
}
defaultScenario.getElementParameters().add(etype);
}
}
simDataType.getScenario().add(defaultScenario);
ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
relationship.getExtensionValues().add(extensionElement);
FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) BpsimPackage.Literals.DOCUMENT_ROOT__BP_SIM_DATA, simDataType);
relationship.getExtensionValues().get(0).getValue().add(extensionElementEntry);
def.getRelationships().add(relationship);
}
Aggregations