Fixed check on controlled vocabulary

This commit is contained in:
Luca Frosini 2021-02-17 17:30:25 +01:00
parent 878b5cfae9
commit 243cae757f
1 changed files with 9 additions and 1 deletions

View File

@ -23,6 +23,7 @@ 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.MetadataVocabulary;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.NamespaceCategory;
import org.gcube.gcat.persistence.ckan.CKANGroup;
import org.gcube.gcat.persistence.ckan.CKANPackage;
@ -465,7 +466,14 @@ public class Validator {
DataType dataType = metadataField.getDataType();
String regex = metadataField.getValidator() != null ? metadataField.getValidator().getRegularExpression()
: null;
boolean hasControlledVocabulary = metadataField.getVocabulary() != null;
boolean hasControlledVocabulary = false;
MetadataVocabulary metadataVocabulary = metadataField.getVocabulary();
if(metadataVocabulary!=null) {
List<String> vocabularyFields = metadataVocabulary.getVocabularyFields();
if(vocabularyFields!=null && vocabularyFields.size()>0) {
hasControlledVocabulary = true;
}
}
String value = fieldToValidate.getValue();
String key = fieldToValidate.getKey();
String defaultValue = metadataField.getDefaultValue();