Skip to content

Commit

Permalink
Merge pull request #694 from samvera/2-0-rc
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
tpendragon authored Jun 20, 2019
2 parents 08a0a51 + b8c4a99 commit 590e52e
Show file tree
Hide file tree
Showing 50 changed files with 504 additions and 592 deletions.
73 changes: 73 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,76 @@
# v2.0.0 2019-06-06

## Changes since last release

* Make LDP optional (Add `gem ldp` to Gemfile if using Fedora)
* Make ActiveRecord optional (Add `gem activerecord` to Gemfile if using
Postgres)
* Make RSolr optional (Add `gem rsolr` to Gemfile if using Solr)
* Remove deprecated `standardize_query_result` argument.
* Remove deprecated `Valkyrie::ID#to_uri`
* Remove ActiveFedora as a dependency.
* Remove deprecated `Valkyrie::Persistence::Fedora::PermissiveSchema.alternate_ids`
* Remove deprecated `Valkyrie::Persistence::Fedora::PermissiveSchema.references`
* Upgrade `dry-types` to `1.0.x`
* Fedora Adapter default is now version 5.
* Require a symbol key when instantiating a Valkyrie::Resource (string keys are no longer valid)
* Remove deprecated `type.member()` method (use `type.of()`)
* Remove deprecated `Valkyrie::Types::Int` (use `Valkyrie::Types::Integer`)
* Performance improvements

## Changes Without Deprecations in `1.6.0`

1. Overriding an attribute getter no longer changes the output of `to_h`. If
you've overridden something via `def title; "overwritten"; end`, then `to_h`
will now have what was set via the setter or initializer, not `overwritten`.
2. Setting attribute values via overriding instance variables no longer works.
Please use `#set_value` if you need dynamic setting, as this will be a stable
API.
3. `Valkyrie::Resource#to_h` no longer includes keys with `nil` values.

## Upgrade Guide

1. Upgrade Valkyrie to `1.6.0` in your application, run tests, and fix all
deprecations output to console.
2. Upgrade Valkyrie to `2.0.0` in your application.
3. Failing tests at this point are likely due to behavior in the "Changes
Without Deprecations" section above. If you have any trouble, please contact
us in the #valkyrie channel in [Samvera Slack](http://slack.samvera.org/).

## New Product Owner

All of us who have been part of the Valkyrie project so far would like to thank
[Carolyn Cole](https://github.com/carolyncole) for her role so far as Product Owner.
We'd like to welcome [Kate Lynch](https://github.com/kelynch), who will be
taking over effective immediately!

## Special Thanks

This is the first major version of Valkyrie since 1.0 over a year ago. A lot of
work has gone into it, and I'd like to take the chance to thank everyone
involved for their contributions in the last year:


[DanCoughlin](https://github.com/DanCoughlin)
[awead](https://github.com/awead)
[cam156](https://github.com/cam156)
[carolyncole](https://github.com/carolyncole)
[cjcolvar](https://github.com/cjcolvar)
[dgcliff](https://github.com/dgcliff)
[escowles](https://github.com/escowles)
[hackmastera](https://github.com/hackmastera)
[jeremyf](https://github.com/jeremyf)
[jrgriffiniii](https://github.com/jrgriffiniii)
[kelynch](https://github.com/kelynch)
[mbklein](https://github.com/mbklein)
[mjgiarlo](https://github.com/mjgiarlo)
[mtribone](https://github.com/mtribone)
[no-reply](https://github.com/no-reply)
[ojlyytinen](https://github.com/ojlyytinen)
[revgum](https://github.com/revgum)
[stkenny](https://github.com/stkenny)
[tpendragon](https://github.com/tpendragon)

# v1.7.1 2019-05-30

## Changes since last release
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in valkyrie.gemspec
gemspec

gem 'activerecord'
gem 'ldp'
gem 'pg'
gem 'rsolr'
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Jump in: [![Slack Status](http://slack.samvera.org/badge.svg)](http://slack.samv
## Primary Contacts

### Product Owner
[Katherine Lynch](https://github.com/kelynch)
[Kate Lynch](https://github.com/kelynch)

### Technical Lead
[Trey Pendragon](https://github.com/tpendragon)
Expand Down Expand Up @@ -51,12 +51,34 @@ instance with a short name that can be used to refer to it in your application:
```
# frozen_string_literal: true
require 'valkyrie'
Rails.application.config.to_prepare do
# To use the postgres adapter you must add `gem 'pg'` to your Gemfile
Valkyrie::MetadataAdapter.register(
Valkyrie::Persistence::Postgres::MetadataAdapter.new,
:postgres
)
# To use the solr adapter you must add gem 'rsolr' to your Gemfile
Valkyrie::MetadataAdapter.register(
Valkyrie::Persistence::Solr::MetadataAdapter.new(
connection: Blacklight.default_index.connection
),
:solr
)
# To use the fedora adapter you must add `gem 'ldp'` to your Gemfile
Valkyrie::MetadataAdapter.register(
Valkyrie::Persistence::Fedora::MetadataAdapter.new(
connection: ::Ldp::Client.new("http://localhost:8988/rest"),
base_path: "test_fed",
schema: Valkyrie::Persistence::Fedora::PermissiveSchema.new(title: RDF::URI("http://bad.com/title"))
),
:fedora
)
Valkyrie::MetadataAdapter.register(
Valkyrie::Persistence::Memory::MetadataAdapter.new,
:memory
Expand All @@ -80,10 +102,12 @@ Rails.application.config.to_prepare do
end
```

The initializer registers two `Valkyrie::MetadataAdapter` instances for storing metadata:
* `:postgres` which stores metadata in a PostgreSQL database
The initializer registers four `Valkyrie::MetadataAdapter` instances for storing metadata:
* `:fedora` which stores metadata in a Fedora server.
* `:memory` which stores metadata in an in-memory cache (this cache is not persistent, so it is only
appropriate for testing)
appropriate for testing).
* `:postgres` which stores metadata in a PostgreSQL database.
* `:solr` which stores metadata in a Solr Index.

Other adapter options include `Valkyrie::Persistence::BufferedPersister` for buffering in memory before bulk
updating another persister, `Valkyrie::Persistence::CompositePersister` for storing in more than one adapter
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/activerecord_5_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
source "https://rubygems.org"

gem "activerecord", "~> 5.1.0"
gem "ldp"
gem "pg"
gem "rsolr"

gemspec path: "../"
3 changes: 3 additions & 0 deletions gemfiles/activerecord_5_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
source "https://rubygems.org"

gem "activerecord", "~> 5.2.0"
gem "ldp"
gem "pg"
gem "rsolr"

gemspec path: "../"
10 changes: 1 addition & 9 deletions lib/valkyrie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
require 'dry-types'
require 'dry-struct'
require 'draper'
require 'active_record'
require 'reform'
require 'reform/active_record'
require 'rdf'
require 'valkyrie/rdf_patches'
require 'json/ld'
Expand Down Expand Up @@ -71,11 +69,6 @@ def logger=(logger)
@logger = logger
end

def warn_about_standard_queries!
warn "[DEPRECATION] Please enable query normalization to avoid inconsistent results between different adapters by adding `standardize_query_results: true` to your environment block" \
" in config\/valkyrie.yml. This will be the behavior in Valkyrie 2.0."
end

class Config < OpenStruct
def initialize(hsh = {})
super(defaults.merge(hsh))
Expand Down Expand Up @@ -110,7 +103,6 @@ def resource_class_resolver

def defaults
{
standardize_query_result: false,
resource_class_resolver: method(:default_resource_class_resolver)
}
end
Expand All @@ -124,5 +116,5 @@ def default_resource_class_resolver(class_name)
end
end

module_function :config, :logger, :logger=, :config_root_path, :environment, :warn_about_standard_queries!, :config_file, :config_hash
module_function :config, :logger, :logger=, :config_root_path, :environment, :config_file, :config_hash
end
9 changes: 9 additions & 0 deletions lib/valkyrie/change_set.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true
require 'reform/form/coercion'
require 'reform/form/orm'
require 'reform/form/active_model'
require 'reform/form/active_model/validations'
require 'reform/form/active_model/model_reflections'
require 'reform/form/active_model/form_builder_methods'
module Valkyrie
##
# Standard change set object for Valkyrie.
Expand All @@ -16,7 +20,9 @@ module Valkyrie
class ChangeSet < Reform::Form
include Reform::Form::ORM
include Reform::Form::ModelReflections
include Reform::Form::ActiveModel
include Reform::Form::ActiveModel::Validations
include Reform::Form::ActiveModel::FormBuilderMethods
feature Coercion
class_attribute :fields
self.fields = []
Expand Down Expand Up @@ -62,6 +68,9 @@ def self.fields=(fields)
fields
end

# Override reflect_on_association so SimpleForm can work.
def self.reflect_on_association(*_args); end

# Returns value for a given property.
# @param key [Symbol]
def [](key)
Expand Down
8 changes: 0 additions & 8 deletions lib/valkyrie/id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ def eql?(other)
end
alias == eql?

# @deprecated Please use {.uri_for} instead
def to_uri
return RDF::Literal.new(id.to_s, datatype: RDF::URI("http://example.com/valkyrie_id")) if id.to_s.include?("://")
warn "[DEPRECATION] `to_uri` is deprecated and will be removed in the next major release. " \
"Called from #{Gem.location_of_caller.join(':')}"
::RDF::URI(ActiveFedora::Base.id_to_uri(id))
end

protected

def state
Expand Down
1 change: 1 addition & 0 deletions lib/valkyrie/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Persistence
require 'valkyrie/persistence/composite_persister'
require 'valkyrie/persistence/delete_tracking_buffer'
require 'valkyrie/persistence/buffered_persister'
require 'valkyrie/persistence/shared'
autoload :Postgres, 'valkyrie/persistence/postgres'
autoload :Solr, 'valkyrie/persistence/solr'
autoload :Fedora, 'valkyrie/persistence/fedora'
Expand Down
17 changes: 10 additions & 7 deletions lib/valkyrie/persistence/fedora.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# frozen_string_literal: true
# :nocov:
begin
gem 'ldp'
rescue Gem::LoadError => e
raise Gem::LoadError,
"You are using the Fedora adapter without installing the #{e.name} gem. "\
"Add `gem '#{e.name}'` to your Gemfile."
end
# :nocov:
module Valkyrie::Persistence
# Implements the DataMapper Pattern to store metadata into Fedora
module Fedora
# Deprecation to allow us to make pg an optional dependency
path = Bundler.definition.gemfiles.first
matches = File.readlines(path).select { |l| l =~ /gem ['"]ldp\b/ }
if matches.empty?
warn "[DEPRECATION] ldp will not be included as a dependency in Valkyrie's gemspec as of the next major release. Please add the gem directly to your Gemfile if you use a fedora adapter."
end
require 'active_fedora'
require 'ldp'
require 'valkyrie/persistence/fedora/permissive_schema'
require 'valkyrie/persistence/fedora/metadata_adapter'
require 'valkyrie/persistence/fedora/persister'
Expand Down
9 changes: 1 addition & 8 deletions lib/valkyrie/persistence/fedora/metadata_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ class MetadataAdapter
# @param [String] base_path
# @param [Valkyrie::Persistence::Fedora::PermissiveSchema] schema
# @param [Integer] fedora_version
def initialize(connection:, base_path: "/", schema: Valkyrie::Persistence::Fedora::PermissiveSchema.new, fedora_version: 4)
def initialize(connection:, base_path: "/", schema: Valkyrie::Persistence::Fedora::PermissiveSchema.new, fedora_version: 5)
@connection = connection
@base_path = base_path
@schema = schema
@fedora_version = fedora_version

warn "[DEPRECATION] `fedora_version` will default to 5 in the next major release." unless fedora_version
end

# Construct the query service object using this adapter
Expand Down Expand Up @@ -78,10 +76,5 @@ def pair_path(id)
def connection_prefix
"#{connection.http.url_prefix}/#{base_path}"
end

def standardize_query_result?
Valkyrie.warn_about_standard_queries! if Valkyrie.config.standardize_query_result != true
Valkyrie.config.standardize_query_result == true
end
end
end
16 changes: 0 additions & 16 deletions lib/valkyrie/persistence/fedora/permissive_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,11 @@ def self.id
uri_for(:id)
end

# @deprecated Please use {.uri_for} instead
def self.alternate_ids
warn "[DEPRECATION] `alternate_ids` is deprecated and will be removed in the next major release. " \
"It was never used internally - please use `uri_for(:alternate_ids)` " \
"Called from #{Gem.location_of_caller.join(':')}"
uri_for(:alternate_ids)
end

# @return [RDF::URI]
def self.member_ids
uri_for(:member_ids)
end

# @deprecated Please use {.uri_for} instead
def self.references
warn "[DEPRECATION] `references` is deprecated and will be removed in the next major release. " \
"It was never used internally - please use `uri_for(:references)` " \
"Called from #{Gem.location_of_caller.join(':')}"
uri_for(:references)
end

# @return [RDF::URI]
def self.valkyrie_bool
uri_for(:valkyrie_bool)
Expand Down
2 changes: 1 addition & 1 deletion lib/valkyrie/persistence/fedora/persister.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def save(resource:)
initialize_repository
internal_resource = resource.dup
internal_resource.created_at ||= Time.current
internal_resource.updated_at ||= Time.current
internal_resource.updated_at = Time.current
validate_lock_token(internal_resource)
native_lock = native_lock_token(internal_resource)
generate_lock_token(internal_resource)
Expand Down
7 changes: 4 additions & 3 deletions lib/valkyrie/persistence/fedora/persister/model_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def self.handles?(value)
end

def self.ordered?(value)
return false unless value.resource.class.schema[value.key]
value.resource.class.schema[value.key].meta.try(:[], :ordered)
return false unless value.resource.class.attribute_names.include?(value.key)
value.resource.ordered_attribute?(value.key)
end

delegate :subject, to: :value
Expand Down Expand Up @@ -488,9 +488,10 @@ def self.handles?(value)
# @return [Valkyrie::Persistence::Fedora::Persister::ModelConverter::Property]
def result
# cast it to datetime for storage, to preserve milliseconds and date
# @todo Remove strftime when https://github.com/ruby-rdf/rdf/issues/394 is closed.
map_value(converted_value:
RDF::Literal.new(
value.value.to_datetime,
value.value.to_datetime.strftime("%Y-%m-%dT%H:%M:%S.%N%z"),
datatype: PermissiveSchema.valkyrie_time
))
end
Expand Down
Loading

0 comments on commit 590e52e

Please sign in to comment.