toMetadataFormat moved to static. commented tests
This commit is contained in:
parent
a6d91a4b7d
commit
ee9969f2ba
|
@ -86,6 +86,7 @@ public class MetadataProfileReader implements MetadataProfileDiscovery {
|
||||||
throw new Exception("Please set a valid scope into ScopeProvider");
|
throw new Exception("Please set a valid scope into ScopeProvider");
|
||||||
|
|
||||||
scope = new ScopeBean(scopeString);
|
scope = new ScopeBean(scopeString);
|
||||||
|
|
||||||
readNamespaces();
|
readNamespaces();
|
||||||
readMetadataFormats();
|
readMetadataFormats();
|
||||||
}
|
}
|
||||||
|
@ -97,23 +98,22 @@ public class MetadataProfileReader implements MetadataProfileDiscovery {
|
||||||
*/
|
*/
|
||||||
private void readMetadataFormats() throws Exception {
|
private void readMetadataFormats() throws Exception {
|
||||||
|
|
||||||
//reading from Generic Resource for Secondary Type
|
//reading from Generic Resource for Secondary Type passed in input
|
||||||
if(grMetadataProfileSecondaryType!=null) {
|
medataFormatDiscovery = new MetadataFormatDiscovery(scope, grMetadataProfileSecondaryType);
|
||||||
medataFormatDiscovery = new MetadataFormatDiscovery(scope, grMetadataProfileSecondaryType);
|
|
||||||
|
logger.info("MedataFormatDiscovery has retrieved: " + medataFormatDiscovery.getMetadataProfiles().size()
|
||||||
logger.info("MedataFormatDiscovery has retrieved: " + medataFormatDiscovery.getMetadataProfiles().size()
|
+ " metadata type/s");
|
||||||
+ " metadata type/s");
|
logger.debug("filling cache for MedataFormat");
|
||||||
logger.debug("filling cache for MedataFormat");
|
hashMetadataFormats = new HashMap<String, MetadataFormat>(medataFormatDiscovery.getMetadataProfiles().size());
|
||||||
hashMetadataFormats = new HashMap<String, MetadataFormat>(medataFormatDiscovery.getMetadataProfiles().size());
|
for (MetadataProfile mT : medataFormatDiscovery.getMetadataProfiles()) {
|
||||||
for (MetadataProfile mT : medataFormatDiscovery.getMetadataProfiles()) {
|
if (mT == null)
|
||||||
if (mT == null)
|
continue;
|
||||||
continue;
|
|
||||||
|
MetadataFormatReader reader = new MetadataFormatReader(scope, mT.getId());
|
||||||
MetadataFormatReader reader = new MetadataFormatReader(scope, mT.getId());
|
hashMetadataFormats.put(mT.getId(), reader.getMetadataFormat());
|
||||||
hashMetadataFormats.put(mT.getId(), reader.getMetadataFormat());
|
logger.debug("MetadataType id: " + mT.getId() + " cached as: " + reader.getMetadataFormat());
|
||||||
logger.debug("MetadataType id: " + mT.getId() + " cached as: " + reader.getMetadataFormat());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -316,7 +316,7 @@ public class MetadataProfileReader implements MetadataProfileDiscovery {
|
||||||
* @return the metadata format
|
* @return the metadata format
|
||||||
* @throws JAXBException the JAXB exception
|
* @throws JAXBException the JAXB exception
|
||||||
*/
|
*/
|
||||||
public MetadataFormat toMetadataFormat(InputStream metadataProfileStream) throws JAXBException{
|
public static MetadataFormat toMetadataFormat(InputStream metadataProfileStream) throws JAXBException{
|
||||||
|
|
||||||
if(metadataProfileStream==null)
|
if(metadataProfileStream==null)
|
||||||
throw new NullPointerException("Invalid input parameter");
|
throw new NullPointerException("Invalid input parameter");
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class TestDataCatalogueMetadataFormatReader {
|
||||||
/**
|
/**
|
||||||
* Test.
|
* Test.
|
||||||
*/
|
*/
|
||||||
@Test
|
//@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
try {
|
try {
|
||||||
String scopeString = "/gcube/devsec/devVRE";
|
String scopeString = "/gcube/devsec/devVRE";
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class TestMetadataFormatDiscovery {
|
||||||
/**
|
/**
|
||||||
* Test.
|
* Test.
|
||||||
*/
|
*/
|
||||||
@Test
|
//@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
String scopeString = "/gcube/devsec/devVRE";
|
String scopeString = "/gcube/devsec/devVRE";
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.common.metadataprofilediscovery;
|
package org.gcube.common.metadataprofilediscovery;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataField;
|
||||||
|
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataFormat;
|
||||||
import org.gcube.common.metadataprofilediscovery.reader.MetadataFormatReader;
|
import org.gcube.common.metadataprofilediscovery.reader.MetadataFormatReader;
|
||||||
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;
|
||||||
|
@ -30,4 +35,21 @@ public class TestMetadataFormatReader {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@Test
|
||||||
|
public void testReadInputStream() {
|
||||||
|
String fileNameMeatadataProfile = "HarvestedObject.xml";
|
||||||
|
try {
|
||||||
|
InputStream in = ClassLoader.getSystemResourceAsStream(fileNameMeatadataProfile);
|
||||||
|
//InputStream in = TestMetadataFormatReader.class.getResourceAsStream(fileNameMeatadataProfile);
|
||||||
|
MetadataFormat mf = MetadataProfileReader.toMetadataFormat(in);
|
||||||
|
System.out.println("Source: "+mf.getMetadataSource());
|
||||||
|
|
||||||
|
for (MetadataField field : mf.getMetadataFields()) {
|
||||||
|
System.out.println(field);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue