/**
  * 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();
     }
   }
 }
  /**
   * 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;
  }
  /**
   * 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();
      }
    }
  }