You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Lewis John Mcgibbney <le...@gmail.com> on 2013/08/21 00:18:54 UTC

Obtaining only object's from Model

Hi All,
I get a results stream from Fuseki as follows

SPARQL_Rresult.getModel()

for clarity, then I do model.toString() the results stream looks like this

<ModelCom   {mheq:ModelTA_Horizontal_Belt_Conveyor @rdfs:comment "The
ModelTA_Horizontal_Belt_Conveyor individual is a representation of the
product located a
http://www.gilmorekramer.com/more_info/hytrol_ta_conveyor/hytrol_ta_conveyor.shtml.
Data type propoerty associations are made in accordance with the power
calculation methodology located in "ENERGY MANAGEMENT
SERIES 17, FOR INDUSTRY COMMERCE AND INSTITUTIONS, Materials Handling and
On-Site Transportation Equipment, Canada."^^
http://www.w3.org/2001/XMLSchema#string;
mheq:ModelTA_Horizontal_Belt_Conveyor @mheq:hasConveyorProductLoading
"36.0"^^http://www.w3.org/2001/XMLSchema#double;
mheq:ModelTA_Horizontal_Belt_Conveyor @mheq:hasConveyorLength "30.0"^^
http://www.w3.org/2001/XMLSchema#double;
mheq:ModelTA_Horizontal_Belt_Conveyor @mheq:hasConveyorSpeed "0.508"^^
http://www.w3.org/2001/XMLSchema#double;
mheq:ModelTA_Horizontal_Belt_Conveyor @rdf:type mheq:BeltConveyor;
mheq:ModelTA_Horizontal_Belt_Conveyor @rdf:type owl:NamedIndividual} |  [
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
http://www.w3.org/2000/01/rdf-schema#comment, "The
ModelTA_Horizontal_Belt_Conveyor individual is a representation of the
product located a
http://www.gilmorekramer.com/more_info/hytrol_ta_conveyor/hytrol_ta_conveyor.shtml.
Data type propoerty associations are made in accordance with the power
calculation methodology located in "ENERGY MANAGEMENT
SERIES 17, FOR INDUSTRY COMMERCE AND INSTITUTIONS, Materials Handling and
On-Site Transportation Equipment, Canada."^^
http://www.w3.org/2001/XMLSchema#string] [
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#hasConveyorProductLoading,
"36.0"^^http://www.w3.org/2001/XMLSchema#double] [
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#hasConveyorLength,
"30.0"^^http://www.w3.org/2001/XMLSchema#double] [
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#hasConveyorSpeed,
"0.508"^^http://www.w3.org/2001/XMLSchema#double] [
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#BeltConveyor]
[
http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
http://www.w3.org/2002/07/owl#NamedIndividual]>

what I am interested here is the following

#hasConveyorProductLoading, "36.0"
#hasConveyorLength, "30.0"
#hasConveyorSpeed, "0.508"

I want to use the object data type values as input for an Apache CXF
Webservice.
What I wonder, is what methods I can use from Model [0] or ModelCon [1] to
just get the object values?

Thank you very much
Lewis

[0]
http://jena.apache.org/documentation/javadoc/jena/index.html?com/hp/hpl/jena/rdf/model/Model.html
[1]
http://jena.apache.org/documentation/javadoc/jena/index.html?com/hp/hpl/jena/rdf/model/ModelCon.html

-- 
*Lewis*

Re: Obtaining only object's from Model

Posted by Lewis John Mcgibbney <le...@gmail.com>.
Hi Joshua,

Thanks for reply

On Tue, Aug 20, 2013 at 6:40 PM, Joshua TAYLOR <jo...@gmail.com>wrote:

>
> It's sort of surprising to me that you don't seem to care about what
> subjects those properties and values are attached to, but at any rate,
> if that's really what you want to do, then
>

This is because I know 'exactly' what is in the triples stream. For the
example I provide there are 'only' three properties and data values. This
is all. If there is anything more then the web service will be overloaded
with parameters and should not work, anything less then the web service
should not work either. I am writing this logic into the application so
that it works under very restrictive conditions and doesn't work for any
other case.


> listObjectsOfProperty(Property) [1] is probably what you want.  Call
> it with hasConveyorProductLoading and you'll get an NodeIterator that
> will return "36.0" to you, and similarly for the other properties and
> their values.
>
> Thank you very much this is exactly what I am after.

Best
Lewis

Re: Obtaining only object's from Model

Posted by Joshua TAYLOR <jo...@gmail.com>.
On Tue, Aug 20, 2013 at 6:18 PM, Lewis John Mcgibbney
<le...@gmail.com> wrote:
> Hi All,
> I get a results stream from Fuseki as follows
>
> SPARQL_Rresult.getModel()
>
> for clarity, then I do model.toString() the results stream looks like this
>
> <ModelCom   {mheq:ModelTA_Horizontal_Belt_Conveyor @rdfs:comment "The
> ModelTA_Horizontal_Belt_Conveyor individual is a representation of the
> product located a
> http://www.gilmorekramer.com/more_info/hytrol_ta_conveyor/hytrol_ta_conveyor.shtml.
> Data type propoerty associations are made in accordance with the power
> calculation methodology located in "ENERGY MANAGEMENT
> SERIES 17, FOR INDUSTRY COMMERCE AND INSTITUTIONS, Materials Handling and
> On-Site Transportation Equipment, Canada."^^
> http://www.w3.org/2001/XMLSchema#string;
> mheq:ModelTA_Horizontal_Belt_Conveyor @mheq:hasConveyorProductLoading
> "36.0"^^http://www.w3.org/2001/XMLSchema#double;
> mheq:ModelTA_Horizontal_Belt_Conveyor @mheq:hasConveyorLength "30.0"^^
> http://www.w3.org/2001/XMLSchema#double;
> mheq:ModelTA_Horizontal_Belt_Conveyor @mheq:hasConveyorSpeed "0.508"^^
> http://www.w3.org/2001/XMLSchema#double;
> mheq:ModelTA_Horizontal_Belt_Conveyor @rdf:type mheq:BeltConveyor;
> mheq:ModelTA_Horizontal_Belt_Conveyor @rdf:type owl:NamedIndividual} |  [
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
> http://www.w3.org/2000/01/rdf-schema#comment, "The
> ModelTA_Horizontal_Belt_Conveyor individual is a representation of the
> product located a
> http://www.gilmorekramer.com/more_info/hytrol_ta_conveyor/hytrol_ta_conveyor.shtml.
> Data type propoerty associations are made in accordance with the power
> calculation methodology located in "ENERGY MANAGEMENT
> SERIES 17, FOR INDUSTRY COMMERCE AND INSTITUTIONS, Materials Handling and
> On-Site Transportation Equipment, Canada."^^
> http://www.w3.org/2001/XMLSchema#string] [
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#hasConveyorProductLoading,
> "36.0"^^http://www.w3.org/2001/XMLSchema#double] [
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#hasConveyorLength,
> "30.0"^^http://www.w3.org/2001/XMLSchema#double] [
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#hasConveyorSpeed,
> "0.508"^^http://www.w3.org/2001/XMLSchema#double] [
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
> http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#BeltConveyor]
> [
> http://eil.stanford.edu:443/svn/eil-repo/Users/Lewis/ontology/MaterialHandlingEquipment.owl#ModelTA_Horizontal_Belt_Conveyor,
> http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
> http://www.w3.org/2002/07/owl#NamedIndividual]>
>
> what I am interested here is the following
>
> #hasConveyorProductLoading, "36.0"
> #hasConveyorLength, "30.0"
> #hasConveyorSpeed, "0.508"
>
> I want to use the object data type values as input for an Apache CXF
> Webservice.
> What I wonder, is what methods I can use from Model [0] or ModelCon [1] to
> just get the object values?

It's sort of surprising to me that you don't seem to care about what
subjects those properties and values are attached to, but at any rate,
if that's really what you want to do, then
listObjectsOfProperty(Property) [1] is probably what you want.  Call
it with hasConveyorProductLoading and you'll get an NodeIterator that
will return "36.0" to you, and similarly for the other properties and
their values.

//JT

[1] http://jena.apache.org/documentation/javadoc/jena/com/hp/hpl/jena/rdf/model/Model.html#listObjectsOfProperty(com.hp.hpl.jena.rdf.model.Property)

-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/