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);
}
}
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;
}
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));
}
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));
}
}
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(",");
}
}
}
}
}
Aggregations