From 52ba62c31d3b2e933860725c8da92f6aafb0e3d1 Mon Sep 17 00:00:00 2001 From: gakin <gakin> Date: Tue, 7 Mar 2017 11:08:43 +0000 Subject: [PATCH] SSDM-4853 Sync removal of assigned properties for data sets SVN: 37860 --- .../DataSetRegistrationIngestionService.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/DataSetRegistrationIngestionService.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/DataSetRegistrationIngestionService.java index 6fa9b718229..83379ae11e4 100644 --- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/DataSetRegistrationIngestionService.java +++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/DataSetRegistrationIngestionService.java @@ -23,10 +23,12 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import org.apache.log4j.Logger; @@ -139,14 +141,32 @@ class DataSetRegistrationIngestionService extends IngestionService<DataSetInform dataSetForUpdate.setSample(sample); dataSetForUpdate.setExperiment(experiment); dataSetForUpdate.setParentDatasets(dataSet.getParentDataSetCodes()); + List<String> existingPropertyCodes = dataSetForUpdate.getAllPropertyCodes(); + Set<String> newPropertyCodes = extractPropertyNames(dataSetProperties); for (NewProperty newProperty : dataSetProperties) { dataSetForUpdate.setPropertyValue(newProperty.getPropertyCode(), newProperty.getValue()); } + // set the properties that are in the harvester but not in the data source anymore, to "" + existingPropertyCodes.removeAll(newPropertyCodes); + for (String propCode : existingPropertyCodes) + { + dataSetForUpdate.setPropertyValue(propCode, ""); + } } return null; } + private Set<String> extractPropertyNames(List<NewProperty> dataSetProperties) + { + Set<String> existingPropertyNames = new HashSet<String>(); + for (NewProperty prop : dataSetProperties) + { + existingPropertyNames.add(prop.getPropertyCode()); + } + return existingPropertyNames; + } + class FileDetails { final int crc32checksum; -- GitLab