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

This commit is contained in:
George Kalampokis 2022-01-13 13:33:13 +02:00
commit 64ec74363b
10 changed files with 256 additions and 44 deletions

View File

@ -131,7 +131,7 @@ public class WordBuilder {
this.options.put(ParagraphStyle.COMMENT, (mainDocumentPart, item) -> { this.options.put(ParagraphStyle.COMMENT, (mainDocumentPart, item) -> {
XWPFParagraph paragraph = mainDocumentPart.createParagraph(); XWPFParagraph paragraph = mainDocumentPart.createParagraph();
XWPFRun run = paragraph.createRun(); XWPFRun run = paragraph.createRun();
run.setText(item); run.setText(" " + item);
run.setItalic(true); run.setItalic(true);
return paragraph; return paragraph;
}); });
@ -178,7 +178,7 @@ public class WordBuilder {
number.setVal(BigInteger.valueOf(indent)); number.setVal(BigInteger.valueOf(indent));
paragraphPos = mainDocumentPart.getPosOfParagraph(paragraph); paragraphPos = mainDocumentPart.getPosOfParagraph(paragraph);
} }
createSections(section.getSections(), mainDocumentPart, ParagraphStyle.HEADER5, 1, createListing, visibilityRuleService, page, tempSectionString); createSections(section.getSections(), mainDocumentPart, ParagraphStyle.HEADER4, 1, createListing, visibilityRuleService, page, tempSectionString);
hasValue = createCompositeFields(section.getCompositeFields(), mainDocumentPart, 2, createListing, visibilityRuleService, page, tempSectionString); hasValue = createCompositeFields(section.getCompositeFields(), mainDocumentPart, 2, createListing, visibilityRuleService, page, tempSectionString);
if (!hasValue && paragraphPos > -1) { if (!hasValue && paragraphPos > -1) {
@ -193,18 +193,26 @@ public class WordBuilder {
boolean hasValue = false; boolean hasValue = false;
for (FieldSet compositeField: compositeFields) { for (FieldSet compositeField: compositeFields) {
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) { if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
char c = 'a';
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(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);
if(compositeField.getMultiplicityItems() != null && !compositeField.getMultiplicityItems().isEmpty()){
addParagraphContent(c + ".\n", mainDocumentPart, ParagraphStyle.HEADER6, numId);
}
} }
hasValue = createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService); hasValue = createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService);
if (compositeField.getMultiplicityItems() != null && !compositeField.getMultiplicityItems().isEmpty()) { if (compositeField.getMultiplicityItems() != null && !compositeField.getMultiplicityItems().isEmpty()) {
List<FieldSet> list = compositeField.getMultiplicityItems().stream().sorted(Comparator.comparingInt(FieldSet::getOrdinal)).collect(Collectors.toList()); List<FieldSet> list = compositeField.getMultiplicityItems().stream().sorted(Comparator.comparingInt(FieldSet::getOrdinal)).collect(Collectors.toList());
for (FieldSet multiplicityFieldset : list) { for (FieldSet multiplicityFieldset : list) {
hasValue = createFields(multiplicityFieldset.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService); if(!createListing){
c++;
addParagraphContent(c + ".\n", mainDocumentPart, ParagraphStyle.HEADER6, numId);
}
hasValue = createFields(multiplicityFieldset.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService);
} }
} }
if (hasValue && compositeField.getHasCommentField() && compositeField.getCommentFieldValue() != null && !compositeField.getCommentFieldValue().isEmpty() && !createListing) { if (hasValue && compositeField.getHasCommentField() && compositeField.getCommentFieldValue() != null && !compositeField.getCommentFieldValue().isEmpty() && !createListing) {
@ -224,13 +232,31 @@ public class WordBuilder {
if (createListing) this.addListing(mainDocumentPart, indent, false, false); if (createListing) this.addListing(mainDocumentPart, indent, false, false);
boolean hasValue = false; boolean hasValue = false;
List<Field> tempFields = fields.stream().sorted(Comparator.comparingInt(Field::getOrdinal)).collect(Collectors.toList()); 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) { for (Field field: tempFields) {
if (visibilityRuleService.isElementVisible(field.getId())) { if (visibilityRuleService.isElementVisible(field.getId())) {
if (!createListing) { if (!createListing) {
try { try {
if (field.getValue() != null && !field.getValue().toString().isEmpty()) { if (field.getValue() != null && !field.getValue().toString().isEmpty()) {
this.indent = indent; this.indent = indent;
XWPFParagraph paragraph = addParagraphContent(this.formatter(field), mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId); String format = this.formatter(field);
if(format != null){
if(format.charAt(0) == '['){
format = format.substring(1, format.length() - 1).replaceAll(",", ", ");
}
if(formats.size() > 1){
format = "\t• " + format;
}
}
XWPFParagraph paragraph = addParagraphContent(format, mainDocumentPart, field.getViewStyle().getRenderStyle().equals("richTextarea") ? ParagraphStyle.HTML : ParagraphStyle.TEXT, numId);
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));

View File

@ -4,10 +4,10 @@ public class JavaToJson {
public static String objectStringToJson(String object) { public static String objectStringToJson(String object) {
String result = object.replaceAll("=", "\":\"") String result = object.replaceAll("=", "\":\"")
.replaceAll("\\{", "{\"") //.replaceAll("\\{", "{\"")
.replaceAll(", ", "\", \"") .replaceAll(", ", "\", \"")
.replaceAll("}", "\"}" ). //.replaceAll("}", "\"}" ).
replaceAll("}\", \"\\{", "}, {"); .replaceAll("}\", \"\\{", "}, {");
return result; return result;
} }
} }

View File

@ -1,10 +1,19 @@
package eu.eudat.models.rda.mapper; package eu.eudat.models.rda.mapper;
import java.util.Map; import java.util.*;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.utilities.json.JavaToJson;
import eu.eudat.models.rda.Cost; import eu.eudat.models.rda.Cost;
import eu.eudat.models.rda.PidSystem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CostRDAMapper { public class CostRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class);
public static Cost toRDA(Map<String, Object> cost) { public static Cost toRDA(Map<String, Object> cost) {
Cost rda = new Cost(); Cost rda = new Cost();
@ -19,4 +28,69 @@ public class CostRDAMapper {
return rda; return rda;
} }
public static List<Cost> toRDAList(List<JsonNode> nodes) throws JsonProcessingException {
Map<String, Cost> rdaMap = new HashMap<>();
for(JsonNode node: nodes){
String rdaProperty = node.get("rdaProperty").asText();
String rdaValue = node.get("value").asText();
if(rdaValue == null || (rdaValue.isEmpty() && !node.get("value").isArray())){
continue;
}
String key = node.get("numbering").asText();
if(!key.contains("mult")){
key = "0";
}
else{
key = "" + key.charAt(4);
}
Cost rda;
if(rdaMap.containsKey(key)){
rda = rdaMap.get(key);
}
else{
rda = new Cost();
rdaMap.put(key, rda);
}
if(rdaProperty.contains("value")){
rda.setValue(Double.valueOf(rdaValue));
}
else if(rdaProperty.contains("currency_code")){
String json = JavaToJson.objectStringToJson(rdaValue);
HashMap<String,String> result =
new ObjectMapper().readValue(json, HashMap.class);
rda.setCurrencyCode(Cost.CurrencyCode.fromValue(result.get("value")));
}
else if(rdaProperty.contains("title")){
Iterator<JsonNode> iter = node.get("value").elements();
StringBuilder title = new StringBuilder();
while(iter.hasNext()){
String next = iter.next().asText();
if(!next.equals("Other")) {
title.append(next).append(", ");
}
}
if(title.length() > 2){
rda.setTitle(title.substring(0, title.length() - 2));
}
else{
String t = rda.getTitle();
if(t == null){ // only other as title
rda.setTitle(rdaValue);
}
else{ // option + other
rda.setTitle(t + ", " + rdaValue);
}
}
}
else if(rdaProperty.contains("description")){
rda.setDescription(rdaValue);
}
}
List<Cost> rdaList = rdaMap.values().stream()
.filter(cost -> cost.getTitle() != null)
.collect(Collectors.toList());
return rdaList;
}
} }

View File

@ -9,10 +9,7 @@ import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.rda.Contributor; import eu.eudat.models.rda.*;
import eu.eudat.models.rda.Dataset;
import eu.eudat.models.rda.DatasetId;
import eu.eudat.models.rda.Language;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -20,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.net.URI;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -43,7 +41,7 @@ public class DatasetRDAMapper {
} }
@Transactional @Transactional
public Dataset toRDA(eu.eudat.data.entities.Dataset dataset, List<Contributor> contributors) { public Dataset toRDA(eu.eudat.data.entities.Dataset dataset, eu.eudat.models.rda.Dmp dmp) {
Dataset rda = new Dataset(); Dataset rda = new Dataset();
// rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); // rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId()));
if (dataset.getLabel() == null) { if (dataset.getLabel() == null) {
@ -128,7 +126,11 @@ public class DatasetRDAMapper {
} }
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data");
if (!personalDataNodes.isEmpty()) { if (!personalDataNodes.isEmpty()) {
rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get()); try{
rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get());
}catch(IllegalArgumentException e){
rda.setPersonalData(Dataset.PersonalData.UNKNOWN);
}
} else { } else {
rda.setPersonalData(Dataset.PersonalData.UNKNOWN); rda.setPersonalData(Dataset.PersonalData.UNKNOWN);
} }
@ -140,7 +142,11 @@ public class DatasetRDAMapper {
} }
List<JsonNode> sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); List<JsonNode> sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data");
if (!sensitiveDataNodes.isEmpty()) { if (!sensitiveDataNodes.isEmpty()) {
rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); try{
rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get());
}catch(IllegalArgumentException e){
rda.setSensitiveData(Dataset.SensitiveData.UNKNOWN);
}
} else { } else {
rda.setSensitiveData(Dataset.SensitiveData.UNKNOWN); rda.setSensitiveData(Dataset.SensitiveData.UNKNOWN);
} }
@ -156,15 +162,58 @@ public class DatasetRDAMapper {
} }
List<JsonNode> contributorNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dmp.contributor"); List<JsonNode> contributorNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dmp.contributor");
if (!contributorNodes.isEmpty()) { if (!contributorNodes.isEmpty()) {
contributors.addAll(contributorNodes.stream().map(contributorNode -> { dmp.getContributor().addAll(contributorNodes.stream().map(contributorNode -> {
JsonNode value = contributorNode.get("value"); JsonNode value = contributorNode.get("value");
if (value.isArray()) { if (value.isArray()) {
return StreamSupport.stream(value.spliterator(), false).map(node -> ContributorRDAMapper.toRDA(node.asText())).collect(Collectors.toList()); return StreamSupport.stream(value.spliterator(), false).map(node -> ContributorRDAMapper.toRDA(node.asText())).collect(Collectors.toList());
} else { } else {
return Collections.singletonList(new Contributor()); return Collections.singletonList(new Contributor()); // return null kalutera
} }
}).flatMap(Collection::stream).collect(Collectors.toList())); }).flatMap(Collection::stream).collect(Collectors.toList()));
} }
List<JsonNode> costNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dmp.cost");
if (!costNodes.isEmpty()) {
dmp.getCost().addAll(CostRDAMapper.toRDAList(costNodes));
}
List<JsonNode> ethicsNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dmp.ethical_issues");
if (!ethicsNodes.isEmpty()) {
for(JsonNode node: ethicsNodes){
String rdaProperty = node.get("rdaProperty").asText();
String rdaValue = node.get("value").asText();
if(rdaValue == null || rdaValue.isEmpty()){
continue;
}
if(rdaProperty.contains("exist")){
try {
Dmp.EthicalIssuesExist exists = dmp.getEthicalIssuesExist();
if(exists == null
|| ((exists == Dmp.EthicalIssuesExist.NO || exists == Dmp.EthicalIssuesExist.UNKNOWN) && rdaValue.equals("yes"))
|| (exists == Dmp.EthicalIssuesExist.YES && !(rdaValue.equals("no") || rdaValue.equals("unknown")))
|| (exists == Dmp.EthicalIssuesExist.UNKNOWN && rdaValue.equals("no"))){
dmp.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(rdaValue));
}
}catch(IllegalArgumentException e){
logger.warn(e.getLocalizedMessage() + ". Setting ethical_issues_exist to unknown");
dmp.setEthicalIssuesExist(Dmp.EthicalIssuesExist.UNKNOWN);
}
}
else if(rdaProperty.contains("description")){
if(dmp.getEthicalIssuesDescription() == null){
dmp.setEthicalIssuesDescription(rdaValue);
}
else{
dmp.setEthicalIssuesDescription(dmp.getEthicalIssuesDescription() + ", " + rdaValue);
}
}
else if(rdaProperty.contains("report")){
try {
dmp.setEthicalIssuesReport(URI.create(rdaValue));
} catch (IllegalArgumentException e) {
logger.warn(e.getLocalizedMessage() + ". Skipping url parsing");
}
}
}
}
List<JsonNode> foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes, List<JsonNode> foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes,
keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList()); keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList());
templateIdsToValues.entrySet().forEach(entry -> { templateIdsToValues.entrySet().forEach(entry -> {

View File

@ -1,7 +1,11 @@
package eu.eudat.models.rda.mapper; package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.logic.utilities.helpers.MyStringUtils;
import eu.eudat.logic.utilities.json.JavaToJson;
import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.models.rda.Distribution; import eu.eudat.models.rda.Distribution;
import eu.eudat.models.rda.License; import eu.eudat.models.rda.License;
@ -21,7 +25,8 @@ public class DistributionRDAMapper {
for (JsonNode node: nodes) { for (JsonNode node: nodes) {
String rdaProperty = node.get("rdaProperty").asText(); String rdaProperty = node.get("rdaProperty").asText();
String rdaValue = node.get("value").asText(); String rdaValue = node.get("value").asText();
if(rdaValue == null || rdaValue.isEmpty()){ //if(rdaValue == null || rdaValue.isEmpty()){
if(rdaValue == null || (rdaValue.isEmpty() && !node.get("value").isArray())){
continue; continue;
} }
String key = node.get("numbering").asText(); String key = node.get("numbering").asText();
@ -39,10 +44,10 @@ public class DistributionRDAMapper {
rda = new Distribution(); rda = new Distribution();
rdaMap.put(key, rda); rdaMap.put(key, rda);
} }
/* Distribution rda = getRelative(rdaMap, node.get("numbering").asText()); /* Distribution rda = getRelative(rdaMap, node.get("numbering").asText());
if (!rdaMap.containsValue(rda)) { if (!rdaMap.containsValue(rda)) {
rdaMap.put(node.get("numbering").asText(), rda); rdaMap.put(node.get("numbering").asText(), rda);
}*/ } */
for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) {
if (rdaProperty.contains(exportPropertyName.getName())) { if (rdaProperty.contains(exportPropertyName.getName())) {
switch (exportPropertyName) { switch (exportPropertyName) {
@ -78,7 +83,25 @@ public class DistributionRDAMapper {
rda.setLicense(license != null? Collections.singletonList(license): new ArrayList<>()); rda.setLicense(license != null? Collections.singletonList(license): new ArrayList<>());
break; break;
case FORMAT: case FORMAT:
rda.setFormat(new ArrayList<>(Arrays.asList(rdaValue.replace(" ", "").split(",")))); if(node.get("value").isArray()){
Iterator<JsonNode> iter = node.get("value").elements();
List<String> formats = new ArrayList<>();
while(iter.hasNext()) {
String format = JavaToJson.objectStringToJson(iter.next().asText());
try {
Map<String, String> result = new ObjectMapper().readValue(format, HashMap.class);
format = result.get("label");
formats.add(format);
}
catch(JsonProcessingException e){
logger.warn(e.getMessage());
}
}
rda.setFormat(formats);
}
else{
rda.setFormat(new ArrayList<>(Arrays.asList(rdaValue.replace(" ", "").split(","))));
}
rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText()); rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText());
break; break;
case TITLE: case TITLE:

View File

@ -68,7 +68,7 @@ public class DmpRDAMapper {
if (!extraProperties.isEmpty()) { if (!extraProperties.isEmpty()) {
if (extraProperties.get("ethicalIssues") != null) { if (extraProperties.get("ethicalIssues") != null) {
rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(extraProperties.get("ethicalIsses").toString())); rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(extraProperties.get("ethicalIssues").toString()));
} else { } else {
rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.UNKNOWN); rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.UNKNOWN);
} }
@ -95,7 +95,7 @@ public class DmpRDAMapper {
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
} }
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); // rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != eu.eudat.elastic.entities.Dmp.DMPStatus.DELETED.getValue()).map(dataset -> datasetRDAMapper.toRDA(dataset, rda.getContributor())).collect(Collectors.toList())); rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != eu.eudat.elastic.entities.Dmp.DMPStatus.DELETED.getValue()).map(dataset -> datasetRDAMapper.toRDA(dataset, rda)).collect(Collectors.toList()));
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray()); rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
return rda; return rda;

View File

@ -22,7 +22,7 @@ public class HostRDAMapper {
String rdaProperty = node.get("rdaProperty").asText(); String rdaProperty = node.get("rdaProperty").asText();
if (rdaProperty.contains("host")) { if (rdaProperty.contains("host")) {
int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText());
if (firstDiff == -1 || firstDiff > 2) { if (firstDiff == -1 || firstDiff >= 2) {
String rdaValue = node.get("value").asText(); String rdaValue = node.get("value").asText();
if(rdaValue == null || (rdaValue.isEmpty() && !node.get("value").isArray())){ if(rdaValue == null || (rdaValue.isEmpty() && !node.get("value").isArray())){
continue; continue;
@ -67,7 +67,14 @@ public class HostRDAMapper {
while(iter.hasNext()) { while(iter.hasNext()) {
pList.add(iter.next().asText()); pList.add(iter.next().asText());
} }
List<PidSystem> pidList = pList.stream().map(PidSystem::fromValue).collect(Collectors.toList()); List<PidSystem> pidList;
if(pList.size() == 0){
pidList = Arrays.stream(rdaValue.replaceAll("[\\[\"\\]]","").split(","))
.map(PidSystem::fromValue).collect(Collectors.toList());
}
else{
pidList = pList.stream().map(PidSystem::fromValue).collect(Collectors.toList());
}
rda.setPidSystem(pidList); rda.setPidSystem(pidList);
rda.setAdditionalProperty(ImportPropertyName.PID_SYSTEM.getName(), node.get("id").asText()); rda.setAdditionalProperty(ImportPropertyName.PID_SYSTEM.getName(), node.get("id").asText());
} }

View File

@ -15,21 +15,17 @@ public class KeywordRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(KeywordRDAMapper.class); private static final Logger logger = LoggerFactory.getLogger(KeywordRDAMapper.class);
public static List<String> toRDA(String value) { public static List<String> toRDA(String value) {
ObjectMapper mapper = new ObjectMapper(); if (!value.isEmpty()) {
value = JavaToJson.objectStringToJson(value); try {
if (!value.isEmpty()) { ObjectMapper mapper = new ObjectMapper();
try { String valueJson = JavaToJson.objectStringToJson(value);
List<Tag> tags = Arrays.asList(mapper.readValue(value, Tag[].class)); List<Tag> tags = Arrays.asList(mapper.readValue(valueJson, Tag[].class));
List<String> keywordNames = tags.stream().map(Tag::getName).collect(Collectors.toList()); return tags.stream().map(Tag::getName).collect(Collectors.toList());
return keywordNames; } catch (JsonProcessingException e) {
} catch (JsonProcessingException e) { logger.warn(e.getMessage() + ". Attempting to parse it as a String list.");
logger.warn(e.getMessage() + ". Attempting to parse it as a String list."); return new ArrayList<>(Arrays.asList(value.replace(" ", "").split(",")));
if(!value.isEmpty()) {
return new ArrayList<>(Arrays.asList(value.replace(" ", "").split(",")));
}
}
} }
}
return new ArrayList<>(); return new ArrayList<>();
} }

View File

@ -34,12 +34,49 @@ dataset.security_and_privacy.description
dataset.security_and_privacy.title dataset.security_and_privacy.title
dataset.sensitive_data dataset.sensitive_data
dataset.technical_resource.description dataset.technical_resource.description
dataset.technical_resource.technical_resource dataset.technical_resource.name
dataset.technical_resource.technical_resource.description dataset.title
dataset.technical_resource.technical_resource.name
dataset.type dataset.type
dataset.issued dataset.issued
dataset.dataset_id dataset.dataset_id
dataset.dataset_id.identifier dataset.dataset_id.identifier
dataset.dataset_id.type dataset.dataset_id.type
dmp.contributor dataset.description
dmp.contact
dmp.contact.contact_id.identifier
dmp.contact.contact_id.type
dmp.contact.mbox
dmp.contact.name
dmp.contributor
dmp.contributor.contributor_id.identifier
dmp.contributor.contributor_id.type
dmp.contributor.mbox
dmp.contributor.name
dmp.contributor.role
dmp.cost
dmp.cost.currency_code
dmp.cost.description
dmp.cost.title
dmp.cost.value
dmp.created
dmp.description
dmp.dmp_id
dmp.dmp_id.identifier
dmp.dmp_id.type
dmp.ethical_issues_description
dmp.ethical_issues_exist
dmp.ethical_issues_report
dmp.language
dmp.modified
dmp.project
dmp.project.description
dmp.project.end
dmp.project.funding
dmp.project.funding.funder_id.identifier
dmp.project.funding.funder_id.type
dmp.project.funding.funding_status
dmp.project.funding.grant_id.identifier
dmp.project.funding.grant_id.type
dmp.project.start
dmp.project.title
dmp.title

View File

@ -19,7 +19,7 @@ elasticsearch.index=dmps
http-logger.server-address = http://localhost:31311 http-logger.server-address = http://localhost:31311
####################PDF OVERRIDES CONFIGURATIONS########## ####################PDF OVERRIDES CONFIGURATIONS##########
pdf.converter.url=http://localhost:88/ pdf.converter.url=http://localhost:3000/
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS########## ####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=externalUrls/ExternalUrls.xml configuration.externalUrls=externalUrls/ExternalUrls.xml