Search in sources :

Example 76 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.

the class EventOverviewPanel method initProcessInstances.

protected void initProcessInstances() {
    HorizontalLayout instancesHeader = new HorizontalLayout();
    instancesHeader.setSpacing(false);
    instancesHeader.setMargin(false);
    instancesHeader.setWidth(100, UNITS_PERCENTAGE);
    instancesHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    addDetailComponent(instancesHeader);
    initProcessInstanceTitle(instancesHeader);
    HorizontalLayout selectLayout = new HorizontalLayout();
    selectLayout.setSpacing(true);
    selectLayout.setMargin(true);
    selectLayout.setWidth(50, UNITS_PERCENTAGE);
    addDetailComponent(selectLayout);
    definitionSelect = new NativeSelect(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_DEFINITIONS));
    definitionSelect.setImmediate(true);
    for (ProcessDefinition definition : definitionList) {
        definitionSelect.addItem(definition.getId());
        definitionSelect.setItemCaption(definition.getId(), definition.getName());
    }
    definitionSelect.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (definitionSelect.getValue() != null) {
                String selectedDefinitionId = (String) definitionSelect.getValue();
                ExplorerApp.get().setCrystalBallCurrentDefinitionId(selectedDefinitionId);
                refreshInstances(selectedDefinitionId);
            }
        }
    });
    selectLayout.addComponent(definitionSelect);
    replayButton = new Button(i18nManager.getMessage(Messages.CRYSTALBALL_BUTTON_REPLAY));
    replayButton.setEnabled(false);
    replayButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (instanceTable.getValue() != null) {
                String processInstanceId = (String) instanceTable.getValue();
                ExplorerApp.get().setCrystalBallCurrentInstanceId(processInstanceId);
                List<EventLogEntry> eventLogEntries = managementService.getEventLogEntriesByProcessInstanceId(processInstanceId);
                if (eventLogEntries == null || eventLogEntries.isEmpty())
                    return;
                EventLogTransformer transformer = new EventLogTransformer(getTransformers());
                simulationEvents = transformer.transform(eventLogEntries);
                ExplorerApp.get().setCrystalBallSimulationEvents(simulationEvents);
                SimpleEventCalendar eventCalendar = new SimpleEventCalendar(ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration().getClock(), new SimulationEventComparator());
                eventCalendar.addEvents(simulationEvents);
                // replay process instance run
                simulationDebugger = new ReplaySimulationRun(ProcessEngines.getDefaultProcessEngine(), eventCalendar, getReplayHandlers(processInstanceId));
                ExplorerApp.get().setCrystalBallSimulationDebugger(simulationDebugger);
                simulationDebugger.init(new NoExecutionVariableScope());
                simulationDebugger.step();
                // replay process was started
                List<HistoricProcessInstance> replayProcessInstanceList = historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(SIMULATION_BUSINESS_KEY).orderByProcessInstanceStartTime().desc().list();
                if (replayProcessInstanceList != null && !replayProcessInstanceList.isEmpty()) {
                    replayHistoricInstance = replayProcessInstanceList.get(0);
                }
                refreshEvents();
            }
        }
    });
    selectLayout.addComponent(replayButton);
    selectLayout.setComponentAlignment(replayButton, Alignment.MIDDLE_LEFT);
    instanceLayout = new HorizontalLayout();
    instanceLayout.setWidth(100, UNITS_PERCENTAGE);
    addDetailComponent(instanceLayout);
    initInstancesTable();
}
Also used : ReplaySimulationRun(org.activiti.crystalball.simulator.ReplaySimulationRun) ClickEvent(com.vaadin.ui.Button.ClickEvent) SimpleEventCalendar(org.activiti.crystalball.simulator.SimpleEventCalendar) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) SimulationEventComparator(org.activiti.crystalball.simulator.SimulationEventComparator) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) EventLogTransformer(org.activiti.crystalball.simulator.delegate.event.impl.EventLogTransformer) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) Button(com.vaadin.ui.Button) NativeSelect(com.vaadin.ui.NativeSelect) ArrayList(java.util.ArrayList) List(java.util.List) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 77 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.

