Search in sources :

Example 1 with FormalExpression

use of org.eclipse.bpmn2.FormalExpression in project kie-wb-common by kiegroup.

the class UserTaskPropertyWriter method setActors.

public void setActors(Actors actors) {
    for (String actor : fromActorString(actors.getValue())) {
        PotentialOwner potentialOwner = bpmn2.createPotentialOwner();
        potentialOwner.setId(UUID.randomUUID().toString());
        FormalExpression formalExpression = bpmn2.createFormalExpression();
        formalExpression.setBody(actor);
        ResourceAssignmentExpression resourceAssignmentExpression = bpmn2.createResourceAssignmentExpression();
        resourceAssignmentExpression.setExpression(formalExpression);
        potentialOwner.setResourceAssignmentExpression(resourceAssignmentExpression);
        task.getResources().add(potentialOwner);
    }
}
Also used : ResourceAssignmentExpression(org.eclipse.bpmn2.ResourceAssignmentExpression) PotentialOwner(org.eclipse.bpmn2.PotentialOwner) FormalExpression(org.eclipse.bpmn2.FormalExpression)

Example 2 with FormalExpression

use of org.eclipse.bpmn2.FormalExpression in project kie-wb-common by kiegroup.

the class SequenceFlowConverter method toFlowElement.

public SequenceFlowPropertyWriter toFlowElement(Edge<?, ?> edge, ElementContainer process) {
    ViewConnector<SequenceFlow> content = (ViewConnector<SequenceFlow>) edge.getContent();
    SequenceFlow definition = content.getDefinition();
    org.eclipse.bpmn2.SequenceFlow seq = bpmn2.createSequenceFlow();
    SequenceFlowPropertyWriter p = propertyWriterFactory.of(seq);
    seq.setId(edge.getUUID());
    BasePropertyWriter pSrc = process.getChildElement(edge.getSourceNode().getUUID());
    BasePropertyWriter pTgt = process.getChildElement(edge.getTargetNode().getUUID());
    p.setSource(pSrc);
    p.setTarget(pTgt);
    seq.setId(edge.getUUID());
    seq.setName(definition.getGeneral().getName().getValue());
    p.setConnection(content);
    SequenceFlowExecutionSet executionSet = definition.getExecutionSet();
    ScriptTypeValue scriptTypeValue = executionSet.getConditionExpression().getValue();
    String language = scriptTypeValue.getLanguage();
    String script = scriptTypeValue.getScript();
    if (script != null) {
        FormalExpression formalExpression = bpmn2.createFormalExpression();
        String uri = Scripts.scriptLanguageToUri(language);
        formalExpression.setLanguage(uri);
        formalExpression.setBody(asCData(script));
        seq.setConditionExpression(formalExpression);
    }
    process.addChildElement(p);
    process.addChildEdge(p.getEdge());
    return p;
}
Also used : BasePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) SequenceFlowPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SequenceFlowPropertyWriter) SequenceFlowExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet) FormalExpression(org.eclipse.bpmn2.FormalExpression) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)

Example 3 with FormalExpression

use of org.eclipse.bpmn2.FormalExpression in project kie-wb-common by kiegroup.

the class UserTaskPropertyReader method getActors.

public Actors getActors() {
    // get the user task actors
    List<ResourceRole> roles = task.getResources();
    List<String> users = new ArrayList<>();
    for (ResourceRole role : roles) {
        if (role instanceof PotentialOwner) {
            FormalExpression fe = (FormalExpression) role.getResourceAssignmentExpression().getExpression();
            users.add(fe.getBody());
        }
    }
    return new Actors(renderActors(users));
}
Also used : ResourceRole(org.eclipse.bpmn2.ResourceRole) ArrayList(java.util.ArrayList) PotentialOwner(org.eclipse.bpmn2.PotentialOwner) Actors(org.kie.workbench.common.stunner.bpmn.definition.property.assignee.Actors) FormalExpression(org.eclipse.bpmn2.FormalExpression)

Example 4 with FormalExpression

