use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class ProcessEngineMvcEndpoint method processDefinitionDiagram.
/**
* Look up the process definition by key. For example,
* this is <A href="http://localhost:8080/activiti/processes/fulfillmentProcess">process-diagram for</A>
* a process definition named {@code fulfillmentProcess}.
*/
@RequestMapping(value = "/processes/{processDefinitionKey:.*}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public ResponseEntity processDefinitionDiagram(@PathVariable String processDefinitionKey) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey).latestVersion().singleResult();
if (processDefinition == null) {
return ResponseEntity.status(NOT_FOUND).body(null);
}
ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
if (bpmnModel.getLocationMap().size() == 0) {
BpmnAutoLayout autoLayout = new BpmnAutoLayout(bpmnModel);
autoLayout.execute();
}
InputStream is = processDiagramGenerator.generateJpgDiagram(bpmnModel);
return ResponseEntity.ok(new InputStreamResource(is));
}
use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class AbstractServiceTest method getBpmnModelForXmlResource.
/**
* Generates the BpmnModel for the given Activiti xml resource.
*
* @param activitiXmlResource the classpath location of Activiti Xml
*
* @return BpmnModel the constructed model
* @throws Exception if any exception occurs in creation
*/
protected BpmnModel getBpmnModelForXmlResource(String activitiXmlResource) throws Exception {
String activitiXml = IOUtils.toString(resourceLoader.getResource(activitiXmlResource).getInputStream());
BpmnModel bpmnModel;
try {
bpmnModel = activitiHelper.constructBpmnModelFromXmlAndValidate(activitiXml);
} catch (Exception ex) {
throw new IllegalArgumentException("Error processing Activiti XML: " + ex.getMessage(), ex);
}
return bpmnModel;
}
use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class AddEmrStepsTest method buildActivitiXml.
private String buildActivitiXml(String implementation, List<FieldExtension> fieldExtensionList) throws Exception {
BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_ADD_EMR_STEPS_WITH_CLASSPATH);
ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("addStepServiceTask");
serviceTask.setImplementation(implementation);
serviceTask.getFieldExtensions().addAll(fieldExtensionList);
return getActivitiXmlFromBpmnModel(bpmnModel);
}
use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class ActivitiDelegateTest method testDelegateWrongClass.
/**
* This method tests when wrong class name is used in service task, the process instance is created.
*/
@Test
public void testDelegateWrongClass() throws Exception {
BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_WORKFLOW);
ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1");
serviceTask.setImplementation("ClassDoesNotExist");
serviceTask.getFieldExtensions().clear();
// Run a job with Activiti XML that will start cluster.
try {
jobServiceTestHelper.createJobFromActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel), null);
fail();
} catch (Exception e) {
assertEquals(ActivitiException.class, e.getClass());
assertEquals("couldn't instantiate class ClassDoesNotExist", e.getMessage());
}
}
use of org.activiti.bpmn.model.BpmnModel in project herd by FINRAOS.
the class ActivitiDelegateTest method testDelegateSpringBeansNotPopulatedAgain.
/**
* This method tests the scenario where a java delegate is not populated again with spring beans.
*/
@Test
public void testDelegateSpringBeansNotPopulatedAgain() throws Exception {
BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_WORKFLOW);
ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1");
serviceTask.setImplementation(MockJavaDelegate.class.getCanonicalName());
serviceTask.getFieldExtensions().clear();
// Define the job definition
jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel));
// Executing the job twice so that the same JavaDelegate object is used and spring beans are not wired again.
jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME));
}
Aggregations