Skip to content

Commit

Permalink
first binary distrbution
Browse files Browse the repository at this point in the history
1. First R2RML binary available, generated using maven assembly plugin
2. Spring context file can be passed as a command-line argument
3. Catch exception and inform user when input model does not exist
  • Loading branch information
nkons committed Jul 14, 2013
1 parent 5d64c4e commit a0c09bf
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF>
<rdf:RDF xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

</rdf:RDF>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF>
<rdf:RDF xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:dcam="http://purl.org/dc/dcam/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

</rdf:RDF>
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions dspace/epersons-mapping.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@prefix map: <#>.
@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix dc: <http://purl.org/dc/elements/1.1/>.
@prefix dcterms: <http://purl.org/dc/terms/>.
@prefix dctype: <http://purl.org/dc/dcmitype/>.
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

map:groups
rr:logicalTable [ rr:tableName '"epersongroup"'; ];
rr:subjectMap [
rr:template 'http://data.example.org/repository/group/{"eperson_group_id"}';
rr:class foaf:Group;
];

rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [ rr:template '{"name"}' ;
rr:termType rr:Literal; ]
].

map:persons
rr:logicalTable [ rr:tableName '"eperson"'; ];
rr:subjectMap [
rr:template 'http://data.example.org/repository/person/{"eperson_id"}';
rr:class foaf:Person;
];

rr:predicateObjectMap [
rr:predicate foaf:name;
rr:objectMap [ rr:template '{"firstname"} {"lastname"}' ;
rr:termType rr:Literal; ]
].

map:persons-groups
rr:logicalTable [ rr:tableName '"epersongroup2eperson"'; ];
rr:subjectMap [
rr:template 'http://data.example.org/repository/group/{"eperson_group_id"}';
];

rr:predicateObjectMap [
rr:predicate foaf:member;
rr:objectMap [ rr:template 'http://data.example.org/repository/person/{"eperson_id"}' ;
rr:termType rr:IRI; ]
].

35 changes: 34 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,45 @@
<artifactId>r2rml</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>r2rml implementation</name>
<name>R2RML Parser</name>
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<spring.framework.version>3.2.1.RELEASE</spring.framework.version>
</properties>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<!-- overall project assembly -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>src/assemble/assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>directory-single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
4 changes: 4 additions & 0 deletions r2rml-parser.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
echo This is R2RML Parser

java -cp "./*;./lib/*;" gr.ekt.r2rml.beans.Main %1
3 changes: 3 additions & 0 deletions r2rml-parser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
echo "This is R2RML Parser"

java -cp "./*;./lib/*;" gr.ekt.r2rml.beans.Main
128 changes: 64 additions & 64 deletions src/main/resources/r2rml.properties → r2rml.properties
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
#---------------------------------------------------------------#
#-------------------- General configuration --------------------#
#---------------------------------------------------------------#
mapping.file=src/main/resources/dspace/dspace-mapping.rdf

# Valid types are RDF/XML, N-TRIPLE, TURTLE, TTL, N3.
mapping.file.type=TURTLE

default.namespace=http://example.com/base

# Uncomment the following to log inserted triples
default.verbose=false

# File where last run is logged
default.log=status.rdf

#---------------------------------------------------------------#
#------------------------- Input Model -------------------------#
#---------------------------------------------------------------#
input.model=src/main/resources/dspace/dcterms-empty.rdf

# Valid types are RDF/XML, N-TRIPLE, TURTLE, TTL, N3.
#input.model.type=TURTLE
input.model.type=RDF/XML

#---------------------------------------------------------------#
#-------------------- Database connectivity --------------------#
#---------------------------------------------------------------#
#db.host=127.0.0.1
#db.port=3306
#db.name=sakila
#db.login=root
#db.password=1234
#db.driver=com.mysql.jdbc.Driver

db.host=localhost
db.port=5432
db.name=dspace3
db.login=postgres
db.password=postgres
db.driver=org.postgresql.Driver

#---------------------------------------------------------------#
#------------------ Jena Database Output ----------------------#
#---------------------------------------------------------------#
jena.db.host=127.0.0.1
jena.db.port=3306
jena.db.name=jena
jena.db.login=root
jena.db.password=1234
jena.db.driver=com.mysql.jdbc.Driver

# Store the resulting triples in the database
jena.storeOutputModelInDatabase=false
# Clean database on startup is activated only when the output model is stored in the database, i.e. jena.storeOutputModelInDatabase is true
jena.cleanDbOnStartup=false

#---------------------------------------------------------------#
#---------------------- Jena File Output -----------------------#
#---------------------------------------------------------------#

#in case we will output the resulting triples in a file. This matters if property jena.storeOutputModelInDatabase is false
jena.destinationFileName=dump3.rdf
jena.destinationFileSyntax=N3
#---------------------------------------------------------------#
#-------------------- General configuration --------------------#
#---------------------------------------------------------------#
mapping.file=dspace/epersons-mapping.rdf

# Valid types are RDF/XML, N-TRIPLE, TURTLE, TTL, N3.
mapping.file.type=TURTLE

default.namespace=http://example.com/base

# Uncomment the following to log inserted triples
default.verbose=false

# File where last run is logged
default.log=status.rdf

#---------------------------------------------------------------#
#------------------------- Input Model -------------------------#
#---------------------------------------------------------------#
input.model=dspace/dcterms-empty.rdf

# Valid types are RDF/XML, N-TRIPLE, TURTLE, TTL, N3.
#input.model.type=TURTLE
input.model.type=RDF/XML

