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"); }
@Override @SuppressWarnings("unchecked") protected Set<String> getMembersSet(String roleId) throws Exception { if (GroovyExpression.isGroovyExpression(getUsers())) { final APIAccessor accessor = getApiAccessor(); final RuntimeAPI runtimeAPI = accessor.getRuntimeAPI(); final Object people = runtimeAPI.evaluateGroovyExpression(getUsers(), getProcessInstanceUUID(), true); if (people instanceof Collection<?>) { return new HashSet<String>((Collection<String>) people); } else if (people instanceof String) { return setMembers((String) people); } else { throw new BonitaRuntimeException( "The Groovy expression returns neither a Collection nor a String."); } } else { return setMembers(getUsers()); } }
@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(); } }
public void execute(APIAccessor accessor, ActivityInstance activityInstance) throws Exception { RuntimeAPI runtimeAPI = accessor.getRuntimeAPI(); runtimeAPI.setProcessInstanceVariable(activityInstance.getProcessInstanceUUID(), "cont", "0"); }