Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed attachment mecanism to return a map, and adapted it for jbpm5…

…, instead of an String array.
  • Loading branch information...
commit d4b9d9e5912fe1d135ff95f8bad60142c7d3623f 1 parent 3def4c2
Demian authored
View
2  ...i-example/bin/src/main/resources/uihelper/definitions/formDefinitions/default.config.json
@@ -16,7 +16,7 @@
},
{
"name":"Input",
- "sourceExpresion":"#{in:0}"
+ "sourceExpresion":"#{in:Content}"
}
],
"outputFields": [
View
2  ...eb-ui-example/src/main/resources/uihelper/definitions/formDefinitions/default.config.json
@@ -16,7 +16,7 @@
},
{
"name":"Input",
- "sourceExpresion":"#{in:0}"
+ "sourceExpresion":"#{in:Content}"
}
],
"outputFields": [
View
4 .../java/com/wordpress/salaboy/smarttasks/formbuilder/expression/MVELExpressionResolver.java
@@ -40,8 +40,8 @@ else if(context.equals("task")){
}
//TODO check this "in". This is not an MVEL expression to be evaluated, so it should not be here.
else if(context.equals("in")){
- if (metaTask.getInputs() != null && metaTask.getInputs().length>=Integer.parseInt(realExpression)) {
- return metaTask.getInputs()[Integer.parseInt(realExpression)];
+ if (metaTask.getInputs() != null) {
+ return metaTask.getInputs().get(realExpression);
}
return "";
}
View
21 ...ain/java/com/wordpress/salaboy/smarttasks/formbuilder/impl/SmartTasksTaskFormBuilder.java
@@ -1,7 +1,6 @@
package com.wordpress.salaboy.smarttasks.formbuilder.impl;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -10,7 +9,6 @@
import org.example.ws_ht.api.TAttachment;
import org.example.ws_ht.api.TAttachmentInfo;
import org.example.ws_ht.api.wsdl.IllegalArgumentFault;
-import org.jbpm.task.Content;
import com.wordpress.salaboy.api.HumanTaskService;
import com.wordpress.salaboy.smarttasks.formbuilder.api.TaskFormBuilder;
@@ -89,7 +87,7 @@ public SmartTasksTaskFormBuilder(BuilderConfiguration configuration,
MetaTask myTask = MetaTaskDecoratorService.getInstance().decorate(
"base", humanTaskService.getTaskInfo(this.taskId));
// TODO, see if we can put this in a decorator.
- String[] inputs = this.getTaskInputFields(taskId);
+ Map<String, Object> inputs = this.getMapTaskInputFields(taskId);
myTask.setInputs(inputs);
return new SmartTasksTaskDataSet(taskFormDefinition, myTask)
.getTaskInputs();
@@ -112,7 +110,7 @@ public SmartTasksTaskFormBuilder(BuilderConfiguration configuration,
* the task id to search.
* @return the attachments.
*/
- private String[] getTaskInputFields(String taskId) {
+ private Map<String, Object> getMapTaskInputFields(String taskId) {
try {
List<TAttachmentInfo> attachmentsInfo = humanTaskService
.getAttachmentInfos(taskId);
@@ -122,15 +120,14 @@ public SmartTasksTaskFormBuilder(BuilderConfiguration configuration,
Object attachmentValue = attachment.getValue();
//TODO check how to define an universal way for this attachment!!
- if (attachmentValue instanceof String[]) {
- return (String[]) attachmentValue;
+ if (attachmentValue instanceof Map) {
+ return (Map<String, Object>) attachmentValue;
}
- else if (attachmentValue instanceof String) {
- String[] inputs = new String[1];
- inputs[0] = (String) attachmentValue;
- return inputs;
+ else {
+ Map<String, Object> newMap = new HashMap<String, Object>();
+ newMap.put("Content", attachmentValue);
+ return newMap;
}
- return new String[0];
} catch (Exception e) {
Logger.getLogger(SmartTasksTaskFormBuilder.class.getName())
.log(Level.SEVERE, "Could not obtain task input.", e);
View
30 ...ain/java/com/wordpress/salaboy/smarttasks/jbpm5wrapper/JBPM5AttachmentContentAdapter.java
@@ -3,6 +3,8 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
+import java.util.HashMap;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -11,15 +13,35 @@
import com.wordpress.salaboy.api.TAttachmentAdapter;
public class JBPM5AttachmentContentAdapter implements
- TAttachmentAdapter<String[], Content> {
- public String[] adapt(Content content) {
+ TAttachmentAdapter<Map<String, Object>, Content> {
+
+ /**
+ * This will be used as default key for the getAttachment method map return,
+ * it does not come a map from jbpm5 attachment.
+ */
+ public static final String defaultAttachmentKey = "Content";
+
+ public Map<String, Object> adapt(Content content) {
ByteArrayInputStream bais = new ByteArrayInputStream(
content.getContent());
ObjectInputStream ois;
try {
ois = new ObjectInputStream(bais);
- String taskinfo = (String) ois.readObject();
- return taskinfo.split(",");
+ Object input = ois.readObject();
+ if (input instanceof Map) {
+ Map mapInput = (Map) input;
+ Map<String, Object> finalMap = new HashMap<String, Object>();
+ for (Object key : mapInput.keySet()) {
+ finalMap.put(key.toString(), mapInput.get(key));
+ }
+ return finalMap;
+ }
+ if (input instanceof String) {
+ Map<String, Object> newMap = new HashMap<String, Object>();
+ newMap.put(defaultAttachmentKey, (String) input);
+ return newMap;
+ }
+ return null;
} catch (IOException e) {
Logger.getLogger(JBPM5HumanTaskServiceOperations.class.getName())
.log(Level.SEVERE, "There was an exception.", e);
View
10 ...s-jbpm5-impl/src/test/java/com/wordpress/salaboy/JBPM5SmartTaskAdapterAttachmentTest.java
@@ -9,10 +9,10 @@
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import org.example.ws_ht.api.TAttachment;
import org.example.ws_ht.api.TAttachmentInfo;
@@ -20,7 +20,6 @@
import org.example.ws_ht.api.TTaskAbstract;
import org.jbpm.process.workitem.wsht.BlockingAddTaskResponseHandler;
import org.jbpm.task.AccessType;
-import org.jbpm.task.Content;
import org.jbpm.task.I18NText;
import org.jbpm.task.OrganizationalEntity;
import org.jbpm.task.PeopleAssignments;
@@ -34,6 +33,7 @@
import com.wordpress.salaboy.api.HumanTaskService;
import com.wordpress.salaboy.api.HumanTaskServiceFactory;
import com.wordpress.salaboy.conf.HumanTaskServiceConfiguration;
+import com.wordpress.salaboy.smarttasks.jbpm5wrapper.JBPM5AttachmentContentAdapter;
import com.wordpress.salaboy.smarttasks.jbpm5wrapper.conf.JBPM5MinaHumanTaskClientConfiguration;
/**
@@ -76,11 +76,11 @@ public void testNewTaskWithContent() throws Exception {
assertEquals(1, attachments.size());
TAttachment attachment = attachments.get(0);
- assertTrue(attachment.getValue() instanceof String[]);
+ assertTrue(attachment.getValue() instanceof Map);
- String content = ((String[]) attachment.getValue())[0];
+ Map<String, Object> content = (Map<String, Object>) attachment.getValue();
- assertEquals("content", content);
+ assertEquals("content", content.get(JBPM5AttachmentContentAdapter.defaultAttachmentKey));
}finally{
if (humanTaskService != null){
humanTaskService.cleanUpService();
View
8 ...sks-metamodel-base/src/main/java/com/wordpress/salaboy/smarttasks/metamodel/MetaTask.java
@@ -4,6 +4,8 @@
*/
package com.wordpress.salaboy.smarttasks.metamodel;
+import java.util.Map;
+
import org.example.ws_ht.api.TTask;
import org.example.ws_ht.api.TTaskAbstract;
@@ -15,7 +17,7 @@
private Long id;
private TTask task;
private TTaskAbstract taskAbstract;
- String[] inputs;
+ private Map<String, Object> inputs;
public MetaTask(TTask task) {
this.task = task;
@@ -52,14 +54,14 @@ public void setTaskAbstract(TTaskAbstract taskAbstract) {
/**
* @return the inputs
*/
- public String[] getInputs() {
+ public Map<String, Object> getInputs() {
return inputs;
}
/**
* @param inputs the inputs to set
*/
- public void setInputs(String[] inputs) {
+ public void setInputs(Map<String, Object> inputs) {
this.inputs = inputs;
}
Please sign in to comment.
Something went wrong with that request. Please try again.