コード例 #1
0
  /**
   * Importamos el conjunto de lineas de informe
   *
   * @return
   */
  private boolean importReportLineSet() {

    String sql =
        "select rls.rls_name, rls.rls_description from i_reportlineset rls where "
            + "rls.pa_reportlineset_id is null group by rls.rls_name, rls.rls_description";
    try {
      PreparedStatement pstmt = DB.prepareStatement(sql, trxName);
      ResultSet rs = pstmt.executeQuery();
      while (rs.next()) {

        // Creamo El conjunto de lineas del informe
        MReportLineSet rls = new MReportLineSet(getCtx(), 0, trxName);
        rls.setName(rs.getString("rls_name"));
        rls.setDescription(rs.getString("rls_description"));
        rls.save(trxName);

        // Actualizamos la table de importacion con el ReportLineSet generado
        String upd_sql =
            "update i_reportlineset set pa_reportlineset_id=? where rls_name=? and rls_description=?";
        PreparedStatement upd_pstmt = DB.prepareStatement(upd_sql, trxName);
        upd_pstmt.setInt(1, rls.getPA_ReportLineSet_ID());
        upd_pstmt.setString(2, rls.getName());
        upd_pstmt.setString(3, rls.getDescription());

        upd_pstmt.executeUpdate();
      }
    } catch (SQLException e) {
      log.log(Level.SEVERE, "Fallo al crear el conjunto de lineas de informe: " + e);
      return false;
    }

    return true;
  }
コード例 #2
0
ファイル: MProductPrice.java プロジェクト: AtrumGeost/ati_ds
 /**
  * Obtener un precio de producto a partir del producto y de la versión de la tarifa
  *
  * @param ctx contexto
  * @param priceListVersionID id de la versión de tarifa
  * @param productID id del producto
  * @param trxName nombre de la transacción en curso
  * @return precio de producto o null si no existe
  */
 public static MProductPrice get(
     Properties ctx, int priceListVersionID, int productID, String trxName) {
   String sql =
       "SELECT * FROM " + Table_Name + " WHERE m_pricelist_version_id = ? and m_product_id = ?";
   MProductPrice price = null;
   PreparedStatement ps = null;
   ResultSet rs = null;
   try {
     ps = DB.prepareStatement(sql, trxName);
     ps.setInt(1, priceListVersionID);
     ps.setInt(2, productID);
     rs = ps.executeQuery();
     if (rs.next()) {
       price = new MProductPrice(ctx, rs, trxName);
     }
   } catch (Exception e) {
     s_log.severe("Error finding product price, method get. " + e.getMessage());
   } finally {
     try {
       if (ps != null) ps.close();
       if (rs != null) rs.close();
     } catch (Exception e2) {
       s_log.severe("Error finding product price, method get. " + e2.getMessage());
     }
   }
   return price;
 }
コード例 #3
0
  /**
   * Devuelve todas las líneas de la Boleta de Depósito
   *
   * @param reload fuerza a recargar las líneas desde la BD
   * @return Arreglo con las líneas
   */
  public MBoletaDepositoLine[] getLines(boolean reload) {
    if (lines == null || reload) {
      ArrayList<MBoletaDepositoLine> list = new ArrayList<MBoletaDepositoLine>();
      StringBuffer sql =
          new StringBuffer("SELECT * FROM M_BOLETADEPOSITOLINE WHERE M_BOLETADEPOSITO_ID=? ");

      PreparedStatement pstmt = null;
      try {
        pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
        pstmt.setInt(1, getM_BoletaDeposito_ID());
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) list.add(new MBoletaDepositoLine(getCtx(), rs, get_TrxName()));
        rs.close();
        pstmt.close();
        pstmt = null;
      } catch (Exception e) {
        log.log(Level.SEVERE, "getLines - " + sql, e);
      } finally {
        try {
          if (pstmt != null) pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
      }
      //
      lines = new MBoletaDepositoLine[list.size()];
      list.toArray(lines);
    }
    return lines;
  }
コード例 #4
0
ファイル: MRefList.java プロジェクト: Garridus/libertya
 /**
  * @param ctx contexto
  * @param referenceID id de la referencia
  * @param trxName nombre de la transacción
  * @return lista con todos los values de la lista
  */
 public static List<String> getValueList(Properties ctx, Integer referenceID, String trxName) {
   String sql =
       "SELECT value " + "FROM ad_ref_list " + "WHERE ad_reference_id = ? " + "ORDER BY value";
   List<String> values = new ArrayList<String>();
   PreparedStatement ps = null;
   ResultSet rs = null;
   try {
     ps = DB.prepareStatement(sql, trxName);
     ps.setInt(1, referenceID);
     rs = ps.executeQuery();
     while (rs.next()) {
       values.add(rs.getString("value"));
     }
   } catch (Exception e) {
     s_log.severe(e.getMessage());
   } finally {
     try {
       if (ps != null) ps.close();
       if (rs != null) rs.close();
     } catch (Exception e2) {
       s_log.severe(e2.getMessage());
     }
   }
   return values;
 }
コード例 #5
0
ファイル: MRemesa.java プロジェクト: jdhuayta/libertya
 /**
  * ************************************************************************ Lineas de Remesa
  *
  * @param whereClause where clause or null (starting with AND)
  * @return lines
  */
 public MRemesaLine[] getLines(String whereClause, String orderClause) {
   ArrayList list = new ArrayList();
   StringBuffer sql = new StringBuffer("SELECT * FROM C_RemesaLine WHERE C_Remesa_ID=? ");
   if (whereClause != null) sql.append(whereClause);
   if (orderClause != null) sql.append(" ").append(orderClause);
   PreparedStatement pstmt = null;
   try {
     pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
     pstmt.setInt(1, getC_Remesa_ID());
     ResultSet rs = pstmt.executeQuery();
     while (rs.next()) list.add(new MRemesaLine(getCtx(), rs));
     rs.close();
     pstmt.close();
     pstmt = null;
   } catch (Exception e) {
     log.saveError("getLines - " + sql, e);
   } finally {
     try {
       if (pstmt != null) pstmt.close();
     } catch (Exception e) {
     }
     pstmt = null;
   }
   //
   MRemesaLine[] lines = new MRemesaLine[list.size()];
   list.toArray(lines);
   return lines;
 } //	getLines
コード例 #6
0
ファイル: MRefList.java プロジェクト: Garridus/libertya
 /**
  * Get Reference List (translated)
  *
  * @param ctx context
  * @param AD_Reference_ID reference
  * @param optional if true add "",""
  * @return List or null
  */
 public static ValueNamePair[] getList(Properties ctx, int AD_Reference_ID, boolean optional) {
   String ad_language = Env.getAD_Language(ctx);
   boolean isBaseLanguage = Env.isBaseLanguage(ad_language, "AD_Ref_List");
   String sql =
       isBaseLanguage
           ? "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=? AND IsActive='Y' ORDER BY Name"
           : "SELECT r.Value, t.Name FROM AD_Ref_List_Trl t"
               + " INNER JOIN AD_Ref_List r ON (r.AD_Ref_List_ID=t.AD_Ref_List_ID)"
               + " WHERE r.AD_Reference_ID=? AND t.AD_Language=? AND r.IsActive='Y'"
               + " ORDER BY t.Name";
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
   if (optional) list.add(new ValueNamePair("", ""));
   try {
     pstmt = DB.prepareStatement(sql, null);
     pstmt.setInt(1, AD_Reference_ID);
     if (!isBaseLanguage) pstmt.setString(2, ad_language);
     rs = pstmt.executeQuery();
     while (rs.next()) list.add(new ValueNamePair(rs.getString(1), rs.getString(2)));
     rs.close();
     pstmt.close();
     pstmt = null;
   } catch (SQLException e) {
     s_log.log(Level.SEVERE, sql, e);
   } finally {
     DB.close(rs, pstmt);
     rs = null;
     pstmt = null;
   }
   ValueNamePair[] retValue = new ValueNamePair[list.size()];
   list.toArray(retValue);
   return retValue;
 } //	getList
コード例 #7
0
ファイル: MWarehouse.java プロジェクト: AtrumGeost/ati_ds
  /**
   * Get warehouses of client
   *
   * @param ctx
   * @param trxName
   * @return
   */
  public static List<MWarehouse> getOfClient(Properties ctx, String trxName) {
    // script sql
    String sql = "SELECT * FROM m_warehouse WHERE ad_client_id = ? ";

    List<MWarehouse> list = new ArrayList<MWarehouse>();
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      ps = DB.prepareStatement(sql, trxName);
      // set ad_client
      ps.setInt(1, Env.getAD_Client_ID(ctx));
      rs = ps.executeQuery();

      while (rs.next()) {
        list.add(new MWarehouse(ctx, rs, trxName));
      }

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        ps.close();
        rs.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return list;
  }
コード例 #8
0
  /*----------------------------------
  @Author: Jorge Vidal - Disytel
  @Fecha: 05/09/2006
  @Comentario: Actualiza el total que corresponde a las lineas
  @Parametros:
  -------------------------------------------*/
  public void checkLines() {
    StringBuffer sql =
        new StringBuffer(
            "SELECT SUM(PAYMENT_AMT) FROM M_BOLETADEPOSITOLINE WHERE M_BOLETADEPOSITO_ID=? ");

    PreparedStatement pstmt = null;
    try {
      pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
      pstmt.setInt(1, getM_BoletaDeposito_ID());
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        BigDecimal total = rs.getBigDecimal(1);
        if (!(total.equals(getGrandTotal()))) {
          setGrandTotal(total);
          save();
        }
      }

      rs.close();
      pstmt.close();
      pstmt = null;
    } catch (Exception e) {
      log.log(Level.SEVERE, "CheckLines - " + sql, e);
    } finally {
      try {
        if (pstmt != null) pstmt.close();
      } catch (Exception e) {
      }
      pstmt = null;
    }
  }
コード例 #9
0
  /**
   * Descripción de Método
   *
   * @param goal
   * @return
   */
  public int createMeasures(MSLAGoal goal) {
    String sql =
        "SELECT M_InOut_ID, io.MovementDate-o.DatePromised," // 1..2
            + " io.MovementDate, o.DatePromised, o.DocumentNo "
            + "FROM M_InOut io"
            + " INNER JOIN C_Order o ON (io.C_Order_ID=o.C_Order_ID) "
            + "WHERE io.C_BPartner_ID=?"
            + " AND NOT EXISTS "
            + "(SELECT * FROM PA_SLA_Measure m "
            + "WHERE m.PA_SLA_Goal_ID=?"
            + " AND m.AD_Table_ID="
            + MInOut.Table_ID
            + " AND m.Record_ID=io.M_InOut_ID)";
    int counter = 0;
    PreparedStatement pstmt = null;

    try {
      pstmt = DB.prepareStatement(sql);
      pstmt.setInt(1, goal.getC_BPartner_ID());
      pstmt.setInt(2, goal.getPA_SLA_Goal_ID());

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        int M_InOut_ID = rs.getInt(1);
        BigDecimal MeasureActual = rs.getBigDecimal(2);
        Timestamp MovementDate = rs.getTimestamp(3);
        String Description = rs.getString(5) + ": " + rs.getTimestamp(4);

        if (goal.isDateValid(MovementDate)) {
          MSLAMeasure measure = new MSLAMeasure(goal, MovementDate, MeasureActual, Description);

          measure.setLink(MInOut.Table_ID, M_InOut_ID);

          if (measure.save()) {
            counter++;
          }
        }
      }

      rs.close();
      pstmt.close();
      pstmt = null;
    } catch (Exception e) {
      log.log(Level.SEVERE, "createMeasures", e);
    }

    try {
      if (pstmt != null) {
        pstmt.close();
      }

      pstmt = null;
    } catch (Exception e) {
      pstmt = null;
    }

    return counter;
  } // createMeasures
コード例 #10
0
  private boolean importReportLines() {
    String sql =
        "select * from i_reportlineset rls where "
            + "rls.pa_reportlineset_id is not null and rls.pa_reportline_id is null"
            + " and rls.isReportSource='N' ";

    try {
      PreparedStatement pstmt = DB.prepareStatement(sql, trxName);
      ResultSet rs = pstmt.executeQuery();
      while (rs.next()) {

        // Creamo El conjunto de lineas del informe
        CReportLine rl = new CReportLine(getCtx(), 0, trxName);

        X_I_ReportLineSet ir = new X_I_ReportLineSet(getCtx(), rs, get_TrxName());

        rl.setName(ir.getName());
        rl.setDescription(ir.getDescription());
        rl.setPA_ReportLineSet_ID(ir.getPA_ReportLineSet_ID());
        rl.setSeqNo(ir.getSeqNo());
        rl.setPrintLineNo(ir.getPrintLineNo());
        rl.setFunc(ir.getFunc());
        rl.setLineType(ir.getLineType());
        rl.setPostingType(ir.getPostingType());
        rl.setAmountType(ir.getAmountType());
        rl.setIsPrinted(ir.isPrinted());
        rl.setChangeSign(ir.isChangeSign());
        rl.setNegativeAsZero(ir.isNegativeAsZero());
        rl.setIsEverPrinted(ir.isEverPrinted());
        rl.setIsPageBreak(ir.isPageBreak());
        rl.setIsBold(ir.isBold());
        rl.setIndentLevel(ir.getIndentLevel());

        // Grabamos la linea importada
        if (rl.save() == false) {
          log.log(Level.SEVERE, "Error grabando la linea de informe.");
          return false;
        }

        // Guardamos el PA_ReportLine_ID en la tabla de importacion
        ir.setPA_ReportLine_ID(rl.getPA_ReportLine_ID());
        ir.setI_IsImported(true);

        if (ir.save(trxName) == false) {
          log.log(Level.SEVERE, "Error guardando el PA_ReportLine_ID en la tabla de importacion.");
          return false;
        }
      }
    } catch (SQLException e) {
      log.log(Level.SEVERE, "Fallo al crear el conjunto de lineas de informe: " + e);
      return false;
    }
    return true;
  }
コード例 #11
0
ファイル: Viewer.java プロジェクト: AtrumGeost/ati_ds
  /**
   * Descripción de Método
   *
   * @param AD_PrintFormat_ID
   */
  private void fillComboReport(int AD_PrintFormat_ID) {
    comboReport.removeActionListener(this);
    comboReport.removeAllItems();

    KeyNamePair selectValue = null;

    // fill Report Options

    String sql =
        MRole.getDefault()
            .addAccessSQL(
                "SELECT AD_PrintFormat_ID, Name, Description "
                    + "FROM AD_PrintFormat "
                    + "WHERE AD_Table_ID=? AND IsActive='Y' "
                    + "ORDER BY Name",
                "AD_PrintFormat",
                MRole.SQL_NOTQUALIFIED,
                MRole.SQL_RO);
    int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();

    try {
      PreparedStatement pstmt = DB.prepareStatement(sql);

      pstmt.setInt(1, AD_Table_ID);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));

        comboReport.addItem(pp);

        if (rs.getInt(1) == AD_PrintFormat_ID) {
          selectValue = pp;
        }
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "", e);
    }

    StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(m_ctx, "NewReport")).append(" **");
    KeyNamePair pp = new KeyNamePair(-1, sb.toString());

    // comboReport.addItem( pp );

    if (selectValue != null) {
      comboReport.setSelectedItem(selectValue);
    }

    comboReport.addActionListener(this);
  } // fillComboReport
コード例 #12
0
ファイル: MOrg.java プロジェクト: jdhuayta/libertya
  /*
   * dREHER [email protected]
   *
   * Devuelve un array de organizaciones hojas hijas, en caso de que la organizacion actual sea del tipo carpeta isSummary='Y'
   *
   */
  public ArrayList<MOrg> getOrgsChilds() {

    ArrayList<MOrg> orgs = new ArrayList<MOrg>();

    // Buscar siempre, en caso de llamarse desde una validacion, podia no funcionar
    // if(isSummary()){

    // Si estoy dando de alta, no existen orgs hijas
    if (getAD_Org_ID() <= 0) return orgs;

    log.fine("Busco organizaciones hijas para AD_Org_ID=" + getAD_Org_ID());

    String sql =
        "SELECT org.AD_Org_ID "
            + "FROM AD_Org AS org "
            + "WHERE getisnodechild("
            + Env.getAD_Client_ID(getCtx())
            + ","
            + getAD_Org_ID()
            + ", org.AD_Org_ID, 'OO') = 'Y'";

    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {

      log.fine("sql getOrgsChilds=" + sql);
      pstmt = DB.prepareStatement(sql);
      rs = pstmt.executeQuery();
      while (rs.next()) {

        int orgID = rs.getInt("AD_Org_ID");

        orgs.add(new MOrg(Env.getCtx(), orgID, null));

        log.fine("Encontro org hija ID=" + orgID);
      }
      DB.close(rs, pstmt);

    } catch (SQLException ex) {
      log.log(Level.SEVERE, sql, ex);
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }

    // }

    return orgs;
  }
コード例 #13
0
ファイル: MWarehouse.java プロジェクト: AtrumGeost/ati_ds
  /**
   * Get Locators
   *
   * @param reload if true reload
   * @return array of locators
   */
  public MLocator[] getLocators(boolean reload) {

    if (!reload && (m_locators != null)) {
      return m_locators;
    }

    //
    String sql = "SELECT * FROM M_Locator WHERE M_Warehouse_ID=? ORDER BY X,Y,Z";
    ArrayList list = new ArrayList();
    PreparedStatement pstmt = null;

    try {

      pstmt = DB.prepareStatement(sql);
      pstmt.setInt(1, getM_Warehouse_ID());

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        list.add(new MLocator(getCtx(), rs, null));
      }

      rs.close();
      pstmt.close();
      pstmt = null;

    } catch (Exception e) {
      log.log(Level.SEVERE, "getLocators", e);
    }

    try {

      if (pstmt != null) {
        pstmt.close();
      }

      pstmt = null;

    } catch (Exception e) {
      pstmt = null;
    }

    //
    m_locators = new MLocator[list.size()];
    list.toArray(m_locators);

    return m_locators;
  } // getLocators
コード例 #14
0
ファイル: MRefList.java プロジェクト: Garridus/libertya
  /**
   * Get Reference List Value Description (cached)
   *
   * @param ctx context
   * @param ListName reference
   * @param Value value
   * @return List or null
   */
  public static String getListDescription(Properties ctx, String ListName, String Value) {
    String AD_Language = Env.getAD_Language(ctx);
    String key = AD_Language + "_" + ListName + "_" + Value;
    String retValue = s_cache.get(key);
    if (retValue != null) return retValue;

    boolean isBaseLanguage = Env.isBaseLanguage(AD_Language, "AD_Ref_List");
    String sql =
        isBaseLanguage
            ? "SELECT a.Description FROM AD_Ref_List a, AD_Reference b"
                + " WHERE b.Name=? AND a.Value=?"
                + " AND a.AD_Reference_ID = b.AD_Reference_ID"
            : "SELECT t.Description FROM AD_Reference r"
                + " INNER JOIN AD_Ref_List rl ON (r.AD_Reference_ID=rl.AD_Reference_ID)"
                + " INNER JOIN AD_Ref_List_Trl t ON (t.AD_Ref_List_ID=rl.AD_Ref_List_ID)"
                + " WHERE r.Name=? AND rl.Value=? AND t.AD_Language=?";
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = DB.prepareStatement(sql, null);
      pstmt.setString(1, ListName);
      pstmt.setString(2, Value);
      if (!isBaseLanguage) pstmt.setString(3, AD_Language);
      rs = pstmt.executeQuery();
      if (rs.next()) retValue = rs.getString(1);
      rs.close();
      pstmt.close();
      pstmt = null;
    } catch (SQLException ex) {
      s_log.log(Level.SEVERE, sql + " -- " + key, ex);
    } finally {
      DB.close(rs, pstmt);
      rs = null;
      pstmt = null;
    }

    //	Save into Cache
    if (retValue == null) {
      retValue = "";
      s_log.info("getListDescription - Not found " + key);
    }
    s_cache.put(key, retValue);
    //
    return retValue;
  } //	getListDescription
コード例 #15
0
ファイル: MWarehouse.java プロジェクト: AtrumGeost/ati_ds
  /**
   * Get Warehouses for Org
   *
   * @param ctx context
   * @param AD_Org_ID id
   * @return warehouse
   */
  public static MWarehouse[] getForOrg(Properties ctx, int AD_Org_ID) {

    ArrayList list = new ArrayList();
    String sql = "SELECT * FROM M_Warehouse WHERE AD_Org_ID=? ORDER BY Created";
    PreparedStatement pstmt = null;

    try {

      pstmt = DB.prepareStatement(sql);
      pstmt.setInt(1, AD_Org_ID);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        list.add(new MWarehouse(ctx, rs, null));
      }

      rs.close();
      pstmt.close();
      pstmt = null;

    } catch (Exception e) {
      s_log.log(Level.SEVERE, "getForOrg", e);
    }

    try {

      if (pstmt != null) {
        pstmt.close();
      }

      pstmt = null;

    } catch (Exception e) {
      pstmt = null;
    }

    MWarehouse[] retValue = new MWarehouse[list.size()];

    list.toArray(retValue);

    return retValue;
  } // get
コード例 #16
0
ファイル: VLocatorDialog.java プロジェクト: jdhuayta/libertya
  /**
   * Descripción de Método
   *
   * @param M_Warehouse_ID
   */
  private void getWarehouseInfo(int M_Warehouse_ID) {
    if (M_Warehouse_ID == m_M_Warehouse_ID) {
      return;
    }

    // Defaults

    m_M_Warehouse_ID = 0;
    m_M_WarehouseName = "";
    m_M_WarehouseValue = "";
    m_Separator = ".";
    m_AD_Client_ID = 0;
    m_AD_Org_ID = 0;

    //

    String SQL =
        "SELECT M_Warehouse_ID, Value, Name, Separator, AD_Client_ID, AD_Org_ID "
            + "FROM M_Warehouse WHERE M_Warehouse_ID=?";

    try {
      PreparedStatement pstmt = DB.prepareStatement(SQL);

      pstmt.setInt(1, M_Warehouse_ID);

      ResultSet rs = pstmt.executeQuery();

      if (rs.next()) {
        m_M_Warehouse_ID = rs.getInt(1);
        m_M_WarehouseValue = rs.getString(2);
        m_M_WarehouseName = rs.getString(3);
        m_Separator = rs.getString(4);
        m_AD_Client_ID = rs.getInt(5);
        m_AD_Org_ID = rs.getInt(6);
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "getWarehouseInfo", e);
    }
  } // getWarehouseInfo
