Fixed issue when creating new Datasets
This commit is contained in:
parent
d0cb186ab2
commit
744acd7abf
|
@ -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() != 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…
Reference in New Issue