Search in sources :

Example 6 with ProcessEngineConfiguration

use of org.activiti.engine.ProcessEngineConfiguration 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 7 with ProcessEngineConfiguration

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

the class EventSubscriptionEntity method scheduleEventAsync.

protected void scheduleEventAsync(Serializable payload) {
    final CommandContext commandContext = Context.getCommandContext();
    MessageEntity message = new MessageEntity();
    message.setJobHandlerType(ProcessEventJobHandler.TYPE);
    message.setJobHandlerConfiguration(id);
    message.setTenantId(getTenantId());
    GregorianCalendar expireCal = new GregorianCalendar();
    ProcessEngineConfiguration processEngineConfig = Context.getCommandContext().getProcessEngineConfiguration();
    expireCal.setTime(processEngineConfig.getClock().getCurrentTime());
    expireCal.add(Calendar.SECOND, processEngineConfig.getLockTimeAsyncJobWaitTime());
    message.setLockExpirationTime(expireCal.getTime());
    // TODO: support payload
    //    if(payload != null) {
    //      message.setEventPayload(payload);
    //    }
    commandContext.getJobEntityManager().send(message);
}
Also used : ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) GregorianCalendar(java.util.GregorianCalendar)

Example 8 with ProcessEngineConfiguration

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

the class ExecutionEntity method scheduleAtomicOperationAsync.

protected void scheduleAtomicOperationAsync(AtomicOperation executionOperation) {
    MessageEntity message = new MessageEntity();
    message.setExecution(this);
    message.setExclusive(getActivity().isExclusive());
    message.setJobHandlerType(AsyncContinuationJobHandler.TYPE);
    // At the moment, only AtomicOperationTransitionCreateScope can be performed asynchronously,
    // so there is no need to pass it to the handler
    GregorianCalendar expireCal = new GregorianCalendar();
    ProcessEngineConfiguration processEngineConfig = Context.getCommandContext().getProcessEngineConfiguration();
    expireCal.setTime(processEngineConfig.getClock().getCurrentTime());
    expireCal.add(Calendar.SECOND, processEngineConfig.getLockTimeAsyncJobWaitTime());
    message.setLockExpirationTime(expireCal.getTime());
    // Inherit tenant id (if applicable)
    if (getTenantId() != null) {
        message.setTenantId(getTenantId());
    }
    Context.getCommandContext().getJobEntityManager().send(message);
}
Also used : ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) GregorianCalendar(java.util.GregorianCalendar)

Example 9 with ProcessEngineConfiguration

use of org.activiti.engine.ProcessEngineConfiguration 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 10 with ProcessEngineConfiguration

use of org.activiti.engine.ProcessEngineConfiguration in project tutorials by eugenp.

the class ProcessEngineCreationIntegrationTest method givenDifferentBeanNameInXMLConfig_whenGetProcessEngineConfig_thenGotResult.

@Test
public void givenDifferentBeanNameInXMLConfig_whenGetProcessEngineConfig_thenGotResult() {
    ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("my.activiti.cfg.xml", "myProcessEngineConfiguration");
    ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
    assertNotNull(processEngine);
    assertEquals("baeldung", processEngine.getProcessEngineConfiguration().getJdbcUsername());
}
Also used : ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) ProcessEngine(org.activiti.engine.ProcessEngine) Test(org.junit.Test)

Aggregations

ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)24 ProcessEngine (org.activiti.engine.ProcessEngine)7 Test (org.junit.Test)7 Date (java.util.Date)4 ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)4 ProcessDiagramGenerator (org.activiti.image.ProcessDiagramGenerator)4 StreamResource (com.vaadin.terminal.StreamResource)3 Embedded (com.vaadin.ui.Embedded)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Label (com.vaadin.ui.Label)2 Panel (com.vaadin.ui.Panel)2 URL (java.net.URL)2 GregorianCalendar (java.util.GregorianCalendar)2 MBeanServerConnection (javax.management.MBeanServerConnection)2 ObjectName (javax.management.ObjectName)2 JMXConnector (javax.management.remote.JMXConnector)2 JMXServiceURL (javax.management.remote.JMXServiceURL)2 ActivitiException (org.activiti.engine.ActivitiException)2 RepositoryService (org.activiti.engine.RepositoryService)2 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)2