コード例 #17
0
ファイル: MRefList.java プロジェクト: Garridus/libertya
  /**
   * Get Reference List
   *
   * @param ctx context
   * @param AD_Reference_ID reference
   * @param Value value
   * @param trxName
   * @return List or null
   */
  public static MRefList get(Properties ctx, int AD_Reference_ID, String Value, String trxName) {

    MRefList retValue = null;
    String sql = "SELECT * FROM AD_Ref_List " + "WHERE AD_Reference_ID=? AND Value=?";
    PreparedStatement pstmt = null;

    try {

      pstmt = DB.prepareStatement(sql, trxName);
      pstmt.setInt(1, AD_Reference_ID);
      pstmt.setString(2, Value);

      ResultSet rs = pstmt.executeQuery();

      if (rs.next()) {
        retValue = new MRefList(ctx, rs, trxName);
      }

      rs.close();
      pstmt.close();
      pstmt = null;

    } catch (SQLException ex) {
      s_log.log(Level.SEVERE, sql, ex);
    }

    try {

      if (pstmt != null) {
        pstmt.close();
      }

    } catch (SQLException ex1) {
    }

    pstmt = null;

    return retValue;
  } // get
コード例 #18
0
  /**
   * Descripción de Método
   *
   * @param ctx
   * @param M_MovementLine_ID
   * @param trxName
   * @return
   */
  public static MMovementLineMA[] get(Properties ctx, int M_MovementLine_ID, String trxName) {
    ArrayList list = new ArrayList();
    String sql = "SELECT * FROM M_MovementLineMA WHERE M_MovementLine_ID=?";
    PreparedStatement pstmt = null;

    try {
      pstmt = DB.prepareStatement(sql, trxName);
      pstmt.setInt(1, M_MovementLine_ID);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        list.add(new MMovementLineMA(ctx, rs, trxName));
      }

      rs.close();
      pstmt.close();
      pstmt = null;
    } catch (Exception e) {
      s_log.log(Level.SEVERE, sql, e);
    }

    try {
      if (pstmt != null) {
        pstmt.close();
      }

      pstmt = null;
    } catch (Exception e) {
      pstmt = null;
    }

    MMovementLineMA[] retValue = new MMovementLineMA[list.size()];

    list.toArray(retValue);

    return retValue;
  } // get
コード例 #19
0
ファイル: MOrg.java プロジェクト: jdhuayta/libertya
  public static MOrg[] getOfClient(Properties ctx, String trxName) {
    String sql = "SELECT * FROM ad_org WHERE ad_client_id = ?";
    ArrayList<MOrg> orgs = new ArrayList<MOrg>();
    PreparedStatement psmt = null;

    try {
      psmt = DB.prepareStatement(sql, trxName);
      psmt.setInt(1, Env.getAD_Client_ID(ctx));
      ResultSet rs = psmt.executeQuery();

      while (rs.next()) {
        orgs.add(new MOrg(ctx, rs, trxName));
      }

      rs.close();
      psmt.close();
      psmt = null;
    } catch (Exception e) {

    }
    try {
      if (psmt != null) {
        psmt.close();
      }

      psmt = null;
    } catch (Exception e) {
      psmt = null;
    }

    MOrg[] retValue = new MOrg[orgs.size()];

    orgs.toArray(retValue);

    return retValue;
  }
コード例 #20
0
 /**
  * ************************************************************************ Load Resources. called
  * from variable constructor
  *
  * @return Array with resources
  */
 private KeyNamePair[] getResources() {
   if (m_lookup.size() == 0) {
     String sql =
         MRole.getDefault()
             .addAccessSQL(
                 "SELECT r.S_Resource_ID, r.Name, r.IsActive," //	1..3
                     + "uom.C_UOM_ID,uom.UOMSymbol " //	4..5
                     + "FROM S_Resource r, S_ResourceType rt, C_UOM uom "
                     + "WHERE r.S_ResourceType_ID=rt.S_ResourceType_ID AND rt.C_UOM_ID=uom.C_UOM_ID",
                 "r",
                 MRole.SQL_FULLYQUALIFIED,
                 MRole.SQL_RO);
     try {
       PreparedStatement pstmt = DB.prepareStatement(sql, null);
       ResultSet rs = pstmt.executeQuery();
       while (rs.next()) {
         StringBuffer sb = new StringBuffer(rs.getString(2));
         if (!"Y".equals(rs.getString(3))) sb.insert(0, '~').append('~'); // 	inactive marker
         //	Key		S_Resource_ID/Name
         KeyNamePair key = new KeyNamePair(rs.getInt(1), sb.toString());
         //	Value	C_UOM_ID/Name
         KeyNamePair value = new KeyNamePair(rs.getInt(4), rs.getString(5).trim());
         m_lookup.put(key, value);
       }
       rs.close();
       pstmt.close();
     } catch (SQLException e) {
       log.log(Level.SEVERE, sql, e);
     }
   }
   //	Convert to Array
   KeyNamePair[] retValue = new KeyNamePair[m_lookup.size()];
   m_lookup.keySet().toArray(retValue);
   Arrays.sort(retValue);
   return retValue;
 } //	getResources
コード例 #21
0
ファイル: Viewer.java プロジェクト: AtrumGeost/ati_ds
  /** Descripción de Método */
  private void cmd_translate() {
    ArrayList list = new ArrayList();
    ValueNamePair pp = null;
    String sql = "SELECT Name, AD_Language FROM AD_Language WHERE IsSystemLanguage='Y' ORDER BY 1";

    try {
      PreparedStatement pstmt = DB.prepareStatement(sql);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        list.add(new ValueNamePair(rs.getString(2), rs.getString(1)));
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "", e);
    }

    if (list.size() == 0) {
      ADialog.warn(m_WindowNo, this, "NoTranslation");

      return;
    }

    // Dialog

    String title = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", true);
    String message = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", false);
    int choice =
        JOptionPane.showOptionDialog(
            this,
            message,
            title,
            JOptionPane.OK_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            list.toArray(),
            null);

    if (choice == JOptionPane.CLOSED_OPTION) {
      return;
    }

    //

    pp = (ValueNamePair) list.get(choice);

    String AD_Language = pp.getValue();
    int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().getID();

    log.config(AD_Language + " - AD_PrintFormat_ID=" + AD_PrintFormat_ID);

    StringBuffer sb = new StringBuffer();

    // English

    if (Language.isBaseLanguage(AD_Language)) {
      sb.append(
              "UPDATE AD_PrintFormatItem pfi "
                  + "SET Name = (SELECT e.Name FROM AD_Element e, AD_Column c"
                  + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID),"
                  + "PrintName = (SELECT e.PrintName FROM AD_Element e, AD_Column c"
                  + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) "
                  + "WHERE AD_PrintFormat_ID=")
          .append(AD_PrintFormat_ID)
          .append(
              " AND EXISTS (SELECT * FROM AD_Element e, AD_Column c"
                  + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)");
    } else {
      AD_Language = "'" + AD_Language + "'";
      sb.append(
              "UPDATE AD_PrintFormatItem pfi "
                  + "SET Name = (SELECT e.Name FROM AD_Element_Trl e, AD_Column c"
                  + " WHERE e.AD_Language=")
          .append(AD_Language)
          .append(
              " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID), "
                  + "PrintName = (SELECT e.PrintName FROM AD_Element_Trl e, AD_Column c"
                  + "     WHERE e.AD_Language=")
          .append(AD_Language)
          .append(
              " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) "
                  + "WHERE AD_PrintFormat_ID=")
          .append(AD_PrintFormat_ID)
          .append(
              " AND EXISTS (SELECT * FROM AD_Element_Trl e, AD_Column c" + " WHERE e.AD_Language=")
          .append(AD_Language)
          .append(" AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)");
    }

    int count = DB.executeUpdate(sb.toString());

    log.config("Count=" + count);

    //

    m_reportEngine.setPrintFormat(MPrintFormat.get(Env.getCtx(), AD_PrintFormat_ID, true));
    revalidate();
  } // cmd_translate
コード例 #22
0
ファイル: Viewer.java プロジェクト: AtrumGeost/ati_ds
  /** Descripción de Método */
  private void cmd_find() {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
    String title = null;
    String tableName = null;

    // Get Find Tab Info

    String sql =
        "SELECT t.AD_Tab_ID "

            // ,w.Name, t.Name, w.IsDefault, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)

            + "FROM AD_Tab t"
            + " INNER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)"
            + " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID) "
            + "WHERE t.AD_Table_ID=? "
            + "ORDER BY w.IsDefault DESC, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)";
    int AD_Tab_ID = DB.getSQLValue(null, sql, AD_Table_ID);

    //

    sql = "SELECT Name, TableName FROM AD_Tab_v WHERE AD_Tab_ID=?";

    if (!Env.isBaseLanguage(Env.getCtx(), "AD_Tab")) {
      sql =
          "SELECT Name, TableName FROM AD_Tab_vt WHERE AD_Tab_ID=?"
              + " AND AD_Language='"
              + Env.getAD_Language(Env.getCtx())
              + "'";
    }

    try {
      PreparedStatement pstmt = DB.prepareStatement(sql);

      pstmt.setInt(1, AD_Tab_ID);

      ResultSet rs = pstmt.executeQuery();

      //

      if (rs.next()) {
        title = rs.getString(1);
        tableName = rs.getString(2);
      }

      //

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "MTabVO.create(1)", e);
    }

    MField[] findFields = null;

    if (tableName != null) {
      findFields = MField.createFields(m_ctx, m_WindowNo, 0, AD_Tab_ID);
    }

    if (findFields == null) { // No Tab for Table exists
      bFind.setEnabled(false);
    } else {
      Find find = new Find(this, m_WindowNo, title, AD_Table_ID, tableName, "", findFields, 1);

      m_reportEngine.setQuery(find.getQuery());
      revalidate();
    }

    cmd_drill(); // setCursor
  } // cmd_find
コード例 #23
0
  private boolean importReportLineSource() {
    // Primero, debemos actualizar el valor de las lineas de informe con el id del reportLine
    String sql =
        "update i_reportlineset set pa_reportline_id= ( select rl.pa_reportline_id from pa_reportline rl, pa_reportlineset rls 	where rl.pa_reportlineset_id=rls.pa_reportlineset_id 	and rl.name=trim(i_reportlineset.name) and rls.name=trim(i_reportlineset.rls_name) and rl.ad_client_id=i_reportlineset.ad_client_id and rl.ad_org_id=i_reportlineset.ad_org_id and rls.ad_client_id=i_reportlineset.ad_client_id and rls.ad_org_id=i_reportlineset.ad_org_id) where isReportSource='Y'";
    // String sql = "update i_reportlineset ir set ir.pa_reportline_id= ( select rl.pa_reportline_id
    // from pa_reportline rl where rl.pa_reportlineset_id=ir.pa_reportlineset_id 	and
    // rl.name=trim(ir.name) and rl.ad_client_id=ir.ad_client_id and rl.ad_org_id=ir.ad_org_id)
    // where ir.isReportSource='Y'";
    if (DB.executeUpdate(sql, trxName) == -1) {
      log.log(Level.SEVERE, "Error actualizado el pa_reportline_id de las fuentes");
      return false;
    }
    // Establecemos la cuenta
    sql =
        "update i_reportlineset as ir set c_elementvalue_id= ( select ev.c_elementvalue_id from c_elementvalue ev where ev.issummary='Y' and ev.value=trim(ir.ev_value) and ev.ad_org_id=ir.ad_org_id) where ir.isReportSource='Y' and ir.ev_value is not null and ir.c_elementvalue_id is null and ir.rs_elementType='AC'";
    if (DB.executeUpdate(sql, trxName) == -1) {
      log.log(Level.SEVERE, "Error actualizado el c_elementvalue_id de las fuentes");
      return false;
    }

    sql =
        "update i_reportlineset as ir set i_isimported='E', i_errorMsg='fuente invalida' where ir.isReportSource='Y' and (ir.c_elementvalue_id is null or ir.c_elementvalue_id=0) and ir.rs_elementtype='AC' and (ir.pa_reportline_id is null or ir.pa_reportline_id=0)";
    if (DB.executeUpdate(sql, trxName) == -1) {
      log.log(Level.SEVERE, "Error marcando fuentes erroneas.");
      return false;
    }

    sql =
        "select * from i_reportlineset as ir where ir.isReportSource='Y' and ir.I_isImported='N' and ir.rs_elementtype='AC'";
    try {
      PreparedStatement pstmt = DB.prepareStatement(sql, trxName);
      ResultSet rs = pstmt.executeQuery();
      while (rs.next()) {
        X_PA_ReportSource r = new X_PA_ReportSource(getCtx(), 0, trxName);
        X_I_ReportLineSet ir = new X_I_ReportLineSet(getCtx(), rs, trxName);

        r.set_TrxName(trxName);
        r.setElementType(r.ELEMENTTYPE_Account);
        r.setC_ElementValue_ID(ir.getC_ElementValue_ID());
        if (ir.getEv_Value().trim().equals("395")) {
          log.log(Level.SEVERE, "PA_ReportLine_ID: " + ir.getPA_ReportLine_ID());
        }
        r.setPA_ReportLine_ID(ir.getPA_ReportLine_ID());

        if (r.save(trxName) == false) {
          log.log(
              Level.SEVERE,
              "Error creando las fuentes del informe:"
                  + ir.getEv_Value()
                  + ": "
                  + r.getPA_ReportLine_ID());
          return false;
        }

        ir.setPA_ReportSource_ID(r.getPA_ReportSource_ID());
        ir.setI_IsImported(true);

        if (ir.save(trxName) == false) {
          log.log(
              Level.SEVERE, "Error guardando el PA_ReportSource_ID en la tabla de importacion.");
          return false;
        }
      }
    } catch (SQLException e) {
      log.log(Level.SEVERE, "Error recorriendo las lineas de fuente.");
      return false;
    }

    return true;
  }
コード例 #24
0
ファイル: MRefList.java プロジェクト: Garridus/libertya
  public static String getListName(String AD_Language, int AD_Reference_ID, String Value) {

    String key = AD_Language + "_" + AD_Reference_ID + "_" + Value;
    String retValue = (String) s_cache.get(key);

    if (retValue != null) {
      return retValue;
    }

    boolean isBaseLanguage = Env.isBaseLanguage(AD_Language, "AD_Ref_List");
    String sql =
        isBaseLanguage
            ? "SELECT Name FROM AD_Ref_List " + "WHERE AD_Reference_ID=? AND Value=?"
            : "SELECT t.Name FROM AD_Ref_List_Trl t"
                + " INNER JOIN AD_Ref_List r ON (r.AD_Ref_List_ID=t.AD_Ref_List_ID) "
                + "WHERE r.AD_Reference_ID=? AND r.Value=? AND t.AD_Language=?";
    PreparedStatement pstmt = null;

    try {

      pstmt = DB.prepareStatement(sql, null);
      pstmt.setInt(1, AD_Reference_ID);
      pstmt.setString(2, Value);

      if (!isBaseLanguage) {
        pstmt.setString(3, AD_Language);
      }

      ResultSet rs = pstmt.executeQuery();

      if (rs.next()) {
        retValue = rs.getString(1);
      }

      rs.close();
      pstmt.close();
      pstmt = null;

    } catch (SQLException ex) {
      s_log.log(Level.SEVERE, "getListName - " + sql + " - " + key, ex);
    }

    try {

      if (pstmt != null) {
        pstmt.close();
      }

    } catch (SQLException ex1) {
    }

    pstmt = null;

    // Save into Cache
    if (retValue == null) {

      retValue = "";
      s_log.warning("getListName - Not found " + key);
    }

    s_cache.put(key, retValue);

    //
    return retValue;
  }
コード例 #25
0
ファイル: MRefList.java プロジェクト: Garridus/libertya
  /**
   * Get Reference List
   *
   * @param AD_Reference_ID reference
   * @param optional if true add "",""
   * @return List or null
   */
  public static ValueNamePair[] getList(int AD_Reference_ID, boolean optional, Properties ctx) {
    boolean isBaseLanguage = ctx == null || Env.isBaseLanguage(ctx, "AD_Ref_List");

    String sql = null;
    String language = null;

    if (isBaseLanguage) {
      sql =
          "SELECT Value, Name "
              + "FROM AD_Ref_List "
              + "WHERE AD_Reference_ID=? AND IsActive='Y' ORDER BY 1";
    } else {
      language = Env.getAD_Language(ctx);
      sql =
          "SELECT l.Value, t.Name "
              + "FROM AD_Ref_List_Trl t "
              + "INNER JOIN AD_Ref_List l ON (t.AD_Ref_List_ID = l.AD_Ref_List_ID) "
              + "WHERE l.AD_Reference_ID=? AND l.IsActive='Y' AND t.AD_Language=? ORDER BY 1";
    }
    PreparedStatement pstmt = null;
    ArrayList list = new ArrayList();

    if (optional) {
      list.add(new ValueNamePair("", ""));
    }

    try {

      pstmt = DB.prepareStatement(sql);
      pstmt.setInt(1, AD_Reference_ID);
      if (!isBaseLanguage) {
        pstmt.setString(2, language);
      }
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        list.add(new ValueNamePair(rs.getString(1), rs.getString(2)));
      }

      rs.close();
      pstmt.close();
      pstmt = null;

    } catch (Exception e) {
      s_log.log(Level.SEVERE, "getList " + sql, e);
    }

    try {

      if (pstmt != null) {
        pstmt.close();
      }

      pstmt = null;

    } catch (Exception e) {
      pstmt = null;
    }

    ValueNamePair[] retValue = new ValueNamePair[list.size()];

    list.toArray(retValue);

    return retValue;
  } // getList
コード例 #26
0
ファイル: AD_Column_Sync.java プロジェクト: jdhuayta/libertya
  /**
   * Descripción de Método
   *
   * @return
   * @throws Exception
   */
  protected String doIt() throws Exception {
    StringBuffer sql =
        new StringBuffer(
            "SELECT     t.TableName, c.ColumnName, c.AD_Reference_ID, c.FieldLength, c.DefaultValue, c.IsMandatory FROM AD_Table t, AD_Column c WHERE   t.AD_Table_ID = c.AD_Table_ID AND c.AD_Column_ID = ?");

    log.finest(sql.toString());

    PreparedStatement pstmt = null;

    try {
      pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
      pstmt.setInt(1, v_Record_ID);

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        v_TableName = rs.getString(1);
        v_ColumnName = rs.getString(2);
        v_AD_Reference_ID = rs.getInt(3);
        v_FieldLength = rs.getInt(4);
        v_DefaultValue = rs.getString(5);
        v_IsMandatory = (rs.getString(6).compareTo("Y") == 0) ? true : false;
      }

      rs.close();
      pstmt.close();
      pstmt = null;
    } catch (Exception e) {
      log.log(Level.SEVERE, "doIt", e);
    }

    try {
      if (pstmt != null) {
        pstmt.close();
      }

      pstmt = null;
    } catch (Exception e) {
      pstmt = null;
    }

    DatabaseMetaData md = DB.getConnectionRO().getMetaData();

    // find v_DB_TableName <> null

    ResultSet rsTables =
        md.getTables(md.getConnection().getCatalog(), "openXpertya", "%", new String[] {"TABLE"});

    if (rsTables != null) {
      while (rsTables.next()) {
        if (rsTables.getString(3).toUpperCase().compareTo(v_TableName.toUpperCase()) == 0) {
          v_DB_TableName = rsTables.getString(3).toUpperCase();
        }
      }
    }

    rsTables.close();

    if (v_DB_TableName == null) {
      log.info("Create Table Command");
      v_CMD = "CREATE TABLE " + v_TableName.toUpperCase() + "(XXXX CHAR(1))";

      try {
        DB.executeUpdate(v_CMD);
      } catch (Exception e) {
        log.log(Level.SEVERE, "Error: " + v_CMD, e);
      }
    }

    try {
      System.out.println("Table" + v_TableName.toUpperCase());
      md = DB.getConnectionRO().getMetaData();

      // System.out.println("getCatalog():" + md.getConnection().getCatalog());
      // ResultSet sourceColumns = md.getColumns(md.getConnection().getCatalog(), null ,
      // v_TableName.toUpperCase(), null);

      ResultSet sourceColumns =
          md.getColumns(
              md.getConnection().getCatalog(), "openXpertya", v_TableName.toLowerCase(), "%");

      while (sourceColumns.next()) {

        // System.out.println("ResultSet sourceColumns");

        String columnName = sourceColumns.getString("COLUMN_NAME");

        // System.out.println("Metadata" + columnName + "Internal" + v_ColumnName);
        // Data Type & Precision

        if (columnName.toUpperCase().compareTo(v_ColumnName.toUpperCase()) == 0) {

          // v_DB_DataType = sourceColumns.getInt ("DATA_TYPE");           //      sql.Types

          v_DB_DataType = sourceColumns.getString("TYPE_NAME");

          break;

          // System.out.println("e-evolution --------------" + v_DB_DataType);
          // String typeName = sourceColumns.getString ("TYPE_NAME");      //      DB Dependent
          // int size = sourceColumns.getInt ("COLUMN_SIZE");
          // int decDigits = sourceColumns.getInt("DECIMAL_DIGITS");
          // if (sourceColumns.wasNull())
          // decDigits = -1;

        }
      } // for all columns

      sourceColumns.close();
    } catch (Exception ex) {
      log.log(Level.SEVERE, "createTable", ex);

      return "";
    }

    // Create Statement

    if (v_DB_DataType == null) {
      log.info("Create ALTER Command");

      // Get TableName

      v_CMD = "ALTER TABLE " + v_TableName.toUpperCase() + " ADD " + v_ColumnName + " ";

      // Map Data Type

      if ((v_AD_Reference_ID == 10)
          || (v_AD_Reference_ID == 11)
          || (v_AD_Reference_ID == 12)
          || (v_AD_Reference_ID == 13)
          || (v_AD_Reference_ID == 14)) {

        // String, Text

        v_CMD = v_CMD + "NVARCHAR2(" + v_FieldLength + ')';
      } else if ((v_AD_Reference_ID == 17)
          || (v_AD_Reference_ID == 20)
          || (v_AD_Reference_ID == 28)) {

        // List,YesNo,Button

        v_CMD = v_CMD + "CHAR(" + v_FieldLength + ")";
      } else if ((v_AD_Reference_ID == 13)
          || (v_AD_Reference_ID == 18)
          || (v_AD_Reference_ID == 19)
          || (v_AD_Reference_ID == 21)
          || (v_AD_Reference_ID == 25)
          || (v_AD_Reference_ID == 27)
          || (v_AD_Reference_ID == 30)
          || (v_AD_Reference_ID == 31)) {

        // ID,Table,TableDir,Location,Account,Color,Search,Locator

        v_CMD = v_CMD + "NUMBER(10)";
      } else if ((v_AD_Reference_ID == 11)
          || (v_AD_Reference_ID == 12)
          || (v_AD_Reference_ID == 22)
          || (v_AD_Reference_ID == 29)) { // Integer,Amount,Number,Quantity
        v_CMD = v_CMD + "NUMBER";
      } else if ((v_AD_Reference_ID == 15) || (v_AD_Reference_ID == 16)) { // Date,DateTime
        v_CMD = v_CMD + "DATE";
      } else {

        // 23-Binary, 24-Radio, 26-RowID, 32-Image

        return "DisplayType Not Supported";
      }

      // Default (literal)

      if ((v_DefaultValue != null) && (v_DefaultValue.length() != 0)) {
        if ((v_AD_Reference_ID == 10)
            || (v_AD_Reference_ID == 14)
            || (v_AD_Reference_ID == 17)
            || (v_AD_Reference_ID == 20)
            || (v_AD_Reference_ID == 28)) {
          v_CMD = v_CMD + " DEFAULT ('" + v_DefaultValue + "')";
        } else {
          v_CMD = v_CMD + " DEFAULT " + v_DefaultValue;
        }
      }

      // Mandatory

      if (v_IsMandatory) {
        if ((v_DefaultValue == null) || (v_DefaultValue.length() == 0)) {
          return "Mandatory requites literal default value";
        } else {
          v_CMD = v_CMD + " NOT NULL";
        }
      }

      try {
        DB.executeUpdate(v_CMD, false, get_TrxName());

        return "@Created@ - " + v_CMD;
      } catch (Exception ex) {
        log.log(Level.SEVERE, "Error Command: " + v_CMD, ex);

        return "Error Command: " + v_CMD;
      }
    } else {
      log.info("CreateALTERCommand");

      // Get TableName

      if (DB.isOracle()) {
        v_CMD = "ALTER TABLE " + v_TableName + " MODIFY " + v_ColumnName + " ";
      }

      if (DB.isPostgreSQL()) {
        v_CMD = "ALTER TABLE " + v_TableName + " ALTER COLUMN " + v_ColumnName + " TYPE ";
      }

      // Map Data Type

      if ((v_AD_Reference_ID == 10) || (v_AD_Reference_ID == 14)) { // String, Text
        v_CMD = v_CMD + "NVARCHAR2(" + v_FieldLength + ")";
      } else if ((v_AD_Reference_ID == 17)
          || (v_AD_Reference_ID == 20)
          || (v_AD_Reference_ID == 28)) {

        // List,YesNo,Button

        v_CMD = v_CMD + "CHAR(" + v_FieldLength + ")";
      } else if ((v_AD_Reference_ID == 13)
          || (v_AD_Reference_ID == 18)
          || (v_AD_Reference_ID == 19)
          || (v_AD_Reference_ID == 21)
          || (v_AD_Reference_ID == 25)
          || (v_AD_Reference_ID == 27)
          || (v_AD_Reference_ID == 30)
          || (v_AD_Reference_ID == 31)) { // ID,Table,TableDir,Location,Account,Color,Search,Locator
        v_CMD = v_CMD + "NUMBER(10)";
      } else if ((v_AD_Reference_ID == 11)
          || (v_AD_Reference_ID == 12)
          || (v_AD_Reference_ID == 22)
          || (v_AD_Reference_ID == 29)) { // Integer,Amount,Number,Quantity
        v_CMD = v_CMD + "NUMBER";
      } else if ((v_AD_Reference_ID == 15) || (v_AD_Reference_ID == 16)) { // Date,DateTime
        v_CMD = v_CMD + "DATE";
      } else {

        // 23-Binary, 24-Radio, 26-RowID, 32-Image

        return "DisplayType Not Supported";
      }

      // Default (literal)

      if ((v_DefaultValue != null) && (v_DefaultValue.length() != 0)) {
        if ((v_AD_Reference_ID == 10)
            || (v_AD_Reference_ID == 14)
            || (v_AD_Reference_ID == 17)
            || (v_AD_Reference_ID == 20)
            || (v_AD_Reference_ID == 28)) {
          v_CMD = v_CMD + " DEFAULT ('" + v_DefaultValue + "')";
        } else {
          v_CMD = v_CMD + " DEFAULT " + v_DefaultValue;
        }
      }

      // Mandatory

      if (v_IsMandatory) {
        if ((v_DefaultValue == null) || (v_DefaultValue.length() == 0)) {
          return "Mandatory requites literal default value";
        } else {
          v_CMD = v_CMD + " NOT NULL";
        }
      }

      try {
        DB.executeUpdate(v_CMD, false, get_TrxName());

        return "@Updated@ - " + v_CMD;
      } catch (Exception ex) {
        log.log(Level.SEVERE, "Error Command: " + v_CMD, ex);

        return "Error Command: " + v_CMD;
      }

      /*
       * --      Table did not exist - drop initial column
       * IF (v_DB_TableName IS NULL) THEN
       *       v_ResultStr := 'CreateDropXXColumnCommand';
       *       BEGIN
       *               v_CMD := 'ALTER TABLE ' || v_TableName || ' DROP COLUMN XXXX';
       *               EXECUTE IMMEDIATE v_Cmd;
       *       EXCEPTION
       *               WHEN OTHERS THEN
       *                       v_Result := 0;  -- failure
       *                       v_Message := 'Error: ' || SQLERRM || ' - Command: ' || v_Cmd;
       *       END;
       * END IF;
       */

    }
  } // doIt
