minor fix
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@163065 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e9122ea2a8
commit
6d8c9a22bb
|
@ -491,16 +491,16 @@ public interface DataCatalogue {
|
|||
*/
|
||||
boolean patchResource(String resourceId, String url, String name, String description, String urlType, String apiKey);
|
||||
|
||||
/**
|
||||
* Patch a product with product id productId by using the couples in toChange.
|
||||
/** Patch a product with product id productId by using the couples in customFieldsToChange.
|
||||
* NOTE: only the specified custom fields will be changed. If a custom field with a given key
|
||||
* already exists, the new values are added at the end of the list.
|
||||
* already exists, and removeOld is set to false, the new values are added at the end of the list. Otherwise they are lost.
|
||||
* @param productId
|
||||
* @param apiKey
|
||||
* @param toChange
|
||||
* @return true on success, false otherwise
|
||||
* @param customFieldsToChange
|
||||
* @param removeOld
|
||||
* @return
|
||||
*/
|
||||
boolean patchProductCustomFields(String productId, String apiKey, Map<String, List<String>> customFieldsToChange);
|
||||
boolean patchProductCustomFields(String productId, String apiKey, Map<String, List<String>> customFieldsToChange, boolean removeOld);
|
||||
|
||||
/**
|
||||
* Remove a custom field in the product that has a given key and value. If more than ones are present, the first one is removed.
|
||||
|
|
|
@ -2095,7 +2095,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
|
||||
@Override
|
||||
public boolean patchProductCustomFields(String productId, String apiKey,
|
||||
Map<String, List<String>> customFieldsToChange) {
|
||||
Map<String, List<String>> customFieldsToChange, boolean removeOld) {
|
||||
|
||||
// checks
|
||||
checkNotNull(productId);
|
||||
|
@ -2144,7 +2144,8 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
Set<String> uniqueValues = new HashSet<String>();
|
||||
|
||||
if(fromCKANCustomFields.containsKey(key))
|
||||
uniqueValues.addAll(fromCKANCustomFields.get(key));
|
||||
if(!removeOld)
|
||||
uniqueValues.addAll(fromCKANCustomFields.get(key));
|
||||
|
||||
uniqueValues.addAll(newValues);
|
||||
fromCKANCustomFields.put(key, new ArrayList<String>(uniqueValues));
|
||||
|
|
|
@ -440,7 +440,7 @@ public class TestDataCatalogueLib {
|
|||
DataCatalogueImpl instance = factory.getUtilsPerScope(scope);
|
||||
Map<String, List<String>> customFieldsToChange = new HashMap<String, List<String>>();
|
||||
customFieldsToChange.put("Status", Arrays.asList("Pending"));
|
||||
instance.patchProductCustomFields("a-test-to-ignore", instance.getApiKeyFromUsername("costantino_perciante"), customFieldsToChange);
|
||||
instance.patchProductCustomFields("a-test-to-ignore", instance.getApiKeyFromUsername("costantino_perciante"), customFieldsToChange, false);
|
||||
}
|
||||
|
||||
//@Test
|
||||
|
|
Loading…
Reference in New Issue