This workshop provides an overview of the current state of RDF on the Hydra platform. We will work through examples of modeling complex metadata and creating objects that use it. The content will highlight creative use of Hydra 7's RDF capabilities to manage controlled vocabularies and integrate with Linked Data sources. Participants should expect some technical content, but need not be developers to benefit.
class Person < ActiveTriples::Resource | |
configure :type => RDF::FOAF.Person, :base_uri => 'http://example.org/people#' | |
property :name, :predicate => RDF::FOAF.name | |
end | |
class Organization< ActiveTriples::Resource | |
configure :type => RDF::FOAF.Organization, :base_uri => "http://example.org/orgs#" | |
property :name, :predicate => RDF::FOAF.name | |
end |
ActiveTriples is an Object-to-Graph Mapper (OGM) providing ActiveModel friendly, ORM-like functionality for managing RDF resources and graphs as Objects in Ruby.
The library defines a Resource
class, instances of which represent the equivalent concept in RDF. Resource objects encapsulate an individual RDF Resource (i.e. its identifier (URI or blank node), and relevant statements) creating a corresponding Object schema and API. The Object schema is strictly non-normative with respect to the data structure and content of the associated RDF graph. That is to say, it is a design goal of ActiveTriples that any arbitrary RDF graph should be readable and safely writeable using the library and compatible with any Object schema. To achieve this goal, it is necessary to specify a clear Object-Graph semanti
before do | |
class DummyLicense < ActiveTriples::Resource | |
property :title, :predicate => RDF::DC.title | |
end | |
class DummyResource < ActiveTriples::Resource | |
configure :type => RDF::URI('http://example.org/SomeClass') | |
property :license, :predicate => RDF::DC.license, :class_name => DummyLicense | |
property :title, :predicate => RDF::DC.title | |
property :replaces, :predicate => RDF::DC.replaces |
NOTIFIED: [frontend | restart unicorn] **************************************** | |
<192.168.50.6> ESTABLISH CONNECTION FOR USER: tom | |
<192.168.50.6> REMOTE_MODULE service name=unicorn_frontend state=reloaded | |
<192.168.50.6> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/tjohnson/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=tom', '-o', 'ConnectTimeout=10', '192.168.50.6', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1409156132.72-28508570131040 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1409156132.72-28508570131040 && echo $HOME/.ansible/tmp/ansible-tmp-1409156132.72-28508570131040'"] | |
<192.168.50.6> PUT /tmp/tmp2jNjg7 TO /home/tom/.ansible/tmp/ansible-tmp-1409156132.72-28508570131040/service | |
<192.168.50.6> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'Contr |
require 'spec_helper' | |
require 'mongoid' | |
describe 'Mongoid integration' do | |
before do | |
class Person | |
include Mongoid::Document | |
include ActiveTriples::Identifiable | |
configure :base_uri => 'http://example.org/mongoid/' |
In [10]: DplaGeonamesGeocoder().enrich_place(place) | |
--------------------------------------------------------------------------- | |
AttributeError Traceback (most recent call last) | |
<ipython-input-10-346d292dde39> in <module>() | |
----> 1 DplaGeonamesGeocoder().enrich_place(place) | |
/home/tjohnson/src/dpla/ingestion/ENV/lib/python2.7/site-packages/dplaingestion/akamod/geocode.pyc in enrich_place(self, place) | |
295 hierarchy = self.reverse_geocode_hierarchy(lat, lng, ["PCLI", # Country | |
296 "ADM1", # State | |
--> 297 "ADM2"]) # County |
# lib/models/datastream.rb | |
class CHODatastream < ActiveFedora::NtriplesRDFDatastream | |
property :title, predicate: RDF::DC.title | |
property :creator, predicate: RDF::DC.creator | |
property :date, predicate: RDF::DC.date | |
property :location, predicate: RDF::DC.spatial | |
end |
{ 'sourceResource': { 'DIFFERENT VALUES': { 'CURRENT DICT: ': { u'spatial': [ { u'coordinates': u'39.95233, -75.16379', | |
u'country': u'United States', | |
u'county': u'Philadelphia County', | |
u'name': u'Philadelphia, PA', | |
u'state': u'Pennsylvania'}, | |
{ u'coordinates': u'37.77493, -122.41942', | |
u'country': u'United States', | |
u'county': u'San Francisco County', | |
u'name': u'San Francisco, CA', | |