Ejemplo n.º 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()));
          }
        });
  }
Ejemplo n.º 2
0
  @Test
  public void testCompleteWorkflow_humanInteractionShouldReplaceValues() throws Exception {
    addWorkflow("HIDemoWorkflow");
    authenticateAsAdmin();
    workflowService.startFlow("HIDemoWorkflow");
    Task task = taskboxService.getOpenTasks().get(0);
    Date date = new Date();
    task.addOrReplaceProperty("test", date);
    assertEquals("step1", task.getTaskType());

    task.setName("test");
    taskboxService.updateTask(task);
    task = taskboxService.getOpenTasks().get(0);
    assertEquals("test", task.getName());

    taskboxService.finishTask(task);

    task = taskboxService.getOpenTasks().get(0);
    assertEquals(date, task.getProperty("test"));
    assertEquals("step2", task.getTaskType());

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