From 1ee6547fc4fc816d00a20d1c440e111c3e518462 Mon Sep 17 00:00:00 2001 From: David Caruana Date: Thu, 7 Dec 2006 00:05:28 +0000 Subject: [PATCH] WCM submit (for approval) workflow. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4540 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/bootstrap-context.xml | 7 +- config/alfresco/core-services-context.xml | 5 +- .../workflow/submit_processdefinition.xml | 170 +++++++++++++++--- .../workflow/wcm-workflow-messages.properties | 38 ++++ config/alfresco/workflow/wcmWorkflowModel.xml | 138 ++++++++++++++ .../repo/avm/wf/AVMSubmitPackageHandler.java | 55 ++---- .../alfresco/repo/dictionary/TestModel.java | 2 +- .../repo/workflow/WorkflowInterpreter.java | 18 +- 8 files changed, 353 insertions(+), 80 deletions(-) create mode 100644 config/alfresco/workflow/wcm-workflow-messages.properties create mode 100644 config/alfresco/workflow/wcmWorkflowModel.xml diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 89573f29d7..dabd6e7dc9 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -169,6 +169,7 @@ false + jbpm alfresco/workflow/submit_processdefinition.xml text/xml @@ -178,12 +179,14 @@ - alfresco/workflow/workflowModel.xml + alfresco/workflow/workflowModel.xml + alfresco/workflow/wcmWorkflowModel.xml - alfresco/workflow/workflow-messages + alfresco/workflow/workflow-messages + alfresco/workflow/wcm-workflow-messages diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index 69b1f5aeb3..f7165b5cde 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -59,7 +59,7 @@ - @@ -69,7 +69,6 @@ - @@ -80,11 +79,11 @@ - +--> - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #{wcmwf_reviewType == "Parallel"} + + + + + + + + + + + + #{wcmwf_approveCnt < wcmwf_reviewerCnt} + + + + + + + + + + + + + + + + + + + + + + + + + + #{bpm_assignees} + reviewer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #{wcmwf_approveCnt == wcmwf_reviewerCnt} + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/workflow/wcm-workflow-messages.properties b/config/alfresco/workflow/wcm-workflow-messages.properties new file mode 100644 index 0000000000..08204815fd --- /dev/null +++ b/config/alfresco/workflow/wcm-workflow-messages.properties @@ -0,0 +1,38 @@ +# Display labels for out-of-the-box WCM Content-oriented Workflows + +# +# Submit Workflow +# + +wcmwf_submit.workflow.title=Web Site Submission +wcmwf_submit.workflow.description=Submit changes for approval +wcmwf_submit.node.serialreview.transition.reject.title=Reject +wcmwf_submit.node.serialreview.transition.reject.description=Reject +wcmwf_submit.node.serialreview.transition.approve.title=Approve +wcmwf_submit.node.serialreview.transition.approve.description=Approve +wcmwf_submit.node.parallelreview.transition.reject.title=Reject +wcmwf_submit.node.parallelreview.transition.reject.description=Reject +wcmwf_submit.node.parallelreview.transition.approve.title=Approve +wcmwf_submit.node.parallelreview.transition.approve.description=Approve + +# Submit Task Definitions + +wcmwf_workflowmodel.type.wcmwf_submitReviewTask.title=Web Site Submission +wcmwf_workflowmodel.type.wcmwf_submitReviewTask.description=Submit changes for approval +wcmwf_workflowmodel.type.wcmwf_reviewTask.title=Review +wcmwf_workflowmodel.type.wcmwf_reviewTask.description=Review Documents to approve or reject them +wcmwf_workflowmodel.type.wcmwf_rejectedTask.title=Rejected +wcmwf_workflowmodel.type.wcmwf_rejectedTask.description=Rejected +wcmwf_workflowmodel.type.wcmwf_approvedTask.title=Approved +wcmwf_workflowmodel.type.wcmwf_approvedTask.description=Approved + +wcmwf_workflowmodel.property.wcmwf_reviewType.title=Type of Review +wcmwf_workflowmodel.property.wcmwf_reviewType.description=Serial or parallel review +wcmwf_workflowmodel.property.wcmwf_fromPath.title=Source Folder Path +wcmwf_workflowmodel.property.wcmwf_fromPath.description=Folder Path where items have been submitted from +wcmwf_workflowmodel.property.wcmwf_label.title=Submission Label +wcmwf_workflowmodel.property.wcmwf_label.description=Label associated with the submission +wcmwf_workflowmodel.property.wcmwf_reviewerCnt.title=Total Reviewed +wcmwf_workflowmodel.property.wcmwf_reviewerCnt.description=Count of people who reviewed +wcmwf_workflowmodel.property.wcmwf_approveCnt.title=Total Approved +wcmwf_workflowmodel.property.wcmwf_approveCnt.description=Count of people who approved diff --git a/config/alfresco/workflow/wcmWorkflowModel.xml b/config/alfresco/workflow/wcmWorkflowModel.xml new file mode 100644 index 0000000000..a51aca795c --- /dev/null +++ b/config/alfresco/workflow/wcmWorkflowModel.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + Serial + Parallel + + + + + + + + + + + + + + + + + bpm:startTask + + + + bpm:workflowTask + + + + + + + + wcmwf:startTask + + wcmwf:reviewType + wcmwf:submission + bpm:assignees + + + + + wcmwf:workflowTask + + wcmwf:submission + + + wcmwf:reviewType + bpm:assignees + + + + + wcmwf:workflowTask + + wcmwf:reviewType + bpm:assignees + wcmwf:reviewStats + + + + + wcmwf:workflowTask + + wcmwf:reviewType + bpm:assignees + wcmwf:reviewStats + + + + + + + + + + + Source Folder Path + Folder where items have been submitted from + d:text + true + + + Snapshot Label + d:text + true + + + + + + + + Serial or Parallel Review + d:text + true + Serial + + + + + + + + + + + Reviewer Count + d:int + true + + + Approver Count + d:int + true + + + + + + + \ No newline at end of file diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java index 3f43bd30f0..ab44f08ac8 100644 --- a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java +++ b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java @@ -11,7 +11,6 @@ import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.util.Pair; import org.jbpm.graph.exe.ExecutionContext; import org.springframework.beans.factory.BeanFactory; @@ -31,10 +30,6 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements */ private AVMSyncService fAVMSyncService; - /** - * The NodeService reference. - */ - private NodeService fNodeService; /** * Initialize service references. @@ -45,7 +40,6 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements { fAVMService = (AVMService)factory.getBean("AVMService"); fAVMSyncService = (AVMSyncService)factory.getBean("AVMSyncService"); - fNodeService = (NodeService)factory.getBean("NodeService"); } /** @@ -54,48 +48,25 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements */ public void execute(ExecutionContext executionContext) throws Exception { + // TODO: Allow submit parameters to passed into this action handler + // rather than pulling directly from execution context + NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef(); Pair pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg); + // submit the package changes + String description = (String)executionContext.getContextInstance().getVariable("bpm_workflowDescription"); + String tag = (String)executionContext.getContextInstance().getVariable("wcmwf_label"); AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond()); String targetPath = pkgDesc.getIndirection(); List diff = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null); - fAVMSyncService.update(diff, null, true, true, false, false, null, null); + fAVMSyncService.update(diff, null, true, true, false, false, tag, description); - String from = (String)executionContext.getContextInstance().getVariable("wf_from"); - fAVMSyncService.flatten(from, targetPath); - -// List children = fNodeService.getChildAssocs(pkg); -// List diffs = new ArrayList(); -// Map storesHit = new HashMap(); -// for (ChildAssociationRef child : children) -// { -// NodeRef childRef = child.getChildRef(); -// if (!fNodeService.hasAspect(childRef, ContentModel.ASPECT_REFERENCES_NODE)) -// { -// throw new AVMSyncException("Package node does not have cm:referencesnode."); -// } -// NodeRef toSubmit = (NodeRef)fNodeService.getProperty(childRef, ContentModel.PROP_NODE_REF); -// Pair versionPath = AVMNodeConverter.ToAVMVersionPath(toSubmit); -// String avmPath = versionPath.getSecond(); -// String [] storePath = avmPath.split(":"); -// String websiteName = fAVMService.getStoreProperty(storePath[0], -// QName.createQName(null, ".website.name")). -// getStringValue(); -// String stagingName = websiteName + "-staging"; -// AVMDifference diff = -// new AVMDifference(-1, avmPath, -// -1, stagingName + ":" + storePath[1], -// AVMDifference.NEWER); -// diffs.add(diff); -// storesHit.put(storePath[0], stagingName); -// } -// // TODO fix update comments if needed. -// fAVMSyncService.update(diffs, true, true, false, false, null, null); -// for (Map.Entry entry : storesHit.entrySet()) -// { -// fAVMSyncService.flatten(entry.getKey() + ":/appBase", -// entry.getValue() + ":/appBase"); -// } + // flatten source folder where changes were submitted from + String from = (String)executionContext.getContextInstance().getVariable("wcmwf_fromPath"); + if (from != null && from.length() > 0) + { + fAVMSyncService.flatten(from, targetPath); + } } } diff --git a/source/java/org/alfresco/repo/dictionary/TestModel.java b/source/java/org/alfresco/repo/dictionary/TestModel.java index 240be4ce7b..838eda82a2 100644 --- a/source/java/org/alfresco/repo/dictionary/TestModel.java +++ b/source/java/org/alfresco/repo/dictionary/TestModel.java @@ -42,9 +42,9 @@ public class TestModel bootstrapModels.add("alfresco/model/dictionaryModel.xml"); bootstrapModels.add("alfresco/model/systemModel.xml"); bootstrapModels.add("alfresco/model/contentModel.xml"); + bootstrapModels.add("alfresco/model/wcmModel.xml"); bootstrapModels.add("alfresco/model/applicationModel.xml"); bootstrapModels.add("alfresco/model/bpmModel.xml"); - bootstrapModels.add("alfresco/workflow/workflowModel.xml"); // include models specified on command line for (String arg: args) diff --git a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java index c30639dbce..df4459388e 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java @@ -187,7 +187,7 @@ public class WorkflowInterpreter try { String line = fIn.readLine(); - if (line.equals("exit")) + if (line.equals("exit") || line.equals("quit")) { return; } @@ -347,13 +347,17 @@ public class WorkflowInterpreter return "Syntax Error. Workflow Id not specified.\n"; } List paths = workflowService.getWorkflowPaths(workflowId); + if (paths.size() == 0) + { + out.println("no further transitions"); + } for (WorkflowPath path : paths) { out.println("path: " + path.id + " , node: " + path.node.name + " , active: " + path.active); List tasks = workflowService.getTasksForWorkflowPath(path.id); for (WorkflowTask task : tasks) { - out.println(" task id: " + task.id + " , name: " + task.name + " , properties: " + task.properties.size()); + out.println(" task id: " + task.id + " , name: " + task.name + ", title: " + task.title + " , desc: " + task.description + " , properties: " + task.properties.size()); } for (WorkflowTransition transition : path.node.transitions) { @@ -564,8 +568,9 @@ public class WorkflowInterpreter return "Workflow definition not selected.\n"; } WorkflowPath path = workflowService.startWorkflow(currentWorkflowDef.id, params); - out.println("started workflow id: " + path.instance.id + ", path: " + path.id + " , node: " + path.node.name + " , def: " + path.instance.definition.title); + out.println("started workflow id: " + path.instance.id + " , def: " + path.instance.definition.title); currentPath = path; + out.print(interpretCommand("show transitions")); } else if (command[0].equals("update")) @@ -619,7 +624,8 @@ public class WorkflowInterpreter return "Syntax Error.\n"; } WorkflowPath path = workflowService.signal(command[1], (command.length == 3) ? command[2] : null); - out.println("signal sent - path id: " + path.id + " , node: " + path.node.name); + out.println("signal sent - path id: " + path.id); + out.print(interpretCommand("show transitions")); } else if (command[0].equals("end")) @@ -631,7 +637,8 @@ public class WorkflowInterpreter if (command[1].equals("task")) { WorkflowTask task = workflowService.endTask(command[2], (command.length == 4) ? command[3] : null); - out.println("signal sent - path id: " + task.path.id + " , node: " + task.path.node.name); + out.println("signal sent - path id: " + task.path.id); + out.print(interpretCommand("show transitions")); } else if (command[1].equals("workflow")) { @@ -642,6 +649,7 @@ public class WorkflowInterpreter } workflowService.cancelWorkflow(workflowId); out.println("cancelled workflow" + workflowId); + out.print(interpretCommand("show transitions")); } else {