cleaned up pom and testing Ariadne mapping via URL
This commit is contained in:
parent
d78122c64d
commit
2ed3a388ac
|
@ -36,138 +36,8 @@
|
|||
<artifactId>dnet-msro-service</artifactId>
|
||||
<version>[7.0.0-SAXONHE-SOLR772-SNAPSHOT, 8.0.0-SAXONHE)</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.common</groupId>-->
|
||||
<!--<artifactId>authorization-client</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.information-system</groupId>-->
|
||||
<!--<artifactId>information-system-model</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.information-system</groupId>-->
|
||||
<!--<artifactId>gcube-resources</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.information-system</groupId>-->
|
||||
<!--<artifactId>resource-registry-client</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.information-system</groupId>-->
|
||||
<!--<artifactId>resource-registry-publisher</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.core</groupId>-->
|
||||
<!--<artifactId>common-scope</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.information-system</groupId>-->
|
||||
<!--<artifactId>ariadneplus-entities</artifactId>-->
|
||||
<!--<version>0.0.1-SNAPSHOT</version>-->
|
||||
<!--</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<!--<dependencyManagement>-->
|
||||
<!--<dependencies>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.distribution</groupId>-->
|
||||
<!--<artifactId>gcube-bom</artifactId>-->
|
||||
<!--<version>LATEST</version>-->
|
||||
<!--<type>pom</type>-->
|
||||
<!--<scope>import</scope>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.distribution</groupId>-->
|
||||
<!--<artifactId>gcube-smartgears-bom</artifactId>-->
|
||||
<!--<version>LATEST</version>-->
|
||||
<!--<type>pom</type>-->
|
||||
<!--<scope>import</scope>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.gcube.information-system</groupId>-->
|
||||
<!--<artifactId>information-system-bom</artifactId>-->
|
||||
<!--<version>LATEST</version>-->
|
||||
<!--<type>pom</type>-->
|
||||
<!--<scope>import</scope>-->
|
||||
<!--</dependency>-->
|
||||
<!--</dependencies>-->
|
||||
<!--</dependencyManagement>-->
|
||||
|
||||
<!--<repositories>-->
|
||||
<!--<repository>-->
|
||||
<!--<id>gcube-snapshots</id>-->
|
||||
<!--<name>gCube Snapshots</name>-->
|
||||
<!--<url>http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-snapshots</url>-->
|
||||
<!--<releases>-->
|
||||
<!--<enabled>false</enabled>-->
|
||||
<!--</releases>-->
|
||||
<!--<snapshots>-->
|
||||
<!--<enabled>true</enabled>-->
|
||||
<!--</snapshots>-->
|
||||
<!--</repository>-->
|
||||
<!--<repository>-->
|
||||
<!--<id>gcube-releases</id>-->
|
||||
<!--<name>gCube Releases</name>-->
|
||||
<!--<url>http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-releases</url>-->
|
||||
<!--<snapshots>-->
|
||||
<!--<enabled>false</enabled>-->
|
||||
<!--</snapshots>-->
|
||||
<!--<releases>-->
|
||||
<!--<enabled>true</enabled>-->
|
||||
<!--</releases>-->
|
||||
<!--</repository>-->
|
||||
<!--<repository>-->
|
||||
<!--<id>gcube-externals</id>-->
|
||||
<!--<name>gCube Externals</name>-->
|
||||
<!--<url>http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-externals</url>-->
|
||||
<!--<snapshots>-->
|
||||
<!--<enabled>false</enabled>-->
|
||||
<!--</snapshots>-->
|
||||
<!--<releases>-->
|
||||
<!--<enabled>true</enabled>-->
|
||||
<!--</releases>-->
|
||||
<!--</repository>-->
|
||||
<!--</repositories>-->
|
||||
|
||||
<!--<pluginRepositories>-->
|
||||
<!--<pluginRepository>-->
|
||||
<!--<id>gcube-snapshots</id>-->
|
||||
<!--<name>gCube Snapshots</name>-->
|
||||
<!--<url>http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-snapshots</url>-->
|
||||
<!--<releases>-->
|
||||
<!--<enabled>false</enabled>-->
|
||||
<!--</releases>-->
|
||||
<!--<snapshots>-->
|
||||
<!--<enabled>true</enabled>-->
|
||||
<!--</snapshots>-->
|
||||
<!--</pluginRepository>-->
|
||||
<!--<pluginRepository>-->
|
||||
<!--<id>gcube-releases</id>-->
|
||||
<!--<name>gCube Releases</name>-->
|
||||
<!--<url>http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-releases</url>-->
|
||||
<!--<snapshots>-->
|
||||
<!--<enabled>false</enabled>-->
|
||||
<!--</snapshots>-->
|
||||
<!--<releases>-->
|
||||
<!--<enabled>true</enabled>-->
|
||||
<!--</releases>-->
|
||||
<!--</pluginRepository>-->
|
||||
|
||||
<!--<pluginRepository>-->
|
||||
<!--<id>gcube-externals</id>-->
|
||||
<!--<name>gCube Externals</name>-->
|
||||
<!--<url>http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-externals</url>-->
|
||||
<!--<snapshots>-->
|
||||
<!--<enabled>false</enabled>-->
|
||||
<!--</snapshots>-->
|
||||
<!--<releases>-->
|
||||
<!--<enabled>true</enabled>-->
|
||||
<!--</releases>-->
|
||||
<!--</pluginRepository>-->
|
||||
<!--</pluginRepositories>-->
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
|
||||
import eu.dnetlib.msro.workflows.nodes.transform.ApplyX3Mapping;
|
||||
import gr.forth.ics.isl.x3ml.X3MLEngineFactory;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -19,61 +20,52 @@ public class ApplyX3MappingTest {
|
|||
|
||||
private static final Log log = LogFactory.getLog(ApplyX3MappingTest.class);
|
||||
|
||||
private static String basePathProfiles = "/eu/dnetlib/bootstrap/profiles/TransformationRuleDSResources/TransformationRuleDSResourceType/";
|
||||
|
||||
private String mappingUrl = "https://mapping.d4science.org/3MEditor/Services?id=575&output=text/xml&method=export";
|
||||
|
||||
//Ariadne policy
|
||||
final String ariadnePolicyPath = "ARIADNE_Policy.xml";
|
||||
final String ariadnePolicyPath = "ariadne_policy.xml";
|
||||
|
||||
//ADS record
|
||||
final String adsRecordPath = "/eu/dnetlib/x3m/ads-record.xml";
|
||||
final String adsRecordPath = "ariadneADSsample.xml";
|
||||
|
||||
@Test
|
||||
public void testAriadne() {
|
||||
public void testAriadne() throws IOException {
|
||||
doBasicTest(ariadnePolicyPath, adsRecordPath);
|
||||
}
|
||||
|
||||
public void doBasicTest(String policyPath, String recordPath){
|
||||
String g = loadFromTransformationProfile(policyPath);
|
||||
@Test
|
||||
public void testWithURLMapping() throws MalformedURLException {
|
||||
X3MLEngineFactory x3mEngine = X3MLEngineFactory.create()
|
||||
.withMappings(new URL("https://mapping.d4science.org/3MEditor/Services?id=575&output=text/xml&method=export"))
|
||||
.withVerboseLogging()
|
||||
.withGeneratorPolicy(getInputStreamFromClasspath("/eu/dnetlib/x3m/ariadne_policy.xml"))
|
||||
.withInput(getInputStreamFromClasspath("/eu/dnetlib/x3m/ariadneADSsample.xml"))
|
||||
.withOutput(System.out, X3MLEngineFactory.OutputFormat.RDF_XML);
|
||||
x3mEngine.execute();
|
||||
}
|
||||
|
||||
|
||||
public void doBasicTest(String policyPath, String recordPath) throws IOException {
|
||||
String g = getString(policyPath);
|
||||
String r = getString(recordPath);
|
||||
|
||||
URL mappingURL = null;
|
||||
try {
|
||||
mappingURL = new URL(mappingUrl);
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
URL mappingURL = new URL(mappingUrl);
|
||||
ApplyX3Mapping x3m = new ApplyX3Mapping(mappingURL, g, true);
|
||||
String res = x3m.apply(r);
|
||||
System.out.println("res is \n"+res);
|
||||
}
|
||||
|
||||
|
||||
private String getString(final String classpath) {
|
||||
public static InputStream getInputStreamFromClasspath(final String s) {
|
||||
try {
|
||||
final ClassPathResource resource = new ClassPathResource(classpath);
|
||||
return IOUtils.toString(resource.getInputStream(), "UTF-8");
|
||||
final ClassPathResource resource = new ClassPathResource(s);
|
||||
return resource.getInputStream();
|
||||
}catch(IOException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String loadFromTransformationProfile(String profilePath){
|
||||
log.info("Loading xslt from: " + basePathProfiles + profilePath);
|
||||
InputStream profile = getClass().getResourceAsStream(basePathProfiles + profilePath);
|
||||
SAXReader saxReader = new SAXReader();
|
||||
Document doc = null;
|
||||
try {
|
||||
doc = saxReader.read(profile);
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String s = doc.selectSingleNode("//SCRIPT/CODE").getText();
|
||||
//log.debug(profilePath+": "+s);
|
||||
return s;
|
||||
private String getString(final String classpath) throws IOException {
|
||||
final ClassPathResource resource = new ClassPathResource(classpath);
|
||||
return IOUtils.toString(resource.getInputStream(), "UTF-8");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<record xmlns:ads="https://archaeologydataservice.ac.uk/"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
type="record">
|
||||
<dc:title>Part of a cropmark with...</dc:title>
|
||||
<dc:creator>Historic England</dc:creator>
|
||||
<dc:subject>CROPMARK</dc:subject>
|
||||
<dc:subject>HOUSE</dc:subject>
|
||||
<dcterms:temporal>PALAEOLITHIC</dcterms:temporal>
|
||||
<dc:description>Part of a cropmark with internal markings seen on air photograph. Field investigation in 1957 found the marks to be due to natural undulations and vegetational changes, and no traces of antiquity were observed.</dc:description>
|
||||
<dc:identifier>Depositor ID: NT 70 NE 1</dc:identifier>
|
||||
<dc:identifier>NMR_NATINV-3</dc:identifier>
|
||||
<dc:source>https://archaeologydataservice.ac.uk/archsearch/record?titleId=967971</dc:source>
|
||||
<dc:language xsi:type="dcterms:ISO639-2">eng</dc:language>
|
||||
<dcterms:spatial>ALWINTON, ALNWICK, NORTHUMBERLAND, ENGLAND</dcterms:spatial>
|
||||
<dcterms:spatial xsi:type="dcterms:POINT">-2.758696, 55.945225</dcterms:spatial>
|
||||
<dc:rights>http://archaeologydataservice.ac.uk/advice/termsOfUseAndAccess</dc:rights>
|
||||
<dc:relation>1000398</dc:relation>
|
||||
</record>
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><generator_policy>
|
||||
|
||||
<!-- The prefix is a namespace that must be declared in the X3ML definition.
|
||||
in the x3ml define <namespace prefix="ariadneplus" uri="http://www.ariadneplus.eu/"/> -->
|
||||
|
||||
<generator name="CollectionURI" prefix="ariadneplus">
|
||||
<pattern>Collection/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="DataResourceURI" prefix="ariadneplus" shorten="yes">
|
||||
<pattern>Resource/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="ObjectURI" prefix="ariadneplus" shorten="yes">
|
||||
<pattern>Object/{resource}-{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="ObjectLabel">
|
||||
<pattern>Resource {resource} is about {term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="IdentifierURI" prefix="ariadneplus">
|
||||
<pattern>Identifier/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="EventURI" prefix="ariadneplus">
|
||||
<pattern>Event/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="Time-SpanURI" prefix="ariadneplus">
|
||||
<pattern>Time-Span/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="PlaceURI" prefix="ariadneplus" shorten="yes">
|
||||
<pattern>Place/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="AgentURI" prefix="ariadneplus">
|
||||
<pattern>Agent/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="ConceptURI" prefix="ariadneplus">
|
||||
<pattern>Concept/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="ConceptURI-2" prefix="ariadneplus">
|
||||
<pattern>Concept/{scheme}/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="LangURI" prefix="lexvo">
|
||||
<pattern>{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="OneLevelCustomURI" prefix="ariadneplus">
|
||||
<pattern>{level1}/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="TwoLevelCustomURI" prefix="ariadneplus">
|
||||
<pattern>{level1}/{level2}/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="SimpleLabel">
|
||||
<pattern>{label}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="CompositeLabel">
|
||||
<pattern>{label} {text}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="URIorUUID">
|
||||
<custom generatorClass="gr.forth.URIorUUID">
|
||||
<set-arg name="text"/>
|
||||
</custom>
|
||||
</generator>
|
||||
|
||||
<generator name="URNfromTextualContent">
|
||||
<custom generatorClass="gr.forth.TextualContent">
|
||||
<set-arg name="text" type="xpath"/>
|
||||
</custom>
|
||||
</generator>
|
||||
|
||||
<generator name="TypedLiteralGen">
|
||||
<custom generatorClass="gr.forth.TypedLiteralGenerator">
|
||||
<set-arg name="text"/>
|
||||
</custom>
|
||||
</generator>
|
||||
|
||||
|
||||
</generator_policy>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<record xmlns:ads="https://archaeologydataservice.ac.uk/"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
type="record">
|
||||
<dc:title>Part of a cropmark with...</dc:title>
|
||||
<dc:creator>Historic England</dc:creator>
|
||||
<dc:subject>CROPMARK</dc:subject>
|
||||
<dc:subject>HOUSE</dc:subject>
|
||||
<dcterms:temporal>PALAEOLITHIC</dcterms:temporal>
|
||||
<dc:description>Part of a cropmark with internal markings seen on air photograph. Field investigation in 1957 found the marks to be due to natural undulations and vegetational changes, and no traces of antiquity were observed.</dc:description>
|
||||
<dc:identifier>Depositor ID: NT 70 NE 1</dc:identifier>
|
||||
<dc:identifier>NMR_NATINV-3</dc:identifier>
|
||||
<dc:source>https://archaeologydataservice.ac.uk/archsearch/record?titleId=967971</dc:source>
|
||||
<dc:language xsi:type="dcterms:ISO639-2">eng</dc:language>
|
||||
<dcterms:spatial>ALWINTON, ALNWICK, NORTHUMBERLAND, ENGLAND</dcterms:spatial>
|
||||
<dcterms:spatial xsi:type="dcterms:POINT">-2.758696, 55.945225</dcterms:spatial>
|
||||
<dc:rights>http://archaeologydataservice.ac.uk/advice/termsOfUseAndAccess</dc:rights>
|
||||
<dc:relation>1000398</dc:relation>
|
||||
</record>
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><generator_policy>
|
||||
|
||||
<!-- The prefix is a namespace that must be declared in the X3ML definition.
|
||||
in the x3ml define <namespace prefix="ariadneplus" uri="http://www.ariadneplus.eu/"/> -->
|
||||
|
||||
<generator name="CollectionURI" prefix="ariadneplus">
|
||||
<pattern>Collection/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="DataResourceURI" prefix="ariadneplus" shorten="yes">
|
||||
<pattern>Resource/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="ObjectURI" prefix="ariadneplus" shorten="yes">
|
||||
<pattern>Object/{resource}-{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="ObjectLabel">
|
||||
<pattern>Resource {resource} is about {term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="IdentifierURI" prefix="ariadneplus">
|
||||
<pattern>Identifier/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="EventURI" prefix="ariadneplus">
|
||||
<pattern>Event/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="Time-SpanURI" prefix="ariadneplus">
|
||||
<pattern>Time-Span/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="PlaceURI" prefix="ariadneplus" shorten="yes">
|
||||
<pattern>Place/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="AgentURI" prefix="ariadneplus">
|
||||
<pattern>Agent/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="ConceptURI" prefix="ariadneplus">
|
||||
<pattern>Concept/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="ConceptURI-2" prefix="ariadneplus">
|
||||
<pattern>Concept/{scheme}/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="LangURI" prefix="lexvo">
|
||||
<pattern>{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="OneLevelCustomURI" prefix="ariadneplus">
|
||||
<pattern>{level1}/{term}</pattern>
|
||||
</generator>
|
||||
<generator name="TwoLevelCustomURI" prefix="ariadneplus">
|
||||
<pattern>{level1}/{level2}/{term}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="SimpleLabel">
|
||||
<pattern>{label}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="CompositeLabel">
|
||||
<pattern>{label} {text}</pattern>
|
||||
</generator>
|
||||
|
||||
<generator name="URIorUUID">
|
||||
<custom generatorClass="gr.forth.URIorUUID">
|
||||
<set-arg name="text"/>
|
||||
</custom>
|
||||
</generator>
|
||||
|
||||
<generator name="URNfromTextualContent">
|
||||
<custom generatorClass="gr.forth.TextualContent">
|
||||
<set-arg name="text" type="xpath"/>
|
||||
</custom>
|
||||
</generator>
|
||||
|
||||
<generator name="TypedLiteralGen">
|
||||
<custom generatorClass="gr.forth.TypedLiteralGenerator">
|
||||
<set-arg name="text"/>
|
||||
</custom>
|
||||
</generator>
|
||||
|
||||
|
||||
</generator_policy>
|
Loading…
Reference in New Issue