public void testAddAttachment() { try { String sampleProcessId = "150001"; // replace this with a valid id IBPMContext ctx = Fixture.getIBPMContext("pino", "password1"); IInstanceQueryService queryService = Fixture.getBPMServiceClient().getInstanceQueryService(); IProcessInstance instance = queryService.getProcessInstance(ctx, sampleProcessId); IInstanceManagementService service = Fixture.getBPMServiceClient().getInstanceManagementService(); IProcessComment comment = new ProcessComment(); IIdentityType identity = new IdentityType(); identity.setDisplayName(ctx.getUser()); identity.setId(ctx.getUser()); identity.setType("user"); comment.setUpdatedBy(identity); comment.setComment("my programmatic comment5"); comment.setUpdatedDate(Calendar.getInstance()); service.addComment(ctx, instance, comment); // check if persisted IProcessInstance updatedInstance = queryService.getProcessInstance(ctx, sampleProcessId); List<IProcessComment> comments = updatedInstance.getUserComment(); for (IProcessComment c : comments) { System.out.println(c.getComment()); // the new comment should appear } } catch (BPMServiceClientException bpmsce) { // TODO: Add catch code bpmsce.printStackTrace(); } catch (BPMException bpme) { // TODO: Add catch code bpme.printStackTrace(); } catch (Exception e) { // TODO: Add catch code e.printStackTrace(); } }
private void printProcessInstance(IProcessInstance instance) { System.out.println(instance.getSystemAttributes().getProcessInstanceId()); System.out.println(instance.getSystemAttributes().getProcessNumber()); System.out.println(instance.getSystemAttributes().getState()); System.out.println(instance.getProcessDN()); System.out.println(instance.getCreator()); System.out.println(instance.getSystemAttributes().getCreatedDate().getTime()); }