Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.lazyloading.configuracion;

public enum ConstanteConfiguracion {

CODIGO_RESULTADO_EXITO("com.lazyloading.configuracion.codigoresultadoexitoso"),
CODIGO_RESULTADO_ERROR("com.lazyloading.configuracion.codigoresultadoerror"),
MENSAJE_EJECUCION_EXITO("com.lazyloading.configuracion.mensajeejecucionexito"),
MENSAJE_EJECUCION_ERROR("com.lazyloading.configuracion.mensajeejecucionerror"),
NOMBRE_RESOURCE_BUNDLE_CONFIGURACION("com.lazyloading.configuracion.configuracion");

private String key;

private ConstanteConfiguracion(String key) {
this.key = key;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

public enum ConstanteMensajes {

OBTENER_INTEGER("com.lazyloading.mensajes.excepcion.obtenerinteger"),
VERIFICAR_DIAS_ELEMENTOS("com.lazyloading.mensajes.excepcion.verificarDiasElementos"),
VERIFICAR_ARRAY_DIAS_ELEMENTOS("com.lazyloading.mensajes.excepcion.verificarArrayDiasElementos"),
VERIFICAR_VECES_UNO("com.lazyloading.mensajes.excepcion.verificarVecesUno"),
VERIFICAR_VECES_DOS("com.lazyloading.mensajes.excepcion.verificarVecesDos"),
VERIFICAR_CONTADOR_ARR_DIAS_ELEMENTOS("com.lazyloading.mensajes.excepcion.verificarContadorArrDiasElementos"),
VERIFICAR_LISTA_ELEMENTOS_NULL("com.lazyloading.mensajes.excepcion.verificarListaElementosNull"),
VERIFICAR_LISTA_ELEMENTOS_VACIA("com.lazyloading.mensajes.excepcion.verificarListaVacia"),
VERIFICAR_ATRAS_LISTA_ELEMENTOS("com.lazyloading.mensajes.excepcion.verificarAtrasListaElementos"),
OBTENER_LINEA_IMPRESION("com.lazyloading.mensajes.excepcion.lineaimpresion"),
LISTA_JSON_NULL("com.lazyloading.mensajes.excepcion.listajsonnull"),
CLASE_ELEMENTO_JSON_NULL("com.lazyloading.mensajes.excepcion.claseelementojsonnull"),
ADAPTADOR_JSON_NULL("com.lazyloading.mensajes.excepcion.adaptadorjsonnull");
DATOS_EJECUCION_NULL("com.lazyloading.mensajes.excepcion.datosejecucionnull"),
ERROR_INSERTAR_EJECUCION("com.lazyloading.mensajes.excepcion.errorinsertarejecucion"),
ERROR_INSERTAR_LINEAS_IMPRESION("com.lazyloading.mensajes.excepcion.errorinsertarlineasimpresion"),
ERROR_ADICIONAR_EJECUCION("com.lazyloading.mensajes.excepcion.erroradicionarejecucion"),
ERROR_INICIALIZAR_CONTEXTO("com.lazyloading.mensajes.excepcion.errorinicializarcontexto"),
ERROR_NUMERO_IDENTIFACION_EJECUCION("com.lazyloading.mensajes.excepcion.errornumeroidentificacionejecucion"),
ERROR_VALIDAR_FECHA_EJECUCION("com.lazyloading.mensajes.excepcion.errorvalidarfechaejecucion"),
ERROR_VALIDAR_LINEAS_IMPRESION("com.lazyloading.mensajes.excepcion.errorvalidarlineasimpresion"),
ERROR_PROCESAR_FECHA("com.lazyloading.mensajes.excepcion.errorprocesarfecha"),
ERROR_ROLLBACK_CONEXION_BD("com.lazyloading.mensajes.excepcion.errorrollbackconexionbd"),
DATOS_EJECUCION_VACIO("com.lazyloading.mensajes.excepcion.datosejecucionvacio");

private String key;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.lazyloading.controlador;

import com.lazyloading.configuracion.ConstanteConfiguracion;
import com.lazyloading.constante.ConstanteMensajes;
import com.lazyloading.dao.interfaz.EjecucionDAO;
import com.lazyloading.db.factoria.FactoriaEjecucionDAO;
import com.lazyloading.dto.RespuestaDTO;
import com.lazyloading.excepcion.ExcepcionControladorEjecucion;
import com.lazyloading.mensaje.UtilidadMensajes;
import com.lazyloading.modelo.Ejecucion;

public class ControladorEjecucion implements IControladorEjecucion {

@Override
public RespuestaDTO registrarEjecucion(String datosEjecucion) {
RespuestaDTO resultadoDTO = this.procesarResultadoExito();
try {
this.validarDatosEjecucionNull(datosEjecucion);
this.validarDatosEjecucionVacio(datosEjecucion);
Ejecucion ejecucion = new Ejecucion(datosEjecucion);
this.validarEjecucion(ejecucion);
EjecucionDAO ejecucionDAO = FactoriaEjecucionDAO.getFactoriaEjecucionDAO().getEjecucionDAO();
ejecucionDAO.adicionarEjecucion(ejecucion);
} catch (Exception ex) {
ex.printStackTrace();
resultadoDTO = this.procesarResultadoError();
}
return resultadoDTO;
}

private RespuestaDTO procesarResultadoError() {
String resourceBundleConfiguracion = ConstanteConfiguracion.NOMBRE_RESOURCE_BUNDLE_CONFIGURACION.getKey();
String codigoResultado = UtilidadMensajes.buscarMensaje(
resourceBundleConfiguracion,
ConstanteConfiguracion.CODIGO_RESULTADO_ERROR.getKey());
String mensajeError = UtilidadMensajes.buscarMensaje(
resourceBundleConfiguracion,
ConstanteConfiguracion.MENSAJE_EJECUCION_ERROR.getKey());
RespuestaDTO respuestaDTO = this.procesarResultado(codigoResultado, mensajeError);
return respuestaDTO;
}

private RespuestaDTO procesarResultadoExito() {
String resourceBundleConfiguracion = ConstanteConfiguracion.NOMBRE_RESOURCE_BUNDLE_CONFIGURACION.getKey();
String codigoResultado = UtilidadMensajes.buscarMensaje(
resourceBundleConfiguracion,
ConstanteConfiguracion.CODIGO_RESULTADO_EXITO.getKey());
String mensajeExito = UtilidadMensajes.buscarMensaje(
resourceBundleConfiguracion,
ConstanteConfiguracion.MENSAJE_EJECUCION_EXITO.getKey());
RespuestaDTO respuestaDTO = this.procesarResultado(codigoResultado, mensajeExito);
return respuestaDTO;
}

private RespuestaDTO procesarResultado(String codigoResultado, String mensajeResultado) {
RespuestaDTO respuestaDTO = new RespuestaDTO(codigoResultado, mensajeResultado);
return respuestaDTO;
}

private void validarEjecucion(Ejecucion ejecucion) {
this.validarNumeroIdentificacionEjecucion(ejecucion);
this.validarFechaEjecucion(ejecucion);
this.validarLineasImpresion(ejecucion);
}

private void validarNumeroIdentificacionEjecucion(Ejecucion ejecucion) {
if(ejecucion.getNumeroIdentificacion() == null) {
String mensajeExcepcion = UtilidadMensajes.buscarMensaje(ConstanteMensajes.ERROR_NUMERO_IDENTIFACION_EJECUCION.getKey());
throw new ExcepcionControladorEjecucion(mensajeExcepcion);
}
}

private void validarFechaEjecucion(Ejecucion ejecucion) {
if(ejecucion.getFecha() == null
|| ejecucion.getFecha().toString().length() == 0) {
String mensajeExcepcion = UtilidadMensajes.buscarMensaje(ConstanteMensajes.ERROR_VALIDAR_FECHA_EJECUCION.getKey());
throw new ExcepcionControladorEjecucion(mensajeExcepcion);
}
}

private void validarLineasImpresion(Ejecucion ejecucion) {
if(ejecucion.getListaLineaImpresion() == null
|| ejecucion.getListaLineaImpresion().isEmpty()) {
String mensajeExcepcion = UtilidadMensajes.buscarMensaje(ConstanteMensajes.ERROR_VALIDAR_LINEAS_IMPRESION.getKey());
throw new ExcepcionControladorEjecucion(mensajeExcepcion);
}
}

private void validarDatosEjecucionNull(String datosEjecucion) {
if(datosEjecucion == null) {
String mensaje = UtilidadMensajes.buscarMensaje(ConstanteMensajes.DATOS_EJECUCION_NULL.getKey());
throw new ExcepcionControladorEjecucion(mensaje);
} else if(datosEjecucion.isEmpty()) {
String mensaje = UtilidadMensajes.buscarMensaje(ConstanteMensajes.DATOS_EJECUCION_VACIO.getKey());
throw new ExcepcionControladorEjecucion(mensaje);
}
}

private void validarDatosEjecucionVacio(String datosEjecucion) {
if(datosEjecucion.isEmpty()) {
String mensaje = UtilidadMensajes.buscarMensaje(ConstanteMensajes.DATOS_EJECUCION_NULL.getKey());
throw new ExcepcionControladorEjecucion(mensaje);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.lazyloading;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class FachadaHttpServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
String datosEjecucion = request.getParameter("datosEjecucion");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.lazyloading.configuracion;

import java.util.ResourceBundle;

public final class UtilidadConfiguracionSistema {

private static final String RES_BUNDLE_CONFIGURACION = "com.lazyloading.configuracion.configuracion";
private static final String LENGUAJE = "com.lazyloading.configuracion.locale.lenguaje";
private static final String PAIS = "com.lazyloading.configuracion.locale.pais";
private static final String RES_BUNDLE_MENSAJES_BASE_NAME = "com.lazyloading.configuracion.locale.resbundlemensajesbasename";

private static final String SEPARADOR = "com.lazyloading.configuracion.tokenizacion.separador";
private static final String REEMPLAZO = "com.lazyloading.configuracion.tokenizacion.reemplazo";
private static final String UNIDAD_PESO = "com.lazyloading.configuracion.peso.unidadpeso";
private static final String LOGGIN_PATH = "com.lazyloading.configuracion.logs.loggingpath";
private static final String LOGGING_SYSTEM_PROPERTY = "com.lazyloading.configuracion.logs.logginsysproperty";

private UtilidadConfiguracionSistema() {
super();
}

public static String getResBundleMensajesBaseName() {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(RES_BUNDLE_CONFIGURACION);
String mensajesBaseName = resourceBundle.getString(RES_BUNDLE_MENSAJES_BASE_NAME);
return mensajesBaseName;
}

public static String getLenguaje() {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(RES_BUNDLE_CONFIGURACION);
String lenguaje = resourceBundle.getString(LENGUAJE);
return lenguaje;
}

public static String getPais() {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(RES_BUNDLE_CONFIGURACION);
String pais = resourceBundle.getString(PAIS);
return pais;
}

public static String getSeparador() {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(RES_BUNDLE_CONFIGURACION);
String separador = resourceBundle.getString(SEPARADOR);
return separador;
}

public static String getReemplazo() {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(RES_BUNDLE_CONFIGURACION);
String reemplazo = resourceBundle.getString(REEMPLAZO);
return reemplazo;
}

public static String getUnidadPeso() {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(RES_BUNDLE_CONFIGURACION);
String unidadPeso = resourceBundle.getString(UNIDAD_PESO);
return unidadPeso;
}

public static String getLoggingPath() {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(RES_BUNDLE_CONFIGURACION);
String loggingPath = resourceBundle.getString(LOGGIN_PATH);
return loggingPath;
}

public static String getLoggingSystemProperty() {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(RES_BUNDLE_CONFIGURACION);
String loggingSystemProperty = resourceBundle.getString(LOGGING_SYSTEM_PROPERTY);
return loggingSystemProperty;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.lazyloading.constante;

public enum ConstanteMensajes {

DATOS_EJECUCION_NULL("com.lazyloading.mensajes.excepcion.datosejecucionnull");

private String key;

private ConstanteMensajes(String key) {
this.key = key;
}

public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.lazyloading.constante;

public enum TipoConexionBD {
CONEXION_MYSQL;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.lazyloading.controlador;

public interface Controlador {

public abstract void registrarEjecucion(String datosEjecucion);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.lazyloading.controlador;

import com.lazyloading.dto.EjecucionDTO;
import com.lazyloading.utilidad.UtilidadValidadorFachadaHttpServlet;

public class ControladorDatosEjecucion implements Controlador {

@Override
public void registrarEjecucion(String datosEjecucion) {
UtilidadValidadorFachadaHttpServlet.validarDatosEjecucionNull(datosEjecucion);
UtilidadValidadorFachadaHttpServlet.validarDatosEjecucionVacio(datosEjecucion);
EjecucionDTO ejecucionDTO = new EjecucionDTO();
ejecucionDTO.procesarEjecucion(datosEjecucion);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.lazyloading.db.conexion;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public final class UtilidadConexionBD {

public static Connection obtenerConexion(String url, Properties properties)
throws SQLException {
validarParametros(url, properties);
Connection conexionBD =
DriverManager.getConnection(url, properties);
return conexionBD;
}

public static Connection obtenerConexion(String url, String user, String password)
throws SQLException {
validarParametros(url, user, password);
Connection conexionBD =
DriverManager.getConnection(url, user, password);
return conexionBD;
}

private static void validarParametros(String url, Properties properties) {
// TODO Auto-generated method stub
}

private static void validarParametros(String url, String user, String password) {
// TODO Auto-generated method stub
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.lazyloading.db.constante;

import com.lazyloading.mensaje.UtilidadMensajes;

public enum ConstanteMySQLBD {

MYSQL_HOST_ADDRESS("com.lazyloading.db.mysql.hostaddress"),
MYSQL_HOST_PORT("com.lazyloading.db.mysql.hostport"),
MYSQL_HOST_DATABASE("com.lazyloading.db.mysql.hostdatabase"),
MYSQL_USER("com.lazyloading.db.mysql.usuario"),
MYSQL_PASSWORD("com.lazyloading.db.mysql.password"),
MYSQL_URL_FORMAT("com.lazyloading.db.mysql.urlformat");

private String valor;

private ConstanteMySQLBD(String valor) {
this.valor = valor;
}

public String getValor() {
return valor;
}
public void setValor(String valor) {
this.valor = valor;
}

public static String getURLCompleta() {
String urlFormat = UtilidadMensajes.buscarMensaje(MYSQL_URL_FORMAT.getValor());
String urlCompleta =
String.format(urlFormat, MYSQL_HOST_ADDRESS.getValor(),
MYSQL_HOST_PORT.getValor(),
MYSQL_HOST_DATABASE.getValor());
return urlCompleta;
}

}
Loading