How to get all leaf subclass nodes in class view

2014-10-09 Thread Deyan Chen

Hi all,

Is there a convenient way to get all leaf subclass nodes in class view?

Any suggestions and ideas are always welcome.

Thanks in advance.

Deyan Chen
---
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---


jena-text and persistent lucene index

2014-10-09 Thread Phillip Rhodes
Jena crew:

I have Jena-Text pretty much working for what I want to do, but with
one caveat... it only seems to work with the Lucene RamDirectory.  If
I use a persistent dir, I don't find any documents being written to
the Lucene index.  Any help or suggestions are greatly appreciated.
Code sample follows:


---CODE---


package org.fogbeam.example.jenatext

import org.apache.jena.query.text.EntityDefinition
import org.apache.jena.query.text.TextDatasetFactory
import org.apache.jena.query.text.TextQuery
import org.apache.lucene.store.Directory
import org.apache.lucene.store.FSDirectory

import com.hp.hpl.jena.query.Dataset
import com.hp.hpl.jena.query.ReadWrite
import com.hp.hpl.jena.rdf.model.Model
import com.hp.hpl.jena.rdf.model.Resource
import com.hp.hpl.jena.rdf.model.Statement
import com.hp.hpl.jena.tdb.TDBFactory
import com.hp.hpl.jena.vocabulary.RDFS

class JenaTextMain6Write
{

static main(args)
{

TextQuery.init();

EntityDefinition entDef = new EntityDefinition("uri", "text",
RDFS.label.asNode()) ;

// Lucene, in memory.
Directory dir =  FSDirectory.open( new File( "jenastore/index" ) );

// Join together into a dataset
Dataset tdbDataset = TDBFactory.createDataset("jenastore/triples");
Dataset ds = TextDatasetFactory.createLucene(tdbDataset, dir, entDef);


try
{

ds.begin(ReadWrite.WRITE);

Model m = ds.getDefaultModel();

Resource rSubject = m.createResource(
"http://ontology.fogbeam.com/example/TestResource1"; );
Resource rSubject2 = m.createResource(
"http://ontology.fogbeam.com/example/TestResource2"; );


Statement s = m.createStatement(rSubject, RDFS.label,
"This is a Test Resource" );

m.add( s );

Statement s2 = m.createStatement(rSubject2, RDFS.label,
"Bratwurst Test" );

m.add( s2 );

ds.commit();

dir.close();

}
catch( Exception e )
{
e.printStackTrace();
ds.abort();
}
finally
{
if( ds != null )
{
ds.end();
}
}

println "done";
}

}

--- END CODE---



Phil
---
This message optimized for indexing by NSA PRISM


Good Style to interact with Jena

2014-10-09 Thread Benjamin Eckstein
Hello again,

i made some progress with my first Jena Application, but i am really unsure
if this way i am doing
things is "good practice".
can anybody do a quick review and give me a feedback?

http://pastebin.com/S4iFTytz

Basic Idea:

I create a "Model" Class to interact with Individuals for each OntClass.
This way i do not need to repeat URIs for properties and can have functions
like ... create Additional Data from the Input.

Each Model Class has an inner Metaclass that keeps track about the semantic
like Namespace Properties etc...

Thanks for any Feedback from experienced Jena Users.

Btw: keeping the Metamodel static and do not create properties on demand
increases performance from 71 to 50 seconds. (Import from DB to Ontology).


RE: Using Fuseki 2 as a web application

2014-10-09 Thread John A. Fereira
Hijacking an old thread 

