Search in sources :

Example 11 with ProcessEngine

use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.

the class SpringProcessEngineConfiguration method buildProcessEngine.

@Override
public ProcessEngine buildProcessEngine() {
    ProcessEngine processEngine = super.buildProcessEngine();
    ProcessEngines.setInitialized(true);
    autoDeployResources(processEngine);
    return processEngine;
}
Also used : ProcessEngine(org.activiti.engine.ProcessEngine)

Example 12 with ProcessEngine

use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.

the class EndpointAutoConfigurationTest method mvcEndpoint.

@Test
public void mvcEndpoint() throws Throwable {
    AnnotationConfigEmbeddedWebApplicationContext applicationContext = new AnnotationConfigEmbeddedWebApplicationContext(CallbackEmbeddedContainerCustomizer.class, EmbeddedContainerConfiguration.class, EndpointConfiguration.class);
    ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);
    org.junit.Assert.assertNotNull("the processEngine should not be null", processEngine);
    ProcessEngineEndpoint processEngineEndpoint = applicationContext.getBean(ProcessEngineEndpoint.class);
    org.junit.Assert.assertNotNull("the processEngineEndpoint should not be null", processEngineEndpoint);
    RestTemplate restTemplate = applicationContext.getBean(RestTemplate.class);
    ResponseEntity<Map> mapResponseEntity = restTemplate.getForEntity("http://localhost:9091/activiti/", Map.class);
    Map map = mapResponseEntity.getBody();
    String[] criticalKeys = { "completedTaskCount", "openTaskCount", "cachedProcessDefinitionCount" };
    Map<?, ?> invokedResults = processEngineEndpoint.invoke();
    for (String k : criticalKeys) {
        org.junit.Assert.assertTrue(map.containsKey(k));
        org.junit.Assert.assertEquals(((Number) map.get(k)).longValue(), ((Number) invokedResults.get(k)).longValue());
    }
}
Also used : RestTemplate(org.springframework.web.client.RestTemplate) ProcessEngineEndpoint(org.activiti.spring.boot.actuate.endpoint.ProcessEngineEndpoint) Map(java.util.Map) AnnotationConfigEmbeddedWebApplicationContext(org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext) ProcessEngine(org.activiti.engine.ProcessEngine) Test(org.junit.Test)

Example 13 with ProcessEngine

use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.

the class ReportDetailPanel method initForm.

protected void initForm() {
    // Check if a start form is defined
    final ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    StartFormData startFormData = processEngine.getFormService().getStartFormData(processDefinition.getId());
    if (startFormData != null && ((startFormData.getFormProperties() != null && !startFormData.getFormProperties().isEmpty()) || startFormData.getFormKey() != null)) {
        processDefinitionStartForm = new FormPropertiesForm();
        detailContainer.addComponent(processDefinitionStartForm);
        processDefinitionStartForm.setFormProperties(startFormData.getFormProperties());
        processDefinitionStartForm.setSubmitButtonCaption(i18nManager.getMessage(Messages.REPORTING_GENERATE_REPORT));
        processDefinitionStartForm.hideCancelButton();
        processDefinitionStartForm.addListener(new FormPropertiesEventListener() {

            private static final long serialVersionUID = 1L;

            protected void handleFormSubmit(FormPropertiesEvent event) {
                // Report is generated by running a process and storing the dataset in the history tablkes
                savedFormProperties = event.getFormProperties();
                ProcessInstance processInstance = startProcessInstanceWithFormProperties(processDefinition.getId(), event.getFormProperties());
                generateReport(processInstance);
            }

            protected void handleFormCancel(FormPropertiesEvent event) {
            // Not needed, cancel button not shown in report panels
            }
        });
    } else {
        // Just start the process-instance since it has no form.
        ProcessInstance processInstance = startProcessInstance(processDefinition.getId());
        generateReport(processInstance);
    }
}
Also used : FormPropertiesEventListener(org.activiti.explorer.ui.form.FormPropertiesEventListener) StartFormData(org.activiti.engine.form.StartFormData) FormPropertiesForm(org.activiti.explorer.ui.form.FormPropertiesForm) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) FormPropertiesEvent(org.activiti.explorer.ui.form.FormPropertiesForm.FormPropertiesEvent) ProcessEngine(org.activiti.engine.ProcessEngine)

Example 14 with ProcessEngine

use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.

the class TestHelper method getProcessEngine.

// Engine startup and shutdown helpers  ///////////////////////////////////////////////////
public static ProcessEngine getProcessEngine(String configurationResource) {
    ProcessEngine processEngine = processEngines.get(configurationResource);
    if (processEngine == null) {
        log.debug("==== BUILDING PROCESS ENGINE ========================================================================");
        processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(configurationResource).buildProcessEngine();
        log.debug("==== PROCESS ENGINE CREATED =========================================================================");
        processEngines.put(configurationResource, processEngine);
    }
    return processEngine;
}
Also used : ProcessEngine(org.activiti.engine.ProcessEngine)

Example 15 with ProcessEngine

use of org.activiti.engine.ProcessEngine in project Activiti by Activiti.

the class SpringActivitiTestCase method initializeProcessEngine.

@Override
protected void initializeProcessEngine() {
    ContextConfiguration contextConfiguration = getClass().getAnnotation(ContextConfiguration.class);
    String[] value = contextConfiguration.value();
    boolean hasOneArg = value != null && value.length == 1;
    String key = hasOneArg ? value[0] : ProcessEngine.class.getName();
    ProcessEngine engine = this.cachedProcessEngines.containsKey(key) ? this.cachedProcessEngines.get(key) : this.applicationContext.getBean(ProcessEngine.class);
    this.cachedProcessEngines.put(key, engine);
    this.processEngine = engine;
}
Also used : ContextConfiguration(org.springframework.test.context.ContextConfiguration) ProcessEngine(org.activiti.engine.ProcessEngine)

Aggregations

ProcessEngine (org.activiti.engine.ProcessEngine)31 Test (org.junit.Test)13 RepositoryService (org.activiti.engine.RepositoryService)7 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)7 ActivitiException (org.activiti.engine.ActivitiException)6 RuntimeService (org.activiti.engine.RuntimeService)6 TaskService (org.activiti.engine.TaskService)4 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)4 StandaloneProcessEngineConfiguration (org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)4 Task (org.activiti.engine.task.Task)4 StandaloneInMemProcessEngineConfiguration (org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)3 Deployment (org.activiti.engine.repository.Deployment)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1