use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ChineseConverterTest method deployProcess.
protected void deployProcess(BpmnModel bpmnModel) {
byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
try {
Deployment deployment = processEngine.getRepositoryService().createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
processEngine.getRepositoryService().deleteDeployment(deployment.getId());
} finally {
processEngine.close();
}
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class MuleHttpBasicAuthTest method httpWithBasicAuth.
@Test
public void httpWithBasicAuth() throws Exception {
Assert.assertTrue(muleContext.isStarted());
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttpBasicAuth.bpmn20.xml").deploy();
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
Assert.assertFalse(processInstance.isEnded());
Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
Assert.assertEquals(10, result);
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
processEngine.getRepositoryService().deleteDeployment(deployment.getId());
assertAndEnsureCleanDb(processEngine);
ProcessEngines.destroy();
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class MuleHttpTest method http.
@Test
public void http() throws Exception {
Assert.assertTrue(muleContext.isStarted());
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttp.bpmn20.xml").deploy();
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
Assert.assertFalse(processInstance.isEnded());
Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
Assert.assertEquals(20, result);
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
processEngine.getRepositoryService().deleteDeployment(deployment.getId());
assertAndEnsureCleanDb(processEngine);
ProcessEngines.destroy();
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class EditorProcessDefinitionDetailPanel method deploySimpleTableEditorModel.
protected void deploySimpleTableEditorModel(final byte[] model) {
final DeployModelPopupWindow deployModelPopupWindow = new DeployModelPopupWindow(modelData);
deployModelPopupWindow.getDeployButton().addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
// Convert to simple workflow definition
WorkflowDefinition workflowDefinition = ExplorerApp.get().getSimpleWorkflowJsonConverter().readWorkflowDefinition(model);
// Update model name
modelData.setName(deployModelPopupWindow.getProcessName());
workflowDefinition.setName(deployModelPopupWindow.getProcessName());
WorkflowDefinitionConversion conversion = ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
conversion.convert();
// Deploy to database
byte[] bpmnBytes = null;
try {
bpmnBytes = conversion.getBpmn20Xml().getBytes("utf-8");
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
// Generate reports
if (deployModelPopupWindow.isGenerateReports()) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
ReportingUtil.generateTaskDurationReport(processDefinition.getId());
}
// Close popup and show new deployment
deployModelPopupWindow.closePopupWindow();
ExplorerApp.get().getViewManager().showDeploymentPage(deployment.getId());
} catch (UnsupportedEncodingException e) {
ExplorerApp.get().getNotificationManager().showErrorNotification(Messages.PROCESS_TOXML_FAILED, e);
deployModelPopupWindow.closePopupWindow();
}
}
});
deployModelPopupWindow.showPopupWindow();
}
use of org.activiti.engine.repository.Deployment in project bamboobsc by billchen198318.
the class BusinessProcessManagementUtils method deployment.
public static String deployment(SysBpmnResourceVO sysBpmnResource) throws ServiceException, Exception {
DefaultResult<SysBpmnResourceVO> result = sysBpmnResourceService.findByUK(sysBpmnResource);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
ZipInputStream zip = new ZipInputStream(new ByteArrayInputStream(result.getValue().getContent()));
Deployment deployment = null;
try {
deployment = repositoryService.createDeployment().name(result.getValue().getName()).addZipInputStream(zip).deploy();
result.getValue().setDeploymentId(deployment.getId());
byte[] content = result.getValue().getContent();
// 先清掉content
result.getValue().setContent(null);
// 先清掉content
sysBpmnResourceService.updateObject(result.getValue());
// 填回content
result.getValue().setContent(content);
// 填回content
sysBpmnResourceService.updateObject(result.getValue());
logger.info("deployment Id: " + deployment.getId() + " , name: " + deployment.getName());
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage().toString());
throw e;
} finally {
zip.close();
zip = null;
}
return deployment.getId();
}
Aggregations