Search in sources :

Example 61 with Deployment

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();
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter)

Example 62 with Deployment

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();
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ProcessEngine(org.activiti.engine.ProcessEngine) Test(org.junit.Test)

Example 63 with Deployment

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();
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ProcessEngine(org.activiti.engine.ProcessEngine) Test(org.junit.Test)

Example 64 with Deployment

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();
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) ClickEvent(com.vaadin.ui.Button.ClickEvent) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) Deployment(org.activiti.engine.repository.Deployment) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ClickListener(com.vaadin.ui.Button.ClickListener) ImportModelClickListener(org.activiti.explorer.ui.process.listener.ImportModelClickListener) NewModelClickListener(org.activiti.explorer.ui.process.listener.NewModelClickListener) EditModelClickListener(org.activiti.explorer.ui.process.listener.EditModelClickListener)

Example 65 with Deployment

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();
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ByteArrayInputStream(java.io.ByteArrayInputStream) SysBpmnResourceVO(com.netsteadfast.greenstep.vo.SysBpmnResourceVO) Deployment(org.activiti.engine.repository.Deployment) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Aggregations

Deployment (org.activiti.engine.repository.Deployment)66 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)12 BpmnModel (org.activiti.bpmn.model.BpmnModel)10 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ActivitiException (org.activiti.engine.ActivitiException)7 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6 HttpGet (org.apache.http.client.methods.HttpGet)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)3 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)3 ProcessEngine (org.activiti.engine.ProcessEngine)3 RuntimeService (org.activiti.engine.RuntimeService)3 DeploymentBuilder (org.activiti.engine.repository.DeploymentBuilder)3 Task (org.activiti.engine.task.Task)3