You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@marmotta.apache.org by Diego Benna <di...@gmail.com> on 2013/09/03 10:20:12 UTC

Import RDF file with API

Dear community,
I'm doing the university thesis and I'am very interested about Apache
Marmotta. I would like to contribute to the community by producing
good documentation and examples.
I'm building a Crawler which inserts the rdf file in Apache Marmotta.
I don't understand the documentation in Marmotta
{BASE}/core/doc/core/import/upload/index.html

I want to use in my program the following API to import my file "clients.rdf"

ImportWebService.uploadData ({'context': / * upload content and import
it into the LMF system. * /,
   'Content-Type': / * type for the content type of the uploaded content * /});

But how should I write it? Most important thing is that I do not know
which jar file to import in my java project in NetBeans. Can you help
me?
thanks

Diego

Re: Import RDF file with API

Posted by Sergio Fernández <wi...@apache.org>.
Hi,

On 03/09/13 14:22, Diego Benna wrote:
> Thanks Sergio, you're nice. I was able to import the Client Library
> Marmot and I was trying the following example, shown in your link:
>
> String path = "/path/to/file.rdf";
> String context = "http://example.org/context";
> ClientConfiguration configuration = new
> ClientConfiguration("http://host/marmotta/");
> ImportClient importClient = new ImportClient(configuration);
> InputStream is = new FileInputStream(new File(path));
> RDFFormat format = Rio.
> getParserFormatForFileName(path);
> importClient.uploadDataset(is, format.getDefaultMIMEType(), context);
>
> What library is RDFFormat and Rio? I don't find dependency in Maven
> with NetBeans.
>    RDFFormat is part of the project http://www.openrdf.org/?
> http://www.openrdf.org/doc/sesame2/api/org/openrdf/rio/RDFFormat.html
> And Rio?

RDFFormat is part of the Sesame RIO API, right. For using it, you may 
need to include the following dependency in your project:

   <dependency>
     <groupId>org.openrdf.sesame</groupId>
     <artifactId>sesame-rio-api</artifactId>
     <version>2.7.5</version>
   </dependency>

Further details at the Sesame documentation:

http://openrdf.callimachus.net/sesame/2.7/docs/users.docbook?view#Parsing_and_Writing_RDF_with_Rio

But those classes are not strictly required. That's only the generic way 
to guess the RDF format (so the parser) based on the file name. But if 
you know the RDF format, you don't need it since you can set it directly 
in your code; something like:

importClient.uploadDataset(is, "application/rdf+xml", context);

> Another question:
> path = path of the file to be imported

Yes. But from that generic example, you can customize how you build the 
InputStream to your files.

> configuration = server url

The URI where Marmotta runs is the minimum configuration required; you 
you may need something else, such as user and password when required to 
access the server.

> context = what would it be?

That's the context name, named graph if you prefer it, where triples 
will be imported. Further information at:

http://www.w3.org/TR/sparql11-query/#namedGraphs

If you don't pass such parameter in the call, Marmotta will use the 
default context name to import the data.

Cheers,

-- 
Sergio Fernández

Re: Import RDF file with API

Posted by Diego Benna <di...@gmail.com>.
Thanks Sergio, you're nice. I was able to import the Client Library
Marmot and I was trying the following example, shown in your link:

String path = "/path/to/file.rdf";
String context = "http://example.org/context";
ClientConfiguration configuration = new
ClientConfiguration("http://host/marmotta/");
ImportClient importClient = new ImportClient(configuration);
InputStream is = new FileInputStream(new File(path));
RDFFormat format = Rio.
getParserFormatForFileName(path);
importClient.uploadDataset(is, format.getDefaultMIMEType(), context);

What library is RDFFormat and Rio? I don't find dependency in Maven
with NetBeans.
  RDFFormat is part of the project http://www.openrdf.org/?
http://www.openrdf.org/doc/sesame2/api/org/openrdf/rio/RDFFormat.html
And Rio?

