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
|
@ -25,14 +25,14 @@ import eu.trentorise.opendata.jackan.model.CkanResource;
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
public interface DataCatalogue {
|
public interface DataCatalogue {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the statistics for this catalogue
|
* Returns the statistics for this catalogue
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
Statistics getStatistics() throws Exception;
|
Statistics getStatistics() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the main landing pages for this catalogue (i.e. type, orgs, groups and items pages)
|
* Returns the main landing pages for this catalogue (i.e. type, orgs, groups and items pages)
|
||||||
* @return
|
* @return
|
||||||
|
@ -67,7 +67,7 @@ public interface DataCatalogue {
|
||||||
* @return a list of groups
|
* @return a list of groups
|
||||||
*/
|
*/
|
||||||
List<CkanGroup> getGroupsByUser(String username);
|
List<CkanGroup> getGroupsByUser(String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a group given its name
|
* Returns a group given its name
|
||||||
* @return return a {@link CkanGroup} or null if no group with this name exists
|
* @return return a {@link CkanGroup} or null if no group with this name exists
|
||||||
|
@ -203,8 +203,8 @@ public interface DataCatalogue {
|
||||||
String createCKanDatasetMultipleCustomFields(String apiKey, String title, String name, String organizationNameOrId, String author,
|
String createCKanDatasetMultipleCustomFields(String apiKey, String title, String name, String organizationNameOrId, String author,
|
||||||
String authorMail, String maintainer, String maintainerMail, long version, String description, String licenseId,
|
String authorMail, String maintainer, String maintainerMail, long version, String description, String licenseId,
|
||||||
List<String> tags, Map<String, List<String>> customFields, List<ResourceBean> resources, boolean setPublic) throws Exception;
|
List<String> tags, Map<String, List<String>> customFields, List<ResourceBean> resources, boolean setPublic) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a dataset with those information. The method allows to have multiple values for the same custom field key.
|
* Update a dataset with those information. The method allows to have multiple values for the same custom field key.
|
||||||
* @param apiKey
|
* @param apiKey
|
||||||
|
@ -402,7 +402,7 @@ public interface DataCatalogue {
|
||||||
*/
|
*/
|
||||||
boolean assignDatasetToGroup(String groupNameOrId, String datasetNameOrId,
|
boolean assignDatasetToGroup(String groupNameOrId, String datasetNameOrId,
|
||||||
String apiKey);
|
String apiKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a dataset to a group and the group's parents (if any)
|
* Assign a dataset to a group and the group's parents (if any)
|
||||||
* @param groupNameOrId the id or the name of the destination group.
|
* @param groupNameOrId the id or the name of the destination group.
|
||||||
|
@ -440,7 +440,7 @@ public interface DataCatalogue {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
CkanDataset getDataset(String datasetId, String apiKey);
|
CkanDataset getDataset(String datasetId, String apiKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a ckan dataset given its id. The CkanClient is used, without api key. The result
|
* Retrieve a ckan dataset given its id. The CkanClient is used, without api key. The result
|
||||||
* is null also when the dataset is private.
|
* is null also when the dataset is private.
|
||||||
|
@ -491,16 +491,16 @@ public interface DataCatalogue {
|
||||||
*/
|
*/
|
||||||
boolean patchResource(String resourceId, String url, String name, String description, String urlType, String apiKey);
|
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 customFieldsToChange.
|
||||||
* Patch a product with product id productId by using the couples in toChange.
|
|
||||||
* NOTE: only the specified custom fields will be changed. If a custom field with a given key
|
* 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 productId
|
||||||
* @param apiKey
|
* @param apiKey
|
||||||
* @param toChange
|
* @param customFieldsToChange
|
||||||
* @return true on success, false otherwise
|
* @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.
|
* 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.
|
||||||
|
@ -604,13 +604,13 @@ public interface DataCatalogue {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Map<CkanOrganization, RolesCkanGroupOrOrg>>getUserRoleByOrganization(String username, String apiKey);
|
Map<String, Map<CkanOrganization, RolesCkanGroupOrOrg>>getUserRoleByOrganization(String username, String apiKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the users of the current context need to be alerted from a post creation or not. Default is false.
|
* Check if the users of the current context need to be alerted from a post creation or not. Default is false.
|
||||||
* @return a boolean value
|
* @return a boolean value
|
||||||
*/
|
*/
|
||||||
boolean isNotificationToUsersEnabled();
|
boolean isNotificationToUsersEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the user identified by username has to be registered in other organizations with some role.
|
* Check if the user identified by username has to be registered in other organizations with some role.
|
||||||
* @param username
|
* @param username
|
||||||
|
@ -618,7 +618,7 @@ public interface DataCatalogue {
|
||||||
* @param currentRole
|
* @param currentRole
|
||||||
*/
|
*/
|
||||||
void assignRolesOtherOrganization(String username, String sourceOrganization, RolesCkanGroupOrOrg currentRole);
|
void assignRolesOtherOrganization(String username, String sourceOrganization, RolesCkanGroupOrOrg currentRole);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a package through Solr
|
* Search for a package through Solr
|
||||||
* @param apiKey
|
* @param apiKey
|
||||||
|
@ -628,7 +628,7 @@ public interface DataCatalogue {
|
||||||
* @return a list of matching datasets
|
* @return a list of matching datasets
|
||||||
*/
|
*/
|
||||||
List<CkanDataset> searchForPackage(String apiKey, String query, int start, int offset) throws Exception;
|
List<CkanDataset> searchForPackage(String apiKey, String query, int start, int offset) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a package through Solr in a given organization
|
* Search for a package through Solr in a given organization
|
||||||
* @param apiKey
|
* @param apiKey
|
||||||
|
@ -638,13 +638,13 @@ public interface DataCatalogue {
|
||||||
* @return a list of matching datasets
|
* @return a list of matching datasets
|
||||||
*/
|
*/
|
||||||
List<CkanDataset> searchForPackageInOrganization(String apiKey, String query, int start, int offset, String organization) throws Exception;
|
List<CkanDataset> searchForPackageInOrganization(String apiKey, String query, int start, int offset, String organization) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the catalogue email
|
* Retrieve the catalogue email
|
||||||
* @return an email address for sending email to this catalogue
|
* @return an email address for sending email to this catalogue
|
||||||
*/
|
*/
|
||||||
String getCatalogueEmail();
|
String getCatalogueEmail();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a resource by id
|
* Retrieve a resource by id
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1886,7 +1886,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CkanResource getResource(String id, String apiKey) {
|
public CkanResource getResource(String id, String apiKey) {
|
||||||
logger.info("Request ckan resource with id " + id);
|
logger.info("Request ckan resource with id " + id);
|
||||||
|
@ -2095,7 +2095,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean patchProductCustomFields(String productId, String apiKey,
|
public boolean patchProductCustomFields(String productId, String apiKey,
|
||||||
Map<String, List<String>> customFieldsToChange) {
|
Map<String, List<String>> customFieldsToChange, boolean removeOld) {
|
||||||
|
|
||||||
// checks
|
// checks
|
||||||
checkNotNull(productId);
|
checkNotNull(productId);
|
||||||
|
@ -2144,7 +2144,8 @@ public class DataCatalogueImpl implements DataCatalogue{
|
||||||
Set<String> uniqueValues = new HashSet<String>();
|
Set<String> uniqueValues = new HashSet<String>();
|
||||||
|
|
||||||
if(fromCKANCustomFields.containsKey(key))
|
if(fromCKANCustomFields.containsKey(key))
|
||||||
uniqueValues.addAll(fromCKANCustomFields.get(key));
|
if(!removeOld)
|
||||||
|
uniqueValues.addAll(fromCKANCustomFields.get(key));
|
||||||
|
|
||||||
uniqueValues.addAll(newValues);
|
uniqueValues.addAll(newValues);
|
||||||
fromCKANCustomFields.put(key, new ArrayList<String>(uniqueValues));
|
fromCKANCustomFields.put(key, new ArrayList<String>(uniqueValues));
|
||||||
|
@ -2938,7 +2939,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
||||||
|
|
||||||
int numGroups = getGroups().size();
|
int numGroups = getGroups().size();
|
||||||
int numOrganizations = getOrganizationsNames().size();
|
int numOrganizations = getOrganizationsNames().size();
|
||||||
|
|
||||||
logger.debug("SOLR address is " + SOLR_URL);
|
logger.debug("SOLR address is " + SOLR_URL);
|
||||||
HttpSolrServer solr = new HttpSolrServer(SOLR_URL);
|
HttpSolrServer solr = new HttpSolrServer(SOLR_URL);
|
||||||
|
|
||||||
|
@ -2983,13 +2984,13 @@ public class DataCatalogueImpl implements DataCatalogue{
|
||||||
stats.setNumItems(numItems);
|
stats.setNumItems(numItems);
|
||||||
stats.setNumOrganizations(numOrganizations);
|
stats.setNumOrganizations(numOrganizations);
|
||||||
stats.setNumTypes(numTypes);
|
stats.setNumTypes(numTypes);
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LandingPages getLandingPages() throws Exception {
|
public LandingPages getLandingPages() throws Exception {
|
||||||
|
|
||||||
LandingPages landingPages = new LandingPages();
|
LandingPages landingPages = new LandingPages();
|
||||||
landingPages.setUrlGroups(PORTLET_URL_FOR_SCOPE + "?path=/group/");
|
landingPages.setUrlGroups(PORTLET_URL_FOR_SCOPE + "?path=/group/");
|
||||||
landingPages.setUrlItems(PORTLET_URL_FOR_SCOPE + "?path=/dataset/");
|
landingPages.setUrlItems(PORTLET_URL_FOR_SCOPE + "?path=/dataset/");
|
||||||
|
@ -3000,9 +3001,9 @@ public class DataCatalogueImpl implements DataCatalogue{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCatalogueEmail() {
|
public String getCatalogueEmail() {
|
||||||
|
|
||||||
return CKAN_EMAIL;
|
return CKAN_EMAIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -440,7 +440,7 @@ public class TestDataCatalogueLib {
|
||||||
DataCatalogueImpl instance = factory.getUtilsPerScope(scope);
|
DataCatalogueImpl instance = factory.getUtilsPerScope(scope);
|
||||||
Map<String, List<String>> customFieldsToChange = new HashMap<String, List<String>>();
|
Map<String, List<String>> customFieldsToChange = new HashMap<String, List<String>>();
|
||||||
customFieldsToChange.put("Status", Arrays.asList("Pending"));
|
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
|
//@Test
|
||||||
|
|
Loading…
Reference in New Issue