Optional<String> getStringValue(Task element) { for (DataInputAssociation din : element.getDataInputAssociations()) { DataInput targetRef = (DataInput) (din.getTargetRef()); if (targetRef.getName().equalsIgnoreCase(name) && !din.getAssignment().isEmpty()) { Assignment assignment = din.getAssignment().get(0); return Optional.of(evaluate(assignment).toString()); } } return Optional.empty(); }
private DataInputAssociation associationOf(Assignment assignment, DataInput dataInput) { DataInputAssociation dataInputAssociation = bpmn2.createDataInputAssociation(); dataInputAssociation.getAssignment() .add(assignment); dataInputAssociation .setTargetRef(dataInput); 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 ""; }
public static InputAssignmentReader fromAssociation(DataInputAssociation in) { List<ItemAwareElement> sourceList = in.getSourceRef(); List<Assignment> assignmentList = in.getAssignment(); String targetName = ((DataInput) in.getTargetRef()).getName(); if (isReservedIdentifier(targetName)) { return null; } if (!sourceList.isEmpty()) { return new InputAssignmentReader(sourceList.get(0), targetName); } else if (!assignmentList.isEmpty()) { return new InputAssignmentReader(assignmentList.get(0), targetName); } else { throw new IllegalArgumentException("Cannot find SourceRef or Assignment for Target " + targetName); } }
if (datain.getAssignment() != null && datain.getAssignment().size() > 0) { isAssignment = true; if (datain.getAssignment().get(0).getFrom() instanceof FormalExpression) { String associationValue = ((FormalExpression) datain.getAssignment().get(0).getFrom()).getBody(); if (associationValue == null) { associationValue = "";
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(); } }
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); for (Iterator<DataInputAssociation> itr = dataInputAssociations.iterator(); itr.hasNext(); ) { DataInputAssociation da = itr.next(); 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) {
a.setFrom(fromExpression); a.setTo(toExpression); dia.getAssignment().add(a); event.getDataInputAssociation().add(dia); } else if (assignment.contains("->")) {
a.setFrom(fromExpression); a.setTo(toExpression); dia.getAssignment().add(a); callActivity.getDataInputAssociations().add(dia);
for (DataInputAssociation dia : taskDataInputAssociations) { 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() != null && datain.getAssignment().size() > 0) { isAssignment = 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())) {
List<Assignment> assignments = inputAssociation.getAssignment();
a.setFrom(fromExpression); a.setTo(toExpression); dia.getAssignment().add(a); sp.getDataInputAssociations().add(dia);
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; }
if (da.getTargetRef() != null && da.getTargetRef().getId().equals(foundInput.getId())) { foundGroupIdAssociation = true; ((FormalExpression) da.getAssignment().get(0).getFrom()).setBody(wrapInCDATABlock(properties.get("groupid"))); 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); 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"))); a.setFrom(commentFromExpression); a.setTo(commentToExpression); dia.getAssignment().add(a); task.getDataInputAssociations().add(dia); if (da.getTargetRef() != null && da.getTargetRef().getId().equals(foundInput.getId())) { foundDescriptionAssociation = true;
@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()); } }