#---------------------------------------------------------------#
#-------------------- Database connectivity --------------------#
#---------------------------------------------------------------#
#db.host=127.0.0.1
#db.port=3306
#db.name=sakila
#db.login=root
#db.password=1234
#db.driver=com.mysql.jdbc.Driver

db.host=localhost
db.port=5432
db.name=dspace3
db.login=postgres
db.password=postgres
db.driver=org.postgresql.Driver

#---------------------------------------------------------------#
#------------------ Jena Database Output ----------------------#
#---------------------------------------------------------------#
jena.db.host=127.0.0.1
jena.db.port=3306
jena.db.name=jena
jena.db.login=root
jena.db.password=1234
jena.db.driver=com.mysql.jdbc.Driver

# Store the resulting triples in the database
jena.storeOutputModelInDatabase=false
# Clean database on startup is activated only when the output model is stored in the database, i.e. jena.storeOutputModelInDatabase is true
jena.cleanDbOnStartup=false

#---------------------------------------------------------------#
#---------------------- Jena File Output -----------------------#
#---------------------------------------------------------------#

#in case we will output the resulting triples in a file. This matters if property jena.storeOutputModelInDatabase is false
jena.destinationFileName=dump3-epersons.rdf
jena.destinationFileSyntax=N3
52 changes: 52 additions & 0 deletions src/assemble/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<assembly xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.1.0-SNAPSHOT.xsd">
<id>build</id>

<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>

<fileSets>
<fileSet>
<outputDirectory>.</outputDirectory>
<includes>
<include>dspace/**</include>
<include>r2rml-parser.bat</include>
<include>r2rml-parser.sh</include>
</includes>
<excludes>
<exclude>src/**</exclude>
</excludes>
</fileSet>
</fileSets>

<files>
<file>
<source>src/main/resources/app-context.xml</source>
<outputDirectory>.</outputDirectory>
<destName>app-context.xml</destName>
<filtered>false</filtered>
</file>
<file>
<source>src/main/resources/log4j.xml</source>
<outputDirectory>.</outputDirectory>
<destName>log4j.xml</destName>
<filtered>false</filtered>
</file>
<file>
<source>r2rml.properties</source>
<outputDirectory>.</outputDirectory>
<destName>r2rml.properties</destName>
<filtered>false</filtered>
</file>
</files>

<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>

</assembly>
4 changes: 2 additions & 2 deletions src/main/java/gr/ekt/r2rml/beans/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ public void createTriples(MappingDocument mappingDocument) {
}

} else if (predicateObjectMap.getRefObjectMapUri() != null) {
log.info("Object uris will be the subjects of the referenced triples, created previously by the logical table mapping with the uri " + predicateObjectMap.getRefObjectMapUri());
if (verbose) log.info("Object uris will be the subjects of the referenced triples, created previously by the logical table mapping with the uri " + predicateObjectMap.getRefObjectMapUri());
LogicalTableMapping l = mappingDocument.findLogicalTableMappingByUri(predicateObjectMap.getRefObjectMapUri());
log.info("The logical table mapping with the uri " + l.getUri() + " has already generated "+ l.getTriples().size() + " triples.");
if (verbose) log.info("The logical table mapping with the uri " + l.getUri() + " has already generated "+ l.getTriples().size() + " triples.");

for (Statement existingStatement : l.getTriples()) {
String existingSubjectUri = existingStatement.asTriple().getSubject().getURI();
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/gr/ekt/r2rml/beans/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import gr.ekt.r2rml.entities.MappingDocument;

import java.io.File;
import java.util.Calendar;

import org.slf4j.Logger;
Expand All @@ -23,9 +24,21 @@ public class Main {
private static final Logger log = LoggerFactory.getLogger(Main.class);

public static void main(String[] args) {
String appContextFile = "app-context.xml";
if (args.length > 0) {
File f = new File(args[0]);
if (f.exists()) {
log.info("Spring context descriptor set to " + args[0]);
appContextFile = args[0];
} else {
log.info("File " + args[0] + " not in classpath, using app-context.xml instead");
}
} else {
log.info("Spring context file not provided, using app-context.xml");
}
Calendar c0 = Calendar.getInstance();
long t0 = c0.getTimeInMillis();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("app-context.xml");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(appContextFile);

Parser parser = (Parser) context.getBean("parser");
MappingDocument mappingDocument = parser.parse();
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/gr/ekt/r2rml/beans/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,11 @@ public void init() {

InputStream isMap = FileManager.get().open(mappingFilename);
mapModel = ModelFactory.createDefaultModel();
mapModel.read(isMap, baseNs, properties.getProperty("mapping.file.type"));
try {
mapModel.read(isMap, baseNs, properties.getProperty("mapping.file.type"));
} catch (Exception e) {
log.info("Error reading input model");
}
//mapModel.write(System.out, properties.getProperty("mapping.file.type"));

String inputModelFileName = properties.getProperty("input.model");
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/app-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<bean id="util" class="gr.ekt.r2rml.beans.UtilImpl" />

<bean id="db" class="gr.ekt.r2rml.beans.DatabaseImpl">
<constructor-arg value="src/main/resources/r2rml.properties" />
<constructor-arg value="r2rml.properties" />
<property name="util" ref="util" />
</bean>

<bean id="parser" class="gr.ekt.r2rml.beans.Parser">
<constructor-arg value="src/main/resources/r2rml.properties" />
<constructor-arg value="r2rml.properties" />
<property name="db" ref="db" />
<property name="util" ref="util" />
</bean>
Expand Down

0 comments on commit a0c09bf

Please sign in to comment.