W3C home > Mailing lists > Public > semantic-web@w3.org > August 2005

Re: java annotations & the semantic web

From: Henry Story <henry.story@bblfish.net>
Date: Sat, 27 Aug 2005 12:55:48 +0200
Message-Id: <32C9B9C6-A781-44C3-B6D3-1AB16E5D9E2F@bblfish.net>
Cc: "Kirkham, Pete (UK)" <pete.kirkham@baesystems.com>, semanticweb@sun.com, SWIG <semantic-web@w3.org>, Danny Ayers <danny.ayers@gmail.com>
To: users@bloged.dev.java.net

Eureka! I have it!

How does one annotate combined inverse functional properties?

Simple like this :

@RDF(FoafPerson.BASE + "Person")
interface FoafPerson {
     String BASE = "http://xmlns.com/foaf/0.1/";

     @RDF(BASE+"weblog") void addWeblog(URI uri);
     @RDF(BASE+"weblog") Collection<URI> getWeblogs();

     @RDF(BASE+"surname")
     @functional String getSurname();
     @RDF(BASE+"surname") void setSurname(String surname);

     @RDF(BASE+"firstName") String getFirstName();
     @RDF(BASE+"firstName") void setFirstName(String firstName);


     @RDF(BASE+"name") String[] getName()
     @RDF(BASE+"name") @inverseFunctional
                       void setName(@RDF(BASE+"fistName") String  
firstName,
                                        @RDF(BASE+"surname")  String  
surname);

     @RDF(BASE+"mbox")
     @inverseFunctional void addMbox(URI mbox);
     @RDF(BASE+"mbox") Collection<URI> getAllMbox();

}

(sorry to the foaf group for slightly distorting their ontology)
So what does the above say? (Remember we are imagining that we live  
in a world where people
are uniquely identified by their first name, second name combination).

It says that FoafPerson is a class that has a RDF URI <http:// 
xmlns.com/foaf/0.1/Person>
That any Person has a relation to a surname string and a relation to  
a firstname string,
and that each person can have only one first name and one second name  
(the relation is functional)

And also it say that the name relation <http://xmlns.com/foaf/0.1/ 
name> relates a person
to an ordered list (yes that is what argument lists in java really  
are) and that this relation
is inverse functional, ie: that a particular (fist name, last name)  
combination always
identify the same person. Furthermore it specifies that the first  
element in the list is
related via the foaf:firstName relation to the instance of the class,  
and that the second
element of the list (the second argument one would say in java) is  
related to the instance via
the foaf:surname relation to the entity.


In database terms we are saying that we have a compound key [1]  
"firstName" "secondName" that
identifies a person.


Oh. And at the end it also says that a person can have any number of  
other inverseFunctional
relations to mailbox uris. IE. if two Person object X and Y are  
related to a mailbox uri via
the foaf:mbox relation then X and Y are the same person.

I am not sure what that is in database design... does that mean that  
the same person can have
any number of primary keys?

In any case this looks like it is developing quite nicely. One  
advantage it seems
of specifying the URI of each method is that it makes it very easy to  
get a java bean
like framework going. From the above it is very easy to deduce the  
getter and setter
methods that get and set the same property (they have the same uri)....

Now I wonder if Sesame[2] allows me in their OWL sails to work with  
combined inverse
functional properties in that way?

Henry Story


[1] http://en.wikipedia.org/wiki/Compound_key
[2] http://openrdf.org/


On 26 Aug 2005, at 14:23, Henry Story wrote something that is also  
summarized on the
web page: <http://blogs.sun.com/roller/page/bblfish/20050825>
but of which the following is the relevant section for this discussion.
> [snip]
> Btw. There is one type of thing that I cannot think of an easy way  
> to use annotations
> with, and that is my combined inverse functional properties.
>
> class Person {
>
>    String firstName;
>    String lastName;
>
>    @functional dateOfBirth;
>
> }
>
>
> I would like firstName and lastName combined to be an inverse  
> functional property. (speaking
> in an imaginary world where no two people have the same first and  
> last name).
>
> Perhaps one has to do it like this:
>
> class Person {
>     String names = new String[2];
>
>     @functional String getFirstName() { return names[0]; }
>     @functional String getLastName() { return names[1]; }
>
>     @functional dateOfBirth;
>
>     @inverseFunctional List getNames() { return names; }
> }
>
> ((from a hint by timbl on irc, as to how he dealt with this in N3 ))
>
> But there is something here that the annotation fails to capture it  
> seems and that
> is the relation between firstName, lastName and names. The relation  
> is in the code here,
> not the annotations.
>
Received on Saturday, 27 August 2005 10:55:57 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 21:45:06 GMT