示例#1
0
  public void testAddComments() throws BonitaException {
    ProcessDefinition definition =
        ProcessBuilder.createProcess("feed", "1.0")
            .addHuman(getLogin())
            .addHumanTask("sala", getLogin())
            .done();
    definition = getManagementAPI().deploy(getBusinessArchive(definition));
    final ProcessDefinitionUUID processUUID = definition.getUUID();
    final ProcessInstanceUUID instanceUUID = getRuntimeAPI().instantiateProcess(processUUID);

    Collection<ActivityInstance> acts =
        this.getQueryRuntimeAPI().getActivityInstances(instanceUUID, "sala");
    assertEquals(1, acts.size());
    ActivityInstance activityInst = acts.iterator().next();

    getRuntimeAPI().addComment(instanceUUID, "First comment", "john");
    getRuntimeAPI().addComment(activityInst.getUUID(), "Done", "joe");

    List<Comment> feed = this.getQueryRuntimeAPI().getCommentFeed(instanceUUID);
    assertEquals(2, feed.size());
    Comment c = new CommentImpl(feed.get(0));
    assertEquals("First comment", c.getMessage());
    assertEquals("john", c.getUserId());
    assertNotNull(c.getDate());
    assertNull(c.getActivityUUID());

    Comment c1 = new CommentImpl(feed.get(1));
    assertEquals("Done", c1.getMessage());
    assertEquals("joe", c1.getUserId());
    assertNotNull(c1.getDate());
    assertEquals(activityInst.getUUID(), c1.getActivityUUID());

    getManagementAPI().deleteProcess(processUUID);
  }
 public void execute(APIAccessor accessor, ActivityInstance<ActivityBody> activity)
     throws Exception {
   // Retrieve workflow session creator and set the instance property
   // "initiator" with it
   String user_Name =
       accessor
           .getQueryRuntimeAPI()
           .getProcessInstance(activity.getProcessInstanceUUID())
           .getStartedBy();
   accessor
       .getRuntimeAPI()
       .setProcessInstanceVariable(
           activity.getProcessInstanceUUID(), PROCESS_INITIATOR_USER_NAME, user_Name);
   accessor
       .getRuntimeAPI()
       .setActivityInstanceVariable(activity.getUUID(), CHOICE_PROPERTY_NAME, "enough");
 }