valkyrie 0.1.0 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ctags +2 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +3 -0
- data/CHANGELOG.md +43 -0
- data/Gemfile +0 -4
- data/LICENSE +15 -0
- data/README.md +13 -8
- data/Rakefile +15 -1
- data/bin/jetty_wait +14 -0
- data/bin/rspec +29 -0
- data/browserslist +3 -0
- data/circle.yml +17 -0
- data/config/fedora.yml +10 -0
- data/db/migrate/20161007101725_create_orm_resources.rb +9 -1
- data/db/migrate/20171011224121_create_path_gin_index.rb +6 -0
- data/db/migrate/20171204224121_create_internal_resource_index.rb +6 -0
- data/db/migrate/20180212092225_create_updated_at_index.rb +6 -0
- data/lib/generators/valkyrie/templates/resource_spec.rb.erb +1 -1
- data/lib/valkyrie.rb +1 -7
- data/lib/valkyrie/change_set.rb +21 -7
- data/lib/valkyrie/engine.rb +2 -0
- data/lib/valkyrie/id.rb +1 -0
- data/lib/valkyrie/indexers/access_controls_indexer.rb +50 -6
- data/lib/valkyrie/metadata_adapter.rb +29 -1
- data/lib/valkyrie/persistence.rb +27 -0
- data/lib/valkyrie/persistence/buffered_persister.rb +17 -1
- data/lib/valkyrie/persistence/composite_persister.rb +14 -2
- data/lib/valkyrie/persistence/custom_query_container.rb +63 -0
- data/lib/valkyrie/persistence/delete_tracking_buffer.rb +8 -0
- data/lib/valkyrie/persistence/fedora.rb +3 -0
- data/lib/valkyrie/persistence/fedora/list_node.rb +5 -2
- data/lib/valkyrie/persistence/fedora/metadata_adapter.rb +13 -11
- data/lib/valkyrie/persistence/fedora/ordered_list.rb +2 -2
- data/lib/valkyrie/persistence/fedora/ordered_reader.rb +3 -2
- data/lib/valkyrie/persistence/fedora/permissive_schema.rb +75 -0
- data/lib/valkyrie/persistence/fedora/persister.rb +22 -0
- data/lib/valkyrie/persistence/fedora/persister/model_converter.rb +110 -25
- data/lib/valkyrie/persistence/fedora/persister/orm_converter.rb +49 -17
- data/lib/valkyrie/persistence/fedora/persister/resource_factory.rb +2 -0
- data/lib/valkyrie/persistence/fedora/query_service.rb +46 -3
- data/lib/valkyrie/persistence/memory.rb +5 -0
- data/lib/valkyrie/persistence/memory/metadata_adapter.rb +6 -1
- data/lib/valkyrie/persistence/memory/persister.rb +19 -1
- data/lib/valkyrie/persistence/memory/query_service.rb +49 -8
- data/lib/valkyrie/persistence/postgres.rb +2 -0
- data/lib/valkyrie/persistence/postgres/metadata_adapter.rb +8 -1
- data/lib/valkyrie/persistence/postgres/orm.rb +1 -0
- data/lib/valkyrie/persistence/postgres/orm/resource.rb +12 -0
- data/lib/valkyrie/persistence/postgres/orm_converter.rb +99 -74
- data/lib/valkyrie/persistence/postgres/persister.rb +16 -0
- data/lib/valkyrie/persistence/postgres/query_service.rb +94 -6
- data/lib/valkyrie/persistence/postgres/resource_converter.rb +3 -1
- data/lib/valkyrie/persistence/postgres/resource_factory.rb +5 -5
- data/lib/valkyrie/persistence/solr.rb +2 -0
- data/lib/valkyrie/persistence/solr/composite_indexer.rb +29 -0
- data/lib/valkyrie/persistence/solr/metadata_adapter.rb +26 -1
- data/lib/valkyrie/persistence/solr/model_converter.rb +38 -8
- data/lib/valkyrie/persistence/solr/orm_converter.rb +43 -20
- data/lib/valkyrie/persistence/solr/persister.rb +16 -0
- data/lib/valkyrie/persistence/solr/queries.rb +3 -0
- data/lib/valkyrie/persistence/solr/queries/default_paginator.rb +2 -0
- data/lib/valkyrie/persistence/solr/queries/find_all_query.rb +3 -1
- data/lib/valkyrie/persistence/solr/queries/find_by_id_query.rb +4 -2
- data/lib/valkyrie/persistence/solr/queries/find_inverse_references_query.rb +2 -0
- data/lib/valkyrie/persistence/solr/queries/find_many_by_ids_query.rb +21 -0
- data/lib/valkyrie/persistence/solr/queries/find_members_query.rb +13 -5
- data/lib/valkyrie/persistence/solr/queries/find_references_query.rb +7 -3
- data/lib/valkyrie/persistence/solr/query_service.rb +30 -2
- data/lib/valkyrie/persistence/solr/repository.rb +14 -2
- data/lib/valkyrie/persistence/solr/resource_factory.rb +3 -1
- data/lib/valkyrie/resource.rb +11 -4
- data/lib/valkyrie/resource/access_controls.rb +13 -0
- data/lib/valkyrie/specs/shared_specs.rb +1 -2
- data/lib/valkyrie/specs/shared_specs/change_set.rb +75 -0
- data/lib/valkyrie/specs/shared_specs/metadata_adapter.rb +3 -0
- data/lib/valkyrie/specs/shared_specs/persister.rb +145 -15
- data/lib/valkyrie/specs/shared_specs/queries.rb +153 -27
- data/lib/valkyrie/specs/shared_specs/storage_adapter.rb +8 -3
- data/lib/valkyrie/storage.rb +29 -0
- data/lib/valkyrie/storage/disk.rb +17 -5
- data/lib/valkyrie/storage/fedora.rb +14 -1
- data/lib/valkyrie/storage/memory.rb +15 -2
- data/lib/valkyrie/storage_adapter.rb +26 -4
- data/lib/valkyrie/types.rb +65 -7
- data/lib/valkyrie/version.rb +1 -1
- data/solr/config/_rest_managed.json +3 -0
- data/solr/config/admin-extra.html +31 -0
- data/solr/config/elevate.xml +36 -0
- data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
- data/solr/config/protwords.txt +21 -0
- data/solr/config/schema.xml +366 -0
- data/solr/config/scripts.conf +24 -0
- data/solr/config/solrconfig.xml +322 -0
- data/solr/config/spellings.txt +2 -0
- data/solr/config/stopwords.txt +58 -0
- data/solr/config/stopwords_en.txt +58 -0
- data/solr/config/synonyms.txt +31 -0
- data/solr/config/xslt/example.xsl +132 -0
- data/solr/config/xslt/example_atom.xsl +67 -0
- data/solr/config/xslt/example_rss.xsl +66 -0
- data/solr/config/xslt/luke.xsl +337 -0
- data/solr/solr.xml +35 -0
- data/tasks/dev.rake +66 -0
- data/valkyrie.gemspec +6 -6
- metadata +58 -63
- data/lib/valkyrie/decorators/decorator_list.rb +0 -15
- data/lib/valkyrie/decorators/decorator_with_arguments.rb +0 -14
- data/lib/valkyrie/derivative_service.rb +0 -42
- data/lib/valkyrie/file_characterization_service.rb +0 -42
- data/lib/valkyrie/local_file_service.rb +0 -11
- data/lib/valkyrie/persist_derivatives.rb +0 -29
- data/lib/valkyrie/persistence/postgres/queries.rb +0 -8
- data/lib/valkyrie/persistence/postgres/queries/find_inverse_references_query.rb +0 -31
- data/lib/valkyrie/persistence/postgres/queries/find_members_query.rb +0 -33
- data/lib/valkyrie/persistence/postgres/queries/find_references_query.rb +0 -33
- data/lib/valkyrie/specs/shared_specs/derivative_service.rb +0 -30
- data/lib/valkyrie/specs/shared_specs/file_characterization_service.rb +0 -33
data/lib/valkyrie/storage.rb
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Valkyrie
|
3
|
+
# This is a namespacing module for storage adapters, which store binary content as per the DataMapper pattern
|
4
|
+
# https://en.wikipedia.org/wiki/Data_mapper_pattern
|
5
|
+
#
|
6
|
+
# @note These storage adapters do not store metadata
|
7
|
+
# See Valkyrie::Persistence for persisting metadata.
|
8
|
+
#
|
9
|
+
# @example Register storage adapters in an initializer using Valkyrie::StorageAdapter.register
|
10
|
+
#
|
11
|
+
# # Store files on local disk
|
12
|
+
# Valkyrie::StorageAdapter.register(
|
13
|
+
# Valkyrie::Storage::Disk.new(base_path: '/path/to/files'),
|
14
|
+
# :disk
|
15
|
+
# )
|
16
|
+
#
|
17
|
+
# @example Retrieve a registered persister using Valkyrie::StorageAdapter.find
|
18
|
+
#
|
19
|
+
# storage = Valkyrie.config.storage_adapter # default
|
20
|
+
# storage = Valkyrie::StorageAdapter.find(:disk) # named
|
21
|
+
#
|
22
|
+
# @example Save/upload a file
|
23
|
+
#
|
24
|
+
# file_set = FileSet.new title: 'page 1'
|
25
|
+
# upload = ActionDispatch::Http::UploadedFile.new tempfile: File.new('/path/to/files/file1.tiff'), filename: 'file1.tiff', type: 'image/tiff'
|
26
|
+
# file = storage.upload(file: upload, resource: file_set)
|
27
|
+
# file_set.file_identifiers << file.id
|
28
|
+
# persister.save(resource: file_set)
|
29
|
+
#
|
30
|
+
# @see https://github.com/samvera-labs/valkyrie/wiki/Storage-&-Files
|
31
|
+
# @see lib/valkyrie/specs/shared_specs/storage_adapter.rb
|
3
32
|
module Storage
|
4
33
|
require 'valkyrie/storage/disk'
|
5
34
|
require 'valkyrie/storage/fedora'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Valkyrie::Storage
|
3
|
+
# Implements the DataMapper Pattern to store binary data on disk
|
3
4
|
class Disk
|
4
5
|
attr_reader :base_path, :path_generator, :file_mover
|
5
6
|
def initialize(base_path:, path_generator: BucketedStorage, file_mover: FileUtils.method(:mv))
|
@@ -9,10 +10,11 @@ module Valkyrie::Storage
|
|
9
10
|
end
|
10
11
|
|
11
12
|
# @param file [IO]
|
13
|
+
# @param original_filename [String]
|
12
14
|
# @param resource [Valkyrie::Resource]
|
13
15
|
# @return [Valkyrie::StorageAdapter::File]
|
14
|
-
def upload(file:, resource: nil)
|
15
|
-
new_path = path_generator.generate(resource: resource, file: file)
|
16
|
+
def upload(file:, original_filename:, resource: nil)
|
17
|
+
new_path = path_generator.generate(resource: resource, file: file, original_filename: original_filename)
|
16
18
|
FileUtils.mkdir_p(new_path.parent)
|
17
19
|
file_mover.call(file.path, new_path)
|
18
20
|
find_by(id: Valkyrie::ID.new("disk://#{new_path}"))
|
@@ -31,9 +33,18 @@ module Valkyrie::Storage
|
|
31
33
|
# Return the file associated with the given identifier
|
32
34
|
# @param id [Valkyrie::ID]
|
33
35
|
# @return [Valkyrie::StorageAdapter::File]
|
36
|
+
# @raise Valkyrie::StorageAdapter::FileNotFound if nothing is found
|
34
37
|
def find_by(id:)
|
35
|
-
return unless handles?(id: id)
|
36
38
|
Valkyrie::StorageAdapter::File.new(id: Valkyrie::ID.new(id.to_s), io: ::File.open(file_path(id), 'rb'))
|
39
|
+
rescue Errno::ENOENT
|
40
|
+
raise Valkyrie::StorageAdapter::FileNotFound
|
41
|
+
end
|
42
|
+
|
43
|
+
# Delete the file on disk associated with the given identifier.
|
44
|
+
# @param id [Valkyrie::ID]
|
45
|
+
def delete(id:)
|
46
|
+
path = file_path(id)
|
47
|
+
FileUtils.rm_rf(path) if File.exist?(path)
|
37
48
|
end
|
38
49
|
|
39
50
|
class BucketedStorage
|
@@ -42,8 +53,9 @@ module Valkyrie::Storage
|
|
42
53
|
@base_path = base_path
|
43
54
|
end
|
44
55
|
|
45
|
-
def generate(resource:, file:)
|
46
|
-
|
56
|
+
def generate(resource:, file:, original_filename:)
|
57
|
+
raise ArgumentError, "original_filename must be provided" unless original_filename
|
58
|
+
Pathname.new(base_path).join(*bucketed_path(resource.id)).join(original_filename)
|
47
59
|
end
|
48
60
|
|
49
61
|
def bucketed_path(id)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Valkyrie::Storage
|
3
|
+
# Implements the DataMapper Pattern to store binary data in fedora
|
3
4
|
class Fedora
|
4
5
|
attr_reader :connection
|
5
6
|
PROTOCOL = 'fedora://'
|
@@ -16,18 +17,23 @@ module Valkyrie::Storage
|
|
16
17
|
# Return the file associated with the given identifier
|
17
18
|
# @param id [Valkyrie::ID]
|
18
19
|
# @return [Valkyrie::StorageAdapter::StreamFile]
|
20
|
+
# @raise Valkyrie::StorageAdapter::FileNotFound if nothing is found
|
19
21
|
def find_by(id:)
|
20
22
|
Valkyrie::StorageAdapter::StreamFile.new(id: id, io: response(id: id))
|
23
|
+
rescue ::Ldp::Gone
|
24
|
+
raise Valkyrie::StorageAdapter::FileNotFound
|
21
25
|
end
|
22
26
|
|
23
27
|
# @param file [IO]
|
28
|
+
# @param original_filename [String]
|
24
29
|
# @param resource [Valkyrie::Resource]
|
25
30
|
# @return [Valkyrie::StorageAdapter::StreamFile]
|
26
|
-
def upload(file:, resource:)
|
31
|
+
def upload(file:, original_filename:, resource:)
|
27
32
|
# TODO: this is a very naive aproach. Change to PCDM
|
28
33
|
identifier = resource.id.to_uri + '/original'
|
29
34
|
ActiveFedora::File.new(identifier) do |af|
|
30
35
|
af.content = file
|
36
|
+
af.original_name = original_filename
|
31
37
|
af.save!
|
32
38
|
af.metadata.set_value(:type, af.metadata.type + [::RDF::URI('http://pcdm.org/use#OriginalFile')])
|
33
39
|
af.metadata.save
|
@@ -35,6 +41,12 @@ module Valkyrie::Storage
|
|
35
41
|
find_by(id: Valkyrie::ID.new(identifier.to_s.sub(/^.+\/\//, PROTOCOL)))
|
36
42
|
end
|
37
43
|
|
44
|
+
# Delete the file in Fedora associated with the given identifier.
|
45
|
+
# @param id [Valkyrie::ID]
|
46
|
+
def delete(id:)
|
47
|
+
ActiveFedora::File.new(active_fedora_identifier(id: id)).ldp_source.delete
|
48
|
+
end
|
49
|
+
|
38
50
|
class IOProxy
|
39
51
|
# @param response [Ldp::Resource::BinarySource]
|
40
52
|
attr_reader :size
|
@@ -57,6 +69,7 @@ module Valkyrie::Storage
|
|
57
69
|
# @return [IOProxy]
|
58
70
|
def response(id:)
|
59
71
|
af_file = ActiveFedora::File.new(active_fedora_identifier(id: id))
|
72
|
+
raise Valkyrie::StorageAdapter::FileNotFound if af_file.ldp_source.new?
|
60
73
|
IOProxy.new(af_file.ldp_source, af_file.size)
|
61
74
|
end
|
62
75
|
|
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Valkyrie::Storage
|
3
|
+
# Implements the DataMapper Pattern to store binary data in memory
|
4
|
+
#
|
5
|
+
# @note this adapter is used primarily for testing, and is not recommended
|
6
|
+
# in cases where you want to preserve real data
|
3
7
|
class Memory
|
4
8
|
attr_reader :cache
|
5
9
|
def initialize
|
@@ -7,9 +11,10 @@ module Valkyrie::Storage
|
|
7
11
|
end
|
8
12
|
|
9
13
|
# @param file [IO]
|
14
|
+
# @param original_filename [String]
|
10
15
|
# @param resource [Valkyrie::Resource]
|
11
16
|
# @return [Valkyrie::StorageAdapter::StreamFile]
|
12
|
-
def upload(file:, resource: nil)
|
17
|
+
def upload(file:, original_filename:, resource: nil)
|
13
18
|
identifier = Valkyrie::ID.new("memory://#{resource.id}")
|
14
19
|
cache[identifier] = Valkyrie::StorageAdapter::StreamFile.new(id: identifier, io: file)
|
15
20
|
end
|
@@ -17,8 +22,9 @@ module Valkyrie::Storage
|
|
17
22
|
# Return the file associated with the given identifier
|
18
23
|
# @param id [Valkyrie::ID]
|
19
24
|
# @return [Valkyrie::StorageAdapter::StreamFile]
|
25
|
+
# @raise Valkyrie::StorageAdapter::FileNotFound if nothing is found
|
20
26
|
def find_by(id:)
|
21
|
-
|
27
|
+
raise Valkyrie::StorageAdapter::FileNotFound unless cache[id]
|
22
28
|
cache[id]
|
23
29
|
end
|
24
30
|
|
@@ -27,5 +33,12 @@ module Valkyrie::Storage
|
|
27
33
|
def handles?(id:)
|
28
34
|
id.to_s.start_with?("memory://")
|
29
35
|
end
|
36
|
+
|
37
|
+
# Delete the file on disk associated with the given identifier.
|
38
|
+
# @param id [Valkyrie::ID]
|
39
|
+
def delete(id:)
|
40
|
+
cache.delete(id)
|
41
|
+
nil
|
42
|
+
end
|
30
43
|
end
|
31
44
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Valkyrie
|
3
|
+
# StorageAdapter is the primary DataMapper object for binary content persistence.
|
4
|
+
# Used to register and locate adapters for individual
|
5
|
+
# storage backends (such as fedora, disk, etc)
|
3
6
|
class StorageAdapter
|
7
|
+
class FileNotFound < StandardError; end
|
4
8
|
class_attribute :storage_adapters
|
5
9
|
self.storage_adapters = {}
|
6
10
|
class << self
|
@@ -21,8 +25,11 @@ module Valkyrie
|
|
21
25
|
# Find the adapter associated with the provided short name
|
22
26
|
# @param short_name [Symbol]
|
23
27
|
# @return [Valkyrie::StorageAdapter]
|
28
|
+
# @raise Valkyrie::StorageAdapter::AdapterNotFoundError when we are unable to find the named adapter
|
24
29
|
def find(short_name)
|
25
|
-
storage_adapters
|
30
|
+
storage_adapters.fetch(short_name)
|
31
|
+
rescue KeyError
|
32
|
+
raise "Unable to find #{self} with short_name of #{short_name.inspect}. Registered adapters are #{storage_adapters.keys.inspect}"
|
26
33
|
end
|
27
34
|
|
28
35
|
# Search through all registered storage adapters until it finds one that
|
@@ -30,10 +37,27 @@ module Valkyrie
|
|
30
37
|
# with the given identifier.
|
31
38
|
# @param id [Valkyrie::ID]
|
32
39
|
# @return [Valkyrie::StorageAdapter::File]
|
40
|
+
# @raise Valkyrie::StorageAdapter::FileNotFound if nothing is found
|
33
41
|
def find_by(id:)
|
42
|
+
adapter_for(id: id).find_by(id: id)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Search through all registered storage adapters until it finds one that
|
46
|
+
# can handle the passed in identifier. Then call delete on that adapter
|
47
|
+
# with the given identifier.
|
48
|
+
# @param id [Valkyrie::ID]
|
49
|
+
def delete(id:)
|
50
|
+
adapter_for(id: id).delete(id: id)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Return the registered storage adapter which handles the given ID.
|
54
|
+
# @param id [Valkyrie::ID]
|
55
|
+
# @return [Valkyrie::StorageAdapter]
|
56
|
+
def adapter_for(id:)
|
57
|
+
# TODO: Determine the appropriate response when we have an unhandled :id
|
34
58
|
storage_adapters.values.find do |storage_adapter|
|
35
59
|
storage_adapter.handles?(id: id)
|
36
|
-
end
|
60
|
+
end
|
37
61
|
end
|
38
62
|
end
|
39
63
|
|
@@ -49,7 +73,6 @@ module Valkyrie
|
|
49
73
|
Pathname.new(io.path)
|
50
74
|
end
|
51
75
|
|
52
|
-
# @param id [Valkyre::ID]
|
53
76
|
# @param digests [Array<Digest>]
|
54
77
|
# @return [Array<Digest>]
|
55
78
|
def checksum(digests:)
|
@@ -61,7 +84,6 @@ module Valkyrie
|
|
61
84
|
digests.map(&:to_s)
|
62
85
|
end
|
63
86
|
|
64
|
-
# @param id [Valkyre::ID]
|
65
87
|
# @param size [Integer]
|
66
88
|
# @param digests [Array<Digest>]
|
67
89
|
# @return [Boolean]
|
data/lib/valkyrie/types.rb
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Valkyrie
|
3
|
-
##
|
4
3
|
# Namespace for Dry::Types types.
|
4
|
+
# Includes Dry::Types built-in types and defines custom Valkyrie types
|
5
|
+
#
|
6
|
+
# @example Use types in property definitions on a resource
|
7
|
+
# class Book < Valkyrie::Resource
|
8
|
+
# attribute :id, Valkyrie::Types::ID.optional
|
9
|
+
# attribute :title, Valkyrie::Types::Set.optional # default type if none is specified
|
10
|
+
# attribute :member_ids, Valkyrie::Types::Array
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# @note Not all Dry::Types built-in types are supported in Valkyrie
|
14
|
+
# @see https://github.com/samvera-labs/valkyrie/wiki/Supported-Data-Types List of types supported in Valkyrie
|
5
15
|
module Types
|
6
16
|
include Dry::Types.module
|
17
|
+
|
7
18
|
# Valkyrie::ID
|
8
19
|
ID = Dry::Types::Definition
|
9
20
|
.new(Valkyrie::ID)
|
10
21
|
.constructor do |input|
|
11
|
-
|
12
|
-
|
22
|
+
if input.respond_to?(:each)
|
23
|
+
# Solr::ORMConverter tries to pass an array of Valkyrie::IDs
|
24
|
+
Valkyrie::ID.new(input.first)
|
25
|
+
else
|
26
|
+
Valkyrie::ID.new(input)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Valkyrie::URI
|
31
|
+
URI = Dry::Types::Definition
|
32
|
+
.new(RDF::URI)
|
33
|
+
.constructor do |input|
|
34
|
+
if input.present?
|
35
|
+
RDF::URI.new(input.to_s)
|
36
|
+
else
|
37
|
+
input
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
13
41
|
# Used for casting {Valkyrie::Resources} if possible.
|
14
42
|
Anything = Valkyrie::Types::Any.constructor do |value|
|
15
43
|
if value.respond_to?(:fetch) && value.fetch(:internal_resource, nil)
|
@@ -18,13 +46,43 @@ module Valkyrie
|
|
18
46
|
value
|
19
47
|
end
|
20
48
|
end
|
49
|
+
|
50
|
+
Array = Dry::Types['array'].constructor do |value|
|
51
|
+
if value.is_a?(::Hash)
|
52
|
+
if value.empty?
|
53
|
+
[]
|
54
|
+
else
|
55
|
+
[value]
|
56
|
+
end
|
57
|
+
else
|
58
|
+
::Array.wrap(value)
|
59
|
+
end
|
60
|
+
end.default([].freeze)
|
61
|
+
|
21
62
|
# Represents an array of unique values.
|
22
|
-
Set =
|
23
|
-
value
|
63
|
+
Set = Array.constructor do |value|
|
64
|
+
value = Array[value]
|
65
|
+
clean_values = value.reject do |val|
|
66
|
+
val == '' || (val.is_a?(Valkyrie::ID) && val.to_s == '')
|
67
|
+
end.reject(&:nil?).uniq
|
68
|
+
|
69
|
+
clean_values.map do |val|
|
24
70
|
Anything[val]
|
25
71
|
end
|
26
|
-
end.default([])
|
27
|
-
|
72
|
+
end.default([].freeze)
|
73
|
+
|
74
|
+
module ArrayDefault
|
75
|
+
def of(type)
|
76
|
+
super.default([].freeze)
|
77
|
+
end
|
78
|
+
|
79
|
+
def member(type)
|
80
|
+
super.default([].freeze)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
Array.singleton_class.include(ArrayDefault)
|
84
|
+
Set.singleton_class.include(ArrayDefault)
|
85
|
+
|
28
86
|
# Used for when an input may be an array, but the output needs to be a
|
29
87
|
# single string.
|
30
88
|
SingleValuedString = Valkyrie::Types::String.constructor do |value|
|
data/lib/valkyrie/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
<!--
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
contributor license agreements. See the NOTICE file distributed with
|
4
|
+
this work for additional information regarding copyright ownership.
|
5
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
+
(the "License"); you may not use this file except in compliance with
|
7
|
+
the License. You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
-->
|
17
|
+
|
18
|
+
<!-- The content of this page will be statically included into the top
|
19
|
+
of the admin page. Uncomment this as an example to see there the content
|
20
|
+
will show up.
|
21
|
+
|
22
|
+
<hr>
|
23
|
+
<i>This line will appear before the first table</i>
|
24
|
+
<tr>
|
25
|
+
<td colspan="2">
|
26
|
+
This row will be appended to the end of the first table
|
27
|
+
</td>
|
28
|
+
</tr>
|
29
|
+
<hr>
|
30
|
+
|
31
|
+
-->
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<!--
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
contributor license agreements. See the NOTICE file distributed with
|
5
|
+
this work for additional information regarding copyright ownership.
|
6
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
(the "License"); you may not use this file except in compliance with
|
8
|
+
the License. You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
-->
|
18
|
+
|
19
|
+
<!-- If this file is found in the config directory, it will only be
|
20
|
+
loaded once at startup. If it is found in Solr's data
|
21
|
+
directory, it will be re-loaded every commit.
|
22
|
+
-->
|
23
|
+
|
24
|
+
<elevate>
|
25
|
+
<query text="foo bar">
|
26
|
+
<doc id="1" />
|
27
|
+
<doc id="2" />
|
28
|
+
<doc id="3" />
|
29
|
+
</query>
|
30
|
+
|
31
|
+
<query text="ipod">
|
32
|
+
<doc id="MA147LL/A" /> <!-- put the actual ipod at the top -->
|
33
|
+
<doc id="IW-02" exclude="true" /> <!-- exclude this cable -->
|
34
|
+
</query>
|
35
|
+
|
36
|
+
</elevate>
|
@@ -0,0 +1,246 @@
|
|
1
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
2
|
+
# (the "License"); you may not use this file except in compliance with
|
3
|
+
# the License. You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
# Syntax:
|
14
|
+
# "source" => "target"
|
15
|
+
# "source".length() > 0 (source cannot be empty.)
|
16
|
+
# "target".length() >= 0 (target can be empty.)
|
17
|
+
|
18
|
+
# example:
|
19
|
+
# "??" => "A"
|
20
|
+
# "\u00C0" => "A"
|
21
|
+
# "\u00C0" => "\u0041"
|
22
|
+
# "??" => "ss"
|
23
|
+
# "\t" => " "
|
24
|
+
# "\n" => ""
|
25
|
+
|
26
|
+
# ?? => A
|
27
|
+
"\u00C0" => "A"
|
28
|
+
|
29
|
+
# ?? => A
|
30
|
+
"\u00C1" => "A"
|
31
|
+
|
32
|
+
# ?? => A
|
33
|
+
"\u00C2" => "A"
|
34
|
+
|
35
|
+
# ?? => A
|
36
|
+
"\u00C3" => "A"
|
37
|
+
|
38
|
+
# ?? => A
|
39
|
+
"\u00C4" => "A"
|
40
|
+
|
41
|
+
# ?? => A
|
42
|
+
"\u00C5" => "A"
|
43
|
+
|
44
|
+
# ?? => AE
|
45
|
+
"\u00C6" => "AE"
|
46
|
+
|
47
|
+
# ?? => C
|
48
|
+
"\u00C7" => "C"
|
49
|
+
|
50
|
+
# ?? => E
|
51
|
+
"\u00C8" => "E"
|
52
|
+
|
53
|
+
# ?? => E
|
54
|
+
"\u00C9" => "E"
|
55
|
+
|
56
|
+
# ?? => E
|
57
|
+
"\u00CA" => "E"
|
58
|
+
|
59
|
+
# ?? => E
|
60
|
+
"\u00CB" => "E"
|
61
|
+
|
62
|
+
# ?? => I
|
63
|
+
"\u00CC" => "I"
|
64
|
+
|
65
|
+
# ?? => I
|
66
|
+
"\u00CD" => "I"
|
67
|
+
|
68
|
+
# ?? => I
|
69
|
+
"\u00CE" => "I"
|
70
|
+
|
71
|
+
# ?? => I
|
72
|
+
"\u00CF" => "I"
|
73
|
+
|
74
|
+
# ?? => IJ
|
75
|
+
"\u0132" => "IJ"
|
76
|
+
|
77
|
+
# ?? => D
|
78
|
+
"\u00D0" => "D"
|
79
|
+
|
80
|
+
# ?? => N
|
81
|
+
"\u00D1" => "N"
|
82
|
+
|
83
|
+
# ?? => O
|
84
|
+
"\u00D2" => "O"
|
85
|
+
|
86
|
+
# ?? => O
|
87
|
+
"\u00D3" => "O"
|
88
|
+
|
89
|
+
# ?? => O
|
90
|
+
"\u00D4" => "O"
|
91
|
+
|
92
|
+
# ?? => O
|
93
|
+
"\u00D5" => "O"
|
94
|
+
|
95
|
+
# ?? => O
|
96
|
+
"\u00D6" => "O"
|
97
|
+
|
98
|
+
# ?? => O
|
99
|
+
"\u00D8" => "O"
|
100
|
+
|
101
|
+
# ?? => OE
|
102
|
+
"\u0152" => "OE"
|
103
|
+
|
104
|
+
# ??
|
105
|
+
"\u00DE" => "TH"
|
106
|
+
|
107
|
+
# ?? => U
|
108
|
+
"\u00D9" => "U"
|
109
|
+
|
110
|
+
# ?? => U
|
111
|
+
"\u00DA" => "U"
|
112
|
+
|
113
|
+
# ?? => U
|
114
|
+
"\u00DB" => "U"
|
115
|
+
|
116
|
+
# ?? => U
|
117
|
+
"\u00DC" => "U"
|
118
|
+
|
119
|
+
# ?? => Y
|
120
|
+
"\u00DD" => "Y"
|
121
|
+
|
122
|
+
# ?? => Y
|
123
|
+
"\u0178" => "Y"
|
124
|
+
|
125
|
+
# ?? => a
|
126
|
+
"\u00E0" => "a"
|
127
|
+
|
128
|
+
# ?? => a
|
129
|
+
"\u00E1" => "a"
|
130
|
+
|
131
|
+
# ?? => a
|
132
|
+
"\u00E2" => "a"
|
133
|
+
|
134
|
+
# ?? => a
|
135
|
+
"\u00E3" => "a"
|
136
|
+
|
137
|
+
# ?? => a
|
138
|
+
"\u00E4" => "a"
|
139
|
+
|
140
|
+
# ?? => a
|
141
|
+
"\u00E5" => "a"
|
142
|
+
|
143
|
+
# ?? => ae
|
144
|
+
"\u00E6" => "ae"
|
145
|
+
|
146
|
+
# ?? => c
|
147
|
+
"\u00E7" => "c"
|
148
|
+
|
149
|
+
# ?? => e
|
150
|
+
"\u00E8" => "e"
|
151
|
+
|
152
|
+
# ?? => e
|
153
|
+
"\u00E9" => "e"
|
154
|
+
|
155
|
+
# ?? => e
|
156
|
+
"\u00EA" => "e"
|
157
|
+
|
158
|
+
# ?? => e
|
159
|
+
"\u00EB" => "e"
|
160
|
+
|
161
|
+
# ?? => i
|
162
|
+
"\u00EC" => "i"
|
163
|
+
|
164
|
+
# ?? => i
|
165
|
+
"\u00ED" => "i"
|
166
|
+
|
167
|
+
# ?? => i
|
168
|
+
"\u00EE" => "i"
|
169
|
+
|
170
|
+
# ?? => i
|
171
|
+
"\u00EF" => "i"
|
172
|
+
|
173
|
+
# ?? => ij
|
174
|
+
"\u0133" => "ij"
|
175
|
+
|
176
|
+
# ?? => d
|
177
|
+
"\u00F0" => "d"
|
178
|
+
|
179
|
+
# ?? => n
|
180
|
+
"\u00F1" => "n"
|
181
|
+
|
182
|
+
# ?? => o
|
183
|
+
"\u00F2" => "o"
|
184
|
+
|
185
|
+
# ?? => o
|
186
|
+
"\u00F3" => "o"
|
187
|
+
|
188
|
+
# ?? => o
|
189
|
+
"\u00F4" => "o"
|
190
|
+
|
191
|
+
# ?? => o
|
192
|
+
"\u00F5" => "o"
|
193
|
+
|
194
|
+
# ?? => o
|
195
|
+
"\u00F6" => "o"
|
196
|
+
|
197
|
+
# ?? => o
|
198
|
+
"\u00F8" => "o"
|
199
|
+
|
200
|
+
# ?? => oe
|
201
|
+
"\u0153" => "oe"
|
202
|
+
|
203
|
+
# ?? => ss
|
204
|
+
"\u00DF" => "ss"
|
205
|
+
|
206
|
+
# ?? => th
|
207
|
+
"\u00FE" => "th"
|
208
|
+
|
209
|
+
# ?? => u
|
210
|
+
"\u00F9" => "u"
|
211
|
+
|
212
|
+
# ?? => u
|
213
|
+
"\u00FA" => "u"
|
214
|
+
|
215
|
+
# ?? => u
|
216
|
+
"\u00FB" => "u"
|
217
|
+
|
218
|
+
# ?? => u
|
219
|
+
"\u00FC" => "u"
|
220
|
+
|
221
|
+
# ?? => y
|
222
|
+
"\u00FD" => "y"
|
223
|
+
|
224
|
+
# ?? => y
|
225
|
+
"\u00FF" => "y"
|
226
|
+
|
227
|
+
# ??? => ff
|
228
|
+
"\uFB00" => "ff"
|
229
|
+
|
230
|
+
# ??? => fi
|
231
|
+
"\uFB01" => "fi"
|
232
|
+
|
233
|
+
# ??? => fl
|
234
|
+
"\uFB02" => "fl"
|
235
|
+
|
236
|
+
# ??? => ffi
|
237
|
+
"\uFB03" => "ffi"
|
238
|
+
|
239
|
+
# ??? => ffl
|
240
|
+
"\uFB04" => "ffl"
|
241
|
+
|
242
|
+
# ??? => ft
|
243
|
+
"\uFB05" => "ft"
|
244
|
+
|
245
|
+
# ??? => st
|
246
|
+
"\uFB06" => "st"
|