use of org.eclipse.sw360.datahandler.thrift.CustomProperties in project sw360portal by sw360.
the class TypeMappings method getCustomPropertiesWithValuesByIdAndWriteMissingToDatabase.
public static Map<Integer, PropertyWithValue> getCustomPropertiesWithValuesByIdAndWriteMissingToDatabase(LicenseService.Iface licenseClient, InputStream inputStream, User user) throws TException {
List<CSVRecord> records = ImportCSV.readAsCSVRecords(inputStream);
Optional<CustomProperties> dbCustomProperties = CommonUtils.wrapThriftOptionalReplacement(licenseClient.getCustomProperties(SW360Constants.TYPE_TODO));
CustomProperties customProperties;
if (!dbCustomProperties.isPresent()) {
customProperties = new CustomProperties().setDocumentType(SW360Constants.TYPE_TODO);
} else {
customProperties = dbCustomProperties.get();
}
Map<String, Set<String>> propertyToValuesToAdd = ConvertRecord.convertCustomProperties(records);
customProperties.setPropertyToValues(CommonUtils.mergeMapIntoMap(propertyToValuesToAdd, customProperties.getPropertyToValues()));
licenseClient.updateCustomProperties(customProperties, user);
Map<Integer, PropertyWithValue> propertiesWithValuesById = ConvertRecord.convertCustomPropertiesById(records);
return propertiesWithValuesById;
}
Aggregations