Fixed issue when creating new Datasets

Remove_explore v0.4
George Kalampokis 3 years ago
parent d0cb186ab2
commit 744acd7abf
  1. 15
      dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java

@ -49,14 +49,19 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
XContentBuilder builder = XContentFactory.jsonBuilder();
Dmp dmp = this.dmpRepository.findDocument(entity.getDmp().toString());
boolean found = false;
for(int i = 0; i < dmp.getDatasets().size(); i++) {
if (dmp.getDatasets().get(i).getId().equals(entity.getId())) {
dmp.getDatasets().set(i, entity);
found = true;
break;
if (dmp.getDatasets() != null && !dmp.getDatasets().isEmpty()) {
for (int i = 0; i < dmp.getDatasets().size(); i++) {
if (dmp.getDatasets().get(i).getId().equals(entity.getId())) {
dmp.getDatasets().set(i, entity);
found = true;
break;
}
}
}
if (!found) {
if (dmp.getDatasets() == null) {
dmp.setDatasets(new ArrayList<>());
}
dmp.getDatasets().add(entity);
}
IndexRequest request = new IndexRequest("dmps").id(dmp.getId().toString()).source(dmp.toElasticEntity(builder));//new IndexRequest("datasets", "doc", entity.getId()).source(entity.toElasticEntity(builder));

Loading…
Cancel
Save