|
@@ -0,0 +1,302 @@
|
|
|
|
|
+package es.uv.saic.web;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonMappingException;
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
+import com.fasterxml.jackson.databind.SerializationFeature;
|
|
|
|
|
+
|
|
|
|
|
+import es.uv.saic.domain.Organ;
|
|
|
|
|
+import es.uv.saic.service.IndicadorService;
|
|
|
|
|
+import es.uv.saic.domain.Indicador;
|
|
|
|
|
+import es.uv.saic.domain.IndicadorEnquesta;
|
|
|
|
|
+import es.uv.saic.domain.IndicadorEnquestaRepository.IndicadorEnquestaValor;
|
|
|
|
|
+import es.uv.saic.service.IndicadorEnquestaService;
|
|
|
|
|
+import es.uv.saic.service.IndicadorEnquestaTmpService;
|
|
|
|
|
+
|
|
|
|
|
+@RestController
|
|
|
|
|
+public class IndicadorController {
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IndicadorService is;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IndicadorEnquestaService ies;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IndicadorEnquestaTmpService iets;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private es.uv.saic.service.OrganService os;
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Endpoint para la funcion deleteByEnquestaCursAmbitEstudi de iets
|
|
|
|
|
+ */
|
|
|
|
|
+ @DeleteMapping("/delete/ByEnquestaCursAmbitEstudi")
|
|
|
|
|
+ public ResponseEntity<String> deleteByEnquestaCursAmbitEstudi(@RequestBody String json) {
|
|
|
|
|
+
|
|
|
|
|
+ //Parsear el JSON
|
|
|
|
|
+ JsonNode jsonNode = null;
|
|
|
|
|
+ Integer i = 0;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonNode = com.fasterxml.jackson.databind.json.JsonMapper.builder().build().readTree(json);
|
|
|
|
|
+
|
|
|
|
|
+ String enquesta = jsonNode.get("enquesta").asText();
|
|
|
|
|
+ Integer curs = jsonNode.get("curs").asInt();
|
|
|
|
|
+ String ambit = jsonNode.get("ambit").asText();
|
|
|
|
|
+ String estudi = jsonNode.get("estudi").asText();
|
|
|
|
|
+
|
|
|
|
|
+ //i = iets.deleteByEnquestaCursAmbitEstudi(enquesta, curs, ambit, estudi);
|
|
|
|
|
+ }catch (JsonMappingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al mapear el JSON: " + e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al eliminar la enquesta: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResponseEntity.ok("Se han eliminado " + i + " enquesta/s.");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Endpoint para la funcion deleteFromCurrent de iets, dev
|
|
|
|
|
+ */
|
|
|
|
|
+ @DeleteMapping("/delete/current/{enquesta}")
|
|
|
|
|
+ public ResponseEntity<String> deleteFromCurrent(@PathVariable("enquesta") String enquesta) {
|
|
|
|
|
+ //Llamada al servicio, si el resultado es 0 no se ha borrado nada devolvemos error, sino ok
|
|
|
|
|
+ Integer i = 0;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ //i = iets.deleteFromCurrent(enquesta);
|
|
|
|
|
+ if(i == 0)
|
|
|
|
|
+ return ResponseEntity.badRequest().body("No se ha eliminado ninguna enquesta.");
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al eliminar las enquestas: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok("Se han eliminado " + i + " enquesta/s.");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Endpoint para la funcion deleteFromPending de iets
|
|
|
|
|
+ */
|
|
|
|
|
+ @DeleteMapping("/delete/pending/{enquesta}")
|
|
|
|
|
+ public ResponseEntity<String> deleteFromPending(@PathVariable("enquesta") String enquesta) {
|
|
|
|
|
+ Integer i = 0;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ //i = iets.deleteFromPending(enquesta);
|
|
|
|
|
+ if(i == 0)
|
|
|
|
|
+ return ResponseEntity.badRequest().body("No se ha eliminado ninguna enquesta pendiente.");
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al eliminar las enquestas pendientes: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok("Se han eliminado " + i + " enquestas pendientes.");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Endpoint para la funcion deleteDuplicates de iets
|
|
|
|
|
+ */
|
|
|
|
|
+ @DeleteMapping("/delete/duplicates/{enquesta}")
|
|
|
|
|
+ public ResponseEntity<String> deleteDuplicates(@PathVariable("enquesta") String enquesta) {
|
|
|
|
|
+ Integer i = 0;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ //i = iets.deleteDuplicates(enquesta);
|
|
|
|
|
+ if(i == 0)
|
|
|
|
|
+ return ResponseEntity.badRequest().body("No se ha encontrado ninguna enquesta duplicada.");
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al eliminar las enquestas duplicadas: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok("Se han eliminado " + i + " enquestas duplicadas.");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Endpoint1 para la funcion getAllInds de ies
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/allInds1")
|
|
|
|
|
+ public ResponseEntity<String> getAllInds(@RequestBody String json) {
|
|
|
|
|
+ JsonNode jsonNode = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonNode = com.fasterxml.jackson.databind.json.JsonMapper.builder().build().readTree(json);
|
|
|
|
|
+
|
|
|
|
|
+ Organ organ = os.findByRuct(jsonNode.get("ruct").asInt());
|
|
|
|
|
+ Integer curs = jsonNode.get("curs").asInt();
|
|
|
|
|
+ List<IndicadorEnquesta> list = ies.getAllInds(organ, curs);
|
|
|
|
|
+
|
|
|
|
|
+ final ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+
|
|
|
|
|
+ String response = mapper.writeValueAsString(list);
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok(response);
|
|
|
|
|
+ } catch (JsonMappingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al mapear el JSON: " + e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al obtener los indicadores1: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Endpoint2 para la funcion getAllInds de ies
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/allInds2")
|
|
|
|
|
+ public ResponseEntity<String> getAllInds2(@RequestBody String json) {
|
|
|
|
|
+ JsonNode jsonNode = null;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonNode = com.fasterxml.jackson.databind.json.JsonMapper.builder().build().readTree(json);
|
|
|
|
|
+
|
|
|
|
|
+ Integer idTitulacio = jsonNode.get("idTitulacio").asInt();
|
|
|
|
|
+ Integer idCentre = jsonNode.get("idCentre").asInt();
|
|
|
|
|
+ Integer curs = jsonNode.get("curs").asInt();
|
|
|
|
|
+
|
|
|
|
|
+ List<IndicadorEnquestaValor> list = ies.getAllInds(idTitulacio, idCentre, curs);
|
|
|
|
|
+ final ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+ String response = mapper.writeValueAsString(list);
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok(response);
|
|
|
|
|
+ } catch (JsonMappingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al mapear el JSON: " + e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al obtener los indicadores2: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Endpoint para la funcion findByEnquestaCursAmbitEstudi de ies
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/findByEnquestaCursAmbitEstudi")
|
|
|
|
|
+ public ResponseEntity<String> findByEnquestaCursAmbitEstudi(@RequestBody String json) {
|
|
|
|
|
+ JsonNode jsonNode = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonNode = com.fasterxml.jackson.databind.json.JsonMapper.builder().build().readTree(json);
|
|
|
|
|
+ //Obtener los parametros
|
|
|
|
|
+ String enquesta = jsonNode.get("enquesta").asText();
|
|
|
|
|
+ Integer curs = jsonNode.get("curs").asInt();
|
|
|
|
|
+ String ambit = jsonNode.get("ambit").asText();
|
|
|
|
|
+ String estudi = jsonNode.get("estudi").asText();
|
|
|
|
|
+
|
|
|
|
|
+ List<IndicadorEnquesta> list = ies.findByEnquestaCursAmbitEstudi(enquesta, curs, ambit, estudi);
|
|
|
|
|
+
|
|
|
|
|
+ final ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+
|
|
|
|
|
+ String response = mapper.writeValueAsString(list);
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok(response);
|
|
|
|
|
+ } catch (JsonMappingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al mapear el JSON: " + e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al obtener los indicadores: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/findByEnquestaCursAmbitEstudiCentre")
|
|
|
|
|
+ public ResponseEntity<String> findByEnquestaCursAmbitEstudiCentre(@RequestBody String json) {
|
|
|
|
|
+ JsonNode jsonNode = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonNode = com.fasterxml.jackson.databind.json.JsonMapper.builder().build().readTree(json);
|
|
|
|
|
+ //Obtener los parametros
|
|
|
|
|
+ String enquesta = jsonNode.get("enquesta").asText();
|
|
|
|
|
+ Integer curs = jsonNode.get("curs").asInt();
|
|
|
|
|
+ String ambit = jsonNode.get("ambit").asText();
|
|
|
|
|
+ String estudi = jsonNode.get("estudi").asText();
|
|
|
|
|
+ Integer centre = jsonNode.get("centre").asInt();
|
|
|
|
|
+
|
|
|
|
|
+ List<IndicadorEnquesta> list = ies.findByEnquestaCursAmbitEstudiCentre(enquesta, curs, ambit, estudi, centre);
|
|
|
|
|
+
|
|
|
|
|
+ final ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+
|
|
|
|
|
+ String response = mapper.writeValueAsString(list);
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok(response);
|
|
|
|
|
+ } catch (JsonMappingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al mapear el JSON: " + e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al obtener los indicadores: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/findByEnquestaCursAmbitEstudiCentreTitulacio")
|
|
|
|
|
+ public ResponseEntity<String> findByEnquestaCursAmbitEstudiCentreTitulacio(@RequestBody String json) {
|
|
|
|
|
+ JsonNode jsonNode = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonNode = com.fasterxml.jackson.databind.json.JsonMapper.builder().build().readTree(json);
|
|
|
|
|
+
|
|
|
|
|
+ String enquesta = jsonNode.get("enquesta").asText();
|
|
|
|
|
+ Integer curs = jsonNode.get("curs").asInt();
|
|
|
|
|
+ String ambit = jsonNode.get("ambit").asText();
|
|
|
|
|
+ String estudi = jsonNode.get("estudi").asText();
|
|
|
|
|
+ Integer centre = jsonNode.get("centre").asInt();
|
|
|
|
|
+ Integer titulacio = jsonNode.get("titulacio").asInt();
|
|
|
|
|
+
|
|
|
|
|
+ List<IndicadorEnquesta> list = ies.findByEnquestaCursAmbitEstudiCentreTitulacio(enquesta, curs, ambit, estudi, centre, titulacio);
|
|
|
|
|
+
|
|
|
|
|
+ final ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+
|
|
|
|
|
+ String response = mapper.writeValueAsString(list);
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok(response);
|
|
|
|
|
+ } catch (JsonMappingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al mapear el JSON: " + e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al obtener los indicadores: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Endpoint para la funcion getFromTitulacion de ies
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/getFromTitulacio")
|
|
|
|
|
+ public ResponseEntity<String> getFromTitulacion(@RequestBody String json) {
|
|
|
|
|
+ JsonNode jsonNode = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonNode = com.fasterxml.jackson.databind.json.JsonMapper.builder().build().readTree(json);
|
|
|
|
|
+ //Obtener los parametros
|
|
|
|
|
+ Integer idTitulacio = jsonNode.get("idTitulacio").asInt();
|
|
|
|
|
+ Integer curs = jsonNode.get("curs").asInt();
|
|
|
|
|
+
|
|
|
|
|
+ List<Indicador> list = is.getFromTitulacion(idTitulacio, curs);
|
|
|
|
|
+
|
|
|
|
|
+ final ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
+
|
|
|
|
|
+ String response = mapper.writeValueAsString(list);
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseEntity.ok(response);
|
|
|
|
|
+ } catch (JsonMappingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al mapear el JSON: " + e.getMessage());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return ResponseEntity.badRequest().body("Error al obtener los indicadores: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|