Added also source of Metadata Format as an attribute of MetadataFormat
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/gcubedatacatalogue-metadata-discovery@146277 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8b2b2e6d2f
commit
75f0c41a5c
|
@ -11,6 +11,7 @@ import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +43,9 @@ public class MetadataFormat implements Serializable{
|
||||||
@XmlElement(name = "metadatafield")
|
@XmlElement(name = "metadatafield")
|
||||||
private List<MetadataField> metadataFields;
|
private List<MetadataField> metadataFields;
|
||||||
|
|
||||||
|
@XmlTransient
|
||||||
|
private String metadataSource = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the metadata fields.
|
* Gets the metadata fields.
|
||||||
|
@ -102,6 +106,30 @@ public class MetadataFormat implements Serializable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata source.
|
||||||
|
*
|
||||||
|
* @return the metadata source
|
||||||
|
*/
|
||||||
|
public String getMetadataSource() {
|
||||||
|
|
||||||
|
return metadataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the metadata source.
|
||||||
|
*
|
||||||
|
* @param metadataSource the new metadata source
|
||||||
|
*/
|
||||||
|
public void setMetadataSource(String metadataSource) {
|
||||||
|
|
||||||
|
this.metadataSource = metadataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the category.
|
* Adds the category.
|
||||||
*
|
*
|
||||||
|
@ -127,8 +155,11 @@ public class MetadataFormat implements Serializable{
|
||||||
builder.append(metadataCategories);
|
builder.append(metadataCategories);
|
||||||
builder.append(", metadataFields=");
|
builder.append(", metadataFields=");
|
||||||
builder.append(metadataFields);
|
builder.append(metadataFields);
|
||||||
|
builder.append(", metadataSource=");
|
||||||
|
builder.append(metadataSource);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,9 @@ public class MedataFormatReader {
|
||||||
XPathHelper helper = new XPathHelper(node);
|
XPathHelper helper = new XPathHelper(node);
|
||||||
List<MetadataField> fields = getMetadataFieldsFromResource(helper);
|
List<MetadataField> fields = getMetadataFieldsFromResource(helper);
|
||||||
mf.setMetadataFields(fields);
|
mf.setMetadataFields(fields);
|
||||||
|
String metadataSource = getMetadataFormatSourceFromResource(helper);
|
||||||
|
mf.setMetadataSource(metadataSource);
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Error while parsing Resource "+theResource+" from the infrastructure, the scope is "+scopeString,e);
|
logger.error("Error while parsing Resource "+theResource+" from the infrastructure, the scope is "+scopeString,e);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +116,31 @@ public class MedataFormatReader {
|
||||||
return mf;
|
return mf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata format source from resource.
|
||||||
|
*
|
||||||
|
* @param helper the helper
|
||||||
|
* @return the metadata format source from resource
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
private String getMetadataFormatSourceFromResource(XPathHelper helper) throws Exception{
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
List<String> metadataFormatSource = helper.evaluate("/Resource/Profile/Body/metadataformat");
|
||||||
|
|
||||||
|
if(metadataFormatSource==null || metadataFormatSource.isEmpty())
|
||||||
|
throw new Exception("metadataformat not found in the body, consider to add <metadataformat>");
|
||||||
|
|
||||||
|
return metadataFormatSource.get(0);
|
||||||
|
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("An error occurred in getMetadataFormatSourceFromResource ", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the metadata fields from resource.
|
* Gets the metadata fields from resource.
|
||||||
*
|
*
|
||||||
|
@ -153,7 +181,7 @@ public class MedataFormatReader {
|
||||||
return mfs;
|
return mfs;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An error occurred in getListDefaultLayerFromNode ", e);
|
logger.error("An error occurred in getMetadataFieldsFromResource ", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.datacatalogue.metadatadiscovery;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType;
|
import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -31,8 +32,10 @@ public class TestDataCatalogueMetadataFormatReader {
|
||||||
DataCalogueMetadataFormatReader reader = new DataCalogueMetadataFormatReader();
|
DataCalogueMetadataFormatReader reader = new DataCalogueMetadataFormatReader();
|
||||||
logger.trace(""+reader.getListOfMetadataTypes());
|
logger.trace(""+reader.getListOfMetadataTypes());
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
for (MetadataType mt : reader.getListOfMetadataTypes()) {
|
for (MetadataType mt : reader.getListOfMetadataTypes()) {
|
||||||
logger.trace(""+reader.getMetadataFormatForMetadataType(mt));
|
MetadataFormat metadataFormat = reader.getMetadataFormatForMetadataType(mt);
|
||||||
|
logger.trace("\n\n "+ ++i +".) Metadata Format: "+metadataFormat.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue