cancel
Showing results for 
Search instead for 
Did you mean: 

Files wont move after finish workflow.

e-no91
Champ in-the-making
Champ in-the-making
This is my review_pooled_processdefinition.xml that I've edited

<?xml version="1.0" encoding="UTF-8"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:reviewpooled">

    <swimlane name="initiator" />

    <start-state name="start">
        <task name="wf:submitGroupReviewTask" swimlane="initiator" />
        <transition name="" to="review" />
    </start-state>

    <swimlane name="reviewer">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <pooledactors>#{bpm_groupAssignee}</pooledactors>
        </assignment>   
    </swimlane>

    <task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewer">
            <event type="task-create">
                <script>
                   if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                   if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                </script>
            </event>
            <event type="task-end">
               <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                  <script>
                     <variable name="bpm_assignee" access="write"/>
                     <expression>
                        if (taskInstance.actorId != null)
                           people.getPerson(taskInstance.actorId);
                        else
                           person;
                     </expression>
                  </script>
               </action>
            </event>
        </task>
        <transition name="approve" to="approved">
    

            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<runas>admin</runas>

                   <script>

                      var dest = companyhome.childByNamePath("Site/test-script/documentLibrary/kepada");

                      bpm_context.move(dest);

                   </script>

  </action>

          </transition>
        <transition name="reject" to="rejected"/>
    </task-node>

    <task-node name="rejected">
        <task name="wf:rejectedTask" swimlane="initiator" />
        <transition name="" to="end" />

    </task-node>

    <task-node name="approved">
        <task name="wf:approvedTask" swimlane="initiator" />
        <transition name="" to="end"/>

    </task-node>

    <end-state name="end" />

</process-definition>


And my js file,

function startWorkflow(assigneeGroup)
{
    var workflow = actions.create("start-workflow");
    workflow.parameters.workflowName = "activiti$activitiReviewPooled";
    workflow.parameters["bpm:workflowDescription"] = "Please review " + document.name;
    workflow.parameters["bpm:groupAssignee"] = assigneeGroup;
    var futureDate = new Date();
    futureDate.setDate(futureDate.getDate() + 3);
    workflow.parameters["bpm:workflowDueDate"] = futureDate;
    return workflow.execute(document);
}

function main()
{
   var name = document.name;
   var siteName = document.siteShortName;
  
   if (siteName == null)
   {
      if (logger.isLoggingEnabled())
         logger.log("Did not start workflow as the document named " + name + " is not located within a site.");
        
      return;
   }
  
   var reviewGroup = "GROUP_URUSETIA SEKRETARIAT";

   // make sure the group exists
   var group = people.getGroup(reviewGroup);
   if (group != null)
   {
      if (logger.isLoggingEnabled())
         logger.log("Starting pooled review and approve workflow for document named " + name + " assigned to group " + reviewGroup);

      startWorkflow(group);

      if (logger.isLoggingEnabled())
         logger.log("Started pooled review and approve workflow for document named " + name + " assigned to group " + reviewGroup);
   }
   else if (logger.isLoggingEnabled())
   {
      logger.log("Did not start workflow as the group " + reviewGroup + " could not be found.");
   }
}

main();

I set the js file to run whenever a new file is uploaded and to run in background.

I use the original review_pooled.bpmn20.xml. Both xml files are still in the workflow folder.

I've tried many ways for days but the files still wont move after clicking approve. Moreover, the due date only appears to the assigner..

What am I missing here??
6 REPLIES 6

kaynezhang
World-Class Innovator
World-Class Innovator
You want to move the document that the workflow action on ,you should use  bpm_package.children[0].move(dest);
As I remember if you did not specify a bpm:context parameter ,bpm_context would be setted to the parent of the document that the workflow action on

e-no91
Champ in-the-making
Champ in-the-making
I've changed to that, it still didn't work..

