cancel
Showing results for 
Search instead for 
Did you mean: 

how can I get the files detail in the bpm_package

forrest43
Champ in-the-making
Champ in-the-making
I have defined a process, which including a service task node, and set the activiti:expression of the service task as followed,


<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="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="collectDemo" name="collectDemo">
    <endEvent id="endevent1" name="End"></endEvent>
    <subProcess id="collectDoc" name="collectDoc">
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${bpm_assignees}" activiti:elementVariable="subAssignee"></multiInstanceLoopCharacteristics>
      <startEvent id="startevent1" name="Start"></startEvent>
      <endEvent id="endevent2" name="End"></endEvent>
      <userTask id="alfrescoUsertask1" name="Alfresco User Task" activiti:assignee="${subAssignee.properties.userName}" activiti:formKey="ewf:processTask"></userTask>
      <serviceTask id="servicetask1" name="Service Task" activiti:expression="#{generateTemplateBean.generateTemplate(execution)}"></serviceTask>
      <sequenceFlow id="flow8" name="" sourceRef="alfrescoUsertask1" targetRef="endevent2"></sequenceFlow>
      <sequenceFlow id="flow13" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
      <sequenceFlow id="flow14" name="" sourceRef="servicetask1" targetRef="alfrescoUsertask1"></sequenceFlow>
    </subProcess>
    <startEvent id="alfrescoStartevent1" name="Alfresco start" activiti:formKey="ewf:collectStart"></startEvent>
    <userTask id="review_task2" name="review_task" activiti:assignee="${initiator.properties.userName}" activiti:formKey="ewf:viewTask"></userTask>
    <sequenceFlow id="flow10" name="" sourceRef="alfrescoStartevent1" targetRef="collectDoc"></sequenceFlow>
    <sequenceFlow id="flow11" name="" sourceRef="collectDoc" targetRef="review_task2"></sequenceFlow>
    <sequenceFlow id="flow12" name="" sourceRef="review_task2" targetRef="endevent1"></sequenceFlow>
  </process>
</definitions>

the details of the generateTemplatedBean:

public class GenerateTemplateBean{
public void generateTemplate(DelegateExecution execution){
      ActivitiScriptNode bpmPackage = (ActivitiScriptNode)execution.getVariables().get("bpm_package");
   }
}

it's supposed that I can get the varible via DelegateExcution, but all the varible's type is ActivitiScriptNode, how can I get the files in the bpm_package, like path, file type, the content of the file.
7 REPLIES 7

lementree
Champ on-the-rise
Champ on-the-rise
Hi,

You can ge the Documents in Workflow by this Code


ActivitiScriptNode scriptNode = (ActivitiScriptNode)executionEntity.getVariable(WorkflowNotificationUtils.PROP_PACKAGE);
NodeRef packagenode = scriptNode.getNodeRef();
NodeRef docRef= serviceRegistry.getNodeService().getChildAssocs(packagenode).get(0).getChildRef();

Thanks & Regards

dmralfing
Champ in-the-making
Champ in-the-making
Ok, it works, thank you so much!

testuser
Champ in-the-making
Champ in-the-making
Could you please explain how to get a document name from the docRef, do you have an example? that would be great, thanks!

dmralfing
Champ in-the-making
Champ in-the-making

NodeService nodeService=serviceRegistry.getNodeService ();
String nodeName=nodeService.getProperty (docRef, ContentModel.PROP_NAME);

testuser
Champ in-the-making
Champ in-the-making
Thanks!

shadow4110
Champ in-the-making
Champ in-the-making
Hi,

could you please explain how to get serviceRegistry object?
I have used "ApplicationContextHelper.getApplicationContext()" and ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml")
but getting Exception:
Cannot create JDBC driver of class '' for connect URL 'null'
java.lang.NullPointerException
   at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:524)
   at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:493)
   at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
   at java.sql.DriverManager.getDriver(DriverManager.java:262)
   at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
   at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
   at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
   at org.alfresco.config.JndiObjectFactoryBean.lookup(JndiObjectFactoryBean.java:44)
   at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
   at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
   at org.sprin….
…..
…..

kaynezhang
World-Class Innovator
World-Class Innovator
What do you want to do using ApplicationContextHelper,do you want to do unit test? if yes, you shoud copy alfresco-global.properties to your classpath and set your database connection info there.