Esempio n. 1
0
  /** Descripción de Método */
  private void lock() {

    // log.info("...");

    JFrame frame = Env.getFrame((Container) m_parent);

    if (frame instanceof AWindow) {
      ((AWindow) frame).setBusyTimer(m_pi.getEstSeconds());
    } else {
      m_waiting =
          new Waiting(frame, Msg.getMsg(Env.getCtx(), "Processing"), false, m_pi.getEstSeconds());
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            log.finer("lock");
            m_parent.lockUI(m_pi);
          }
        });

    if (m_waiting != null) {
      m_waiting.toFront();
      m_waiting.setVisible(true);
    }
  } // lock
Esempio n. 2
0
  /** Descripción de Método */
  private void unlock() {

    // log.info("...");

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            String summary = m_pi.getSummary();

            log.finer("unlock - " + summary);

            if ((summary != null) && (summary.indexOf("@") != -1)) {
              m_pi.setSummary(Msg.parseTranslation(Env.getCtx(), summary));
            }

            m_parent.unlockUI(m_pi);
          }
        });

    // Remove Waiting/Processing Indicator

    if (m_waiting != null) {
      m_waiting.dispose();
    }

    m_waiting = null;
  } // unlock
Esempio n. 3
0
  /** Descripción de Método */
  public void run() {
    log.fine(
        "En processCtl.Run conAD_PInstance_ID="
            + m_pi.getAD_PInstance_ID()
            + ", Record_ID="
            + m_pi.getRecord_ID());

    // Lock

    lock();

    // try {System.out.println(">> sleeping ..");sleep(20000);System.out.println(".. sleeping <<");}
    // catch (Exception e) {}

    // Get Process Information: Name, Procedure Name, ClassName, IsReport, IsDirectPrint

    String ProcedureName = "";
    int AD_ReportView_ID = 0;
    int AD_Workflow_ID = 0;
    int AD_PrintFormat_ID = 0;
    boolean IsReport = false;
    boolean IsDirectPrint = false;

    //

    String SQL =
        "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4
            + " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8
            + " CASE WHEN p.Statistic_Count=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END, dynamicreport, JasperReport " // 9
            + "FROM AD_Process p, AD_PInstance i "
            + "WHERE p.AD_Process_ID=i.AD_Process_ID AND p.IsActive='Y'"
            + " AND i.AD_PInstance_ID=?";

    if (!Env.isBaseLanguage(Env.getCtx(), "AD_Process")) {
      SQL =
          "SELECT t.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4
              + " p.isReport, p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8
              + " CASE WHEN p.Statistic_Count=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END, p.AD_PrintFormat_ID, dynamicreport, JasperReport "
              + "FROM AD_Process p, AD_Process_Trl t, AD_PInstance i "
              + "WHERE p.AD_Process_ID=i.AD_Process_ID"
              + " AND p.AD_Process_ID=t.AD_Process_ID AND p.IsActive='Y'"
              + " AND i.AD_PInstance_ID=?"
              + " AND t.AD_Language='"
              + Env.getAD_Language(Env.getCtx())
              + "'";
    }

    //

    try {
      PreparedStatement pstmt =
          DB.prepareStatement(
              SQL,
              ResultSet.TYPE_FORWARD_ONLY,
              ResultSet.CONCUR_READ_ONLY,
              m_trx != null ? m_trx.getTrxName() : null);

      pstmt.setInt(1, m_pi.getAD_PInstance_ID());

      ResultSet rs = pstmt.executeQuery();

      if (rs.next()) {
        m_pi.setTitle(rs.getString(1));

        if (m_waiting != null) {
          m_waiting.setTitle(m_pi.getTitle());
        }

        ProcedureName = rs.getString(2);
        m_pi.setClassName(rs.getString(3));

        // Si tiene definido un jasper dinamico, entonces usar la clase encargada para ésto
        if (rs.getString("dynamicreport") != null
            && "Y".equalsIgnoreCase(rs.getString("dynamicreport"))
            && rs.getString("jasperreport") != null
            && rs.getString("jasperreport").trim().length() > 0)
          m_pi.setClassName(DYNAMIC_JASPER_CLASSNAME);

        /** Logica para plugins, verificar si existe una clase que redefina el proceso original */
        String pluginProcessClassName = PluginProcessUtils.findPluginProcessClass(rs.getString(3));
        if (pluginProcessClassName != null) m_pi.setClassName(pluginProcessClassName);

        m_pi.setAD_Process_ID(rs.getInt(4));

        // Report

        if ("Y".equals(rs.getString(5))) {
          IsReport = true;

          if ("Y".equals(rs.getString(6)) && !Ini.getPropertyBool(Ini.P_PRINTPREVIEW)) {
            IsDirectPrint = true;
          }
        }

        AD_ReportView_ID = rs.getInt(7);
        AD_Workflow_ID = rs.getInt(8);
        AD_PrintFormat_ID = rs.getInt("AD_PrintFormat_ID");
        //

        int estimate = rs.getInt(9);

        if (estimate != 0) {
          m_pi.setEstSeconds(estimate + 1); // admin overhead

          if (m_waiting != null) {
            m_waiting.setTimerEstimate(m_pi.getEstSeconds());
          }
        }
      } else {
        log.log(Level.SEVERE, "No AD_PInstance_ID=" + m_pi.getAD_PInstance_ID());
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      m_pi.setSummary(
          Msg.getMsg(Env.getCtx(), "ProcessNoProcedure") + " " + e.getLocalizedMessage(), true);
      unlock();
      log.log(Level.SEVERE, "run", e);

      return;
    }

    // -- Disytel
    // Se agrega el listener de DocAction Events a la información del proceso.
    m_pi.setDocActionStatusListener(docActionStatusListener);
    // --

    // No PL/SQL Procedure

    if (ProcedureName == null) {
      ProcedureName = "";
    }

    if (AD_Workflow_ID > 0) {
      startWorkflow(AD_Workflow_ID);
      unlock();

      return;
    }

    if (m_pi.getClassName() != null) {

      // Run Class

      if (!startProcess()) {
        unlock();

        return;
      }

      // No Optional SQL procedure ... done

      if (!IsReport && (ProcedureName.length() == 0)) {
        unlock();

        return;
      }

      // No Optional Report ... done

      if (IsReport && (AD_ReportView_ID == 0) && (AD_PrintFormat_ID == 0)) {
        unlock();

        return;
      }
    }

    // If not a report, we need a prodedure name

    if (!IsReport && (ProcedureName.length() == 0)) {
      m_pi.setSummary(Msg.getMsg(Env.getCtx(), "ProcessNoProcedure"), true);
      unlock();

      return;
    }

    if (IsReport) {

      // Optional Pre-Report Process

      if (ProcedureName.length() > 0) {
        if (!startDBProcess(ProcedureName)) {
          unlock();

          return;
        }
      } // Pre-Report

      // Start Report    -----------------------------------------------

      boolean ok = ReportCtl.start(m_pi, IsDirectPrint);

      m_pi.setSummary("Report", !ok);
      unlock();
    } else {
      if (!startDBProcess(ProcedureName)) {
        unlock();

        return;
      }

      // Success - getResult

      ProcessInfoUtil.setSummaryFromDB(m_pi);
      unlock();
    } // *** Process submission ***

    // log.fine(Log.l3_Util, "ProcessCtl.run - done");

  } // run