Programmatic process definition and deployment (without xml)

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2011 12:41 PM
Hi everyone
I'm new to Activiti and wanted to see if it will work for a project we're migrating.
I couldn't find a good example of creating a processDefinition and deploying it programatically. I took point from ProcessDefinitionsTest, and a few others, but they seem to be deploying a process by reading from an existing xml resource or from a process string. (ie. DeploymentBuilder.addClasspathResource and addString)
I have a requirement where I am reading from external sources (ie. lists from db and flat files). I want to avoid having to preprocess and convert them all to bpmn xml files. I have List objects created from them, and would like to see if I can create a process definition from it, using something similar to the following
How do I deploy this now? Would this be the best way to do this? Is there an example you can point me to?
Thanks
I'm new to Activiti and wanted to see if it will work for a project we're migrating.
I couldn't find a good example of creating a processDefinition and deploying it programatically. I took point from ProcessDefinitionsTest, and a few others, but they seem to be deploying a process by reading from an existing xml resource or from a process string. (ie. DeploymentBuilder.addClasspathResource and addString)
I have a requirement where I am reading from external sources (ie. lists from db and flat files). I want to avoid having to preprocess and convert them all to bpmn xml files. I have List objects created from them, and would like to see if I can create a process definition from it, using something similar to the following
ProcessDefinitionBuilder processDefinitionBuilder = new ProcessDefinitionBuilder(someName);processDefinitionBuilder = processDefinitionBuilder.createActivity(top.getName()) .initial() .behavior(new BaseServiceTaskHandler("start node")) .transition(startName) .endActivity();for (int i = 0; i < myChecklist.size(); i++) { if(i<myChecklist.size() - 1) { processDefinitionBuilder = processDefinitionBuilder.createActivity(myChecklist.get(i).getName()) .behavior(new ReminderActivityHandler()) .transition(myChecklist.get(i + 1).getName()) .endActivity(); } else { processDefinitionBuilder = processDefinitionBuilder.createActivity(top.getRoutine().get(i).getName()) .endActivity(); } }PvmProcessDefinition processDefinition = processDefinitionBuilder.buildProcessDefinition();
How do I deploy this now? Would this be the best way to do this? Is there an example you can point me to?
Thanks
Labels:
- Labels:
-
Archive
12 REPLIES 12
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2011 12:05 PM
That is at least 'guaranteed' to be stable 🙂
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2012 11:45 AM
Is it a joke… /:/ to generate xml from my object/PvmProcessDefinition then re-import in the ProcessEngine via stream resource reading ?
PvmProcessDefinition should not be the centric language/model/template of work of the process engine ?
PvmProcessDefinition should not be the centric language/model/template of work of the process engine ?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2012 01:33 AM
I had a need for this and since 5.9 (thanks to http://jira.codehaus.org/browse/ACT-831) you can generate and execute a subprocess dynamically.
- your base (non dynamic) processdefinition should have a callActivity with a variable as calledElement
- your base (non dynamic) processdefinition should have a callActivity with a variable as calledElement
<callActivity id="callCheckCreditProcess" name="Check credit" calledElement="${dynamicProcess}" />
- just before this callactivity you put a service task to generate and deploy the processdefinition
String processXml = generateMyProcessDefinitionXml();
String processId = …. ; // the process id referenced in processXml
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment().name(..);
// make sure that the name ends with .bpmn20.xml otherwise it won't deploy
deploymentBuilder.addString("dynamicprocess.bpmn20.xml",processXml);
deploymentBuilder.deploy();
execution.setVariable("dynamicProcess", processId);
- then when the callActivity kicks in it will lookup the newly deployed process and execute it
