Skip to content
Snippets Groups Projects
Commit 52ba62c3 authored by gakin's avatar gakin
Browse files

SSDM-4853 Sync removal of assigned properties for data sets

SVN: 37860
parent a101f933
No related branches found
No related tags found
No related merge requests found
...@@ -23,10 +23,12 @@ import java.nio.file.Files; ...@@ -23,10 +23,12 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
...@@ -139,14 +141,32 @@ class DataSetRegistrationIngestionService extends IngestionService<DataSetInform ...@@ -139,14 +141,32 @@ class DataSetRegistrationIngestionService extends IngestionService<DataSetInform
dataSetForUpdate.setSample(sample); dataSetForUpdate.setSample(sample);
dataSetForUpdate.setExperiment(experiment); dataSetForUpdate.setExperiment(experiment);
dataSetForUpdate.setParentDatasets(dataSet.getParentDataSetCodes()); dataSetForUpdate.setParentDatasets(dataSet.getParentDataSetCodes());
List<String> existingPropertyCodes = dataSetForUpdate.getAllPropertyCodes();
Set<String> newPropertyCodes = extractPropertyNames(dataSetProperties);
for (NewProperty newProperty : dataSetProperties) for (NewProperty newProperty : dataSetProperties)
{ {
dataSetForUpdate.setPropertyValue(newProperty.getPropertyCode(), newProperty.getValue()); 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; 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 class FileDetails
{ {
final int crc32checksum; final int crc32checksum;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment