예제 #1
0
  public void testProcessEngineInfo() {

    List<ProcessEngineInfo> processEngineInfos = ProcessEngines.getProcessEngineInfos();
    assertEquals(1, processEngineInfos.size());

    ProcessEngineInfo processEngineInfo = processEngineInfos.get(0);
    assertNull(processEngineInfo.getException());
    assertNotNull(processEngineInfo.getName());
    assertNotNull(processEngineInfo.getResourceUrl());

    ProcessEngine processEngine = ProcessEngines.getProcessEngine(ProcessEngines.NAME_DEFAULT);
    assertNotNull(processEngine);
  }
 protected void closeProcessEngine() {
   ProcessEngines.unregister(activitiProcessEngine);
   JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
   if (jobExecutor != null && jobExecutor.isActive()) {
     jobExecutor.shutdown();
   }
 }
예제 #3
0
 static {
   if (beanFactory == null) {
     ProcessEngineImpl processEngine =
         (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
     beanFactory = (Map) processEngine.getProcessEngineConfiguration().getBeans();
   }
 }
예제 #4
0
  public TaskListHeader() {
    this.i18nManager = ExplorerApp.get().getI18nManager();
    this.taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
    this.verlayout = new VerticalLayout();

    addStyleName(Reindeer.PANEL_LIGHT);
    addStyleName(ExplorerLayout.STYLE_SEARCHBOX);

    layout = new HorizontalLayout();
    layout.setHeight(36, UNITS_PIXELS);
    layout.setWidth(99, UNITS_PERCENTAGE); // 99, otherwise the Panel will
    // display scrollbars
    layout.setSpacing(true);
    layout.setMargin(false, true, false, true);
    verlayout.addComponent(layout);

    inLayout = new HorizontalLayout();
    inLayout.setHeight(36, UNITS_PIXELS);
    inLayout.setWidth(99, UNITS_PERCENTAGE); // 99, otherwise the Panel will
    // display scrollbars
    inLayout.setSpacing(true);
    inLayout.setMargin(false, true, false, true);

    verlayout.addComponent(layout);
    verlayout.addComponent(inLayout);

    setContent(verlayout);

    initInputField();
    initKeyboardListener();
    // initSortMenu();
  }
예제 #5
0
 /** @param args */
 public static void main(String[] args) {
   // 创建流程引擎
   ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
   // 得到流程存储服务组件
   RepositoryService repositoryService = engine.getRepositoryService();
   // 得到运行时服务组件
   RuntimeService runtimeService = engine.getRuntimeService();
   // 获取流程任务组件
   TaskService taskService = engine.getTaskService();
   // 部署流程文件
   repositoryService
       .createDeployment()
       .addClasspathResource("bpmn11.5/SignalBoundaryEvent.bpmn")
       .deploy();
   // 启动2个流程实例
   ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("sbProcess");
   ProcessInstance pi2 = runtimeService.startProcessInstanceByKey("sbProcess");
   // 查找第一个流程实例中签订合同的任务
   Task pi1Task = taskService.createTaskQuery().processInstanceId(pi1.getId()).singleResult();
   taskService.complete(pi1Task.getId());
   // 查找第二个流程实例中签订合同的任务
   Task pi2Task = taskService.createTaskQuery().processInstanceId(pi2.getId()).singleResult();
   taskService.complete(pi2Task.getId());
   // 此时执行流到达确认合同任务,发送一次信号
   runtimeService.signalEventReceived("contactChangeSignal");
   // 查询全部的任务
   List<Task> tasks = taskService.createTaskQuery().list();
   // 输出结果
   for (Task task : tasks) {
     System.out.println(task.getProcessInstanceId() + "---" + task.getName());
   }
 }
예제 #6
0
 public EditTodoPopupWindow(BeanItem<Todo> currentBeanItem, String projectId) {
   this.currentBeanItem = currentBeanItem;
   this.projectId = projectId;
   todoService = (TodoService) ViewToolManager.getBean("todoService");
   teamService = (TeamService) SpringApplicationContextUtil.getContext().getBean("teamService");
   identityService = ProcessEngines.getDefaultProcessEngine().getIdentityService();
   initUI();
 }
 private void stopProcessEngine() {
   log.info("*** stopProcessEngine ***");
   if (processEngine != null) {
     ProcessEngines.unregister(processEngine);
     processEngine.close();
     processEngine = null;
   }
 }
예제 #8
0
  public DeploymentDetailPanel(String deploymentId, DeploymentPage parent) {
    this.repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
    this.i18nManager = ExplorerApp.get().getI18nManager();
    this.viewManager = ExplorerApp.get().getViewManager();

    this.deployment =
        repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
    this.parent = parent;

    init();
  }
  public ProcessInstanceDetailPanel(
      String processInstanceId, AbstractTablePage processInstancePage) {

    // Member initialization
    this.processInstancePage = processInstancePage;

    this.runtimeService = ProcessEngines.getDefaultProcessEngine().getRuntimeService();
    this.repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
    this.taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
    this.historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService();
    this.i18nManager = ExplorerApp.get().getI18nManager();
    this.variableRendererManager = ExplorerApp.get().getVariableRendererManager();

    this.processInstance = getProcessInstance(processInstanceId);
    this.processDefinition = getProcessDefinition(processInstance.getProcessDefinitionId());
    this.historicProcessInstance = getHistoricProcessInstance(processInstanceId);
    this.identityService = ProcessEngines.getDefaultProcessEngine().getIdentityService();

    init();
  }
예제 #10
0
  public void attemptLogin(String username, String password) {
    /*
    if (getIdentityService().checkPassword(username, password)) {
    	getIdentityService().setAuthenticatedUserId(username);
    	fireViewEvent(new UserLoggedInEvent(getView(), username));
    } else {
    	getView().clearForm();
    	getView().showLoginFailed();
    }
    */

    RepositoryService service = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
  }
예제 #11
0
 @Test
 public void testSetAssignee() {
   ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
   IdentityService identityService = engine.getIdentityService();
   User user = creatUser(identityService, "user1", "张三", "last", "*****@*****.**", "123");
   TaskService taskService = engine.getTaskService();
   Task task1 = taskService.newTask("task1");
   task1.setName("申请任务");
   taskService.saveTask(task1);
   taskService.setAssignee(task1.getId(), user.getId());
   System.out.println(
       "用户张三受理的任务数量:" + taskService.createTaskQuery().taskAssignee(user.getId()).count());
 }
 public void startService() {
   try {
     Server.createTcpServer(new String[] {"-tcpAllowOthers"}).start();
   } catch (SQLException e) {
     e.printStackTrace();
   }
   processEngine = ProcessEngines.getDefaultProcessEngine();
   processEngine
       .getRepositoryService()
       .createDeployment()
       .addClasspathResource("process/activiti/humanTask.xml.bpmn20.xml")
       .deploy();
 }
예제 #13
0
  public NewCasePopupWindow() {
    this.taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
    this.i18nManager = ExplorerApp.get().getI18nManager();

    setModal(true);
    center();
    setResizable(false);
    setCaption(i18nManager.getMessage(Messages.TASK_NEW));
    addStyleName(Reindeer.WINDOW_LIGHT);
    setWidth(430, UNITS_PIXELS);
    setHeight(320, UNITS_PIXELS);

    initForm();
    initCreateTaskButton();
    initEnterKeyListener();
  }
예제 #14
0
  /**
   * 读取带跟踪的流程图片
   *
   * @throws Exception
   */
  @RequestMapping(params = "traceImage")
  public void traceImage(
      @RequestParam("processInstanceId") String processInstanceId, HttpServletResponse response)
      throws Exception {

    Command<InputStream> cmd = new HistoryProcessInstanceDiagramCmd(processInstanceId);

    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    InputStream is = processEngine.getManagementService().executeCommand(cmd);

    int len = 0;
    byte[] b = new byte[1024];

    while ((len = is.read(b, 0, 1024)) != -1) {
      response.getOutputStream().write(b, 0, len);
    }
  }
예제 #15
0
 @Test
 public void test() {
   ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
   RepositoryService repositoryService = engine.getRepositoryService();
   RuntimeService runtimeService = engine.getRuntimeService();
   TaskService taskService = engine.getTaskService();
   repositoryService.createDeployment().addClasspathResource("bpmn/first.bpmn").deploy();
   runtimeService.startProcessInstanceByKey("process1");
   Task task = taskService.createTaskQuery().singleResult();
   System.out.println("第一个任务完成前,当前任务名称:" + task.getName());
   taskService.complete(task.getId());
   task = taskService.createTaskQuery().singleResult();
   System.out.println("第二个任务完成前,当前任务名称:" + task.getName());
   taskService.complete(task.getId());
   task = taskService.createTaskQuery().singleResult();
   System.out.println("流程结束后,查找任务:" + task);
 }
  public FileAttachmentEditorComponent(
      Attachment attachment, String taskId, String processInstanceId) {
    this.attachment = attachment;
    this.taskId = taskId;
    this.processInstanceId = processInstanceId;

    this.i18nManager = ExplorerApp.get().getI18nManager();
    taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();

    form = new Form();
    form.setDescription(i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_FILE_HELP));
    setSizeFull();
    addComponent(form);
    initSuccessIndicator();
    initFileUpload();
    initName();
    initDescription();
  }
  @Override
  public Object convertFormValueToModelValue(String propertyValue) {
    if (propertyValue != null) {
      ProcessDefinition processDefinition =
          ProcessEngines.getDefaultProcessEngine()
              .getRepositoryService()
              .createProcessDefinitionQuery()
              .processDefinitionId(propertyValue)
              .singleResult();

      if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException(
            "Process definition with id " + propertyValue + " does not exist",
            ProcessDefinitionEntity.class);
      }

      return processDefinition;
    }
    return null;
  }
