added shared classes

This commit is contained in:
Francesco Mangiacrapa 2020-09-30 16:49:28 +02:00
parent ca36a05919
commit 45bd3c10b2
10 changed files with 1164 additions and 2 deletions

View File

@ -0,0 +1,402 @@
package org.gcube.portlets.widgets.mpformbuilder.server;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBException;
import org.gcube.common.metadataprofilediscovery.MetadataProfileReader;
import org.gcube.common.metadataprofilediscovery.bean.MetadataProfile;
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataField;
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataFormat;
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataGrouping;
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataTagging;
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataValidator;
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataVocabulary;
import org.gcube.common.metadataprofilediscovery.jaxb.NamespaceCategory;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.FieldAsGroup;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.FieldAsTag;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.TaggingGroupingValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class MetadataDiscovery.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 30, 2020
*/
public class MetadataDiscovery {
private static final Logger logger = LoggerFactory.getLogger(MetadataDiscovery.class);
/**
* Gets the profiles names.
*
* @param scope the scope
* @param genericResourceSecondaryType the generic resource secondary type in
* which discover "gCube Metadata Profiles"
* @return the profiles names
* @throws Exception the exception
*/
public static List<String> getProfilesNames(String scope, String genericResourceSecondaryType) throws Exception {
String currentContext = ScopeProvider.instance.get();
try {
ScopeProvider.instance.set(scope);
List<String> toReturn = new ArrayList<String>();
MetadataProfileReader reader = new MetadataProfileReader(genericResourceSecondaryType);
List<MetadataProfile> listProfiles = reader.getListOfMetadataProfiles();
if (listProfiles != null && !listProfiles.isEmpty()) {
for (MetadataProfile profile : listProfiles) {
toReturn.add(profile.getName());
}
}
return toReturn;
} catch (Exception e) {
logger.error("Failed to fetch profiles", e);
} finally {
ScopeProvider.instance.set(currentContext);
}
return null;
}
/**
* Gets the metadata profiles list.
*
* @param scope the scope
* @param gRSecondaryType the g R secondary type
* @return the metadata profiles list
* @throws Exception the exception
*/
public static List<MetaDataProfileBean> getMetadataProfilesList(String scope, String gRSecondaryType)
throws Exception {
List<MetaDataProfileBean> beans = new ArrayList<MetaDataProfileBean>();
logger.debug("Discovering into scope " + scope);
String currentContext = ScopeProvider.instance.get();
try {
ScopeProvider.instance.set(scope);
// TODO two reset methods could be added to force the reader to read again these
// information (after a while)
MetadataProfileReader reader = new MetadataProfileReader(gRSecondaryType);
List<MetadataProfile> profiles = reader.getListOfMetadataProfiles();
logger.debug("Profiles are " + profiles);
List<NamespaceCategory> categories = reader.getListOfNamespaceCategories();
if (categories == null)
categories = new ArrayList<NamespaceCategory>();
logger.debug("All Categories are " + categories);
for (MetadataProfile profile : profiles) {
logger.debug(
"Wrapping profile with name " + profile.getName() + " and type " + profile.getMetadataType());
MetadataFormat metadata = reader.getMetadataFormatForMetadataProfile(profile);
MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName());
beans.add(bean);
/*
String type = metadata.getType();
String title = profile.getName();
List<MetadataField> fields = metadata.getMetadataFields();
// we need to wrap the list of metadata and categories
List<MetadataFieldWrapper> fieldsWrapper = new ArrayList<MetadataFieldWrapper>(
fields != null ? fields.size() : 0);
List<CategoryWrapper> categoriesWrapper = new ArrayList<CategoryWrapper>(categories.size());
Map<String, CategoryWrapper> idToCategory = new HashMap<String, CategoryWrapper>(categories.size());
// manage the categories
for (NamespaceCategory category : categories) {
CategoryWrapper categoryWrapped = new CategoryWrapper(category.getId(), category.getTitle(),
category.getDescription());
categoriesWrapper.add(categoryWrapped);
idToCategory.put(category.getId(), categoryWrapped);
}
// also evaluate the fields for each category
Map<String, List<MetadataFieldWrapper>> fieldsPerCategory = new HashMap<String, List<MetadataFieldWrapper>>(
categoriesWrapper.size());
// manage the fields
if (fields != null)
for (MetadataField metadataField : fields) {
MetadataFieldWrapper wrapperObj = new MetadataFieldWrapper();
wrapperObj.setFieldNameFromCategory(metadataField.getCategoryFieldQName());
wrapperObj.setType(DataTypeWrapper.valueOf(metadataField.getDataType().toString()));
wrapperObj.setDefaultValue(metadataField.getDefaultValue());
wrapperObj.setFieldName(metadataField.getFieldName());
wrapperObj.setMandatory(metadataField.getMandatory());
wrapperObj.setNote(metadataField.getNote());
MetadataValidator validator = metadataField.getValidator();
if (validator != null)
wrapperObj.setValidator(validator.getRegularExpression());
MetadataVocabulary vocabulary = metadataField.getVocabulary();
if (vocabulary != null) {
wrapperObj.setVocabulary(vocabulary.getVocabularyFields());
wrapperObj.setMultiSelection(vocabulary.isMultiSelection());
}
MetadataTagging tagging = metadataField.getTagging();
if (tagging != null) {
FieldAsTag tag = new FieldAsTag();
tag.setCreate(tagging.getCreate());
tag.setSeparator(tagging.getSeparator());
tag.setTaggingValue(TaggingGroupingValue.valueOf(tagging.getTaggingValue().toString()));
wrapperObj.setAsTag(tag);
}
MetadataGrouping grouping = metadataField.getGrouping();
if (grouping != null) {
FieldAsGroup group = new FieldAsGroup();
group.setCreate(grouping.getCreate());
group.setPropagateUp(grouping.getPropagateUp());
group.setGroupingValue(
TaggingGroupingValue.valueOf(grouping.getGroupingValue().toString()));
wrapperObj.setAsGroup(group);
}
// set to which category this field belongs to and vice-versa
if (metadataField.getCategoryRef() != null) {
CategoryWrapper ownerCategory = idToCategory.get(metadataField.getCategoryRef());
if (ownerCategory == null) {
logger.warn("A field with categoryref " + metadataField.getCategoryRef()
+ " has been found, but"
+ " such category is not defined within the namespaces");
} else {
wrapperObj.setOwnerCategory(ownerCategory);
List<MetadataFieldWrapper> fieldsPerCategoryN = fieldsPerCategory
.get(metadataField.getCategoryRef());
if (fieldsPerCategoryN == null)
fieldsPerCategoryN = new ArrayList<MetadataFieldWrapper>();
fieldsPerCategoryN.add(wrapperObj);
fieldsPerCategory.put(metadataField.getCategoryRef(), fieldsPerCategoryN);
// instead of re-looping on the fieldsPerCategory map later, just set this
// potentially partial list
ownerCategory.setFieldsForThisCategory(fieldsPerCategoryN);
}
}
// Added by Francesco
int maxOccurs = 1; // Default value is 1. A field should occur once.
if (metadataField.getMaxOccurs() != null) {
try {
// the field can appear an unlimited number of times.
if (metadataField.getMaxOccurs().equals("*")) {
maxOccurs = Integer.MAX_VALUE;
} else {
// the field must appear N times;
maxOccurs = Integer.parseInt(metadataField.getMaxOccurs());
}
} catch (Exception e) {
// silent
}
wrapperObj.setMaxOccurs(maxOccurs);
}
fieldsWrapper.add(wrapperObj);
}
// filter the categories without children here
Iterator<CategoryWrapper> categoryToRemoveIT = categoriesWrapper.iterator();
while (categoryToRemoveIT.hasNext()) {
CategoryWrapper categoryWrapper = (CategoryWrapper) categoryToRemoveIT.next();
if (categoryWrapper.getFieldsForThisCategory() == null)
categoryToRemoveIT.remove();
}
MetaDataProfileBean bean = new MetaDataProfileBean(type, title, fieldsWrapper, categoriesWrapper);
beans.add(bean);
*/
}
logger.debug("List of beans is " + beans);
} catch (Exception e) {
logger.error("Error while retrieving metadata beans ", e);
throw new Exception("Failed to parse Types: " + e.getMessage());
} finally {
ScopeProvider.instance.set(currentContext);
}
return beans;
}
/**
* Gets the metadata profiles.
*
* @param metadataProfileStream the metadata profile stream
* @return the metadata profiles
* @throws JAXBException the JAXB exception
*/
public MetaDataProfileBean getMetadataProfiles(InputStream metadataProfileStream) throws JAXBException {
MetadataFormat metadata = MetadataProfileReader.toMetadataFormat(metadataProfileStream);
return toMetaDataProfileBean(metadata, null, null);
}
private static MetaDataProfileBean toMetaDataProfileBean(MetadataFormat metadata, List<NamespaceCategory> categories, String profileName){
String type = metadata.getType();
String title = profileName!=null?profileName:type;
List<MetadataField> fields = metadata.getMetadataFields();
// we need to wrap the list of metadata and categories
List<MetadataFieldWrapper> fieldsWrapper = new ArrayList<MetadataFieldWrapper>(
fields != null ? fields.size() : 0);
List<CategoryWrapper> categoriesWrapper = new ArrayList<CategoryWrapper>(categories.size());
Map<String, CategoryWrapper> idToCategory = new HashMap<String, CategoryWrapper>(categories.size());
// manage the categories
for (NamespaceCategory category : categories) {
CategoryWrapper categoryWrapped = new CategoryWrapper(category.getId(), category.getTitle(),
category.getDescription());
categoriesWrapper.add(categoryWrapped);
idToCategory.put(category.getId(), categoryWrapped);
}
// also evaluate the fields for each category
Map<String, List<MetadataFieldWrapper>> fieldsPerCategory = new HashMap<String, List<MetadataFieldWrapper>>(
categoriesWrapper.size());
// manage the fields
if (fields != null)
for (MetadataField metadataField : fields) {
MetadataFieldWrapper wrapperObj = new MetadataFieldWrapper();
wrapperObj.setFieldNameFromCategory(metadataField.getCategoryFieldQName());
wrapperObj.setType(DataTypeWrapper.valueOf(metadataField.getDataType().toString()));
wrapperObj.setDefaultValue(metadataField.getDefaultValue());
wrapperObj.setFieldName(metadataField.getFieldName());
wrapperObj.setMandatory(metadataField.getMandatory());
wrapperObj.setNote(metadataField.getNote());
MetadataValidator validator = metadataField.getValidator();
if (validator != null)
wrapperObj.setValidator(validator.getRegularExpression());
MetadataVocabulary vocabulary = metadataField.getVocabulary();
if (vocabulary != null) {
wrapperObj.setVocabulary(vocabulary.getVocabularyFields());
wrapperObj.setMultiSelection(vocabulary.isMultiSelection());
}
MetadataTagging tagging = metadataField.getTagging();
if (tagging != null) {
FieldAsTag tag = new FieldAsTag();
tag.setCreate(tagging.getCreate());
tag.setSeparator(tagging.getSeparator());
tag.setTaggingValue(TaggingGroupingValue.valueOf(tagging.getTaggingValue().toString()));
wrapperObj.setAsTag(tag);
}
MetadataGrouping grouping = metadataField.getGrouping();
if (grouping != null) {
FieldAsGroup group = new FieldAsGroup();
group.setCreate(grouping.getCreate());
group.setPropagateUp(grouping.getPropagateUp());
group.setGroupingValue(
TaggingGroupingValue.valueOf(grouping.getGroupingValue().toString()));
wrapperObj.setAsGroup(group);
}
// set to which category this field belongs to and vice-versa
if (metadataField.getCategoryRef() != null) {
CategoryWrapper ownerCategory = idToCategory.get(metadataField.getCategoryRef());
if (ownerCategory == null) {
logger.warn("A field with categoryref " + metadataField.getCategoryRef()
+ " has been found, but"
+ " such category is not defined within the namespaces");
} else {
wrapperObj.setOwnerCategory(ownerCategory);
List<MetadataFieldWrapper> fieldsPerCategoryN = fieldsPerCategory
.get(metadataField.getCategoryRef());
if (fieldsPerCategoryN == null)
fieldsPerCategoryN = new ArrayList<MetadataFieldWrapper>();
fieldsPerCategoryN.add(wrapperObj);
fieldsPerCategory.put(metadataField.getCategoryRef(), fieldsPerCategoryN);
// instead of re-looping on the fieldsPerCategory map later, just set this
// potentially partial list
ownerCategory.setFieldsForThisCategory(fieldsPerCategoryN);
}
}
// Added by Francesco
int maxOccurs = 1; // Default value is 1. A field should occur once.
if (metadataField.getMaxOccurs() != null) {
try {
// the field can appear an unlimited number of times.
if (metadataField.getMaxOccurs().equals("*")) {
maxOccurs = Integer.MAX_VALUE;
} else {
// the field must appear N times;
maxOccurs = Integer.parseInt(metadataField.getMaxOccurs());
}
} catch (Exception e) {
// silent
}
wrapperObj.setMaxOccurs(maxOccurs);
}
fieldsWrapper.add(wrapperObj);
}
// filter the categories without children here
Iterator<CategoryWrapper> categoryToRemoveIT = categoriesWrapper.iterator();
while (categoryToRemoveIT.hasNext()) {
CategoryWrapper categoryWrapper = (CategoryWrapper) categoryToRemoveIT.next();
if (categoryWrapper.getFieldsForThisCategory() == null)
categoryToRemoveIT.remove();
}
return new MetaDataProfileBean(type, title, fieldsWrapper, categoriesWrapper);
}
}

