|
@@ -13,6 +13,7 @@ import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
@@ -33,8 +34,10 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import es.uv.saic.domain.Informe;
|
|
import es.uv.saic.domain.Informe;
|
|
@@ -58,10 +61,12 @@ import es.uv.saic.dto.DocumentTmpDTO;
|
|
|
import es.uv.saic.dto.IndicadorDTO;
|
|
import es.uv.saic.dto.IndicadorDTO;
|
|
|
import es.uv.saic.dto.InstanciaDTO;
|
|
import es.uv.saic.dto.InstanciaDTO;
|
|
|
import es.uv.saic.dto.InstanciaGanttDTO;
|
|
import es.uv.saic.dto.InstanciaGanttDTO;
|
|
|
|
|
+import es.uv.saic.dto.OrganDTO;
|
|
|
import es.uv.saic.dto.TreeDTOAny;
|
|
import es.uv.saic.dto.TreeDTOAny;
|
|
|
import es.uv.saic.dto.TreeDTODimensio;
|
|
import es.uv.saic.dto.TreeDTODimensio;
|
|
|
import es.uv.saic.dto.TreeDTOInstancia;
|
|
import es.uv.saic.dto.TreeDTOInstancia;
|
|
|
import es.uv.saic.dto.TreeDTOOrgan;
|
|
import es.uv.saic.dto.TreeDTOOrgan;
|
|
|
|
|
+import es.uv.saic.dto.UsuarisRolDTO;
|
|
|
import es.uv.saic.feign.DocumentClient;
|
|
import es.uv.saic.feign.DocumentClient;
|
|
|
import es.uv.saic.service.CategoriaService;
|
|
import es.uv.saic.service.CategoriaService;
|
|
|
import es.uv.saic.service.GraficaService;
|
|
import es.uv.saic.service.GraficaService;
|
|
@@ -71,6 +76,7 @@ import es.uv.saic.service.InformeService;
|
|
|
import es.uv.saic.service.InstanciaService;
|
|
import es.uv.saic.service.InstanciaService;
|
|
|
import es.uv.saic.service.LinkService;
|
|
import es.uv.saic.service.LinkService;
|
|
|
import es.uv.saic.service.OrganService;
|
|
import es.uv.saic.service.OrganService;
|
|
|
|
|
+import es.uv.saic.service.UsuariService;
|
|
|
import es.uv.saic.service.UsuarisRolService;
|
|
import es.uv.saic.service.UsuarisRolService;
|
|
|
|
|
|
|
|
@Controller
|
|
@Controller
|
|
@@ -80,6 +86,9 @@ public class DashboardController {
|
|
|
private OrganService os;
|
|
private OrganService os;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private UsuarisRolService urs;
|
|
private UsuarisRolService urs;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private UsuariService us;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private InformeService infs;
|
|
private InformeService infs;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -107,17 +116,20 @@ public class DashboardController {
|
|
|
@Value("${saic.data.templates.fileNotFound}")
|
|
@Value("${saic.data.templates.fileNotFound}")
|
|
|
private String fileNotFound;
|
|
private String fileNotFound;
|
|
|
|
|
|
|
|
- // GET para cargar el dashboard con toda su información
|
|
|
|
|
- @GetMapping("/dashboard")
|
|
|
|
|
- public String getOrganList(Model model, Authentication auth) {
|
|
|
|
|
|
|
+ // POST para cargar el dashboard con toda su información
|
|
|
|
|
+ @PostMapping("/dashboard")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public HashMap<String, Object> getOrganList(@RequestBody String usuari) {
|
|
|
|
|
+ HashMap<String, Object> model = new HashMap<>();
|
|
|
List<Organ> titulacions = new ArrayList<Organ>();
|
|
List<Organ> titulacions = new ArrayList<Organ>();
|
|
|
List<Organ> centres = new ArrayList<Organ>();
|
|
List<Organ> centres = new ArrayList<Organ>();
|
|
|
|
|
+ Usuari u = us.findByUsername(usuari);
|
|
|
boolean showCentres = false;
|
|
boolean showCentres = false;
|
|
|
- Usuari u = (Usuari) auth.getPrincipal();
|
|
|
|
|
|
|
|
|
|
if(urs.isGrantedUser(u)){
|
|
if(urs.isGrantedUser(u)){
|
|
|
Organ o = os.findByID("C", 0);
|
|
Organ o = os.findByID("C", 0);
|
|
|
- return "redirect:/dashboard/"+o.getRuct();
|
|
|
|
|
|
|
+ model.put("redirect", "redirect:/dashboard/"+o.getRuct());
|
|
|
|
|
+ return model;
|
|
|
}
|
|
}
|
|
|
else if(urs.isGrantedSupervisor(u)) {
|
|
else if(urs.isGrantedSupervisor(u)) {
|
|
|
titulacions = os.getTitulacions().stream().filter(o -> o.getOrgan().getId().getLugar() != 99).collect(Collectors.toList());
|
|
titulacions = os.getTitulacions().stream().filter(o -> o.getOrgan().getId().getLugar() != 99).collect(Collectors.toList());
|
|
@@ -144,63 +156,73 @@ public class DashboardController {
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
if(centres.size() == 1) {
|
|
if(centres.size() == 1) {
|
|
|
- return "redirect:/dashboard/"+centres.get(0).getRuct();
|
|
|
|
|
|
|
+ model.put("redirect", "redirect:/dashboard/"+centres.get(0).getRuct());
|
|
|
|
|
+ return model;
|
|
|
}
|
|
}
|
|
|
else if(titulacions.size() == 1) {
|
|
else if(titulacions.size() == 1) {
|
|
|
- return "redirect:/dashboard/"+titulacions.get(0).getRuct();
|
|
|
|
|
|
|
+ model.put("redirect", "redirect:/dashboard/"+titulacions.get(0).getRuct());
|
|
|
|
|
+ return model;
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- model.addAttribute("showCentres", showCentres);
|
|
|
|
|
- model.addAttribute("titulacions", titulacions);
|
|
|
|
|
- return "dashboard";
|
|
|
|
|
|
|
+ model.put("showCentres", showCentres);
|
|
|
|
|
+ model.put("titulacions", titulacions.stream().map(OrganDTO::new).toList());
|
|
|
|
|
+ model.put("redirect", "dashboard");
|
|
|
|
|
+ return model;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //GET para mostrar el dashboard a partir de un numero ruct
|
|
|
|
|
- @GetMapping("/dashboard/{ruct}")
|
|
|
|
|
- public String getDashboardOrgan(Model model, Authentication auth, @PathVariable("ruct") Integer ruct) {
|
|
|
|
|
|
|
+ //POST para mostrar el dashboard a partir de un numero ruct
|
|
|
|
|
+ @PostMapping("/dashboard/{ruct}")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public HashMap<String, Object> getDashboardOrgan(@PathVariable Integer ruct, @RequestBody String usuari) {
|
|
|
|
|
+ HashMap<String, Object> model = new HashMap<>();
|
|
|
Organ o = os.findByRuct(ruct);
|
|
Organ o = os.findByRuct(ruct);
|
|
|
|
|
+ Usuari u = us.findByUsername(usuari);
|
|
|
o.setCodis();
|
|
o.setCodis();
|
|
|
- Usuari u = (Usuari) auth.getPrincipal();
|
|
|
|
|
|
|
+
|
|
|
if(!this.isSuitable(o, u)) {
|
|
if(!this.isSuitable(o, u)) {
|
|
|
- return "401";
|
|
|
|
|
|
|
+ model.put("redirect", "401");
|
|
|
|
|
+ return model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(o.getTambit().equals("C") && o.getId().getTlugar().equals("C") && o.getId().getLugar() == 0) {
|
|
if(o.getTambit().equals("C") && o.getId().getTlugar().equals("C") && o.getId().getLugar() == 0) {
|
|
|
List<Organ> tits = os.getTitulacions();
|
|
List<Organ> tits = os.getTitulacions();
|
|
|
tits.forEach( (t) -> t.setCodis() );
|
|
tits.forEach( (t) -> t.setCodis() );
|
|
|
- model.addAttribute("titulacions", tits);
|
|
|
|
|
|
|
+ model.put("titulacions", tits.stream().map(OrganDTO::new).toList());
|
|
|
this.loadManagers(model, o.getId().getLugar(), o.getId().getLugar());
|
|
this.loadManagers(model, o.getId().getLugar(), o.getId().getLugar());
|
|
|
}
|
|
}
|
|
|
else if(o.getTambit().equals("C")){
|
|
else if(o.getTambit().equals("C")){
|
|
|
List<Organ> tits = this.os.getTitulacionsByCentre(o.getId().getLugar());
|
|
List<Organ> tits = this.os.getTitulacionsByCentre(o.getId().getLugar());
|
|
|
- model.addAttribute("titulacions", tits);
|
|
|
|
|
|
|
+ model.put("titulacions", tits.stream().map(OrganDTO::new).toList());
|
|
|
this.loadManagers(model, o.getId().getLugar(), o.getId().getLugar());
|
|
this.loadManagers(model, o.getId().getLugar(), o.getId().getLugar());
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
this.loadManagers(model, o.getOrgan().getId().getLugar(), o.getId().getLugar());
|
|
this.loadManagers(model, o.getOrgan().getId().getLugar(), o.getId().getLugar());
|
|
|
}
|
|
}
|
|
|
List<Categoria> c = cs.findFirstLevel(o.getId().getTlugar());
|
|
List<Categoria> c = cs.findFirstLevel(o.getId().getTlugar());
|
|
|
- model.addAttribute("organ", o);
|
|
|
|
|
- model.addAttribute("categories", c);
|
|
|
|
|
- model.addAttribute("editable", ((Usuari)auth.getPrincipal()).isAdmin() || ((Usuari)auth.getPrincipal()).isGranted());
|
|
|
|
|
- model.addAttribute("showCentres", false);
|
|
|
|
|
|
|
+ model.put("organ", new OrganDTO(o));
|
|
|
|
|
+ model.put("categories", c);
|
|
|
|
|
+ model.put("editable", (u.isAdmin() || (u.isGranted())));
|
|
|
|
|
+ model.put("showCentres", false);
|
|
|
if(o.getTambit().equals("C") && o.getId().getTlugar().equals("C") && o.getId().getLugar() == 0) {
|
|
if(o.getTambit().equals("C") && o.getId().getTlugar().equals("C") && o.getId().getLugar() == 0) {
|
|
|
- model.addAttribute("showCentres", true);
|
|
|
|
|
|
|
+ model.put("showCentres", true);
|
|
|
c = cs.findFirstLevelAndU(o.getId().getTlugar());
|
|
c = cs.findFirstLevelAndU(o.getId().getTlugar());
|
|
|
- model.addAttribute("categories", c);
|
|
|
|
|
- return "dashboardUniversitat";
|
|
|
|
|
|
|
+ model.put("categories", c);
|
|
|
|
|
+ model.put("redirect", "dashboardUniversitat");
|
|
|
|
|
+ return model;
|
|
|
}
|
|
}
|
|
|
else if(o.getTambit().equals("C")) {
|
|
else if(o.getTambit().equals("C")) {
|
|
|
- return "dashboardCentre";
|
|
|
|
|
|
|
+ model.put("redirect", "dashboardCentre");
|
|
|
|
|
+ return model;
|
|
|
}
|
|
}
|
|
|
- return "dashboardTitulacio";
|
|
|
|
|
|
|
+ model.put("redirect", "dashboardTitulacio");
|
|
|
|
|
+ return model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// GET para conseguir todos los procedimiento a partir del idTitulacio
|
|
// GET para conseguir todos los procedimiento a partir del idTitulacio
|
|
|
- @GetMapping("/dashboard/procedures/{idTitulacio}")
|
|
|
|
|
|
|
+ @PostMapping("/dashboard/procedures/{idTitulacio}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<?> loadReports(Model model, Authentication auth, @PathVariable("idTitulacio") Integer idTitulacio) {
|
|
|
|
|
|
|
+ public List<?> loadReports(@PathVariable Integer idTitulacio) {
|
|
|
String locale = LocaleContextHolder.getLocale().getLanguage();
|
|
String locale = LocaleContextHolder.getLocale().getLanguage();
|
|
|
Organ o = os.findByRuct(idTitulacio);
|
|
Organ o = os.findByRuct(idTitulacio);
|
|
|
List<Informe> informes = this.infs.findByGrupWebTambit("D", o.getTambit());
|
|
List<Informe> informes = this.infs.findByGrupWebTambit("D", o.getTambit());
|
|
@@ -327,7 +349,7 @@ public class DashboardController {
|
|
|
// GET para conseguir la documentación ya a aportada a partir del id de la tituación
|
|
// GET para conseguir la documentación ya a aportada a partir del id de la tituación
|
|
|
@GetMapping("/dashboard/documents/{idTitulacio}")
|
|
@GetMapping("/dashboard/documents/{idTitulacio}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<CategoriaDocumentDTO> loadDocuments(Model model, @PathVariable("idTitulacio") Integer idTitulacio){
|
|
|
|
|
|
|
+ public List<CategoriaDocumentDTO> loadDocuments(@PathVariable Integer idTitulacio) {
|
|
|
String locale = LocaleContextHolder.getLocale().getLanguage();
|
|
String locale = LocaleContextHolder.getLocale().getLanguage();
|
|
|
Organ o = os.findByRuct(idTitulacio);
|
|
Organ o = os.findByRuct(idTitulacio);
|
|
|
List<Categoria> parents = cs.findFirstLevelAndU(o.getId().getTlugar());
|
|
List<Categoria> parents = cs.findFirstLevelAndU(o.getId().getTlugar());
|
|
@@ -363,7 +385,7 @@ public class DashboardController {
|
|
|
// GET para conseguir el diagrama de gantt a partir del ruct
|
|
// GET para conseguir el diagrama de gantt a partir del ruct
|
|
|
@GetMapping("/dashboard/gantt/{ruct}")
|
|
@GetMapping("/dashboard/gantt/{ruct}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<InstanciaGanttDTO> loadGantt(Model model, @PathVariable("ruct") Integer ruct){
|
|
|
|
|
|
|
+ public List<InstanciaGanttDTO> loadGantt(@PathVariable Integer ruct) {
|
|
|
Organ o = os.findByRuct(ruct);
|
|
Organ o = os.findByRuct(ruct);
|
|
|
List<Integer> ambits = Arrays.asList(1, 2, 3, 0);
|
|
List<Integer> ambits = Arrays.asList(1, 2, 3, 0);
|
|
|
if(!o.getTambit().equals("C")) {
|
|
if(!o.getTambit().equals("C")) {
|
|
@@ -408,24 +430,21 @@ public class DashboardController {
|
|
|
|
|
|
|
|
@GetMapping("/dashboard/documents/cats/{idCategoria}/{tambit}")
|
|
@GetMapping("/dashboard/documents/cats/{idCategoria}/{tambit}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<Categoria> getDocumentChildCats(@PathVariable("idCategoria") Integer idCategoria, @PathVariable("tambit") String tambit){
|
|
|
|
|
- List<Categoria> c = cs.findByPareTambit(idCategoria, tambit);
|
|
|
|
|
- return c;
|
|
|
|
|
|
|
+ public List<Categoria> getDocumentChildCats(@PathVariable Integer idCategoria, @PathVariable String tambit) {
|
|
|
|
|
+ return cs.findByPareTambit(idCategoria, tambit);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/dashboard/documents/catsu/{idCategoria}/{tambit}")
|
|
@GetMapping("/dashboard/documents/catsu/{idCategoria}/{tambit}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<Categoria> getDocumentChildCatsU(@PathVariable("idCategoria") Integer idCategoria, @PathVariable("tambit") String tambit){
|
|
|
|
|
- List<Categoria> c = cs.findByPareTambitAndU(idCategoria, tambit);
|
|
|
|
|
- System.out.println(c);
|
|
|
|
|
- return c;
|
|
|
|
|
|
|
+ public List<Categoria> getDocumentChildCatsU(@PathVariable Integer idCategoria, @PathVariable String tambit) {
|
|
|
|
|
+ return cs.findByPareTambitAndU(idCategoria, tambit);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// POST para guardar un documento en el sistema
|
|
// POST para guardar un documento en el sistema
|
|
|
@PostMapping("/dashboard/documents")
|
|
@PostMapping("/dashboard/documents")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public void uploadDocument(Model model, @RequestParam MultipartFile file, @RequestParam("idCategoria") Integer idCategoria,
|
|
|
|
|
- @RequestParam("lugar") Integer lugar, @RequestParam("tlugar") String tlugar) throws IllegalStateException, IOException {
|
|
|
|
|
|
|
+ public void uploadDocument(@RequestParam MultipartFile file, @RequestParam Integer idCategoria,
|
|
|
|
|
+ @RequestParam Integer lugar, @RequestParam String tlugar) throws IllegalStateException, IOException {
|
|
|
|
|
|
|
|
Categoria cat = this.cs.findById(idCategoria);
|
|
Categoria cat = this.cs.findById(idCategoria);
|
|
|
Organ org = this.os.findByID(tlugar, lugar);
|
|
Organ org = this.os.findByID(tlugar, lugar);
|
|
@@ -448,14 +467,15 @@ public class DashboardController {
|
|
|
// POST para añadir un documento a un centro cocncreto
|
|
// POST para añadir un documento a un centro cocncreto
|
|
|
@PostMapping("/dashboard/documents/archive")
|
|
@PostMapping("/dashboard/documents/archive")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public void archiveDocuments(Model model, @RequestParam("lugar") Integer lugar, @RequestParam("tlugar") String tlugar) {
|
|
|
|
|
- this.archiveByOrgan(lugar, tlugar);
|
|
|
|
|
|
|
+ public void archiveDocuments(Model model, @RequestParam Integer lugar, @RequestParam String tlugar) {
|
|
|
|
|
+ ArchiveOrganDTO organ = new ArchiveOrganDTO(lugar, tlugar);
|
|
|
|
|
+ dc.archiveByOrgan(organ);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// GET para conseguir todos los graficos a partir de un RUCT
|
|
// GET para conseguir todos los graficos a partir de un RUCT
|
|
|
@GetMapping("/dashboard/graphs/list/{ruct}")
|
|
@GetMapping("/dashboard/graphs/list/{ruct}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<Grafica> getGraphDataList(@PathVariable("ruct") Integer ruct) throws ParserConfigurationException{
|
|
|
|
|
|
|
+ public List<Grafica> getGraphDataList(@PathVariable Integer ruct) throws ParserConfigurationException {
|
|
|
Organ o = os.findByRuct(ruct);
|
|
Organ o = os.findByRuct(ruct);
|
|
|
if(o.getId().getTlugar().equals("C")) {
|
|
if(o.getId().getTlugar().equals("C")) {
|
|
|
return this.gs.findLikeAmbit("%"+o.getId().getTlugar()+"%");
|
|
return this.gs.findLikeAmbit("%"+o.getId().getTlugar()+"%");
|
|
@@ -468,15 +488,14 @@ public class DashboardController {
|
|
|
//GET para conseguir todos los datos concretos de tasas para las tablas
|
|
//GET para conseguir todos los datos concretos de tasas para las tablas
|
|
|
@GetMapping("/dashboard/graphs/rates/{lugar}")
|
|
@GetMapping("/dashboard/graphs/rates/{lugar}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<Indicador> getGraphDataTaxes(@PathVariable("lugar") Integer lugar) throws ParserConfigurationException{
|
|
|
|
|
- List<Indicador> inds = this.ids.getGraphData(lugar);
|
|
|
|
|
- return inds;
|
|
|
|
|
|
|
+ public List<Indicador> getGraphDataTaxes(@PathVariable Integer lugar) throws ParserConfigurationException {
|
|
|
|
|
+ return this.ids.getGraphData(lugar);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//GET para conseguir todos los datos concretos de cada gráfico
|
|
//GET para conseguir todos los datos concretos de cada gráfico
|
|
|
@GetMapping({"/dashboard/graphs/inds/{ruct}", "/dashboard/graphs/inds/{ruct}/{tambit}"})
|
|
@GetMapping({"/dashboard/graphs/inds/{ruct}", "/dashboard/graphs/inds/{ruct}/{tambit}"})
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<Indicador> getGraphData(@PathVariable("ruct") Integer ruct, @PathVariable("tambit") Optional<String> tambit) throws ParserConfigurationException{
|
|
|
|
|
|
|
+ public List<Indicador> getGraphData(@PathVariable Integer ruct, @PathVariable Optional<String> tambit) throws ParserConfigurationException {
|
|
|
Organ o = os.findByRuct(ruct);
|
|
Organ o = os.findByRuct(ruct);
|
|
|
int year = Year.now().getValue();
|
|
int year = Year.now().getValue();
|
|
|
List<IndicadorDTO> data = new ArrayList<IndicadorDTO>();
|
|
List<IndicadorDTO> data = new ArrayList<IndicadorDTO>();
|
|
@@ -526,8 +545,7 @@ public class DashboardController {
|
|
|
|
|
|
|
|
@GetMapping("/dashboard/links/{ruct}")
|
|
@GetMapping("/dashboard/links/{ruct}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
|
|
- public List<Link> getLinks(@PathVariable("ruct") Integer ruct) {
|
|
|
|
|
|
|
+ public List<Link> getLinks(@PathVariable Integer ruct) {
|
|
|
List<Link> links = this.ls.findByRuct(ruct);
|
|
List<Link> links = this.ls.findByRuct(ruct);
|
|
|
for(Link l : links){
|
|
for(Link l : links){
|
|
|
l.setLink(publicUrl+l.getLink());
|
|
l.setLink(publicUrl+l.getLink());
|
|
@@ -537,8 +555,7 @@ public class DashboardController {
|
|
|
|
|
|
|
|
@PostMapping("/dashboard/links/{ruct}")
|
|
@PostMapping("/dashboard/links/{ruct}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
|
|
- public Link createLink(@PathVariable("ruct") Integer ruct, @RequestParam("dataExp") String dataExp) throws ParseException {
|
|
|
|
|
|
|
+ public Link createLink(@PathVariable Integer ruct, @RequestParam String dataExp) throws ParseException {
|
|
|
|
|
|
|
|
String token = UUID.randomUUID().toString();
|
|
String token = UUID.randomUUID().toString();
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
|
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
|
@@ -558,8 +575,7 @@ public class DashboardController {
|
|
|
|
|
|
|
|
@DeleteMapping("/dashboard/links/{id}")
|
|
@DeleteMapping("/dashboard/links/{id}")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- @Secured({"ROLE_ADMIN", "ROLE_MANAGER"})
|
|
|
|
|
- public Integer deleteLink(@PathVariable("id") Integer id) {
|
|
|
|
|
|
|
+ public Integer deleteLink(@PathVariable Integer id) {
|
|
|
Link l = this.ls.findById(id);
|
|
Link l = this.ls.findById(id);
|
|
|
if(l != null){
|
|
if(l != null){
|
|
|
this.ls.delete(l);
|
|
this.ls.delete(l);
|
|
@@ -616,8 +632,8 @@ public class DashboardController {
|
|
|
}
|
|
}
|
|
|
else{
|
|
else{
|
|
|
model.addAttribute("results", true);
|
|
model.addAttribute("results", true);
|
|
|
- model.addAttribute("resp_centres", resp_centre);
|
|
|
|
|
- model.addAttribute("resp_titulacions", resp_titulacio);
|
|
|
|
|
|
|
+ model.addAttribute("resp_centres", resp_centre.stream().map(UsuarisRolDTO::new).toList());
|
|
|
|
|
+ model.addAttribute("resp_titulacions", resp_titulacio.stream().map(UsuarisRolDTO::new).toList());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -689,13 +705,60 @@ public class DashboardController {
|
|
|
return dc.archive(doc);
|
|
return dc.archive(doc);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void archiveByOrgan(Integer lugar, String tlugar) {
|
|
|
|
|
- ArchiveOrganDTO organ = new ArchiveOrganDTO(lugar, tlugar);
|
|
|
|
|
- dc.archiveByOrgan(organ);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private String upload(Integer idDocument, Integer idCategoria, Integer lugar, String tlugar, MultipartFile file) {
|
|
private String upload(Integer idDocument, Integer idCategoria, Integer lugar, String tlugar, MultipartFile file) {
|
|
|
DocumentTmpDTO doc = new DocumentTmpDTO(idDocument, idCategoria, lugar, tlugar, file);
|
|
DocumentTmpDTO doc = new DocumentTmpDTO(idDocument, idCategoria, lugar, tlugar, file);
|
|
|
return dc.upload(doc);
|
|
return dc.upload(doc);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void loadManagers(HashMap<String, Object> model, Integer centre, Integer titulacio) {
|
|
|
|
|
+ List<Integer> centres = Arrays.asList(centre);
|
|
|
|
|
+ List<Integer> titulacions = Arrays.asList(titulacio);
|
|
|
|
|
+ List<UsuarisRol> resp_centre = urs.findManagerByCentres(centres);
|
|
|
|
|
+ Collections.sort(resp_centre, new Comparator<UsuarisRol>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(UsuarisRol a, UsuarisRol b) {
|
|
|
|
|
+
|
|
|
|
|
+ int OrgnomComp = a.getOrgan().getNomVal().compareTo(b.getOrgan().getNomVal());
|
|
|
|
|
+ if (OrgnomComp != 0) {
|
|
|
|
|
+ return OrgnomComp;
|
|
|
|
|
+ }
|
|
|
|
|
+ int rolComp = a.getRol().getNomRol().compareTo(b.getRol().getNomRol());
|
|
|
|
|
+ if (rolComp != 0) {
|
|
|
|
|
+ return rolComp;
|
|
|
|
|
+ }
|
|
|
|
|
+ return a.getUsuari().getNom().concat(a.getUsuari().getCognoms()).compareTo(
|
|
|
|
|
+ b.getUsuari().getNom().concat(b.getUsuari().getCognoms()));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ List<UsuarisRol> resp_titulacio = new ArrayList<UsuarisRol>();
|
|
|
|
|
+ if(titulacions.size() > 0) {
|
|
|
|
|
+ resp_titulacio = urs.findManagerByTitulacions(titulacions);
|
|
|
|
|
+ Collections.sort(resp_titulacio, new Comparator<UsuarisRol>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(UsuarisRol a, UsuarisRol b) {
|
|
|
|
|
+
|
|
|
|
|
+ int OrgnomComp = a.getOrgan().getNomVal().compareTo(b.getOrgan().getNomVal());
|
|
|
|
|
+ if (OrgnomComp != 0) {
|
|
|
|
|
+ return OrgnomComp;
|
|
|
|
|
+ }
|
|
|
|
|
+ int rolComp = a.getRol().getNomRol().compareTo(b.getRol().getNomRol());
|
|
|
|
|
+ if (rolComp != 0) {
|
|
|
|
|
+ return rolComp;
|
|
|
|
|
+ }
|
|
|
|
|
+ return a.getUsuari().getNom().concat(a.getUsuari().getCognoms()).compareTo(
|
|
|
|
|
+ b.getUsuari().getNom().concat(b.getUsuari().getCognoms()));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(resp_centre == null) {
|
|
|
|
|
+ model.put("results", false);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ model.put("results", true);
|
|
|
|
|
+ model.put("resp_centres", resp_centre.stream().map(UsuarisRolDTO::new).toList());
|
|
|
|
|
+ model.put("resp_titulacions", resp_titulacio.stream().map(UsuarisRolDTO::new).toList());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|