Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
JBPM-4661 - Description property for user tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Tihomir Surdilovic committed May 21, 2015
1 parent 00ac752 commit 1c44a68
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,7 @@ protected void marshallTask(Task task, BPMNPlane plane, JsonGenerator generator,
DataInput groupDataInput = null;
DataInput skippableDataInput = null;
DataInput commentDataInput = null;
DataInput descriptionDataInput = null;
DataInput contentDataInput = null;
DataInput priorityDataInput = null;
DataInput localeDataInput = null;
Expand Down Expand Up @@ -1714,6 +1715,9 @@ protected void marshallTask(Task task, BPMNPlane plane, JsonGenerator generator,
if(dataIn.getName() != null && dataIn.getName().equals("Comment")) {
commentDataInput = dataIn;
}
if(dataIn.getName() != null && dataIn.getName().equals("Description ")) {
descriptionDataInput = dataIn;
}
if(dataIn.getName() != null && dataIn.getName().equals("Content")) {
contentDataInput = dataIn;
}
Expand Down Expand Up @@ -1848,6 +1852,7 @@ protected void marshallTask(Task task, BPMNPlane plane, JsonGenerator generator,
if(!(rhsAssociation.equals("GroupId") ||
rhsAssociation.equals("Skippable") ||
rhsAssociation.equals("Comment") ||
rhsAssociation.equals("Description ") ||
rhsAssociation.equals("Priority") ||
rhsAssociation.equals("Content") ||
rhsAssociation.equals("TaskName") ||
Expand Down Expand Up @@ -1886,6 +1891,11 @@ protected void marshallTask(Task task, BPMNPlane plane, JsonGenerator generator,
((FormalExpression) datain.getAssignment().get(0).getTo()).getBody().equals(commentDataInput.getId())) {
properties.put("comment", ((FormalExpression) datain.getAssignment().get(0).getFrom()).getBody());
}
if (descriptionDataInput != null && datain.getAssignment().get(0).getTo() != null &&
((FormalExpression) datain.getAssignment().get(0).getTo()).getBody() != null &&
((FormalExpression) datain.getAssignment().get(0).getTo()).getBody().equals(descriptionDataInput.getId())) {
properties.put("description", ((FormalExpression) datain.getAssignment().get(0).getFrom()).getBody());
}
if (priorityDataInput != null && datain.getAssignment().get(0).getTo() != null &&
((FormalExpression) datain.getAssignment().get(0).getTo()).getBody() != null &&
((FormalExpression) datain.getAssignment().get(0).getTo()).getBody().equals(priorityDataInput.getId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6071,6 +6071,64 @@ protected void applyUserTaskProperties(UserTask task, Map<String, String> proper
task.getDataInputAssociations().add(dia);
}
}

if(properties.get("description") != null && properties.get("description").length() > 0) {
if(task.getIoSpecification() == null) {
InputOutputSpecification iospec = Bpmn2Factory.eINSTANCE.createInputOutputSpecification();
task.setIoSpecification(iospec);
}
List<DataInput> dataInputs = task.getIoSpecification().getDataInputs();
boolean foundDescriptionInput = false;
DataInput foundInput = null;
for(DataInput din : dataInputs) {
if(din.getName().equals("Description")) {
foundDescriptionInput = true;
foundInput = din;
break;
}
}

if(!foundDescriptionInput) {
DataInput d = Bpmn2Factory.eINSTANCE.createDataInput();
d.setId(task.getId() + "_" + "Description" + "InputX");
d.setName("Description");
task.getIoSpecification().getDataInputs().add(d);
foundInput = d;

if(task.getIoSpecification().getInputSets() == null || task.getIoSpecification().getInputSets().size() < 1) {
InputSet inset = Bpmn2Factory.eINSTANCE.createInputSet();
task.getIoSpecification().getInputSets().add(inset);
}
task.getIoSpecification().getInputSets().get(0).getDataInputRefs().add(d);
}

boolean foundDescriptionAssociation = false;
List<DataInputAssociation> inputAssociations = task.getDataInputAssociations();
for(DataInputAssociation da : inputAssociations) {
if(da.getTargetRef() != null && da.getTargetRef().getId().equals(foundInput.getId())) {
foundDescriptionAssociation = true;
((FormalExpression) da.getAssignment().get(0).getFrom()).setBody(wrapInCDATABlock(properties.get("description")));
}
}

if(!foundDescriptionAssociation) {
DataInputAssociation dia = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
dia.setTargetRef(foundInput);

Assignment a = Bpmn2Factory.eINSTANCE.createAssignment();
FormalExpression descriptionFromExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
descriptionFromExpression.setBody(wrapInCDATABlock(properties.get("description")));

FormalExpression descriptionToExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
descriptionToExpression.setBody(foundInput.getId());

a.setFrom(descriptionFromExpression);
a.setTo(descriptionToExpression);

dia.getAssignment().add(a);
task.getDataInputAssociations().add(dia);
}
}

if(properties.get("priority") != null && properties.get("priority").length() > 0) {
if(task.getIoSpecification() == null) {
Expand Down Expand Up @@ -6527,7 +6585,9 @@ protected void applyUserTaskProperties(UserTask task, Map<String, String> proper
incompleteAssociations.add(dia);
} else if(targetInput.getName().equalsIgnoreCase("Comment") && (properties.get("comment") == null || properties.get("comment").length() == 0)) {
incompleteAssociations.add(dia);
} else if(targetInput.getName().equalsIgnoreCase("Priority") && (properties.get("priority") == null || properties.get("priority").length() == 0)) {
} else if(targetInput.getName().equalsIgnoreCase("Description") && (properties.get("description") == null || properties.get("description").length() == 0)) {
incompleteAssociations.add(dia);
} else if(targetInput.getName().equalsIgnoreCase("Priority") && (properties.get("priority") == null || properties.get("priority").length() == 0)) {
incompleteAssociations.add(dia);
} else if(targetInput.getName().equalsIgnoreCase("Content") && (properties.get("content") == null || properties.get("content").length() == 0)) {
incompleteAssociations.add(dia);
Expand Down Expand Up @@ -6563,7 +6623,9 @@ protected void applyUserTaskProperties(UserTask task, Map<String, String> proper
toRemoveDataInputs.add(din);
} else if(din.getName().equalsIgnoreCase("Comment") && (properties.get("comment") == null || properties.get("comment").length() == 0)) {
toRemoveDataInputs.add(din);
} else if(din.getName().equalsIgnoreCase("Priority") && (properties.get("priority") == null || properties.get("priority").length() == 0)) {
} else if(din.getName().equalsIgnoreCase("Description") && (properties.get("description") == null || properties.get("description").length() == 0)) {
toRemoveDataInputs.add(din);
} else if(din.getName().equalsIgnoreCase("Priority") && (properties.get("priority") == null || properties.get("priority").length() == 0)) {
toRemoveDataInputs.add(din);
} else if(din.getName().equalsIgnoreCase("Content") && (properties.get("content") == null || properties.get("content").length() == 0)) {
toRemoveDataInputs.add(din);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2753,6 +2753,18 @@
"fortasktypes":"None|User",
"extra":true
},
{
"id":"description",
"type":"String",
"title":"Description",
"value":"",
"description":"Description",
"description_ja":"",
"readonly":false,
"optional":true,
"fortasktypes":"None|User",
"extra":true
},
{
"id":"content",
"type":"String",
Expand Down

0 comments on commit 1c44a68

Please sign in to comment.