Пример #1
0
  /**
   * INTERNAL: This method is used when computing the nested queries for batch read mappings. It
   * recurses computing the nested mapping queries.
   */
  protected void computeNestedQueriesForBatchReadExpressions(Vector batchReadExpressions) {
    for (int index = 0; index < batchReadExpressions.size(); index++) {
      ObjectExpression objectExpression = (ObjectExpression) batchReadExpressions.get(index);

      // Expression may not have been initialized.
      ExpressionBuilder builder = objectExpression.getBuilder();
      builder.setSession(getSession().getRootSession(null));
      builder.setQueryClass(getReferenceClass());

      // PERF: Cache join attribute names.
      ObjectExpression baseExpression = objectExpression;
      while (!baseExpression.getBaseExpression().isExpressionBuilder()) {
        baseExpression = (ObjectExpression) baseExpression.getBaseExpression();
      }
      this.batchReadAttributes.add(baseExpression.getName());

      // Ignore nested
      if (objectExpression.getBaseExpression().isExpressionBuilder()) {
        DatabaseMapping mapping = objectExpression.getMapping();
        if ((mapping != null) && mapping.isForeignReferenceMapping()) {
          // A nested query must be built to pass to the descriptor that looks like the real query
          // execution would.
          ReadQuery nestedQuery = ((ForeignReferenceMapping) mapping).prepareNestedBatchQuery(this);
          // Register the nested query to be used by the mapping for all the objects.
          getBatchReadMappingQueries().put(mapping, nestedQuery);
        }
      }
    }
  }
Пример #2
0
  public Collection<Experiment> findExpts(CellLine cells, ExptCondition cond) throws SQLException {

    LinkedList<Integer> dbids = new LinkedList<Integer>();

    String tables = "experiment e";
    if (genome != null) {
      tables += ", probe_platform_to_genome p2g";
    }

    String query = "select e.id from " + tables;

    Vector<String> conds = new Vector<String>();

    if (genome != null) {
      int gid = genome.getDBID();
      conds.add("e.platform=p2g.platform and p2g.genome=" + gid);
    }

    if (cells != null) {
      conds.add("e.cells=" + cells.getDBID());
    }

    if (cond != null) {
      conds.add("e.condition=" + cond.getDBID());
    }

    for (int i = 0; i < conds.size(); i++) {
      if (i == 0) {
        query += " where ";
      } else {
        query += " and ";
      }
      query += conds.get(i);
    }

    System.out.println("Final Query: \"" + query + "\"");

    java.sql.Connection cxn = loader.getConnection();
    Statement s = cxn.createStatement();
    ResultSet rs = s.executeQuery(query);

    while (rs.next()) {
      int dbid = rs.getInt(1);
      dbids.addLast(dbid);
    }

    rs.close();
    s.close();

    Collection<Experiment> expts = loader.loadExperiments(dbids);
    return expts;
  }
Пример #3
0
 /** INTERNAL: Return if the attribute is specified for batch reading. */
 public boolean isAttributeBatchRead(String attributeName) {
   if (!hasBatchReadAttributes()) {
     return false;
   }
   Vector batchReadAttributeExpressions = getBatchReadAttributeExpressions();
   int size = batchReadAttributeExpressions.size();
   for (int index = 0; index < size; index++) {
     QueryKeyExpression expression = (QueryKeyExpression) batchReadAttributeExpressions.get(index);
     while (!expression.getBaseExpression().isExpressionBuilder()) {
       expression = (QueryKeyExpression) expression.getBaseExpression();
     }
     if (expression.getName().equals(attributeName)) {
       return true;
     }
   }
   return false;
 }
 public void doPost(HttpServletRequest req, HttpServletResponse res)
     throws IOException, ServletException {
   res.setContentType("text/html");
   hs = req.getSession(true);
   PrintWriter pw = res.getWriter();
   uid = req.getParameter("did");
   if (!uid.equals("")) {
     v = D.getDealer(uid);
     pw.println(
         "<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE><script language=javascript>function set() {");
     pw.println(
         "document.deldealer.select1.value='"
             + (String) v.elementAt(4)
             + "'} </script></head><P align=center><FONT color=deepskyblue size=4><STRONG>MODIFY&nbsp;DEALER </STRONG></FONT></P> ");
     pw.println(
         "<body onLoad=set()><br><br><form name=deldealer method=post action='http://peers:8080/servlet/DelDealer'>");
     pw.println(
         "<center><TABLE border=0 cellPadding=1 cellSpacing=1 width='75%' style='HEIGHT: 147px; WIDTH: 248px'>");
     pw.println(
         "<TR><TD>DealerId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD><TD><INPUT id=text1 name=did value="
             + (String) v.elementAt(0)
             + "></TD></TR>");
     pw.println(
         "<TR><TD>DealerName</TD><TD><INPUT id=text2 name=dname value="
             + (String) v.elementAt(1)
             + " ></TD></TR><TR><TD>DealerAddress</TD>");
     pw.println(
         "<TD><INPUT id=text2 type=text name=daddr value="
             + (String) v.elementAt(2)
             + "></TD></TR><TR><TD>CreditLimit</TD><TD><INPUT id=text4 name=cl value="
             + v.get(3).toString());
     pw.println(
         "></TD></TR><TR><TD><P>Staus</P></TD><td><SELECT id=select1 name=status style='HEIGHT: 22px; LEFT: 1px; TOP: 1px; WIDTH: 136px'> <OPTION ");
     pw.println(
         "selected value=''></OPTION><OPTION value=Active>Active</OPTION><OPTION value=Inactive>Inactive</OPTION></SELECT><INPUT id=submit1 name=submit1 style='LEFT: 151px; TOP: 318px' type=submit value=Delete></TD></TR>");
     pw.println("</table></center></form></body></html>");
     pw.flush();
     pw.close();
   }
 }