View File

@ -0,0 +1,50 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.license;
import java.io.Serializable;
/**
* A license bean like the ckan's one.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class LicenseBean implements Serializable{
private static final long serialVersionUID = -2079275598877326206L;
private String title;
private String url;
public LicenseBean() {
super();
}
public LicenseBean(String title, String url) {
super();
this.title = title;
this.url = url;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public boolean equals(Object obj) {
return obj.getClass().equals(this.getClass()) && ((LicenseBean)obj).getTitle().equals(this.title);
}
@Override
public String toString() {
return "LicenseBean [title=" + title + ", url=" + url + "]";
}
}

View File

@ -0,0 +1,75 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.io.Serializable;
import java.util.List;
/**
* A wrapper for the MetadataCategory class.
* @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataCategory
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class CategoryWrapper implements Serializable{
private static final long serialVersionUID = -1949961285656672831L;
private String id;
private String title;
private String description;
private List<MetadataFieldWrapper> fieldsForThisCategory;
public CategoryWrapper() {
super();
}
public CategoryWrapper(String id, String title, String description) {
super();
this.id = id;
this.title = title;
this.description = description;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<MetadataFieldWrapper> getFieldsForThisCategory() {
return fieldsForThisCategory;
}
public void setFieldsForThisCategory(
List<MetadataFieldWrapper> fieldsForThisCategory) {
this.fieldsForThisCategory = fieldsForThisCategory;
}
@Override
public String toString() {
return "CategoryWrapper ["
+ (id != null ? "id=" + id + ", " : "")
+ (title != null ? "title=" + title + ", " : "")
+ (description != null ? "description=" + description + ", "
: "")
+ (fieldsForThisCategory != null ? "fieldsForThisCategory="
+ fieldsForThisCategory.size() : "") + "]";
}
}

View File

@ -0,0 +1,26 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
/**
* Data type.
* @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.DataType
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public enum DataTypeWrapper {
String,
Time,
Time_Interval,
Times_ListOf,
Text,
Boolean,
Number,
GeoJSON;
/**
* Value as String.
* @return the string
*/
public String value() {
return name();
}
}

