@ -108,19 +108,20 @@ public class OfertaService implements IOferta {
}
@Override
public Page < Oferta > getPage ( int pageNum , int size , String sortField , String sortDir , String query , String secondaryOption ) throws ParseException {
Integer yearQuery = null ;
if ( isYear ( query ) ) {
yearQuery = Integer . parseInt ( query ) ;
System . out . println ( "Year query TEST: " + yearQuery ) ;
}
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
return findAllPaginated ( pageNum , size , sortField , sortDir ) ;
} else if ( secondaryOption . equals ( "Skill" ) ) {
return ofertaRepository . findOfertaBySkill ( query , PageRequest . of ( pageNum - 1 , size , Sort . by ( sortField ) . ascending ( ) ) ) ;
} else if ( secondaryOption . equals ( "Nombre" ) ) {
return ofertaRepository . findOfertaByNombre ( query , PageRequest . of ( pageNum - 1 , size , Sort . by ( sortField ) . ascending ( ) ) ) ;
} else if ( secondaryOption . equals ( "Año" ) ) {
return ofertaRepository . findOfertaByFechaAnyo ( yearQuery , PageRequest . of ( pageNum - 1 , size , Sort . by ( sortField ) . ascending ( ) ) ) ;
} else if ( secondaryOption . equals ( "Este Año" ) ) {
String year = new SimpleDateFormat ( "yyyy" ) . format ( new Date ( ) ) ;
return ofertaRepository . findOfertaByFechaAnyo ( year , PageRequest . of ( pageNum - 1 , size , Sort . by ( sortField ) . ascending ( ) ) ) ;
} else if ( secondaryOption . equals ( "Ultimos 3 meses" ) ) {
return ofertaRepository . findOfertaByFechaUltimos3Meses ( PageRequest . of ( pageNum - 1 , size , Sort . by ( sortField ) . ascending ( ) ) ) ;
} else if ( secondaryOption . equals ( "Ultimos 6 meses" ) ) {
return ofertaRepository . findOfertaByFechaUltimos6Meses ( PageRequest . of ( pageNum - 1 , size , Sort . by ( sortField ) . ascending ( ) ) ) ;
} else if ( secondaryOption . equals ( "Empresa" ) ) {
return ofertaRepository . findOfertaByEmpresa ( query , PageRequest . of ( pageNum - 1 , size , Sort . by ( sortField ) . ascending ( ) ) ) ;
} else {
@ -174,13 +175,13 @@ public class OfertaService implements IOferta {
listEmpPrime . addAll ( ofertaRepository . ofertasByEmpresaCust ( query ) ) ;
} else if ( secondaryOption . equals ( "Skill" ) ) {
listEmpPrime . addAll ( ofertaRepository . ofertasBySkillCust ( query ) ) ;
} else if ( secondaryOption . equals ( " Año") ) {
try {
Date dateQuery = new SimpleDateFormat ( "yyyy-MM-dd" ) . parse ( query ) ;
listEmpPrime . addAll ( ofertaRepository . ofertasByFechaAnyoCust ( dateQuery ) ) ;
} catch ( ParseException e ) {
e . printStackTrace ( ) ;
}
} else if ( secondaryOption . equals ( " Este Año") ) {
String year = new SimpleDateFormat ( "yyyy" ) . format ( new Date ( ) ) ;
listEmpPrime . addAll ( ofertaRepository . findOfertaByFechaAnyo ( year , PageRequest . of ( 0 , 1000 , Sort . by ( "fecha" ) . ascending ( ) ) ) . getContent ( ) ) ;
} else if ( secondaryOption . equals ( "Ultimos 3 meses" ) ) {
listEmpPrime . addAll ( ofertaRepository . findOfertaByFechaUltimos3Meses ( PageRequest . of ( 0 , 1000 , Sort . by ( "fecha" ) . ascending ( ) ) ) . getContent ( ) ) ;
} else if ( secondaryOption . equals ( "Ultimos 6 meses" ) ) {
listEmpPrime . addAll ( ofertaRepository . findOfertaByFechaUltimos6Meses ( PageRequest . of ( 0 , 1000 , Sort . by ( "fecha" ) . ascending ( ) ) ) . getContent ( ) ) ;
}
}
}