/**
  * Eliminar un registro.
  *
  * @param inTproc Object - Objeto procesado
  * @throws PersistenciaException - capa de persistencia
  * @return Object - identificador de objeto
  */
 public Object delete(Object Par_Ldap) throws PersistenciaException {
   PreparedStatement stmt = null;
   Connection connection = null;
   StringBuffer sqlString = new StringBuffer();
   Par_LdapTO Par_LdapTO = (Par_LdapTO) Par_Ldap;
   sqlString.append(" DELETE FROM siga_parametros.Par_Ldap");
   sqlString.append(" WHERE PAR_ID=?");
   try {
     synchronized (this) {
       connection = super.getConnection(this.objDataSession);
       stmt = connection.prepareStatement(sqlString.toString());
       int i = 1;
       setLong(stmt, (Long) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_ID), i++);
       stmt.executeUpdate();
     }
     return "Ok";
   } catch (SQLException ex) {
     System.err.println("error Par_LdapDAO.delete: " + ex.toString());
     throw new PersistenciaException(ex.getMessage(), ex);
   } finally {
     try {
       super.cerrarConexiones(connection, stmt, null, this.objDataSession);
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
 }
  /**
   * Inserta un registro.
   *
   * @param inTproc Object - Objeto procesado
   * @throws PersistenciaException - capa de persistencia
   * @return Object - identificador de objeto
   */
  public Object insert(Object Par_Ldap) throws PersistenciaException {
    PreparedStatement stmt = null;
    Connection connection = null;
    StringBuffer sqlString = new StringBuffer();
    Par_LdapTO Par_LdapTO = (Par_LdapTO) Par_Ldap;
    int i = 0;
    Long sequence = new Long(0);
    sqlString.append(" INSERT INTO siga_parametros.Par_Ldap ");
    sqlString.append("    (ldap_id ");
    sqlString.append("    ,ldap_ip ");
    sqlString.append("    ,ldap_puerto");
    sqlString.append("    ,ldap_basedn");
    sqlString.append("    ,ldap_usuario ");
    sqlString.append("    ,ldap_administrador ");
    sqlString.append("    ,ldap_password ");

    sqlString.append(" )VALUES (?,?,?,?,?,?,?) ");
    try {
      synchronized (this) {
        connection = super.getConnection(this.objDataSession);
        sequence = getNextSequential("Par_Ldap", "PAR_ID", connection);
        Par_LdapTO.setAttribute(Par_LdapTO.LDAP_ID, sequence);
        stmt = connection.prepareStatement(sqlString.toString());
        i = 1;
        setLong(stmt, (Long) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_ID), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_IP), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_PUERTO), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_BASEDN), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_USUARIO), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_ADMINISTRADOR), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_PASSWORD), i++);

        stmt.executeUpdate();
      }
      return "Ok";
    } catch (SQLException ex) {
      System.err.println("error Par_LdapDAO.insert: " + ex.toString());
      throw new PersistenciaException(ex.getMessage(), ex);
    } finally {
      try {
        super.cerrarConexiones(connection, stmt, null, this.objDataSession);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
  /**
   * Actualizar un registro.
   *
   * @param inTproc Object - Objeto procesado.
   * @throws PersistenciaException - capa de persistencia.
   * @return Object - identificador de objeto
   */
  public Object update(Object Par_Ldap) throws PersistenciaException {
    PreparedStatement stmt = null;
    Connection connection = null;
    StringBuffer sqlString = new StringBuffer();
    Par_LdapTO Par_LdapTO = (Par_LdapTO) Par_Ldap;
    sqlString.append(" UPDATE siga_parametros.Par_Ldap ");
    sqlString.append(" SET LDAP_ID = ? ");
    sqlString.append(" , LDAP_IP = ? ");
    sqlString.append(" , LDAP_PUERTO = ? ");
    sqlString.append(" , LDAP_BASEDN = ? ");
    sqlString.append(" , LDAP_USUARIO = ? ");
    sqlString.append("     ,LDAP_ADMINISTRADOR = ? ");
    sqlString.append("     ,LDAP_PASSWORD = ? ");

    sqlString.append(" WHERE LDAP_ID = ? ");
    try {
      synchronized (this) {
        connection = super.getConnection(this.objDataSession);
        stmt = connection.prepareStatement(sqlString.toString());
        int i = 1;

        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_IP), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_PUERTO), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_BASEDN), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_USUARIO), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_ADMINISTRADOR), i++);
        setString(stmt, (String) Par_LdapTO.getAttribute(Par_LdapTO.LDAP_PASSWORD), i++);
        setLong(stmt, (Long) Par_LdapTO.getAttribute(1), i++);
        stmt.executeUpdate();
      }
      return "Ok";
    } catch (SQLException ex) {
      System.err.println("error Par_LdapDAO.update: " + ex.toString());
      throw new PersistenciaException(ex.getMessage(), ex);
    } finally {
      try {
        cerrarConexiones(connection, stmt, null, this.objDataSession);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
  /**
   * Retorna una colección Par_LdapTO
   *
   * @param parameters Hashtable - parametros para la consulta
   * @throws PersistenciaException - capa de persistencia
   * @return Collection - resultado Par_Ldap
   */
  public java.util.Collection<Object> getPar_Ldap(Hashtable<String, Object> parameters)
      throws PersistenciaException {
    PreparedStatement stm = null;
    ResultSet rs = null;
    Connection connection = null;
    Collection<Object> result = new ArrayList<Object>();
    Par_LdapTO Par_LdapTO = new Par_LdapTO();
    Par_LdapTO Par_LdapCollTO = null;
    StringBuffer sqlString = new StringBuffer();
    int posicion = 1;
    try {
      sqlString.append(" SELECT ldap_id ");
      sqlString.append("       ,ldap_ip ");
      sqlString.append("       ,ldap_puerto ");
      sqlString.append("       ,ldap_basedn ");
      sqlString.append("       ,ldap_usuario ");
      sqlString.append("       ,ldap_administrador");
      sqlString.append("       ,ldap_password ");

      sqlString.append(" FROM siga_parametros.Par_Ldap ");
      sqlString.append(" WHERE 1=1 ");
      adicionarCondiciones(sqlString, Par_LdapTO, parameters);
      connection = super.getConnection(this.objDataSession);
      stm = connection.prepareStatement(sqlString.toString());
      System.out.println("sql string" + sqlString.toString());
      rs = stm.executeQuery();
      while (rs.next()) {
        Par_LdapCollTO = new Par_LdapTO();
        Par_LdapCollTO.setPosicion(posicion++);
        poblarTO(rs, Par_LdapCollTO);
        result.add(Par_LdapCollTO);
      }
    } catch (SQLException e) {
      e.printStackTrace();
      throw new PersistenciaException("Error en getPar_LdapDAO.getPar_Ldap: ", e);
    } finally {
      super.cerrarConexiones(connection, stm, rs, this.objDataSession);
    }
    return result;
  }
  /**
   * Consulta Join utilizada para retornar Query's de informacion.
   *
   * @param parameters Hashtable - parametros para la consulta
   * @param limiteInf - Indice de inicio del registro de paginacion
   * @param registrosPagina - Cantidad de registros mostrados por pagina
   * @throws PersistenciaException - capa de persistencia
   * @return Collection - resultado Par_Ldap
   */
  public java.util.Collection<Object> getPar_LdapJoin(
      Hashtable<String, Object> parameters, int limiteInf, int registrosPagina)
      throws PersistenciaException {
    Statement stm = null;
    ResultSet rs = null;
    Connection connection = null;
    Collection<Object> result = new ArrayList<Object>();
    Par_LdapDAO.QueryPar_LdapTO objetoDaoQuery = new Par_LdapDAO.QueryPar_LdapTO();
    StringBuffer sqlString = new StringBuffer();
    try {
      int contador = 0;
      if (registrosPagina < 0) {
        contador = registrosPagina - 1;
      }
      sqlString.append(" SELECT * FROM ( SELECT ROWNUM RN, CS.* FROM ( ");
      sqlString.append("         SELECT siga_parametros.Par_Ldap.ldap_id ");
      sqlString.append("                 ,siga_parametros.Par_Ldap.ldap_ip ");
      sqlString.append("                 ,siga_parametros.Par_Ldap.ldap_puerto ");
      sqlString.append("                 ,siga_parametros.Par_Ldap.ldap_basedn ");
      sqlString.append("                 ,siga_parametros.Par_Ldap.ldap_usuario ");
      sqlString.append("                 ,siga_parametros.Par_Ldap.ldap_administrador ");
      sqlString.append("                 ,siga_parametros.Par_Ldap.ldap_password ");

      sqlString.append(" FROM siga_parametros.Par_Ldap ");
      sqlString.append(" WHERE 1=1 ");
      super.adicionarCondicionesJoin(sqlString, parameters);
      sqlString.append("  ) CS ) ");
      if (registrosPagina > 0) {
        sqlString.append(
            "WHERE rn between '" + limiteInf + "' and '" + (limiteInf + registrosPagina) + "'");
      }
      connection = super.getConnection(this.objDataSession);
      stm = connection.createStatement();
      rs = stm.executeQuery(sqlString.toString());
      while (rs.next()) {
        objetoDaoQuery = new Par_LdapDAO.QueryPar_LdapTO();
        objetoDaoQuery.poblarTO(rs, connection);
        result.add(objetoDaoQuery);
        contador++;
      }
      if (registrosPagina > 0) {
        sqlString.delete(0, sqlString.length());
        sqlString.append("SELECT count(*) as conteo  ");
        sqlString.append("FROM Par_Ldap ");
        sqlString.append("WHERE 1=1 ");
        super.adicionarCondicionesJoin(sqlString, parameters);
        rs = stm.executeQuery(sqlString.toString());
        if (rs.next()) {
          result.add("" + rs.getString("conteo"));
        } else {
          result.add("" + contador);
        }
      }
      rs.close();
      rs = null;
      stm.close();
      stm = null;
    } catch (SQLException e) {
      e.printStackTrace();
      throw new PersistenciaException("Error en Par_LdapDAO.getPar_LdapJoin: ", e);
    } finally {
      super.cerrarConexiones(connection, null, null, this.objDataSession);
    }
    return result;
  }