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:
parent
13e62fd409
commit
0adc7044ab
|
@ -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)
|
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
|
||||||
wordBuilder.fillFirstPage(dmpEntity, null, document);
|
wordBuilder.fillFirstPage(dmpEntity, null, document, false);
|
||||||
|
|
||||||
// int powered_pos = document.getParagraphs().size() - 3;
|
// int powered_pos = document.getParagraphs().size() - 3;
|
||||||
int powered_pos = wordBuilder.findPosOfPoweredBy(document);
|
int powered_pos = wordBuilder.findPosOfPoweredBy(document);
|
||||||
|
|
|
@ -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)
|
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
|
||||||
wordBuilder.fillFirstPage(dmpEntity, datasetEntity, document);
|
wordBuilder.fillFirstPage(dmpEntity, datasetEntity, document, true);
|
||||||
wordBuilder.fillFooter(dmpEntity, datasetEntity, document, true);
|
wordBuilder.fillFooter(dmpEntity, datasetEntity, document, true);
|
||||||
|
|
||||||
int powered_pos = wordBuilder.findPosOfPoweredBy(document);
|
int powered_pos = wordBuilder.findPosOfPoweredBy(document);
|
||||||
|
|
|
@ -922,7 +922,7 @@ public class WordBuilder {
|
||||||
return -1;
|
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 parPos = 0;
|
||||||
int descrParPos = -1;
|
int descrParPos = -1;
|
||||||
XWPFParagraph descrPar = null;
|
XWPFParagraph descrPar = null;
|
||||||
|
@ -941,12 +941,14 @@ public class WordBuilder {
|
||||||
} else if(datasetEntity != null && text.contains("{ARGOS.DATASET.TITLE}")) {
|
} else if(datasetEntity != null && text.contains("{ARGOS.DATASET.TITLE}")) {
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
||||||
r.setText(text, 0);
|
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;
|
descrParPos = parPos;
|
||||||
descrPar = p;
|
descrPar = p;
|
||||||
if(dmpEntity != null) {
|
if(dmpEntity != null && !isDataset) {
|
||||||
text = text.replace("{ARGOS.DMP.DESCRIPTION}", "");
|
text = text.replace("{ARGOS.DMP.DESCRIPTION}", "");
|
||||||
} else {
|
} else if(datasetEntity != null && isDataset) {
|
||||||
text = text.replace("{ARGOS.DATASET.DESCRIPTION}", "");
|
text = text.replace("{ARGOS.DATASET.DESCRIPTION}", "");
|
||||||
}
|
}
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
|
@ -978,14 +980,15 @@ public class WordBuilder {
|
||||||
}
|
}
|
||||||
parPos++;
|
parPos++;
|
||||||
}
|
}
|
||||||
if(descrParPos != -1 && dmpEntity!=null && dmpEntity.getDescription() != null) {
|
|
||||||
|
if((descrParPos != -1) && (dmpEntity!=null) && (dmpEntity.getDescription() != null) && !isDataset) {
|
||||||
XmlCursor cursor = descrPar.getCTP().newCursor();
|
XmlCursor cursor = descrPar.getCTP().newCursor();
|
||||||
cursor.toNextSibling();
|
cursor.toNextSibling();
|
||||||
Document htmlDoc = Jsoup.parse(((String)dmpEntity.getDescription()).replaceAll("\n", "<br>"));
|
Document htmlDoc = Jsoup.parse(((String)dmpEntity.getDescription()).replaceAll("\n", "<br>"));
|
||||||
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
|
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
|
||||||
NodeTraversor.traverse(htmlToWorldBuilder, htmlDoc);
|
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();
|
XmlCursor cursor = descrPar.getCTP().newCursor();
|
||||||
cursor.toNextSibling();
|
cursor.toNextSibling();
|
||||||
Document htmlDoc = Jsoup.parse(((String)datasetEntity.getDescription()).replaceAll("\n", "<br>"));
|
Document htmlDoc = Jsoup.parse(((String)datasetEntity.getDescription()).replaceAll("\n", "<br>"));
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue