Workflow Service: add support for task comment.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5763 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2007-05-23 16:15:07 +00:00
parent 0b8d2fc6d6
commit 1c46628575
3 changed files with 47 additions and 9 deletions

View File

@@ -135,7 +135,9 @@
<!-- --> <!-- -->
<!-- Task Notes --> <!-- Task Notes -->
<!-- --> <!-- -->
<!-- Note: Implemented via cm:content property : see 'fm:post' --> <property name="bpm:comment">
<type>d:text</type>
</property>
</properties> </properties>
@@ -180,7 +182,8 @@
<!-- Task Outcome --> <!-- Task Outcome -->
<property name="bpm:outcome"> <property name="bpm:outcome">
<type>d:text</type><!-- Transition id --> <!-- NOTE: Transition id -->
<type>d:text</type>
</property> </property>
<!-- Items within package marked as complete --> <!-- Items within package marked as complete -->
@@ -394,12 +397,6 @@
</properties> </properties>
<!-- Commentary -->
<!-- Note: Implement tracking of comments via fm:discussable aspect -->
<!-- Note: Haven't made this aspect mandatory as this would force creation -->
<!-- of forum folder against each package, even if there aren't any -->
<!-- comments -->
</aspect> </aspect>
</aspects> </aspects>

View File

@@ -48,6 +48,7 @@ public interface WorkflowModel
static final QName PROP_STATUS = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "status"); static final QName PROP_STATUS = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "status");
static final QName PROP_PERCENT_COMPLETE = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "percentComplete"); static final QName PROP_PERCENT_COMPLETE = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "percentComplete");
static final QName PROP_COMPLETED_ITEMS = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "completedItems"); static final QName PROP_COMPLETED_ITEMS = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "completedItems");
static final QName PROP_COMMENT = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "comment");
static final QName ASSOC_POOLED_ACTORS = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "pooledActors"); static final QName ASSOC_POOLED_ACTORS = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "pooledActors");
// workflow task contstants // workflow task contstants

View File

@@ -31,8 +31,8 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
@@ -96,6 +96,7 @@ import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.Node; import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.def.Transition; import org.jbpm.graph.def.Transition;
import org.jbpm.graph.exe.Comment;
import org.jbpm.graph.exe.ExecutionContext; import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance; import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token; import org.jbpm.graph.exe.Token;
@@ -1809,6 +1810,14 @@ public class JBPMEngine extends BPMEngine
properties.put(ContentModel.PROP_CREATED, instance.getCreate()); properties.put(ContentModel.PROP_CREATED, instance.getCreate());
properties.put(ContentModel.PROP_OWNER, instance.getActorId()); properties.put(ContentModel.PROP_OWNER, instance.getActorId());
// map jBPM comments
// NOTE: Only use first comment in list
List<Comment> comments = instance.getComments();
if (comments != null && comments.size() > 0)
{
properties.put(WorkflowModel.PROP_COMMENT, comments.get(0).getMessage());
}
// map jBPM task instance collections to associations // map jBPM task instance collections to associations
Set pooledActors = instance.getPooledActors(); Set pooledActors = instance.getPooledActors();
if (pooledActors != null) if (pooledActors != null)
@@ -1918,6 +1927,37 @@ public class JBPMEngine extends BPMEngine
instance.setPriority((Integer)value); instance.setPriority((Integer)value);
continue; continue;
} }
else if (key.equals(WorkflowModel.PROP_COMMENT))
{
if (!(value instanceof String))
{
throw new WorkflowException("Task comment '" + value + "' is invalid");
}
// NOTE: Only use first comment in list
final List<Comment> comments = instance.getComments();
if (comments != null && comments.size() > 0)
{
// remove existing comments
// TODO: jBPM does not provide assistance here
jbpmTemplate.execute(new JbpmCallback()
{
public Object doInJbpm(JbpmContext context)
{
Session session = context.getSession();
for (Comment comment : comments)
{
comment.getToken().getComments().remove(comment);
session.delete(comment);
}
comments.clear();
return null;
}
});
}
instance.addComment((String)value);
continue;
}
else if (key.equals(ContentModel.PROP_OWNER)) else if (key.equals(ContentModel.PROP_OWNER))
{ {
if (value != null && !(value instanceof String)) if (value != null && !(value instanceof String))