Search in sources :

Example 1 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class SimpleTableEditor method showDiagram.

protected void showDiagram() {
    StreamResource.StreamSource streamSource = new StreamSource() {

        private static final long serialVersionUID = 6993112534181068935L;

        public InputStream getStream() {
            WorkflowDefinitionConversion workflowDefinitionConversion = ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(createWorkflow());
            final ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
            final ProcessEngineConfiguration processEngineConfiguration = defaultProcessEngine.getProcessEngineConfiguration();
            final ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
            return diagramGenerator.generateDiagram(workflowDefinitionConversion.getBpmnModel(), "png", processEngineConfiguration.getActivityFontName(), processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getAnnotationFontName(), processEngineConfiguration.getClassLoader());
        }
    };
    // resource must have unique id (or cache-crap can happen)!
    StreamResource imageresource = new StreamResource(streamSource, UUID.randomUUID() + ".png", ExplorerApp.get());
    Embedded diagram = new Embedded("", imageresource);
    diagram.setType(Embedded.TYPE_IMAGE);
    diagram.setSizeUndefined();
    // using panel for scrollbars
    imagePanel = new Panel();
    imagePanel.setScrollable(true);
    imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
    imagePanel.setWidth(100, UNITS_PERCENTAGE);
    imagePanel.setHeight("100%");
    mainLayout.addComponent(imagePanel);
    HorizontalLayout panelLayout = new HorizontalLayout();
    panelLayout.setSizeUndefined();
    imagePanel.setContent(panelLayout);
    imagePanel.addComponent(diagram);
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) Panel(com.vaadin.ui.Panel) DetailPanel(org.activiti.explorer.ui.custom.DetailPanel) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) StreamResource(com.vaadin.terminal.StreamResource) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) StreamSource(com.vaadin.terminal.StreamResource.StreamSource) Embedded(com.vaadin.ui.Embedded) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 2 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class DbSchemaDrop method main.

public static void main(String[] args) {
    ProcessEngineImpl processEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
    CommandExecutor commandExecutor = processEngine.getProcessEngineConfiguration().getCommandExecutor();
    CommandConfig config = new CommandConfig().transactionNotSupported();
    commandExecutor.execute(config, new Command<Object>() {

        public Object execute(CommandContext commandContext) {
            commandContext.getSession(DbSqlSession.class).dbSchemaDrop();
            return null;
        }
    });
}
Also used : CommandConfig(org.activiti.engine.impl.interceptor.CommandConfig) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Example 3 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class AdminRunningInstancesPanel method addProcessImage.

protected void addProcessImage(ProcessDefinition processDefinition, HistoricProcessInstance processInstance) {
    if (currentEmbedded != null) {
        mainPanel.removeComponent(currentEmbedded);
    }
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId());
    // Only show when graphical notation is defined
    if (processDefinitionEntity != null && processDefinitionEntity.isGraphicalNotationDefined()) {
        if (imageHeader == null) {
            imageHeader = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
            imageHeader.addStyleName(ExplorerLayout.STYLE_H3);
            imageHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
            imageHeader.addStyleName(ExplorerLayout.STYLE_NO_LINE);
            addDetailComponent(imageHeader);
        }
        ProcessEngineConfiguration processEngineConfig = ((ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine()).getProcessEngineConfiguration();
        ProcessDiagramGenerator diagramGenerator = processEngineConfig.getProcessDiagramGenerator();
        StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder().buildStreamResource(processInstance.getId(), processInstance.getProcessDefinitionId(), repositoryService, runtimeService, diagramGenerator, processEngineConfig);
        currentEmbedded = new Embedded(null, diagram);
        currentEmbedded.setType(Embedded.TYPE_IMAGE);
        addDetailComponent(currentEmbedded);
    }
}
Also used : ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) StreamResource(com.vaadin.terminal.StreamResource) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) Embedded(com.vaadin.ui.Embedded) ProcessDefinitionImageStreamResourceBuilder(org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Example 4 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class PlaybackRunTest method testProcessInstanceStartEvents.

@Test
public void testProcessInstanceStartEvents() throws Exception {
    recordEvents();
    final SimpleSimulationRun.Builder builder = new SimpleSimulationRun.Builder();
    // init simulation run
    Clock clock = new ThreadLocalClock(new DefaultClockFactory());
    ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
    config.setClock(clock);
    SimulationProcessEngineFactory simulationProcessEngineFactory = new SimulationProcessEngineFactory(config);
    final ProcessEngineImpl simProcessEngine = simulationProcessEngineFactory.getObject();
    builder.processEngine(simProcessEngine).eventCalendar((new SimpleEventCalendarFactory(clock, new SimulationEventComparator(), listener.getSimulationEvents())).getObject()).eventHandlers(getHandlers());
    SimpleSimulationRun simRun = builder.build();
    simRun.execute(new NoExecutionVariableScope());
    checkStatus(simProcessEngine);
    simProcessEngine.getProcessEngineConfiguration().setDatabaseSchemaUpdate("create-drop");
    simProcessEngine.close();
    ProcessEngines.destroy();
}
Also used : NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) DefaultClockFactory(org.activiti.crystalball.simulator.impl.clock.DefaultClockFactory) ThreadLocalClock(org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock) Clock(org.activiti.engine.runtime.Clock) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ThreadLocalClock(org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl) Test(org.junit.Test)

