Fixed minor issues with RDA Mapping

This commit is contained in:
George Kalampokis 2020-06-25 13:30:47 +03:00
parent 791f2fee61
commit 55d3feb4e3
5 changed files with 26 additions and 40 deletions

View File

@ -1404,7 +1404,9 @@ public class DataManagementPlanManager {
} }
databaseRepository.getDmpDao().createOrUpdate(dmp); databaseRepository.getDmpDao().createOrUpdate(dmp);
assignUser(dmp, me); assignUser(dmp, me);
if (this.apiContext.getOperationsContext().getElasticRepository().getDmpRepository().getClient() != null) {
this.updateIndex(dmp); this.updateIndex(dmp);
}
dmp.getDataset().forEach(dataset -> { dmp.getDataset().forEach(dataset -> {
dataset.setStatus(Dataset.Status.SAVED.getValue()); dataset.setStatus(Dataset.Status.SAVED.getValue());
dataset.setCreated(new Date()); dataset.setCreated(new Date());

View File

@ -34,8 +34,9 @@ public class RDAManager {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")); mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));
DMPWrap wrap = new DMPWrap(rdaDmp); RDAModel model = new RDAModel();
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(wrap); model.setDmp(rdaDmp);
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
return result; return result;
} }
@ -44,28 +45,7 @@ public class RDAManager {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")); mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));
Dmp rda = mapper.readValue(json, RDAModel.class).getDmp();
Dmp rda = mapper.readValue(json, DMPWrap.class).getDmp();
return dmpRDAMapper.toEntity(rda, profiles); return dmpRDAMapper.toEntity(rda, profiles);
} }
public static class DMPWrap implements Serializable {
@JsonProperty("dmp")
private Dmp dmp;
public DMPWrap() {
}
public DMPWrap(Dmp dmp) {
this.dmp = dmp;
}
public Dmp getDmp() {
return dmp;
}
public void setDmp(Dmp dmp) {
this.dmp = dmp;
}
}
} }

View File

@ -58,7 +58,7 @@ public class DmpMapper {
} }
if (dmp.getDataset() != null) { if (dmp.getDataset() != null) {
elastic.setDatasets(dmp.getDataset().stream().map(dataset -> { elastic.setDatasets(dmp.getDataset().stream().filter(dataset -> dataset.getId() != null).map(dataset -> {
List<Tag> tags = null; List<Tag> tags = null;
try { try {
Dataset dataset1 = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString()); Dataset dataset1 = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());

View File

@ -217,7 +217,8 @@ public class DatasetRDAMapper {
properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution().get(0), datasetDescriptionObj)); properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution().get(0), datasetDescriptionObj));
} }
List <String> keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); if (rda.getKeyword() != null) {
List<String> keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList());
boolean takeAll = false; boolean takeAll = false;
if (keywordIds.size() < rda.getKeyword().size()) { if (keywordIds.size() < rda.getKeyword().size()) {
takeAll = true; takeAll = true;
@ -225,7 +226,7 @@ public class DatasetRDAMapper {
for (int i = 0; i < keywordIds.size(); i++) { for (int i = 0; i < keywordIds.size(); i++) {
if (takeAll) { if (takeAll) {
List<String> tags = new ArrayList<>(); List<String> tags = new ArrayList<>();
for (String keyword: rda.getKeyword()) { for (String keyword : rda.getKeyword()) {
tags.add(mapper.writeValueAsString(toTagEntity(keyword))); tags.add(mapper.writeValueAsString(toTagEntity(keyword)));
} }
properties.put(keywordIds.get(i), tags); properties.put(keywordIds.get(i), tags);
@ -233,6 +234,7 @@ public class DatasetRDAMapper {
properties.put(keywordIds.get(i), mapper.writeValueAsString(toTagEntity(rda.getKeyword().get(i)))); properties.put(keywordIds.get(i), mapper.writeValueAsString(toTagEntity(rda.getKeyword().get(i))));
} }
} }
}
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()) {

View File

@ -42,7 +42,9 @@ public class DmpRDAMapper {
rda.setTitle(dmp.getLabel()); rda.setTitle(dmp.getLabel());
Map<String, Object> extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap(); Map<String, Object> extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
if (!extraProperties.isEmpty()) {
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString())); rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString()));
}
UserInfo creator; UserInfo creator;
if (dmp.getCreator() != null) { if (dmp.getCreator() != null) {