You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Dibyanshu Jaiswal <dj...@gmail.com> on 2013/10/23 08:28:12 UTC

Adding Individuals of a given OntClass with ObjectProperty

I am facing problem in adding Individuals of a given class using jena.

Say for example we have a give hierarchy of classes:
Class Customer
         ObjectProperties:        hasName               Range: Class Name
                                          hasAddress            Range:
Class Address

Class Name
         ObjectProperties:        hasFirstName        Range: Class FirstName
                                          hasLastName        Range: Class
LastName


Class FirstName
         DatatypeProperties:        FirstName_Is        Range: String
datatype


Class LastName
         DatatypeProperties:        LastName_Is        Range: String
datatype

Class Address
         ObjectProperties:        hasBuildingInfo        Range: Class
BuildingInfo
                                          hasStreetInfo        Range: Class
StreetName

Class BuildingInfo
         DatatypeProperties:        BuildingNo_Is        Range: int datatype
                                              FlooNo_Is             Range:
int datatype


Class StreetInfo
         DatatypeProperties:        StreetName        Range: String datatype
                                              CityCode            Range:
String datatype



Now I want to add an individual of Customer Is there any easy way to do
that, instead of driiling down to the range classes and creating
individuals of FirstName, LastName, BuildinInfo, StrretInfo, and then
adding these individuals as values to Name and Address and hence add these
Name and Address individuals to Customer??

This is just an example where the object property hierarchy goes only two
level deep, but in my web application the hierarchies are much deeper and
hence i am in a search of some generic method to deal with this problem.
Can Jena API deal/help me with this??

-- 
*Dibyanshu Jaiswal*
Mb: +91 9038304989
Mb: +91 9674272265

Re: Adding Individuals of a given OntClass with ObjectProperty

Posted by Dibyanshu Jaiswal <dj...@gmail.com>.
Ian, Sorry for the table formatting, but I'am not used to turtle, on top of
that, I had just made up the example to give an idea of my current state of
art.

I am creating a web application where I need to register my customers with
their name and address details.  And I kno RDF/Jena does not performs any
data integrity check. But I need to keep these information for my
application. May the decision of which properties to be added be taken by
the application, but ultimately the apllication needs to register the
customer as an individual in the model with whatevr details being provided.
As per the link provided by you, currently I'am using those api by which my
application needs to drill down the classes and properties for their range
and hence create individuals and keep it linking it back to the hierarchy
above.


So any more suggesstions/solutions?
 Any help will be greatly appreciated.


On Wed, Oct 23, 2013 at 12:47 PM, Ian Dickinson <i....@gmail.com>wrote:

> On Wed, Oct 23, 2013 at 7:28 AM, Dibyanshu Jaiswal <dj...@gmail.com>
> wrote:
> > I am facing problem in adding Individuals of a given class using jena.
> >
> > Say for example we have a give hierarchy of classes:
> As an aside, this would have been easier to read as Turtle than as a
> table whose formatting didn't really survive being transmitted in
> email.
>
> > Now I want to add an individual of Customer Is there any easy way to do
> > that, instead of driiling down to the range classes and creating
> > individuals of FirstName, LastName, BuildinInfo, StrretInfo, and then
> > adding these individuals as values to Name and Address and hence add
> these
> > Name and Address individuals to Customer??
> To create an individual of class Customer takes only one triple:
>
> yourNamespace:customer1234 rdf:type :Customer.
>
> That's it. This may sound flippant, but in RDF you're not required to
> add any information to create a valid resource, because of the open
> world assumption. It's not like creating a row in a database, which
> will fail your data integrity checks if some columns are missing.
> Missing triples in RDF are perfectly OK. One upshot of which is that
> no, there's no generic mechanism in Jena for creating individuals with
> a certain collection of properties, because which properties those
> would be is basically an application decision.
>
> > This is just an example where the object property hierarchy goes only two
> > level deep, but in my web application the hierarchies are much deeper and
> > hence i am in a search of some generic method to deal with this problem.
> > Can Jena API deal/help me with this??
>
> You may find this helpful:
> http://jena.apache.org/documentation/notes/rdf-frames.html
>
> Ian
>



-- 
*Dibyanshu Jaiswal*
Mb: +91 9038304989
Mb: +91 9674272265

Re: Adding Individuals of a given OntClass with ObjectProperty

Posted by Ian Dickinson <i....@gmail.com>.
On Wed, Oct 23, 2013 at 7:28 AM, Dibyanshu Jaiswal <dj...@gmail.com> wrote:
> I am facing problem in adding Individuals of a given class using jena.
>
> Say for example we have a give hierarchy of classes:
As an aside, this would have been easier to read as Turtle than as a
table whose formatting didn't really survive being transmitted in
email.

> Now I want to add an individual of Customer Is there any easy way to do
> that, instead of driiling down to the range classes and creating
> individuals of FirstName, LastName, BuildinInfo, StrretInfo, and then
> adding these individuals as values to Name and Address and hence add these
> Name and Address individuals to Customer??
To create an individual of class Customer takes only one triple:

yourNamespace:customer1234 rdf:type :Customer.

That's it. This may sound flippant, but in RDF you're not required to
add any information to create a valid resource, because of the open
world assumption. It's not like creating a row in a database, which
will fail your data integrity checks if some columns are missing.
Missing triples in RDF are perfectly OK. One upshot of which is that
no, there's no generic mechanism in Jena for creating individuals with
a certain collection of properties, because which properties those
would be is basically an application decision.

> This is just an example where the object property hierarchy goes only two
> level deep, but in my web application the hierarchies are much deeper and
> hence i am in a search of some generic method to deal with this problem.
> Can Jena API deal/help me with this??

You may find this helpful:
http://jena.apache.org/documentation/notes/rdf-frames.html

Ian