W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > November 2016

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

From: Marios Avgeris <avgeris.marios@gmail.com>
Date: Mon, 31 Oct 2016 23:33:14 +0200
Message-Id: <7391958D-1C18-46D7-A719-D864FAEBDD1C@gmail.com>
To: public-rdf-ruby@w3.org
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 Wednesday, 2 November 2016 12:45:54 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:18 UTC