Commit 2958cab1 authored by Georgios Kolokythas's avatar Georgios Kolokythas
Browse files

Refactors how "External Resources" are saved on Dataset.

parent 1b7d1188
Loading
Loading
Loading
Loading
+31 −10
Original line number Diff line number Diff line
@@ -281,19 +281,40 @@ public class Dataset implements DataEntity<Dataset, UUID> {
		this.setLabel(entity.getLabel());
		this.setProperties(entity.getProperties());

		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());
		if (entity.getDatasetDataRepositories() != null)
			this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories());
			} else {
				this.setDatasetDataRepositories(new HashSet<>());
			}
			this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
		}

		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());
		if (entity.getDatasetExternalDatasets() != null)
			this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets());

		this.setRegistries(entity.getRegistries());
			} 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());
		if (entity.getServices() != null)
			this.getServices().addAll(entity.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.setDmp(entity.getDmp());
		this.setStatus(entity.getStatus());