fixed retrieval of Categories

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/catalogue-ws@147214 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-04-27 08:59:01 +00:00
parent 9dabe607e2
commit e387f21c8a
1 changed files with 19 additions and 5 deletions

View File

@ -42,11 +42,11 @@ import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory;
import org.gcube.datacatalogue.metadatadiscovery.DataCalogueMetadataFormatReader;
import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataProfile;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.DataType;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataCategory;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataField;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataGrouping;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataTagging;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.NamespaceCategory;
import org.geojson.GeoJsonObject;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
@ -191,6 +191,20 @@ public class CatalogueUtils {
return xmlToReturn;
}
/**
* Returns the categories.
* @param context
* @return
* @throws Exception
*/
public static List<NamespaceCategory> getNamespaceCategories() throws Exception{
DataCalogueMetadataFormatReader
reader = new DataCalogueMetadataFormatReader();
return reader.getListOfNamespaceCategories();
}
/**
* Returns the metadataform of the metadata profile (specified via name) in a given context
@ -383,7 +397,7 @@ public class CatalogueUtils {
for (String profileName : profiles) {
profile = getMetadataProfile(profileName);
if(profile.getMetadataType().equals(metadataTypeCF.getValue())){
if(profile.getType().equals(metadataTypeCF.getValue())){
profileNameMatched = profileName;
break;
}
@ -404,13 +418,13 @@ public class CatalogueUtils {
else{
extrasArrayUpdated = new JSONArray();
List<MetadataCategory> categories = profile.getMetadataCategories();
List<NamespaceCategory> categories = getNamespaceCategories();
List<String> categoriesIds = new ArrayList<String>(categories.size());
if(categories == null)
logger.warn("No category defined into profile " + profileNameMatched);
else{
for (MetadataCategory metadataCategory : categories) {
for (NamespaceCategory metadataCategory : categories) {
categoriesIds.add(metadataCategory.getId()); // save them later for matching with custom fields
// there is no longer need to submit the categories' JSON information
// JSONObject catJsonObj = new JSONObject();
@ -522,7 +536,7 @@ public class CatalogueUtils {
JSONArray tagsArrayOriginal,
JSONArray groupsArrayOriginal,
MetadataField metadataField,
List<MetadataCategory> categories,
List<NamespaceCategory> categories,
Map<String, Integer> fieldsMandatoryLowerBoundMap,
Map<String, Integer> fieldsMandatoryUpperBoundMap,
Map<String, Integer> numberFieldsSameKeyMap) throws Exception {