Fixed issue when creating new Datasets
This commit is contained in:
parent
d0cb186ab2
commit
744acd7abf
|
@ -49,6 +49,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
Dmp dmp = this.dmpRepository.findDocument(entity.getDmp().toString());
|
Dmp dmp = this.dmpRepository.findDocument(entity.getDmp().toString());
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
if (dmp.getDatasets() != null && !dmp.getDatasets().isEmpty()) {
|
||||||
for (int i = 0; i < dmp.getDatasets().size(); i++) {
|
for (int i = 0; i < dmp.getDatasets().size(); i++) {
|
||||||
if (dmp.getDatasets().get(i).getId().equals(entity.getId())) {
|
if (dmp.getDatasets().get(i).getId().equals(entity.getId())) {
|
||||||
dmp.getDatasets().set(i, entity);
|
dmp.getDatasets().set(i, entity);
|
||||||
|
@ -56,7 +57,11 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
if (dmp.getDatasets() == null) {
|
||||||
|
dmp.setDatasets(new ArrayList<>());
|
||||||
|
}
|
||||||
dmp.getDatasets().add(entity);
|
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));
|
IndexRequest request = new IndexRequest("dmps").id(dmp.getId().toString()).source(dmp.toElasticEntity(builder));//new IndexRequest("datasets", "doc", entity.getId()).source(entity.toElasticEntity(builder));
|
||||||
|
|
Loading…
Reference in New Issue