Skip to content

Version 7.0.0

Choose a tag to compare

@jcoyne jcoyne released this 31 Mar 16:23

Autocommits

In order to speed up writes, ActiveFedora 7 depends on Solr autocommits. You must add a block like this to your solrconfig.xml or commits may be lost when you restart solr: https://github.com/projecthydra/active_fedora/blob/f2b1fd092889cfefdffcb5d63a9fc1fd87e7242a/lib/generators/active_fedora/config/solr/templates/solr_conf/conf/solrconfig.xml#L19-L68

Association Validation

ActiveFedora 7 validates association options passed to has_many, belongs_to and has_and_belongs_to_many. Options for these methods were not validated in earlier versions. Hence, legacy options (such as :inbound) which had become effectively no-ops now raise exceptions and will have to be removed.

RDF Compatibility:

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

These changes effect serialization of typed data in RDF. This may lead to differences between legacy datastreams and new ones created with the same inputs.

Where old versions represented all literals as plain strings, they are now serialized as typed data where appropriate and ruby objects of matching type are returned when retrieving properties. For example:

# Behavior in AF 6
asset.modified = Date.today
asset.descMetadata.content
#=> "<info:fedora/changeme:1> <http://purl.org/dc/terms/modified> \"2014-03-28\" .\n"
asset.modified
#=> ["2014-03-28"]

# Behavior in AF 7
asset.modified = Date.today
asset.descMetadata.content
#=> "<info:fedora/changeme:1> <http://purl.org/dc/terms/modified> \"2014-03-28Z\"^^<http://www.w3.org/2001/XMLSchema#date> .\n"
asset.modified
#=> [Fri, 28 Mar 2014]

The behavior of legacy datastreams will not break, but client code needs to be able to handle both typed data and strings unless and until they are updated.

Syntax changes:

There are a handful of syntax changes brought on by the restructure of AF::Rdf.

RDF Objects used to be defined like this:

class Component
  include ActiveFedora::RdfObject
end

Now like this:

class Component < ActiveFedora::Rdf::Resource
end

Lists used to be defined like this:

class ElementList
  include ActiveFedora::RdfList
end

Now, like this:

class ElementList < ActiveFedora::Rdf::List
end

New objects used to take an RDF::Graph on init:

Component.new(RDF::Graph.new)

Now they take (optionally) a URI subject

Component.new('http://myorg.org/resource1')

Optionally, they take a parent resource and/or parameters inherited from RDF::Graph. You can pass an existing graph to the Resource in the RDF::Graph way:

Component.new('http://myorg.org/resource1', :data => RDF::Graph.load('http://example.org/somedata.rdf'))

URI values in RDF now return an Rdf::Resource instead of a String when no class is specified:

Component.property :seeAlso, :predicate => RDF::RDFS.seeAlso
c = Component.new
c.seeAlso = "http://google.com"
# old behavior: 
c.seeAlso # => ["http://google.com"]
# new behavior:
c.seeAlso # => [#<ActiveFedora::Rdf::Resource:0x3fa648d8e0e0(default)>]
c.seeAlso.rdf_subject # => "http://google.com"

This version also uses RDF 1.1, which should not have any effect on legacy data.

Caveats:

When ActiveFedora::Base.load_instance_from_solr is used and you attempt to access a term that is not stored in the index, an error will be raised.

Deprecations:

Solr Prefixes

DEPRECATION WARNING: In active-fedora 8 the solr fields created by Hydra::ModsArticleDatastream will be prefixed with "desc_metadata__".  If you want to maintain the existing behavior, you must override Hydra::ModsArticleDatastream.#prefix to return an empty string. (called from to_solr at /Users/justin/workspace/active_fedora/lib/active_fedora/om_datastream.rb:51)

In ActiveFedora 8, all the solr fields will be prefixed with the datastream name. If you want this behavior before upgrading to ActiveFedora 8 add this method to your datastreams:

    def prefix
      "#{dsid.underscore}__"
    end

If you want to preserve the existing behavior going forward (i.e. do not prefix solr fields with the datastream name), then add this method instead:

    def prefix
      ""
    end

Adding the #prefix method will remove the deprecation warning.

RDF

DEPRECATION WARNING: map_predicates is deprecated and will be removed in active-fedora 8.0.0. Use property :name, predicate: predicate instead.

Previous versions used the following syntax to register properties in datastreams:

class Datastream < ActiveFedora::NtriplesRDFDatastream
  map_predicates do |map|
    map.subject in: RDF::DC, to: :subject
  end
end

The syntax is now as seen below. The :class_name argument and index blocks still work in the same way.

class Datastream < ActiveFedora::NtriplesRDFDatastream
  property :subject, predicate: RDF::DC.subject
end
DEPRECATION WARNING: rdf_type is deprecated and will be removed in active-fedora 8.0.0. Use configure type: instead. 

RDF Types used to be defined like this:

class MediatorUser < ActiveFedora::Rdf::Resource
  rdf_type RDF::DC.AgentClass
end

They now use a generalized #configure method, which assigns other class level variables (:repository, :rdf_label, and :base_uri).

class MediatorUser < ActiveFedora::Rdf::Resource
  configure type: RDF::DC.AgentClass
end