Not sure if this helps, but I'm getting this in my debug
2014-05-06 22:45:37,166  DEBUG [repo.jscript.ScriptLogger] [defaultAsyncAction1] Starting pooled review and approve workflow for document named T - Copy (4).txt assigned to group GROUP_URUSETIA SEKRETARIAT
2014-05-06 22:45:40,272  INFO  [management.subsystems.ChildApplicationContextFactory] [http-apr-8080-exec-3] Starting 'Transformers' subsystem, ID: [Transformers, default]
2014-05-06 22:45:40,942  ERROR [content.transform.TransformerConfigDynamicTransformers] [http-apr-8080-exec-3] Cannot create dynamic transformer transformer.complex.JodConverter.Image as sub transformers could not be found or created ("JodConverter.2Pdf|pdf|complex.PDF.Image").
2014-05-06 22:45:40,942  ERROR [content.transform.TransformerConfigDynamicTransformers] [http-apr-8080-exec-3] Cannot create dynamic transformer transformer.complex.JodConverter.Pdf2swf as sub transformers could not be found or created ("JodConverter.2Pdf|pdf|Pdf2swf").
2014-05-06 22:45:40,942  ERROR [content.transform.TransformerConfigDynamicTransformers] [http-apr-8080-exec-3] Cannot create dynamic transformer transformer.JodConverter.Html2Pdf as sub transformers could not be found or created ("JodConverter|odt|JodConverter").
2014-05-06 22:45:40,942  ERROR [content.transform.TransformerConfigDynamicTransformers] [http-apr-8080-exec-3] Cannot create dynamic transformer transformer.JodConverter.2Pdf as sub transformers could not be found or created ("JodConverter|JodConverter.Html2Pdf").
2014-05-06 22:45:40,942  ERROR [content.transform.TransformerConfigDynamicTransformers] [http-apr-8080-exec-3] Cannot create dynamic transformer transformer.complex.JodConverter.PdfBox as sub transformers could not be found or created ("JodConverter.2Pdf|pdf|PdfBox").
2014-05-06 22:45:41,598  INFO  [management.subsystems.ChildApplicationContextFactory] [http-apr-8080-exec-3] Startup of 'Transformers' subsystem, ID: [Transformers, default] complete
2014-05-06 22:45:45,761  DEBUG [repo.jscript.ScriptLogger] [defaultAsyncAction1] Started pooled review and approve workflow for document named T - Copy (4).txt assigned to group GROUP_URUSETIA SEKRETARIAT
2014-05-06 22:46:19,112  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.get.js - NodeRef: alfresco://company/home Query:  +@cm\:modified:[2014\-4\-29T00\:00\:00.000 TO 2014\-5\-6T23\:59\:59.999] +@cm\:modifier:"us1" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
2014-05-06 22:46:19,375  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.get.js - query results: 0
2014-05-06 22:46:19,375  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.get.js - totalRecords: 0
2014-05-06 22:46:24,818  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] Generating form for item:
2014-05-06 22:46:24,819  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1]    kind = task
2014-05-06 22:46:24,819  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1]    id = activiti$2047
2014-05-06 22:46:24,820  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] fields = message,taskOwner,bpmSmiley Tongueriority,bpm:dueDate,bpm:taskId,bpm:status,packageItems,bpm:comment,wf:reviewOutcome
2014-05-06 22:46:25,527  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] formModel = {"formData": {"prop_wf_reviewOutcome": "Reject", "prop_bpm_taskId": "2047", "prop_bpm_packageActionGroup": "", "assoc_packageItems": "workspace:\/\/SpacesStore\/07ee9291-4972-4c90-8f1c-b9443dec97eb", "prop_bpm_priority": 2, "prop_bpm_status": "Not Yet Started", "prop_bpm_packageItemActionGroup": "edit_package_item_actions", "prop_message": "Please review T - Copy (4).txt"}, "item": "api\/task-instances\/activiti$2047", "type": "wf:activitiReviewTask", "submissionUrl": "\/api\/task\/activiti%242047\/formprocessor", "fields": "[Lorg.alfresco.repo.forms.FieldDefinition;@c83901"}
2014-05-06 22:46:32,113  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-8] #items = 1, #results = 1
2014-05-06 22:46:38,138  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-7] json form submission for item:
2014-05-06 22:46:38,141  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-7]    kind = task
2014-05-06 22:46:38,141  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-7]    id = activiti$2047
2014-05-06 22:46:46,995  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-8] doclist.get.js - NodeRef: alfresco://company/home Query:  +@cm\:modified:[2014\-4\-29T00\:00\:00.000 TO 2014\-5\-6T23\:59\:59.999] +@cm\:modifier:"us1" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
2014-05-06 22:46:47,044  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-8] doclist.get.js - query results: 0
2014-05-06 22:46:47,045  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-8] doclist.get.js - totalRecords: 0
2014-05-06 22:47:04,371  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-7] doclist.get.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary//*" +@cm\:modified:[2014\-4\-29T00\:00\:00.000 TO 2014\-5\-6T23\:59\:59.999] +@cm\:modifier:"us1" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
2014-05-06 22:47:04,939  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-7] doclist.get.js - query results: 0
2014-05-06 22:47:04,940  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-7] doclist.get.js - totalRecords: 0
2014-05-06 22:47:50,063  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-6] doclist.lib.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary/*" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost"
2014-05-06 22:47:50,092  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-6] doclist.lib.js - query results: 2
2014-05-06 22:47:50,094  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-6] doclist.lib.js - totalRecords: 2
2014-05-06 22:48:07,727  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-10] doclist.lib.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary/cm:kepada/*" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost"
2014-05-06 22:48:07,744  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-10] doclist.lib.js - query results: 0
2014-05-06 22:48:07,744  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-10] doclist.lib.js - totalRecords: 0
2014-05-07 03:08:47,360  WARN  [solr.tracker.CoreTracker] [SolrTrackerScheduler_Worker-3] Tracking communication timed out.
2014-05-07 03:08:47,374  WARN  [scripts.solr.AlfrescoModelsDiff] [http-bio-8443-exec-10] Unable to fetch model changes from /alfresco/service/api/solr/modelsdiff
2014-05-07 03:08:47,402  WARN  [scripts.solr.AlfrescoModelsDiff] [http-bio-8443-exec-2] Unable to fetch model changes from /alfresco/service/api/solr/modelsdiff
2014-05-07 03:08:47,393  WARN  [solr.tracker.CoreTracker] [SolrTrackerScheduler_Worker-2] Tracking communication timed out.
2014-05-07 03:11:23,714  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4] doclist.get.js - NodeRef: alfresco://company/home Query:  +@cm\:modified:[2014\-4\-30T00\:00\:00.000 TO 2014\-5\-7T23\:59\:59.999] +@cm\:modifier:"kus1" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
2014-05-07 03:11:24,202  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4] doclist.get.js - query results: 1
2014-05-07 03:11:24,206  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4] doclist.get.js - totalRecords: 1
2014-05-07 03:11:37,229  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] Generating form for item:
2014-05-07 03:11:37,230  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1]    kind = task
2014-05-07 03:11:37,230  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1]    id = activiti$1961
2014-05-07 03:11:37,231  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] fields = message,taskOwner,bpmSmiley Tongueriority,bpm:dueDate,bpm:taskId,bpm:status,packageItems,bpm:comment,transitions
2014-05-07 03:11:37,426  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] formModel = {"formData": {"assoc_packageItems": "workspace:\/\/SpacesStore\/2e624035-b16c-4a30-815e-1b21bedf46ad", "prop_bpm_taskId": "1961", "prop_bpm_priority": 2, "prop_bpm_packageItemActionGroup": "read_package_item_actions", "prop_transitions": "Next|Task Done", "prop_bpm_status": "Not Yet Started", "prop_bpm_dueDate": "2014-05-09T21:54:02.943+08:00", "prop_message": "The document was reviewed and approved.", "prop_taskOwner": "kus1|KUS1|kus1", "prop_bpm_packageActionGroup": ""}, "item": "api\/task-instances\/activiti$1961", "type": "wf:approvedTask", "submissionUrl": "\/api\/task\/activiti%241961\/formprocessor", "fields": "[Lorg.alfresco.repo.forms.FieldDefinition;@17c0fa4"}
2014-05-07 03:11:44,012  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-9] #items = 1, #results = 1
2014-05-07 03:12:19,457  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4] json form submission for item:
2014-05-07 03:12:19,458  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4]    kind = task
2014-05-07 03:12:19,459  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4]    id = activiti$1961
2014-05-07 03:12:35,428  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.get.js - NodeRef: alfresco://company/home Query:  +@cm\:modified:[2014\-4\-30T00\:00\:00.000 TO 2014\-5\-7T23\:59\:59.999] +@cm\:modifier:"kus1" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
2014-05-07 03:12:35,477  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.get.js - query results: 1
2014-05-07 03:12:35,480  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.get.js - totalRecords: 1
2014-05-07 03:12:54,788  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] doclist.get.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary//*" +@cm\:modified:[2014\-4\-30T00\:00\:00.000 TO 2014\-5\-7T23\:59\:59.999] +@cm\:modifier:"kus1" +TYPE:"cm:content" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost" +(TYPE:"content" OR TYPE:"app:filelink" OR TYPE:"folder")
2014-05-07 03:12:54,833  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] doclist.get.js - query results: 1
2014-05-07 03:12:54,837  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-1] doclist.get.js - totalRecords: 1
2014-05-07 03:13:24,472  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-2] doclist.lib.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary/*" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost"
2014-05-07 03:13:24,540  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-2] doclist.lib.js - query results: 2
2014-05-07 03:13:24,542  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-2] doclist.lib.js - totalRecords: 2
2014-05-07 03:15:36,287  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4] doclist.lib.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary/cm:dari/*" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost"
2014-05-07 03:15:36,353  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4] doclist.lib.js - query results: 2
2014-05-07 03:15:36,354  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-4] doclist.lib.js - totalRecords: 2
2014-05-07 03:15:41,254  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-2] doclist.lib.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary/*" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost"
2014-05-07 03:15:41,278  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-2] doclist.lib.js - query results: 2
2014-05-07 03:15:41,279  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-2] doclist.lib.js - totalRecords: 2
2014-05-07 03:15:43,382  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.lib.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary/cm:kepada/*" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost"
2014-05-07 03:15:43,408  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.lib.js - query results: 0
2014-05-07 03:15:43,408  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-11] doclist.lib.js - totalRecords: 0
2014-05-07 03:15:46,729  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-10] doclist.lib.js - NodeRef: null Query: +PATH:"/app:company_home/st:sites/cm:test-script/cm:documentLibrary/*" -TYPE:"cm:systemfolder" -TYPE:"fm:forums" -TYPE:"fm:forum" -TYPE:"fm:topic" -TYPE:"fmSmiley Tongueost"
2014-05-07 03:15:46,766  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-10] doclist.lib.js - query results: 2
2014-05-07 03:15:46,768  DEBUG [repo.jscript.ScriptLogger] [http-apr-8080-exec-10] doclist.lib.js - totalRecords: 2

kaynezhang
World-Class Innovator
World-Class Innovator
You can add some log information to make sure you javascript is excuted correctly

logger.log("****");//valide if your javascript is entered as expected
var dest = companyhome.childByNamePath("Site/test-script/documentLibrary/kepada");
logger.log(dest);// make sure your destination node exists
logger.log(bpm_package.children[0]);//check your node to move.
bpm_package.children[0].move(dest);

e-no91
Champ in-the-making
Champ in-the-making
Actually I have added logger.log before var dest, even at every script statement in processdefinition.xml, but I can't find it anywhere inside the log. Do you know how to resolve this?

kaynezhang
World-Class Innovator
World-Class Innovator
Maybe you didn't configure log4j propertly,you can look to http://docs.alfresco.com/4.2/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Ftasks%2Flog-levels-set...
Or you can try to use below code,it will print log information on console,just like using System.out.println("*****");

logger.getSystem().out("*****");

yaseeralfresco
Champ in-the-making
Champ in-the-making
The example i am using is Estimate and added a below script.
There are no errors workflow is executed fine .But file is not moved to folder
Thanks in advance

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="estimate" name="estimate" isExecutable="true">
    <extensionElements>
      <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
        <activiti:field name="script">
          <activiti:string><![CDATA[execution.setVariable('wf_managementGroup', groups.getGroup('Management').getFullName());]]></activiti:string>
        </activiti:field>
      </activiti:executionListener>
    </extensionElements>
    <startEvent id="start" name="Start" activiti:formKey="wf:estimate"></startEvent>
    <userTask id="assignEstimateTask" name="Assign Estimate Task" activiti:candidateGroups="${wf_managementGroup}" activiti:formKey="wf:assignEstimateTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('bpm_assignee', task.getVariable('bpm_assignee'));
execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('wf_manager', person);
execution.setVariable('bpm_dueDate', task.dueDate);
execution.setVariable('bpm_priority', task.priority);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="estimateTask" name="Estimate Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:estimateTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_dueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_priority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="reviewEstimate" name="Review Estimate" activiti:assignee="${wf_manager.properties.userName}" activiti:formKey="wf:reviewEstimate">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
      <activiti:field name="runAs"><activiti:string>admin</activiti:string></activiti:field>
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
         execution.setVariable('wf:workflowOutcome', task.getVariable('wf_reviewOutcome'));
execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
]]></activiti:string>
         <activiti:string>   
             <![CDATA[if (bpm_package != null &amp;&amp; bpm_package.children != null) {
             var i = 0;
             for (i = 0; i &lt; bpm_package.children.length; i++) {
            var document = bpm_package.children;
            document.addAspect("wf:workflowOutcomeAspect");
            document.properties["wf_reviewOutcome"] = "Approve";
            document.save();
             }
         }
                  ]]> </activiti:string>
         

<activiti:string><![CDATA[logger.log("Hello, World!");]]></activiti:string>

<activiti:string><![CDATA[execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));]]></activiti:string>   
          </activiti:field>
        </activiti:taskListener>
      
      
      </extensionElements>
    </userTask>
    <exclusiveGateway id="reviewDecision" name="Review Decision"></exclusiveGateway>
    <userTask id="estimateApproved" name="Estimate Approved" activiti:assignee="${initiator.exists() ? initiator.properties.userName : 'admin'}" activiti:formKey="wf:estimateApproved">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <endEvent id="end" name="End"></endEvent>
   

    <sequenceFlow id="flow1" sourceRef="start" targetRef="assignEstimateTask"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="assignEstimateTask" targetRef="estimateTask"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="estimateTask" targetRef="reviewEstimate"></sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="reviewEstimate" targetRef="reviewDecision"></sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="reviewDecision" targetRef="estimateApproved">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome
            == 'Approve'}]]></conditionExpression>
    </sequenceFlow>
   
    <sequenceFlow id="flow7" sourceRef="estimateApproved" targetRef="end"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="reviewDecision" targetRef="estimateTask"></sequenceFlow>
   <!–<sequenceFlow id="flow9" sourceRef="reviewDecision" targetRef="alfrescoScripttask1"></sequenceFlow>–>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_estimate">
    <bpmndi:BPMNPlane bpmnElement="estimate" id="BPMNPlane_estimate">
      <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
        <omgdc:Bounds height="35.0" width="35.0" x="30.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="assignEstimateTask" id="BPMNShape_assignEstimateTask">
        <omgdc:Bounds height="55.0" width="105.0" x="105.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="estimateTask" id="BPMNShape_estimateTask">
        <omgdc:Bounds height="55.0" width="105.0" x="250.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="reviewEstimate" id="BPMNShape_reviewEstimate">
        <omgdc:Bounds height="55.0" width="105.0" x="395.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="reviewDecision" id="BPMNShape_reviewDecision">
        <omgdc:Bounds height="40.0" width="40.0" x="540.0" y="197.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="estimateApproved" id="BPMNShape_estimateApproved">
        <omgdc:Bounds height="55.0" width="105.0" x="620.0" y="137.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
        <omgdc:Bounds height="35.0" width="35.0" x="765.0" y="147.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="65.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="105.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="210.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="355.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="395.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="500.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="540.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="560.0" y="197.0"></omgdi:waypoint>
        <omgdi:waypoint x="560.0" y="164.0"></omgdi:waypoint>
        <omgdi:waypoint x="620.0" y="164.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="725.0" y="164.0"></omgdi:waypoint>
        <omgdi:waypoint x="765.0" y="164.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="560.0" y="237.0"></omgdi:waypoint>
        <omgdi:waypoint x="447.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="302.0" y="245.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>