|
|
@@ -24,25 +24,23 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
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.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import com.netflix.discovery.converters.Auto;
|
|
|
-
|
|
|
-import es.uv.saic.domain.Document;
|
|
|
-import es.uv.saic.domain.Indicador;
|
|
|
-import es.uv.saic.dto.IndicadorEnquestaDTO;
|
|
|
-import es.uv.saic.dto.IndicadorEnquestaValorDTOImp;
|
|
|
-import es.uv.saic.dto.InstanciaTascaDTO;
|
|
|
-import es.uv.saic.dto.OrganDTO;
|
|
|
-import es.uv.saic.dto.PdfDTO;
|
|
|
-import es.uv.saic.dto.ProcesDTO;
|
|
|
-import es.uv.saic.dto.TascaDTO;
|
|
|
-import es.uv.saic.dto.TascaInformeTransferDTO;
|
|
|
-import es.uv.saic.feign.CoreClient;
|
|
|
-import es.uv.saic.feign.IndicadorClient;
|
|
|
import es.uv.saic.service.DocumentService;
|
|
|
import es.uv.saic.service.PlantillaService;
|
|
|
+import es.uv.saic.shared.domain.Document;
|
|
|
+import es.uv.saic.shared.dto.InstanciaTascaDTO;
|
|
|
+import es.uv.saic.shared.dto.OrganDTO;
|
|
|
+import es.uv.saic.shared.dto.PdfDTO;
|
|
|
+import es.uv.saic.shared.dto.ProcesDTO;
|
|
|
+import es.uv.saic.shared.dto.TascaDTO;
|
|
|
+import es.uv.saic.shared.dto.TascaInformeTransferDTO;
|
|
|
+import es.uv.saic.shared.feign.IndicadorClient;
|
|
|
+import es.uv.saic.shared.feign.OrganClient;
|
|
|
+import es.uv.saic.shared.feign.ProceduresClient;
|
|
|
+import es.uv.saic.shared.feign.TascaClient;
|
|
|
import fr.opensagres.xdocreport.core.XDocReportException;
|
|
|
import fr.opensagres.xdocreport.core.io.internal.ByteArrayOutputStream;
|
|
|
import fr.opensagres.xdocreport.document.IXDocReport;
|
|
|
@@ -80,11 +78,17 @@ public class DownloadController {
|
|
|
private String logoPath;
|
|
|
|
|
|
@Autowired
|
|
|
- private CoreClient core;
|
|
|
+ private TascaClient tc;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrganClient oc;
|
|
|
|
|
|
@Autowired
|
|
|
private IndicadorClient ic;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProceduresClient pc;
|
|
|
+
|
|
|
/*
|
|
|
* Download a file associated with a task instance
|
|
|
* @param model
|
|
|
@@ -93,11 +97,11 @@ public class DownloadController {
|
|
|
* @return A FileSystemResource
|
|
|
* representing the file to download
|
|
|
*/
|
|
|
- @GetMapping(value="/downloads/{fileName}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+ @GetMapping(value="/download/{fileName}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
public ResponseEntity<byte[]> download(@PathVariable("fileName") BigInteger idInstanciaTasca, HttpServletResponse response) throws FileNotFoundException {
|
|
|
|
|
|
try {
|
|
|
- InstanciaTascaDTO i = core.findInstanciaTascaById(idInstanciaTasca);
|
|
|
+ InstanciaTascaDTO i = tc.findInstanciaTascaById(idInstanciaTasca);
|
|
|
FileSystemResource file = null;
|
|
|
if(i.getTasca().getIdTipus() == 22){
|
|
|
file = new FileSystemResource(i.getEvidencia());
|
|
|
@@ -130,9 +134,9 @@ public class DownloadController {
|
|
|
* @param response HttpServletResponse
|
|
|
* @return A FileSystemResource representing the document to download
|
|
|
*/
|
|
|
- @GetMapping(value="/downloads/document/{id}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+ @GetMapping(value="/download/document/{id}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
@ResponseBody
|
|
|
- public ResponseEntity<byte[]> downloadDocument(@PathVariable("id") Integer idDocument, HttpServletResponse response) throws FileNotFoundException {
|
|
|
+ public ResponseEntity<byte[]> downloadDocument(@PathVariable("id") Integer idDocument, HttpServletResponse response) {
|
|
|
Document document = ds.findById(idDocument);
|
|
|
FileSystemResource file = new FileSystemResource(document.getRuta());
|
|
|
if(!file.exists()) {
|
|
|
@@ -156,17 +160,17 @@ public class DownloadController {
|
|
|
* @param response HttpServletResponse
|
|
|
* @return A FileSystemResource representing the report to download
|
|
|
*/
|
|
|
- @GetMapping(value="/downloads/report/{t}/{p}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+ @GetMapping(value="/download/report/{t}/{p}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
@ResponseBody
|
|
|
public ResponseEntity<byte[]> downloadReport(@PathVariable("t") Integer idTitulacio, @PathVariable("p") String nomProces,
|
|
|
HttpServletResponse response) throws IOException, XDocReportException {
|
|
|
|
|
|
- OrganDTO titulacio = core.findOrganById("T", idTitulacio);
|
|
|
+ OrganDTO titulacio = oc.findByID("T", idTitulacio);
|
|
|
|
|
|
ProcesDTO procesDTO = new ProcesDTO(nomProces, titulacio.getLugar(),
|
|
|
titulacio.getLugar2(),
|
|
|
titulacio.getTambit());
|
|
|
- TascaInformeTransferDTO it = core.getLastByProcName(procesDTO);
|
|
|
+ TascaInformeTransferDTO it = tc.getLastByProcName(procesDTO);
|
|
|
|
|
|
if(it != null) {
|
|
|
if((new File(this.filePath+it.getEvidencia())).exists()) {
|
|
|
@@ -186,12 +190,12 @@ public class DownloadController {
|
|
|
* @param response HttpServletResponse
|
|
|
* @return A byte array representing the populated template to download
|
|
|
*/
|
|
|
- @GetMapping(value="/downloads/template/{id}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+ @GetMapping(value="/download/template/{id}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
@ResponseBody
|
|
|
public ResponseEntity<byte[]> downloadTemplate(@PathVariable("id") BigInteger idTascai, HttpServletResponse response) throws IOException, XDocReportException {
|
|
|
XDocReportRegistry.getRegistry().clear();
|
|
|
String reportId = "none";
|
|
|
- InstanciaTascaDTO it = core.findInstanciaTascaById(idTascai);
|
|
|
+ InstanciaTascaDTO it = tc.findInstanciaTascaById(idTascai);
|
|
|
TascaDTO tasca = it.getTasca();
|
|
|
|
|
|
/* Check if specific template exists */
|
|
|
@@ -239,7 +243,7 @@ public class DownloadController {
|
|
|
if(tasca.getIdTipus() == 14) { // Iterable template task
|
|
|
List<OrganDTO> titulacions = new ArrayList<OrganDTO>();
|
|
|
Integer ambit = idTitulacio/(int)1000;
|
|
|
- titulacions = core.getTitulacionsByTypeCentre(it.getInstancia().getLugar(), ambit);
|
|
|
+ titulacions = oc.getTitulacionsByTypeCentre(it.getInstancia().getLugar(), ambit);
|
|
|
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
|
|
|
for(OrganDTO x : titulacions) {
|
|
|
HashMap<String, String> t = ic.getTemplateDataArray(x.getLugar2(), idCentre, it.getInstancia().getCursAvaluat());
|
|
|
@@ -279,10 +283,10 @@ public class DownloadController {
|
|
|
XDocReportRegistry.getRegistry().clear();
|
|
|
String reportId = "none";
|
|
|
|
|
|
- TascaDTO tasca = core.getByProcesTascap(idProces, idTascap);
|
|
|
- ProcesDTO proces = core.findProcesdById(idProces);
|
|
|
- OrganDTO titulacio = core.findOrganById("T", idTitulacio);
|
|
|
- OrganDTO centre = core.findOrganById("C", idCentre);
|
|
|
+ TascaDTO tasca = tc.getByProcesTascap(idProces, idTascap);
|
|
|
+ ProcesDTO proces = pc.findById(idProces);
|
|
|
+ OrganDTO titulacio = oc.findByID("T", idTitulacio);
|
|
|
+ OrganDTO centre = oc.findByID("C", idCentre);
|
|
|
Integer ambit = idTitulacio/(int)1000;
|
|
|
|
|
|
/* Check if specific template exists */
|
|
|
@@ -321,7 +325,7 @@ public class DownloadController {
|
|
|
|
|
|
if(tasca.getIdTipus() == 14) { // Iterable template task
|
|
|
List<OrganDTO> titulacions = new ArrayList<OrganDTO>();
|
|
|
- titulacions = core.getTitulacionsByTypeCentre(centre.getLugar2(), ambit);
|
|
|
+ titulacions = oc.getTitulacionsByTypeCentre(centre.getLugar2(), ambit);
|
|
|
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
|
|
|
for(OrganDTO x : titulacions) {
|
|
|
HashMap<String, String> t = ic.getTemplateDataArray(x.getLugar2(), idCentre, proces.getCursAvaluat());
|
|
|
@@ -361,8 +365,8 @@ public class DownloadController {
|
|
|
XDocReportRegistry.getRegistry().clear();
|
|
|
String reportId = "none";
|
|
|
|
|
|
- OrganDTO titulacio = core.findOrganById("T", idTitulacio);
|
|
|
- OrganDTO centre = core.findOrganById("C", idCentre);
|
|
|
+ OrganDTO titulacio = oc.findByID("T", idTitulacio);
|
|
|
+ OrganDTO centre = oc.findByID("C", idCentre);
|
|
|
Integer ambit = idTitulacio/(int)1000;
|
|
|
|
|
|
/* Check if specific template exists */
|
|
|
@@ -403,7 +407,7 @@ public class DownloadController {
|
|
|
|
|
|
if(tipusTasca == 14) { // Iterable template task
|
|
|
List<OrganDTO> titulacions = new ArrayList<OrganDTO>();
|
|
|
- titulacions = core.getTitulacionsByTypeCentre(centre.getLugar2(), ambit);
|
|
|
+ titulacions = oc.getTitulacionsByTypeCentre(centre.getLugar2(), ambit);
|
|
|
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
|
|
|
for(OrganDTO x : titulacions) {
|
|
|
HashMap<String, String> t = ic.getTemplateDataArray(x.getLugar2(), idCentre, curs);
|
|
|
@@ -436,7 +440,7 @@ public class DownloadController {
|
|
|
@GetMapping(value="/pdf/{idTascai}")
|
|
|
@ResponseBody
|
|
|
public byte[] downloadTemplatePdf(@PathVariable("idTascai") BigInteger idTascai, HttpServletResponse response) throws IOException, InterruptedException {
|
|
|
- InstanciaTascaDTO it = core.findInstanciaTascaById(idTascai);
|
|
|
+ InstanciaTascaDTO it = tc.findInstanciaTascaById(idTascai);
|
|
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\""+it.getIdInstanciaTasca()+".pdf\"");
|
|
|
response.setHeader(HttpHeaders.CONTENT_TYPE, "application/pdf");
|
|
|
return pls.toPDF(it.getText(), Optional.of(idTascai));
|