@ -49,7 +49,11 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
private final ComboBox < String > tipoMantt ;
private final ComboBox < String > area ;
private final ComboBox < String > usuario ;
private RadioButtonGroup < String > formaGroup ;
private CheckboxGroup < String > actualizaciones ;
private final HorizontalLayout botonesLayout ;
private TextArea txtCuales ;
private RadioButtonGroup < String > masActualizacionesGroup ;
Span userSignSpan = new Span ( "Nombre Usuario" ) ;
@ -242,21 +246,21 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
Span Titulo = new Span ( "Actualizaciones de Seguridad Informatica:" ) ;
etiquetaLayout . add ( Titulo ) ;
CheckboxGroup < String > actualizaciones = new CheckboxGroup < > ( ) ;
this . actualizaciones = new CheckboxGroup < > ( ) ;
actualizaciones . setLabel ( "Actualizaciones Necesarias" ) ;
actualizaciones . setItems ( "S.O" , "Antivirus" , "Firewall" ) ;
RadioButtonGroup < String > formaGroup = new RadioButtonGroup < > ( ) ;
this . formaGroup = new RadioButtonGroup < > ( ) ;
formaGroup . setRequired ( true ) ;
formaGroup . setLabel ( "Actividad Realizada de Forma:" ) ;
formaGroup . setItems ( "Remota" , "Manual" ) ;
TextArea txtCuales = new TextArea ( ) ;
this . txtCuales = new TextArea ( ) ;
txtCuales . setLabel ( "¿Cuales?" ) ;
txtCuales . setEnabled ( false ) ;
txtCuales . setWidthFull ( ) ;
RadioButtonGroup < String > masActualizacionesGroup = new RadioButtonGroup < > ( ) ;
this . masActualizacionesGroup = new RadioButtonGroup < > ( ) ;
masActualizacionesGroup . setRequired ( true ) ;
masActualizacionesGroup . setLabel ( "¿Requiere Más Actualizaciones?" ) ;
masActualizacionesGroup . setItems ( "Si" , "No" ) ;
@ -388,13 +392,27 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
String departamentoId = area . getValue ( ) ;
String empleadoId = usuario . getValue ( ) ;
if ( fechaSeleccionada = = null | | tipoMantId = = null | | departamentoId = = null | | empleadoId = = null ) {
/ / AQUI SE MANEJA LA OPCION SELECIONADA EN LA FORMA DE MANTENIMIENTO ( REMOTA o MANUAL )
String formaSeleccionada = formaGroup . getValue ( ) ;
String formaMantt = null ;
if ( "Remota" . equals ( formaSeleccionada ) ) {
formaMantt = "R" ;
} else if ( "Manual" . equals ( formaSeleccionada ) ) {
formaMantt = "M" ;
}
/ / VALIDACION PARA QUE TODOS LOS CAMPOS OBLIGATORIOS SEAN LLENADOS
if ( fechaSeleccionada = = null | | tipoMantId = = null | | departamentoId = = null | | empleadoId = = null | | formaMantt = = null ) {
Notification . show ( "Por favor, completa todos los campos requeridos" , 4000 , Notification . Position . MIDDLE ) ;
return ;
}
int isInserted = databaseService . insertarMantenimiento ( fechaSeleccionada , tipoMantId , departamentoId , empleadoId ) ;
int isInserted = databaseService . insertarMantenimiento ( fechaSeleccionada , tipoMantId , departamentoId , empleadoId , formaMantt ) ;
/ / AQUI SE MANEJA LA INSERCION DE LOS DETALLES DE HARDWARE ( TIPO DE HARDWARE , NO . DE SERIE , MODELO , PLACA )
if ( isInserted > 0 ) {
int mantenimientoId = databaseService . getUltimoMantenimientoId ( ) ;
@ -408,7 +426,7 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
int numSerieInt = noSerie . getValue ( ) ! = null ? noSerie . getValue ( ) . intValue ( ) : 0 ;
int placaInt = placa . getValue ( ) ! = null ? placa . getValue ( ) . intValue ( ) : 0 ;
/ / Validaciones antes de insertar hardware
/ / Validaciones antes de insertar detalles del hardware
if ( tipoHardware . getValue ( ) = = null | | modelo . getValue ( ) = = null | | numSerieInt < = 0 | | placaInt < = 0 ) {
Notification . show ( "Por favor, completa todos los campos de hardware" , 4000 , Notification . Position . MIDDLE ) ;
return ;
@ -430,14 +448,43 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
Notification . show ( "Error al insertar detalles del hardware" , 4000 , Notification . Position . MIDDLE ) ;
return ;
}
}
/ / AQUI MANEJO LA INSERCION DE LOS DATOS DE LOS CHECKBOXES DE ACTUALIZACIONES DE SEGURIDAD ! ! !
for ( String actualizacionSelecionada : actualizaciones . getSelectedItems ( ) ) {
boolean isActualizacionInserted = databaseService . insertActualizacionSeg ( actualizacionSelecionada , null , mantenimientoId ) ;
if ( ! isActualizacionInserted ) {
Notification . show ( "Error al insertar actualizacion de seguridad" , 4000 , Notification . Position . MIDDLE ) ;
return ;
}
}
if ( masActualizacionesGroup . getValue ( ) . equals ( "Si" ) ) {
String otrasActu = txtCuales . getValue ( ) ;
String actualizacion = "Otras" ;
if ( otrasActu ! = null & & ! otrasActu . trim ( ) . isEmpty ( ) ) {
boolean isOtrasActualizaciones = databaseService . insertActualizacionSeg ( actualizacion , otrasActu , mantenimientoId ) ;
if ( ! isOtrasActualizaciones ) {
Notification . show ( "Error al insertar otras actualizaciones de seguridad" , 4000 , Notification . Position . MIDDLE ) ;
return ;
}
}
}
/ / NOTIFICACION DE GUARDADO EXITOSO Y LIMPIEZA DE LOS CAMPOS ! ! !
Notification . show ( "!!Mantenimiento guardado exitosamente!!" , 4000 , Notification . Position . MIDDLE ) ;
fecha . clear ( ) ;
tipoMantt . clear ( ) ;
area . clear ( ) ;
usuario . clear ( ) ;
formaGroup . clear ( ) ;
actualizaciones . clear ( ) ;
masActualizacionesGroup . clear ( ) ;
txtCuales . clear ( ) ;
} else {
Notification . show ( "Error al guardar el mantenimeinto" , 4000 , Notification . Position . MIDDLE ) ;
}