View File

@ -0,0 +1,60 @@
/**
*
*/
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.io.Serializable;
/**
* To be used when a field must be used to create a group.
* @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataGrouping
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class FieldAsGroup implements Serializable{
private static final long serialVersionUID = 8096886403417944385L;
private boolean create;
private boolean isPropagateUp;
private TaggingGroupingValue groupingValue;
public FieldAsGroup() {
super();
}
public FieldAsGroup(boolean create, TaggingGroupingValue groupingValue, boolean isPropagateUp) {
this.isPropagateUp = isPropagateUp;
this.create = create;
this.groupingValue = groupingValue;
}
public boolean getCreate() {
return create;
}
public void setCreate(Boolean create) {
this.create = create;
}
public TaggingGroupingValue getGroupingValue() {
return groupingValue;
}
public void setGroupingValue(TaggingGroupingValue groupingValue) {
this.groupingValue = groupingValue;
}
public boolean isPropagateUp() {
return isPropagateUp;
}
public void setPropagateUp(boolean isPropagateUp) {
this.isPropagateUp = isPropagateUp;
}
@Override
public String toString() {
return "FieldAsGroup [create=" + create + ", isPropagateUp="
+ isPropagateUp + ", groupingValue=" + groupingValue + "]";
}
}

View File

@ -0,0 +1,60 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.io.Serializable;
/**
* To be used when a field must be used to create a tag.
* @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataTagging
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class FieldAsTag implements Serializable{
private static final long serialVersionUID = 5414077853964288094L;
public static final String DEFAULT_SEPARATOR = "-";
private boolean create;
private String separator = DEFAULT_SEPARATOR;
private TaggingGroupingValue taggingValue;
public FieldAsTag() {
super();
}
public FieldAsTag(Boolean create, String separator, TaggingGroupingValue taggingValue) {
super();
this.create = create;
this.separator = separator;
this.taggingValue = taggingValue;
}
public boolean isCreate() {
return create;
}
public void setCreate(boolean create) {
this.create = create;
}
public String getSeparator() {
return separator;
}
public void setSeparator(String separator) {
this.separator = separator;
}
public TaggingGroupingValue getTaggingValue() {
return taggingValue;
}
public void setTaggingValue(TaggingGroupingValue taggingValue) {
this.taggingValue = taggingValue;
}
@Override
public String toString() {
return "FieldAsTag [create=" + create + ", separator=" + separator
+ ", taggingValue=" + taggingValue + "]";
}
}

View File

@ -0,0 +1,86 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.io.Serializable;
import java.util.List;
/**
* A MetaDataProfileBean with its children (MetaDataType, MetaDataFields, Categories)
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class MetaDataProfileBean implements Serializable{
private static final long serialVersionUID = -7377022025375553568L;
private String type;
private String title;
private List<CategoryWrapper> categories;
private List<MetadataFieldWrapper> metadataFields;
public MetaDataProfileBean(){
super();
}
public MetaDataProfileBean(String type,
String title,
List<MetadataFieldWrapper> metadataFields,
List<CategoryWrapper> categories) {
super();
this.type = type;
this.title = title;
this.categories = categories;
this.metadataFields = metadataFields;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the metadataFields
*/
public List<MetadataFieldWrapper> getMetadataFields() {
return metadataFields;
}
/**
* @param metadataFields the metadataFields to set
*/
public void setMetadataFields(List<MetadataFieldWrapper> metadataFields) {
this.metadataFields = metadataFields;
}
public List<CategoryWrapper> getCategories() {
return categories;
}
public void setCategories(List<CategoryWrapper> categories) {
this.categories = categories;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
final int maxLen = 10;
return "MetaDataProfileBean [type="
+ type
+ ", title="
+ title
+ ", categories="
+ (categories != null ? categories.subList(0,
Math.min(categories.size(), maxLen)) : null)
+ ", metadataFields="
+ (metadataFields != null ? metadataFields.subList(0,
Math.min(metadataFields.size(), maxLen)) : null) + "]";
}
}

View File

@ -0,0 +1,339 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.io.Serializable;
import java.util.List;
/**
* The Class MetadataFieldWrapper.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*
* @author francesco-mangiacrapa at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class MetadataFieldWrapper implements Serializable{
private static final long serialVersionUID = -8476731365884466698L;
private String fieldName;
private String fieldNameFromCategory;
private Boolean mandatory = false;
private DataTypeWrapper type;
private String defaultValue;
private String note;
private List<String> vocabulary;
private boolean multiSelection;
private String validator;
private CategoryWrapper ownerCategory;
private FieldAsGroup asGroup;
private FieldAsTag asTag;
private Integer maxOccurs = 1;
/**
* Instantiates a new metadata field.
*/
public MetadataFieldWrapper() {
super();
}
/**
* Instantiates a new metadata field.
*
* @param fieldName the field name
* @param mandatory the mandatory
* @param type the type
* @param defaultValue the default value
* @param note the note
* @param vocabulary the vocabulary
* @param validator the validator
* @param category the category
*/
public MetadataFieldWrapper(
String fieldName, Boolean mandatory, DataTypeWrapper type,
String defaultValue, String note, List<String> vocabulary,
String validator, CategoryWrapper category) {
super();
this.fieldName = fieldName;
this.mandatory = mandatory;
this.type = type;
this.defaultValue = defaultValue;
this.note = note;
this.vocabulary = vocabulary;
this.validator = validator;
this.ownerCategory = category;
}
/**
* Gets the max occurs.
*
* @return the max occurs
*/
public Integer getMaxOccurs() {
return maxOccurs;
}
/**
* Sets the max occurs.
*
* @param maxOccurs the new max occurs
*/
public void setMaxOccurs(Integer maxOccurs) {
this.maxOccurs = maxOccurs;
}
/**
* Gets the field name.
*
* @return the fieldName
*/
public String getFieldName() {
return fieldName;
}
/**
* Gets the mandatory.
*
* @return the mandatory
*/
public Boolean getMandatory() {
return mandatory;
}
/**
* Gets the defaul value.
*
* @return the defaulValue
*/
public String getDefaultValue() {
return defaultValue;
}
/**
* Gets the note.
*
* @return the note
*/
public String getNote() {
return note;
}
/**
* Gets the vocabulary.
*
* @return the vocabulary
*/
public List<String> getVocabulary() {
return vocabulary;
}
/**
* Gets the validator.
*
* @return the validator
*/
public String getValidator() {
return validator;
}
/**
* Sets the field name.
*
* @param fieldName the fieldName to set
*/
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
/**
* Sets the mandatory.
*
* @param mandatory the mandatory to set
*/
public void setMandatory(Boolean mandatory) {
this.mandatory = mandatory;
}
/**
* Sets the defaul value.
*
* @param defaultValue the new default value
*/
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
/**
* Sets the note.
*
* @param note the note to set
*/
public void setNote(String note) {
this.note = note;
}
/**
* Sets the vocabulary.
*
* @param vocabulary the vocabulary to set
*/
public void setVocabulary(List<String> vocabulary) {
this.vocabulary = vocabulary;
}
/**
* Sets the validator.
*
* @param validator the validator to set
*/
public void setValidator(String validator) {
this.validator = validator;
}
/**
* Gets the type.
*
* @return the type
*/
public DataTypeWrapper getType() {
return type;
}
/**
* Sets the type.
*
* @param type the new type
*/
public void setType(DataTypeWrapper type) {
this.type = type;
}
/**
* Checks if is multi selection.
*
* @return true, if is multi selection
*/
public boolean isMultiSelection() {
return multiSelection;
}
/**
* Sets the multi selection.
*
* @param multiSelection the new multi selection
*/
public void setMultiSelection(boolean multiSelection) {
this.multiSelection = multiSelection;
}
/**
* Gets the owner category.
*
* @return the owner category
*/
public CategoryWrapper getOwnerCategory() {
return ownerCategory;
}
/**
* Sets the owner category.
*
* @param ownerCategory the new owner category
*/
public void setOwnerCategory(CategoryWrapper ownerCategory) {
this.ownerCategory = ownerCategory;
}
/**
* Gets the field name from category.
*
* @return the field name from category
*/
public String getFieldNameFromCategory() {
return fieldNameFromCategory;
}
/**
* Sets the field name from category.
*
* @param fieldNameFromCategory the new field name from category
*/
public void setFieldNameFromCategory(String fieldNameFromCategory) {
this.fieldNameFromCategory = fieldNameFromCategory;
}
/**
* Gets the as group.
*
* @return the as group
*/
public FieldAsGroup getAsGroup() {
return asGroup;
}
/**
* Sets the as group.
*
* @param asGroup the new as group
*/
public void setAsGroup(FieldAsGroup asGroup) {
this.asGroup = asGroup;
}
/**
* Gets the as tag.
*
* @return the as tag
*/
public FieldAsTag getAsTag() {
return asTag;
}
/**
* Sets the as tag.
*
* @param asTag the new as tag
*/
public void setAsTag(FieldAsTag asTag) {
this.asTag = asTag;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "MetadataFieldWrapper ["
+ (fieldName != null ? "fieldName=" + fieldName + ", " : "")
+ (fieldNameFromCategory != null ? "fieldNameFromCategory="
+ fieldNameFromCategory + ", " : "")
+ (mandatory != null ? "mandatory=" + mandatory + ", " : "")
+ (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "")
+ (type != null ? "type=" + type + ", " : "")
+ (defaultValue != null ? "defaultValue=" + defaultValue + ", "
: "")
+ (note != null ? "note=" + note + ", " : "")
+ (vocabulary != null ? "vocabulary=" + vocabulary + ", " : "")
+ "multiSelection="
+ multiSelection
+ ", "
+ (validator != null ? "validator=" + validator + ", " : "")
+ (ownerCategory != null ? "ownerCategory=" + ownerCategory.getId()
+ ", " : "")
+ (asGroup != null ? "asGroup=" + asGroup + ", " : "")
+ (asTag != null ? "asTag=" + asTag : "") + "]";
}
}

View File

@ -0,0 +1,66 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.util.Arrays;
import java.util.List;
/**
* Specifies the action to take when a tag or a group must be created from a field.
* @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.TaggingGroupingValue
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public enum TaggingGroupingValue {
onFieldName,
onValue,
onFieldName_onValue,
onValue_onFieldName;
/**
* Returns the composed value in case of tag
* @param name
* @param value
* @param separator
* @param action
* @return
*/
public static String getComposedValueTag(String name, String value, String separator, TaggingGroupingValue action){
switch(action){
case onFieldName:
return name;
case onValue:
return value;
case onFieldName_onValue:
return name + separator + value;
case onValue_onFieldName:
return value + separator + name;
default: return null;
}
}
/**
* Returns the composed value in case of group
* @param name
* @param value
* @param separator
* @param action
* @return a list of group names
*/
public static List<String> getComposedValueGroup(String name, String value, TaggingGroupingValue action){
switch(action){
case onFieldName:
return Arrays.asList(name);
case onValue:
return Arrays.asList(value);
case onFieldName_onValue:
case onValue_onFieldName:
return Arrays.asList(value, name);
default: return null;
}
}
}

View File

@ -1,2 +0,0 @@
sendButton = Envoyer
nameField = Entrez votre nom