I've been playing around with the jena-fuseki2 code (from a recent clone of the 
jena git repository) and have made pretty good progress getting it to work with 
SDB, using the ReconnectingSDB jar file 
(https://github.com/shellac/ReconnectingSDB).   On my laptop (windows 7),  I 
have a configuration which connects to a SDB and deploys successfully into 
Tomcat.  Although there are quite a few broken links in the UI, I can execute 
sparql select queries and get valid results.  Now here's the weird part.  If I 
copy all the code over to a linux box, everything seems to work.  It deploys 
into tomcat but when I go to the web app it doesn't seem to recognize that any 
datasets are available.  The logger output looks identical to what I am seeing 
on my laptop (no errors, /ds was registered as a dataset) but the app 
doesn't think it's available.

Any ideas?


Re: [] Jena 2.12.1 released

2014-10-09 Thread Osma Suominen
Thank you Rob and others for the release! It's good to have rather short 
release cycles (seems to have been around 2 months recently), as it 
makes it more meaningful to contribute to the development knowing that 
the patches will end up pretty soon in an official release.


Keep up the good work!

-Osma

On 09/10/14 16:20, Andy Seaborne wrote:

Rob,

Thank you for doing this release, updating the process document and
dealing with all the consequences of the move to git for the release
process.

 Andy

On 09/10/14 11:18, Rob Vesse wrote:

We are pleased to announce the release of Apache Jena 2.12.1 which
includes Apache Jena Fuseki 1.1.1.

Users are reminded that from Jena 2.12.1 requires Java 7.

Thanks as ever to everyone who has contributed to this release.

The code changes can be found in the list of resolved issues at

 http://s.apache.org/jena2.12.1-changes

Download Jena via the mirrors and links at

 http://jena.apache.org/download/index.html

or from Maven central.

Rob










--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Teollisuuskatu 23)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suomi...@helsinki.fi
http://www.nationallibrary.fi


Re: [] Jena 2.12.1 released

2014-10-09 Thread Andy Seaborne

Rob,

Thank you for doing this release, updating the process document and 
dealing with all the consequences of the move to git for the release 
process.


Andy

On 09/10/14 11:18, Rob Vesse wrote:

We are pleased to announce the release of Apache Jena 2.12.1 which
includes Apache Jena Fuseki 1.1.1.

Users are reminded that from Jena 2.12.1 requires Java 7.

Thanks as ever to everyone who has contributed to this release.

The code changes can be found in the list of resolved issues at

 http://s.apache.org/jena2.12.1-changes

Download Jena via the mirrors and links at

 http://jena.apache.org/download/index.html

or from Maven central.

Rob









Re: Q. about RDFDataMgr & BadURIException

2014-10-09 Thread Andy Seaborne

For better for for worse, this only affects RDF/XML.

In RDF/XML some URIs can not be relative - properties, and class names 
in striped syntax.


You have to be careful in JSON-LD about relative properties.

Andy

On 09/10/14 11:39, Andy Seaborne wrote:

Nicolas,

Which version of Jena are you referring to? (the line number for
RDFDataMgr does not seem to line up).

And what's the data being serialized?  There is some BananaDRF
processing applied to the data read in teh example.  Could you provide
(N-Triples is quite forgiving) the data or a short, standalone program
that can produce it?

There is some confusion about relative URIs here.

The RDF data model is defined in terms of absolute URIs.  A relative URI
should never occur in an RDF graph.  They can occur in RDF syntax.

A base URI on writing is used to convert an absolute URI to a relative
one in the output syntax.  As the base URI is also written out, the
whole RDF Graph still has absolute URIs when read back in again.

The report you reference was caused by "" as a subject URI.  That's not
legal RDF. <> is not "".

Supplying the baseURI on writing only affects the abbreviation of URIs
in the data. They must be absolute in the data in the first place.

BananaRDF has some way to use Jena so that it creates the output it
wants.  I thought BananaRDF achieved this by adding some sort of
identifiable maker to URIs as the initial part of the URI.

 Andy

On 09/10/14 00:26, Rouquette, Nicolas F (313D) wrote:

I understand that several folks have had this exception in conjunction
with Fuseki/TDB:
http://jena.markmail.org/search/?q=BadURIException#query:BadURIException+pa

ge:1+mid:fur2joez3ny5ibvw+state:results

I've tracked down this exception in a Scala example from the
w3/banana-rdf
project -- specifically:
https://github.com/w3c/banana-rdf/blob/master/examples/src/main/scala/org/w

3/banana/examples/IOExample.scala

This exception happens during the RDF/XML serialization:

Unparser.wObjStar() line: 358
Unparser.wRDF() line: 345
Unparser.write() line: 247
Abbreviated.writeBody(Model, PrintWriter, String, Boolean) line: 142
BaseXMLWriter.writeXMLBody(Model, PrintWriter, String) line: 492
BaseXMLWriter.write(Model, Writer, String) line: 464
Abbreviated.write(Model, Writer, String) line: 127
BaseXMLWriter.write(Model, OutputStream, String) line: 450
AdapterRDFWriter.write(OutputStream, Graph, PrefixMap, String, Context)
line: 52
RDFDataMgr.write$(OutputStream, Graph, RDFFormat) line: 1262
RDFDataMgr.write(OutputStream, Graph, RDFFormat) line: 1028
RDFDataMgr.write(OutputStream, Graph, Lang) line: 1018
JenaRDFWriter$$anon$1$$anonfun$write$1.apply$mcV$sp() line: 20
JenaRDFWriter$$anon$1$$anonfun$write$1.apply() line: 17
JenaRDFWriter$$anon$1$$anonfun$write$1.apply() line: 17
Try$.apply(Function0) line: 191
JenaRDFWriter$$anon$1.write(Graph, OutputStream, String) line: 17
JenaRDFWriter$$anon$1.write(Object, OutputStream, String) line: 15
IOExample$class.main(IOExample, Array[String]) line: 44
IOExampleWithJena$.main(Array[String]) line: 64
IOExampleWithJena.main(Array[String]) line: not available


I believe the problem originates, in part, here:

RDFDataMgr.write$(OutputStream, Graph, RDFFormat) line: 1262


 private static void write$(OutputStream out, Graph graph, RDFFormat
serialization)
 {
 WriterGraphRIOT w = createGraphWriter$(serialization) ;
 w.write(out, graph, RiotLib.prefixMap(graph), null, null) ; //
line 1262
 }

The last 2 null arguments are the values for the "baseURI" and "context"
parameters.
Are all writers able to cope with a null base URI?







It seems that the Turtle writer can but not the RDF/XML writer.
The BadURIException happens during Unparser.wObjStar() when one of the
Resources has a null URI:

BaseXMLWriter.checkURI(String) line: 820
BaseXMLWriter.relativize(String) line: 797
Unparser.wURIreference(String) line: 918
Unparser.wURIreference(Resource) line: 922
Unparser.wAboutAttr(Resource) line: 913
Unparser.wIdAboutAttrOpt(Resource) line: 869
Unparser.wTypedNodeOrDescriptionLong(Unparser$WType, Resource, Resource,
List) line: 830
Unparser.wTypedNodeOrDescription(Unparser$WType, Resource, Resource)
line:
764
Unparser.wTypedNode(Resource) line: 737
Unparser.wObj(Resource, Boolean) line: 677
Unparser.wObjStar() line: 364

Because the writer has a null baseURI, then
BaseXMLWriter.relativize(null)
returns null.
This then fails the URI check; hence the BadURIException.

To avoid this problem, I refactored the call to RDFDataMgr.write(),
originally:

def write(graph: Jena#Graph, os: OutputStream, base: String): Try[Unit] =
Try {
   import org.w3.banana.jena.Jena.ops._
   val relativeGraph : Jena#Graph = graph.relativize(URI(base))
   RDFDataMgr.write(os, relativeGraph, lang)
 }

To the following:

def write(graph: Jena#Graph, os: OutputStream, base: String): Try[Unit] =
Try {
   import org.w3.banana.jena.Jena.ops._
   val relativeGraph : Jena#Graph = graph.relativize(UR

Re: Q. about RDFDataMgr & BadURIException

2014-10-09 Thread Andy Seaborne

Nicolas,

Which version of Jena are you referring to? (the line number for 
RDFDataMgr does not seem to line up).


And what's the data being serialized?  There is some BananaDRF 
processing applied to the data read in teh example.  Could you provide 
(N-Triples is quite forgiving) the data or a short, standalone program 
that can produce it?


There is some confusion about relative URIs here.

The RDF data model is defined in terms of absolute URIs.  A relative URI 
should never occur in an RDF graph.  They can occur in RDF syntax.


A base URI on writing is used to convert an absolute URI to a relative 
one in the output syntax.  As the base URI is also written out, the 
whole RDF Graph still has absolute URIs when read back in again.


The report you reference was caused by "" as a subject URI.  That's not 
legal RDF. <> is not "".


Supplying the baseURI on writing only affects the abbreviation of URIs 
in the data. They must be absolute in the data in the first place.


BananaRDF has some way to use Jena so that it creates the output it 
wants.  I thought BananaRDF achieved this by adding some sort of 
identifiable maker to URIs as the initial part of the URI.


Andy

On 09/10/14 00:26, Rouquette, Nicolas F (313D) wrote:

I understand that several folks have had this exception in conjunction
with Fuseki/TDB:
http://jena.markmail.org/search/?q=BadURIException#query:BadURIException+pa
ge:1+mid:fur2joez3ny5ibvw+state:results

I've tracked down this exception in a Scala example from the w3/banana-rdf
project -- specifically:
https://github.com/w3c/banana-rdf/blob/master/examples/src/main/scala/org/w
3/banana/examples/IOExample.scala

This exception happens during the RDF/XML serialization:

Unparser.wObjStar() line: 358   
Unparser.wRDF() line: 345   
Unparser.write() line: 247  
Abbreviated.writeBody(Model, PrintWriter, String, Boolean) line: 142
BaseXMLWriter.writeXMLBody(Model, PrintWriter, String) line: 492
BaseXMLWriter.write(Model, Writer, String) line: 464
Abbreviated.write(Model, Writer, String) line: 127  
BaseXMLWriter.write(Model, OutputStream, String) line: 450  
AdapterRDFWriter.write(OutputStream, Graph, PrefixMap, String, Context)
line: 52
RDFDataMgr.write$(OutputStream, Graph, RDFFormat) line: 1262
RDFDataMgr.write(OutputStream, Graph, RDFFormat) line: 1028 
RDFDataMgr.write(OutputStream, Graph, Lang) line: 1018  
JenaRDFWriter$$anon$1$$anonfun$write$1.apply$mcV$sp() line: 20  
JenaRDFWriter$$anon$1$$anonfun$write$1.apply() line: 17 
JenaRDFWriter$$anon$1$$anonfun$write$1.apply() line: 17 
Try$.apply(Function0) line: 191 
JenaRDFWriter$$anon$1.write(Graph, OutputStream, String) line: 17   
JenaRDFWriter$$anon$1.write(Object, OutputStream, String) line: 15  
IOExample$class.main(IOExample, Array[String]) line: 44 
IOExampleWithJena$.main(Array[String]) line: 64 
IOExampleWithJena.main(Array[String]) line: not available   


I believe the problem originates, in part, here:

RDFDataMgr.write$(OutputStream, Graph, RDFFormat) line: 1262


 private static void write$(OutputStream out, Graph graph, RDFFormat
serialization)
 {
 WriterGraphRIOT w = createGraphWriter$(serialization) ;
 w.write(out, graph, RiotLib.prefixMap(graph), null, null) ; //
line 1262
 }

The last 2 null arguments are the values for the "baseURI" and "context"
parameters.
Are all writers able to cope with a null base URI?







It seems that the Turtle writer can but not the RDF/XML writer.
The BadURIException happens during Unparser.wObjStar() when one of the
Resources has a null URI:

BaseXMLWriter.checkURI(String) line: 820
BaseXMLWriter.relativize(String) line: 797  
Unparser.wURIreference(String) line: 918
Unparser.wURIreference(Resource) line: 922  
Unparser.wAboutAttr(Resource) line: 913 
Unparser.wIdAboutAttrOpt(Resource) line: 869
Unparser.wTypedNodeOrDescriptionLong(Unparser$WType, Resource, Resource,
List) line: 830 
Unparser.wTypedNodeOrDescription(Unparser$WType, Resource, Resource) line:
764 
Unparser.wTypedNode(Resource) line: 737 
Unparser.wObj(Resource, Boolean) line: 677  
Unparser.wObjStar() line: 364   

Because the writer has a null baseURI, then BaseXMLWriter.relativize(null)
returns null.
This then fails the URI check; hence the BadURIException.

To avoid this problem, I refactored the call to RDFDataMgr.write(),
originally:

def write(graph: Jena#Graph, os: OutputStream, base: String): Try[Unit] =
Try {
   import org.w3.banana.jena.Jena.ops._
   val relativeGraph : Jena#Graph = graph.relativize(URI(base))
   RDFDataMgr.write(os, relativeGraph, lang)
 }

To the following:

def write(graph: Jena#Graph, os: OutputStream, base: String): Try[Unit] =
Try {
   import org.w3.banana.jena.Jena.ops._
   val relativeGraph : Jena#Graph = graph.relativize(URI(base))
   val serialization: RDFFormat =
RDFWriterRegistry.defaultSerialization(lang)
   val wf:

[ANN] Jena 2.12.1 released

2014-10-09 Thread Rob Vesse
We are pleased to announce the release of Apache Jena 2.12.1 which
includes Apache Jena Fuseki 1.1.1.

Users are reminded that from Jena 2.12.1 requires Java 7.

Thanks as ever to everyone who has contributed to this release.

The code changes can be found in the list of resolved issues at

http://s.apache.org/jena2.12.1-changes

Download Jena via the mirrors and links at

http://jena.apache.org/download/index.html

or from Maven central.

Rob