示例#1
0
  @SuppressWarnings({"serial"})
  public CustomTaskPanel(String id, Task t) {
    super(id);
    task = t;

    add(new Label("taskid", task.getTaskId()));
    add(new Label("taskname", task.getName()));
    add(new Label("tasktype", task.getTaskType() != null ? task.getTaskType() : "N/A"));

    add(
        new Label(
            "taskdescription", task.getDescription() != null ? task.getDescription() : "N/A"));

    Form<Task> form = new Form<Task>("inputForm");
    form.setOutputMarkupId(true);

    form.add(new Label("taskid", new PropertyModel<String>(task, "taskId")));
    form.add(
        new TextField<String>("taskname", new PropertyModel<String>(task, "name"))
            .setRequired(true)
            .add(StringValidator.minimumLength(2)));
    form.add(
        new TextField<String>("tasktype", new PropertyModel<String>(task, "taskType"))
            .setRequired(true)
            .add(StringValidator.minimumLength(2)));
    form.add(
        new Label(
            "taskcreationTimestamp",
            task.getTaskCreationTimestamp() != null
                ? task.getTaskCreationTimestamp().toString()
                : "N/A"));
    form.add(
        new TextArea<String>("taskdescription", new PropertyModel<String>(task, "description"))
            .setRequired(true));

    form.add(
        new AjaxButton("submitButton", form) {
          @Override
          protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
              service.finishTask(task);
              // setResponsePage(TaskOverviewPage.class);
            } catch (WorkflowException e) {
              e.printStackTrace();
            }
          }

          @Override
          protected void onError(AjaxRequestTarget target, Form<?> form) {}
        });
    add(form);

    add(
        new ListView<String>("propertiesList", new ArrayList<String>(task.propertyKeySet())) {
          @Override
          protected void populateItem(ListItem<String> item) {
            item.add(new Label("propertiesLabel", item.getModel()));
          }
        });
  }
  @Test
  public void testHumanTaskFlow_shouldWorkWithGivenProcessBag() throws Exception {
    authenticateAsAdmin();
    addWorkflow("TaskDemoWorkflow");

    ProcessBag processBag = new ProcessBag();
    processBag.addProperty("test", "test");
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("processBag", processBag);

    assertThat(taskboxService.getOpenTasks().size(), is(0));

    workflowService.startFlow("TaskDemoWorkflow", parameterMap);
    System.out.println("workflow started, getting processId");
    assertNotNull(processBag.getProcessId());
    System.out.println("got processId");
    assertThat(taskboxService.getOpenTasks().size(), is(1));
    System.out.println("opentasks is 1");

    Task task = taskboxService.getOpenTasks().get(0);
    System.out.println("got task");
    assertEquals(task.getProcessId(), processBag.getProcessId());
    assertEquals(task.getProperty("test"), "test");
    assertEquals(task.getTaskType(), "demo");
    assertNotNull(task.getTaskId());
    System.out.println("task correct, finishing");
    taskboxService.finishTask(task);
    assertTrue(taskboxService.getOpenTasks().size() == 0);
  }
  @Test
  public void testHumanTaskFlow_shouldCreateOwnProcessBag() throws Exception {
    addWorkflow("TaskDemoWorkflow");

    assertThat(taskboxService.getOpenTasks().size(), is(0));

    authenticateAsAdmin();
    workflowService.startFlow("TaskDemoWorkflow");
    assertThat(taskboxService.getOpenTasks().size(), is(1));

    Task task = taskboxService.getOpenTasks().get(0);
    assertNotNull(task.getProcessId());
    assertNotNull(task.getTaskId());

    taskboxService.finishTask(task);
    assertThat(taskboxService.getOpenTasks().size(), is(0));
  }