예제 #18
0
 public static void main(String[] args) throws Exception {
   // 创建流程引擎
   ProcessEngineImpl engine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
   // 启动JobExecutor
   engine.getProcessEngineConfiguration().getJobExecutor().start();
   // 得到流程存储服务组件
   RepositoryService repositoryService = engine.getRepositoryService();
   RuntimeService runtimeService = engine.getRuntimeService();
   // 部署流程文件
   repositoryService
       .createDeployment()
       .addClasspathResource("bpmn11.3/TimerStartEvent.bpmn")
       .deploy();
   // 一分钟后关闭JobExecutor
   Thread.sleep(1000 * 60);
   engine.getProcessEngineConfiguration().getJobExecutor().shutdown();
   // 查询流程实例
   List<ProcessInstance> ints = runtimeService.createProcessInstanceQuery().list();
   System.out.println(ints.size());
 }
예제 #19
0
 /**
  * Returns the process engine.
  *
  * @return The process engine
  */
 protected ProcessEngine getProcessEngine() {
   return ProcessEngines.getProcessEngine(config.getEngine());
 }
예제 #20
0
/** @author Joram Barrez */
public class DeleteDeploymentPopupWindow extends PopupWindow {

  private static final long serialVersionUID = 1L;

  protected transient RepositoryService repositoryService =
      ProcessEngines.getDefaultProcessEngine().getRepositoryService();
  protected transient RuntimeService runtimeService =
      ProcessEngines.getDefaultProcessEngine().getRuntimeService();
  protected I18nManager i18nManager;
  protected DeploymentPage deploymentPage;
  protected VerticalLayout windowLayout;
  protected Deployment deployment;

