Reputation: 3019
To get the companyHome I use this method:
public NodeRef getCompanyHome()
{
return nodeLocatorService.getNode("companyhome", null, null);
}
the spring confuguration is the following:
<bean id="TransformationHandler" class="org.alfresco.transformation.TransformationHandler" parent="baseJavaDelegate" lazy-init="default" autowire="default" dependency-check="default">
<property name="nodeService" ref="NodeService" />
<property name="nodeLocatorService" ref="nodeLocatorService" />
</bean>
when I loop throug the children of a NodeRef I see the root folder structure(I'm not shure I name them right in english): data dictionary, guest catalog, users home space, published and so on. But as I run my code in the workflow I need to get files I attached to the workflow. What is the way to do this? I'm interested in the configuring workflow model too because in the tutorial there are few information about the bpm:package and the bpm:packageItemActionGroup
is the only place where the bpm:package can be found. Is this enough:
<type name="scwf:activitiApprovedNotification">
<parent>bpm:workflowTask</parent>
<overrides>
<property name="bpm:packageItemActionGroup">
<default>read_package_item_actions</default>
</property>
</overrides>
</type>
? So there are two questions: What is the way to access the content of bpm:package and is the provided above part of workflow model enough for this purpose?
Upvotes: 0
Views: 1121
Reputation: 2203
The one way to access content of workflow is to write webscript for it. Here is an example of java backed webscript to access some workflow details:
workflowdetails.get.json.ftl
<webscript>
<shortname>Get Workflow Task</shortname>
<description>Retrieves all the workflow tasks which are in progress</description>
<url>/workflow/details</url>
<format default="json"/>
<authentication>user</authentication>
<transaction allow="readonly">required</transaction>
<lifecycle>public_api</lifecycle>
</webscript>
WorkflowActiveTaskDetails.java
package util.workflow;
public class WorkflowActiveTaskDetails extends DeclarativeWebScript {
ServiceRegistry serviceRegistry;
public void setServiceRegistry(ServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
}
protected Map<String, Object> executeImpl(WebScriptRequest arg0, Status status, Cache cache) {
WorkflowService workflowService = serviceRegistry.getWorkflowService();
NodeService nodeService=serviceRegistry.getNodeService();
JSONArray arr = new JSONArray();
Map<String, Object> model = new HashMap<String, Object>();
WorkflowTaskQuery tasksQuery = new WorkflowTaskQuery();
tasksQuery.setTaskState(WorkflowTaskState.IN_PROGRESS);
tasksQuery.setActive(true);
List<WorkflowTask> tasks = workflowService.queryTasks(tasksQuery);
for(int i=0;i<tasks.size();i++) {
JSONObject jsondata = new JSONObject();
Map<QName, Serializable> properties= tasks.get(i).getProperties();
try {
Date dueDate=tasks.get(i).getPath().getInstance().getDueDate();
jsondata.put("duedate", dueDate!=null?dueDate.toString().split(" ")[0]:"");
jsondata.put("priority",tasks.get(i).getPath().getInstance().getPriority()); jsondata.put("initiator",nodeService.getProperty(tasks.get(i).getPath().getInstance().getInitiator(),ContentModel.PROP_FIRSTNAME));
jsondata.put("description",properties.get(WorkflowModel.PROP_DESCRIPTION));
arr.put(jsondata);
} catch (JSONException e) {
e.printStackTrace();
}
}
model.put("data", arr);
return model;
}
}
workflowdetails.get.json.ftl
{data}
Bean configuration:
<bean id="webscript.util.workflow.WorkflowActiveTaskDetails.get" class="util.workflow.WorkflowActiveTaskDetails" parent="webscript">
<property name="serviceRegistry" ref="ServiceRegistry" />
</bean>
And hit this URL: http://localhost:8080/alfresco/service/workflow/details
You will get response like
[{"initiator":"test5","description":"Test Workflow","priority":2,"duedate":"2014-03-29"},{"initiator":"test5","description":"Test Workflow2","priority":1,"duedate":"2014-03-31"}]
Upvotes: 2