Refactors DMP docx export by adding navigation pane and using Header styles from "template" document.
This commit is contained in:
parent
d9c338a6e0
commit
36ce246f0b
|
@ -188,18 +188,13 @@ public class DataManagementPlanManager {
|
|||
throw new UnauthorisedException();
|
||||
|
||||
// Space above DMP title.
|
||||
XWPFParagraph parAboveDmpTitle = document.createParagraph();
|
||||
/* XWPFParagraph parAboveDmpTitle = document.createParagraph();
|
||||
XWPFParagraph parAboveDmpTitle1 = document.createParagraph();
|
||||
XWPFParagraph parAboveDmpTitle2 = document.createParagraph();
|
||||
XWPFParagraph parAboveDmpTitle3 = document.createParagraph();
|
||||
XWPFParagraph parAboveDmpTitle3 = document.createParagraph();*/
|
||||
|
||||
// DMP title custom style.
|
||||
//wordBuilder.addParagraphContent(dmpEntity.getLabel(), document, ParagraphStyle.TITLE, BigInteger.ZERO);
|
||||
XWPFParagraph dmpLabelParagraph = document.createParagraph();
|
||||
XWPFRun run = dmpLabelParagraph.createRun();
|
||||
run.setText(dmpEntity.getLabel());
|
||||
run.setBold(true);
|
||||
run.setFontSize(20);
|
||||
wordBuilder.addParagraphContent(dmpEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
|
||||
// Space below DMP title.
|
||||
XWPFParagraph parBelowDmpTitle = document.createParagraph();
|
||||
|
@ -241,6 +236,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");
|
||||
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
||||
runDatasetTitle1.setText("Title: ");
|
||||
runDatasetTitle1.setBold(true);
|
||||
|
@ -252,6 +248,7 @@ public class DataManagementPlanManager {
|
|||
runDatasetTitle.setFontSize(12);
|
||||
|
||||
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
||||
datasetTemplateParagraph.setStyle("Heading2");
|
||||
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
|
||||
runDatasetTemplate1.setText("Template: ");
|
||||
runDatasetTemplate1.setBold(true);
|
||||
|
@ -263,7 +260,7 @@ public class DataManagementPlanManager {
|
|||
runDatasetTemplate.setFontSize(12);
|
||||
|
||||
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
|
||||
visibilityRuleService.setProperties(properties);
|
||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||
|
@ -463,7 +460,7 @@ public class DataManagementPlanManager {
|
|||
newDmp.setCreated(dmp.getCreated() == null ? new Date() : dmp.getCreated());
|
||||
if (newDmp.getUsers()!= null && newDmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
|
||||
.collect(Collectors.toList()).size() == 0) {
|
||||
List<UserDMP> userDMPList = newDmp.getUsers().stream().collect(Collectors.toList());
|
||||
List<UserDMP> userDMPList = new ArrayList<>(newDmp.getUsers());
|
||||
for (UserInfoListingModel userInfoListingModel : dataManagementPlan.getUsers()) {
|
||||
for (UserDMP userDMP : userDMPList) {
|
||||
if (!(userDMP.getUser().getId().equals(userInfoListingModel.getId()))) {
|
||||
|
@ -970,8 +967,8 @@ public class DataManagementPlanManager {
|
|||
} catch (IOException | JAXBException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
// TODO Iterate through the list of dataManagmentPlans.
|
||||
// Creates new dataManagmentPlan to fill it with the data model that was parsed from the xml.
|
||||
// TODO Iterate through the list of dataManagementPlans.
|
||||
// Creates new dataManagementPlan to fill it with the data model that was parsed from the xml.
|
||||
// Creates properties.
|
||||
DataManagementPlan dm = new DataManagementPlan();
|
||||
DataManagementPlanProfile dmpProfile = new DataManagementPlanProfile();
|
||||
|
|
|
@ -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);
|
||||
TEXT(0), HEADER1(1), HEADER2(2), HEADER3(3), HEADER4(4), TITLE(5), FOOTER(6), COMMENT(7), HEADER5(8);
|
||||
|
||||
private Integer value;
|
||||
|
||||
|
@ -34,6 +34,8 @@ public enum ParagraphStyle {
|
|||
return FOOTER;
|
||||
case 7:
|
||||
return COMMENT;
|
||||
case 8:
|
||||
return HEADER5;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported ParagraphStyle Code");
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.math.BigInteger;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/26/2018.
|
||||
|
@ -46,7 +47,7 @@ public class WordBuilder {
|
|||
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||
XWPFRun run = paragraph.createRun();
|
||||
if (item != null)
|
||||
run.setText(" " + item);
|
||||
run.setText(item);
|
||||
run.setFontSize(11);
|
||||
return paragraph;
|
||||
});
|
||||
|
@ -65,26 +66,41 @@ public class WordBuilder {
|
|||
paragraph.setStyle("Heading1");
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(item);
|
||||
run.setBold(true);
|
||||
run.setFontSize(12);
|
||||
// run.setBold(true);
|
||||
// run.setFontSize(12);
|
||||
// run.setStyle("0");
|
||||
return paragraph;
|
||||
});
|
||||
this.options.put(ParagraphStyle.HEADER2, (mainDocumentPart, item) -> {
|
||||
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||
paragraph.setStyle("Heading2");
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(" " + item);
|
||||
run.setBold(true);
|
||||
run.setFontSize(12);
|
||||
run.setText(item);
|
||||
// run.setBold(true);
|
||||
// run.setFontSize(12);
|
||||
return paragraph;
|
||||
});
|
||||
this.options.put(ParagraphStyle.HEADER3, (mainDocumentPart, item) -> {
|
||||
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||
paragraph.setStyle("Heading3");
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(" " + item);
|
||||
run.setBold(true);
|
||||
run.setFontSize(11);
|
||||
run.setText(item);
|
||||
// run.setBold(true);
|
||||
// run.setFontSize(11);
|
||||
return paragraph;
|
||||
});
|
||||
this.options.put(ParagraphStyle.HEADER4, (mainDocumentPart, item) -> {
|
||||
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||
paragraph.setStyle("Heading4");
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(item);
|
||||
return paragraph;
|
||||
});
|
||||
this.options.put(ParagraphStyle.HEADER5, (mainDocumentPart, item) -> {
|
||||
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||
paragraph.setStyle("Heading5");
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(item);
|
||||
return paragraph;
|
||||
});
|
||||
this.options.put(ParagraphStyle.FOOTER, (mainDocumentPart, item) -> {
|
||||
|
@ -96,7 +112,7 @@ public class WordBuilder {
|
|||
this.options.put(ParagraphStyle.COMMENT, (mainDocumentPart, item) -> {
|
||||
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(" " + item);
|
||||
run.setText(item);
|
||||
run.setItalic(true);
|
||||
return paragraph;
|
||||
});
|
||||
|
@ -114,7 +130,7 @@ public class WordBuilder {
|
|||
|
||||
public void createPages(List<DatasetProfilePage> datasetProfilePages, XWPFDocument mainDocumentPart, Boolean createListing, VisibilityRuleService visibilityRuleService) {
|
||||
datasetProfilePages.forEach(item -> {
|
||||
createSections(item.getSections(), mainDocumentPart, ParagraphStyle.HEADER1, 0, createListing, visibilityRuleService);
|
||||
createSections(item.getSections(), mainDocumentPart, ParagraphStyle.HEADER3, 0, createListing, visibilityRuleService);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -127,7 +143,7 @@ public class WordBuilder {
|
|||
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||
number.setVal(BigInteger.valueOf(indent));
|
||||
}
|
||||
createSections(section.getSections(), mainDocumentPart, ParagraphStyle.HEADER2, 1, createListing, visibilityRuleService);
|
||||
createSections(section.getSections(), mainDocumentPart, ParagraphStyle.HEADER4, 1, createListing, visibilityRuleService);
|
||||
createCompositeFields(section.getCompositeFields(), mainDocumentPart, 2, createListing, visibilityRuleService);
|
||||
}
|
||||
});
|
||||
|
@ -138,12 +154,12 @@ 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.HEADER3, numId);
|
||||
XWPFParagraph paragraph = addParagraphContent(compositeField.getNumbering() + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER5, numId);
|
||||
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||
number.setVal(BigInteger.valueOf(indent));
|
||||
}
|
||||
createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService);
|
||||
if (!compositeField.getMultiplicityItems().isEmpty()) {
|
||||
if (compositeField.getMultiplicityItems() != null && !compositeField.getMultiplicityItems().isEmpty()) {
|
||||
for (FieldSet multiplicityFieldset : compositeField.getMultiplicityItems()) {
|
||||
createFields(multiplicityFieldset.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService);
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue