Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhauling implementatation of ActiveFedora::Rdf #377

Merged
merged 1 commit into from
Mar 18, 2014

Conversation

no-reply
Copy link
Contributor

** THIS BREAKS BACKWARD COMPATIBILITY **

This is a major rewrite of RDF Datastreams and the underlying node
support, tightly coupling the ActiveFedora::Rdf to rdf.rb. It replaces
the old RdfNode and related modules with a Resource class that
subclasses RDF::Graph.

The commit adds support for RDF Resources (nodes) persisted to an
RDF::Repository, which allows many ActiveFedora::Base objects to share
data without duplicating statements in each of their datastreams. It
will handle deep nodes in graphs gracefully, even if they are not
expected in the model. The other key features are some powerful
convenience methods for handling Linked Data; namely, #fetch (which
pulls data from an upstream URI) and #rdf_label (which is a way of
getting a human-readable label from common fields).

It also improves handling of typed data. Primarily by virtue of using
df.rb. Saving a Date object (for example) will serialize correctly
typed data and return a Date object when parsed.

A demo of the features included in the commit is here:
https://gist.github.com/no-reply/9519740

The commit breaks backwards compatability in several ways. Full
documentation of compatibility breakage and deprecation is here:
https://gist.github.com/terrellt/75a2fc84fd3d274a1bbd

  • New object types now subclass ActiveFedora::Rdf::Resource:

    class Component < ActiveFedora::Rdf::Resource
    end

    instead of:

    class Component
    include ActiveFedora::RdfObject
    end

  • Parameters for new Resources are changed.

  • A resource is always returned for URI subjects, even when no
    class can be identified. This allows better handling of nested data
    from sources whose structure is unknown; properties won't be
    registered, but other Resource methods will be available. You can get
    the string version by calling #rdf_subject.

  • Typed literals are supported. This includes changes to
    serialization of RDF!
    Passing (e.g.) a Ruby Date object as the value
    of a property/triple will yield a typed literal in RDF serializations
    and a Ruby Date object will be returned when fetching that data.

It also deprecates a few things for future removal.

  • rdf_type is deprecated in favor of a general configuration syntax
    for Resources.
  • map_predicates is superceded by property, which registers
    properties in a simpler way (without need for a block) using a pattern
    borrowed from some non-core ruby-rdf libraries.

This work depends on the linkeddata gem for support loading arbitrary
RDF serialations (see: ActiveFedora::Rdf::Resource#fetch).

@no-reply
Copy link
Contributor Author

This is perhaps a few hours premature. Our cCLA is on the way, but it may not be on file yet.

Thought it wouldn't hurt for the PR to get some eyeballs today, since it's a pretty major commit.

@jcoyne
Copy link
Member

jcoyne commented Mar 13, 2014

Since this is such a big commit, with a massive impact, I propose we have at least 3 👍 before we merge.

@no-reply
Copy link
Contributor Author

I'm in support of that @jcoyne.

This is squashed, in line with the contribution guidelines. The history is still available at https://github.com/no-reply/active_fedora/tree/rdf, if that helps people review the content.

@mjgiarlo
Copy link
Member

I will be pointing my local ScholarSphere installation at this branch this afternoon to see what breaks and compare that to the documentation above. Stay tuned.

@jcoyne
Copy link
Member

jcoyne commented Mar 14, 2014

@no-reply can you rebase please ;)


def rdf_type(value)
Deprecation.warn Configurable, "rdf_type is deprecated and will be removed in active-fedora 8.0.0. Use configure :type => instead.", caller
configure :type => value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end

def class_for_property
klass = property_config[:class_name]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klass = property_config.fetch(:class_name, ActiveFedora::Rdf::Resource)

@mjgiarlo
Copy link
Member

I agree with @jcoyne's suggestions. ;) Once those are incorporated, I give this a hearty 👍, and will commit to testing a release candidate in a timely fashion.

It'd be good to hear from the UCSD contingent too. @escowles?

@escowles
Copy link
Contributor

I agree with @mjgiarlo ;) -- I have started a branch to use this in damspas (https://github.com/ucsdlib/damspas/tree/feature/af7) and will spend some quality time on this, probably at c4l and definitely the following week.

** THIS BREAKS BACKWARD COMPATIBILITY **

This is	a major	rewrite of RDF	Datastreams and the underlying node
support, tightly coupling the ActiveFedora::Rdf to rdf.rb. It replaces
the old RdfNode and related modules with a Resource class that
subclasses RDF::Graph.

The commit adds support for RDF Resources (nodes) persisted to an
RDF::Repository, which allows many ActiveFedora::Base objects to share
data without duplicating statements in each of their datastreams.  It
will handle deep nodes in graphs gracefully, even if they are not
expected in the model. The other key features are some powerful
convienince methods for handling Linked Data; namely, #fetch (which
pulls data from an upstream URI) and #rdf_label (which is a way of
getting a human-readable label from common fields).

Improves handling of typed data. Primarily by virtue of using
df.rb. Saving a Date object (for example) will serialize correctly
typed data and return a Date object when parsed.

Adds the new Rdf::Identifiable to ActiveFedora::Base, allowing
Fedora objects to be treated as Rdf::Resources. This lets you create
complex relationships between objects, referencing them in and
retrieving them from datastreams.

A demo of the features included in the commit is here:
https://gist.github.com/no-reply/9519740

The commit breaks backwards compatability in several ways. Full
documentation of compatibility breakage and deprecation is here:
https://gist.github.com/terrellt/75a2fc84fd3d274a1bbd

 - New object types now subclass ActiveFedora::Rdf::Resource:

    class Component < ActiveFedora::Rdf::Resource
    end
    # instead of:
    class Component
      include ActiveFedora::RdfObject
    end

 - Parameters for new Resources are changed.

 - A resource is *always* returned for URI subjects, even when no
class can be identified. This allows better handling of nested data
from sources whose structure is unknown; properties won't be
registered, but other Resource methods will be available. You can get
the string version by calling #rdf_subject.

 - Typed literals are supported. *This includes changes to
serialization of RDF!* Passing (e.g.) a Ruby Date object as the value
of a property/triple will yield a typed literal in RDF serializations
and a Ruby Date object will be returned when fetching that data.

It also deprecates a few things for future removal.

 - `rdf_type` is deprecated in favor of a general configuration syntax
for Resources.

 - `map_predicates` is superceded by `property`, which registers
properties in a simpler way (without need for a block) using a pattern
borrowed from some non-core ruby-rdf libraries.

This work depends on the linkeddata gem for support loading arbitrary
RDF serialations (see: ActiveFedora::Rdf::Resource#fetch).
@no-reply
Copy link
Contributor Author

This has been rebased (and unceremoniously force-pushed) for further comment and/or merge.

jcoyne added a commit that referenced this pull request Mar 18, 2014
Overhauling implementatation of ActiveFedora::Rdf
@jcoyne jcoyne merged commit cf4400f into samvera:master Mar 18, 2014
@no-reply no-reply deleted the af7-rdf branch July 2, 2014 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants