diff --git a/src/main/java/com/example/proyectofinal/controllers/BuscadorController.java b/src/main/java/com/example/proyectofinal/controllers/BuscadorController.java index c93e102..2926b12 100644 --- a/src/main/java/com/example/proyectofinal/controllers/BuscadorController.java +++ b/src/main/java/com/example/proyectofinal/controllers/BuscadorController.java @@ -199,8 +199,6 @@ public class BuscadorController { @RequestParam(defaultValue = "asc") String sortDir, @RequestParam(defaultValue = "") String secondaryOption, Model model) throws ParseException { - System.out.println("Query: TEST " + query); - System.out.println("SecondaryOption: TEST " + secondaryOption); String[] queryMultiWord = query.split(","); List queryList = new ArrayList<>(); for (String queryForList : queryMultiWord) { @@ -237,7 +235,6 @@ public class BuscadorController { @RequestParam(defaultValue = "asc") String sortDir, @RequestParam(defaultValue = "") String secondaryOption, Model model) { - String[] word = query.split("\\b(y|o)\\b|[,/]"); List itemsPage = Arrays.asList(5, 10, 15, 20, 25, 50); Map attributes = new HashMap<>(); if (secondaryOption.equalsIgnoreCase("Todo")){ @@ -260,7 +257,6 @@ public class BuscadorController { @RequestParam(defaultValue = "asc") String sortDir, @RequestParam(defaultValue = "") String secondaryOption, Model model) throws ParseException { - System.out.println("Query: TEST " + query); String[] queryMultiWord = query.split(","); List queryList = new ArrayList<>(); for (String queryForList : queryMultiWord) { diff --git a/src/main/java/com/example/proyectofinal/controllers/LogOutController.java b/src/main/java/com/example/proyectofinal/controllers/LogOutController.java index 6edc995..36e3558 100644 --- a/src/main/java/com/example/proyectofinal/controllers/LogOutController.java +++ b/src/main/java/com/example/proyectofinal/controllers/LogOutController.java @@ -19,9 +19,6 @@ import java.util.Optional; @Controller public class LogOutController { - - @Autowired - private UsuarioService usuarioService; @Autowired private UserRepository userRepository; diff --git a/src/main/java/com/example/proyectofinal/controllers/modelControllers/ContactoController.java b/src/main/java/com/example/proyectofinal/controllers/modelControllers/ContactoController.java index d41758c..e071658 100644 --- a/src/main/java/com/example/proyectofinal/controllers/modelControllers/ContactoController.java +++ b/src/main/java/com/example/proyectofinal/controllers/modelControllers/ContactoController.java @@ -66,7 +66,6 @@ public class ContactoController { } } - @RolesAllowed({"ADMIN"}) @GetMapping("/admin/contacto/update/{id}") public String showUpdateForm(Model model, @PathVariable Long id,Authentication authentication) { Collection authorities = authentication.getAuthorities(); @@ -111,7 +110,7 @@ public class ContactoController { throw new ResponseStatusException(HttpStatus.FORBIDDEN, "No tienes permisos para acceder a esta página"); } try{ - empresaService.deleteById(id); + contactosService.deleteById(id); return new ResponseEntity<>("El contacto ha sido eliminado", HttpStatus.OK); }catch (Exception e){ return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); diff --git a/src/main/java/com/example/proyectofinal/controllers/modelControllers/EmpressaController.java b/src/main/java/com/example/proyectofinal/controllers/modelControllers/EmpressaController.java index c725c8a..b95d075 100644 --- a/src/main/java/com/example/proyectofinal/controllers/modelControllers/EmpressaController.java +++ b/src/main/java/com/example/proyectofinal/controllers/modelControllers/EmpressaController.java @@ -112,10 +112,17 @@ public class EmpressaController { empresa.setKeywords(keywords); Sector existingSector = sectorService.findById(sectorId); if(existingSector != null) { + System.out.println("TEST UPDATE: EX-SEC " + existingSector.getNombre()); + System.out.println("TEST UPDATE: EX-SEC " + existingSector.getId()); empresa.setSector(existingSector); + System.out.println("TEST UPDATE: EMPRESA-NOMBRE " + empresa.getNombre()); + System.out.println("TEST UPDATE: EMPRESA-ID " + empresa.getId()); + System.out.println("TEST UPDATE: EMPRESA-SEC " + empresa.getSector().getNombre()); + System.out.println("TEST UPDATE: EMPRESA-SEC-ID " + empresa.getSector().getId()); } else { return new ResponseEntity<>("Sector no encontrado", HttpStatus.BAD_REQUEST); } + empresaService.save(empresa); return new ResponseEntity<>("Los datos de la empresa fue renovados con exito", HttpStatus.OK); }catch (Exception e) { diff --git a/src/main/java/com/example/proyectofinal/repositories/empresas/EmpressaRepository.java b/src/main/java/com/example/proyectofinal/repositories/empresas/EmpressaRepository.java index e03ecd5..002ad45 100644 --- a/src/main/java/com/example/proyectofinal/repositories/empresas/EmpressaRepository.java +++ b/src/main/java/com/example/proyectofinal/repositories/empresas/EmpressaRepository.java @@ -7,9 +7,11 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; @@ -60,6 +62,11 @@ public interface EmpressaRepository extends JpaRepository, JpaSpe @Query("SELECT e FROM Empresa e WHERE e.keywords LIKE %:query%") ArrayList findEmpresasByKeywordsCust(String query); + @Modifying + @Transactional + @Query("UPDATE Empresa e SET e.nombre = :nombre, e.cif = :cif, e.correo = :correo, e.telefono = :telefono, e.keywords = :keywords, e.sector.id = :sectorId WHERE e.id = :id") + void saveManualy(@Param("id") Long id, @Param("nombre") String nombre, @Param("cif") String cif, @Param("correo") String correo, @Param("telefono") String telefono, @Param("keywords") String keywords, @Param("sectorId") Long sectorId); + // @Query() // List findByQueryAndSecondaryOption(String query, String secondaryQuery); diff --git a/src/main/java/com/example/proyectofinal/repositories/empresas/OfertaRepository.java b/src/main/java/com/example/proyectofinal/repositories/empresas/OfertaRepository.java index 4f67967..98ebb5a 100644 --- a/src/main/java/com/example/proyectofinal/repositories/empresas/OfertaRepository.java +++ b/src/main/java/com/example/proyectofinal/repositories/empresas/OfertaRepository.java @@ -56,7 +56,7 @@ public interface OfertaRepository extends JpaRepository { Page findOfertaByEmpresa(@Param("query") String query, Pageable pageable); @Query(value = "SELECT * FROM ofertas o WHERE YEAR(o.fecha) = :yearQuery", nativeQuery = true) - Page findOfertaByFechaAnyo(@Param("yearQuery") Integer yearQuery, Pageable pageable); + Page findOfertaByFechaAnyo(@Param("yearQuery") String yearQuery, Pageable pageable); @Query("SELECT o FROM Oferta o WHERE lower(o.nombre) IN :queryList") Page findOfertasByNombres(@Param("queryList") String queryList, Pageable pageable); @@ -76,9 +76,12 @@ public interface OfertaRepository extends JpaRepository { @Query("SELECT o FROM Oferta o JOIN o.skills s WHERE s.nombre LIKE %:query%") Collection ofertasBySkillCust(@Param("query") String query); - @Query(value = "SELECT * FROM ofertas o WHERE YEAR(o.fecha) = YEAR(:dateQuery)", nativeQuery = true) - Collection ofertasByFechaAnyoCust(Date dateQuery); - @Query(value = "SELECT DISTINCT YEAR(o.fecha) FROM ofertas o", nativeQuery = true) List findDistinctYears(); + + @Query(value = "SELECT * FROM ofertas o WHERE o.fecha >= CURRENT_DATE - INTERVAL 3 MONTH", nativeQuery = true) + Page findOfertaByFechaUltimos3Meses(Pageable pageable); + + @Query(value = "SELECT * FROM ofertas o WHERE o.fecha >= CURRENT_DATE - INTERVAL 6 MONTH", nativeQuery = true) + Page findOfertaByFechaUltimos6Meses(Pageable pageable); } diff --git a/src/main/java/com/example/proyectofinal/servicios/empresa/EmpresaService.java b/src/main/java/com/example/proyectofinal/servicios/empresa/EmpresaService.java index 5a1a376..96bf0e1 100644 --- a/src/main/java/com/example/proyectofinal/servicios/empresa/EmpresaService.java +++ b/src/main/java/com/example/proyectofinal/servicios/empresa/EmpresaService.java @@ -56,7 +56,6 @@ public class EmpresaService implements IEmpresa { public Empresa save(Empresa empresa) { return empresaRepository.save(empresa); } - @Transactional @Override public void deleteById(Long id) { @@ -156,5 +155,11 @@ public class EmpresaService implements IEmpresa { listEmpPrime.retainAll(listEmpSec); return listEmpPrime; } + + @Override + public void saveManualy(long id, String nombre, String cif, String correo, String telefono, String keywords, long id1) { + empresaRepository.saveManualy( id, nombre, cif, correo, telefono, keywords, id1); + + } } diff --git a/src/main/java/com/example/proyectofinal/servicios/empresa/OfertaService.java b/src/main/java/com/example/proyectofinal/servicios/empresa/OfertaService.java index efa817e..f630058 100644 --- a/src/main/java/com/example/proyectofinal/servicios/empresa/OfertaService.java +++ b/src/main/java/com/example/proyectofinal/servicios/empresa/OfertaService.java @@ -108,19 +108,20 @@ public class OfertaService implements IOferta { } @Override public Page 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()); } } } diff --git a/src/main/java/com/example/proyectofinal/servicios/implemetations/empresas/IEmpresa.java b/src/main/java/com/example/proyectofinal/servicios/implemetations/empresas/IEmpresa.java index f5e4b78..6e84d54 100644 --- a/src/main/java/com/example/proyectofinal/servicios/implemetations/empresas/IEmpresa.java +++ b/src/main/java/com/example/proyectofinal/servicios/implemetations/empresas/IEmpresa.java @@ -28,5 +28,7 @@ public interface IEmpresa extends IPagination { List searchCustom(String querySearchBar, String query,String secondaryOption); + void saveManualy(long id, String nombre, String cif, String correo, String telefono, String keywords, long id1); + // List getEmpresasByQueryAndSecondaryOption(String query, String secondaryQuery); } diff --git a/src/main/resources/static/style.css b/src/main/resources/static/style.css index bbb9d02..1fa357f 100644 --- a/src/main/resources/static/style.css +++ b/src/main/resources/static/style.css @@ -41,28 +41,27 @@ h1 { .table { width: 100%; } -.table td, .table th { - overflow: visible; - white-space: nowrap; +.table th, .table td.keywords-cell { + width: 200px; /* Adjust this value to your needs */ } .table thead th { position: sticky; top: 0; background: #fff; z-index: 10; + width: 200px; /* Set a specific width */ + overflow: auto; /* Add overflow */ } -.table td { - width: 100px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; +.table td.keywords-cell { + display: inline-block !important; + overflow-x: auto !important; + text-overflow: clip !important; + border: 1px solid #ddd; } -.table tr td:first-child { - width: 50px; - overflow: hidden; - text-overflow: ellipsis; +.table-header, .keywords-cell { + width: 200px; /* Adjust this value as needed */ } -.table tr th:first-child { +.table tr td:first-child { width: 50px; overflow: hidden; text-overflow: ellipsis; diff --git a/src/main/resources/templates/admin/alumno/create.html b/src/main/resources/templates/admin/alumno/create.html index 27e74d8..ef764bf 100644 --- a/src/main/resources/templates/admin/alumno/create.html +++ b/src/main/resources/templates/admin/alumno/create.html @@ -170,7 +170,7 @@
-

Select Skills

+

Elige Skills

diff --git a/src/main/resources/templates/admin/alumno/update.html b/src/main/resources/templates/admin/alumno/update.html index d1568ec..793eba7 100644 --- a/src/main/resources/templates/admin/alumno/update.html +++ b/src/main/resources/templates/admin/alumno/update.html @@ -169,7 +169,7 @@
-

Select Skills

+

Elige Skills

diff --git a/src/main/resources/templates/admin/contacto/create.html b/src/main/resources/templates/admin/contacto/create.html index 4c37de6..bb4ee03 100644 --- a/src/main/resources/templates/admin/contacto/create.html +++ b/src/main/resources/templates/admin/contacto/create.html @@ -74,9 +74,9 @@
- +
- +
diff --git a/src/main/resources/templates/admin/contacto/update.html b/src/main/resources/templates/admin/contacto/update.html index 6af537f..1d0ff9b 100644 --- a/src/main/resources/templates/admin/contacto/update.html +++ b/src/main/resources/templates/admin/contacto/update.html @@ -74,9 +74,9 @@
- +
- +
@@ -109,6 +109,7 @@ +
@@ -127,7 +128,7 @@ var formData = $(this).serialize(); var empresaId = $('#empresa').val(); - formData += '&contacto=' + encodeURIComponent(empresaId); + formData += '&empresa.id=' + encodeURIComponent(empresaId); $.ajax({ url: '/contacto/update', type: 'post', diff --git a/src/main/resources/templates/admin/empresa/create.html b/src/main/resources/templates/admin/empresa/create.html index 9e687de..5fe82d6 100644 --- a/src/main/resources/templates/admin/empresa/create.html +++ b/src/main/resources/templates/admin/empresa/create.html @@ -136,7 +136,6 @@ }); function goBack() { - console.log("goBack function called"); window.history.back(); } diff --git a/src/main/resources/templates/admin/empresa/update.html b/src/main/resources/templates/admin/empresa/update.html index 39b68ea..1259988 100644 --- a/src/main/resources/templates/admin/empresa/update.html +++ b/src/main/resources/templates/admin/empresa/update.html @@ -127,6 +127,9 @@ \ No newline at end of file diff --git a/src/main/resources/templates/buscador_alumno.html b/src/main/resources/templates/buscador_alumno.html index 3efc461..2fb3313 100644 --- a/src/main/resources/templates/buscador_alumno.html +++ b/src/main/resources/templates/buscador_alumno.html @@ -219,9 +219,12 @@ var secondaryDropdown = document.getElementById('secondaryDropdown'); secondaryDropdown.addEventListener('change', function() { - if (secondaryDropdown.value === 'Todo') { + if (secondaryDropdown.value === 'Todo') { searchBar.value = 'Todo'; searchBar.disabled = true; + } else if (secondaryDropdown.value === 'Este Año' || secondaryDropdown.value === 'Ultimos 3 meses' || secondaryDropdown.value === 'Ultimos 6 meses') { + searchBar.value = secondaryDropdown.value; + searchBar.disabled = true; } else { searchBar.value = ''; searchBar.disabled = false; @@ -244,7 +247,7 @@ options = ['Todo', 'Nombre', 'Empresa']; break; case'ofertas': - options = ['Todo', 'Nombre', 'Empresa','Año']; + options = ['Todo', 'Nombre', 'Empresa','Este Año',"Ultimos 3 meses","Ultimos 6 meses"]; break; case'sucursales': options = ['Todo', 'Nombre', 'Empresa','Localidad']; diff --git a/src/main/resources/templates/list/alumnos.html b/src/main/resources/templates/list/alumnos.html index 064bafa..874df95 100644 --- a/src/main/resources/templates/list/alumnos.html +++ b/src/main/resources/templates/list/alumnos.html @@ -107,9 +107,9 @@ [[${alumno.correo}]] [[${alumno.correo2}]] [[${alumno.nacionalidad}]] - [[${alumno.keywords}]] + [[${alumno.keywords}]] [[${alumno.ciclo.nombre}]] - + @@ -146,8 +146,8 @@