04-11-2011 03:20 PM
04-13-2011 08:38 AM
04-22-2011 02:25 PM
…
<super-state name="specify-document-data">
<task-node name="set-document-type">
<task name="blfinwf:setDocumentTypeTask" swimlane="initiator">
<description>Set Document Type</description>
<event type="task-end">
<action class="com.burris.common.bpm.actions.ForceChangeTypeAction" />
</event>
<controller>
<variable name="blfinwf_documentType" />
</controller>
</task>
<transition name="Submit" to="set-meta-data"></transition>
</task-node>
…
…
<type name="blfinwf:setDocumentTypeTask">
<parent>bpm:workflowTask</parent>
<properties>
<property name="blfinwf:documentType">
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>false</multiple>
<constraints>
<constraint type="LIST">
<parameter name="allowedValues">
<list>
<value>blfin:certificateOfLiabilityInsurance</value>
<value>blfin:1099</value>
<value>blfin:w9</value>
</list>
</parameter>
</constraint>
</constraints>
</property>
</properties>
</type>
…
…
package com.burris.common.bpm.actions;
import java.util.List;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.springframework.beans.factory.BeanFactory;
@SuppressWarnings("serial")
public class ForceChangeTypeAction extends JBPMSpringActionHandler {
private static final Logger log = Logger.getLogger( ForceChangeTypeAction.class );
private NodeService nodeService;
private NamespaceService namespaceService;
@Override
protected void initialiseHandler( BeanFactory factory ) {
this.nodeService = (NodeService) factory.getBean( "nodeService" );
this.namespaceService = (NamespaceService) factory.getBean( "namespaceService" );
}
@Override
public void execute( ExecutionContext context ) throws Exception {
ContextInstance contextInstance = context.getContextInstance();
Object object = contextInstance.getVariable( "bpm_package" );
if ( object == null ) {
log.fatal( "bpm_package variable is null." );
return;
}
NodeRef nodeRef = ((JBPMNode) object).getNodeRef();
if ( nodeRef == null ) {
log.fatal( "nodeRef is null." );
return;
}
TaskInstance task = context.getTaskInstance();
String documentType = (String) task.getVariable( "blfinwf_documentType" );
QName qname = QName.createQName( documentType, namespaceService );
// Set document to finance doc type to ensure child type compatibility
// (ie someone dropped a document with a type already specified)
List<ChildAssociationRef> children = nodeService.getChildAssocs( nodeRef );
for ( ChildAssociationRef child : children ) {
NodeRef childNodeRef = child.getChildRef();
nodeService.setType( childNodeRef, qname );
}
}
}
…
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.