Skip to content

Commit

Permalink
Template: Move reused and produced dataset description bellow table f…
Browse files Browse the repository at this point in the history
…or HorizonEurope and ScienceEurope
  • Loading branch information
GeoffreyKarnbach authored and ValentinFutterer committed Sep 24, 2024
1 parent ab4f13e commit f9991d5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,11 @@ public void formattingParagraph(
.reverseOrder()); // reverse sort index to avoid missing index while deleting the
// run
for (Integer runIndex : removeRunIndex) {
xwpfParagraphs.get(xwpfParagraphs.indexOf(xwpfParagraph)).removeRun(runIndex);
try {
xwpfParagraphs.get(xwpfParagraphs.indexOf(xwpfParagraph)).removeRun(runIndex);
} catch (Exception e) {
log.error("Error while removing run: " + e.getMessage());
}
}
removeRunIndex.clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,32 @@ public void datasetsInformation() {
if (dmp.getTargetAudience() != null)
addReplacement(replacements, "[targetaudience]", dmp.getTargetAudience());
else addReplacement(replacements, "[targetaudience]", "");

StringBuilder reusedDescription = new StringBuilder();
List<Dataset> reusedDatasets = getReusedDatasets();
for (int i = 0; i < reusedDatasets.size(); i++) {
Dataset dataset = reusedDatasets.get(i);
if (dataset.getDescription() != null && !dataset.getDescription().isEmpty()) {
reusedDescription.append("Description for \"");
reusedDescription.append(dataset.getTitle()).append("\": ;");
reusedDescription.append(dataset.getDescription()).append(";");
}
}

addReplacement(replacements, "[reuseddatadescription]", reusedDescription.toString());

StringBuilder newDescription = new StringBuilder();
List<Dataset> newDatasets = getNewDatasets();
for (int i = 0; i < newDatasets.size(); i++) {
Dataset dataset = newDatasets.get(i);
if (dataset.getDescription() != null && !dataset.getDescription().isEmpty()) {
newDescription.append("Description for \"");
newDescription.append(dataset.getTitle()).append("\": ;");
newDescription.append(dataset.getDescription()).append(";");
}
}

addReplacement(replacements, "[produceddatadescription]", newDescription.toString());
}

/** storageIntroInformation */
Expand Down Expand Up @@ -930,8 +956,6 @@ public void composeTableNewDatasets(XWPFTable xwpfTable) {
docVar.add("no");
}

docVar.add(Optional.ofNullable(dataset.getDescription()).orElse(""));

insertTableCells(xwpfTable, newRow, docVar);
}
xwpfTable.removeRow(xwpfTable.getRows().size() - 1);
Expand Down Expand Up @@ -1017,8 +1041,6 @@ public void composeTableReusedDatasets(XWPFDocument document, XWPFTable xwpfTabl
docVar.add("no");
}

docVar.add(Optional.ofNullable(dataset.getDescription()).orElse(""));

insertTableCells(xwpfTable, newRow, docVar);
}
xwpfTable.removeRow(xwpfTable.getRows().size() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public XWPFDocument exportTemplate(long dmpId) {
loadTemplate(templateFileBrokerService.loadScienceEuropeTemplate(), startChar, endChar);
} catch (Exception e) {
log.error("Template file not found!");
log.error(e.getMessage());
return null;
}
xwpfParagraphs = document.getParagraphs();
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit f9991d5

Please sign in to comment.