You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Valerio Belcastro <va...@gmail.com> on 2016/03/05 12:57:33 UTC
Jena Fuseki named graph issue
Hi guys,
I launched Fuseki 2.3.1 as a standalone server on my local machine from
command line like this:
path-to-fuseki-folder>fuseki-server --update --mem /myData
Then I uploaded some data into the dataset default graph using this code
snippet:
String personURI = "http://somewhere/JohnSmith";
String malcolmURI = "http://somewhere/MalcolmGraves";
String givenName = "John";
String familyName = "Smith";
String fullName = givenName + " " + familyName;
String fullName2 = "Malcolm Graves";
String email = givenName+familyName+"@gmail.com";
// create an empty Model
Model model = ModelFactory.createDefaultModel();
// create the resource // and add the properties cascading style
Resource johnSmith
= model.createResource(personURI)
.addProperty(VCARD.FN, fullName)
.addProperty(VCARD.N,
model.createResource()
.addProperty(VCARD.Given, givenName)
.addProperty(VCARD.Family, familyName));
model.setNsPrefix("vcard", VCARD.getURI());
DatasetAccessor dsa = DatasetAccessorFactory.createHTTP("http:/
/localhost:3030/myData/data");
dsa.add(model);
After that, I retrieved the default graph and printed his prefix map:
Iterator<Map.Entry<String, String>> nsIt = dsga.getModel().getN
sPrefixMap().entrySet().iterator();
nsIt.forEachRemaining(ns -> {
System.out.println(ns); });
The output I obtained is the following:
vcard=http://www.w3.org/2001/vcard-rdf/3.0#
rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#
If I do the same thing loading the model into a named graph instead of
the defaultgraph nothing is printed on console, it is like the prefix
map is empty.
Do I need to configure something to make things work?
Thank you in advance
Re: Jena Fuseki named graph issue
Posted by Andy Seaborne <an...@apache.org>.
On 06/03/16 18:30, Valerio Belcastro wrote:
> Do I need to get the entire default graph each time I need prefixes? Isn't
> this low-performant when dealing with big default graphs?
Not if the graph is empty :-)
But any graph-based query will return the prefixes regardless of results
so for example:
CONSTRUCT {} WHERE {FILTER(false) }
or
CONSTRUCT WHERE {}
Andy
>
> 2016-03-06 17:41 GMT+01:00 Andy Seaborne <an...@apache.org>:
>
>> The prefixes for serialization are taken from the default graph.
>>
>> You can load the default graph just with prefixes, and no triples, to
>> control the output from a named graph.
>>
>> Andy
>>
>>
>> On 05/03/16 11:57, Valerio Belcastro wrote:
>>
>>> Hi guys,
>>>
>>> I launched Fuseki 2.3.1 as a standalone server on my local machine from
>>> command line like this:
>>>
>>> path-to-fuseki-folder>fuseki-server --update --mem /myData
>>>
>>> Then I uploaded some data into the dataset default graph using this code
>>> snippet:
>>>
>>> String personURI = "http://somewhere/JohnSmith";
>>> String malcolmURI = "http://somewhere/MalcolmGraves";
>>> String givenName = "John";
>>> String familyName = "Smith";
>>> String fullName = givenName + " " + familyName;
>>> String fullName2 = "Malcolm Graves";
>>> String email = givenName+familyName+"@gmail.com";
>>> // create an empty Model
>>> Model model = ModelFactory.createDefaultModel();
>>> // create the resource // and add the properties cascading style
>>> Resource johnSmith
>>> = model.createResource(personURI)
>>> .addProperty(VCARD.FN, fullName)
>>> .addProperty(VCARD.N,
>>> model.createResource()
>>> .addProperty(VCARD.Given, givenName)
>>> .addProperty(VCARD.Family, familyName));
>>>
>>> model.setNsPrefix("vcard", VCARD.getURI());
>>> DatasetAccessor dsa = DatasetAccessorFactory.createHTTP("http:/
>>> /localhost:3030/myData/data");
>>>
>>> dsa.add(model);
>>>
>>>
>>> After that, I retrieved the default graph and printed his prefix map:
>>>
>>> Iterator<Map.Entry<String, String>> nsIt = dsga.getModel().getN
>>> sPrefixMap().entrySet().iterator();
>>> nsIt.forEachRemaining(ns -> {
>>> System.out.println(ns); });
>>>
>>>
>>> The output I obtained is the following:
>>>
>>> vcard=http://www.w3.org/2001/vcard-rdf/3.0#
>>>
>>> rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#
>>>
>>>
>>> If I do the same thing loading the model into a named graph instead of
>>> the defaultgraph nothing is printed on console, it is like the prefix
>>> map is empty.
>>>
>>> Do I need to configure something to make things work?
>>>
>>> Thank you in advance
>>>
>>>
>>
>
Re: Jena Fuseki named graph issue
Posted by Valerio Belcastro <va...@gmail.com>.
Do I need to get the entire default graph each time I need prefixes? Isn't
this low-performant when dealing with big default graphs?
2016-03-06 17:41 GMT+01:00 Andy Seaborne <an...@apache.org>:
> The prefixes for serialization are taken from the default graph.
>
> You can load the default graph just with prefixes, and no triples, to
> control the output from a named graph.
>
> Andy
>
>
> On 05/03/16 11:57, Valerio Belcastro wrote:
>
>> Hi guys,
>>
>> I launched Fuseki 2.3.1 as a standalone server on my local machine from
>> command line like this:
>>
>> path-to-fuseki-folder>fuseki-server --update --mem /myData
>>
>> Then I uploaded some data into the dataset default graph using this code
>> snippet:
>>
>> String personURI = "http://somewhere/JohnSmith";
>> String malcolmURI = "http://somewhere/MalcolmGraves";
>> String givenName = "John";
>> String familyName = "Smith";
>> String fullName = givenName + " " + familyName;
>> String fullName2 = "Malcolm Graves";
>> String email = givenName+familyName+"@gmail.com";
>> // create an empty Model
>> Model model = ModelFactory.createDefaultModel();
>> // create the resource // and add the properties cascading style
>> Resource johnSmith
>> = model.createResource(personURI)
>> .addProperty(VCARD.FN, fullName)
>> .addProperty(VCARD.N,
>> model.createResource()
>> .addProperty(VCARD.Given, givenName)
>> .addProperty(VCARD.Family, familyName));
>>
>> model.setNsPrefix("vcard", VCARD.getURI());
>> DatasetAccessor dsa = DatasetAccessorFactory.createHTTP("http:/
>> /localhost:3030/myData/data");
>>
>> dsa.add(model);
>>
>>
>> After that, I retrieved the default graph and printed his prefix map:
>>
>> Iterator<Map.Entry<String, String>> nsIt = dsga.getModel().getN
>> sPrefixMap().entrySet().iterator();
>> nsIt.forEachRemaining(ns -> {
>> System.out.println(ns); });
>>
>>
>> The output I obtained is the following:
>>
>> vcard=http://www.w3.org/2001/vcard-rdf/3.0#
>>
>> rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#
>>
>>
>> If I do the same thing loading the model into a named graph instead of
>> the defaultgraph nothing is printed on console, it is like the prefix
>> map is empty.
>>
>> Do I need to configure something to make things work?
>>
>> Thank you in advance
>>
>>
>
Re: Jena Fuseki named graph issue
Posted by Andy Seaborne <an...@apache.org>.
The prefixes for serialization are taken from the default graph.
You can load the default graph just with prefixes, and no triples, to
control the output from a named graph.
Andy
On 05/03/16 11:57, Valerio Belcastro wrote:
> Hi guys,
>
> I launched Fuseki 2.3.1 as a standalone server on my local machine from
> command line like this:
>
> path-to-fuseki-folder>fuseki-server --update --mem /myData
>
> Then I uploaded some data into the dataset default graph using this code
> snippet:
>
> String personURI = "http://somewhere/JohnSmith";
> String malcolmURI = "http://somewhere/MalcolmGraves";
> String givenName = "John";
> String familyName = "Smith";
> String fullName = givenName + " " + familyName;
> String fullName2 = "Malcolm Graves";
> String email = givenName+familyName+"@gmail.com";
> // create an empty Model
> Model model = ModelFactory.createDefaultModel();
> // create the resource // and add the properties cascading style
> Resource johnSmith
> = model.createResource(personURI)
> .addProperty(VCARD.FN, fullName)
> .addProperty(VCARD.N,
> model.createResource()
> .addProperty(VCARD.Given, givenName)
> .addProperty(VCARD.Family, familyName));
>
> model.setNsPrefix("vcard", VCARD.getURI());
> DatasetAccessor dsa = DatasetAccessorFactory.createHTTP("http:/
> /localhost:3030/myData/data");
>
> dsa.add(model);
>
>
> After that, I retrieved the default graph and printed his prefix map:
>
> Iterator<Map.Entry<String, String>> nsIt = dsga.getModel().getN
> sPrefixMap().entrySet().iterator();
> nsIt.forEachRemaining(ns -> {
> System.out.println(ns); });
>
>
> The output I obtained is the following:
>
> vcard=http://www.w3.org/2001/vcard-rdf/3.0#
>
> rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#
>
>
> If I do the same thing loading the model into a named graph instead of
> the defaultgraph nothing is printed on console, it is like the prefix
> map is empty.
>
> Do I need to configure something to make things work?
>
> Thank you in advance
>
Re: Jena Fuseki named graph issue
Posted by Luca Ambrosini <lu...@gmail.com>.
Hi,
I’m an apache Jena user too.
Unfortunately i’m not texting you because i have a solution for you problem but because i hope you can help me with mine.
I will be glad to help you in the future.
Here is my question :
Which version of apache HttpCore and HttpClient are you using ?
I’m trying to use DataAccessor as you but my code does not run.
You can find more informations about my question here :
http://stackoverflow.com/questions/35813506/jena-datasetaccessor-http-incompatibility
Any help is very appreciated, i’m stuck since 5 days :(
Thank you so much
Luca
> On 05 Mar 2016, at 12:57, Valerio Belcastro <va...@gmail.com> wrote:
>
> Hi guys,
>
> I launched Fuseki 2.3.1 as a standalone server on my local machine from
> command line like this:
>
> path-to-fuseki-folder>fuseki-server --update --mem /myData
>
> Then I uploaded some data into the dataset default graph using this code
> snippet:
>
> String personURI = "http://somewhere/JohnSmith";
> String malcolmURI = "http://somewhere/MalcolmGraves";
> String givenName = "John";
> String familyName = "Smith";
> String fullName = givenName + " " + familyName;
> String fullName2 = "Malcolm Graves";
> String email = givenName+familyName+"@gmail.com";
> // create an empty Model
> Model model = ModelFactory.createDefaultModel();
> // create the resource // and add the properties cascading style
> Resource johnSmith
> = model.createResource(personURI)
> .addProperty(VCARD.FN, fullName)
> .addProperty(VCARD.N,
> model.createResource()
> .addProperty(VCARD.Given, givenName)
> .addProperty(VCARD.Family, familyName));
>
> model.setNsPrefix("vcard", VCARD.getURI());
> DatasetAccessor dsa = DatasetAccessorFactory.createHTTP("http:/
> /localhost:3030/myData/data");
>
> dsa.add(model);
>
>
> After that, I retrieved the default graph and printed his prefix map:
>
> Iterator<Map.Entry<String, String>> nsIt = dsga.getModel().getN
> sPrefixMap().entrySet().iterator();
> nsIt.forEachRemaining(ns -> {
> System.out.println(ns); });
>
>
> The output I obtained is the following:
>
> vcard=http://www.w3.org/2001/vcard-rdf/3.0#
>
> rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#
>
>
> If I do the same thing loading the model into a named graph instead of
> the defaultgraph nothing is printed on console, it is like the prefix
> map is empty.
>
> Do I need to configure something to make things work?
>
> Thank you in advance