  public DeleteDeploymentPopupWindow(Deployment deployment, DeploymentPage deploymentPage) {
    this.deployment = deployment;
    this.deploymentPage = deploymentPage;
    this.windowLayout = (VerticalLayout) getContent();
    this.i18nManager = ExplorerApp.get().getI18nManager();

    initWindow();
    addDeleteWarning();
    addButtons();
  }

  protected void initWindow() {
    windowLayout.setSpacing(true);
    addStyleName(Reindeer.WINDOW_LIGHT);
    setModal(true);
    center();
    setCaption(
        i18nManager.getMessage(Messages.DEPLOYMENT_DELETE_POPUP_CAPTION, deployment.getName()));
  }

  protected void addDeleteWarning() {
    List<ProcessDefinition> processDefinitions =
        repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();

    int nrOfProcessInstances = 0;
    for (ProcessDefinition processDefinition : processDefinitions) {
      nrOfProcessInstances +=
          runtimeService
              .createProcessInstanceQuery()
              .processDefinitionId(processDefinition.getId())
              .count();
    }

    if (nrOfProcessInstances == 0) {
      Label noInstancesLabel = new Label(i18nManager.getMessage(Messages.DEPLOYMENT_NO_INSTANCES));
      noInstancesLabel.addStyleName(Reindeer.LABEL_SMALL);
      addComponent(noInstancesLabel);
    } else {
      HorizontalLayout warningLayout = new HorizontalLayout();
      warningLayout.setSpacing(true);
      addComponent(warningLayout);

      Embedded warningIcon = new Embedded(null, Images.WARNING);
      warningIcon.setType(Embedded.TYPE_IMAGE);
      warningLayout.addComponent(warningIcon);

      Label warningLabel =
          new Label(
              i18nManager.getMessage(
                  Messages.DEPLOYMENT_DELETE_POPUP_WARNING, nrOfProcessInstances),
              Label.CONTENT_XHTML);
      warningLabel.setSizeUndefined();
      warningLabel.addStyleName(Reindeer.LABEL_SMALL);
      warningLayout.addComponent(warningLabel);
    }

    // Some empty space
    Label emptySpace = new Label("&nbsp;", Label.CONTENT_XHTML);
    addComponent(emptySpace);
  }

