Search in sources :

Example 1 with CustomProperties

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;
}
Also used : CSVRecord(org.apache.commons.csv.CSVRecord) PropertyWithValue(org.eclipse.sw360.commonIO.ConvertRecord.PropertyWithValue) CustomProperties(org.eclipse.sw360.datahandler.thrift.CustomProperties)

Aggregations

CSVRecord (org.apache.commons.csv.CSVRecord)1 PropertyWithValue (org.eclipse.sw360.commonIO.ConvertRecord.PropertyWithValue)1 CustomProperties (org.eclipse.sw360.datahandler.thrift.CustomProperties)1