为了获得公司,我使用这种方法:
public NodeRef getCompanyHome()
{
return nodeLocatorService.getNode("companyhome", null, null);
}
弹簧配置如下:
<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>
当我循环访问NodeRef的孩子时,我看到根文件夹结构(我不是因为我用英语命名它们):数据字典,访客目录,用户家庭空间,已发布等等。但是当我在工作流程中运行代码时,我需要获取附加到工作流程的文件。这样做的方法是什么?我也对配置工作流模型感兴趣,因为在tutorial中有关于bpm:package的信息很少,bpm:packageItemActionGroup
是唯一可以找到bpm:包的地方。这够了吗?
<type name="scwf:activitiApprovedNotification">
<parent>bpm:workflowTask</parent>
<overrides>
<property name="bpm:packageItemActionGroup">
<default>read_package_item_actions</default>
</property>
</overrides>
</type>
? 所以有两个问题:访问bpm:package的内容的方法是什么?是否为此目的提供了工作流模型的上述部分?
答案 0 :(得分:2)
访问工作流内容的一种方法是为其编写webscript。 以下是java支持的webscript访问某些工作流程详细信息的示例:
<强> 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配置:
<bean id="webscript.util.workflow.WorkflowActiveTaskDetails.get" class="util.workflow.WorkflowActiveTaskDetails" parent="webscript">
<property name="serviceRegistry" ref="ServiceRegistry" />
</bean>
点击此网址: http://localhost:8080/alfresco/service/workflow/details
你会得到像
这样的回复[{"initiator":"test5","description":"Test Workflow","priority":2,"duedate":"2014-03-29"},{"initiator":"test5","description":"Test Workflow2","priority":1,"duedate":"2014-03-31"}]