@ -47,106 +47,108 @@ public class BuscadorController {
String [ ] word = query . split ( "\\b(y|o)\\b|[,/]" ) ;
if ( searchOption . equals ( "OptEmpresa" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) {
Set< Empresa > empresas = new HashSe t< > ( empressaRepository . findAll ( ) ) ;
ArrayList< Empresa > empresas = new ArrayLis t< > ( empressaRepository . findAll Asc ( ) ) ;
model . addAttribute ( "empresas" , empresas ) ;
return "/list/list_empresas" ;
}
System . out . println ( "Buscando empresas" ) ;
if ( word . length = = 1 ) {
Set < Empresa > empresas = new HashSet < > ( empressaRepository . getEmpressaByKeywordsOrName ( word [ 0 ] ) ) ;
model . addAttribute ( "empresas" , empresas ) ;
return "/list/list_empresas" ;
} else if ( word . length = = 2 ) {
Set < Empresa > empresas = new HashSet < > ( empressaRepository . getEmpressaByKeywordsOrName ( word [ 0 ] ) ) ;
empresas . addAll ( empressaRepository . getEmpressaByKeywordsOrName ( word [ 1 ] ) ) ;
model . addAttribute ( "empresas" , empresas ) ;
return "/list/list_empresas" ;
}
return "/list/empresas" ;
}
// if(word.length == 1){
// ArrayList<Empresa> empresas = new ArrayList<>(empressaRepository.getEmpressaByKeywordsOrName(word[0]));
// model.addAttribute("empresas", empresas);
// return "/list/empresas";
// }else if(word.length == 2){
// ArrayList<Empresa> empresas = new ArrayList<>(empressaRepository.getEmpressaByKeywordsOrName(word[0]));
// empresas.addAll(empressaRepository.getEmpressaByKeywordsOrName(word[1]));
// model.addAttribute("empresas", empresas);
// return "/list/empresas";
// }
} else if ( searchOption . equals ( "OptAlumno" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todos" ) ) {
Set< Alumno > alumnos = new HashSe t< > ( alumnoRepository . findAll ( ) ) ;
ArrayList< Alumno > alumnos = new ArrayLis t< > ( alumnoRepository . findAll ( ) ) ;
model . addAttribute ( "alumnos" , alumnos ) ;
return "/list/ list_ alumnos";
}
if ( word . length = = 1 ) {
System . out . println ( "Buscando alumnos" ) ;
Set < Alumno > alumnos = new HashSet < > ( alumnoRepository . getAlumnoByKeywordsOrName ( word [ 0 ] ) ) ;
model . addAttribute ( "alumnos" , alumnos ) ;
return "/list/list_ alumnos" ;
} else if ( word . length = = 2 ) {
System . out . println ( "Buscando alumnos" ) ;
Set < Alumno > alumnos = new HashSet < > ( alumnoRepository . getAlumnoByKeywordsOrName ( word [ 0 ] ) ) ;
alumnos . addAll ( alumnoRepository . getAlumnoByKeywordsOrName ( word [ 1 ] ) ) ;
model . addAttribute ( "alumnos" , alumnos ) ;
return "/list/list_ alumnos" ;
}
return "/list/ alumnos";
}
// if (word.length == 1) {
// System.out.println("Buscando alumnos");
// ArrayList<Alumno> alumnos = new ArrayList<>(alumnoRepository.getAlumnoByKeywordsOrName(word[0]));
// model.addAttribute("alumnos", alumnos);
// return "/list/alumnos";
// } else if (word.length == 2) {
// System.out.println("Buscando alumnos");
// ArrayList<Alumno> alumnos = new ArrayList<>(alumnoRepository.getAlumnoByKeywordsOrName(word[0]));
// alumnos.addAll(alumnoRepository.getAlumnoByKeywordsOrName(word[1]));
// model.addAttribute("alumnos", alumnos);
// return "/list/alumnos";
// }
} else if ( searchOption . equals ( "OptOferta" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) {
Set < Oferta > ofertas = new HashSet < > ( ofertaRepository . findAll ( ) ) ;
model . addAttribute ( "ofertas" , ofertas ) ;
return "/list/list_ofertas" ;
}
if ( word . length = = 1 ) {
Set < Oferta > ofertas = new HashSet < > ( ofertaRepository . getOfertaFullTextSeach ( word [ 0 ] ) ) ;
model . addAttribute ( "ofertas" , ofertas ) ;
return "/list/list_ofertas" ;
} else if ( word . length = = 2 ) {
Set < Oferta > ofertas = new HashSet < > ( ofertaRepository . getOfertaFullTextSeach ( word [ 0 ] ) ) ;
ofertas . addAll ( ofertaRepository . getOfertaFullTextSeach ( word [ 1 ] ) ) ;
ArrayList < Oferta > ofertas = new ArrayList < > ( ofertaRepository . findAll ( ) ) ;
model . addAttribute ( "ofertas" , ofertas ) ;
return "/list/list_ofertas" ;
}
return "/list/ofertas" ;
}
// if (word.length == 1) {
// ArrayList<Oferta> ofertas = new ArrayList<>(ofertaRepository.getOfertaFullTextSeach(word[0]));
// model.addAttribute("ofertas", ofertas);
// return "/list/ofertas";
// } else if (word.length == 2) {
// ArrayList<Oferta> ofertas = new ArrayList<>(ofertaRepository.getOfertaFullTextSeach(word[0]));
// ofertas.addAll(ofertaRepository.getOfertaFullTextSeach(word[1]));
// model.addAttribute("ofertas", ofertas);
// return "/list/ofertas";
// }
} else if ( searchOption . equals ( "OptSector" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) {
Set < Sector > sectores = new HashSet < > ( sectorRepository . findAll ( ) ) ;
ArrayList< Sector > sectores = new ArrayLis t< > ( sectorRepository . findAll ( ) ) ;
model . addAttribute ( "sectores" , sectores ) ;
return "/list/list_sectores" ;
return "/list/ sectores";
} else {
Sector sector = sectorRepository . findByNombre ( word [ 0 ] ) ;
model . addAttribute ( "sectores" , sector ) ;
return "/list/list_sectores" ;
return "/list/ sectores";
}
} else if ( searchOption . equals ( "OptSucursal" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) {
Set < Sucursal > sucursalSet = new HashSet < > ( sucursalRepository . findAll ( ) ) ;
model . addAttribute ( "sucursales" , sucursalSet ) ;
return "/list/list_sucursales" ;
} else {
Set < Sucursal > sucursalSet = new HashSet < > ( sucursalRepository . getSucursalFullTextSeach ( word [ 0 ] ) ) ;
ArrayList < Sucursal > sucursalSet = new ArrayList < > ( sucursalRepository . findAll ( ) ) ;
model . addAttribute ( "sucursales" , sucursalSet ) ;
return "/list/ list_ sucursales";
return "/list/sucursales" ;
}
// } else {
// ArrayList<Sucursal> sucursalSet = new ArrayList<>(sucursalRepository.getSucursalFullTextSeach(word[0]));
// model.addAttribute("sucursales", sucursalSet);
// return "/list/sucursales";
// }
} else if ( searchOption . equals ( "OptSkill" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) {
Set < Skill > skills = new HashSet < > ( skillRepository . findAll ( ) ) ;
ArrayList< Skill > skills = new ArrayLis t< > ( skillRepository . findAll ( ) ) ;
model . addAttribute ( "skills" , skills ) ;
return "/list/list_skills" ;
} else {
Set < Skill > skills = new HashSet < > ( skillRepository . getSkillFullTextSeach ( word [ 0 ] ) ) ;
model . addAttribute ( "skills" , skills ) ;
return "/list/list_skills" ;
return "/list/skills" ;
}
// else{
// ArrayList<Skill> skills = new ArrayList<>(skillRepository.getSkillFullTextSeach(word[0]));
// model.addAttribute("skills", skills);
// return "/list/skills";
// }
} else if ( searchOption . equals ( "OptContactos" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) {
Set < Contacto > contactos = new HashSet < > ( contactoRepository . findAll ( ) ) ;
model . addAttribute ( "contactos" , contactos ) ;
return "/list/list_contactos" ;
} else {
Set < Contacto > contactos = new HashSet < > ( contactoRepository . getContactoFullTextSeach ( word [ 0 ] ) ) ;
ArrayList < Contacto > contactos = new ArrayList < > ( contactoRepository . findAll ( ) ) ;
model . addAttribute ( "contactos" , contactos ) ;
return "/list/ list_ contactos";
return "/list/contactos" ;
}
// else {
// ArrayList<Contacto> contactos = new ArrayList<>(contactoRepository.getContactoFullTextSeach(word[0]));
// model.addAttribute("contactos", contactos);
// return "/list/contactos";
// }
} else if ( searchOption . equals ( "OptFamilias" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) {
Set < Familia > familias = new HashSet < > ( familiaRepository . findAll ( ) ) ;
ArrayList< Familia > familias = new ArrayLis t< > ( familiaRepository . findAll ( ) ) ;
model . addAttribute ( "familias" , familias ) ;
return "/list/list_familias" ;
return "/list/ familias";
}
} else if ( searchOption . equals ( "OptCiclos" ) ) {
if ( word . length = = 1 & & word [ 0 ] . equalsIgnoreCase ( "all" ) | | word [ 0 ] . equalsIgnoreCase ( "todas" ) ) {
Set< Ciclo > ciclos = new HashSe t< > ( cicloRepository . findAll ( ) ) ;
ArrayList< Ciclo > ciclos = new ArrayLis t< > ( cicloRepository . findAll ( ) ) ;
model . addAttribute ( "ciclos" , ciclos ) ;
return "/list/ list_ ciclos";
return "/list/ ciclos";
}
} else {
System . out . println ( "ERROR EN BUSQUEDA DE UNA PALABRA" ) ;