h2020.docx: [Bug fix] Updated image of Argos in h2020.docx DMP template | DataManagementPlanManager.java & DatasetManager.java: Added parameter "isDataset" in fillFirstPage() | WordBuilder.java: [Bug fix] Added parameter isDataset in fillFirstPage() and added some checks in description.

(cherry picked from commit c9b4b35e39)
This commit is contained in:
Konstantina Galouni 2023-04-05 11:13:26 +03:00 committed by Diamantis Tziotzios
parent 13e62fd409
commit 0adc7044ab
4 changed files with 11 additions and 8 deletions

View File

@ -1201,7 +1201,7 @@ public class DataManagementPlanManager {
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException();
wordBuilder.fillFirstPage(dmpEntity, null, document);
wordBuilder.fillFirstPage(dmpEntity, null, document, false);
// int powered_pos = document.getParagraphs().size() - 3;
int powered_pos = wordBuilder.findPosOfPoweredBy(document);

View File

@ -406,7 +406,7 @@ public class DatasetManager {
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException();
wordBuilder.fillFirstPage(dmpEntity, datasetEntity, document);
wordBuilder.fillFirstPage(dmpEntity, datasetEntity, document, true);
wordBuilder.fillFooter(dmpEntity, datasetEntity, document, true);
int powered_pos = wordBuilder.findPosOfPoweredBy(document);

View File

@ -922,7 +922,7 @@ public class WordBuilder {
return -1;
}
public void fillFirstPage(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document) {
public void fillFirstPage(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
int parPos = 0;
int descrParPos = -1;
XWPFParagraph descrPar = null;
@ -941,12 +941,14 @@ public class WordBuilder {
} else if(datasetEntity != null && text.contains("{ARGOS.DATASET.TITLE}")) {
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
r.setText(text, 0);
} else if((dmpEntity != null && text.contains("{ARGOS.DMP.DESCRIPTION}")) || (datasetEntity != null && text.contains("{ARGOS.DATASET.DESCRIPTION}"))) {
// } else if(text.equals("Description") && ((!isDataset && (dmpEntity == null || dmpEntity.getDescription() != null)) || (isDataset && (datasetEntity == null || datasetEntity.getDescription() == null)))) {
// r.setText("", 0);
} else if((dmpEntity != null && text.contains("{ARGOS.DMP.DESCRIPTION}") && !isDataset) || (datasetEntity != null && text.contains("{ARGOS.DATASET.DESCRIPTION}") && isDataset)) {
descrParPos = parPos;
descrPar = p;
if(dmpEntity != null) {
if(dmpEntity != null && !isDataset) {
text = text.replace("{ARGOS.DMP.DESCRIPTION}", "");
} else {
} else if(datasetEntity != null && isDataset) {
text = text.replace("{ARGOS.DATASET.DESCRIPTION}", "");
}
r.setText(text, 0);
@ -978,14 +980,15 @@ public class WordBuilder {
}
parPos++;
}
if(descrParPos != -1 && dmpEntity!=null && dmpEntity.getDescription() != null) {
if((descrParPos != -1) && (dmpEntity!=null) && (dmpEntity.getDescription() != null) && !isDataset) {
XmlCursor cursor = descrPar.getCTP().newCursor();
cursor.toNextSibling();
Document htmlDoc = Jsoup.parse(((String)dmpEntity.getDescription()).replaceAll("\n", "<br>"));
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
NodeTraversor.traverse(htmlToWorldBuilder, htmlDoc);
}
if(descrParPos != -1 && datasetEntity != null && datasetEntity.getDescription() != null) {
if((descrParPos != -1) && (datasetEntity != null) && (datasetEntity.getDescription() != null) && isDataset) {
XmlCursor cursor = descrPar.getCTP().newCursor();
cursor.toNextSibling();
Document htmlDoc = Jsoup.parse(((String)datasetEntity.getDescription()).replaceAll("\n", "<br>"));