|
|
@@ -1,6 +1,7 @@
|
|
|
package es.uv.saic.service;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigInteger;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -37,28 +38,25 @@ public class TemplateService {
|
|
|
|
|
|
private static final DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
|
- public String addTemplateData(InstanciaTascaDTO it, String template){
|
|
|
+ public String addTemplateData(Integer idTitulacio, Integer cursAvaluat, Integer idCentre, String opcionsStr, String tlugar, String lugar, BigInteger idInstanciaTasca, String nomVal, String nomvalTitulacio, String template){
|
|
|
HashMap<String, String> context = new HashMap<String, String>();
|
|
|
HashMap<String, String> header = new HashMap<String, String>();
|
|
|
HashMap<String, String> img = new HashMap<String, String>();
|
|
|
|
|
|
- Integer idTitulacio = it.getInstancia().getTitulacio();
|
|
|
- Integer cursAvaluat = it.getInstancia().getCursAvaluat();
|
|
|
- Integer idCentre = it.getInstancia().getCentre();
|
|
|
String ambit = "G";
|
|
|
- String opcionsStr = it.getTasca().getOpcions().replaceAll("^\\.$", "");
|
|
|
+ opcionsStr = opcionsStr.replaceAll("^\\.$", "");
|
|
|
String [] opcions = new String[0];
|
|
|
if(!opcionsStr.isEmpty()) {
|
|
|
opcions = opcionsStr.split(";");
|
|
|
}
|
|
|
- if(it.getInstancia().getTlugar().equals("C")) {
|
|
|
- if(it.getInstancia().getTitulacio() == 2) {
|
|
|
+ if(tlugar.equals("C")) {
|
|
|
+ if(idTitulacio == 2) {
|
|
|
ambit = "M";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** Add header information **/
|
|
|
- addHeaderData(it.getInstancia().getNomval(), it.getInstancia().getLugar(), it.getInstancia().getNomValTitulacio(), it.getInstancia().getCursAvaluat(), header, img);
|
|
|
+ addHeaderData(nomVal, Integer.parseInt(lugar), nomvalTitulacio, cursAvaluat, header, img);
|
|
|
|
|
|
/** Iterate elements inside {[loop]} ... {[endloop]} **/
|
|
|
template = this.iterateLoopTag(template, idCentre, ambit, cursAvaluat, context);
|
|
|
@@ -72,18 +70,18 @@ public class TemplateService {
|
|
|
this.replaceValues(doc, context, header, img);
|
|
|
|
|
|
/** Replace sections if specified in options **/
|
|
|
- this.replaceSection(opcions, it, doc);
|
|
|
+ this.replaceSection(opcions, tlugar, lugar, idCentre, idTitulacio, doc, idInstanciaTasca);
|
|
|
|
|
|
return doc.html();
|
|
|
}
|
|
|
|
|
|
- public Document replaceSection(String[] opcions, InstanciaTascaDTO it, Document doc) {
|
|
|
+ public Document replaceSection(String[] opcions, String tlugar, String lugar, Integer centre, Integer idTitulacio, Document doc, BigInteger idInstanciaTasca) {
|
|
|
if(opcions.length > 0) {
|
|
|
NomProcesOrganDTO nomProcesOrganDTO = new NomProcesOrganDTO(opcions[0],
|
|
|
- it.getInstancia().getTlugar(),
|
|
|
- it.getInstancia().getLugar(),
|
|
|
- it.getInstancia().getCentre(),
|
|
|
- it.getInstancia().getTitulacio());
|
|
|
+ tlugar,
|
|
|
+ (Integer) Integer.parseInt(lugar),
|
|
|
+ centre,
|
|
|
+ idTitulacio);
|
|
|
InstanciaTascaDTO itOld = tc.getReportFromNomProcesOrgan(nomProcesOrganDTO);
|
|
|
try {
|
|
|
Document doc2 = Jsoup.parse(itOld.getText());
|
|
|
@@ -106,7 +104,7 @@ public class TemplateService {
|
|
|
source.remove();
|
|
|
}
|
|
|
catch(NullPointerException e){
|
|
|
- System.out.println("No previous version found for "+it.getIdInstanciaTasca().toString());
|
|
|
+ System.out.println("No previous version found for "+idInstanciaTasca.toString());
|
|
|
}
|
|
|
|
|
|
}
|