10-01-2010 08:45 AM
<type name="sdzwf:someTask">
<parent>bpm:workflowTask</parent>
<overrides>
<property name="bpm:packageActionGroup">
<default>add_package_item_actions</default>
</property>
<property name="bpm:packageItemActionGroup">
<default>edit_package_item_actions</default>
</property>
</overrides>
<mandatory-aspects>
<aspect>bpm:assignee</aspect>
</mandatory-aspects>
</type>
<swimlane name="somelane">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<actor>#{bpm_assignee}</actor>
</assignment>
</swimlane>
…
<task-node name="someTask">
<task name="sdzwf:someTask" swimlane="somelane"></task>
<transition to="someTask1" name="Odobri"></transition>
<transition to="someTask2" name="Vrati"></transition>
</task-node>
TransactionService transactionService = AlfrescoServices.getTransactionService();
RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {
NodeRef nrUser = Authentication.getInstance().getUserNodeRef(ticket);
WorkflowTask task = AlfrescoServices.getWorkflowService().getTaskById(taskId);
String pathId = task.path.id;
// update map
Map<QName, Serializable> updateProperties = new HashMap<QName, Serializable>();
// assignee node reference
NodeRef nrAssignee = AlfrescoServices.getPersonService().getPerson(assigneeUsername);
if(nrAssignee != null) {
updateProperties.put(WorkflowModel.ASSOC_ASSIGNEE, nrAssignee);
// update task
AlfrescoServices.getWorkflowService().updateTask(taskId, updateProperties, null, null);
// execute task
WorkflowPath path = AlfrescoServices.getWorkflowService().signal(pathId, transitionId);
}
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
10-04-2010 06:11 AM
WorkflowTask task = AlfrescoServices.getWorkflowService().getTaskById(taskId);
// change assignee property
updateProperties.put(WorkflowModel.ASSOC_ASSIGNEE, nrAssignee);
// update task
AlfrescoServices.getWorkflowService().updateTask(taskId, updateProperties, null, null);
WorkflowTask task2 = AlfrescoServices.getWorkflowService().getTaskById(taskId);
10-04-2010 08:54 AM
org.alfresco.service.cmr.workflow.WorkflowException: Failed to signal transition 'Odobri' from workflow path 'jbpm$40-@'
at org.alfresco.repo.workflow.jbpm.JBPMEngine.signal(JBPMEngine.java:863)
at org.alfresco.repo.workflow.WorkflowServiceImpl.signal(WorkflowServiceImpl.java:317)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:256)
at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:191)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
at $Proxy43.signal(Unknown Source)
at com.inkubator.test.app.workflow.Workflow$3.execute(Workflow.java:384)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:225)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:155)
at com.inkubator.test.app.workflow.Workflow.executeTransition(Workflow.java:391)
at com.inkubator.test.app.ui.Menu.displayTaskManageTransitionsScreen(Menu.java:757)
at com.inkubator.test.app.ui.Menu.display(Menu.java:130)
at com.inkubator.test.app.AlfrescoWorkflowApiTestConsoleApp$1.execute(AlfrescoWorkflowApiTestConsoleApp.java:64)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:225)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:155)
at com.inkubator.test.app.AlfrescoWorkflowApiTestConsoleApp.main(AlfrescoWorkflowApiTestConsoleApp.java:74)
Caused by: org.jbpm.graph.def.DelegationException: Failed to execute supplied script: Failed to execute supplied script: ReferenceError: "sdzwf_xyz" is not defined. (AlfrescoScript#1)
<?xml version="1.0" encoding="UTF-8"?>
<process-definition
xmlns="urn:jbpm.org:jpdl-3.1" name="sdzwf:myWorkflow">
<swimlane name="initiator" />
<swimlane name="aaa">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<actor>#{sdzwf_aaa}</actor>
</assignment>
</swimlane>
<swimlane name="xyz">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<actor>#{sdzwf_xyz}</actor>
</assignment>
</swimlane>
<swimlane name="bbb">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<actor>#{sdzwf_bbb}</actor>
</assignment>
</swimlane>
<start-state name="start">
<task name="sdzwf:startTask" swimlane="initiator" />
<transition name="" to="aaaTask"></transition>
</start-state>
<task-node name="aaaTask">
<task name="sdzwf:aaaTask" swimlane="aaa"></task>
<transition to="xyzTask" name="Odobri"></transition>
</task-node>
<task-node name="xyzTask">
<task name="sdzwf:xyzTask" swimlane="xyz"></task>
<transition to="bbbTask" name="Odobri"></transition>
<transition to="aaaTask" name="Vrati"></transition>
</task-node>
<task-node name="bbbTask">
<task name="sdzwf:bbbTask" swimlane="bbb"></task>
<transition to="xyzTask" name="Vrati"></transition>
<transition to="end" name="Odobri"></transition>
</task-node>
<end-state name="end"></end-state>
</process-definition>
<type name="sdzwf:startTask">
<parent>bpm:startTask</parent>
<overrides>
<property name="bpm:packageActionGroup">
<default>add_package_item_actions</default>
</property>
<property name="bpm:packageItemActionGroup">
<default>edit_package_item_actions</default>
</property>
</overrides>
<mandatory-aspects>
<aspect>sdzwf:aaa</aspect>
</mandatory-aspects>
</type>
<type name="sdzwf:aaaTask">
<parent>bpm:workflowTask</parent>
<overrides>
<property name="bpm:packageActionGroup">
<default>add_package_item_actions</default>
</property>
<property name="bpm:packageItemActionGroup">
<default>edit_package_item_actions</default>
</property>
</overrides>
<mandatory-aspects>
<aspect>sdzwf:xyz</aspect>
</mandatory-aspects>
</type>
<type name="sdzwf:xyzTask">
<parent>bpm:workflowTask</parent>
<overrides>
<property name="bpm:packageActionGroup">
<default>add_package_item_actions</default>
</property>
<property name="bpm:packageItemActionGroup">
<default>edit_package_item_actions</default>
</property>
</overrides>
<mandatory-aspects>
<aspect>sdzwf:bbb</aspect>
</mandatory-aspects>
</type>
<type name="sdzwf:bbbTask">
<parent>bpm:workflowTask</parent>
<overrides>
<property name="bpm:packageActionGroup">
<default>add_package_item_actions</default>
</property>
<property name="bpm:packageItemActionGroup">
<default>edit_package_item_actions</default>
</property>
</overrides>
</type>
</types>
<aspects>
<aspect name="sdzwf:aaa">
<associations>
<association name="sdzwf:aaa">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
</associations>
</aspect>
<aspect name="sdzwf:xyz">
<associations>
<association name="sdzwf:xyz">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
</associations>
</aspect>
<aspect name="sdzwf:bbb">
<associations>
<association name="sdzwf:bbb">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
</associations>
</aspect>
</aspects>
10-07-2010 03:25 AM
10-18-2010 09:30 AM
public static void executeTransition(final String taskId, String taskOwnerUsername, final String nrPackage, final String transitionId, final String assigneeUsername, final String comment, final String ticket) {
/*TransactionService transactionService = AlfrescoServices.getTransactionService();
RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {*/
NodeRef nrUser = Authentication.getInstance().getUserNodeRef(ticket);
String userName = DefaultTypeConverter.INSTANCE.convert(String.class, AlfrescoServices.getNodeService().getProperty(nrUser, ContentModel.PROP_USERNAME));
WorkflowTask task = AlfrescoServices.getWorkflowService().getTaskById(taskId);
// update map
Map<QName, Serializable> updateProperties = new HashMap<QName, Serializable>();
// comment
if(comment != null) {
updateProperties.put(QName.createQName(BPM_DESCRIPTION_QNAME), comment);
}
// package
if(nrPackage != null) {
updateProperties.put(WorkflowModel.ASSOC_PACKAGE, new NodeRef(nrPackage));
}
// TODO: due date
// parameters.put(WorkflowModel.PROP_DUE_DATE, dueDate);
// assignee node reference
NodeRef nrAssignee = AlfrescoServices.getPersonService().getPerson(assigneeUsername);
if(nrAssignee != null) {
//updateProperties.put(WorkflowModel.ASSOC_ASSIGNEE, assigneeUsername);
updateProperties.put(WorkflowModel.ASSOC_ASSIGNEE, nrAssignee);
updateProperties.put(ContentModel.PROP_OWNER, assigneeUsername);
// auth 1 begin
net.sf.acegisecurity.Authentication auth = AuthenticationUtil.setSystemUserAsCurrentUser();
// update task
AlfrescoServices.getWorkflowService().updateTask(taskId, updateProperties, null, null);
// execute task
String pathId = task.path.id;
AlfrescoServices.getWorkflowService().signal(pathId, transitionId);
NodeRef nrCompanyHome = getCompanyHomeNodeRef();
AlfrescoServices.getPermissionService().setPermission(nrCompanyHome, userName, PermissionService.COORDINATOR, true);
AuthenticationUtil.setCurrentUser(userName);
// auth 1 end
// auth 2 begin
AuthenticationUtil.setSystemUserAsCurrentUser();
AlfrescoServices.getPermissionService().deletePermission(nrCompanyHome, userName, PermissionService.COORDINATOR);
AuthenticationUtil.setCurrentUser(userName);
// auth 2 end
}
/*return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);*/
}
10-23-2010 07:45 AM
07-11-2017 07:33 AM
" Right approach is to signal task first, then from path end old task with endTask, and then update new task from path, especially with bpmwner value which will transfer task to the new owner."
I didn't get above clarification, can you explain it in more detail.
Thanks in Advance
07-15-2011 11:01 AM
Haven't found a solution for my problems yet…
My serial workflow is working perfectly in Alfresco web client, I can assign new actor when I perform a task, but I can't do the same in Java code. Java method updateTask does not update task properties with the actor necessary for the next task.
Anyone?
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.