[#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.
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
- [#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

View File

@ -43,7 +43,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.0</version>
<version>3.6.4</version>
<type>pom</type>
<scope>import</scope>
</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.adapter.DataTypeAdapter;
/**
* The Class MetadataField.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 8, 2016
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 20, 2022
*/
@XmlRootElement(name="metadatafield")
@XmlRootElement(name = "metadatafield")
@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;
@XmlAttribute(name=LOCAL_NAME_CATEGORYREF)
private String categoryRef = null; //ITS VALUE IS A CATEGORY-ID
@XmlAttribute(name = LOCAL_NAME_CATEGORYREF)
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)
private String fieldName;
@XmlElement(required = true)
@XmlElement(required = true)
private Boolean mandatory = false;
@XmlElement(name = "maxOccurs")
@XmlElement(name = "maxOccurs")
private String maxOccurs;
// private Boolean isBoolean = false;
@XmlJavaTypeAdapter(DataTypeAdapter.class)
@XmlJavaTypeAdapter(DataTypeAdapter.class)
private DataType dataType = DataType.String;
private String defaultValue;
private String note;
//It's the list of eligible values;
// It's the list of eligible values;
@XmlElement(name = "vocabulary")
private MetadataVocabulary vocabulary;
@ -84,12 +88,11 @@ public class MetadataField implements Serializable{
this.mandatory = mandatory;
}
/**
* Instantiates a new metadata field.
*
* @param fieldName the field name
* @param mandatory the mandatory
* @param fieldName the field name
* @param mandatory the mandatory
* @param categoryID the category id
*/
public MetadataField(String fieldName, Boolean mandatory, String categoryID) {
@ -110,7 +113,6 @@ public class MetadataField implements Serializable{
return categoryRef;
}
/**
* Sets the category ref to category id.
*
@ -124,17 +126,37 @@ 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#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
*
* @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.
@ -146,7 +168,6 @@ public class MetadataField implements Serializable{
return fieldName;
}
/**
* Gets the mandatory.
*
@ -157,7 +178,6 @@ public class MetadataField implements Serializable{
return mandatory;
}
/**
* Gets the data type.
*
@ -168,7 +188,6 @@ public class MetadataField implements Serializable{
return dataType;
}
/**
* Gets the max occurs.
*
@ -179,8 +198,9 @@ public class MetadataField implements Serializable{
return maxOccurs;
}
/**
* Sets the max occurs.
*
* @param maxOccurs the maxOccurs to set
*/
public void setMaxOccurs(String maxOccurs) {
@ -198,7 +218,6 @@ public class MetadataField implements Serializable{
return defaultValue;
}
/**
* Gets the note.
*
@ -209,7 +228,6 @@ public class MetadataField implements Serializable{
return note;
}
/**
* Gets the vocabulary.
*
@ -220,7 +238,6 @@ public class MetadataField implements Serializable{
return vocabulary;
}
/**
* Gets the validator.
*
@ -231,7 +248,6 @@ public class MetadataField implements Serializable{
return validator;
}
/**
* Gets the tagging.
*
@ -242,7 +258,6 @@ public class MetadataField implements Serializable{
return tagging;
}
/**
* Gets the grouping.
*
@ -253,7 +268,6 @@ public class MetadataField implements Serializable{
return grouping;
}
/**
* Sets the field name.
*
@ -264,7 +278,6 @@ public class MetadataField implements Serializable{
this.fieldName = fieldName;
}
/**
* Sets the mandatory.
*
@ -275,7 +288,6 @@ public class MetadataField implements Serializable{
this.mandatory = mandatory;
}
/**
* Sets the data type.
*
@ -286,7 +298,6 @@ public class MetadataField implements Serializable{
this.dataType = dataType;
}
/**
* Sets the default value.
*
@ -297,7 +308,6 @@ public class MetadataField implements Serializable{
this.defaultValue = defaultValue;
}
/**
* Sets the note.
*
@ -308,7 +318,6 @@ public class MetadataField implements Serializable{
this.note = note;
}
/**
* Sets the vocabulary.
*
@ -319,7 +328,6 @@ public class MetadataField implements Serializable{
this.vocabulary = vocabulary;
}
/**
* Sets the validator.
*
@ -330,7 +338,6 @@ public class MetadataField implements Serializable{
this.validator = validator;
}
/**
* Sets the tagging.
*
@ -341,7 +348,6 @@ public class MetadataField implements Serializable{
this.tagging = tagging;
}
/**
* Sets the grouping.
*
@ -352,7 +358,14 @@ public class MetadataField implements Serializable{
this.grouping = grouping;
}
/* (non-Javadoc)
/**
* To string.
*
* @return the string
*/
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
@ -361,6 +374,8 @@ public class MetadataField implements Serializable{
StringBuilder builder = new StringBuilder();
builder.append("MetadataField [categoryRef=");
builder.append(categoryRef);
builder.append(", fieldId=");
builder.append(fieldId);
builder.append(", fieldName=");
builder.append(fieldName);
builder.append(", mandatory=");
@ -385,5 +400,4 @@ public class MetadataField implements Serializable{
return builder.toString();
}
}

View File

@ -29,7 +29,7 @@ public class TestDataCatalogueMetadataFormatReader {
* Test.
* @throws Exception
*/
@Test
//@Test
public void test() throws Exception {
@ -45,7 +45,7 @@ public class TestDataCatalogueMetadataFormatReader {
List<NamespaceCategory> categs = reader.getListOfNamespaceCategories();
for (NamespaceCategory namespaceCategory : categs) {
logger.trace("\n\n "+ ++i +".) Category: "+namespaceCategory);
logger.info("\n\n "+ ++i +".) Category: "+namespaceCategory);
}
i = 0;
@ -55,7 +55,7 @@ public class TestDataCatalogueMetadataFormatReader {
continue;
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;
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.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.junit.Test;
/**
@ -25,6 +28,8 @@ public class TestMetadataFormatDiscovery {
String scopeString = "/gcube/devsec/devVRE";
String grMetadataProfileSecondaryType = "DataCatalogueMetadata";
grMetadataProfileSecondaryType = "GeoNaMetadata";
final ScopeBean scope = new ScopeBean(scopeString);
MetadataFormatDiscovery reader;
try {
@ -33,8 +38,22 @@ public class TestMetadataFormatDiscovery {
//System.out.println(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) {
e.printStackTrace();