Refactors how "External Resources" are saved on Dataset.

This commit is contained in:
gkolokythas 2020-01-14 13:36:48 +02:00
parent 1b7d118861
commit 2958cab113
1 changed files with 31 additions and 10 deletions

View File

@ -281,20 +281,41 @@ public class Dataset implements DataEntity<Dataset, UUID> {
this.setLabel(entity.getLabel());
this.setProperties(entity.getProperties());
this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
if (entity.getDatasetDataRepositories() != null)
this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories());
if (entity.getDatasetDataRepositories() == null || entity.getDatasetDataRepositories().size() < 1) {
if (this.getDatasetDataRepositories() != null) this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
} else {
if (this.getDatasetDataRepositories() != null) {
this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
} else {
this.setDatasetDataRepositories(new HashSet<>());
}
this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
}
this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
if (entity.getDatasetExternalDatasets() != null)
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets());
if (entity.getDatasetExternalDatasets() == null || entity.getDatasetExternalDatasets().size() < 1) {
if (this.getDatasetExternalDatasets() != null) this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
} else {
if (this.getDatasetExternalDatasets() != null) {
this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
} else {
this.setDatasetExternalDatasets(new HashSet<>());
}
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
}
if (entity.getServices() == null || entity.getServices().size() < 1) {
if (this.getServices() != null) this.getServices().removeAll(this.getServices());
} else {
if (this.getServices() != null) {
this.getServices().removeAll(this.getServices());
} else {
this.setServices(new HashSet<>());
}
this.getServices().addAll(entity.getServices().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
}
this.setRegistries(entity.getRegistries());
this.getServices().removeAll(this.getServices());
if (entity.getServices() != null)
this.getServices().addAll(entity.getServices());
this.setDmp(entity.getDmp());
this.setStatus(entity.getStatus());
this.setProfile(entity.getProfile());