Re: Spira, search with object properties & declare multi-type object properties

Sorry, Marios. Spira isn’t getting much support, as many developers have moved on to ActiveTriples and other projects.

Gregg Kellogg
gregg@greggkellogg.net

> On Oct 31, 2016, at 2:33 PM, Marios Avgeris <avgeris.marios@gmail.com> wrote:
> 
> Hello,
> 
> I’ve been trying my hand on Ruby RDF and I’d like some clarification on the following subjects. Assume the existence of the following classes:
> 
> class Car < Spira::Base
>  configure :base_uri => 'http://example.org/car'
>  type RDF::URI.new('http://example.org/types/car')
> end
> 
> class Spaceship < Spira::Base
>  configure :base_uri => 'http://example.org/spaceship'
>  type RDF::URI.new('http://example.org/types/spaceship')
> end
> 
> class Person < Spira::Base
>  configure :base_uri => 'http://example.org/person'
>  type RDF::URI.new('http://example.org/types/person')
>  property :name, :predicate => RDF::Vocab::DC.title, :type => XSD.string
>  property :age,  :predicate => RDF::Vocab::FOAF.age,  :type => Integer
>  property :drives, :predicate => RDF::URI.new('http://example.org/vocab/drives’), :type =>  :Car
> end
> 
> 1) one can search the respective repository using properties with data (String, Integer, Boolean etc.) like this:
> 
>  adam = Person.for(“adam”)
>  adam.age = 67
>  p = Person.find(:all, :conditions => { :age => 67} )
> 
> that will return an array containing objects of class People, matching the given conditions (obviously only adam in this case). 
> Is there a way to search the repo using object properties? I was imagining something like this:
> 
>  beetle = Car.for(“beetle”).save
>  adam.drives = beetle
>  adam.save
>  p = Person.find(:all, :conditions => { :drives => beetle} ) 
> 
> However this doesn’t seem to work.
> 
> 2) This one is separate from the above. Is there a way in which a property could support more than one spira class/object type? what I’m trying to achieve would seem like this:
> 
>  class Person < Spira::Base
>   ...
>    property :drives, :predicate => RDF::URI.new('http://example.org/vocab/drives’), :type =>  [:Car, :Spaceship]
>   ...
>  end
> 
> Obviously this doesn’t work either.
> 
> Any ideas?
> Thanks in advance,
> Marios
> 

Received on Friday, 4 November 2016 22:11:14 UTC