Añado los fuentes de java
This commit is contained in:
@@ -0,0 +1,475 @@
|
||||
/**
|
||||
* @(#) PersistenciaTanivelEspecialidadTanivelActo.java
|
||||
*/
|
||||
|
||||
package com.tarisan.control;
|
||||
|
||||
import com.tarisan.data.TanivelActo;
|
||||
import com.tarisan.data.TanivelEspecialidad;
|
||||
import com.tarisan.excepcion.*;
|
||||
import com.tarisan.log.*;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Controla los accesos a la persistencia para la entidad <code>TanivelEspecialidad</code>.
|
||||
* @author <a href="mailto:sistemas@imqnavarra.com">Dpto. Informática</a>.
|
||||
* @version 1.0, 24/09/2003
|
||||
*/
|
||||
public class PersistenciaTanivelEspecialidadTanivelActo
|
||||
{
|
||||
|
||||
/**
|
||||
* El objeto <code>Paginacion</code> que controla el número de filas a mostrar por cada página.
|
||||
*/
|
||||
private Paginacion objPaginacion = new Paginacion();
|
||||
|
||||
|
||||
/**
|
||||
* Obtiene el valor del objeto <code>Paginacion</code> para saber qué página se está visualizando.
|
||||
* @return El objeto <code>Paginacion</code>
|
||||
*/
|
||||
public Paginacion getPaginacion()
|
||||
{
|
||||
return objPaginacion;
|
||||
}
|
||||
/**
|
||||
* Selecciona los registros de la tabla TANIVEL_ESPECIALIDAD en función de la sentencia SELECT indicada.
|
||||
* @param sqlSelect La sentencia SELECT de selección.
|
||||
* @param pagina Número de página a mostrar.
|
||||
* @param aCondiciones Array que contiene los parámetros utilizados en la sentencia SELECT.
|
||||
* @return El Vector con los registros seleccionados (todos pertenencientes a la clase <code>tanivelEspecialidad</code>).
|
||||
* @throws
|
||||
*/
|
||||
public Vector obtenerEspecialidades()
|
||||
{
|
||||
Vector vResultado = new Vector();
|
||||
TanivelEspecialidad tanivelEspe = null;
|
||||
String sqlSelect = "SELECT DISTINCT (ESPECIALIDAD) FROM TANIVEL_ESPECIALIDAD";
|
||||
|
||||
try
|
||||
{
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect);
|
||||
|
||||
|
||||
while(rs.next())
|
||||
{
|
||||
|
||||
tanivelEspe = new TanivelEspecialidad();
|
||||
tanivelEspe.setEspecialidad(rs.getInt("ESPECIALIDAD"));
|
||||
vResultado.addElement(tanivelEspe);
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + vResultado.size() + " registros de la tabla TANIVEL_ESPECIALIDAD (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return vResultado;
|
||||
}
|
||||
|
||||
public String ObtenerDescripcion(int especialidad) {
|
||||
String resultado = "";
|
||||
String sqlSelect = "SELECT DESCRIPCION FROM TAESPECI WHERE ESPECIALIDAD=" + especialidad;
|
||||
|
||||
try
|
||||
{
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect);
|
||||
|
||||
|
||||
while(rs.next())
|
||||
{
|
||||
resultado = rs.getString("DESCRIPCION");
|
||||
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Descripcion de especialidad("+ especialidad +"): " + resultado + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAESPECI: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAESPECI: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAESPECI: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAESPECI: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
|
||||
}
|
||||
|
||||
return resultado;
|
||||
|
||||
}
|
||||
|
||||
public Vector ObtenerNiveles(int especialidad) {
|
||||
return ObtenerNiveles(especialidad, 0);
|
||||
|
||||
}
|
||||
|
||||
public Vector ObtenerNiveles(int especialidad, int especialidadSolicitada) {
|
||||
Vector vResultado = new Vector();
|
||||
TanivelEspecialidad tanivelEspe = null;
|
||||
String sqlSelect = "SELECT * FROM TANIVEL_ESPECIALIDAD WHERE ESPECIALIDAD=" + especialidad;
|
||||
|
||||
if (especialidadSolicitada!=0){
|
||||
sqlSelect = "SELECT * FROM TANIVEL_ESPECIALIDAD WHERE ESPECIALIDAD=" + especialidad + "AND ESPECIALIDAD_SOLICITADA=" + especialidadSolicitada;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect);
|
||||
|
||||
|
||||
while(rs.next())
|
||||
{
|
||||
tanivelEspe = new TanivelEspecialidad();
|
||||
tanivelEspe.setEspecialidad(rs.getInt("ESPECIALIDAD"));
|
||||
tanivelEspe.setNivel(rs.getInt("NIVEL"));
|
||||
tanivelEspe.setVisibilidad(rs.getInt("VISIBILIDAD"));
|
||||
vResultado.addElement(tanivelEspe);
|
||||
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + vResultado.size() + " registros de la tabla TANIVEL_ESPECIALIDAD (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
|
||||
}
|
||||
|
||||
return vResultado;
|
||||
|
||||
}
|
||||
|
||||
public boolean ActualizarVisibilidad(Vector vTanivEspe) {
|
||||
return ActualizarVisibilidad(vTanivEspe, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean ActualizarVisibilidad(Vector vTanivEspe, int especialidadSolicitada) {
|
||||
boolean resultado = false;
|
||||
TanivelEspecialidad TanivEsp = null;
|
||||
Connection conexion = null;
|
||||
|
||||
try {
|
||||
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
|
||||
ParametrosConfiguracion.dataStore.iniciarTransaccion(conexion);
|
||||
for(int i = 0; i < vTanivEspe.size(); i++){
|
||||
if ((i!=0) && (resultado==false)){
|
||||
return resultado;
|
||||
}
|
||||
TanivEsp = (TanivelEspecialidad)vTanivEspe.elementAt(i);
|
||||
String sqlSelect = "UPDATE TANIVEL_ESPECIALIDAD SET VISIBILIDAD="+ TanivEsp.getVisibilidad() +""
|
||||
+ " WHERE ESPECIALIDAD="+ TanivEsp.getEspecialidad() + " and NIVEL="+ TanivEsp.getNivel();
|
||||
|
||||
if (especialidadSolicitada!=0){
|
||||
sqlSelect = "UPDATE TANIVEL_ESPECIALIDAD SET VISIBILIDAD="+ TanivEsp.getVisibilidad() +""
|
||||
+ " WHERE ESPECIALIDAD="+ TanivEsp.getEspecialidad() + " and NIVEL="+ TanivEsp.getNivel() + " and ESPECIALIDAD_SOLICITADA="+ especialidadSolicitada;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (ParametrosConfiguracion.dataStore.actualizar(sqlSelect, conexion)){
|
||||
resultado = true;
|
||||
}
|
||||
|
||||
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Visibilidad actualizada de la tabla TANIVEL_ESPECIALIDAD (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en el update de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en el update de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en el update de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (resultado == false) {
|
||||
ParametrosConfiguracion.dataStore.deshacerTransaccion(conexion);
|
||||
}else{
|
||||
ParametrosConfiguracion.dataStore.confirmarTransaccion(conexion);
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
}
|
||||
} catch (ExcepcionTarisan e) {
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en el update de TANIVEL_ESPECIALIDAD "+e.toString());
|
||||
}
|
||||
return resultado;
|
||||
|
||||
}
|
||||
|
||||
public String ObtenerDescripcionActo(int acto, int esp){
|
||||
String resultado = "";
|
||||
String sqlSelect = "SELECT DESCRIPCION FROM TTACTMED WHERE ACTO=" + acto + "AND ESPECIALIDAD=" + esp;
|
||||
|
||||
try
|
||||
{
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect);
|
||||
|
||||
|
||||
while(rs.next())
|
||||
{
|
||||
resultado = rs.getString("DESCRIPCION");
|
||||
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Descripcion de especialidad("+ acto +"): " + resultado + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAESPECI: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAESPECI: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAESPECI: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAESPECI: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
|
||||
return resultado;
|
||||
|
||||
}
|
||||
|
||||
public Vector ObtenerActos(int especialidad, int pagina) {
|
||||
return ObtenerActos(especialidad, pagina, "");
|
||||
|
||||
}
|
||||
|
||||
public Vector ObtenerActos(int especialidad, int pagina, String acto) {
|
||||
int elementosPaginacion = 1;
|
||||
Vector vResultado = new Vector();
|
||||
TanivelActo tanivelAct = null;
|
||||
String sqlSelect = "SELECT * FROM TANIVEL_ACTO WHERE ESPECIALIDAD=" + especialidad;
|
||||
|
||||
if (acto!=""){
|
||||
sqlSelect = "SELECT * FROM TANIVEL_ACTO, ttactmed WHERE TANIVEL_ACTO.ESPECIALIDAD=" + especialidad +" AND ttactmed.ACTO=TANIVEL_ACTO.ACTO AND ttactmed.DESCRIPCION LIKE '%"+ acto + "%' AND TANIVEL_ACTO.ESPECIALIDAD=ttactmed.ESPECIALIDAD";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect);
|
||||
|
||||
objPaginacion.inicializarPaginacion(rs);
|
||||
if (objPaginacion.getNumeroRegistrosTotales()!=0)
|
||||
{
|
||||
objPaginacion.realizarPaginacion(rs, pagina);
|
||||
|
||||
while(rs.next() && (elementosPaginacion <= Paginacion.getFilasPorPagina()))
|
||||
{
|
||||
tanivelAct = new TanivelActo();
|
||||
tanivelAct.setEspecialidad(rs.getInt("ESPECIALIDAD"));
|
||||
tanivelAct.setActo(rs.getInt("ACTO"));
|
||||
tanivelAct.setNivel(rs.getInt("NIVEL"));
|
||||
vResultado.addElement(tanivelAct);
|
||||
if (pagina != 0)
|
||||
{
|
||||
elementosPaginacion++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + vResultado.size() + " registros de la tabla TANIVEL_ACTO (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ACTO: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ACTO: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ACTO: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ACTO: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
|
||||
return vResultado;
|
||||
|
||||
}
|
||||
|
||||
public boolean ActualizarNivelActo(Vector vTanivelAct) {
|
||||
boolean resultado = false;
|
||||
TanivelActo TanivAct = null;
|
||||
Connection conexion = null;
|
||||
|
||||
try {
|
||||
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
|
||||
ParametrosConfiguracion.dataStore.iniciarTransaccion(conexion);
|
||||
for(int i = 0; i < vTanivelAct.size(); i++){
|
||||
if ((i!=0) && (resultado==false)){
|
||||
return resultado;
|
||||
}
|
||||
TanivAct = (TanivelActo)vTanivelAct.elementAt(i);
|
||||
String sqlSelect = "UPDATE TANIVEL_ACTO SET NIVEL="+ TanivAct.getNivel() +""
|
||||
+ " WHERE ESPECIALIDAD="+ TanivAct.getEspecialidad() + " and ACTO="+ TanivAct.getActo();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (ParametrosConfiguracion.dataStore.actualizar(sqlSelect, conexion)){
|
||||
resultado = true;
|
||||
}
|
||||
|
||||
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Visibilidad actualizada de la tabla TANIVEL_ACTO (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en el update de TANIVEL_ACTO: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en el update de TANIVEL_ACTO: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en el update de TANIVEL_ACTO: " + sqle + " (" + sqlSelect + ")");
|
||||
}
|
||||
}
|
||||
if (resultado == false) {
|
||||
ParametrosConfiguracion.dataStore.deshacerTransaccion(conexion);
|
||||
}else{
|
||||
ParametrosConfiguracion.dataStore.confirmarTransaccion(conexion);
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
}
|
||||
} catch (ExcepcionTarisan e) {
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en el update de TANIVEL_ACTO: "+e.toString());
|
||||
}
|
||||
return resultado;
|
||||
|
||||
}
|
||||
|
||||
public Vector obtenerEspecialidadesSolicitadas(int espe)
|
||||
{
|
||||
Vector vResultado = new Vector();
|
||||
TanivelEspecialidad tanivelEspe = null;
|
||||
String sqlSelect = "SELECT DISTINCT (ESPECIALIDAD_SOLICITADA) AS ESPECI FROM TANIVEL_ESPECIALIDAD WHERE ESPECIALIDAD="+ espe;
|
||||
|
||||
try
|
||||
{
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect);
|
||||
|
||||
|
||||
while(rs.next())
|
||||
{
|
||||
|
||||
tanivelEspe = new TanivelEspecialidad();
|
||||
tanivelEspe.setEspecialidad(rs.getInt("ESPECI"));
|
||||
vResultado.addElement(tanivelEspe);
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + vResultado.size() + " registros de la tabla TANIVEL_ESPECIALIDAD (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TANIVEL_ESPECIALIDAD: " + sqle + " (" + sqlSelect + ")");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return vResultado;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user