  protected void addButtons() {
    // Cancel
    Button cancelButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
    cancelButton.addStyleName(Reindeer.BUTTON_SMALL);
    cancelButton.addListener(
        new ClickListener() {
          public void buttonClick(ClickEvent event) {
            close();
          }
        });

    // Delete
    Button deleteButton =
        new Button(i18nManager.getMessage(Messages.DEPLOYMENT_DELETE_POPUP_DELETE_BUTTON));
    deleteButton.addStyleName(Reindeer.BUTTON_SMALL);
    deleteButton.addListener(
        new ClickListener() {
          public void buttonClick(ClickEvent event) {
            // Delete deployment, close popup window and refresh deployment list
            repositoryService.deleteDeployment(deployment.getId(), true);
            close();
            deploymentPage.refreshSelectNext();
          }
        });

    // Alignment
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(cancelButton);
    buttonLayout.addComponent(deleteButton);
    addComponent(buttonLayout);
    windowLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
  }
}
/** @author Tijs Rademakers */
public class ConvertProcessDefinitionPopupWindow extends PopupWindow
    implements ModelDataJsonConstants {

  private static final long serialVersionUID = 1L;

  protected transient RepositoryService repositoryService =
      ProcessEngines.getDefaultProcessEngine().getRepositoryService();
  protected transient RuntimeService runtimeService =
      ProcessEngines.getDefaultProcessEngine().getRuntimeService();

  protected I18nManager i18nManager;
  protected NotificationManager notificationManager;
  protected VerticalLayout windowLayout;
  protected ProcessDefinition processDefinition;

  public ConvertProcessDefinitionPopupWindow(ProcessDefinition processDefinition) {
    this.processDefinition = processDefinition;
    this.windowLayout = (VerticalLayout) getContent();
    this.i18nManager = ExplorerApp.get().getI18nManager();
    this.notificationManager = ExplorerApp.get().getNotificationManager();

    initWindow();
    addConvertWarning();
    addButtons();
  }

  protected void initWindow() {
    windowLayout.setSpacing(true);
    addStyleName(Reindeer.WINDOW_LIGHT);
    setModal(true);
    center();

    String name = processDefinition.getName();
    if (StringUtils.isEmpty(name)) {
      name = processDefinition.getKey();
    }
    setCaption(i18nManager.getMessage(Messages.PROCESS_CONVERT_POPUP_CAPTION, name));
  }

  protected void addConvertWarning() {
    Label convertLabel = new Label(i18nManager.getMessage(Messages.PROCESS_CONVERT_POPUP_MESSAGE));
    convertLabel.addStyleName(Reindeer.LABEL_SMALL);
    addComponent(convertLabel);

    // Some empty space
    Label emptySpace = new Label("&nbsp;", Label.CONTENT_XHTML);
    addComponent(emptySpace);
  }

  protected void addButtons() {
    // Cancel
    Button cancelButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
    cancelButton.addStyleName(Reindeer.BUTTON_SMALL);
    cancelButton.addListener(
        new ClickListener() {

          private static final long serialVersionUID = 1L;

          public void buttonClick(ClickEvent event) {
            close();
          }
        });

    // Convert
    Button convertButton =
        new Button(i18nManager.getMessage(Messages.PROCESS_CONVERT_POPUP_CONVERT_BUTTON));
    convertButton.addStyleName(Reindeer.BUTTON_SMALL);
    convertButton.addListener(
        new ClickListener() {

          private static final long serialVersionUID = 1L;

          public void buttonClick(ClickEvent event) {

            try {
              InputStream bpmnStream =
                  repositoryService.getResourceAsStream(
                      processDefinition.getDeploymentId(), processDefinition.getResourceName());
              XMLInputFactory xif = XMLInputFactory.newInstance();
              InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8");
              XMLStreamReader xtr = xif.createXMLStreamReader(in);
              BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);

              if (bpmnModel.getMainProcess() == null
                  || bpmnModel.getMainProcess().getId() == null) {
                notificationManager.showErrorNotification(
                    Messages.MODEL_IMPORT_FAILED,
                    i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMN_EXPLANATION));
              } else {

                if (bpmnModel.getLocationMap().size() == 0) {
                  notificationManager.showErrorNotification(
                      Messages.MODEL_IMPORT_INVALID_BPMNDI,
                      i18nManager.getMessage(Messages.MODEL_IMPORT_INVALID_BPMNDI_EXPLANATION));
                } else {

                  BpmnJsonConverter converter = new BpmnJsonConverter();
                  ObjectNode modelNode = converter.convertToJson(bpmnModel);
                  Model modelData = repositoryService.newModel();

                  ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
                  modelObjectNode.put(MODEL_NAME, processDefinition.getName());
                  modelObjectNode.put(MODEL_REVISION, 1);
                  modelObjectNode.put(MODEL_DESCRIPTION, processDefinition.getDescription());
                  modelData.setMetaInfo(modelObjectNode.toString());
                  modelData.setName(processDefinition.getName());

                  repositoryService.saveModel(modelData);

                  repositoryService.addModelEditorSource(
                      modelData.getId(), modelNode.toString().getBytes("utf-8"));

                  close();
                  ExplorerApp.get()
                      .getViewManager()
                      .showEditorProcessDefinitionPage(modelData.getId());

                  URL explorerURL = ExplorerApp.get().getURL();
                  URL url =
                      new URL(
                          explorerURL.getProtocol(),
                          explorerURL.getHost(),
                          explorerURL.getPort(),
                          explorerURL.getPath().replace("/ui", "")
                              + "service/editor?id="
                              + modelData.getId());
                  ExplorerApp.get().getMainWindow().open(new ExternalResource(url));
                }
              }

            } catch (Exception e) {
              notificationManager.showErrorNotification("error", e);
            }
          }
        });

    // Alignment
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(cancelButton);
    buttonLayout.addComponent(convertButton);
    addComponent(buttonLayout);
    windowLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
  }
}
 private void initializeProcessEngine() {
   processEngine = TestHelper.getProcessEngine(configurationResource);
   ProcessEnginesRest.init();
   ProcessEngines.registerProcessEngine(processEngine);
 }
