コード例 #1
0
ファイル: WWorkflow.java プロジェクト: makezjdq/adempiere-1
  /**
   * Execute the M_Command and update the .
   *
   * @param m_command
   * @param wf
   * @param activeNode
   * @param nodes
   * @param nodes_ID
   * @param sess
   */
  private void executeCommand(
      String m_command,
      int j_command,
      MWorkflow wf,
      int activeNode,
      MWFNode[] nodes,
      ArrayList nodes_ID,
      HttpSession sess) {
    if (j_command != 0) {
      sess.setAttribute(ACTIVE_NODE, new Integer(j_command));
      return;
    }

    debug(m_command, "m_command in executeCommand");
    // check first or last node
    boolean isFirst = wf.isFirst(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));
    boolean isLast = wf.isLast(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));

    boolean notReady = false;
    int updatedActiveNode = activeNode;

    if (activeNode < 0) notReady = true;

    if (notReady) {
      updatedActiveNode = ((Integer) nodes_ID.get(0)).intValue();

    } else {
      if (m_command.equals(NEXT)) {
        if (notReady) updatedActiveNode = ((Integer) nodes_ID.get(0)).intValue();
        else updatedActiveNode = wf.getNext(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));
      } // next
      if (m_command.equals(BACK)) {
        if (notReady) updatedActiveNode = ((Integer) nodes_ID.get(0)).intValue();
        else
          updatedActiveNode = wf.getPrevious(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));
      } // back
      if (m_command.equals(FIRST)) updatedActiveNode = ((Integer) nodes_ID.get(0)).intValue();

      if (m_command.equals(LAST))
        updatedActiveNode = wf.getLast(0, Env.getContextAsInt(ctx, "#AD_Client_ID"));
    } // ready

    // update
    sess.setAttribute(ACTIVE_NODE, new Integer(updatedActiveNode));
  } // executeCommand