Example #1
0
 @Test
 public void createRable2() {
   ProcessEngineConfiguration processEngineConfiguration =
       ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
   ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
   System.out.println("processEngine" + processEngine);
 }
 @Test
 public void testCreateFromResource_2() {
   ProcessEngineConfiguration config =
       ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(
           "my-activiti2.xml", "test");
   System.out.println(config.getProcessEngineName());
 }
  @Test
  public void should_initialize_with_prebuild_engine() {
    final ProcessEngine preBuildProcessEngine = processEngineConfiguration.buildProcessEngine();

    delegate = new ProcessEngineDelegate(preBuildProcessEngine);
    assertThat(delegate.isInitialized(), is(true));
  }
  @Test
  public void should_fail_to_close_more_than_once() {
    final ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
    delegate = new ProcessEngineDelegate(processEngine);
    delegate.closeProcessEngine();

    thrown.expect(IllegalStateException.class);
    delegate.closeProcessEngine();
  }
 protected void initializeProcessEngine() {
   if (cachedProcessEngine == null) {
     cachedProcessEngine =
         ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(PPI_ENGINE_CONFIG)
             .buildProcessEngine();
     if (cachedProcessEngine == null) {
       throw new ActivitiException("no default process engine available");
     }
   }
   processEngine = cachedProcessEngine;
 }
  @Test
  public void should_fail_to_re_initialize_engine_after_close_when_configuration() {

    final ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
    delegate = new ProcessEngineDelegate(processEngine);

    delegate.closeProcessEngine();
    assertThat(delegate.isInitialized(), is(false));

    delegate.initProcessEngine();
    assertThat(delegate.isInitialized(), is(true));
  }
