diff --git a/dmp-backend/web/src/main/java/eu/eudat/document/DocxDocumentBuilderAdapter.java b/dmp-backend/web/src/main/java/eu/eudat/document/DocxDocumentBuilderAdapter.java deleted file mode 100644 index a302e05ba..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/document/DocxDocumentBuilderAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -package eu.eudat.document; - -import org.apache.poi.ooxml.POIXMLDocument; -import org.apache.poi.ooxml.POIXMLDocumentPart; -import org.apache.poi.openxml4j.exceptions.OpenXML4JException; -import org.apache.poi.openxml4j.opc.OPCPackage; -import org.apache.poi.openxml4j.opc.PackagePart; -import org.apache.poi.xwpf.usermodel.*; -import org.apache.xmlbeans.XmlCursor; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc; - -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -/** - * Created by ikalyvas on 10/17/2018. - */ -public class DocxDocumentBuilderAdapter extends XWPFDocument { - - public DocxDocumentBuilderAdapter(OPCPackage pkg) throws IOException { - super(pkg); - } - - public DocxDocumentBuilderAdapter(InputStream is) throws IOException { - super(is); - } - - public DocxDocumentBuilderAdapter() { - } - - @Override - public void createTOC() { - super.createTOC(); - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 20e2b3f35..54816ac81 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -10,7 +10,6 @@ import eu.eudat.data.dao.entities.*; import eu.eudat.data.entities.*; import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest; import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest; -import eu.eudat.document.DocxDocumentBuilderAdapter; import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException; import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.builders.entity.UserInfoBuilder; @@ -91,18 +90,18 @@ public class DataManagementPlanManager { DatasetWizardModel dataset = new DatasetWizardModel(); String fileUrl = environment.getProperty("configuration.h2020template"); InputStream is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream(); - DocxDocumentBuilderAdapter document = new DocxDocumentBuilderAdapter(is); + XWPFDocument document = new XWPFDocument(is); eu.eudat.data.entities.DMP dmpEntity = dmpRepository.find(UUID.fromString(id)); wordBuilder.addParagraphContent(dmpEntity.getLabel(), document, ParagraphStyle.TITLE, BigInteger.ZERO); wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.TEXT, BigInteger.ZERO); wordBuilder.addParagraphContent("Organisations", document, ParagraphStyle.HEADER2, BigInteger.ZERO); - wordBuilder.addParagraphContent(dmpEntity.getOrganisations().stream().map(x-> x.getLabel()).collect(Collectors.joining(",")) + wordBuilder.addParagraphContent(dmpEntity.getOrganisations().stream().map(x -> x.getLabel()).collect(Collectors.joining(",")) , document, ParagraphStyle.TEXT, BigInteger.ZERO); wordBuilder.addParagraphContent("Researchers", document, ParagraphStyle.HEADER2, BigInteger.ZERO); - wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(x-> x.getLabel()).collect(Collectors.joining(",")) + wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(x -> x.getLabel()).collect(Collectors.joining(",")) , document, ParagraphStyle.TEXT, BigInteger.ZERO); wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.TITLE, BigInteger.ZERO); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java index 72f521b02..d13920afc 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java @@ -91,6 +91,13 @@ public class WordBuilder { run.setText(item); return paragraph; }); + this.options.put(ParagraphStyle.COMMENT, (mainDocumentPart, item) -> { + XWPFParagraph paragraph = mainDocumentPart.createParagraph(); + XWPFRun run = paragraph.createRun(); + run.setText(item); + run.setItalic(true); + return paragraph; + }); } public XWPFDocument build(XWPFDocument document, PagedDatasetProfile pagedDatasetProfile, VisibilityRuleService visibilityRuleService) throws IOException { @@ -134,6 +141,11 @@ public class WordBuilder { number.setVal(BigInteger.valueOf(indent)); } createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService); + if (compositeField.getHasCommentField() && !createListing) { + XWPFParagraph paragraph = addParagraphContent("Comment: " + compositeField.getCommentFieldValue(), mainDocumentPart, ParagraphStyle.COMMENT, numId); + CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); + number.setVal(BigInteger.valueOf(indent)); + } } }); } @@ -213,6 +225,7 @@ public class WordBuilder { return field.getValue(); case "checkBox": CheckBoxData data = (CheckBoxData) field.getData(); + if (field.getValue() == null || field.getValue().equals("false")) return null; return data.getLabel(); case "freetext": return field.getValue();