コード例 #27
0
  /**
   * Descripción de Método
   *
   * @param C_Invoice_ID
   */
  private void loadInvoice(int C_Invoice_ID) {
    log.config("C_Invoice_ID=" + C_Invoice_ID);
    if (C_Invoice_ID > 0) {
      m_invoice = new MInvoice(Env.getCtx(), C_Invoice_ID, null); // save
      // Se carga la EC de la factura.
      if (bPartnerField != null) {
        bPartnerField.setValue(m_invoice.getC_BPartner_ID());
      }
    }
    p_order = null;

    List<InvoiceLine> data = new ArrayList<InvoiceLine>();

    StringBuffer sql = new StringBuffer();
    sql.append("SELECT ") // Entered UOM
        .append("l.C_InvoiceLine_ID, ")
        .append("l.Line, ")
        .append("l.Description, ")
        .append("l.M_Product_ID, ")
        .append("p.Name AS ProductName, ")
        .append("l.C_UOM_ID, ")
        .append("QtyInvoiced, ")
        .append("l.QtyInvoiced-SUM(NVL(mi.Qty,0)) AS RemainingQty, ")
        .append("l.QtyEntered/l.QtyInvoiced AS Multiplier, ")
        .append("COALESCE(l.C_OrderLine_ID,0) AS C_OrderLine_ID ")
        .append("FROM C_UOM uom, C_InvoiceLine l, M_Product p, M_MatchInv mi ")
        .append("WHERE l.C_UOM_ID=uom.C_UOM_ID ")
        .append("AND l.M_Product_ID=p.M_Product_ID ")
        .append("AND l.C_InvoiceLine_ID=mi.C_InvoiceLine_ID(+) ")
        .append("AND l.C_Invoice_ID=? ")
        .append(
            "GROUP BY l.QtyInvoiced, l.QtyEntered/l.QtyInvoiced, l.C_UOM_ID, l.M_Product_ID, p.Name, l.C_InvoiceLine_ID, l.Line, l.C_OrderLine_ID, l.Description ")
        .append("ORDER BY l.Line ");

    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {
      pstmt = DB.prepareStatement(sql.toString());
      pstmt.setInt(1, C_Invoice_ID);
      rs = pstmt.executeQuery();

      while (rs.next()) {
        InvoiceLine invoiceLine = new InvoiceLine();

        // Por defecto no está seleccionada para ser procesada
        invoiceLine.selected = false;

        // ID de la línea de factura
        invoiceLine.invoiceLineID = rs.getInt("C_InvoiceLine_ID");

        // Nro de línea
        invoiceLine.lineNo = rs.getInt("Line");

        // Descripción
        invoiceLine.description = rs.getString("Description");

        // Cantidades
        BigDecimal multiplier = rs.getBigDecimal("Multiplier");
        BigDecimal qtyInvoiced = rs.getBigDecimal("QtyInvoiced").multiply(multiplier);
        BigDecimal remainingQty = rs.getBigDecimal("RemainingQty").multiply(multiplier);
        invoiceLine.lineQty = qtyInvoiced;
        invoiceLine.remainingQty = remainingQty;

        // Artículo
        invoiceLine.productID = rs.getInt("M_Product_ID");
        invoiceLine.productName = rs.getString("ProductName");

        // Unidad de Medida
        invoiceLine.uomID = rs.getInt("C_UOM_ID");
        invoiceLine.uomName = getUOMName(invoiceLine.uomID);

        // Línea de pedido (puede ser 0)
        invoiceLine.orderLineID = rs.getInt("C_OrderLine_ID");

        // Agrega la línea a la lista solo si tiene cantidad pendiente
        if (invoiceLine.remainingQty.compareTo(BigDecimal.ZERO) > 0) {
          data.add(invoiceLine);
        }
      }

    } catch (SQLException e) {
      log.log(Level.SEVERE, sql.toString(), e);
    } finally {
      try {
        if (rs != null) rs.close();
        if (pstmt != null) pstmt.close();
      } catch (Exception e) {
      }
    }

    loadTable(data);
  } // loadInvoice
コード例 #28
0
ファイル: Viewer.java プロジェクト: AtrumGeost/ati_ds
  /** Descripción de Método */
  private void dynInit() {
    createMenu();

    //              comboZoom.addActionListener(this);
    // Change Listener to set Page no

    // centerScrollPane.getViewport().addChangeListener( this );

    // Max Page

    m_pageMax = m_viewPanel.getPageCount();
    spinnerModel.setMaximum(new Integer(m_pageMax));
    spinner.addChangeListener(this);
    fillComboReport(m_reportEngine.getPrintFormat().getID());

    // View Panel Mouse Listener

    m_viewPanel.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
              mouse_clicked(e, true);
            } else if (e.getClickCount() > 1) {
              mouse_clicked(e, false);
            }
          }
        });

    // fill Drill Options (Name, TableName)

    comboDrill.addItem(new ValueNamePair(null, ""));

    String sql =
        "SELECT t.AD_Table_ID, t.TableName, e.PrintName, NULLIF(e.PO_PrintName,e.PrintName) "
            + "FROM AD_Column c "
            + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)"
            + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)"
            + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')"
            + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName) "
            + "WHERE c.AD_Table_ID=? AND c.IsKey='Y' "
            + "ORDER BY 3";
    boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Element");

    if (trl) {
      sql =
          "SELECT t.AD_Table_ID, t.TableName, et.PrintName, NULLIF(et.PO_PrintName,et.PrintName) "
              + "FROM AD_Column c"
              + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)"
              + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)"
              + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')"
              + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName)"
              + " INNER JOIN AD_Element_Trl et ON (e.AD_Element_ID=et.AD_Element_ID) "
              + "WHERE c.AD_Table_ID=? AND c.IsKey='Y'"
              + " AND et.AD_Language=? "
              + "ORDER BY 3";
    }

    try {
      PreparedStatement pstmt = DB.prepareStatement(sql);

      pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID());

      if (trl) {
        pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
      }

      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        String tableName = rs.getString(2);
        String name = rs.getString(3);
        String poName = rs.getString(4);

        if (poName != null) {
          name += "/" + poName;
        }

        comboDrill.addItem(new ValueNamePair(tableName, name));
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "Drill", e);
    }

    if (comboDrill.getItemCount() == 1) {
      labelDrill.setVisible(false);
      comboDrill.setVisible(false);
    } else {
      comboDrill.addActionListener(this);
    }

    revalidate();
  } // dynInit
コード例 #29
0
ファイル: ProcessCtl.java プロジェクト: AtrumGeost/ati_ds
  /** 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
コード例 #30
0
ファイル: VLocatorDialog.java プロジェクト: jdhuayta/libertya
  /** Descripción de Método */
  private void initLocator() {
    log.fine("");

    // Load Warehouse

    String sql = "SELECT M_Warehouse_ID, Name FROM M_Warehouse";

    if (m_only_Warehouse_ID != 0) {
      sql += " WHERE M_Warehouse_ID=" + m_only_Warehouse_ID;
    }

    String SQL =
        MRole.getDefault().addAccessSQL(sql, "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO)
            + " ORDER BY 2";

    try {
      PreparedStatement pstmt = DB.prepareStatement(SQL);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        fWarehouse.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
      }

      rs.close();
      pstmt.close();
    } catch (SQLException e) {
      log.log(Level.SEVERE, "warehouse", e);
    }

    log.fine("Warehouses=" + fWarehouse.getItemCount());

    // Load existing Locators

    m_mLocator.fillComboBox(m_mandatory, true, true, false);
    log.fine(m_mLocator.toString());
    fLocator.setModel(m_mLocator);
    fLocator.setValue(m_M_Locator_ID);
    fLocator.addActionListener(this);
    displayLocator();

    //

    fCreateNew.setSelected(false);
    fCreateNew.addActionListener(this);
    enableNew();

    //

    fWarehouse.addActionListener(this);
    fX.addKeyListener(this);
    fY.addKeyListener(this);
    fZ.addKeyListener(this);

    // Guarda el ID de la ubicación con la cual se invocó el constructor
    // de este diálogo. Este ID se utiliza en caso de cancelar el diálogo
    // para recuperar el valor que tenía previamente el ID de ubicación.
    m_OriginalLocatorID = m_M_Locator_ID;

    // Update UI

    pack();
  } // initLocator