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);
this.updateIndex(dmp); if (this.apiContext.getOperationsContext().getElasticRepository().getDmpRepository().getClient() != null) {
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,20 +217,22 @@ 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) {
boolean takeAll = false; List<String> keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList());
if (keywordIds.size() < rda.getKeyword().size()) { boolean takeAll = false;
takeAll = true; if (keywordIds.size() < rda.getKeyword().size()) {
} takeAll = true;
for (int i = 0; i < keywordIds.size(); i++) { }
if (takeAll) { for (int i = 0; i < keywordIds.size(); i++) {
List<String> tags = new ArrayList<>(); if (takeAll) {
for (String keyword: rda.getKeyword()) { List<String> tags = new ArrayList<>();
tags.add(mapper.writeValueAsString(toTagEntity(keyword))); for (String keyword : rda.getKeyword()) {
tags.add(mapper.writeValueAsString(toTagEntity(keyword)));
}
properties.put(keywordIds.get(i), tags);
} else {
properties.put(keywordIds.get(i), mapper.writeValueAsString(toTagEntity(rda.getKeyword().get(i))));
} }
properties.put(keywordIds.get(i), tags);
} else {
properties.put(keywordIds.get(i), mapper.writeValueAsString(toTagEntity(rda.getKeyword().get(i))));
} }
} }

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();
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString())); if (!extraProperties.isEmpty()) {
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString()));
}
UserInfo creator; UserInfo creator;
if (dmp.getCreator() != null) { if (dmp.getCreator() != null) {