return "redirect:/modeler/modeler-list.do";
}
@RequestMapping("modeler-deploy")
public String deploy(@RequestParam("id") String id) throws Exception {
RepositoryService repositoryService = processEngine
.getRepositoryService();
Model modelData = repositoryService.getModel(id);
JsonNode modelNode = (JsonNode) new ObjectMapper()
.readTree(repositoryService.getModelEditorSource(modelData
.getId()));
byte[] bpmnBytes = null;
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment()
.name(modelData.getName())
.addString(processName, new String(bpmnBytes, "UTF-8"))
.deploy();
modelData.setDeploymentId(deployment.getId());
repositoryService.saveModel(modelData);
List<ProcessDefinition> processDefinitions = repositoryService
.createProcessDefinitionQuery()
.deploymentId(deployment.getId()).list();
for (ProcessDefinition processDefinition : processDefinitions) {
processEngine.getManagementService().executeCommand(