From 05c7e92b086bfa2a988299dc272d8879f3dbd2d5 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Fri, 24 Mar 2017 11:43:57 +0000 Subject: [PATCH] added Qualified Name to Metadata Category and Metadata Field Renamed classes git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/gcubedatacatalogue-metadata-discovery@146320 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../DataCalogueMetadataFormatReader.java | 12 +-- .../bean/jaxb/MetadataCategory.java | 12 ++- .../bean/jaxb/MetadataField.java | 80 +++++++++++++++++-- .../bean/jaxb/MetadataFormat.java | 34 -------- ...very.java => MetadataFormatDiscovery.java} | 6 +- ...tReader.java => MetadataFormatReader.java} | 6 +- .../TestMetadataFormatDiscovery.java | 6 +- .../TestMetadataFormatReader.java | 6 +- 8 files changed, 104 insertions(+), 58 deletions(-) rename src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/{MedataFormatDiscovery.java => MetadataFormatDiscovery.java} (96%) rename src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/{MedataFormatReader.java => MetadataFormatReader.java} (97%) diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/DataCalogueMetadataFormatReader.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/DataCalogueMetadataFormatReader.java index 4671f6b..726294d 100644 --- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/DataCalogueMetadataFormatReader.java +++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/DataCalogueMetadataFormatReader.java @@ -8,8 +8,8 @@ import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.impl.ScopeBean; import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType; import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat; -import org.gcube.datacatalogue.metadatadiscovery.reader.MedataFormatDiscovery; -import org.gcube.datacatalogue.metadatadiscovery.reader.MedataFormatReader; +import org.gcube.datacatalogue.metadatadiscovery.reader.MetadataFormatDiscovery; +import org.gcube.datacatalogue.metadatadiscovery.reader.MetadataFormatReader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory; */ public class DataCalogueMetadataFormatReader implements DataCatalogueMetadataDiscovery{ - private MedataFormatDiscovery medataFormatDiscovery; + private MetadataFormatDiscovery medataFormatDiscovery; private final ScopeBean scope; private Map hash = new HashMap(); @@ -43,11 +43,11 @@ public class DataCalogueMetadataFormatReader implements DataCatalogueMetadataDis throw new Exception("Please set a valid scope into ScopeProvider"); scope = new ScopeBean(scopeString); - medataFormatDiscovery = new MedataFormatDiscovery(scope); + medataFormatDiscovery = new MetadataFormatDiscovery(scope); logger.info("MedataFormatDiscovery has retrieved: "+medataFormatDiscovery.getMetadataTypes().size() +" metadata type/s"); logger.debug("filling cache for MedataFormat"); for (MetadataType mT : medataFormatDiscovery.getMetadataTypes()) { - MedataFormatReader reader = new MedataFormatReader(scope, mT.getId()); + MetadataFormatReader reader = new MetadataFormatReader(scope, mT.getId()); hash.put(mT.getId(), reader.getMetadataFormat()); logger.debug("MetadataType id: "+mT.getId() +" cached as: "+reader.getMetadataFormat()); } @@ -75,7 +75,7 @@ public class DataCalogueMetadataFormatReader implements DataCatalogueMetadataDis if(format!=null) return format; - MedataFormatReader reader = new MedataFormatReader(scope, type.getId()); + MetadataFormatReader reader = new MetadataFormatReader(scope, type.getId()); return reader.getMetadataFormat(); } diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataCategory.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataCategory.java index a1fadc3..5c2ded7 100644 --- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataCategory.java +++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataCategory.java @@ -25,6 +25,11 @@ import org.gcube.datacatalogue.metadatadiscovery.MetadataNamespace; @XmlAccessorType (XmlAccessType.FIELD) public class MetadataCategory implements Serializable{ + /** + * + */ + private static final String NAME_ELEMENT_METADATACATEGORY = "metadatacategory"; + /** * */ @@ -125,10 +130,15 @@ public class MetadataCategory implements Serializable{ */ private void setNamespaceCategory() { - this.namespaceCategory = "metadatacategory"+MetadataNamespace.Separator+id; + this.namespaceCategory = NAME_ELEMENT_METADATACATEGORY; } + public String getCategoryQName(){ + + return namespaceCategory+MetadataNamespace.Separator+id; + } + /** * Sets the title. diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataField.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataField.java index a60ad43..5c62ea5 100644 --- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataField.java +++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataField.java @@ -28,12 +28,17 @@ import org.gcube.datacatalogue.metadatadiscovery.adapter.DataTypeAdapter; @XmlAccessorType(XmlAccessType.FIELD) public class MetadataField implements Serializable{ + /** + * + */ + private static final String LOCAL_NAME_CATEGORYREF = "categoryref"; + /** * */ private static final long serialVersionUID = 5935573474465015727L; - @XmlAttribute(name="categoryref") + @XmlAttribute(name=LOCAL_NAME_CATEGORYREF) private String categoryRef = null; @XmlElement(required = true) private String fieldName; @@ -69,8 +74,10 @@ public class MetadataField implements Serializable{ } /** - * @param fieldName - * @param mandatory + * Instantiates a new metadata field. + * + * @param fieldName the field name + * @param mandatory the mandatory */ public MetadataField(String fieldName, Boolean mandatory) { @@ -82,6 +89,8 @@ public class MetadataField implements Serializable{ /** + * Gets the category ref. + * * @return the categoryRef */ public String getCategoryRef() { @@ -91,6 +100,8 @@ public class MetadataField implements Serializable{ /** + * Sets the category ref. + * * @param categoryRef the categoryRef to set */ public void setCategoryRef(String categoryRef) { @@ -100,16 +111,18 @@ public class MetadataField implements Serializable{ } /** - * + * Sets the namespace field to category ref. */ private void setNamespaceFieldToCategoryRef() { - this.namespaceFieldToCategoryReference = "categoryref"+MetadataNamespace.Separator+categoryRef+MetadataNamespace.Separator+fieldName; + this.namespaceFieldToCategoryReference = LOCAL_NAME_CATEGORYREF+MetadataNamespace.Separator+categoryRef; } /** + * Gets the namespace field to category reference. + * * @return the namespaceFieldToCategoryReference */ public String getNamespaceFieldToCategoryReference() { @@ -118,7 +131,25 @@ public class MetadataField implements Serializable{ } + /** + * Gets the category field qualified name. + * + * If the Metadata Field belongs to a category returns the qualified name: {@link MetadataField#LOCAL_NAME_CATEGORYREF} {@link MetadataNamespace#Separator}} fieldName; + * Otherwise returns the fieldName + * + * @return the category q name + */ + public String getCategoryFieldQName(){ + + return namespaceFieldToCategoryReference==null?fieldName:namespaceFieldToCategoryReference+MetadataNamespace.Separator+fieldName; + + } + + + /** + * Gets the field name. + * * @return the fieldName */ public String getFieldName() { @@ -128,6 +159,8 @@ public class MetadataField implements Serializable{ /** + * Gets the mandatory. + * * @return the mandatory */ public Boolean getMandatory() { @@ -137,6 +170,8 @@ public class MetadataField implements Serializable{ /** + * Gets the data type. + * * @return the dataType */ public DataType getDataType() { @@ -146,6 +181,8 @@ public class MetadataField implements Serializable{ /** + * Gets the default value. + * * @return the defaultValue */ public String getDefaultValue() { @@ -155,6 +192,8 @@ public class MetadataField implements Serializable{ /** + * Gets the note. + * * @return the note */ public String getNote() { @@ -164,6 +203,8 @@ public class MetadataField implements Serializable{ /** + * Gets the vocabulary. + * * @return the vocabulary */ public MetadataVocabulary getVocabulary() { @@ -173,6 +214,8 @@ public class MetadataField implements Serializable{ /** + * Gets the validator. + * * @return the validator */ public MetadataValidator getValidator() { @@ -182,6 +225,8 @@ public class MetadataField implements Serializable{ /** + * Gets the tagging. + * * @return the tagging */ public MetadataTagging getTagging() { @@ -191,6 +236,8 @@ public class MetadataField implements Serializable{ /** + * Gets the grouping. + * * @return the grouping */ public MetadataGrouping getGrouping() { @@ -200,6 +247,8 @@ public class MetadataField implements Serializable{ /** + * Sets the field name. + * * @param fieldName the fieldName to set */ public void setFieldName(String fieldName) { @@ -209,6 +258,8 @@ public class MetadataField implements Serializable{ /** + * Sets the mandatory. + * * @param mandatory the mandatory to set */ public void setMandatory(Boolean mandatory) { @@ -218,6 +269,8 @@ public class MetadataField implements Serializable{ /** + * Sets the data type. + * * @param dataType the dataType to set */ public void setDataType(DataType dataType) { @@ -227,6 +280,8 @@ public class MetadataField implements Serializable{ /** + * Sets the default value. + * * @param defaultValue the defaultValue to set */ public void setDefaultValue(String defaultValue) { @@ -236,6 +291,8 @@ public class MetadataField implements Serializable{ /** + * Sets the note. + * * @param note the note to set */ public void setNote(String note) { @@ -245,6 +302,8 @@ public class MetadataField implements Serializable{ /** + * Sets the vocabulary. + * * @param vocabulary the vocabulary to set */ public void setVocabulary(MetadataVocabulary vocabulary) { @@ -254,6 +313,8 @@ public class MetadataField implements Serializable{ /** + * Sets the validator. + * * @param validator the validator to set */ public void setValidator(MetadataValidator validator) { @@ -263,6 +324,8 @@ public class MetadataField implements Serializable{ /** + * Sets the tagging. + * * @param tagging the tagging to set */ public void setTagging(MetadataTagging tagging) { @@ -272,6 +335,8 @@ public class MetadataField implements Serializable{ /** + * Sets the grouping. + * * @param grouping the grouping to set */ public void setGrouping(MetadataGrouping grouping) { @@ -282,6 +347,11 @@ public class MetadataField implements Serializable{ /* (non-Javadoc) * @see java.lang.Object#toString() */ + /** + * To string. + * + * @return the string + */ @Override public String toString() { diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataFormat.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataFormat.java index de5d9e0..49bb17a 100644 --- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataFormat.java +++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/bean/jaxb/MetadataFormat.java @@ -72,17 +72,6 @@ public class MetadataFormat implements Serializable{ } - /** - * Sets the metadata type. - * - * @param metadataType the new metadata type - */ - public void setMetadataType(String metadataType) { - - this.metadataType = metadataType; - } - - /** * Gets the metadata categories. * @@ -93,28 +82,6 @@ public class MetadataFormat implements Serializable{ return metadataCategories; } - /** - * Sets the metadata categories. - * - * @param metadataCategories the metadataCategories to set - */ - public void setMetadataCategories(List metadataCategories) { - - this.metadataCategories = metadataCategories; - } - - - - /** - * Sets the metadata fields. - * - * @param metadataFields the metadataFields to set - */ - public void setMetadataFields(List metadataFields) { - - this.metadataFields = metadataFields; - } - /** * Adds the metadata. * @@ -139,7 +106,6 @@ public class MetadataFormat implements Serializable{ } - /** * Sets the metadata source. * diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatDiscovery.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MetadataFormatDiscovery.java similarity index 96% rename from src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatDiscovery.java rename to src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MetadataFormatDiscovery.java index 9cc451f..1c88165 100644 --- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatDiscovery.java +++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MetadataFormatDiscovery.java @@ -27,9 +27,9 @@ import org.xml.sax.InputSource; * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * Jun 8, 2016 */ -public class MedataFormatDiscovery { +public class MetadataFormatDiscovery { - private static Logger logger = LoggerFactory.getLogger(MedataFormatDiscovery.class); + private static Logger logger = LoggerFactory.getLogger(MetadataFormatDiscovery.class); protected static final String DATA_CATALOGUE_METADATA_SECONDARY_TYPE = "DataCatalogueMetadata"; private String secondaryType; private ScopeBean scope; @@ -41,7 +41,7 @@ public class MedataFormatDiscovery { * @param scope - the scope to be searched * @throws Exception the exception */ - public MedataFormatDiscovery(ScopeBean scope) throws Exception { + public MetadataFormatDiscovery(ScopeBean scope) throws Exception { this.scope = scope; this.secondaryType = DATA_CATALOGUE_METADATA_SECONDARY_TYPE; this.metadataTypes = readProfileFromInfrastrucure(); diff --git a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatReader.java b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MetadataFormatReader.java similarity index 97% rename from src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatReader.java rename to src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MetadataFormatReader.java index afaf527..4d2b1c4 100644 --- a/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MedataFormatReader.java +++ b/src/main/java/org/gcube/datacatalogue/metadatadiscovery/reader/MetadataFormatReader.java @@ -31,9 +31,9 @@ import org.xml.sax.InputSource; * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @Jul 26, 2013 */ -public class MedataFormatReader { +public class MetadataFormatReader { - private static Logger logger = LoggerFactory.getLogger(MedataFormatReader.class); + private static Logger logger = LoggerFactory.getLogger(MetadataFormatReader.class); private ScopeBean scope; private MetadataFormat metadataFormat; private String resourceID; @@ -46,7 +46,7 @@ public class MedataFormatReader { * @param resourceID the resource id * @throws Exception the exception */ - public MedataFormatReader(ScopeBean scope, String resourceID) throws Exception { + public MetadataFormatReader(ScopeBean scope, String resourceID) throws Exception { this.scope = scope; this.resourceID = resourceID; this.metadataFormat = getMetadataFormatByID(resourceID); diff --git a/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestMetadataFormatDiscovery.java b/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestMetadataFormatDiscovery.java index d81eb53..5dd1d10 100644 --- a/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestMetadataFormatDiscovery.java +++ b/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestMetadataFormatDiscovery.java @@ -6,7 +6,7 @@ package org.gcube.datacatalogue.metadatadiscovery; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.impl.ScopeBean; import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType; -import org.gcube.datacatalogue.metadatadiscovery.reader.MedataFormatDiscovery; +import org.gcube.datacatalogue.metadatadiscovery.reader.MetadataFormatDiscovery; import org.junit.Test; @@ -26,10 +26,10 @@ public class TestMetadataFormatDiscovery { String scopeString = "/gcube/devNext/NextNext"; final ScopeBean scope = new ScopeBean(scopeString); - MedataFormatDiscovery reader; + MetadataFormatDiscovery reader; try { ScopeProvider.instance.set(scopeString); - reader = new MedataFormatDiscovery(scope); + reader = new MetadataFormatDiscovery(scope); System.out.println(reader.getMetadataTypes()); for (MetadataType type : reader.getMetadataTypes()) { diff --git a/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestMetadataFormatReader.java b/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestMetadataFormatReader.java index 816abb3..1c7a1f1 100644 --- a/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestMetadataFormatReader.java +++ b/src/test/java/org/gcube/datacatalogue/metadatadiscovery/TestMetadataFormatReader.java @@ -4,7 +4,7 @@ package org.gcube.datacatalogue.metadatadiscovery; import org.gcube.common.scope.impl.ScopeBean; -import org.gcube.datacatalogue.metadatadiscovery.reader.MedataFormatReader; +import org.gcube.datacatalogue.metadatadiscovery.reader.MetadataFormatReader; import org.junit.Test; @@ -20,9 +20,9 @@ public class TestMetadataFormatReader { String scopeString = "/gcube/devsec/devVRE"; final ScopeBean scope = new ScopeBean(scopeString); - MedataFormatReader reader; + MetadataFormatReader reader; try { - reader = new MedataFormatReader(scope, "78355412-b45a-4519-adce-679452583aa2"); + reader = new MetadataFormatReader(scope, "78355412-b45a-4519-adce-679452583aa2"); System.out.println(reader.getMetadataFormat()); } catch (Exception e) { e.printStackTrace();