Search in sources :

Example 11 with Property

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);
        }
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) Auditing(org.eclipse.bpmn2.Auditing) FloatingParameterType(bpsim.FloatingParameterType) EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) EObject(org.eclipse.emf.ecore.EObject) ControlParameters(bpsim.ControlParameters) Parameter(bpsim.Parameter) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData) Monitoring(org.eclipse.bpmn2.Monitoring)

Example 12 with Property

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"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) RootElement(org.eclipse.bpmn2.RootElement) JBPMBpmn2ResourceImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceImpl) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Process(org.eclipse.bpmn2.Process) Matchers.anyString(org.mockito.Matchers.anyString) Property(org.eclipse.bpmn2.Property) Test(org.junit.Test)

Example 13 with Property

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"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) RootElement(org.eclipse.bpmn2.RootElement) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Property(org.eclipse.bpmn2.Property) Test(org.junit.Test)

Example 14 with Property

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);
}
Also used : UnitLiteral(org.osate.aadl2.UnitLiteral) Property(org.osate.aadl2.Property)

Example 15 with Property

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());
    }
}
Also used : Mapped(org.polymap.core.style.model.feature.MappedValues.Mapped) Configurable(org.polymap.core.runtime.config.Configurable) StylePropertyValue(org.polymap.core.style.model.StylePropertyValue) ScaleRangeFilter(org.polymap.core.style.model.feature.ScaleRangeFilter) Mandatory(org.polymap.core.runtime.config.Mandatory) StyleComposite(org.polymap.core.style.model.StyleComposite) Function(java.util.function.Function) StyleFactory(org.geotools.styling.StyleFactory) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) Style(org.polymap.core.style.model.Style) ScaleMappedValues(org.polymap.core.style.model.feature.ScaleMappedValues) Config2(org.polymap.core.runtime.config.Config2) FluentIterable(com.google.common.collect.FluentIterable) FilterFactory2(org.opengis.filter.FilterFactory2) ConstantValue(org.polymap.core.style.model.feature.ConstantValue) FilterMappedValues(org.polymap.core.style.model.feature.FilterMappedValues) ScaleRange(org.polymap.core.style.model.feature.ScaleMappedValues.ScaleRange) Symbolizer(org.geotools.styling.Symbolizer) Cloner(com.rits.cloning.Cloner) ConstantFilter(org.polymap.core.style.model.feature.ConstantFilter) Property(org.polymap.model2.Property) Expression(org.opengis.filter.expression.Expression) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) List(java.util.List) NoValue(org.polymap.core.style.model.feature.NoValue) Rule(org.geotools.styling.Rule) AttributeValue(org.polymap.core.style.model.feature.AttributeValue) Filter(org.opengis.filter.Filter) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) Context(org.polymap.core.style.serialize.FeatureStyleSerializer.Context) FilterStyleProperty(org.polymap.core.style.model.feature.FilterStyleProperty) AttributeValue(org.polymap.core.style.model.feature.AttributeValue) Mapped(org.polymap.core.style.model.feature.MappedValues.Mapped) ScaleMappedValues(org.polymap.core.style.model.feature.ScaleMappedValues) NoValue(org.polymap.core.style.model.feature.NoValue) Expression(org.opengis.filter.expression.Expression) ScaleRangeFilter(org.polymap.core.style.model.feature.ScaleRangeFilter) ConstantFilter(org.polymap.core.style.model.feature.ConstantFilter) Filter(org.opengis.filter.Filter) FilterMappedValues(org.polymap.core.style.model.feature.FilterMappedValues) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) ConstantValue(org.polymap.core.style.model.feature.ConstantValue)

Aggregations

Property (org.eclipse.bpmn2.Property)9 Property (io.atlasmap.v2.Property)7 ArrayList (java.util.ArrayList)7 Process (org.eclipse.bpmn2.Process)7 RootElement (org.eclipse.bpmn2.RootElement)6 Properties (io.atlasmap.v2.Properties)5 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)5 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)5 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)5 List (java.util.List)4 DataInput (org.eclipse.bpmn2.DataInput)4 DataOutput (org.eclipse.bpmn2.DataOutput)4 FormalExpression (org.eclipse.bpmn2.FormalExpression)4 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)3 Definitions (org.eclipse.bpmn2.Definitions)3 FlowElement (org.eclipse.bpmn2.FlowElement)3 SubProcess (org.eclipse.bpmn2.SubProcess)3 Test (org.junit.Test)3 FloatingParameterType (bpsim.FloatingParameterType)2 Parameter (bpsim.Parameter)2