use of org.eclipse.bpmn2.Property 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 org.eclipse.bpmn2.Property in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testMarshallProcessVariables.
@Test
public void testMarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
Definitions definitions = (Definitions) resource.getContents().get(0);
assertNotNull(definitions);
List<RootElement> rootElements = definitions.getRootElements();
assertNotNull(rootElements);
assertNotNull(getItemDefinition(rootElements, "_employeeItem", "java.lang.String"));
assertNotNull(getItemDefinition(rootElements, "_reasonItem", "java.lang.String"));
assertNotNull(getItemDefinition(rootElements, "_performanceItem", "java.lang.String"));
Process process = getProcess(definitions);
assertNotNull(process);
List<Property> properties = process.getProperties();
assertNotNull(properties);
assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
use of org.eclipse.bpmn2.Property in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMarshallProcessVariables.
@Test
public void testMarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
Definitions definitions = new DefinitionsConverter(diagram.getGraph()).toDefinitions();
assertNotNull(definitions);
List<RootElement> rootElements = definitions.getRootElements();
assertNotNull(rootElements);
assertItemExists(rootElements, "_employeeItem", "java.lang.String");
assertItemExists(rootElements, "_reasonItem", "java.lang.String");
assertItemExists(rootElements, "_performanceItem", "java.lang.String");
Process process = getProcess(definitions);
assertNotNull(process);
List<Property> properties = process.getProperties();
assertNotNull(properties);
assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
use of org.eclipse.bpmn2.Property in project alisa-examples by osate.
the class ModelVerifications method getVoltage.
public static double getVoltage(final FeatureInstance fi) {
Property voltage = GetProperties.lookupPropertyDefinition(fi, "Physical", "Voltage");
UnitLiteral volts = GetProperties.findUnitLiteral(voltage, "V");
return PropertyUtils.getScaledNumberValue(fi, voltage, volts, 0.0);
}
use of org.eclipse.bpmn2.Property in project polymap4-core by Polymap4.
the class StyleCompositeSerializer method handle.
protected <V> Iterable<RuleModifier<V, S>> handle(Property<StylePropertyValue<V>> prop) {
StylePropertyValue<V> styleProp = prop.get();
// no value -> nothing to modify
if (styleProp == null || styleProp instanceof NoValue) {
return singletonList(new NoValueRuleModifier());
} else // ConstantValue
if (styleProp instanceof ConstantValue) {
Expression expr = ff.literal(((ConstantValue) styleProp).value());
return singletonList(new SimpleRuleModifier(expr));
} else // AttributeValue
if (styleProp instanceof AttributeValue) {
String attributeName = (String) ((AttributeValue) styleProp).attributeName.get();
Expression expr = ff.property(attributeName);
return singletonList(new SimpleRuleModifier(expr));
} else // FilterMappedValues
if (styleProp instanceof FilterMappedValues) {
List<Mapped<Filter, Object>> values = ((FilterMappedValues) styleProp).values();
return FluentIterable.from(values).transform(mapped -> new SimpleRuleModifier(ff.literal(mapped.value()), mapped.key()));
} else // ScaleMappedValues
if (styleProp instanceof ScaleMappedValues) {
List<Mapped<ScaleRange, Object>> values = ((ScaleMappedValues) styleProp).values();
return FluentIterable.from(values).transform(mapped -> new SimpleRuleModifier(ff.literal(mapped.value()), mapped.key().min.get(), mapped.key().max.get()));
} else {
throw new RuntimeException("Unhandled StylePropertyValue type: " + styleProp.getClass().getSimpleName());
}
}
Aggregations