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

Hi Marios,

On Mon, Oct 31, 2016 at 10:33 PM, Marios Avgeris <avgeris.marios@gmail.com>
wrote:

> Hello,
>
> 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.
>

I am not familiar with the find method, but from what you can find in
the source
code
<https://github.com/ruby-rdf/spira/blob/5fcdfba464321e9a977e5bb852157656531a02bc/lib/spira/persistence.rb#L252>
something like  :

Person.find(:all, :conditions => { VOCAB.drives => beetle.uri })  # VOCAB =
RDF::Vocabulary.new('http://example.org/vocab/
<http://example.org/vocab/drives>’)

should 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?
>

That's not possible with Spira. You can define a superclass Vehicle and
uses that type as the range of the *drives *property


> Thanks in advance,
> Marios
>
>
Cheers!

Received on Friday, 4 November 2016 22:44:57 UTC