Пример #5
0
 public static int[] getMSPIDs(MSPLocator loc, Connection c) throws SQLException {
   Statement s = c.createStatement();
   String name = loc.getNameVersion().name;
   String version = loc.getNameVersion().version;
   ResultSet rs =
       s.executeQuery(
           "select id from rosettaanalysis where name='"
               + name
               + "' and "
               + "version = '"
               + version
               + "'");
   Vector<Integer> values = new Vector<Integer>();
   while (rs.next()) {
     values.add(rs.getInt(1));
   }
   s.close();
   int[] array = new int[values.size()];
   for (int i = 0; i < values.size(); i++) {
     array[i] = values.get(i);
   }
   Arrays.sort(array);
   return array;
 }
Пример #6
0
  public void InsertDataTable() {
    for (int i = 0; i < dataBaru.size(); i++) {
      try {
        rowSet.moveToInsertRow();
        for (int ii = 0; ii < insertKolom.size(); ii++) {
          String temp = insertKolom.get(ii + "");
          String data[] = temp.split("#");
          int no = 0;
          boolean constanta = false;
          if (data[1].trim().toLowerCase().equals("c")) {
            constanta = true;
          } else {
            try {
              no = Integer.parseInt(data[1].trim());
            } catch (Exception e) {
              no = 0;
            }
          }
          if (data[0].trim().toLowerCase().contains("i")) {
            if (data[2].trim().toLowerCase().equals("boolean")) {
              String value = "";
              if (data[4].trim().toLowerCase().equals("int")) {
                if (getValueAt(
                        new Integer(dataBaru.get(i).toString()), Integer.parseInt(data[1].trim()))
                    .toString()
                    .equals("true")) {
                  if (data[5].trim().equals("1") || data[5].trim().equals("0")) {
                    value = "1";
                  } else {
                    value = "Y";
                  }
                } else {
                  if (data[5].trim().equals("1") || data[5].trim().equals("0")) {
                    value = "0";
                  } else {
                    value = "N";
                  }
                }
                try {
                  rowSet.updateInt(data[3].trim().toString(), Integer.parseInt(value));
                } catch (Exception e) {
                  e.printStackTrace();
                }
              } else {
                if (getValueAt(
                        new Integer(dataBaru.get(i).toString()), Integer.parseInt(data[1].trim()))
                    .toString()
                    .equals("true")) {
                  if (data[5].trim().equals("1") || data[5].trim().equals("0")) {
                    value = "1";
                  } else {
                    value = "Y";
                  }
                } else {
                  if (data[5].trim().equals("1") || data[5].trim().equals("0")) {
                    value = "0";
                  } else {
                    value = "N";
                  }
                }
                try {
                  rowSet.updateString(data[3].trim().toString(), value.trim());
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }

            } else if (data[2].trim().toLowerCase().equals("date")) {
              String value = "";
              java.util.Date dd =
                  (java.util.Date) getValueAt(new Integer(dataBaru.get(i).toString()), no);
              if (data[4].equals("dd-MM-yyyy")) {
                value = Function.dateToString(dd);
              } else if (data[4].equals("MM-yyyy")) {
                value = Function.monthToString(dd).trim();
              } else if (data[4].equals("yyyy")) {
                //                                    value = Function.yearToDate(sql);
                JOptionPane.showMessageDialog(null, "Belom Support");
              }
              //                            JOptionPane.showMessageDialog(null, value.length());
              try {
                rowSet.updateString(data[3].trim().toString(), value.trim());
              } catch (Exception e) {
                e.printStackTrace();
              }
            } else if (data[2].trim().toLowerCase().equals("string")
                || data[2].trim().toLowerCase().equals("numeric")) {
              String value = "";
              if (constanta) {
                value = data[6].trim();
              } else {
                try {
                  value = getValueAt(new Integer(dataBaru.get(i).toString()), no).toString();
                } catch (Exception e) {
                  try {
                    value = getValueAt(new Integer(dataBaru.get(i).toString()), no).toString();
                  } catch (Exception ee) {
                    value = "";
                  }
                }
              }
              if (data[4].trim().toLowerCase().equals("int")) {
                try {
                  if (value.trim().equals("")) {
                    value = "0";
                  }
                  rowSet.updateLong(data[3].trim().toString(), Long.parseLong(value.trim()));
                } catch (Exception e) {
                  e.printStackTrace();
                }
              } else {
                try {
                  rowSet.updateString(data[3].trim().toString(), value.trim());
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            } else if (data[2].trim().toLowerCase().equals("combo")) {
              String value = "";
              String valueKolom = "";
              try {
                valueKolom =
                    getValueAt(new Integer(dataBaru.get(i).toString()), no).toString().trim();
              } catch (Exception e) {
                valueKolom = "";
              }
              try {
                value = Function.getValueFromCell(data[5].trim(), valueKolom);
              } catch (Exception e) {
                value = "";
              }
              if (data[4].trim().toLowerCase().equals("int")) {
                try {
                  rowSet.updateString(data[3].trim().toString(), value.trim());
                } catch (Exception e) {
                  e.printStackTrace();
                }
              } else {
                try {
                  rowSet.updateString(data[3].trim().toString(), value.trim());
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            }
          }
        }
        //                JOptionPane.showMessageDialog(null, rowSet.getCommand());
        rowSet.insertRow();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Пример #7
0
  public void updateDataTable() {
    for (int i = 0; i < dataAsli.size(); i++) {
      try {
        rowSet.absolute(new Integer(dataAsli.elementAt(i).toString()));
        if (rowSet.next()) {
          for (int ii = 0; ii < updateKolom.size(); ii++) {
            String temp = updateKolom.get(ii + "");
            String data[] = temp.split("#");
            int no = 0;
            try {
              no = Integer.parseInt(data[1].trim());
            } catch (Exception e) {
              no = 0;
            }
            if (data[0].trim().toLowerCase().contains("u")) {
              if (data[2].trim().toLowerCase().equals("boolean")) {
                String value = "";
                if (data[4].trim().toLowerCase().equals("int")) {
                  if (getValueAt(
                          new Integer(dataAsli.get(i).toString()), Integer.parseInt(data[1].trim()))
                      .toString()
                      .equals("true")) {
                    if (data[5].trim().equals("1") || data[5].trim().equals("0")) {
                      value = "1";
                    } else {
                      value = "Y";
                    }
                  } else {
                    if (data[5].trim().equals("1") || data[5].trim().equals("0")) {
                      value = "0";
                    } else {
                      value = "N";
                    }
                  }
                  try {
                    rowSet.updateInt(data[3].trim().toString(), Integer.parseInt(value));
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                } else {
                  if (getValueAt(
                          new Integer(dataAsli.get(i).toString()), Integer.parseInt(data[1].trim()))
                      .toString()
                      .equals("true")) {
                    if (data[5].trim().equals("1") || data[5].trim().equals("0")) {
                      value = "1";
                    } else {
                      value = "Y";
                    }
                  } else {
                    if (data[5].trim().equals("1") || data[5].trim().equals("0")) {
                      value = "0";
                    } else {
                      value = "N";
                    }
                  }
                  try {
                    rowSet.updateString(data[3].trim().toString(), value.trim());
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                }

              } else if (data[2].trim().toLowerCase().equals("date")) {
                String value = "";
                java.util.Date dd =
                    (java.util.Date) getValueAt(new Integer(dataAsli.get(i).toString()), no);
                if (data[4].equals("dd-MM-yyyy")) {
                  value = Function.dateToString(dd);
                } else if (data[4].equals("MM-yyyy")) {
                  value = Function.monthToString(dd);
                } else if (data[4].equals("yyyy")) {
                  //                                    value = Function.yearToDate(sql);
                  JOptionPane.showMessageDialog(null, "Belom Support");
                }
                try {
                  rowSet.updateString(data[3].trim().toString(), value.trim());
                } catch (Exception e) {
                  e.printStackTrace();
                }
              } else if (data[2].trim().toLowerCase().equals("string")
                  || data[2].trim().toLowerCase().equals("numeric")) {
                String value = "";
                String data1 = data[1].trim();
                if (data1 == null || data1.equals("")) {
                  data1 = "0";
                }
                try {
                  value = getValueAt(new Integer(dataAsli.get(i).toString()), no).toString();
                } catch (Exception e) {
                  //                                    e.printStackTrace();
                  try {
                    value = getValueAt(new Integer(dataAsli.get(i).toString()), no).toString();
                  } catch (Exception ee) {
                    value = "";
                    //                                        e.printStackTrace();
                  }
                }
                if (data[4].trim().toLowerCase().equals("int")) {
                  try {
                    if (value.trim().equals("")) {
                      value = "0";
                    }
                    rowSet.updateLong(data[3].trim().toString(), Long.parseLong(value.trim()));
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                } else {
                  try {
                    rowSet.updateString(data[3].trim().toString(), value.trim());
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                }
              } else if (data[2].trim().toLowerCase().equals("combo")) {
                String value = "";
                value =
                    Function.getValueFromCell(
                        data[5].trim(),
                        getValueAt(new Integer(dataAsli.get(i).toString()), no).toString().trim());
                if (data[4].trim().toLowerCase().equals("int")) {
                  try {
                    rowSet.updateString(data[3].trim().toString(), value.trim());
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                } else {
                  try {
                    rowSet.updateString(data[3].trim().toString(), value.trim());
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                }
              }
            }
          }
          rowSet.updateRow();
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  /**
   * Inserta el registro dado por la entidad vData.
   *
   * <p><b> insert into
   * GRLRegistroPNC(iEjercicio,iConsecutivoPNC,dtRegistro,iCveUsuRegistro,iCveProducto,lResuelto,dtResolucion,iCveOficinaAsignado,iCveDeptoAsignado)
   * values (?,?,?,?,?,?,?,?,?) </b>
   *
   * <p><b> Campos Llave: iEjercicio,iConsecutivoPNC, </b>
   *
   * @param vData TVDinRep - VO Dinámico que contiene a la entidad a Insertar.
   * @param cnNested Connection - Conexión anidada que permite que el método se encuentre dentro de
   *     una transacción mayor.
   * @throws DAOException - Excepción de tipo DAO
   * @return TVDinRep - VO Dinámico que contiene a la entidad a Insertada, así como a la llave de
   *     esta entidad.
   */
  public TVDinRep insert(TVDinRep vData, Connection cnNested) throws DAOException {
    DbConnection dbConn = null;
    Connection conn = cnNested;
    PreparedStatement lPStmt = null;
    boolean lSuccess = true;
    TFechas dtFechaActual = new TFechas();

    try {
      if (cnNested == null) {
        dbConn = new DbConnection(dataSourceName);
        conn = dbConn.getConnection();
        conn.setAutoCommit(false);
        conn.setTransactionIsolation(2);
      }
      String lSQL =
          "insert into GRLRegistroPNC(iEjercicio,iConsecutivoPNC,dtRegistro,iCveUsuRegistro,iCveProducto,lResuelto,dtResolucion,iCveOficinaAsignado,iCveDeptoAsignado,iCveOficina,iCveDepartamento,iCveProceso) values (?,?,?,?,?,?,?,?,?,?,?,?)";

      // AGREGAR AL ULTIMO ...
      Vector vcData =
          findByCustom(
              "",
              "select MAX(iConsecutivoPNC) AS iConsecutivoPNC from GRLRegistroPNC WHERE iEjercicio = "
                  + vData.getInt("iEjercicio"));
      if (vcData.size() > 0) {
        TVDinRep vUltimo = (TVDinRep) vcData.get(0);
        vData.put("iConsecutivoPNC", vUltimo.getInt("iConsecutivoPNC") + 1);
      } else vData.put("iConsecutivoPNC", 1);
      vData.addPK(vData.getString("iConsecutivoPNC"));
      lPStmt = conn.prepareStatement(lSQL);
      lPStmt.setInt(1, dtFechaActual.getIntYear(dtFechaActual.TodaySQL()));
      lPStmt.setInt(2, vData.getInt("iConsecutivoPNC"));
      iConsecutivo = vData.getInt("iConsecutivoPNC");
      lPStmt.setDate(3, tFecha.TodaySQL());
      lPStmt.setInt(4, vData.getInt("iCveUsuario"));
      lPStmt.setInt(5, vData.getInt("iCveProducto"));
      lPStmt.setInt(6, vData.getInt("lResuelto"));
      if (vData.getDate("dtResolucion") == null) lPStmt.setNull(7, Types.DATE);
      else lPStmt.setDate(7, vData.getDate("dtResolucion"));
      lPStmt.setInt(8, vData.getInt("iCveOficinaUsrAsg"));
      lPStmt.setInt(9, vData.getInt("iCveDeptoUsrAsg"));
      lPStmt.setInt(10, vData.getInt("iCveOficinaUsr"));
      lPStmt.setInt(11, vData.getInt("iCveDeptoUsr"));
      lPStmt.setInt(12, vData.getInt("iCveProceso"));

      lPStmt.executeUpdate();
      lPStmt.close();
      try {
        TDGRLRegCausaPNC1 dGRLRegCausaPNC = new TDGRLRegCausaPNC1();
        dGRLRegCausaPNC.insert(vData, conn, iConsecutivo);
      } catch (Exception exCausa) {
        exCausa.printStackTrace();
        lSuccess = false;
        throw new Exception("Error Causa");
      }
      if (cnNested == null && lSuccess) conn.commit();
    } catch (Exception ex) {
      warn("insert", ex);
      if (cnNested == null) {
        try {
          conn.rollback();
        } catch (Exception e) {
          fatal("insert.rollback", e);
        }
      }
      lSuccess = false;
    } finally {
      try {
        if (lPStmt != null) lPStmt.close();
        if (cnNested == null) {
          if (conn != null) conn.close();
          dbConn.closeConnection();
        }
      } catch (Exception ex2) {
        warn("insert.close", ex2);
      }
      if (lSuccess == false) throw new DAOException("");
      return vData;
    }
  }
  /**
   * Actualiza el campo de Producto No Conforme de la persona que recibe la notificación.
   *
   * <p><b> update GRLRegistroPNC set cRecibeNotif=? where iEjercicio = ? AND iConsecutivoPNC = ?
   * </b>
   *
   * <p><b> Campos Llave: iEjercicio,iConsecutivoPNC, </b>
   *
   * @param vData TVDinRep - VO Dinámico que contiene a la entidad a Insertar.
   * @param cnNested Connection - Conexión anidada que permite que el método se encuentre dentro de
   *     una transacción mayor.
   * @throws DAOException - Excepción de tipo DAO
   * @return TVDinRep - Entidad Modificada.
   */
  public TVDinRep updateRecibe(TVDinRep vData, Connection cnNested) throws DAOException {
    DbConnection dbConn = null;
    Connection conn = cnNested;
    PreparedStatement lPStmt = null;
    int iConsecutivoPNC = 0, iEjercicioPNC = 0;
    boolean lSuccess = true;
    try {

      if (cnNested == null) {
        dbConn = new DbConnection(dataSourceName);
        conn = dbConn.getConnection();
        conn.setAutoCommit(false);
        conn.setTransactionIsolation(2);
      }
      Vector vcPNC =
          findByCustom(
              "",
              "SELECT "
                  + "iEjercicioPNC,ICONSECUTIVOPNC "
                  + "FROM TRAREGPNCETAPA "
                  + "where IEJERCICIO = "
                  + vData.getInt("iEjercicio")
                  + " and INUMSOLICITUD = "
                  + vData.getInt("iNumSolicitud")
                  + " order by iorden desc");
      if (vcPNC.size() > 0) {
        TVDinRep vRegPNC = (TVDinRep) vcPNC.get(0);
        iConsecutivoPNC = vRegPNC.getInt("ICONSECUTIVOPNC");
        iEjercicioPNC = vRegPNC.getInt("iEjercicioPNC");
      }

      String lSQL =
          "update GRLRegistroPNC set cRecibeNotif=?,dtNotificacion=? where iEjercicio = ? AND iConsecutivoPNC = ? ";

      lPStmt = conn.prepareStatement(lSQL);
      lPStmt.setString(1, vData.getString("cRecibeNotif"));
      lPStmt.setDate(2, vData.getDate("dtNotificacion"));
      lPStmt.setInt(3, iEjercicioPNC);
      lPStmt.setInt(4, iConsecutivoPNC);

      if (cnNested == null) {
        conn.commit();
      }

      /*if(cnNested == null){
        conn.commit();
        TDVerificacion tdVer = new TDVerificacion();
        tdVer.upNotificacion(vData, cnNested);
      }*/
    } catch (Exception ex) {
      warn("update", ex);
      if (cnNested == null) {
        try {
          conn.rollback();
        } catch (Exception e) {
          fatal("update.rollback", e);
        }
      }
      lSuccess = false;
    } finally {
      try {
        if (lPStmt != null) {
          lPStmt.close();
        }
        if (cnNested == null) {
          if (conn != null) {
            conn.close();
          }
          dbConn.closeConnection();
        }
      } catch (Exception ex2) {
        warn("update.close", ex2);
      }
      if (lSuccess == false) throw new DAOException("");

      return vData;
    }
  }
Пример #10
0
  /**
   * Inserta el registro dado por la entidad vData.
   *
   * <p><b> insert into
   * GRLRegistroPNC(iEjercicio,iConsecutivoPNC,dtRegistro,iCveUsuRegistro,iCveProducto,lResuelto,dtResolucion,iCveOficinaAsignado,iCveDeptoAsignado)
   * values (?,?,?,?,?,?,?,?,?) </b>
   *
   * <p><b> Campos Llave: iEjercicio,iConsecutivoPNC, </b>
   *
   * @param vData TVDinRep - VO Dinámico que contiene a la entidad a Insertar.
   * @param cnNested Connection - Conexión anidada que permite que el método se encuentre dentro de
   *     una transacción mayor.
   * @throws DAOException - Excepción de tipo DAO
   * @return TVDinRep - VO Dinámico que contiene a la entidad a Insertada, así como a la llave de
   *     esta entidad.
   */
  public TVDinRep insertExiste(TVDinRep vData, Connection cnNested) throws DAOException {
    DbConnection dbConn = null;
    Connection conn = cnNested;
    PreparedStatement lPStmt = null;
    boolean lSuccess = true;
    boolean lAgregarAPNC = false;
    boolean lInsertaCausa = false;
    TFechas dtFechaActual = new TFechas();
    int iNumSolicitud, iCveTramite, iCveModalidad = 0;
    int iConsecutivoPNC = 0;
    int iEjercicio = 0;
    try {
      // LEL26092006
      Vector vcDataA =
          findByCustom(
              "",
              "SELECT "
                  + "TRAREGPNCETAPA.IEJERCICIOPNC, "
                  + "TRAREGPNCETAPA.INUMSOLICITUD, "
                  + "TRAREGPNCETAPA.ICONSECUTIVOPNC, "
                  + "TRAREGPNCETAPA.ICVETRAMITE, "
                  + "TRAREGPNCETAPA.ICVEMODALIDAD "
                  + "FROM TRAREGPNCETAPA "
                  + "where TRAREGPNCETAPA.IEJERCICIO = "
                  + vData.getInt("iEjercicio")
                  + " and TRAREGPNCETAPA.INUMSOLICITUD = "
                  + vData.getInt("iNumSolicitud")
                  + " ORDER BY ICONSECUTIVOPNC DESC ");
      TVDinRep vSoli;
      if (vcDataA.size() > 0) {
        vSoli = (TVDinRep) vcDataA.get(0);
        iEjercicio = vSoli.getInt("IEJERCICIOPNC");
        iNumSolicitud = vSoli.getInt("INUMSOLICITUD");
        iConsecutivoPNC = vSoli.getInt("ICONSECUTIVOPNC");
        iCveTramite = vSoli.getInt("ICVETRAMITE");
        iCveModalidad = vSoli.getInt("ICVEMODALIDAD");
        vcDataA = null;
        vcDataA =
            findByCustom(
                "",
                "SELECT "
                    + "DTNOTIFICACION FROM TRAREGREQXTRAM "
                    + "WHERE IEJERCICIO = "
                    + iEjercicio
                    + " AND INUMSOLICITUD = "
                    + iNumSolicitud
                    + " AND ICVETRAMITE = "
                    + iCveTramite
                    + " AND ICVEMODALIDAD = "
                    + iCveModalidad
                    + " AND LTIENEPNC = 1");
        lAgregarAPNC = true;
        for (int i = 0; i < vcDataA.size() && lAgregarAPNC == false; i++) {
          vSoli = (TVDinRep) vcDataA.get(i);
          if (vSoli.getDate("DTNOTIFICACION") == null) lAgregarAPNC = true;
          else lAgregarAPNC = false;
        }
      }
      if (lAgregarAPNC) {
        TVDinRep vResuelto;
        Vector vcDataR =
            findByCustom(
                "",
                "SELECT lResuelto "
                    + "FROM GRLREGISTROPNC WHERE "
                    + "IEJERCICIO = "
                    + iEjercicio
                    + " AND ICONSECUTIVOPNC = "
                    + iConsecutivoPNC);
        if (vcDataR.size() > 0) {
          vResuelto = (TVDinRep) vcDataR.get(0);
          if (vResuelto.getInt("lResuelto") != 0) lAgregarAPNC = false;
        }
      }
      // FinLEL26092006
      if (cnNested == null) {
        dbConn = new DbConnection(dataSourceName);
        conn = dbConn.getConnection();
        conn.setAutoCommit(false);
        conn.setTransactionIsolation(2);
      }
      String lSQL =
          "insert into GRLRegistroPNC(iEjercicio,iConsecutivoPNC,dtRegistro,iCveUsuRegistro,iCveProducto,lResuelto,dtResolucion,iCveOficinaAsignado,iCveDeptoAsignado,iCveOficina,iCveDepartamento,iCveProceso) values (?,?,?,?,?,?,?,?,?,?,?,?)";

      // AGREGAR AL ULTIMO ...
      if (lAgregarAPNC == false) {
        Vector vcData =
            findByCustom(
                "",
                "select MAX(iConsecutivoPNC) AS iConsecutivoPNC from GRLRegistroPNC WHERE iEjercicio = "
                    + vData.getInt("iEjercicio"));
        if (vcData.size() > 0) {
          TVDinRep vUltimo = (TVDinRep) vcData.get(0);
          vData.put("iConsecutivoPNC", vUltimo.getInt("iConsecutivoPNC") + 1);
        } else vData.put("iConsecutivoPNC", 1);
      } else {
        vData.put("iConsecutivoPNC", iConsecutivoPNC);
      }
      vData.addPK(vData.getString("iConsecutivoPNC"));
      lPStmt = conn.prepareStatement(lSQL);
      lPStmt.setInt(1, dtFechaActual.getIntYear(dtFechaActual.TodaySQL()));
      lPStmt.setInt(2, vData.getInt("iConsecutivoPNC"));
      iConsecutivo = vData.getInt("iConsecutivoPNC");
      lPStmt.setDate(3, tFecha.TodaySQL());
      lPStmt.setInt(4, vData.getInt("iCveUsuario"));
      lPStmt.setInt(5, vData.getInt("iCveProducto"));
      lPStmt.setInt(6, vData.getInt("lResuelto"));
      if (vData.getDate("dtResolucion") == null) lPStmt.setNull(7, Types.DATE);
      else lPStmt.setDate(7, vData.getDate("dtResolucion"));
      lPStmt.setInt(8, vData.getInt("iCveOficinaUsrAsg"));
      lPStmt.setInt(9, vData.getInt("iCveDeptoUsrAsg"));
      lPStmt.setInt(10, vData.getInt("iCveOficinaUsr"));
      lPStmt.setInt(11, vData.getInt("iCveDeptoUsr"));
      lPStmt.setInt(12, vData.getInt("iCveProceso"));

      if (lAgregarAPNC == false) lPStmt.executeUpdate();
      lPStmt.close();
      try {
        TDGRLRegCausaPNC1 dGRLRegCausaPNC = new TDGRLRegCausaPNC1();
        //    TDGRLRegCausaPNC dGRLRegCausaPNC = new TDGRLRegCausaPNC();
        if (lAgregarAPNC == false) {
          dGRLRegCausaPNC.insert(vData, conn, iConsecutivo);
          //   dGRLRegCausaPNC.insert(vData,conn);
        } else {
          dGRLRegCausaPNC.insertA(vData, conn, iConsecutivo);
          //   dGRLRegCausaPNC.insertA(vData,conn);
        }
      } catch (Exception exCausa) {
        exCausa.printStackTrace();
        lSuccess = false;
      }
      if (cnNested == null && lSuccess) conn.commit();
    } catch (Exception ex) {
      warn("insert", ex);
      if (cnNested == null) {
        try {
          conn.rollback();
        } catch (Exception e) {
          fatal("insert.rollback", e);
        }
      }
      lSuccess = false;
    } finally {
      try {
        if (lPStmt != null) lPStmt.close();
        if (cnNested == null) {
          if (conn != null) conn.close();
          dbConn.closeConnection();
        }
      } catch (Exception ex2) {
        warn("insert.close", ex2);
      }
      if (lSuccess == false) throw new DAOException("");
      return vData;
    }
  }
Пример #11
0
  public void go(SystemEnvironment sysEnv) throws SDMSException {
    Long sgId = null;
    Long ZERO = new Long(0);

    if (!sysEnv.cEnv.gid().contains(SDMSObject.adminGId)) {
      SDMSPrivilege p = new SDMSPrivilege();
      Vector v = SDMSMemberTable.idx_uId.getVector(sysEnv, sysEnv.cEnv.uid());
      for (int i = 0; i < v.size(); i++) {
        SDMSMember m = (SDMSMember) v.get(i);
        try {
          SDMSGrant gr =
              SDMSGrantTable.idx_objectId_gId_getUnique(
                  sysEnv, new SDMSKey(ZERO, m.getGId(sysEnv)));
          p.addPriv(sysEnv, gr.getPrivs(sysEnv).longValue());
        } catch (NotFoundException nfe) {

        }
      }
      try {
        if (sysEnv.selectGroup != null) {
          SDMSGroup sg = SDMSGroupTable.idx_name_getUnique(sysEnv, sysEnv.selectGroup);
          sgId = sg.getId(sysEnv);
        }
      } catch (NotFoundException nfe) {

      }
      if (!(p.can(SDMSPrivilege.MANAGE_SEL) || (sgId != null && sysEnv.cEnv.gid().contains(sgId))))
        throw new AccessViolationException(
            new SDMSMessage(sysEnv, "03003081235", "Insufficient Privileges"));
    }

    int read = 0;
    SDMSOutputContainer d_container = null;

    if (cl_size > 0) {
      clist = new int[cl_size];
      ctype = new int[cl_size];
    }

    try {
      Statement stmt = sysEnv.dbConnection.createStatement();
      ResultSet rset = stmt.executeQuery(selectCmd);
      ResultSetMetaData mdset = rset.getMetaData();
      Vector desc = collist(mdset);
      d_container = new SDMSOutputContainer(sysEnv, "Selected Values", desc);
      while (rset.next()) {
        Vector data = new Vector();
        int j = 0;
        for (int i = 1; i <= desc.size(); i++) {
          Object o = rset.getObject(i);
          if (cl_size > 0 && j < cl_size && i == clist[j]) {
            o = convert(sysEnv, o, j);
            j++;
          }
          data.addElement((rset.wasNull() ? null : o));
        }
        d_container.addData(sysEnv, data);
        read++;
      }
      stmt.close();
      sysEnv.dbConnection.commit();
    } catch (SQLException sqle) {

      try {

        sysEnv.dbConnection.rollback();
      } catch (SQLException sqle2) {

        throw new RecoverableException(new SDMSMessage(sysEnv, "03310281524", "Connection lost"));
      }

      throw new CommonErrorException(
          new SDMSMessage(sysEnv, "03204170024", "SQL Error : $1", sqle.toString()));
    }

    if (sv != null && sv.size() > 0) {
      int sca[] = new int[sv.size()];
      for (int i = 0; i < sv.size(); i++) {
        sca[i] = ((Integer) sv.get(i)).intValue();
        if (sca[i] >= d_container.columns)
          throw new CommonErrorException(
              new SDMSMessage(
                  sysEnv,
                  "03003081227",
                  "The sort column specified ($1) exceeds the number of columns in the output",
                  new Integer(sca[i])));
      }
      Collections.sort(d_container.dataset, d_container.getComparator(sysEnv, sca));
    }

    result.setOutputContainer(d_container);
    result.setFeedback(
        new SDMSMessage(sysEnv, "03204112153", "$1 Row(s) selected", new Integer(read)));
  }