The following snipped of code is a modified version of the one I found in the openrdf forum:
For running this code it is necessary to perform a bunch of imports:
Repository myRepository = new VirtuosoRepository("jdbc:virtuoso://localhost:1111","dba","dba");
myRepository.initialize();
File file = new File("/Users/paolociccarese/Desktop/contact.rdf");
RepositoryConnection con = myRepository.getConnection();
URI context = new URIImpl("http://paolociccarese.info/contact");
con.add(file, null, RDFFormat.RDFXML, context);
con.close();
To make it work, if you use grails and ivy (ivy.xml), you should add at least the following dependencies:
import org.openrdf.model.URI;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.rio.RDFFormat
import org.openrdf.repository.Repository
import org.openrdf.repository.RepositoryConnection
<dependency org="org.openrdf" name="openrdf-repository-api" rev="2.0.1" conf="compile"/>
<dependency org="org.openrdf" name="openrdf-rio-rdfxml" rev="2.0.1" conf="compile"/>
<dependency org="org.openrdf" name="openrdf-model" rev="2.0.1" conf="compile"/>
and you also need to link to the maven repository for these in the ivysettings.xml file:
<ibiblio name="aduna" root="http://repository.aduna-software.org/maven2" m2compatible="true"/>
and finally run the command >grails get-dependencies again.
No comments:
Post a Comment