|
|
@@ -58,6 +58,7 @@ import es.uv.saic.domain.Organ;
|
|
|
import es.uv.saic.domain.Usuari;
|
|
|
import es.uv.saic.domain.UsuarisRol;
|
|
|
import es.uv.saic.dto.AnyDimensioDTO;
|
|
|
+import es.uv.saic.dto.ArchiveOrganDTO;
|
|
|
import es.uv.saic.dto.CategoriaDTO;
|
|
|
import es.uv.saic.dto.CategoriaDocumentDTO;
|
|
|
import es.uv.saic.dto.DimensioInstanciesDTO;
|
|
|
@@ -71,7 +72,6 @@ import es.uv.saic.dto.TreeDTODimensio;
|
|
|
import es.uv.saic.dto.TreeDTOInstancia;
|
|
|
import es.uv.saic.dto.TreeDTOOrgan;
|
|
|
import es.uv.saic.service.CategoriaService;
|
|
|
-import es.uv.saic.service.DocumentService;
|
|
|
import es.uv.saic.service.GraficaService;
|
|
|
import es.uv.saic.service.IndicadorEnquestaService;
|
|
|
import es.uv.saic.service.IndicadorService;
|
|
|
@@ -95,8 +95,6 @@ public class DashboardController {
|
|
|
@Autowired
|
|
|
private CategoriaService cs;
|
|
|
@Autowired
|
|
|
- private DocumentService ds;
|
|
|
- @Autowired
|
|
|
private IndicadorService ids;
|
|
|
@Autowired
|
|
|
private IndicadorEnquestaService ies;
|
|
|
@@ -444,7 +442,7 @@ public class DashboardController {
|
|
|
Organ org = this.os.findByID(tlugar, lugar);
|
|
|
Document doc = findByCategoriaOrgan(idCategoria, lugar, tlugar);
|
|
|
if(doc != null) {
|
|
|
- this.ds.archive(doc);
|
|
|
+ this.archive(doc);
|
|
|
}
|
|
|
doc = new Document();
|
|
|
doc.setCategoria(cat);
|
|
|
@@ -462,9 +460,9 @@ public class DashboardController {
|
|
|
@PostMapping("/dashboard/documents/archive")
|
|
|
@ResponseBody
|
|
|
public void archiveDocuments(Model model, @RequestParam("lugar") Integer lugar, @RequestParam("tlugar") String tlugar) {
|
|
|
- this.ds.archiveByOrgan(lugar, tlugar);
|
|
|
+ this.archiveByOrgan(lugar, tlugar);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// GET para conseguir todos los graficos a partir de un RUCT
|
|
|
@GetMapping("/dashboard/graphs/list/{ruct}")
|
|
|
@ResponseBody
|
|
|
@@ -721,7 +719,7 @@ public class DashboardController {
|
|
|
return doc;
|
|
|
}
|
|
|
|
|
|
- private Document save(Document doc) {
|
|
|
+ private Document save(Document doc) {
|
|
|
URI uriobjUri = URI.create(uriDocs + "/document/save");
|
|
|
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
|
|
|
@@ -751,6 +749,65 @@ public class DashboardController {
|
|
|
return doc;
|
|
|
}
|
|
|
|
|
|
+ private Document archive(Document doc ){
|
|
|
+ Document archivedDoc = null;
|
|
|
+ URI uriArchive = URI.create(uriDocs + "/document/archive");
|
|
|
+ ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
+
|
|
|
+ try {
|
|
|
+ String requestBody = mapper.writeValueAsString(doc);
|
|
|
+
|
|
|
+ HttpClient httpClient = HttpClient.newHttpClient();
|
|
|
+ HttpRequest request = HttpRequest.newBuilder()
|
|
|
+ .uri(uriArchive)
|
|
|
+ .header("Content-Type", "application/json")
|
|
|
+ .POST(HttpRequest.BodyPublishers.ofString(requestBody))
|
|
|
+ .build();
|
|
|
+
|
|
|
+ HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
+
|
|
|
+ if (response.statusCode() == HttpURLConnection.HTTP_OK) {
|
|
|
+ archivedDoc = mapper.readValue(response.body(), new TypeReference<Document>() {});
|
|
|
+ } else {
|
|
|
+ System.err.println("Failed to archive Document. HTTP error code: " + response.statusCode());
|
|
|
+ System.err.println("Response body: " + response.body());
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("Error archiving Document: " + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return archivedDoc;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void archiveByOrgan(Integer lugar, String tlugar) {
|
|
|
+ URI uriArchive = URI.create(uriDocs + "/archiveByOrgan");
|
|
|
+ ArchiveOrganDTO organ = new ArchiveOrganDTO(lugar, tlugar);
|
|
|
+ ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
+
|
|
|
+ try {
|
|
|
+ String requestBody = mapper.writeValueAsString(organ);
|
|
|
+
|
|
|
+ HttpClient httpClient = HttpClient.newHttpClient();
|
|
|
+ HttpRequest request = HttpRequest.newBuilder()
|
|
|
+ .uri(uriArchive)
|
|
|
+ .header("Content-Type", "application/json")
|
|
|
+ .POST(HttpRequest.BodyPublishers.ofString(requestBody))
|
|
|
+ .build();
|
|
|
+
|
|
|
+ HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
+
|
|
|
+ if (response.statusCode() != HttpURLConnection.HTTP_OK) {
|
|
|
+ System.err.println("Failed to archive Document by org. HTTP error code: " + response.statusCode());
|
|
|
+ System.err.println("Response body: " + response.body());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("Error archiving Document: " + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private String upload(Integer idDocument, Integer idCategoria, Integer lugar, String tlugar, MultipartFile file) {
|
|
|
URI uriobjUri = URI.create(uriDocs + "/document/upload");
|
|
|
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|