1. export redesign based on new word template
2. orcid researchers in export are clickable
This commit is contained in:
parent
941cca8103
commit
0ac5902bfd
|
@ -173,13 +173,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>4.0.0</version>
|
<version>4.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
<version>4.0.0</version>
|
<version>4.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
|
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
|
||||||
|
|
|
@ -1190,43 +1190,45 @@ 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();
|
||||||
|
|
||||||
// DMP info on top of the document.
|
wordBuilder.fillFirstPage(dmpEntity, document);
|
||||||
wordBuilder.addParagraphContent("Data Management Plan Information", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
|
||||||
// DMP title custom style.
|
|
||||||
wordBuilder.addParagraphContent(dmpEntity.getLabel(), document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
|
||||||
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO);
|
|
||||||
|
|
||||||
wordBuilder.addParagraphContent("Funder", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
// // DMP info on top of the document.
|
||||||
if (dmpEntity.getGrant().getFunder() != null)
|
// wordBuilder.addParagraphContent("Data Management Plan Information", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent(dmpEntity.getGrant().getFunder().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
// // DMP title custom style.
|
||||||
|
// wordBuilder.addParagraphContent(dmpEntity.getLabel(), document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent("Grant", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent(dmpEntity.getGrant().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
//
|
||||||
|
// wordBuilder.addParagraphContent("Funder", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent("Organisations", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
// if (dmpEntity.getGrant().getFunder() != null)
|
||||||
if (dmpEntity.getOrganisations().size() > 0) {
|
// wordBuilder.addParagraphContent(dmpEntity.getGrant().getFunder().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent(dmpEntity.getOrganisations().stream().map(Organisation::getLabel).collect(Collectors.joining(", "))
|
//
|
||||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent("Grant", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||||
}
|
// wordBuilder.addParagraphContent(dmpEntity.getGrant().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||||
|
//
|
||||||
wordBuilder.addParagraphContent("Researchers", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent("Organisations", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||||
if (dmpEntity.getResearchers().size() > 0) {
|
// if (dmpEntity.getOrganisations().size() > 0) {
|
||||||
wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(Researcher::getLabel).collect(Collectors.joining(", "))
|
// wordBuilder.addParagraphContent(dmpEntity.getOrganisations().stream().map(Organisation::getLabel).collect(Collectors.joining(", "))
|
||||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
// , document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/*wordBuilder.addParagraphContent("DMP Profile", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent("Researchers", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||||
if (dmpEntity.getProfile() != null){
|
// if (dmpEntity.getResearchers().size() > 0) {
|
||||||
wordBuilder.addParagraphContent(dmpEntity.getProfile().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(Researcher::getLabel).collect(Collectors.joining(", "))
|
||||||
}*/
|
// , document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||||
|
// }
|
||||||
// Page break at the end of the DMP title.
|
//
|
||||||
XWPFParagraph parBreakDMP = document.createParagraph();
|
// /*wordBuilder.addParagraphContent("DMP Profile", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||||
parBreakDMP.setPageBreak(true);
|
// if (dmpEntity.getProfile() != null){
|
||||||
|
// wordBuilder.addParagraphContent(dmpEntity.getProfile().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
// }*/
|
||||||
// Space below Datasets.
|
//
|
||||||
XWPFParagraph parBreakDatasets = document.createParagraph();
|
// // Page break at the end of the DMP title.
|
||||||
|
// XWPFParagraph parBreakDMP = document.createParagraph();
|
||||||
|
// parBreakDMP.setPageBreak(true);
|
||||||
|
//
|
||||||
|
// wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||||
|
// // Space below Datasets.
|
||||||
|
// XWPFParagraph parBreakDatasets = document.createParagraph();
|
||||||
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||||
final Boolean isPublic = dmpEntity.isPublic();
|
final Boolean isPublic = dmpEntity.isPublic();
|
||||||
dmpEntity.getDataset().stream()
|
dmpEntity.getDataset().stream()
|
||||||
|
@ -1251,73 +1253,79 @@ public class DataManagementPlanManager {
|
||||||
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||||
XWPFParagraph datasetLabelParagraph = document.createParagraph();
|
XWPFParagraph datasetLabelParagraph = document.createParagraph();
|
||||||
datasetLabelParagraph.setStyle("Heading2");
|
datasetLabelParagraph.setStyle("Heading2");
|
||||||
|
datasetLabelParagraph.setSpacingBetween(1.0);
|
||||||
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
|
||||||
runDatasetTitle1.setText("Title: ");
|
runDatasetTitle1.setText("Title: ");
|
||||||
runDatasetTitle1.setBold(true);
|
runDatasetTitle1.setColor("000000");
|
||||||
runDatasetTitle1.setFontSize(12);
|
//runDatasetTitle1.setBold(true);
|
||||||
|
//runDatasetTitle1.setFontSize(12);
|
||||||
XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
|
XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
|
||||||
runDatasetTitle.setText(datasetEntity.getLabel());
|
runDatasetTitle.setText(datasetEntity.getLabel());
|
||||||
runDatasetTitle.setColor("2E75B6");
|
//runDatasetTitle.setColor("2E75B6");
|
||||||
runDatasetTitle.setBold(true);
|
//runDatasetTitle.setBold(true);
|
||||||
runDatasetTitle.setFontSize(12);
|
//runDatasetTitle.setFontSize(12);
|
||||||
|
|
||||||
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
|
||||||
datasetTemplateParagraph.setStyle("Heading3");
|
datasetTemplateParagraph.setStyle("Heading3");
|
||||||
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
|
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
|
||||||
runDatasetTemplate1.setText("Template: ");
|
runDatasetTemplate1.setText("Template: ");
|
||||||
runDatasetTemplate1.setBold(true);
|
runDatasetTemplate1.setColor("000000");
|
||||||
runDatasetTemplate1.setFontSize(12);
|
//runDatasetTemplate1.setBold(true);
|
||||||
|
//runDatasetTemplate1.setFontSize(12);
|
||||||
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
|
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
|
||||||
runDatasetTemplate.setText(datasetEntity.getProfile().getLabel());
|
runDatasetTemplate.setText(datasetEntity.getProfile().getLabel());
|
||||||
runDatasetTemplate.setColor("2E75B6");
|
//runDatasetTemplate.setColor("2E75B6");
|
||||||
runDatasetTemplate.setBold(true);
|
//runDatasetTemplate.setBold(true);
|
||||||
runDatasetTemplate.setFontSize(12);
|
//runDatasetTemplate.setFontSize(12);
|
||||||
|
|
||||||
/*XWPFParagraph externalReferencesParagraph = document.createParagraph();
|
document.createParagraph();
|
||||||
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.HEADER4, BigInteger.ZERO);
|
// /*XWPFParagraph externalReferencesParagraph = document.createParagraph();
|
||||||
if (datasetEntity.getDatasetDataRepositories().size() > 0) {
|
// externalReferencesParagraph.setStyle("Heading3");
|
||||||
wordBuilder.addParagraphContent(datasetEntity.getDatasetDataRepositories().stream().map(DatasetDataRepository::getDataRepository).map(DataRepository::getLabel).collect(Collectors.joining(", "))
|
// XWPFRun externalReferencesRun = externalReferencesParagraph.createRun();
|
||||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
// externalReferencesRun.setText("External References");
|
||||||
}
|
// externalReferencesRun.setColor("2E75B6");
|
||||||
wordBuilder.addParagraphContent("External Datasets", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
// externalReferencesRun.setBold(true);
|
||||||
if (datasetEntity.getDatasetExternalDatasets().size() > 0) {
|
// externalReferencesRun.setFontSize(12);
|
||||||
wordBuilder.addParagraphContent(datasetEntity.getDatasetExternalDatasets().stream().map(DatasetExternalDataset::getExternalDataset).map(ExternalDataset::getLabel).collect(Collectors.joining(", "))
|
//
|
||||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent("Data Repositories", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
||||||
}
|
// if (datasetEntity.getDatasetDataRepositories().size() > 0) {
|
||||||
wordBuilder.addParagraphContent("Registries", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent(datasetEntity.getDatasetDataRepositories().stream().map(DatasetDataRepository::getDataRepository).map(DataRepository::getLabel).collect(Collectors.joining(", "))
|
||||||
if (datasetEntity.getRegistries().size() > 0) {
|
// , document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent(datasetEntity.getRegistries().stream().map(Registry::getLabel).collect(Collectors.joining(", "))
|
// }
|
||||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent("External Datasets", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
||||||
}
|
// if (datasetEntity.getDatasetExternalDatasets().size() > 0) {
|
||||||
wordBuilder.addParagraphContent("Services", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent(datasetEntity.getDatasetExternalDatasets().stream().map(DatasetExternalDataset::getExternalDataset).map(ExternalDataset::getLabel).collect(Collectors.joining(", "))
|
||||||
if (datasetEntity.getServices().size() > 0) {
|
// , document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent(datasetEntity.getServices().stream().map(DatasetService::getService).map(Service::getLabel).collect(Collectors.joining(", "))
|
// }
|
||||||
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent("Registries", document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
||||||
}
|
// if (datasetEntity.getRegistries().size() > 0) {
|
||||||
*//*wordBuilder.addParagraphContent("Tags", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent(datasetEntity.getRegistries().stream().map(Registry::getLabel).collect(Collectors.joining(", "))
|
||||||
if (datasetEntity.().size() > 0) {
|
// , document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||||
wordBuilder.addParagraphContent(datasetEntity.getServices().stream().map(DatasetService::getService).map(Service::getLabel).collect(Collectors.joining(", "))
|
// }
|
||||||
, document, ParagraphStyle.HEADER4, 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);
|
||||||
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO);
|
// }
|
||||||
|
// *//*wordBuilder.addParagraphContent("Tags", document, ParagraphStyle.HEADER3, BigInteger.ZERO);
|
||||||
|
// if (datasetEntity.().size() > 0) {
|
||||||
|
// wordBuilder.addParagraphContent(datasetEntity.getServices().stream().map(DatasetService::getService).map(Service::getLabel).collect(Collectors.joining(", "))
|
||||||
|
// , document, ParagraphStyle.HEADER4, BigInteger.ZERO);
|
||||||
|
// }*/
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO);
|
||||||
|
|
||||||
// Dataset Description custom style.
|
// Dataset Description custom style.
|
||||||
XWPFParagraph datasetDescriptionParagraph = document.createParagraph();
|
XWPFParagraph datasetDescriptionParagraph = document.createParagraph();
|
||||||
datasetDescriptionParagraph.setStyle("Heading3");
|
datasetDescriptionParagraph.setStyle("Heading3");
|
||||||
|
datasetDescriptionParagraph.setSpacingBetween(1.5);
|
||||||
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
|
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
|
||||||
datasetDescriptionRun.setText("Dataset Description");
|
datasetDescriptionRun.setText("Dataset Description");
|
||||||
datasetDescriptionRun.setColor("2E75B6");
|
//datasetDescriptionRun.setColor("2E75B6");
|
||||||
datasetDescriptionRun.setBold(true);
|
//datasetDescriptionRun.setBold(true);
|
||||||
datasetDescriptionRun.setFontSize(12);
|
datasetDescriptionRun.setFontSize(15);
|
||||||
|
|
||||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
|
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
|
||||||
visibilityRuleService.setProperties(properties);
|
visibilityRuleService.setProperties(properties);
|
||||||
|
@ -1329,12 +1337,15 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
// Page break at the end of the Dataset.
|
// Page break at the end of the Dataset.
|
||||||
XWPFParagraph parBreakDataset = document.createParagraph();
|
XWPFParagraph parBreakDataset = document.createParagraph();
|
||||||
|
parBreakDataset.setPageBreak(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Removes the top empty headings.
|
// // Removes the top empty headings.
|
||||||
for (int i = 0; i < 6; i++) {
|
// for (int i = 0; i < 6; i++) {
|
||||||
document.removeBodyElement(0);
|
// document.removeBodyElement(0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
wordBuilder.fillFooter(dmpEntity, document);
|
||||||
|
|
||||||
String fileName = "DMP_" + dmpEntity.getGrant().getLabel();
|
String fileName = "DMP_" + dmpEntity.getGrant().getLabel();
|
||||||
if (versioned) {
|
if (versioned) {
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package eu.eudat.logic.utilities.documents.word;
|
package eu.eudat.logic.utilities.documents.word;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.Organisation;
|
||||||
|
import eu.eudat.data.entities.Researcher;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
||||||
import eu.eudat.logic.utilities.interfaces.ApplierWithValue;
|
import eu.eudat.logic.utilities.interfaces.ApplierWithValue;
|
||||||
|
@ -31,6 +35,8 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -282,7 +288,7 @@ public class WordBuilder {
|
||||||
boolean hasMultiplicityItems = false;
|
boolean hasMultiplicityItems = false;
|
||||||
int paragraphPos = -1;
|
int paragraphPos = -1;
|
||||||
if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) {
|
if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) {
|
||||||
XWPFParagraph paragraph = addParagraphContent(page + "." + section + "." + (compositeField.getOrdinal() +1) + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER6, numId);
|
XWPFParagraph paragraph = addParagraphContent("\t" + page + "." + section + "." + (compositeField.getOrdinal() +1) + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER6, numId);
|
||||||
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||||
number.setVal(BigInteger.valueOf(indent));
|
number.setVal(BigInteger.valueOf(indent));
|
||||||
paragraphPos = mainDocumentPart.getPosOfParagraph(paragraph);
|
paragraphPos = mainDocumentPart.getPosOfParagraph(paragraph);
|
||||||
|
@ -361,6 +367,7 @@ public class WordBuilder {
|
||||||
} else if (field.getViewStyle().getRenderStyle().equals("combobox") && field.getData() instanceof AutoCompleteData) {
|
} else if (field.getViewStyle().getRenderStyle().equals("combobox") && field.getData() instanceof AutoCompleteData) {
|
||||||
format = getCommaSeparatedFormatsFromJson(format, "label");
|
format = getCommaSeparatedFormatsFromJson(format, "label");
|
||||||
}
|
}
|
||||||
|
boolean isResearcher = field.getViewStyle().getRenderStyle().equals("researchers");
|
||||||
if(format != null && !format.isEmpty()){
|
if(format != null && !format.isEmpty()){
|
||||||
Object hasMultiAutoComplete = mapper.convertValue(field.getData(), Map.class).get("multiAutoComplete");
|
Object hasMultiAutoComplete = mapper.convertValue(field.getData(), Map.class).get("multiAutoComplete");
|
||||||
boolean isMultiAutoComplete = hasMultiAutoComplete != null && (boolean)hasMultiAutoComplete;
|
boolean isMultiAutoComplete = hasMultiAutoComplete != null && (boolean)hasMultiAutoComplete;
|
||||||
|
@ -368,14 +375,36 @@ public class WordBuilder {
|
||||||
if(arrayStringFormat || isMultiAutoComplete){
|
if(arrayStringFormat || isMultiAutoComplete){
|
||||||
List<String> values = (arrayStringFormat) ? Arrays.asList(format.substring(1, format.length() - 1).split(",[ ]*")) : Arrays.asList(format.split(",[ ]*"));
|
List<String> values = (arrayStringFormat) ? Arrays.asList(format.substring(1, format.length() - 1).split(",[ ]*")) : Arrays.asList(format.split(",[ ]*"));
|
||||||
if(values.size() > 1) {
|
if(values.size() > 1) {
|
||||||
|
boolean orcidResearcher;
|
||||||
for (String val : values) {
|
for (String val : values) {
|
||||||
|
orcidResearcher = false;
|
||||||
|
String orcId = null;
|
||||||
|
if(isResearcher && val.contains("orcid:")){
|
||||||
|
orcId = val.substring(val.indexOf(':') + 1, val.indexOf(')'));
|
||||||
|
val = val.substring(0, val.indexOf(':') + 1);
|
||||||
|
orcidResearcher = true;
|
||||||
|
}
|
||||||
format = "• " + val;
|
format = "• " + val;
|
||||||
if(hasMultiplicityItems){
|
if(hasMultiplicityItems){
|
||||||
mainDocumentPart.getLastParagraph().createRun().setText(format);
|
mainDocumentPart.getLastParagraph().createRun().setText(format);
|
||||||
|
if(orcidResearcher){
|
||||||
|
XWPFHyperlinkRun run = mainDocumentPart.getLastParagraph().createHyperlinkRun("https://orcid.org/" + orcId);
|
||||||
|
run.setText(orcId);
|
||||||
|
run.setUnderline(UnderlinePatterns.SINGLE);
|
||||||
|
run.setColor("0000FF");
|
||||||
|
mainDocumentPart.getLastParagraph().createRun().setText(")");
|
||||||
|
}
|
||||||
hasMultiplicityItems = false;
|
hasMultiplicityItems = false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId);
|
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId);
|
||||||
|
if(orcidResearcher){
|
||||||
|
XWPFHyperlinkRun run = paragraph.createHyperlinkRun("https://orcid.org/" + orcId);
|
||||||
|
run.setText(orcId);
|
||||||
|
run.setUnderline(UnderlinePatterns.SINGLE);
|
||||||
|
run.setColor("0000FF");
|
||||||
|
paragraph.createRun().setText(")");
|
||||||
|
}
|
||||||
if (paragraph != null) {
|
if (paragraph != null) {
|
||||||
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
|
||||||
number.setVal(BigInteger.valueOf(indent));
|
number.setVal(BigInteger.valueOf(indent));
|
||||||
|
@ -390,7 +419,7 @@ public class WordBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(hasMultiplicityItems){
|
if(hasMultiplicityItems && format != null){
|
||||||
mainDocumentPart.getLastParagraph().createRun().setText(format);
|
mainDocumentPart.getLastParagraph().createRun().setText(format);
|
||||||
hasMultiplicityItems = false;
|
hasMultiplicityItems = false;
|
||||||
}
|
}
|
||||||
|
@ -600,4 +629,97 @@ public class WordBuilder {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fillFirstPage(DMP dmpEntity, XWPFDocument document) {
|
||||||
|
for(XWPFParagraph p: document.getParagraphs()){
|
||||||
|
List<XWPFRun> runs = p.getRuns();
|
||||||
|
if(runs != null){
|
||||||
|
for(XWPFRun r : runs){
|
||||||
|
String text = r.getText(0);
|
||||||
|
if(text != null){
|
||||||
|
if(text.contains("{ARGOS.DMP.VERSION}")){
|
||||||
|
text = text.replace("{ARGOS.DMP.VERSION}", "VERSION " + dmpEntity.getVersion());
|
||||||
|
r.setText(text, 0);
|
||||||
|
}
|
||||||
|
else if(text.contains("{ARGOS.DMP.FUNDER}")){
|
||||||
|
text = text.replace("{ARGOS.DMP.FUNDER}", dmpEntity.getGrant().getFunder().getLabel());
|
||||||
|
r.setText(text, 0);
|
||||||
|
}
|
||||||
|
else if(text.contains("{ARGOS.DMP.GRANT}")){
|
||||||
|
text = text.replace("{ARGOS.DMP.GRANT}", dmpEntity.getGrant().getLabel());
|
||||||
|
r.setText(text, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int researchers = dmpEntity.getResearchers().size();
|
||||||
|
int organizations = dmpEntity.getOrganisations().size();
|
||||||
|
if(researchers > 0 || organizations > 0){
|
||||||
|
XWPFTable tbl = document.getTables().get(0);
|
||||||
|
for(int i = (Integer.max(researchers, organizations) - 1); i > 0; i--)
|
||||||
|
tbl.createRow();
|
||||||
|
Iterator<XWPFTableRow> it = tbl.getRows().iterator();
|
||||||
|
it.next(); // skip first row
|
||||||
|
for(Researcher researcher : dmpEntity.getResearchers()){
|
||||||
|
if(it.hasNext()){
|
||||||
|
XWPFRun run = it.next().getCell(0).getParagraphs().get(0).createRun();
|
||||||
|
run.setText(researcher.getLabel());
|
||||||
|
run.setFontSize(17);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it = tbl.getRows().iterator();
|
||||||
|
it.next();
|
||||||
|
for(Organisation organisation : dmpEntity.getOrganisations()){
|
||||||
|
if(it.hasNext()){
|
||||||
|
XWPFParagraph p = it.next().getCell(1).getParagraphs().get(0);
|
||||||
|
XWPFRun run = p.createRun();
|
||||||
|
run.setText(organisation.getLabel());
|
||||||
|
run.setFontSize(17);
|
||||||
|
p.setAlignment(ParagraphAlignment.RIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillFooter(DMP dmpEntity, XWPFDocument document) {
|
||||||
|
document.getFooterList().forEach(xwpfFooter -> {
|
||||||
|
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
||||||
|
if(runs != null){
|
||||||
|
for(XWPFRun r : runs){
|
||||||
|
String text = r.getText(0);
|
||||||
|
if(text != null){
|
||||||
|
if(text.contains("{ARGOS.DMP.TITLE}")){
|
||||||
|
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
||||||
|
r.setText(text, 0);
|
||||||
|
}
|
||||||
|
if(text.contains("{ARGOS.DMP.LICENSE}")){
|
||||||
|
try{
|
||||||
|
Map<String, String> license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
||||||
|
text = text.replace("{ARGOS.DMP.LICENSE}", license.get("pid"));
|
||||||
|
}
|
||||||
|
catch (JsonProcessingException | NullPointerException e){
|
||||||
|
text = text.replace("{ARGOS.DMP.LICENSE}", "License: -");
|
||||||
|
}
|
||||||
|
r.setText(text, 0);
|
||||||
|
}
|
||||||
|
if(text.contains("{ARGOS.DMP.DOI}")){
|
||||||
|
String doi = dmpEntity.getDoi();
|
||||||
|
if(doi != null)
|
||||||
|
text = text.replace("{ARGOS.DMP.DOI}", doi);
|
||||||
|
else
|
||||||
|
text = text.replace("{ARGOS.DMP.DOI}", "-");
|
||||||
|
r.setText(text, 0);
|
||||||
|
}
|
||||||
|
if(text.contains("{ARGOS.DMP.LAST_MODIFIED}")){
|
||||||
|
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
|
text = text.replace("{ARGOS.DMP.LAST_MODIFIED}", formatter.format(dmpEntity.getModified()));
|
||||||
|
r.setText(text, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue