[#23537] Introduced the fieldId in the gCube Metadata Profile, Moved to

maven-portal-bom 3.6.4
This commit is contained in:
Francesco Mangiacrapa 2022-06-20 16:24:11 +02:00
parent 471536ae64
commit ff90eda8bd
5 changed files with 80 additions and 45 deletions

View File

@ -4,11 +4,13 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.1.0-SNAPSHOT] - 2022-03-01 ## [v1.1.0-SNAPSHOT] - 2022-06-20
#### Enhancement #### Enhancement
- [#22890] Extend the MetadataDiscovery logic - [#22890] Extend the MetadataDiscovery logic
- [#23537] Introduce the fieldId in the gCube Metadata Profile
- Moved to maven-portal-bom 3.6.4
## [v1.0.0] - 2020-09-30 ## [v1.0.0] - 2020-09-30

View File

@ -43,7 +43,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.6.0</version> <version>3.6.4</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

View File

@ -15,17 +15,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.gcube.common.metadataprofilediscovery.Namespace; import org.gcube.common.metadataprofilediscovery.Namespace;
import org.gcube.common.metadataprofilediscovery.adapter.DataTypeAdapter; import org.gcube.common.metadataprofilediscovery.adapter.DataTypeAdapter;
/** /**
* The Class MetadataField. * The Class MetadataField.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* Jun 8, 2016 *
* Jun 20, 2022
*/ */
@XmlRootElement(name="metadatafield") @XmlRootElement(name = "metadatafield")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class MetadataField implements Serializable{ public class MetadataField implements Serializable {
/** /**
* *
@ -37,22 +36,27 @@ public class MetadataField implements Serializable{
*/ */
private static final long serialVersionUID = 5935573474465015727L; private static final long serialVersionUID = 5935573474465015727L;
@XmlAttribute(name=LOCAL_NAME_CATEGORYREF) @XmlAttribute(name = LOCAL_NAME_CATEGORYREF)
private String categoryRef = null; //ITS VALUE IS A CATEGORY-ID private String categoryRef = null; // ITS VALUE IS A CATEGORY-ID
// optional Field used as fieldName in the (result) Document. If it absent, the
// mandatory fieldName is used
private String fieldId = null;
@XmlElement(required = true) @XmlElement(required = true)
private String fieldName; private String fieldName;
@XmlElement(required = true) @XmlElement(required = true)
private Boolean mandatory = false; private Boolean mandatory = false;
@XmlElement(name = "maxOccurs") @XmlElement(name = "maxOccurs")
private String maxOccurs; private String maxOccurs;
// private Boolean isBoolean = false; // private Boolean isBoolean = false;
@XmlJavaTypeAdapter(DataTypeAdapter.class) @XmlJavaTypeAdapter(DataTypeAdapter.class)
private DataType dataType = DataType.String; private DataType dataType = DataType.String;
private String defaultValue; private String defaultValue;
private String note; private String note;
//It's the list of eligible values; // It's the list of eligible values;
@XmlElement(name = "vocabulary") @XmlElement(name = "vocabulary")
private MetadataVocabulary vocabulary; private MetadataVocabulary vocabulary;
@ -84,12 +88,11 @@ public class MetadataField implements Serializable{
this.mandatory = mandatory; this.mandatory = mandatory;
} }
/** /**
* Instantiates a new metadata field. * Instantiates a new metadata field.
* *
* @param fieldName the field name * @param fieldName the field name
* @param mandatory the mandatory * @param mandatory the mandatory
* @param categoryID the category id * @param categoryID the category id
*/ */
public MetadataField(String fieldName, Boolean mandatory, String categoryID) { public MetadataField(String fieldName, Boolean mandatory, String categoryID) {
@ -110,7 +113,6 @@ public class MetadataField implements Serializable{
return categoryRef; return categoryRef;
} }
/** /**
* Sets the category ref to category id. * Sets the category ref to category id.
* *
@ -124,17 +126,37 @@ public class MetadataField implements Serializable{
/** /**
* Gets the category field qualified name. * Gets the category field qualified name.
* *
* If the Metadata Field belongs to a category, returns the qualified name: {@link MetadataField#categoryRef} {@link Namespace#Separator}} fieldName; * If the Metadata Field belongs to a category, returns the qualified name:
* {@link MetadataField#categoryRef} {@link Namespace#Separator}} fieldName;
* Otherwise returns the fieldName * Otherwise returns the fieldName
* *
* @return the category q name * @return the category q name
*/ */
public String getCategoryFieldQName(){ public String getCategoryFieldQName() {
return categoryRef==null?fieldName:categoryRef+Namespace.Separator+fieldName; return categoryRef == null ? fieldName : categoryRef + Namespace.Separator + fieldName;
} }
/**
* Gets the field id.
*
* @return the field id
*/
public String getFieldId() {
return fieldId;
}
/**
* Sets the field id. Optional Field used as fieldName in the (result) Document.
* (e.g. JSON Document { fieldId: [data entry value]} If it absent, the
* mandatory fieldName is used
*
* @param fieldId the new field id
*/
public void setFieldId(String fieldId) {
this.fieldId = fieldId;
}
/** /**
* Gets the field name. * Gets the field name.
@ -146,7 +168,6 @@ public class MetadataField implements Serializable{
return fieldName; return fieldName;
} }
/** /**
* Gets the mandatory. * Gets the mandatory.
* *
@ -157,7 +178,6 @@ public class MetadataField implements Serializable{
return mandatory; return mandatory;
} }
/** /**
* Gets the data type. * Gets the data type.
* *
@ -168,7 +188,6 @@ public class MetadataField implements Serializable{
return dataType; return dataType;
} }
/** /**
* Gets the max occurs. * Gets the max occurs.
* *
@ -179,8 +198,9 @@ public class MetadataField implements Serializable{
return maxOccurs; return maxOccurs;
} }
/** /**
* Sets the max occurs.
*
* @param maxOccurs the maxOccurs to set * @param maxOccurs the maxOccurs to set
*/ */
public void setMaxOccurs(String maxOccurs) { public void setMaxOccurs(String maxOccurs) {
@ -198,7 +218,6 @@ public class MetadataField implements Serializable{
return defaultValue; return defaultValue;
} }
/** /**
* Gets the note. * Gets the note.
* *
@ -209,7 +228,6 @@ public class MetadataField implements Serializable{
return note; return note;
} }
/** /**
* Gets the vocabulary. * Gets the vocabulary.
* *
@ -220,7 +238,6 @@ public class MetadataField implements Serializable{
return vocabulary; return vocabulary;
} }
/** /**
* Gets the validator. * Gets the validator.
* *
@ -231,7 +248,6 @@ public class MetadataField implements Serializable{
return validator; return validator;
} }
/** /**
* Gets the tagging. * Gets the tagging.
* *
@ -242,7 +258,6 @@ public class MetadataField implements Serializable{
return tagging; return tagging;
} }
/** /**
* Gets the grouping. * Gets the grouping.
* *
@ -253,7 +268,6 @@ public class MetadataField implements Serializable{
return grouping; return grouping;
} }
/** /**
* Sets the field name. * Sets the field name.
* *
@ -264,7 +278,6 @@ public class MetadataField implements Serializable{
this.fieldName = fieldName; this.fieldName = fieldName;
} }
/** /**
* Sets the mandatory. * Sets the mandatory.
* *
@ -275,7 +288,6 @@ public class MetadataField implements Serializable{
this.mandatory = mandatory; this.mandatory = mandatory;
} }
/** /**
* Sets the data type. * Sets the data type.
* *
@ -286,7 +298,6 @@ public class MetadataField implements Serializable{
this.dataType = dataType; this.dataType = dataType;
} }
/** /**
* Sets the default value. * Sets the default value.
* *
@ -297,7 +308,6 @@ public class MetadataField implements Serializable{
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
} }
/** /**
* Sets the note. * Sets the note.
* *
@ -308,7 +318,6 @@ public class MetadataField implements Serializable{
this.note = note; this.note = note;
} }
/** /**
* Sets the vocabulary. * Sets the vocabulary.
* *
@ -319,7 +328,6 @@ public class MetadataField implements Serializable{
this.vocabulary = vocabulary; this.vocabulary = vocabulary;
} }
/** /**
* Sets the validator. * Sets the validator.
* *
@ -330,7 +338,6 @@ public class MetadataField implements Serializable{
this.validator = validator; this.validator = validator;
} }
/** /**
* Sets the tagging. * Sets the tagging.
* *
@ -341,7 +348,6 @@ public class MetadataField implements Serializable{
this.tagging = tagging; this.tagging = tagging;
} }
/** /**
* Sets the grouping. * Sets the grouping.
* *
@ -352,7 +358,14 @@ public class MetadataField implements Serializable{
this.grouping = grouping; this.grouping = grouping;
} }
/* (non-Javadoc) /**
* To string.
*
* @return the string
*/
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@Override @Override
@ -361,6 +374,8 @@ public class MetadataField implements Serializable{
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("MetadataField [categoryRef="); builder.append("MetadataField [categoryRef=");
builder.append(categoryRef); builder.append(categoryRef);
builder.append(", fieldId=");
builder.append(fieldId);
builder.append(", fieldName="); builder.append(", fieldName=");
builder.append(fieldName); builder.append(fieldName);
builder.append(", mandatory="); builder.append(", mandatory=");
@ -385,5 +400,4 @@ public class MetadataField implements Serializable{
return builder.toString(); return builder.toString();
} }
} }

View File

@ -29,7 +29,7 @@ public class TestDataCatalogueMetadataFormatReader {
* Test. * Test.
* @throws Exception * @throws Exception
*/ */
@Test //@Test
public void test() throws Exception { public void test() throws Exception {
@ -45,7 +45,7 @@ public class TestDataCatalogueMetadataFormatReader {
List<NamespaceCategory> categs = reader.getListOfNamespaceCategories(); List<NamespaceCategory> categs = reader.getListOfNamespaceCategories();
for (NamespaceCategory namespaceCategory : categs) { for (NamespaceCategory namespaceCategory : categs) {
logger.trace("\n\n "+ ++i +".) Category: "+namespaceCategory); logger.info("\n\n "+ ++i +".) Category: "+namespaceCategory);
} }
i = 0; i = 0;
@ -55,7 +55,7 @@ public class TestDataCatalogueMetadataFormatReader {
continue; continue;
MetadataFormat metadataFormat = reader.getMetadataFormatForMetadataProfile(mt); MetadataFormat metadataFormat = reader.getMetadataFormatForMetadataProfile(mt);
logger.trace("\n\n "+ ++i +".) Metadata source: "+metadataFormat.getMetadataSource().substring(0, 100)); logger.info("\n\n "+ ++i +".) Metadata source: "+metadataFormat.getMetadataSource().substring(0, 100));
} }
} }

View File

@ -4,9 +4,12 @@
package org.gcube.common.metadataprofilediscovery; package org.gcube.common.metadataprofilediscovery;
import org.gcube.common.metadataprofilediscovery.bean.MetadataProfile; 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.reader.MetadataFormatDiscovery; import org.gcube.common.metadataprofilediscovery.reader.MetadataFormatDiscovery;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean;
import org.junit.Test;
/** /**
@ -25,6 +28,8 @@ public class TestMetadataFormatDiscovery {
String scopeString = "/gcube/devsec/devVRE"; String scopeString = "/gcube/devsec/devVRE";
String grMetadataProfileSecondaryType = "DataCatalogueMetadata"; String grMetadataProfileSecondaryType = "DataCatalogueMetadata";
grMetadataProfileSecondaryType = "GeoNaMetadata";
final ScopeBean scope = new ScopeBean(scopeString); final ScopeBean scope = new ScopeBean(scopeString);
MetadataFormatDiscovery reader; MetadataFormatDiscovery reader;
try { try {
@ -33,9 +38,23 @@ public class TestMetadataFormatDiscovery {
//System.out.println(reader.getMetadataProfiles()); //System.out.println(reader.getMetadataProfiles());
for (MetadataProfile metaProfile : reader.getMetadataProfiles()) { for (MetadataProfile metaProfile : reader.getMetadataProfiles()) {
System.out.println(metaProfile.getId() +", name: "+metaProfile.getName() +", type: "+metaProfile.getMetadataType()); System.out.println("\n\n###" + metaProfile.getId() +", name: "+metaProfile.getName() +", type: "+metaProfile.getMetadataType());
MetadataProfileReader readerProfile = new MetadataProfileReader(grMetadataProfileSecondaryType, metaProfile.getName());
MetadataFormat format = readerProfile.getMetadataFormatForMetadataProfile(metaProfile);
int i = 0;
try {
for (MetadataField field : format.getMetadataFields()) {
System.out.println(++i +") "+field);
}
}catch (Exception e) {
System.out.println("\t## Error occurred reading: " + metaProfile.getId() +", name: "+metaProfile.getName() +", type: "+metaProfile.getMetadataType());
e.printStackTrace();
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }