|
|
|
@ -41,7 +41,6 @@ public class OfertaService implements IOferta {
|
|
|
|
|
Sort.by(sortField).descending();
|
|
|
|
|
Pageable pageable = PageRequest.of(pageNum - 1, pageSize, sort);
|
|
|
|
|
Page<Oferta> page = this.ofertaRepository.findAll(pageable);
|
|
|
|
|
|
|
|
|
|
List<Oferta> ofertas = page.getContent();
|
|
|
|
|
for (Oferta oferta : ofertas) {
|
|
|
|
|
List<Object[]> skillsData = ofertaRepository.findSkillsByOfertaId(oferta.getId());
|
|
|
|
@ -54,7 +53,6 @@ public class OfertaService implements IOferta {
|
|
|
|
|
}
|
|
|
|
|
oferta.setSkills(skills);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -110,16 +108,16 @@ public class OfertaService implements IOferta {
|
|
|
|
|
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()));
|
|
|
|
|
return ofertaRepository.findOfertaBySkill(query, PageRequest.of(pageNum - 1, size, sortDir.equals("asc") ? Sort.by(sortField).ascending() : Sort.by(sortField).descending()));
|
|
|
|
|
} 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()));
|
|
|
|
|
return ofertaRepository.findOfertaByFechaAnyo(year, PageRequest.of(pageNum - 1, size, sortDir.equals("asc") ? Sort.by(sortField).ascending() : Sort.by(sortField).descending()));
|
|
|
|
|
}else if(secondaryOption.equals("Ultimos 3 meses")){
|
|
|
|
|
return ofertaRepository.findOfertaByFechaUltimos3Meses(PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
|
|
|
|
|
return ofertaRepository.findOfertaByFechaUltimos3Meses(PageRequest.of(pageNum - 1, size, sortDir.equals("asc") ? Sort.by(sortField).ascending() : Sort.by(sortField).descending()));
|
|
|
|
|
}else if(secondaryOption.equals("Ultimos 6 meses")){
|
|
|
|
|
return ofertaRepository.findOfertaByFechaUltimos6Meses(PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
|
|
|
|
|
return ofertaRepository.findOfertaByFechaUltimos6Meses(PageRequest.of(pageNum - 1, size, sortDir.equals("asc") ? Sort.by(sortField).ascending() : Sort.by(sortField).descending()));
|
|
|
|
|
} else if(secondaryOption.equals("Empresa")) {
|
|
|
|
|
return ofertaRepository.findOfertaByEmpresa(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
|
|
|
|
|
return ofertaRepository.findOfertaByEmpresa(query, PageRequest.of(pageNum - 1, size, sortDir.equals("asc") ? Sort.by(sortField).ascending() : Sort.by(sortField).descending()));
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
@ -132,11 +130,11 @@ public class OfertaService implements IOferta {
|
|
|
|
|
Page<Oferta> page;
|
|
|
|
|
switch (secondaryOption) {
|
|
|
|
|
case "Empresa" -> {
|
|
|
|
|
page = ofertaRepository.findOfertaByEmpresas(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
|
|
|
|
|
page = ofertaRepository.findOfertaByEmpresas(query, PageRequest.of(pageNum - 1, size, sortDir.equals("asc") ? Sort.by(sortField).ascending() : Sort.by(sortField).descending()));
|
|
|
|
|
allMatches.addAll(page.getContent());
|
|
|
|
|
}
|
|
|
|
|
case "Skill" -> {
|
|
|
|
|
page = ofertaRepository.findOfertaBySkills(query, PageRequest.of(pageNum - 1, size, Sort.by(sortField).ascending()));
|
|
|
|
|
page = ofertaRepository.findOfertaBySkills(query, PageRequest.of(pageNum - 1, size,sortDir.equals("asc") ? Sort.by(sortField).ascending() : Sort.by(sortField).descending()));
|
|
|
|
|
allMatches.addAll(page.getContent());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -147,15 +145,6 @@ public class OfertaService implements IOferta {
|
|
|
|
|
return new PageImpl<>(allMatches.subList(start, end), PageRequest.of(pageNum - 1, size), allMatches.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isYear(String query) {
|
|
|
|
|
try {
|
|
|
|
|
Integer.parseInt(query);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Oferta> searchCustom(String querySearchBar, String queryPrime, String secondaryOption) {
|
|
|
|
|
String[] queryMultiWord = queryPrime.split(",");
|
|
|
|
@ -226,8 +215,6 @@ public class OfertaService implements IOferta {
|
|
|
|
|
listEmpPrime.addAll(ofertaRepository.findOfertaByFechaUltimos6Meses(PageRequest.of(0, 1000, Sort.by("fecha").ascending())).getContent());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return listEmpPrime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|