use of org.eclipse.bpmn2.FormalExpression in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method setAdHocSubProcessProperties.

private void setAdHocSubProcessProperties(final AdHocSubProcess subProcess, final Map<String, Object> properties) {
    if (subProcess.getOrdering().equals(AdHocOrdering.PARALLEL)) {
        properties.put(ADHOCORDERING, "Parallel");
    } else if (subProcess.getOrdering().equals(AdHocOrdering.SEQUENTIAL)) {
        properties.put(ADHOCORDERING, "Sequential");
    } else {
        // default to parallel
        properties.put(ADHOCORDERING, "Parallel");
    }
    if (subProcess.getCompletionCondition() != null) {
        final FormalExpression expression = (FormalExpression) subProcess.getCompletionCondition();
        final String language = Utils.getScriptLanguage(expression.getLanguage());
        final String script = expression.getBody().replaceAll("\n", "\\\\n");
        final ScriptTypeValue value = new ScriptTypeValue(language, script);
        properties.put(ADHOCCOMPLETIONCONDITION, new ScriptTypeTypeSerializer().serialize(value));
    }
}
Also used : ScriptTypeTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeTypeSerializer) FormalExpression(org.eclipse.bpmn2.FormalExpression) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)

Example 5 with FormalExpression

use of org.eclipse.bpmn2.FormalExpression in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method marshallDataInputAssociations.

private void marshallDataInputAssociations(StringBuilder associationBuff, List<DataInputAssociation> inputAssociations) {
    if (inputAssociations != null) {
        for (DataInputAssociation datain : inputAssociations) {
            String lhsAssociation = "";
            if (datain.getSourceRef() != null && datain.getSourceRef().size() > 0) {
                if (datain.getTransformation() != null && datain.getTransformation().getBody() != null) {
                    lhsAssociation = datain.getTransformation().getBody();
                } else {
                    lhsAssociation = datain.getSourceRef().get(0).getId();
                }
            }
            String rhsAssociation = "";
            if (datain.getTargetRef() != null) {
                rhsAssociation = ((DataInput) datain.getTargetRef()).getName();
            }
            // boolean isBiDirectional = false;
            boolean isAssignment = false;
            if (datain.getAssignment() != null && datain.getAssignment().size() > 0) {
                isAssignment = true;
            }
            if (isAssignment) {
                // only know how to deal with formal expressions
                if (datain.getAssignment().get(0).getFrom() instanceof FormalExpression) {
                    String associationValue = ((FormalExpression) datain.getAssignment().get(0).getFrom()).getBody();
                    if (associationValue == null) {
                        associationValue = "";
                    }
                    String replacer = encodeAssociationValue(associationValue);
                    associationBuff.append("[din]" + rhsAssociation).append("=").append(replacer);
                    associationBuff.append(",");
                }
            } else {
                if (lhsAssociation != null && lhsAssociation.length() > 0) {
                    associationBuff.append("[din]" + lhsAssociation).append("->").append(rhsAssociation);
                    associationBuff.append(",");
                }
            }
        }
    }
}
Also used : FormalExpression(org.eclipse.bpmn2.FormalExpression) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation)

Aggregations

FormalExpression (org.eclipse.bpmn2.FormalExpression)24 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)11 ArrayList (java.util.ArrayList)10 DataInput (org.eclipse.bpmn2.DataInput)10 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)9 DataOutput (org.eclipse.bpmn2.DataOutput)8 List (java.util.List)7 Assignment (org.eclipse.bpmn2.Assignment)7 InputSet (org.eclipse.bpmn2.InputSet)7 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)7 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)6 ScriptTypeValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)6 Parameter (bpsim.Parameter)5 RootElement (org.eclipse.bpmn2.RootElement)5 NormalDistributionType (bpsim.NormalDistributionType)4 PoissonDistributionType (bpsim.PoissonDistributionType)4 TimeParameters (bpsim.TimeParameters)4 UniformDistributionType (bpsim.UniformDistributionType)4 Entry (java.util.Map.Entry)4 InputOutputSpecification (org.eclipse.bpmn2.InputOutputSpecification)4