Another question:
path = path of the file to be imported
configuration = server url
context = what would it be?

Thank you very much

Diego

2013/9/3 Sergio Fernández <wi...@apache.org>:
> Hi Diego.
>
>
> On 03/09/13 10:20, Diego Benna wrote:
>>
>> Dear community,
>> I'm doing the university thesis and I'am very interested about Apache
>> Marmotta. I would like to contribute to the community by producing
>> good documentation and examples.
>> I'm building a Crawler which inserts the rdf file in Apache Marmotta.
>> I don't understand the documentation in Marmotta
>> {BASE}/core/doc/core/import/upload/index.html
>
>
> The first question I'd like to know is: where do you plan to run such code?
> Because there are two options:
>
> a) Running as module in the platform.
>
> b) Running out of the platform
>
> Most likely would be this second one, right? For such the most convenient
> way is to use the Marmotta's Client Library, which already offer clients for
> the different web services, currently in Java, PHP and Javascript.
>
> Further details at:
>
>   http://marmotta.incubator.apache.org/client-library.html
>
>
>> I want to use in my program the following API to import my file
>> "clients.rdf"
>>
>> ImportWebService.uploadData ({'context': / * upload content and import
>> it into the LMF system. * /,
>>     'Content-Type': / * type for the content type of the uploaded content
>> * /});
>
>
> In the wiki you could find a brief summary (with code snippet) how to import
> data into Marmotta:
>
>   http://wiki.apache.org/marmotta/ImportData
>
>
>> But how should I write it? Most important thing is that I do not know
>> which jar file to import in my java project in NetBeans. Can you help
>> me?
>
>
> If you are using Maven in NetBeans, you can directly use the Maven
> artifacts:
>
>   <dependency>
>     <groupId>org.apache.marmotta</groupId>
>     <artifactId>marmotta-client-java</artifactId>
>     <version>3.1.0-incubating-SNAPSHOT</version>
>   </dependency>
>
> I agree we must improve the documentation.. so any feedback would be
> welcomed ;-)
>
> Cheers,
>
> --
> Sergio Fernández

Re: Import RDF file with API

Posted by Sergio Fernández <wi...@apache.org>.
Hi Diego.

On 03/09/13 10:20, Diego Benna wrote:
> Dear community,
> I'm doing the university thesis and I'am very interested about Apache
> Marmotta. I would like to contribute to the community by producing
> good documentation and examples.
> I'm building a Crawler which inserts the rdf file in Apache Marmotta.
> I don't understand the documentation in Marmotta
> {BASE}/core/doc/core/import/upload/index.html

The first question I'd like to know is: where do you plan to run such 
code? Because there are two options:

a) Running as module in the platform.

b) Running out of the platform

Most likely would be this second one, right? For such the most 
convenient way is to use the Marmotta's Client Library, which already 
offer clients for the different web services, currently in Java, PHP and 
Javascript.

Further details at:

   http://marmotta.incubator.apache.org/client-library.html

> I want to use in my program the following API to import my file "clients.rdf"
>
> ImportWebService.uploadData ({'context': / * upload content and import
> it into the LMF system. * /,
>     'Content-Type': / * type for the content type of the uploaded content * /});

In the wiki you could find a brief summary (with code snippet) how to 
import data into Marmotta:

   http://wiki.apache.org/marmotta/ImportData

> But how should I write it? Most important thing is that I do not know
> which jar file to import in my java project in NetBeans. Can you help
> me?

If you are using Maven in NetBeans, you can directly use the Maven 
artifacts:

   <dependency>
     <groupId>org.apache.marmotta</groupId>
     <artifactId>marmotta-client-java</artifactId>
     <version>3.1.0-incubating-SNAPSHOT</version>
   </dependency>

I agree we must improve the documentation.. so any feedback would be 
welcomed ;-)

Cheers,

-- 
Sergio Fernández