the class ProcessDefinitionFormPropertyRenderer method getPropertyField.

public Field getPropertyField(FormProperty formProperty) {
    ComboBox comboBox = new ComboBox(getPropertyLabel(formProperty));
    comboBox.setRequired(formProperty.isRequired());
    comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
    comboBox.setEnabled(formProperty.isWritable());
    List<ProcessDefinition> processDefinitions = ProcessEngines.getDefaultProcessEngine().getRepositoryService().createProcessDefinitionQuery().orderByProcessDefinitionName().asc().orderByProcessDefinitionVersion().asc().list();
    for (ProcessDefinition processDefinition : processDefinitions) {
        comboBox.addItem(processDefinition.getId());
        String name = processDefinition.getName() + " (v" + processDefinition.getVersion() + ")";
        comboBox.setItemCaption(processDefinition.getId(), name);
    }
    // Select first
    if (!processDefinitions.isEmpty()) {
        comboBox.setNullSelectionAllowed(false);
        comboBox.select(processDefinitions.get(0).getId());
    }
    return comboBox;
}
Also used : ComboBox(com.vaadin.ui.ComboBox) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 78 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.

the class IntegrationAutoConfigurationTest method testLaunchingGatewayProcessDefinition.

@Test
public void testLaunchingGatewayProcessDefinition() throws Exception {
    AnnotationConfigApplicationContext applicationContext = this.context(InboundGatewayConfiguration.class);
    RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class);
    RuntimeService runtimeService = applicationContext.getBean(RuntimeService.class);
    ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);
    Assert.assertNotNull("the process engine should not be null", processEngine);
    Assert.assertNotNull("we should have a default repositoryService included", repositoryService);
    String integrationGatewayProcess = "integrationGatewayProcess";
    List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery().processDefinitionKey(integrationGatewayProcess).list();
    ProcessDefinition processDefinition = processDefinitionList.iterator().next();
    Assert.assertEquals(processDefinition.getKey(), integrationGatewayProcess);
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("customerId", 232);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(integrationGatewayProcess, vars);
    Assert.assertNotNull("the processInstance should not be null", processInstance);
    org.junit.Assert.assertTrue(applicationContext.getBean(InboundGatewayConfiguration.AnalysingService.class).getStringAtomicReference().get().equals(projectId));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) RuntimeService(org.activiti.engine.RuntimeService) HashMap(java.util.HashMap) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) RepositoryService(org.activiti.engine.RepositoryService) ProcessEngine(org.activiti.engine.ProcessEngine) Test(org.junit.Test)

Example 79 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition 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));
}
Also used : DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) InputStream(java.io.InputStream) BpmnAutoLayout(org.activiti.bpmn.BpmnAutoLayout) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) BpmnModel(org.activiti.bpmn.model.BpmnModel) InputStreamResource(org.springframework.core.io.InputStreamResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 80 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project alfresco-remote-api by Alfresco.

the class ProcessesImpl method createProcessInfo.

protected ProcessInfo createProcessInfo(HistoricProcessInstance processInstance) {
    ProcessInfo processInfo = new ProcessInfo(processInstance);
    ProcessDefinition definitionEntity = activitiProcessEngine.getRepositoryService().getProcessDefinition(processInstance.getProcessDefinitionId());
    processInfo.setProcessDefinitionKey(getLocalProcessDefinitionKey(definitionEntity.getKey()));
    return processInfo;
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInfo(org.alfresco.rest.workflow.api.model.ProcessInfo)

Aggregations

ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)211 Deployment (org.activiti.engine.test.Deployment)82 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)42 ArrayList (java.util.ArrayList)29 ActivitiException (org.activiti.engine.ActivitiException)25 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)23 RepositoryService (org.activiti.engine.RepositoryService)20 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)19 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)19 Task (org.activiti.engine.task.Task)16 Date (java.util.Date)14 Test (org.junit.Test)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12 HashMap (java.util.HashMap)12 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)11 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)11 InputStream (java.io.InputStream)10 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)10 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)9