Accessing package attributes in workflow
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2013 11:00 AM
I am using Alfresco Community 4.2.d and I have a workflow where I use a service task to initially setup users and process variables. I have a need to get property information from the document that is stored in the workflow package. My question is how do I do this through my service task class? I see how I can use the WorkflowService to get the workflow package contents, but that method requires a taskId and I am having difficulty getting access to the current service task id through the DelegateExecution object that my service task has access to.
Any help on this is greatly appreciated.
Thanks,
- Shannon
Any help on this is greatly appreciated.
Thanks,
- Shannon
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2013 02:54 AM
The delegateExecution contains a property "package" (or something similar, there is a constant on WorkflowModel or BpmModel for this). This is just a plain node-ref and contains references to all the documents that are attached. If you look at the source of the WorklfowServiceImpl you see this clearly, you can just use the node service to fetch child-assocs and fetch properties of the document afterwards (I presume you're not using AVM, this has a different lookup-method):
Another alternative is to use a script-task, this has single-lmine access to document-properties in the packages, using an expression…
private List<NodeRef> getRepositoryPackageContents(NodeRef workflowPackage)
{
List<NodeRef> contents = new ArrayList<NodeRef>();
// get existing workflow package items
List<ChildAssociationRef> packageAssocs = protectedNodeService.getChildAssocs(workflowPackage);
for (ChildAssociationRef assoc : packageAssocs)
{
// create our Node representation from the NodeRef
NodeRef nodeRef = assoc.getChildRef();
QName assocType = assoc.getTypeQName();
if (!protectedNodeService.exists(nodeRef))
{
if (logger.isDebugEnabled())
logger.debug("Ignoring " + nodeRef + " as it has been removed from the repository");
}
else if (!ContentModel.ASSOC_CONTAINS.equals(assocType) && !WorkflowModel.ASSOC_PACKAGE_CONTAINS.equals(assocType))
{
if (logger.isDebugEnabled())
logger.debug("Ignoring " + nodeRef + " as it has an invalid association type: "+assocType);
}
else
{
if (checkTypeIsInDataDictionary(nodeRef))
{
contents.add(nodeRef);
}
}
}
return contents;
}
Another alternative is to use a script-task, this has single-lmine access to document-properties in the packages, using an expression…
