private static Object evaluate(Assignment assignment) { return ((FormalExpression) assignment.getFrom()).getBody(); }
private Assignment assignment(String from, String to) { Assignment assignment = bpmn2.createAssignment(); FormalExpression fromExpr = bpmn2.createFormalExpression(); fromExpr.setBody(asCData(from)); assignment.setFrom(fromExpr); FormalExpression toExpr = bpmn2.createFormalExpression(); toExpr.setBody(to); assignment.setTo(toExpr); return assignment; }
if (da.getTargetRef() != null && da.getTargetRef().getId().equals(foundInput.getId())) { foundGroupIdAssociation = true; ((FormalExpression) da.getAssignment().get(0).getFrom()).setBody(wrapInCDATABlock(properties.get("groupid"))); FormalExpression groupToExpression = Bpmn2Factory.eINSTANCE.createFormalExpression(); groupToExpression.setBody(foundInput.getId()); a.setFrom(groupFromExpression); a.setTo(groupToExpression); dia.getAssignment().add(a); task.getDataInputAssociations().add(dia); if (da.getTargetRef() != null && da.getTargetRef().getId().equals(foundInput.getId())) { foundSkippableAssociation = true; ((FormalExpression) da.getAssignment().get(0).getFrom()).setBody(skippableStr); FormalExpression skippableToExpression = Bpmn2Factory.eINSTANCE.createFormalExpression(); skippableToExpression.setBody(foundInput.getId()); a.setFrom(skippableFromExpression); a.setTo(skippableToExpression); dia.getAssignment().add(a); task.getDataInputAssociations().add(dia); if (da.getTargetRef() != null && da.getTargetRef().getId().equals(foundInput.getId())) { foundCommentAssociation = true; ((FormalExpression) da.getAssignment().get(0).getFrom()).setBody(wrapInCDATABlock(properties.get("subject"))); FormalExpression commentToExpression = Bpmn2Factory.eINSTANCE.createFormalExpression(); commentToExpression.setBody(foundInput.getId()); a.setFrom(commentFromExpression);
@Test public void urlDecodeConstants() throws UnsupportedEncodingException { String expected = "<<<#!!!#>>>"; String encoded = URLEncoder.encode(expected, "UTF-8"); VariableDeclaration variable = new VariableDeclaration("ID", "Object"); InputConstant c = new InputConstant("PARENT", variable, encoded); Assignment assignment = c.getDataInputAssociation().getAssignment().get(0); FormalExpression to = (FormalExpression) assignment.getTo(); assertEquals(Ids.dataInput("PARENT", "ID"), to.getBody()); FormalExpression from = (FormalExpression) assignment.getFrom(); assertEquals(asCData(expected), from.getBody()); } }
"").replaceAll(" ", "")); taskNameAssignment.setFrom(fromExp); FormalExpression toExp = Bpmn2Factory.eINSTANCE.createFormalExpression(); toExp.setBody(task.getId() + "_TaskNameInputX"); taskNameAssignment.setTo(toExp); taskNameDataInputAssociation.getAssignment().add(taskNameAssignment); task.getDataInputAssociations().add(taskNameDataInputAssociation); a.setFrom(fromExpression); a.setTo(toExpression); dia.getAssignment().add(a); task.getDataInputAssociations().add(dia); if (da.getAssignment() != null && da.getAssignment().size() > 0) { Assignment a = da.getAssignment().get(0); if (((FormalExpression) a.getTo()).getBody().equals(task.getId() + "_TaskNameInputX")) { if (!haveTaskNameInput) { haveTaskNameInput = true;
if (dia.getTargetRef() != null && dia.getTargetRef().getId().equals(din.getId()) && dia.getAssignment() != null && !dia.getAssignment().isEmpty() && dia.getAssignment().get(0).getFrom() != null) { properties.put("taskname", ((FormalExpression) dia.getAssignment().get(0).getFrom()).getBody()); foundTaskName = true; if (datain.getAssignment().get(0).getFrom() instanceof FormalExpression) { String associationValue = ((FormalExpression) datain.getAssignment().get(0).getFrom()).getBody(); if (associationValue == null) { associationValue = ""; associationValue); if (task instanceof UserTask && datain.getAssignment().get(0).getTo() != null && ((FormalExpression) datain.getAssignment().get(0).getTo()).getBody() != null && datain.getAssignment().get(0).getFrom() != null ) { String toBody = ((FormalExpression) datain.getAssignment().get(0).getTo()).getBody(); String fromBody = ((FormalExpression) datain.getAssignment().get(0).getFrom()).getBody(); if (toBody != null) { if (groupDataInput != null && toBody.equals(groupDataInput.getId())) {
public DataInputAssociation getDataInputAssociation() { DataInputAssociation dataInputAssociation = bpmn2.createDataInputAssociation(); Assignment assignment = bpmn2.createAssignment(); String id = getDataInput().getId(); FormalExpression toExpr = bpmn2.createFormalExpression(); toExpr.setBody(id); assignment.setTo(toExpr); FormalExpression fromExpr = bpmn2.createFormalExpression(); // this should be handled **outside** the marshallers! String decodedExpression = decode(expression); String cdataExpression = asCData(decodedExpression); fromExpr.setBody(cdataExpression); assignment.setFrom(fromExpr); dataInputAssociation .getAssignment().add(assignment); dataInputAssociation .setTargetRef(getDataInput()); return dataInputAssociation; }
private String readTaskFormName(DataInputAssociation inputAssociation) { Optional<FormalExpression> optional = inputAssociation.getAssignment() .stream() .filter(assignment -> assignment.getFrom() != null && assignment.getFrom() instanceof FormalExpression) .map(assignment -> (FormalExpression)assignment.getFrom()) .findAny(); if(optional.isPresent()) { return Parser.xmlParser().parseInput(optional.get().getBody(), "").toString(); } return ""; }
InputAssignmentReader(Assignment assignment, String targetName) { FormalExpression from = (FormalExpression) assignment.getFrom(); String body = from.getBody(); String encodedBody = encode(body); this.associationDeclaration = new AssociationDeclaration( AssociationDeclaration.Direction.Input, AssociationDeclaration.Type.FromTo, encodedBody, targetName); }
public String findAssignment(List<DataInputAssociation> associations, String varName) { return associations.stream() .filter(a -> { DataInput in = (DataInput) a.getTargetRef(); return in.getName().equals(varName); }) .map(a -> { Assignment assignment = a.getAssignment().get(0); FormalExpression expr = (FormalExpression) assignment.getFrom(); return expr.getBody(); }) .findFirst() .get(); } }
@Test public void urlEncodeConstants() throws UnsupportedEncodingException { String decoded = "<<<#!!!#>>>"; String expected = URLEncoder.encode(decoded, "UTF-8"); Assignment assignment = bpmn2.createAssignment(); FormalExpression from = bpmn2.createFormalExpression(); from.setBody(decoded); FormalExpression to = bpmn2.createFormalExpression(); to.setBody("ID"); assignment.setFrom(from); assignment.setTo(to); InputAssignmentReader iar = new InputAssignmentReader(assignment, "ID"); AssociationDeclaration associationDeclaration = iar.getAssociationDeclaration(); assertEquals(AssociationDeclaration.Type.FromTo, associationDeclaration.getType()); assertEquals(expected, associationDeclaration.getSource()); } }