use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class EditorProcessDefinitionDetailPanel method deployModelerModel.
protected void deployModelerModel(final ObjectNode modelNode) {
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
ExplorerApp.get().getViewManager().showDeploymentPage(deployment.getId());
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class ChineseConverterTest method exportAndReadXMLFile.
protected BpmnModel exportAndReadXMLFile(BpmnModel bpmnModel) throws Exception {
byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel, processEngineConfiguration.getXmlEncoding());
StreamSource xmlSource = new InputStreamSource(new ByteArrayInputStream(xml));
BpmnModel parsedModel = new BpmnXMLConverter().convertToBpmnModel(xmlSource, false, false, processEngineConfiguration.getXmlEncoding());
return parsedModel;
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testGeneratedWorkflowDefinitionId.
/**
* Check if all required artifacts are created when converting an empty workflow-definition.
*/
@Test
public void testGeneratedWorkflowDefinitionId() {
WorkflowDefinition definition = new WorkflowDefinition();
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
BpmnModel bpmnModel = conversion.getBpmnModel();
assertNotNull(bpmnModel);
Process process = bpmnModel.getMainProcess();
assertNotNull(process);
String generatedProcessId = process.getId();
assertNotNull(generatedProcessId);
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class DeploymentManager method getBpmnModelById.
public BpmnModel getBpmnModelById(String processDefinitionId) {
if (processDefinitionId == null) {
throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
}
// first try the cache
BpmnModel bpmnModel = bpmnModelCache.get(processDefinitionId);
if (bpmnModel == null) {
ProcessDefinitionEntity processDefinition = findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", ProcessDefinition.class);
}
// Fetch the resource
String resourceName = processDefinition.getResourceName();
ResourceEntity resource = Context.getCommandContext().getResourceEntityManager().findResourceByDeploymentIdAndResourceName(processDefinition.getDeploymentId(), resourceName);
if (resource == null) {
if (Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(processDefinition.getDeploymentId()) == null) {
throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: " + processDefinition.getDeploymentId(), Deployment.class);
} else {
throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + processDefinition.getDeploymentId() + "'", InputStream.class);
}
}
// Convert the bpmn 2.0 xml to a bpmn model
BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
bpmnModel = bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false);
bpmnModelCache.add(processDefinition.getId(), bpmnModel);
}
return bpmnModel;
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class TestProcessUtil method createTwoTasksBpmnModel.
public static BpmnModel createTwoTasksBpmnModel() {
BpmnModel model = new BpmnModel();
org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
model.addProcess(process);
process.setId("twoTasksProcess");
process.setName("The two tasks process");
StartEvent startEvent = new StartEvent();
startEvent.setId("start");
process.addFlowElement(startEvent);
UserTask userTask = new UserTask();
userTask.setName("The First Task");
userTask.setId("task1");
userTask.setAssignee("kermit");
process.addFlowElement(userTask);
UserTask userTask2 = new UserTask();
userTask2.setName("The Second Task");
userTask2.setId("task2");
userTask2.setAssignee("kermit");
process.addFlowElement(userTask2);
EndEvent endEvent = new EndEvent();
endEvent.setId("theEnd");
process.addFlowElement(endEvent);
process.addFlowElement(new SequenceFlow("start", "task1"));
process.addFlowElement(new SequenceFlow("start", "task2"));
process.addFlowElement(new SequenceFlow("task1", "theEnd"));
process.addFlowElement(new SequenceFlow("task2", "theEnd"));
return model;
}
Aggregations