Example 5 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class ReplayEventLogTest method testProcessInstanceStartEvents.

@Test
public void testProcessInstanceStartEvents() throws Exception {
    ProcessEngineImpl processEngine = initProcessEngine();
    TaskService taskService = processEngine.getTaskService();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    ManagementService managementService = processEngine.getManagementService();
    HistoryService historyService = processEngine.getHistoryService();
    // record events
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(TEST_VARIABLE, TEST_VALUE);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);
    Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
    TimeUnit.MILLISECONDS.sleep(50);
    variables = new HashMap<String, Object>();
    variables.put(TASK_TEST_VARIABLE, TASK_TEST_VALUE);
    taskService.complete(task.getId(), variables);
    // transform log events
    List<EventLogEntry> eventLogEntries = managementService.getEventLogEntries(null, null);
    EventLogTransformer transformer = new EventLogTransformer(getTransformers());
    List<SimulationEvent> simulationEvents = transformer.transform(eventLogEntries);
    SimpleEventCalendar eventCalendar = new SimpleEventCalendar(processEngine.getProcessEngineConfiguration().getClock(), new SimulationEventComparator());
    eventCalendar.addEvents(simulationEvents);
    // replay process instance run
    final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, eventCalendar, getReplayHandlers(processInstance.getId()));
    simRun.init(new NoExecutionVariableScope());
    // original process is finished - there should not be any running process instance/task
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
    simRun.step();
    // replay process was started
    ProcessInstance replayProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).singleResult();
    assertNotNull(replayProcessInstance);
    assertTrue(replayProcessInstance.getId().equals(processInstance.getId()) == false);
    assertEquals(TEST_VALUE, runtimeService.getVariable(replayProcessInstance.getId(), TEST_VARIABLE));
    // there should be one task
    assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
    simRun.step();
    // userTask was completed - replay process was finished
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
    HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(replayProcessInstance.getId()).variableName(TASK_TEST_VARIABLE).singleResult();
    assertNotNull(variableInstance);
    assertEquals(TASK_TEST_VALUE, variableInstance.getValue());
    // close simulation
    simRun.close();
    processEngine.close();
    ProcessEngines.destroy();
}
Also used : ReplaySimulationRun(org.activiti.crystalball.simulator.ReplaySimulationRun) Task(org.activiti.engine.task.Task) RuntimeService(org.activiti.engine.RuntimeService) HashMap(java.util.HashMap) TaskService(org.activiti.engine.TaskService) EventLogEntry(org.activiti.engine.event.EventLogEntry) SimpleEventCalendar(org.activiti.crystalball.simulator.SimpleEventCalendar) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) HistoryService(org.activiti.engine.HistoryService) SimulationEventComparator(org.activiti.crystalball.simulator.SimulationEventComparator) EventLogTransformer(org.activiti.crystalball.simulator.delegate.event.impl.EventLogTransformer) ManagementService(org.activiti.engine.ManagementService) SimulationDebugger(org.activiti.crystalball.simulator.SimulationDebugger) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) SimulationEvent(org.activiti.crystalball.simulator.SimulationEvent) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl) Test(org.junit.Test)

Aggregations

ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)14 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)4 NoExecutionVariableScope (org.activiti.engine.impl.el.NoExecutionVariableScope)4 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)3 CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)3 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)3 ProcessDiagramGenerator (org.activiti.image.ProcessDiagramGenerator)3 Test (org.junit.Test)3 StreamResource (com.vaadin.terminal.StreamResource)2 Embedded (com.vaadin.ui.Embedded)2 HashMap (java.util.HashMap)2 ReplaySimulationRun (org.activiti.crystalball.simulator.ReplaySimulationRun)2 SimulationDebugger (org.activiti.crystalball.simulator.SimulationDebugger)2 DefaultClockFactory (org.activiti.crystalball.simulator.impl.clock.DefaultClockFactory)2 ThreadLocalClock (org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock)2 ActivitiException (org.activiti.engine.ActivitiException)2 RuntimeService (org.activiti.engine.RuntimeService)2 TaskService (org.activiti.engine.TaskService)2 CommandConfig (org.activiti.engine.impl.interceptor.CommandConfig)2 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)2