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");
 }
Exemple #2
0
 @Override
 protected void executeConnector() throws Exception {
   final APIAccessor accessor = getApiAccessor();
   final QueryRuntimeAPI queryRuntimeAPI =
       accessor.getQueryRuntimeAPI(AccessorUtil.QUERYLIST_JOURNAL_KEY);
   final Set<LightActivityInstance> activities =
       queryRuntimeAPI.getLightActivityInstances(getProcessInstanceUUID(), taskName);
   LightTaskInstance task;
   if (activities.size() == 0) {
     // No step found.
     author = null;
   } else if (activities.size() == 1) {
     // Only one step has the given name.
     final LightActivityInstance lightActivityInstance = activities.iterator().next();
     if (lightActivityInstance.isTask()) {
       task = lightActivityInstance.getTask();
       author = task.getEndedBy();
     }
   } else {
     // More than one step have the same name.
     // This is possible in case of iterations.
     // Only consider the current iteration / the latest iteration.
     final List<LightTaskInstance> orderedActivities = new ArrayList<LightTaskInstance>();
     for (LightActivityInstance lightActivityInstance : activities) {
       if (lightActivityInstance.isTask()
           && lightActivityInstance.getTask().getEndedBy() != null) {
         orderedActivities.add(lightActivityInstance.getTask());
       }
     }
     Collections.sort(
         orderedActivities,
         new Comparator<LightTaskInstance>() {
           public int compare(LightTaskInstance o1, LightTaskInstance o2) {
             return o1.getEndedDate().compareTo(o2.getEndedDate());
           }
         });
     author = orderedActivities.iterator().next().getEndedBy();
   }
 }