コード例 #1
0
  public static UpdateReferenceDataData[] selectModules(
      ConnectionProvider connectionProvider,
      String modules,
      String organization,
      int firstRegister,
      int numberRegisters)
      throws ServletException {
    String strSql = "";
    strSql =
        strSql
            + "      SELECT AD_MODULE.NAME, AD_MODULE.HASCHARTOFACCOUNTS, AD_MODULE.ISTRANSLATIONMODULE, "
            + "      AD_MODULE.AD_MODULE_ID , AD_MODULE.JAVAPACKAGE, AD_DATASET.NAME AS DATASETNAME, AD_MODULE.VERSION, AD_DATASET.CHECKSUM"
            + "      FROM AD_MODULE, AD_DATASET"
            + "      WHERE AD_MODULE.AD_MODULE_ID = AD_DATASET.AD_MODULE_ID      "
            + "      AND AD_MODULE.AD_MODULE_ID IN ";
    strSql = strSql + ((modules == null || modules.equals("")) ? "" : modules);
    strSql =
        strSql
            + "      AND AD_DATASET.ISACTIVE='Y'"
            + "      AND ((? <> '0' AND AD_DATASET.ACCESSLEVEL IN ('3','1')) OR (? = '0' AND AD_DATASET.ACCESSLEVEL IN ('3','6')))"
            + "      ORDER BY AD_MODULE.AD_MODULE_ID, AD_DATASET.SEQNO, AD_DATASET.AD_DATASET_ID";

    ResultSet result;
    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
    PreparedStatement st = null;

    int iParameter = 0;
    try {
      st = connectionProvider.getPreparedStatement(strSql);
      if (modules != null && !(modules.equals(""))) {}
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, organization);
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, organization);

      result = st.executeQuery();
      long countRecord = 0;
      long countRecordSkip = 1;
      boolean continueResult = true;
      while (countRecordSkip < firstRegister && continueResult) {
        continueResult = result.next();
        countRecordSkip++;
      }
      while (continueResult && result.next()) {
        countRecord++;
        UpdateReferenceDataData objectUpdateReferenceDataData = new UpdateReferenceDataData();
        objectUpdateReferenceDataData.name = UtilSql.getValue(result, "name");
        objectUpdateReferenceDataData.haschartofaccounts =
            UtilSql.getValue(result, "haschartofaccounts");
        objectUpdateReferenceDataData.istranslationmodule =
            UtilSql.getValue(result, "istranslationmodule");
        objectUpdateReferenceDataData.adModuleId = UtilSql.getValue(result, "ad_module_id");
        objectUpdateReferenceDataData.javapackage = UtilSql.getValue(result, "javapackage");
        objectUpdateReferenceDataData.datasetname = UtilSql.getValue(result, "datasetname");
        objectUpdateReferenceDataData.version = UtilSql.getValue(result, "version");
        objectUpdateReferenceDataData.checksum = UtilSql.getValue(result, "checksum");
        objectUpdateReferenceDataData.InitRecordNumber = Integer.toString(firstRegister);
        vector.addElement(objectUpdateReferenceDataData);
        if (countRecord >= numberRegisters && numberRegisters != 0) {
          continueResult = false;
        }
      }
      result.close();
    } catch (SQLException e) {
      log4j.error("SQL error in query: " + strSql + "Exception:" + e);
      throw new ServletException(
          "@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
    } catch (Exception ex) {
      log4j.error("Exception in query: " + strSql + "Exception:" + ex);
      throw new ServletException("@CODE=@" + ex.getMessage());
    } finally {
      try {
        connectionProvider.releasePreparedStatement(st);
      } catch (Exception ignore) {
        ignore.printStackTrace();
      }
    }
    UpdateReferenceDataData objectUpdateReferenceDataData[] =
        new UpdateReferenceDataData[vector.size()];
    vector.copyInto(objectUpdateReferenceDataData);
    return (objectUpdateReferenceDataData);
  }
