예제 #1
0
  public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
    String validator = (String) executionContext.getVariable("exo:validator");
    String initiator = (String) executionContext.getVariable("initiator");
    String delegate_flg = (String) executionContext.getVariable("delegate_flg");

    if ((delegate_flg != null) && delegate_flg.equals("true")) {
      /* When execute delegate process */
      assignable.setActorId(initiator);
    } else assignable.setActorId(validator);
  }
  public void assign(Assignable arg0, ExecutionContext arg1) throws Exception {
    arg1.getTaskInstance().setBussId((String) arg1.getContextInstance().getVariable("businessId"));

    // 获得当前任务实例的任务编号

    long taskId = arg1.getTaskInstance().getTask().getId();
    // long processId = arg1.getTaskInstance().getTask().getProcessDefinition().getId();
    // 获取当前任务实例的允许分配的角色对应人员
    String taskRoles = "";
    String agencyRoles = "";

    Connection connection = arg1.getJbpmContext().getConnection();
    Statement statement = connection.createStatement();
    // ResultSet resultSet = statement.executeQuery("select task_role from JBPM_EXT_PERMISSION where
    // task_id='"+taskId+"' and process_id='"+processId+"'");
    ResultSet resultSet =
        statement.executeQuery(
            "select TASK_ROLE,AGENCY_ROLE from JBPM_EXT_PERMISSION where task_id='"
                + taskId
                + "' ");

    while (resultSet.next()) {
      taskRoles = resultSet.getString("TASK_ROLE");
      agencyRoles = resultSet.getString("AGENCY_ROLE");
    }

    resultSet.close();
    statement.close();

    String[] currentUserIds = DimsWorkflowHelper.getCurrentUsers(taskRoles, agencyRoles);
    arg0.setPooledActors(currentUserIds);
  }
 /* (non-Javadoc)
  * @see org.jbpm.taskmgmt.def.AssignmentHandler#assign(org.jbpm.taskmgmt.exe.Assignable, org.jbpm.graph.exe.ExecutionContext)
  */
 @Override
 public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
   /*
    * 将审批任务分配给流程发起人的部门领导
    */
   ContextInstance ci = executionContext.getContextInstance();
   String user = (String) ci.getVariable("initiator");
   String manager = getDepartmentManagerByUser(user);
   ci.setVariable("manager", manager);
   assignable.setActorId(manager);
 }
 /**
  * установить исполнителей задачи
  *
  * @param pooledActors список исполнителей, для разделения кодов используется символ ','
  */
 protected void setAssignablePooledActors(String pooledActors) {
   if (pooledActors != null)
     assignable.setPooledActors(StringUtils.split(pooledActors, ",").toArray(new String[0]));
 }
 /**
  * установить исполнителя задачи
  *
  * @param actorId код исполнителя
  */
 protected void setAssignableActorId(String actorId) {
   if (actorId != null) assignable.setActorId(actorId);
 }
  /* (non-Javadoc)
   * @see org.jbpm.taskmgmt.def.AssignmentHandler#assign(org.jbpm.taskmgmt.exe.Assignable, org.jbpm.graph.exe.ExecutionContext)
   */
  public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
    if (actor == null && pooledactors == null) {
      throw new WorkflowException("no actor or pooled actors has been specified");
    }

    //
    // extract actor
    //

    String assignedActor = null;
    if (actor != null) {
      String actorValStr = actor.getTextTrim();
      if (actorValStr != null && actorValStr.length() > 0) {
        if (actorValStr.startsWith("#{")) {
          String expression = actorValStr.substring(2, actorValStr.length() - 1);
          Object eval =
              AlfrescoJavaScript.executeScript(executionContext, services, expression, null, null);
          if (eval == null) {
            throw new WorkflowException("actor expression '" + actorValStr + "' evaluates to null");
          }

          String theActor = null;
          if (eval instanceof String) {
            theActor = (String) eval;
          } else if (eval instanceof JBPMNode) {
            theActor = mapAuthorityToName((JBPMNode) eval, false);
          }
          if (theActor == null) {
            throw new WorkflowException("actor expression must evaluate to a person");
          }
          assignedActor = theActor;
        } else {
          assignedActor = actorValStr;
        }
      }
    }

    //
    // extract pooled actors
    //

    String[] assignedPooledActors = null;
    if (pooledactors != null) {
      String pooledactorValStr = pooledactors.getTextTrim();
      if (pooledactorValStr != null && pooledactorValStr.length() > 0) {
        if (pooledactorValStr.startsWith("#{")) {
          String expression = pooledactorValStr.substring(2, pooledactorValStr.length() - 1);
          Object eval =
              AlfrescoJavaScript.executeScript(executionContext, services, expression, null, null);
          if (eval == null) {
            throw new WorkflowException(
                "pooledactors expression '" + pooledactorValStr + "' evaluates to null");
          }

          if (eval instanceof ScriptNode[]) {
            ScriptNode[] nodes = (ScriptNode[]) eval;
            assignedPooledActors = new String[nodes.length];

            int i = 0;
            for (ScriptNode node : nodes) {
              String theActor = mapAuthorityToName(node, true);
              if (theActor == null) {
                throw new WorkflowException(
                    "pooledactors expression does not evaluate to a collection of authorities");
              }
              assignedPooledActors[i++] = theActor;
            }
          }
          if (eval instanceof Collection) {
            List<String> actors = new ArrayList<String>();
            Collection<?> nodes = (Collection<?>) eval;
            for (Object node : nodes) {
              if (node instanceof ScriptNode) {
                String theActor = mapAuthorityToName((ScriptNode) node, true);
                if (theActor == null) {
                  throw new WorkflowException(
                      "pooledactors expression does not evaluate to a collection of authorities");
                }
                actors.add(theActor);
              }
            }
            assignedPooledActors = new String[actors.size()];
            actors.toArray(assignedPooledActors);
          } else if (eval instanceof ScriptNode) {
            ScriptNode node = (ScriptNode) eval;
            String theActor = mapAuthorityToName(node, true);
            if (theActor == null) {
              throw new WorkflowException(
                  "pooledactors expression does not evaluate to a collection of authorities");
            }
            assignedPooledActors = new String[] {theActor};
          } else if (eval instanceof String) {
            assignedPooledActors = new String[] {(String) eval};
          } else {
            throw new WorkflowException(
                "pooledactors expression does not evaluate to a collection of authorities");
          }
        } else {
          assignedPooledActors = new String[] {pooledactorValStr};
        }
      }
    }

    //
    // make the assignment
    //
    if (assignedActor != null) {
      assignable.setActorId(assignedActor);
    }
    if (assignedPooledActors != null) {
      assignable.setPooledActors(assignedPooledActors);
    }
  }
  public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {

    Job<?, ?> job = (Job<?, ?>) executionContext.getTaskInstance().getVariable("project");
    assignable.setPooledActors(new String[] {job.getName()});
  }