Example #7
0
 /**
  * 使用代码 @Description:这里用一句话描述这个方法的作用 void 返回值描述
  *
  * @author hjx
  * @create_date 2015年10月17日 下午4:59:30
  */
 @Test
 public void createTable() {
   ProcessEngineConfiguration processEngineConfiguration =
       ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
   // 连接数据库
   processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver");
   processEngineConfiguration.setJdbcUrl(
       "jdbc:mysql://localhost:3306/activiti2?useUnicode=true&characterEncoding=utf8");
   processEngineConfiguration.setJdbcUsername("root");
   processEngineConfiguration.setJdbcPassword("123");
   processEngineConfiguration.setDatabaseSchemaUpdate(
       ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
   // 创建表
   ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
   System.err.println("processEngine" + processEngine);
 }
  @BeforeClass
  public static void init() throws FileNotFoundException {
    servers = new AllServers();
    servers.start();

    // Create Activiti process engine
    processEngine =
        ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
            .buildProcessEngine();

    RepositoryService repositoryService = processEngine.getRepositoryService();
    DeploymentBuilder builder = repositoryService.createDeployment();
    String xmlFile = "PaymentProcess.bpmn";
    builder.addClasspathResource("diagrams/" + xmlFile);
    builder.name(xmlFile);
    builder.deploy();
    runtimeService = processEngine.getRuntimeService();
  }
  @BeforeClass
  public static void init() {
    MailServiceImpl service = new MailServiceImpl();
    service.setRecipient("wfm@localhost");

    service.setMessage("hello");
    service.sendMessage();
    // Create Activiti process engine
    processEngine =
        ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
            .setMailServerPort(1025)
            .buildProcessEngine();
    runtimeService = processEngine.getRuntimeService();
    RepositoryService repositoryService = processEngine.getRepositoryService();
    DeploymentBuilder builder = repositoryService.createDeployment();
    String xmlFile = "EventTest.bpmn";
    builder.addClasspathResource("diagrams/" + xmlFile);
    builder.name(xmlFile);
    builder.deploy();
  }
  @Override
  public void loadBus(ServletConfig servletConfig) throws ServletException {
    super.loadBus(servletConfig);

    // TODO: Hacky first version to get default Process Engine
    ProcessEngine processEngine =
        ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault()
            .buildProcessEngine();

    Bus bus = getBus();
    BusFactory.setDefaultBus(bus);
    Endpoint.publish("/RuntimeService", new RuntimeWebServiceImpl(processEngine));

    // You can als use the simple frontend API to do this
    ServerFactoryBean factory = new ServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceClass(RuntimeWebServiceImpl.class);
    factory.setAddress("/RuntimeService");
    factory.create();
  }
  protected void addProcessImage() {
    ProcessDefinitionEntity processDefinitionEntity =
        (ProcessDefinitionEntity)
            ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(processDefinition.getId());

    // Only show when graphical notation is defined
    if (processDefinitionEntity != null) {

      boolean didDrawImage = false;

      if (ExplorerApp.get().isUseJavascriptDiagram()) {
        try {

          final InputStream definitionStream =
              repositoryService.getResourceAsStream(
                  processDefinition.getDeploymentId(), processDefinition.getResourceName());
          XMLInputFactory xif = XMLInputFactory.newInstance();
          XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream);
          BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

          if (bpmnModel.getFlowLocationMap().size() > 0) {

            int maxX = 0;
            int maxY = 0;
            for (String key : bpmnModel.getLocationMap().keySet()) {
              GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key);
              double elementX = graphicInfo.getX() + graphicInfo.getWidth();
              if (maxX < elementX) {
                maxX = (int) elementX;
              }
              double elementY = graphicInfo.getY() + graphicInfo.getHeight();
              if (maxY < elementY) {
                maxY = (int) elementY;
              }
            }

            Panel imagePanel = new Panel(); // using panel for scrollbars
            imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
            imagePanel.setWidth(100, UNITS_PERCENTAGE);
            imagePanel.setHeight(100, UNITS_PERCENTAGE);
            URL explorerURL = ExplorerApp.get().getURL();
            URL url =
                new URL(
                    explorerURL.getProtocol(),
                    explorerURL.getHost(),
                    explorerURL.getPort(),
                    explorerURL.getPath().replace("/ui", "")
                        + "diagram-viewer/index.html?processDefinitionId="
                        + processDefinition.getId()
                        + "&processInstanceId="
                        + processInstance.getId());
            Embedded browserPanel = new Embedded("", new ExternalResource(url));
            browserPanel.setType(Embedded.TYPE_BROWSER);
            browserPanel.setWidth(maxX + 350 + "px");
            browserPanel.setHeight(maxY + 220 + "px");

            HorizontalLayout panelLayoutT = new HorizontalLayout();
            panelLayoutT.setSizeUndefined();
            imagePanel.setContent(panelLayoutT);
            imagePanel.addComponent(browserPanel);

            panelLayout.addComponent(imagePanel);

            didDrawImage = true;
          }

        } catch (Exception e) {
          LOGGER.error("Error loading process diagram component", e);
        }
      }

      if (!didDrawImage && processDefinitionEntity.isGraphicalNotationDefined()) {
        ProcessEngineConfiguration processEngineConfiguration =
            ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration();
        ProcessDiagramGenerator diagramGenerator =
            processEngineConfiguration.getProcessDiagramGenerator();
        StreamResource diagram =
            new ProcessDefinitionImageStreamResourceBuilder()
                .buildStreamResource(
                    processInstance, repositoryService, runtimeService, diagramGenerator);

        if (diagram != null) {
          Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM));
          header.addStyleName(ExplorerLayout.STYLE_H3);
          header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
          header.addStyleName(ExplorerLayout.STYLE_NO_LINE);
          panelLayout.addComponent(header);

          Embedded embedded = new Embedded(null, diagram);
          embedded.setType(Embedded.TYPE_IMAGE);
          embedded.setSizeUndefined();

          Panel imagePanel = new Panel(); // using panel for scrollbars
          imagePanel.setScrollable(true);
          imagePanel.addStyleName(Reindeer.PANEL_LIGHT);
          imagePanel.setWidth(100, UNITS_PERCENTAGE);
          imagePanel.setHeight(100, UNITS_PERCENTAGE);

          HorizontalLayout panelLayoutT = new HorizontalLayout();
          panelLayoutT.setSizeUndefined();
          imagePanel.setContent(panelLayoutT);
          imagePanel.addComponent(embedded);

          panelLayout.addComponent(imagePanel);
        }
      }
    }
  }
 @Test
 public void testCreateFromResource_1() {
   ProcessEngineConfiguration config =
       ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("my-activiti1.xml");
 }