コード例 #2
0
  public static UpdateReferenceDataData[] select(
      ConnectionProvider connectionProvider, int firstRegister, int numberRegisters)
      throws ServletException {
    String strSql = "";
    strSql =
        strSql
            + "      SELECT '' as id, '' as NAME, '' AS HASCHARTOFACCOUNTS, '' AS  ISTRANSLATIONMODULE,"
            + "      '' AS AD_MODULE_ID, '' AS PATH, '' AS  JAVAPACKAGE, '' AS DATASETNAME, '' AS VERSION, '' AS CHECKSUM"
            + "      FROM DUAL";

    ResultSet result;
    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
    PreparedStatement st = null;

    try {
      st = connectionProvider.getPreparedStatement(strSql);

      result = st.executeQuery();
      long countRecord = 0;
      long countRecordSkip = 1;
      boolean continueResult = true;
      while (countRecordSkip < firstRegister && continueResult) {
        continueResult = result.next();
        countRecordSkip++;
      }
      while (continueResult && result.next()) {
        countRecord++;
        UpdateReferenceDataData objectUpdateReferenceDataData = new UpdateReferenceDataData();
        objectUpdateReferenceDataData.id = UtilSql.getValue(result, "id");
        objectUpdateReferenceDataData.name = UtilSql.getValue(result, "name");
        objectUpdateReferenceDataData.haschartofaccounts =
            UtilSql.getValue(result, "haschartofaccounts");
        objectUpdateReferenceDataData.istranslationmodule =
            UtilSql.getValue(result, "istranslationmodule");
        objectUpdateReferenceDataData.adModuleId = UtilSql.getValue(result, "ad_module_id");
        objectUpdateReferenceDataData.path = UtilSql.getValue(result, "path");
        objectUpdateReferenceDataData.javapackage = UtilSql.getValue(result, "javapackage");
        objectUpdateReferenceDataData.datasetname = UtilSql.getValue(result, "datasetname");
        objectUpdateReferenceDataData.version = UtilSql.getValue(result, "version");
        objectUpdateReferenceDataData.checksum = UtilSql.getValue(result, "checksum");
        objectUpdateReferenceDataData.InitRecordNumber = Integer.toString(firstRegister);
        vector.addElement(objectUpdateReferenceDataData);
        if (countRecord >= numberRegisters && numberRegisters != 0) {
          continueResult = false;
        }
      }
      result.close();
    } catch (SQLException e) {
      log4j.error("SQL error in query: " + strSql + "Exception:" + e);
      throw new ServletException(
          "@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
    } catch (Exception ex) {
      log4j.error("Exception in query: " + strSql + "Exception:" + ex);
      throw new ServletException("@CODE=@" + ex.getMessage());
    } finally {
      try {
        connectionProvider.releasePreparedStatement(st);
      } catch (Exception ignore) {
        ignore.printStackTrace();
      }
    }
    UpdateReferenceDataData objectUpdateReferenceDataData[] =
        new UpdateReferenceDataData[vector.size()];
    vector.copyInto(objectUpdateReferenceDataData);
    return (objectUpdateReferenceDataData);
  }
コード例 #3
0
  public static UpdateReferenceDataData[] selectOrganization(
      ConnectionProvider connectionProvider,
      String rol,
      String adOrgClient,
      int firstRegister,
      int numberRegisters)
      throws ServletException {
    String strSql = "";
    strSql =
        strSql
            + "       SELECT A_O.AD_ORG_ID AS ID, A_O.NAME "
            + "       FROM AD_ORG A_O, AD_ROLE_ORGACCESS A_R_O, AD_ROLE R "
            + "       WHERE A_R_O.AD_ORG_ID = A_O.AD_ORG_ID "
            + "       AND A_R_O.ISACTIVE = 'Y' "
            + "       AND A_R_O.AD_ROLE_ID = R.AD_ROLE_ID "
            + "       AND R.ISACTIVE = 'Y'"
            + "       AND A_R_O.AD_ROLE_ID = ? "
            + "       AND A_O.AD_Org_ID IN(";
    strSql = strSql + ((adOrgClient == null || adOrgClient.equals("")) ? "" : adOrgClient);
    strSql = strSql + ")" + "       ORDER BY A_O.NAME";

    ResultSet result;
    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
    PreparedStatement st = null;

    int iParameter = 0;
    try {
      st = connectionProvider.getPreparedStatement(strSql);
      iParameter++;
      UtilSql.setValue(st, iParameter, 12, null, rol);
      if (adOrgClient != null && !(adOrgClient.equals(""))) {}

      result = st.executeQuery();
      long countRecord = 0;
      long countRecordSkip = 1;
      boolean continueResult = true;
      while (countRecordSkip < firstRegister && continueResult) {
        continueResult = result.next();
        countRecordSkip++;
      }
      while (continueResult && result.next()) {
        countRecord++;
        UpdateReferenceDataData objectUpdateReferenceDataData = new UpdateReferenceDataData();
        objectUpdateReferenceDataData.id = UtilSql.getValue(result, "id");
        objectUpdateReferenceDataData.name = UtilSql.getValue(result, "name");
        objectUpdateReferenceDataData.InitRecordNumber = Integer.toString(firstRegister);
        vector.addElement(objectUpdateReferenceDataData);
        if (countRecord >= numberRegisters && numberRegisters != 0) {
          continueResult = false;
        }
      }
      result.close();
    } catch (SQLException e) {
      log4j.error("SQL error in query: " + strSql + "Exception:" + e);
      throw new ServletException(
          "@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
    } catch (Exception ex) {
      log4j.error("Exception in query: " + strSql + "Exception:" + ex);
      throw new ServletException("@CODE=@" + ex.getMessage());
    } finally {
      try {
        connectionProvider.releasePreparedStatement(st);
      } catch (Exception ignore) {
        ignore.printStackTrace();
      }
    }
    UpdateReferenceDataData objectUpdateReferenceDataData[] =
        new UpdateReferenceDataData[vector.size()];
    vector.copyInto(objectUpdateReferenceDataData);
    return (objectUpdateReferenceDataData);
  }