Moves DMP information under element "Data Management information" on DMP docx export.
This commit is contained in:
parent
5cd8b391a7
commit
2a745ad334
|
@ -187,28 +187,26 @@ public class DataManagementPlanManager {
|
|||
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||
throw new UnauthorisedException();
|
||||
|
||||
// DMP info on top of the document.
|
||||
wordBuilder.addParagraphContent("Data Management Plan Information", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
// DMP title custom style.
|
||||
wordBuilder.addParagraphContent(dmpEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
|
||||
// Space below DMP title.
|
||||
XWPFParagraph parBelowDmpTitle = document.createParagraph();
|
||||
|
||||
wordBuilder.addParagraphContent(dmpEntity.getLabel(), document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
|
||||
wordBuilder.addParagraphContent("Funder", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Funder", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||
if (dmpEntity.getGrant().getFunder() != null)
|
||||
wordBuilder.addParagraphContent(dmpEntity.getGrant().getFunder().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
|
||||
wordBuilder.addParagraphContent("Grant", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Grant", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent(dmpEntity.getGrant().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
|
||||
wordBuilder.addParagraphContent("Organisations", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Organisations", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||
if (dmpEntity.getOrganisations().size() > 0) {
|
||||
wordBuilder.addParagraphContent(dmpEntity.getOrganisations().stream().map(Organisation::getLabel).collect(Collectors.joining(", "))
|
||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
}
|
||||
|
||||
wordBuilder.addParagraphContent("Researchers", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Researchers", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||
if (dmpEntity.getResearchers().size() > 0) {
|
||||
wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(Researcher::getLabel).collect(Collectors.joining(", "))
|
||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
|
@ -223,7 +221,9 @@ public class DataManagementPlanManager {
|
|||
XWPFParagraph parBreakDMP = document.createParagraph();
|
||||
parBreakDMP.setPageBreak(true);
|
||||
|
||||
wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.TITLE, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
// Space below Datasets.
|
||||
XWPFParagraph parBreakDatasets = document.createParagraph();
|
||||
dmpEntity.getDataset().stream()
|
||||
.filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue())
|
||||
.filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue())
|
||||
|
@ -237,7 +237,7 @@ public class DataManagementPlanManager {
|
|||
// Custom style for the Dataset title.
|
||||
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
XWPFParagraph datasetLabelParagraph = document.createParagraph();
|
||||
datasetLabelParagraph.setStyle("Heading1");
|
||||
datasetLabelParagraph.setStyle("Heading2");
|
||||
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
||||
runDatasetTitle1.setText("Title: ");
|
||||
runDatasetTitle1.setBold(true);
|
||||
|
@ -249,7 +249,7 @@ public class DataManagementPlanManager {
|
|||
runDatasetTitle.setFontSize(12);
|
||||
|
||||
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
||||
datasetTemplateParagraph.setStyle("Heading2");
|
||||
datasetTemplateParagraph.setStyle("Heading3");
|
||||
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
|
||||
runDatasetTemplate1.setText("Template: ");
|
||||
runDatasetTemplate1.setBold(true);
|
||||
|
@ -261,29 +261,29 @@ public class DataManagementPlanManager {
|
|||
runDatasetTemplate.setFontSize(12);
|
||||
|
||||
XWPFParagraph externalReferencesParagraph = document.createParagraph();
|
||||
externalReferencesParagraph.setStyle("Heading2");
|
||||
externalReferencesParagraph.setStyle("Heading3");
|
||||
XWPFRun externalReferencesRun = externalReferencesParagraph.createRun();
|
||||
externalReferencesRun.setText("External References");
|
||||
externalReferencesRun.setColor("2E75B6");
|
||||
externalReferencesRun.setBold(true);
|
||||
externalReferencesRun.setFontSize(12);
|
||||
|
||||
wordBuilder.addParagraphContent("Data Repositories", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Data Repositories", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
||||
if (datasetEntity.getDatasetDataRepositories().size() > 0) {
|
||||
wordBuilder.addParagraphContent(datasetEntity.getDatasetDataRepositories().stream().map(DatasetDataRepository::getDataRepository).map(DataRepository::getLabel).collect(Collectors.joining(", "))
|
||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
}
|
||||
wordBuilder.addParagraphContent("External Datasets", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("External Datasets", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
||||
if (datasetEntity.getDatasetExternalDatasets().size() > 0) {
|
||||
wordBuilder.addParagraphContent(datasetEntity.getDatasetExternalDatasets().stream().map(DatasetExternalDataset::getExternalDataset).map(ExternalDataset::getLabel).collect(Collectors.joining(", "))
|
||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
}
|
||||
wordBuilder.addParagraphContent("Registries", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Registries", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
||||
if (datasetEntity.getRegistries().size() > 0) {
|
||||
wordBuilder.addParagraphContent(datasetEntity.getRegistries().stream().map(Registry::getLabel).collect(Collectors.joining(", "))
|
||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
}
|
||||
wordBuilder.addParagraphContent("Services", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Services", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
||||
if (datasetEntity.getServices().size() > 0) {
|
||||
wordBuilder.addParagraphContent(datasetEntity.getServices().stream().map(DatasetService::getService).map(Service::getLabel).collect(Collectors.joining(", "))
|
||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
|
@ -296,7 +296,16 @@ public class DataManagementPlanManager {
|
|||
|
||||
|
||||
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||
|
||||
// Dataset Description custom style.
|
||||
XWPFParagraph datasetDescriptionParagraph = document.createParagraph();
|
||||
datasetDescriptionParagraph.setStyle("Heading3");
|
||||
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
|
||||
datasetDescriptionRun.setText("Dataset Description");
|
||||
datasetDescriptionRun.setColor("2E75B6");
|
||||
datasetDescriptionRun.setBold(true);
|
||||
datasetDescriptionRun.setFontSize(12);
|
||||
|
||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
|
||||
visibilityRuleService.setProperties(properties);
|
||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||
|
@ -310,7 +319,7 @@ public class DataManagementPlanManager {
|
|||
});
|
||||
|
||||
// Removes the top empty headings.
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
document.removeBodyElement(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ public class DatasetManager {
|
|||
File exportFile = new File(label + ".docx");
|
||||
|
||||
// Removes the top empty headings.
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
document.removeBodyElement(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package eu.eudat.logic.utilities.documents.types;
|
|||
* Created by ikalyvas on 2/26/2018.
|
||||
*/
|
||||
public enum ParagraphStyle {
|
||||
TEXT(0), HEADER1(1), HEADER2(2), HEADER3(3), HEADER4(4), TITLE(5), FOOTER(6), COMMENT(7), HEADER5(8);
|
||||
TEXT(0), HEADER1(1), HEADER2(2), HEADER3(3), HEADER4(4), TITLE(5), FOOTER(6), COMMENT(7), HEADER5(8), HEADER6(9);
|
||||
|
||||
private Integer value;
|
||||
|
||||
|
@ -36,6 +36,8 @@ public enum ParagraphStyle {
|
|||
return COMMENT;
|
||||
case 8:
|
||||
return HEADER5;
|
||||
case 9:
|
||||
return HEADER6;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported ParagraphStyle Code");
|
||||
}
|
||||
|
|
|
@ -100,6 +100,13 @@ public class WordBuilder {
|
|||
run.setText(" " + item);
|
||||
return paragraph;
|
||||
});
|
||||
this.options.put(ParagraphStyle.HEADER6, (mainDocumentPart, item) -> {
|
||||
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||
paragraph.setStyle("Heading6");
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(" " + item);
|
||||
return paragraph;
|
||||
});
|
||||
this.options.put(ParagraphStyle.FOOTER, (mainDocumentPart, item) -> {
|
||||
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||
XWPFRun run = paragraph.createRun();
|
||||
|
@ -127,7 +134,7 @@ public class WordBuilder {
|
|||
|
||||
public void createPages(List<DatasetProfilePage> datasetProfilePages, XWPFDocument mainDocumentPart, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
||||
datasetProfilePages.forEach(item -> {
|
||||
createSections(item.getSections(), mainDocumentPart, ParagraphStyle.HEADER3, 0, createListing, visibilityRuleService);
|
||||
createSections(item.getSections(), mainDocumentPart, ParagraphStyle.HEADER4, 0, createListing, visibilityRuleService);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -140,7 +147,7 @@ public class WordBuilder {
|
|||
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||
number.setVal(BigInteger.valueOf(indent));
|
||||
}
|
||||
createSections(section.getSections(), mainDocumentPart, ParagraphStyle.HEADER4, 1, createListing, visibilityRuleService);
|
||||
createSections(section.getSections(), mainDocumentPart, ParagraphStyle.HEADER5, 1, createListing, visibilityRuleService);
|
||||
createCompositeFields(section.getCompositeFields(), mainDocumentPart, 2, createListing, visibilityRuleService);
|
||||
}
|
||||
});
|
||||
|
@ -151,7 +158,7 @@ public class WordBuilder {
|
|||
compositeFields.forEach(compositeField -> {
|
||||
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
|
||||
if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) {
|
||||
XWPFParagraph paragraph = addParagraphContent(compositeField.getNumbering() + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER5, numId);
|
||||
XWPFParagraph paragraph = addParagraphContent(compositeField.getNumbering() + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER6, numId);
|
||||
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||
number.setVal(BigInteger.valueOf(indent));
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue