Merge remote-tracking branch 'origin/Development' into roadmap

This commit is contained in:
Konstantinos Triantafyllou 2022-06-15 15:08:15 +03:00
commit 1a53d06fda
10 changed files with 374 additions and 162 deletions

View File

@ -174,13 +174,13 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.0</version>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
<version>4.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->

View File

@ -4,11 +4,14 @@ import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
import org.apache.http.nio.reactor.IOReactorException;
import org.apache.http.nio.reactor.IOReactorExceptionHandler;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.slf4j.Logger;
@ -18,7 +21,17 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
/**
* Created by ikalyvas on 7/5/2018.
@ -56,12 +69,41 @@ public class ElasticSearchConfiguration {
}
});
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost(this.environment.getProperty("elasticsearch.host"),
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "http"))
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
.setDefaultCredentialsProvider(credentialsProvider).setConnectionManager(new PoolingNHttpClientConnectionManager(ioReactor))));
RestHighLevelClient client;
if(this.environment.getProperty("elasticsearch.usingssl", Boolean.class)){
Path caCertificatePath = Paths.get(this.environment.getProperty("elasticsearch.certPath"));
CertificateFactory factory =
CertificateFactory.getInstance("X.509");
Certificate trustedCa;
try (InputStream is = Files.newInputStream(caCertificatePath)) {
trustedCa = factory.generateCertificate(is);
}
KeyStore trustStore = KeyStore.getInstance("pkcs12");
trustStore.load(null, null);
trustStore.setCertificateEntry("ca", trustedCa);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(trustStore);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, tmf.getTrustManagers(), null);
client = new RestHighLevelClient(
RestClient.builder(
new HttpHost(this.environment.getProperty("elasticsearch.host"),
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "https"))
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
.setDefaultCredentialsProvider(credentialsProvider).setSSLContext(sslContext)));
}
else {
client = new RestHighLevelClient(
RestClient.builder(
new HttpHost(this.environment.getProperty("elasticsearch.host"),
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "http"))
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
.setDefaultCredentialsProvider(credentialsProvider).setConnectionManager(new PoolingNHttpClientConnectionManager(ioReactor))));
}
return client;
}catch (IOReactorException ex) {
throw new RuntimeException(ex);

View File

@ -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)
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.HEADER2, BigInteger.ZERO);
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO);
wordBuilder.fillFirstPage(dmpEntity, document);
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.HEADER3, BigInteger.ZERO);
wordBuilder.addParagraphContent(dmpEntity.getGrant().getLabel(), document, ParagraphStyle.TEXT, 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.HEADER3, BigInteger.ZERO);
if (dmpEntity.getResearchers().size() > 0) {
wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(Researcher::getLabel).collect(Collectors.joining(", "))
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
}
/*wordBuilder.addParagraphContent("DMP Profile", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
if (dmpEntity.getProfile() != null){
wordBuilder.addParagraphContent(dmpEntity.getProfile().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
}*/
// 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();
// // 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.HEADER2, BigInteger.ZERO);
// wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.HTML, 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.HEADER3, BigInteger.ZERO);
// wordBuilder.addParagraphContent(dmpEntity.getGrant().getLabel(), document, ParagraphStyle.TEXT, 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.HEADER3, BigInteger.ZERO);
// if (dmpEntity.getResearchers().size() > 0) {
// wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(Researcher::getLabel).collect(Collectors.joining(", "))
// , document, ParagraphStyle.TEXT, BigInteger.ZERO);
// }
//
// /*wordBuilder.addParagraphContent("DMP Profile", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
// if (dmpEntity.getProfile() != null){
// wordBuilder.addParagraphContent(dmpEntity.getProfile().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
// }*/
//
// // 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 isPublic = dmpEntity.isPublic();
dmpEntity.getDataset().stream()
@ -1251,73 +1253,79 @@ public class DataManagementPlanManager {
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
XWPFParagraph datasetLabelParagraph = document.createParagraph();
datasetLabelParagraph.setStyle("Heading2");
datasetLabelParagraph.setSpacingBetween(1.0);
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
runDatasetTitle1.setText("Title: ");
runDatasetTitle1.setBold(true);
runDatasetTitle1.setFontSize(12);
runDatasetTitle1.setColor("000000");
//runDatasetTitle1.setBold(true);
//runDatasetTitle1.setFontSize(12);
XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
runDatasetTitle.setText(datasetEntity.getLabel());
runDatasetTitle.setColor("2E75B6");
runDatasetTitle.setBold(true);
runDatasetTitle.setFontSize(12);
//runDatasetTitle.setColor("2E75B6");
//runDatasetTitle.setBold(true);
//runDatasetTitle.setFontSize(12);
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
datasetTemplateParagraph.setStyle("Heading3");
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
runDatasetTemplate1.setText("Template: ");
runDatasetTemplate1.setBold(true);
runDatasetTemplate1.setFontSize(12);
runDatasetTemplate1.setColor("000000");
//runDatasetTemplate1.setBold(true);
//runDatasetTemplate1.setFontSize(12);
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
runDatasetTemplate.setText(datasetEntity.getProfile().getLabel());
runDatasetTemplate.setColor("2E75B6");
runDatasetTemplate.setBold(true);
runDatasetTemplate.setFontSize(12);
//runDatasetTemplate.setColor("2E75B6");
//runDatasetTemplate.setBold(true);
//runDatasetTemplate.setFontSize(12);
/*XWPFParagraph externalReferencesParagraph = document.createParagraph();
externalReferencesParagraph.setStyle("Heading3");
XWPFRun externalReferencesRun = externalReferencesParagraph.createRun();
externalReferencesRun.setText("External References");
externalReferencesRun.setColor("2E75B6");
externalReferencesRun.setBold(true);
externalReferencesRun.setFontSize(12);
document.createParagraph();
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.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.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.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("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);
// /*XWPFParagraph externalReferencesParagraph = 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);
// 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.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.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.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("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.
XWPFParagraph datasetDescriptionParagraph = document.createParagraph();
datasetDescriptionParagraph.setStyle("Heading3");
datasetDescriptionParagraph.setSpacingBetween(1.5);
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
datasetDescriptionRun.setText("Dataset Description");
datasetDescriptionRun.setColor("2E75B6");
datasetDescriptionRun.setBold(true);
datasetDescriptionRun.setFontSize(12);
//datasetDescriptionRun.setColor("2E75B6");
//datasetDescriptionRun.setBold(true);
datasetDescriptionRun.setFontSize(15);
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
visibilityRuleService.setProperties(properties);
@ -1329,12 +1337,15 @@ public class DataManagementPlanManager {
}
// Page break at the end of the Dataset.
XWPFParagraph parBreakDataset = document.createParagraph();
parBreakDataset.setPageBreak(true);
});
// Removes the top empty headings.
for (int i = 0; i < 6; i++) {
document.removeBodyElement(0);
}
// // Removes the top empty headings.
// for (int i = 0; i < 6; i++) {
// document.removeBodyElement(0);
// }
wordBuilder.fillFooter(dmpEntity, document);
String fileName = "DMP_" + dmpEntity.getGrant().getLabel();
if (versioned) {

View File

@ -167,7 +167,16 @@ public class PrefillingMapper {
List<LicenseModel> licenses = licenseManager.getLicenses("", "");
String finalParsedValue = parsedValue;
licenses = licenses.stream().filter(license -> license.getPid().equals(finalParsedValue)).collect(Collectors.toList());
properties.put(id, licenses);
boolean isMultiAutocomplete = node.isArray() ? node.get(0).get("data").get("multiAutoComplete").booleanValue() : node.get("data").get("multiAutoComplete").booleanValue();
if(isMultiAutocomplete){
List<String> lic = new ArrayList<>();
for(LicenseModel license: licenses){
lic.add(mapper.writeValueAsString(license));
}
properties.put(id, mapper.writeValueAsString(lic));
} else {
properties.put(id, mapper.writeValueAsString(licenses.get(0)));
}
}
catch (NoURLFound | HugeResultSet e){
properties.put(id, parsedValue);

View File

@ -1,7 +1,11 @@
package eu.eudat.logic.utilities.documents.word;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
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.utilities.documents.types.ParagraphStyle;
import eu.eudat.logic.utilities.interfaces.ApplierWithValue;
@ -31,6 +35,8 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
@ -76,7 +82,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;
});
@ -109,7 +115,7 @@ public class WordBuilder {
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
paragraph.setStyle("Heading2");
XWPFRun run = paragraph.createRun();
run.setText(" " + item);
run.setText("" + item);
// run.setBold(true);
// run.setFontSize(12);
return paragraph;
@ -118,7 +124,7 @@ public class WordBuilder {
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
paragraph.setStyle("Heading3");
XWPFRun run = paragraph.createRun();
run.setText(" " + item);
run.setText("" + item);
// run.setBold(true);
// run.setFontSize(11);
return paragraph;
@ -134,14 +140,14 @@ public class WordBuilder {
XWPFParagraph paragraph = mainDocumentPart.createParagraph();
paragraph.setStyle("Heading5");
XWPFRun run = paragraph.createRun();
run.setText(" " + item);
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);
run.setText("" + item);
return paragraph;
});
this.options.put(ParagraphStyle.FOOTER, (mainDocumentPart, item) -> {
@ -153,7 +159,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;
});
@ -279,17 +285,19 @@ public class WordBuilder {
for (FieldSet compositeField: compositeFields) {
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
char c = 'a';
boolean hasMultiplicityItems = false;
int paragraphPos = -1;
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();
number.setVal(BigInteger.valueOf(indent));
paragraphPos = mainDocumentPart.getPosOfParagraph(paragraph);
if(compositeField.getMultiplicityItems() != null && !compositeField.getMultiplicityItems().isEmpty()){
addParagraphContent(c + ".\n", mainDocumentPart, ParagraphStyle.HEADER6, numId);
addParagraphContent(c + ". ", mainDocumentPart, ParagraphStyle.HEADER6, numId);
hasMultiplicityItems = true;
}
}
hasValue = createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService);
hasValue = createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService, hasMultiplicityItems);
if(hasValue){
returnedValue = true;
}
@ -298,16 +306,17 @@ public class WordBuilder {
for (FieldSet multiplicityFieldset : list) {
if(!createListing){
c++;
addParagraphContent(c + ".\n", mainDocumentPart, ParagraphStyle.HEADER6, numId);
addParagraphContent(c + ". ", mainDocumentPart, ParagraphStyle.HEADER6, numId);
hasMultiplicityItems = true;
}
hasValue = createFields(multiplicityFieldset.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService);
hasValue = createFields(multiplicityFieldset.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService, hasMultiplicityItems);
if(hasValue){
returnedValue = true;
}
}
}
if (hasValue && compositeField.getHasCommentField() && compositeField.getCommentFieldValue() != null && !compositeField.getCommentFieldValue().isEmpty() && !createListing) {
XWPFParagraph paragraph = addParagraphContent("Comment: " + compositeField.getCommentFieldValue(), mainDocumentPart, ParagraphStyle.COMMENT, numId);
XWPFParagraph paragraph = addParagraphContent("<i>Comment:</i>\n"+compositeField.getCommentFieldValue(), mainDocumentPart, ParagraphStyle.HTML, numId);
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent));
}
@ -319,19 +328,10 @@ public class WordBuilder {
return returnedValue;
}
private Boolean createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
private Boolean createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService, boolean hasMultiplicityItems) {
if (createListing) this.addListing(mainDocumentPart, indent, false, false);
boolean hasValue = false;
List<Field> tempFields = fields.stream().sorted(Comparator.comparingInt(Field::getOrdinal)).collect(Collectors.toList());
List<Field> formats = tempFields.stream().filter(f -> {
try {
String fTemp = this.formatter(f);
return fTemp != null && !fTemp.isEmpty();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return false;
}).collect(Collectors.toList());
for (Field field: tempFields) {
if (visibilityRuleService.isElementVisible(field.getId()) && field.getExport()) {
if (!createListing) {
@ -346,13 +346,16 @@ public class WordBuilder {
}
}
if(isImage){
if (!field.getValue().toString().isEmpty()) {
if (field.getValue() != null && !field.getValue().toString().isEmpty()) {
XWPFParagraph paragraph = addParagraphContent(mapper.convertValue(field.getValue(), Map.class), mainDocumentPart, ParagraphStyle.IMAGE, numId);
if (paragraph != null) {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent));
hasValue = true;
}
if(hasMultiplicityItems){
hasMultiplicityItems = false;
}
}
}
}
@ -364,19 +367,69 @@ public class WordBuilder {
} else if (field.getViewStyle().getRenderStyle().equals("combobox") && field.getData() instanceof AutoCompleteData) {
format = getCommaSeparatedFormatsFromJson(format, "label");
}
boolean isResearcher = field.getViewStyle().getRenderStyle().equals("researchers");
if(format != null && !format.isEmpty()){
if(format.charAt(0) == '['){
format = format.substring(1, format.length() - 1).replaceAll(",", ", ");
}
if(formats.size() > 1){
format = "\t• " + format;
Object hasMultiAutoComplete = mapper.convertValue(field.getData(), Map.class).get("multiAutoComplete");
boolean isMultiAutoComplete = hasMultiAutoComplete != null && (boolean)hasMultiAutoComplete;
boolean arrayStringFormat = format.charAt(0) == '[';
if(arrayStringFormat || isMultiAutoComplete){
List<String> values = (arrayStringFormat) ? Arrays.asList(format.substring(1, format.length() - 1).split(",[ ]*")) : Arrays.asList(format.split(",[ ]*"));
if(values.size() > 1) {
boolean orcidResearcher;
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;
if(hasMultiplicityItems){
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;
}
else{
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) {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent));
hasValue = true;
}
}
format = null;
}
}
else if(values.size() == 1){
format = values.get(0);
}
}
}
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId);
if (paragraph != null) {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent));
hasValue = true;
if(hasMultiplicityItems && format != null){
mainDocumentPart.getLastParagraph().createRun().setText(format);
hasMultiplicityItems = false;
}
else{
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId);
if (paragraph != null) {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent));
hasValue = true;
}
}
}
} catch (IOException e) {
@ -576,4 +629,97 @@ public class WordBuilder {
}
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);
}
}
}
}
});
}
}

View File

@ -36,6 +36,16 @@ spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=false
####################ELASTIIC SEARCH TAGS OVERRIDES CONFIGURATIONS##########
elasticsearch.host=
elasticsearch.port=
elasticsearch.username=
elasticsearch.password=
elasticsearch.index=
elasticsearch.usingssl=false
elasticsearch.certPath=
elasticsearch.certKey=
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=externalUrls/ExternalUrls.xml
configuration.rda=RDACommonStandards.txt

View File

@ -27,27 +27,9 @@
},
{
"enabled": false,
"type": "",
"type": "saml2",
"configurableLoginId": "",
"name": "",
"spEntityId": "",
"idpEntityId": "",
"idpUrl": "",
"idpArtifactUrl": "",
"idpMetadataUrl": "",
"assertionEncrypted": null,
"keyFormat": "",
"keyAlias": "",
"credentialPath": "",
"archivePassword": "",
"keyPassword": "",
"responseSigned": null,
"assertionSigned": null,
"usingFormat": "",
"configurableUserFromAttributes": null,
"attributeTypes": null,
"binding": "",
"logoUrl": ""
"name": ""
}
]
}

View File

@ -28,10 +28,14 @@
<span class="mt-1" *ngIf="!compositeFieldFormGroup.get('multiplicity').value.placeholder">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}</span>
</span>
</div>
<mat-form-field *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="compositeFieldFormGroup">
<input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">
<mat-hint>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-HINT' | translate}}</mat-hint>
</mat-form-field>
<ng-container *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="">
<!-- <input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">-->
<rich-text-editor-component [parentFormGroup]="compositeFieldFormGroup" [controlName]="'commentFieldValue'"
[id]="'editor1'" [placeholder]="'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate"
[wrapperClasses]="'col-12 mb-2'">
</rich-text-editor-component>
<!-- <mat-hint>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-HINT' | translate}}</mat-hint>-->
</ng-container>
<!-- <div class="col"></div>
<button class="col-auto" mat-icon-button type="button" (click)="next(compositeField)">
<mat-icon>expand_more</mat-icon>

View File

@ -40,10 +40,14 @@
<span class="mt-1" *ngIf="!compositeFieldFormGroup.get('multiplicity').value.placeholder">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}</span>
</span>
</div>
<mat-form-field *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="compositeFieldFormGroup">
<input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">
<mat-hint>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-HINT' | translate}}</mat-hint>
</mat-form-field>
<ng-container *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="">
<!-- <input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">-->
<rich-text-editor-component [parentFormGroup]="compositeFieldFormGroup" [controlName]="'commentFieldValue'"
[id]="'editor1'" [placeholder]="'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate"
[wrapperClasses]="'col-12 mb-2'">
</rich-text-editor-component>
<!-- <mat-hint>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-HINT' | translate}}</mat-hint>-->
</ng-container>
<!-- <div class="col"></div>
<button class="col-auto" mat-icon-button type="button" (click)="next(compositeField)">
<mat-icon>expand_more</mat-icon>
@ -109,10 +113,14 @@
<span class="mt-1" *ngIf="!fieldsetEntry.form.get('multiplicity').value.placeholder">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}</span>
</span>
</div>
<mat-form-field *ngIf="fieldsetEntry.form.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="fieldsetEntry.form">
<input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">
<mat-hint>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-HINT' | translate}}</mat-hint>
</mat-form-field>
<ng-container *ngIf="fieldsetEntry.form.get('hasCommentField').value" class="">
<!-- <input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">-->
<rich-text-editor-component [parentFormGroup]="fieldsetEntry.form" [controlName]="'commentFieldValue'"
[id]="'editor1'" [placeholder]="'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate"
[wrapperClasses]="'col-12 mb-2'">
</rich-text-editor-component>
<!-- <mat-hint>{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-HINT' | translate}}</mat-hint>-->
</ng-container>
<!-- <div class="col"></div>
<button class="col-auto" mat-icon-button type="button" (click)="next(compositeField)">
<mat-icon>expand_more</mat-icon>