|
|
@ -49,14 +49,19 @@ 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;
|
|
|
|
for(int i = 0; i < dmp.getDatasets().size(); i++) {
|
|
|
|
if (dmp.getDatasets() != null && !dmp.getDatasets().isEmpty()) {
|
|
|
|
if (dmp.getDatasets().get(i).getId().equals(entity.getId())) {
|
|
|
|
for (int i = 0; i < dmp.getDatasets().size(); i++) {
|
|
|
|
dmp.getDatasets().set(i, entity);
|
|
|
|
if (dmp.getDatasets().get(i).getId().equals(entity.getId())) {
|
|
|
|
found = true;
|
|
|
|
dmp.getDatasets().set(i, entity);
|
|
|
|
break;
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
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));
|
|
|
|