@ -4,7 +4,7 @@ package com.example.proyectofinal.controllers;
import com.example.proyectofinal.models.empresas.* ;
import com.example.proyectofinal.repositories.empresas.* ;
import com.example.proyectofinal.servicios.* ;
import com.example.proyectofinal. servicios.implemetation s.IPagination;
import com.example.proyectofinal. interface s.IPagination;
import org.springframework.data.domain.Page ;
import org.springframework.http.ResponseEntity ;
import org.springframework.ui.Model ;
@ -52,40 +52,61 @@ public class BuscadorController {
}
@GetMapping ( "/empresas/page/{pageNum}" )
public String sea chEmpresasList( @PathVariable int pageNum ,
public String sea r chEmpresasList( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam String secondaryOption ,
Model model ) {
System . out . println ( "Selected option TEST: " + secondaryOption ) ;
Page < Empresa > page = empresaService . getPage ( pageNum , size , sortField , sortDir , query , secondaryOption ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , empresaService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
if ( page ! = null ) {
List < Empresa > empresas = page . getContent ( ) ;
model . addAttribute ( "currentPage" , pageNum ) ;
model . addAttribute ( "totalPages" , page . getTotalPages ( ) ) ;
model . addAttribute ( "totalItems" , page . getTotalElements ( ) ) ;
model . addAttribute ( "empresas" , empresas ) ;
model . addAttribute ( "sortField" , sortField ) ;
model . addAttribute ( "sortDir" , sortDir ) ;
model . addAttribute ( "reverseSortDir" , sortDir . equals ( "asc" ) ? "desc" : "asc" ) ;
model . addAttribute ( "query" , query ) ;
model . addAttribute ( "secondaryOption" , secondaryOption ) ;
model . addAttribute ( "itemsPage" , itemsPage ) ;
model . addAttribute ( "currentSize" , size ) ;
} else {
System . out . println ( "No se encontraron empresas" ) ;
}
// List<Object> models = model.asMap().values().stream().toList();
// for(Object m : models){
// System.out.println(m);
// }
return "/list/empresas" ;
}
@GetMapping ( "/sectores/page/{pageNum}" )
public String searchSectoresList ( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam ( defaultValue = "" ) String secondaryOption ,
Model model ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
Map < String , Object > attributes = new HashMap < > ( ) ;
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , alumnoService , itemsPage ) ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , sectorService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
@ -96,17 +117,20 @@ public class BuscadorController {
@GetMapping ( "/contactos/page/{pageNum}" )
public String searchContactosList ( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam ( defaultValue = "" ) String secondaryOption ,
Model model ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
Map < String , Object > attributes = new HashMap < > ( ) ;
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , alumnoService , itemsPage ) ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , contactosService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
@ -116,17 +140,19 @@ public class BuscadorController {
@GetMapping ( "/sucursales/page/{pageNum}" )
public String searchSucursalesList ( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam ( defaultValue = "" ) String secondaryOption ,
Model model ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
Map < String , Object > attributes = new HashMap < > ( ) ;
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , alumnoService , itemsPage ) ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , sucursalService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
@ -136,17 +162,19 @@ public class BuscadorController {
@GetMapping ( "/ofertas/page/{pageNum}" )
public String searchOfertasList ( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam ( defaultValue = "" ) String secondaryOption ,
Model model ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
Map < String , Object > attributes = new HashMap < > ( ) ;
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , alumnoService , itemsPage ) ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , ofertasService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
@ -156,17 +184,19 @@ public class BuscadorController {
@GetMapping ( "/familias/page/{pageNum}" )
public String searchFamiliasList ( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam ( defaultValue = "" ) String secondaryOption ,
Model model ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
Map < String , Object > attributes = new HashMap < > ( ) ;
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , alumnoService , itemsPage ) ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , familiaService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
@ -176,17 +206,19 @@ public class BuscadorController {
@GetMapping ( "/ciclos/page/{pageNum}" )
public String searchCiclosList ( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam ( defaultValue = "" ) String secondaryOption ,
Model model ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
Map < String , Object > attributes = new HashMap < > ( ) ;
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , alumnoService , itemsPage ) ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , cicloService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
@ -196,18 +228,20 @@ public class BuscadorController {
@GetMapping ( "/alumnos/page/{pageNum}" )
public String searchAlumnosList ( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam ( defaultValue = "" ) String secondaryOption ,
Model model ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
Map < String , Object > attributes = new HashMap < > ( ) ;
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , alumnoService , itemsPage ) ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , alumnoService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
@ -217,17 +251,20 @@ public class BuscadorController {
@GetMapping ( "/skills/page/{pageNum}" )
public String searchSkillsList ( @PathVariable int pageNum ,
@RequestParam ( defaultValue = "" ) String query ,
Model model ,
@RequestParam ( defaultValue = "10" ) int size ,
@RequestParam ( defaultValue = "nombre" ) String sortField ,
@RequestParam ( defaultValue = "asc" ) String sortDir ) {
@RequestParam ( defaultValue = "asc" ) String sortDir ,
@RequestParam ( defaultValue = "" ) String secondaryOption ,
Model model ) {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
List < Integer > itemsPage = Arrays . asList ( 5 , 10 , 15 , 20 , 25 , 50 ) ;
if ( word . length = = 1 & & ( word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) ) {
Map < String , Object > attributes = new HashMap < > ( ) ;
if ( secondaryOption . equalsIgnoreCase ( "Todo" ) ) {
sortField = "nombre" ;
sortDir = "asc" ;
attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , skillService , itemsPage ) ;
}
Map < String , Object > attributes = getPaginatedAttributes ( pageNum , query , size , sortField , sortDir , skillService , itemsPage ) ;
for ( Map . Entry < String , Object > entry : attributes . entrySet ( ) ) {
model . addAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}