예제 #23
0
 public DefaultViewManager() {
   this.taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
   this.historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService();
   this.identityService = ProcessEngines.getDefaultProcessEngine().getIdentityService();
 }
  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);
        }
      }
    }
  }
예제 #25
0
/**
 * @Package cn.helloworld @Description:用一句话描述该文件做什么
 *
 * @author hjx
 * @date 2015年10月17日 下午4:39:06
 * @version V1.0
 */
public class HelloWorld {
  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

  /** 部署流程定义 */
  @Test
  public void deploymentProcessDefinition() {
    Deployment deployment =
        processEngine
            .getRepositoryService()
            .createDeployment() // 与流程定义和部署对象相关的service
            .name("helloworld入门程序") // 添加部署名称
            .addClasspathResource("diagrams/hellowrold.bpmn") // 加载资源
            .addClasspathResource("diagrams/hellowrold.png") // 加载资源
            .deploy(); // 完成部署
    System.out.println(deployment.getId()); // 部署ID
    System.out.println(deployment.getName()); // 部署名称
  }

  /** 启动流程实例 使用key启动默认是按照最新版本的流程定义启动 */
  @Test
  public void startProcessInstance() {
    ProcessInstance p1 =
        processEngine
            .getRuntimeService() // 与正在执行的流程实例和执行对象相关的service
            .startProcessInstanceByKey("hellowrold"); // 使用流程定义的key
    // key=bpmn文件中ID值
    System.out.println("流程实例ID " + p1.getId()); // 流程实例ID
    System.out.println("流程定义ID" + p1.getProcessDefinitionId()); // 流程定义ID
  }

  /** 查询当前人的个人任务 */
  @Test
  public void findMyProcess() {
    String assignee = "王五";

    List<Task> list =
        processEngine
            .getTaskService() // 与正在执行的任务管理相关的service
            .createTaskQuery() // 创建查询对象
            .taskAssignee(assignee) // 指定个人任务查询,指定办理人
            .list();
    if (list != null && list.size() > 0) {
      for (Task task : list) {
        System.out.println("id" + task.getId());
        System.out.println("任务名称:" + task.getName());
        System.out.println("time:" + task.getCreateTime());
        System.out.println("办理人:" + task.getAssignee());
        System.out.println("流程实例ID" + task.getProcessInstanceId());
        System.out.println("执行对象ID:" + task.getExecutionId());
        System.out.println("流程定义ID" + task.getProcessDefinitionId());
      }
    }
  }

  /** 完成我的任务 */
  @Test
  public void completeMyTask() {
    String taskIdString = "402";
    processEngine
        .getTaskService() // 与正在执行的任务管理相关的service
        .complete(taskIdString);
    System.out.println("完成任务:任务ID" + taskIdString);
    System.out.println("完成任务:任务ID" + taskIdString);
  }
}
예제 #26
0
 protected void tearDown() throws Exception {
   ProcessEngines.destroy();
   super.tearDown();
 }
예제 #27
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   ProcessEngines.init();
 }