在我的文件中 管理 </跨度> 过程中经常需要提供一些额外的文档(例如评论列表,差异列表,一些屏幕截图等)。
这些附加文件将是&lt;&LT; /类型&GT;…&lt; aspect name =“mswf:attachments”&gt; &LT;协会&GT; &LT; 协会 </跨度> NAME = “MSWF:包” &GT; &lt;信源&GT; &LT;强制性&GT假LT; /强制性&GT; &lt;很多
可以将具有NodeRefs的一组字符串传递给以下WebScript,例如:
public class WorkflowAttachmentsManipulator extends DeclarativeWebScript { private static final String WORKFLOW_MODEL_URI = "..."; private WorkflowService workflowService; @Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { Map<String, Object> model = new HashMap<>(); String taskId = req.getParameter("taskId"); String addedItems = req.getParameter("addedItems"); String oldValue = ""; WorkflowTask workflowTask = workflowService.getTaskById(taskId); Map<QName, Serializable> taskProperties = workflowTask.getProperties(); Iterator taskIterator = taskProperties.entrySet().iterator(); while(taskIterator.hasNext()) { Map.Entry taskPair = (Map.Entry)taskIterator.next(); Object key = taskPair.getKey(); if(key != null && key.toString().equalsIgnoreCase("{" + WORKFLOW_MODEL_URI + "}package")) { if(taskPair.getValue() != null) { oldValue = taskPair.getValue().toString(); if(!oldValue.equals("[]")) { oldValue = oldValue.replaceAll("[\\[\\]]", ""); addedItems = "[" + oldValue + "," + addedItems + "]"; } else { if(addedItems.indexOf(",") > 0) { addedItems = "[" + addedItems + "]"; } } } taskProperties.replace( QName.createQName(WORKFLOW_MODEL_URI, "package"), oldValue, addedItems); workflowService.updateTask(workflowTask.getId(), taskProperties, null, null); break; } } ... } public WorkflowService getWorkflowService() { return workflowService; } public void setWorkflowService(WorkflowService workflowService) { this.workflowService = workflowService; } }
此代码会覆盖特定任务的附件。
其他文件需要与文档管理过程中涉及的文件区分开来。例如,它可以完成如下:
/** * Returns items that have been added to the current value * * @method getAddedItems * @return {array} */ getAddedItems: function ObjectFinder_getAddedItems() { var addedItems = [], currentItems = Alfresco.util.arrayToObject(this.options.currentValue.split(",")); var attachments = []; for (var item in this.selectedItems) { if (this.selectedItems.hasOwnProperty(item)) { if (!(item in currentItems)) { // modified for differentiation if (this.options.displayMode == "items") { attachments.push(item); } else { addedItems.push(item); } } } } ... // call to the WebScript with attachments // modified for merge return addedItems.concat(attachments); },
为了在过程变量中保存重写的附件,有必要定义该过滤器的监听器 complete 事件。
complete
此外,通过使用此技术,可以通过链从一个任务到另一个任务(通过更改)“传递”文件:
听众 complete 事件:
public class TaskCompleteListener implements TaskListener { @Override public void notify(DelegateTask delegateTask) { DelegateExecution execution = delegateTask.getExecution(); execution.setVariable("mswf_package", delegateTask.getVariable("mswf_package")); } }
听众 create 事件:
create
public class TaskCreateListener implements TaskListener { @Override public void notify(DelegateTask delegateTask) { DelegateExecution execution = delegateTask.getExecution(); delegateTask.setVariable("mswf_package", execution.getVariable("mswf_package")); } }
这解决了我的问题。