active-fedora 10.2.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -7
- data/.rubocop_todo.yml +55 -0
- data/active-fedora.gemspec +6 -10
- data/lib/active_fedora/aggregation/list_source.rb +2 -0
- data/lib/active_fedora/associations/association_scope.rb +1 -1
- data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
- data/lib/active_fedora/associations/builder/association.rb +1 -1
- data/lib/active_fedora/associations/builder/orders.rb +11 -3
- data/lib/active_fedora/associations/collection_association.rb +3 -3
- data/lib/active_fedora/associations/contained_finder.rb +2 -2
- data/lib/active_fedora/associations/has_many_association.rb +2 -2
- data/lib/active_fedora/associations/orders_association.rb +4 -0
- data/lib/active_fedora/associations/rdf.rb +2 -0
- data/lib/active_fedora/attribute_assignment.rb +0 -1
- data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/base.rb +4 -8
- data/lib/active_fedora/change_set.rb +6 -2
- data/lib/active_fedora/core.rb +22 -27
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file/streaming.rb +1 -1
- data/lib/active_fedora/indexing.rb +0 -17
- data/lib/active_fedora/indexing_service.rb +0 -9
- data/lib/active_fedora/loadable_from_json.rb +12 -1
- data/lib/active_fedora/nested_attributes.rb +2 -2
- data/lib/active_fedora/orders/list_node.rb +2 -2
- data/lib/active_fedora/orders/ordered_list.rb +7 -3
- data/lib/active_fedora/orders/target_proxy.rb +4 -0
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/railtie.rb +2 -2
- data/lib/active_fedora/rdf/persistence.rb +1 -0
- data/lib/active_fedora/rdf.rb +0 -1
- data/lib/active_fedora/relation/delegation.rb +4 -0
- data/lib/active_fedora/solr_hit.rb +0 -13
- data/lib/active_fedora/solr_query_builder.rb +17 -13
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora.rb +0 -12
- data/lib/generators/active_fedora/model/model_generator.rb +1 -1
- data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
- data/lib/tasks/active_fedora_dev.rake +1 -1
- data/spec/config_helper.rb +1 -1
- data/spec/integration/associations_spec.rb +23 -24
- data/spec/integration/attached_files_spec.rb +18 -8
- data/spec/integration/attributes_spec.rb +12 -16
- data/spec/integration/autosave_association_spec.rb +6 -6
- data/spec/integration/base_spec.rb +3 -3
- data/spec/integration/basic_contains_association_spec.rb +1 -1
- data/spec/integration/clean_connection_spec.rb +1 -1
- data/spec/integration/collection_association_spec.rb +2 -5
- data/spec/integration/date_time_properties_spec.rb +1 -17
- data/spec/integration/direct_container_spec.rb +12 -12
- data/spec/integration/directly_contains_one_association_spec.rb +11 -13
- data/spec/integration/fedora_solr_sync_spec.rb +2 -2
- data/spec/integration/file_fixity_spec.rb +6 -8
- data/spec/integration/file_spec.rb +32 -34
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
- data/spec/integration/has_many_associations_spec.rb +9 -11
- data/spec/integration/indexing_spec.rb +2 -2
- data/spec/integration/indirect_container_spec.rb +11 -12
- data/spec/integration/json_serialization_spec.rb +4 -4
- data/spec/integration/query_result_builder_spec.rb +9 -21
- data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
- data/spec/integration/relation_delegation_spec.rb +8 -10
- data/spec/integration/relation_spec.rb +13 -16
- data/spec/integration/scoped_query_spec.rb +3 -3
- data/spec/integration/solr_hit_spec.rb +4 -15
- data/spec/integration/versionable_spec.rb +73 -327
- data/spec/integration/with_metadata_spec.rb +1 -1
- data/spec/spec_helper.rb +52 -10
- data/spec/unit/active_fedora_spec.rb +1 -1
- data/spec/unit/aggregation/list_source_spec.rb +37 -37
- data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
- data/spec/unit/association_hash_spec.rb +17 -31
- data/spec/unit/attached_files_spec.rb +35 -32
- data/spec/unit/attributes_spec.rb +25 -25
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_cma_spec.rb +1 -1
- data/spec/unit/base_extra_spec.rb +7 -22
- data/spec/unit/base_spec.rb +16 -23
- data/spec/unit/callback_spec.rb +2 -2
- data/spec/unit/change_set_spec.rb +5 -5
- data/spec/unit/checksum_spec.rb +2 -2
- data/spec/unit/code_configurator_spec.rb +1 -1
- data/spec/unit/core_spec.rb +62 -26
- data/spec/unit/default_model_mapper_spec.rb +6 -6
- data/spec/unit/fedora_spec.rb +3 -4
- data/spec/unit/file_configurator_spec.rb +96 -96
- data/spec/unit/file_path_builder_spec.rb +1 -1
- data/spec/unit/file_spec.rb +61 -61
- data/spec/unit/files_hash_spec.rb +9 -9
- data/spec/unit/filter_spec.rb +3 -3
- data/spec/unit/finder_methods_spec.rb +3 -3
- data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
- data/spec/unit/has_many_association_spec.rb +26 -11
- data/spec/unit/indexers/global_indexer_spec.rb +6 -6
- data/spec/unit/indexing_service_spec.rb +5 -5
- data/spec/unit/indexing_spec.rb +6 -6
- data/spec/unit/inheritance_spec.rb +11 -7
- data/spec/unit/loadable_from_json_spec.rb +4 -4
- data/spec/unit/logger_spec.rb +1 -1
- data/spec/unit/model_classifier_spec.rb +5 -5
- data/spec/unit/ordered_spec.rb +144 -147
- data/spec/unit/orders/list_node_spec.rb +21 -21
- data/spec/unit/orders/ordered_list_spec.rb +96 -96
- data/spec/unit/orders/reflection_spec.rb +4 -4
- data/spec/unit/pathing_spec.rb +4 -4
- data/spec/unit/persistence_spec.rb +28 -28
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/query_spec.rb +6 -6
- data/spec/unit/rdf/indexing_service_spec.rb +29 -29
- data/spec/unit/readonly_spec.rb +5 -4
- data/spec/unit/reflection_spec.rb +3 -3
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
- data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
- data/spec/unit/serializers_spec.rb +3 -4
- data/spec/unit/solr_config_options_spec.rb +13 -16
- data/spec/unit/solr_hit_spec.rb +9 -9
- data/spec/unit/solr_service_spec.rb +4 -10
- data/spec/unit/sparql_insert_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +9 -9
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
- data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
- metadata +17 -91
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
- data/lib/active_fedora/datastreams.rb +0 -6
- data/lib/active_fedora/nom_datastream.rb +0 -73
- data/lib/active_fedora/om_datastream.rb +0 -118
- data/lib/active_fedora/profile_indexing_service.rb +0 -11
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
- data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
- data/lib/active_fedora/rdf/rdf_datastream.rb +0 -167
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
- data/lib/active_fedora/solr_instance_loader.rb +0 -47
- data/spec/fixtures/damsObjectModel.xml +0 -38
- data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
- data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
- data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
- data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
- data/spec/integration/ntriples_datastream_spec.rb +0 -203
- data/spec/integration/om_datastream_spec.rb +0 -78
- data/spec/integration/solr_instance_loader_spec.rb +0 -156
- data/spec/samples/hydra-mods_article_datastream.rb +0 -517
- data/spec/samples/models/mods_article.rb +0 -9
- data/spec/samples/oral_history_sample.xml +0 -38
- data/spec/samples/oral_history_xml.xml +0 -35
- data/spec/samples/samples.rb +0 -2
- data/spec/unit/nom_datastream_spec.rb +0 -60
- data/spec/unit/ntriples_datastream_spec.rb +0 -170
- data/spec/unit/om_datastream_spec.rb +0 -294
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
- data/spec/unit/rdf_datastream_spec.rb +0 -84
- data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
- data/spec/unit/rdfxml_datastream_spec.rb +0 -106
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
module ActiveFedora
|
|
2
|
-
# This class represents a Qualified Dublin Core Datastream. A special case of ActiveFedora::OmDatastream
|
|
3
|
-
# The implementation of this class defines the terms from the Qualified Dublin Core specification.
|
|
4
|
-
# This implementation features customized xml generators and deserialization routines to handle the
|
|
5
|
-
# Fedora Dublin Core XML datastreams structure.
|
|
6
|
-
#
|
|
7
|
-
# Fields can still be overridden if more specificity is desired (see ActiveFedora::File#fields method).
|
|
8
|
-
class QualifiedDublinCoreDatastream < OmDatastream
|
|
9
|
-
attr_accessor :fields
|
|
10
|
-
class_attribute :class_fields
|
|
11
|
-
self.class_fields = []
|
|
12
|
-
|
|
13
|
-
set_terminology do |t|
|
|
14
|
-
t.root(path: "dc", xmlns: "http://purl.org/dc/terms/")
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
define_template :creator do |xml, name|
|
|
18
|
-
xml.creator do
|
|
19
|
-
xml.text(name)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# A frozen array of Dublincore Terms.
|
|
24
|
-
DCTERMS = [
|
|
25
|
-
:abstract,
|
|
26
|
-
:accessRights,
|
|
27
|
-
:accrualMethod,
|
|
28
|
-
:accrualPeriodicity,
|
|
29
|
-
:accrualPolicy,
|
|
30
|
-
:alternative,
|
|
31
|
-
:audience,
|
|
32
|
-
:available,
|
|
33
|
-
:bibliographicCitation,
|
|
34
|
-
:conformsTo,
|
|
35
|
-
:contributor,
|
|
36
|
-
:coverage,
|
|
37
|
-
:created,
|
|
38
|
-
:creator,
|
|
39
|
-
:date,
|
|
40
|
-
:dateAccepted,
|
|
41
|
-
:dateCopyrighted,
|
|
42
|
-
:dateSubmitted,
|
|
43
|
-
:description,
|
|
44
|
-
:educationLevel,
|
|
45
|
-
:extent,
|
|
46
|
-
:hasFormat,
|
|
47
|
-
:hasPart,
|
|
48
|
-
:hasVersion,
|
|
49
|
-
:identifier,
|
|
50
|
-
:instructionalMethod,
|
|
51
|
-
:isFormatOf,
|
|
52
|
-
:isPartOf,
|
|
53
|
-
:isReferencedBy,
|
|
54
|
-
:isReplacedBy,
|
|
55
|
-
:isRequiredBy,
|
|
56
|
-
:isVersionOf,
|
|
57
|
-
:issued,
|
|
58
|
-
:language,
|
|
59
|
-
:license,
|
|
60
|
-
:mediator,
|
|
61
|
-
:medium,
|
|
62
|
-
:modified,
|
|
63
|
-
:provenance,
|
|
64
|
-
:publisher,
|
|
65
|
-
:references,
|
|
66
|
-
:relation,
|
|
67
|
-
:replaces,
|
|
68
|
-
:requires,
|
|
69
|
-
:rights,
|
|
70
|
-
:rightsHolder,
|
|
71
|
-
:source,
|
|
72
|
-
:spatial,
|
|
73
|
-
:subject,
|
|
74
|
-
:tableOfContents,
|
|
75
|
-
:temporal,
|
|
76
|
-
:title,
|
|
77
|
-
:type,
|
|
78
|
-
:valid
|
|
79
|
-
].freeze # removed :format
|
|
80
|
-
DCTERMS.freeze
|
|
81
|
-
|
|
82
|
-
# Constructor. this class will call self.field for each DCTERM. In short, all DCTERMS fields will already exist
|
|
83
|
-
# when this method returns. Each term is marked as a multivalue string.
|
|
84
|
-
def initialize(string_or_url = nil)
|
|
85
|
-
super
|
|
86
|
-
self.fields = {}
|
|
87
|
-
DCTERMS.each do |el|
|
|
88
|
-
field el, :string, multiple: true
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# This method generates the various accessor and mutator methods on self for the datastream metadata attributes.
|
|
93
|
-
# each field will have the 2 magic methods:
|
|
94
|
-
# name=(arg)
|
|
95
|
-
# name
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
# Calling any of the generated methods marks self as dirty.
|
|
99
|
-
#
|
|
100
|
-
# 'tupe' is a datatype, currently :string, :text and :date are supported.
|
|
101
|
-
#
|
|
102
|
-
# opts is an options hash, which will affect the generation of the xml representation of this datastream.
|
|
103
|
-
#
|
|
104
|
-
# Currently supported modifiers:
|
|
105
|
-
# For +QualifiedDublinCorDatastreams+:
|
|
106
|
-
# :element_attrs =>{:foo=>:bar} - hash of xml element attributes
|
|
107
|
-
# :xml_node => :nodename - The xml node to be used to represent this object (in dcterms namespace)
|
|
108
|
-
# :encoding=>foo, or encodings_scheme - causes an xsi:type attribute to be set to 'foo'
|
|
109
|
-
# :multiple=>true - mark this field as a multivalue field (on by default)
|
|
110
|
-
#
|
|
111
|
-
#
|
|
112
|
-
# There is quite a good example of this class in use in spec/examples/oral_history.rb
|
|
113
|
-
#
|
|
114
|
-
# !! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
|
|
115
|
-
# you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
|
|
116
|
-
# whenever you edit the field's values.
|
|
117
|
-
def field(name, tupe = nil, opts = {})
|
|
118
|
-
@fields[name.to_s.to_sym] = { type: tupe, values: [] }.merge(opts)
|
|
119
|
-
# add term to template
|
|
120
|
-
self.class.class_fields << name.to_s
|
|
121
|
-
# add term to terminology
|
|
122
|
-
return if self.class.terminology.has_term?(name.to_sym)
|
|
123
|
-
om_term_opts = { xmlns: "http://purl.org/dc/terms/", namespace_prefix: "dcterms", path: opts[:path] }
|
|
124
|
-
term = OM::XML::Term.new(name.to_sym, om_term_opts, self.class.terminology)
|
|
125
|
-
self.class.terminology.add_term(term)
|
|
126
|
-
term.generate_xpath_queries!
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def update_indexed_attributes(params = {}, opts = {})
|
|
130
|
-
# if the params are just keys, not an array, make then into an array.
|
|
131
|
-
new_params = {}
|
|
132
|
-
params.each do |key, val|
|
|
133
|
-
if key.is_a? Array
|
|
134
|
-
new_params[key] = val
|
|
135
|
-
else
|
|
136
|
-
new_params[[key.to_sym]] = val
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
super(new_params, opts)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def self.xml_template
|
|
143
|
-
Nokogiri::XML::Document.parse("<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'/>")
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def to_solr(solr_doc = {}, _opts = {}) # :nodoc:
|
|
147
|
-
@fields.each do |field_key, field_info|
|
|
148
|
-
things = send(field_key)
|
|
149
|
-
next unless things
|
|
150
|
-
field_symbol = ActiveFedora.index_field_mapper.solr_name(field_key, type: field_info[:type])
|
|
151
|
-
things.val.each do |val|
|
|
152
|
-
::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val)
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
solr_doc
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
module ActiveFedora::RDF
|
|
2
|
-
module DatastreamIndexing
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
def to_solr(solr_doc = {}, opts = {}) # :nodoc:
|
|
6
|
-
super.tap do |new_doc|
|
|
7
|
-
solrize_rdf_assertions(opts[:name], new_doc)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
module ClassMethods
|
|
12
|
-
def indexer
|
|
13
|
-
ActiveFedora::RDF::IndexingService
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def index_config
|
|
17
|
-
@index_config ||= ActiveFedora::Indexing::Map.new
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
protected
|
|
22
|
-
|
|
23
|
-
def indexing_service
|
|
24
|
-
@indexing_service ||= self.class.indexer.new(self)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# Serialize the datastream's RDF relationships to solr
|
|
28
|
-
# @param [String] file_path used to prefix the keys in the solr document
|
|
29
|
-
# @param [Hash] solr_doc @default an empty Hash
|
|
30
|
-
def solrize_rdf_assertions(file_path, solr_doc = {})
|
|
31
|
-
solr_doc.merge! indexing_service.generate_solr_document(prefix_method(file_path))
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Returns a function that takes field name and returns a solr document key
|
|
35
|
-
def prefix_method(file_path)
|
|
36
|
-
->(field_name) { apply_prefix(field_name, file_path) }
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def apply_prefix(name, file_path)
|
|
40
|
-
prefix(file_path) + name.to_s
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# The string to prefix all solr fields with. Override this method if you want
|
|
44
|
-
# a prefix other than the default
|
|
45
|
-
def prefix(path)
|
|
46
|
-
path ? "#{path.underscore}__" : ''
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require 'rdf/ntriples'
|
|
2
|
-
|
|
3
|
-
module ActiveFedora
|
|
4
|
-
class NtriplesRDFDatastream < RDFDatastream
|
|
5
|
-
def serialization_format
|
|
6
|
-
:ntriples
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def deprecation_warning
|
|
10
|
-
Deprecation.warn(NtriplesRDFDatastream, "NtriplesRDFDatastream is deprecated and will be removed in ActiveFedora 11", caller(2))
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
module ActiveFedora
|
|
2
|
-
class RDFDatastream < File
|
|
3
|
-
include ActiveTriples::NestedAttributes
|
|
4
|
-
include RDF::DatastreamIndexing
|
|
5
|
-
include ActiveTriples::Properties
|
|
6
|
-
include ActiveTriples::Reflection
|
|
7
|
-
extend Deprecation
|
|
8
|
-
|
|
9
|
-
delegate :rdf_subject, :set_value, :get_values, :attributes=, to: :resource
|
|
10
|
-
def initialize(*args)
|
|
11
|
-
super
|
|
12
|
-
deprecation_warning
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def deprecation_warning
|
|
16
|
-
Deprecation.warn(RDFDatastream, "RDFDatastream is deprecated and will be removed in ActiveFedora 11", caller(2))
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
class << self
|
|
20
|
-
def rdf_subject(&block)
|
|
21
|
-
return @subject_block = block if block_given?
|
|
22
|
-
|
|
23
|
-
@subject_block ||= ->(ds) { parent_uri(ds) }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Trim the last segment off the URI to get the parents uri
|
|
27
|
-
def parent_uri(ds)
|
|
28
|
-
m = /^(.*)\/[^\/]*$/.match(ds.uri)
|
|
29
|
-
if m
|
|
30
|
-
m[1]
|
|
31
|
-
else
|
|
32
|
-
::RDF::URI.new(nil)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
##
|
|
37
|
-
# @param [Class] klass an object to set as the resource class, Must be a descendant of
|
|
38
|
-
# ActiveTriples::Resource and include ActiveFedora::RDF::Persistence.
|
|
39
|
-
#
|
|
40
|
-
# @return [Class] the object resource class
|
|
41
|
-
def resource_class(klass = nil)
|
|
42
|
-
if klass
|
|
43
|
-
raise ArgumentError, "#{self} already has a resource_class #{@resource_class}, cannot redefine it to #{klass}" if @resource_class && klass != @resource_class
|
|
44
|
-
raise ArgumentError, "#{klass} must be a subclass of ActiveTriples::Resource" unless klass < ActiveTriples::Resource
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
@resource_class ||= begin
|
|
48
|
-
klass = Class.new(klass || ActiveTriples::Resource)
|
|
49
|
-
klass.send(:include, RDF::Persistence)
|
|
50
|
-
klass
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
before_save do
|
|
56
|
-
if content.blank?
|
|
57
|
-
ActiveFedora::Base.logger.warn "Cowardly refusing to save a datastream with empty content: #{inspect}" if ActiveFedora::Base.logger
|
|
58
|
-
false
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def parent_uri
|
|
63
|
-
self.class.parent_uri(self)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def metadata?
|
|
67
|
-
true
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def content
|
|
71
|
-
serialize
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def content=(new_content)
|
|
75
|
-
resource.clear!
|
|
76
|
-
resource << deserialize(new_content)
|
|
77
|
-
content
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def uri=(uri)
|
|
81
|
-
super
|
|
82
|
-
resource.set_subject!(parent_uri) if empty_or_blank_subject?
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def content_changed?
|
|
86
|
-
return false unless instance_variable_defined? :@resource
|
|
87
|
-
return true if empty_or_blank_subject? # can't be serialized because a subject hasn't been assigned yet.
|
|
88
|
-
@content = serialize
|
|
89
|
-
super
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def empty_or_blank_subject?
|
|
93
|
-
resource.rdf_subject.node? || resource.rdf_subject.value.blank?
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def freeze
|
|
97
|
-
@resource.freeze
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
##
|
|
101
|
-
# The resource is the RdfResource object that stores the graph for
|
|
102
|
-
# the datastream and is the central point for its relationship to
|
|
103
|
-
# other nodes.
|
|
104
|
-
#
|
|
105
|
-
# set_value, get_value, and property accessors are delegated to this object.
|
|
106
|
-
def resource
|
|
107
|
-
@resource ||= begin
|
|
108
|
-
klass = self.class.resource_class
|
|
109
|
-
klass.properties.merge(self.class.properties).each do |_prop, config|
|
|
110
|
-
klass.property(config.term,
|
|
111
|
-
predicate: config.predicate,
|
|
112
|
-
class_name: config.class_name)
|
|
113
|
-
end
|
|
114
|
-
klass.accepts_nested_attributes_for(*nested_attributes_options.keys) unless nested_attributes_options.blank?
|
|
115
|
-
uri_stub = self.class.rdf_subject.call(self)
|
|
116
|
-
|
|
117
|
-
r = klass.new(uri_stub)
|
|
118
|
-
r.datastream = self
|
|
119
|
-
r << deserialize
|
|
120
|
-
r
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
alias graph resource
|
|
125
|
-
|
|
126
|
-
def refresh_attributes
|
|
127
|
-
@resource = nil
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
##
|
|
131
|
-
# This method allows for delegation.
|
|
132
|
-
# This patches the fact that there's no consistent API for allowing delegation - we're matching the
|
|
133
|
-
# OmDatastream implementation as our "consistency" point.
|
|
134
|
-
# @TODO: We may need to enable deep RDF delegation at one point.
|
|
135
|
-
def term_values(*values)
|
|
136
|
-
send(values.first)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def update_indexed_attributes(hash)
|
|
140
|
-
hash.each do |fields, value|
|
|
141
|
-
fields.each do |field|
|
|
142
|
-
send("#{field}=", value)
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def serialize
|
|
148
|
-
resource.set_subject!(parent_uri) if parent_uri && rdf_subject.node?
|
|
149
|
-
resource.dump serialization_format
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def deserialize(data = nil)
|
|
153
|
-
return ::RDF::Graph.new if new_record? && data.nil?
|
|
154
|
-
data ||= remote_content
|
|
155
|
-
|
|
156
|
-
# Because datastream_content can return nil, we should check that here.
|
|
157
|
-
return ::RDF::Graph.new if data.nil?
|
|
158
|
-
|
|
159
|
-
data.force_encoding('utf-8')
|
|
160
|
-
::RDF::Graph.new << ::RDF::Reader.for(serialization_format).new(data)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def serialization_format
|
|
164
|
-
raise "you must override the `serialization_format' method in a subclass"
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
module ActiveFedora
|
|
2
|
-
class FedoraSolrMismatchError < ActiveFedora::ObjectNotFoundError
|
|
3
|
-
def initialize(fedora_id, solr_document_id)
|
|
4
|
-
super("Solr ID and Fedora ID do not match; Solr ID=#{solr_document_id}, Fedora ID=#{fedora_id}")
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
# Responsible for loading an ActiveFedora::Base proxy from a Solr document.
|
|
9
|
-
class SolrInstanceLoader
|
|
10
|
-
attr_reader :context, :id
|
|
11
|
-
private :context, :id
|
|
12
|
-
def initialize(context, id, solr_doc = nil)
|
|
13
|
-
@context = context
|
|
14
|
-
@id = id
|
|
15
|
-
self.solr_doc = solr_doc
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def object
|
|
19
|
-
return @object if @object
|
|
20
|
-
@object = solr_doc.instantiate_with_json
|
|
21
|
-
@object.readonly!
|
|
22
|
-
@object.freeze
|
|
23
|
-
@object
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def solr_doc
|
|
29
|
-
@solr_doc ||= begin
|
|
30
|
-
self.solr_doc = context.search_by_id(id)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def solr_doc=(solr_doc)
|
|
35
|
-
unless solr_doc.nil?
|
|
36
|
-
solr_doc = ActiveFedora::SolrHit.for(solr_doc)
|
|
37
|
-
validate_solr_doc_and_id!(solr_doc)
|
|
38
|
-
@solr_doc = solr_doc
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def validate_solr_doc_and_id!(document)
|
|
43
|
-
return if id == document.id
|
|
44
|
-
raise ActiveFedora::FedoraSolrMismatchError, id, document.id
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<rdf:RDF
|
|
2
|
-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
3
|
-
xmlns:dams="http://library.ucsd.edu/ontology/dams#"
|
|
4
|
-
xmlns:mads="http://www.loc.gov/mads/rdf/v1#"
|
|
5
|
-
xmlns:damsid="http://library.ucsd.edu/ark:/20775/">
|
|
6
|
-
<dams:Object rdf:about="http://library.ucsd.edu/ark:/20775/">
|
|
7
|
-
<dams:title rdf:parseType="Resource">
|
|
8
|
-
<rdf:value>example title</rdf:value>
|
|
9
|
-
<dams:relatedTitle rdf:parseType="Resource">
|
|
10
|
-
<rdf:value xml:lang="fr">example translated relatedTitle</rdf:value>
|
|
11
|
-
<dams:type>translated</dams:type>
|
|
12
|
-
</dams:relatedTitle>
|
|
13
|
-
</dams:title>
|
|
14
|
-
|
|
15
|
-
<dams:date rdf:parseType="Resource">
|
|
16
|
-
<dams:beginDate>2012-11-27</dams:beginDate>
|
|
17
|
-
<dams:endDate>2012-11-30</dams:endDate>
|
|
18
|
-
<rdf:value>2012-11-29</rdf:value>
|
|
19
|
-
</dams:date>
|
|
20
|
-
|
|
21
|
-
<dams:language rdf:resource="http://library.ucsd.edu/ark:/20775/bb12345678"/>
|
|
22
|
-
<dams:typeOfResource>image</dams:typeOfResource>
|
|
23
|
-
<dams:otherResource>
|
|
24
|
-
<dams:RelatedResource>
|
|
25
|
-
<dams:type>online exhibit</dams:type>
|
|
26
|
-
<dams:description>foo</dams:description>
|
|
27
|
-
<dams:uri>http://library.ucsd.edu/test/foo/</dams:uri>
|
|
28
|
-
</dams:RelatedResource>
|
|
29
|
-
</dams:otherResource>
|
|
30
|
-
<dams:relationship>
|
|
31
|
-
<dams:Relationship>
|
|
32
|
-
<dams:role rdf:resource="http://library.ucsd.edu/ark:/20775/bd55639754"/>
|
|
33
|
-
<dams:name rdf:resource="http://library.ucsd.edu/ark:/20775/bb08080808"/>
|
|
34
|
-
</dams:Relationship>
|
|
35
|
-
</dams:relationship>
|
|
36
|
-
<dams:assembledCollection rdf:resource="http://library.ucsd.edu/ark:/20775/bb03030303"/>
|
|
37
|
-
</dams:Object>
|
|
38
|
-
</rdf:RDF>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/description> "This is a work by JD in the field of biology." .
|
|
2
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/publisher> "Penn State" .
|
|
3
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/contributor> "Department of Bioinformatics" .
|
|
4
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/created> "2010-12-31"^^<http://www.w3.org/2001/XMLSchema#date> .
|
|
5
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/title> "Title of work" .
|
|
6
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/subject> "Biology" .
|
|
7
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/language> "en" .
|
|
8
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/date> "2009-12-31"^^<http://www.w3.org/2001/XMLSchema#date> .
|
|
9
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/rights> "insert rights statement here" .
|
|
10
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/type> <http://purl.org/dc/dcmitype/Image> .
|
|
11
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/format> "image/jpeg" .
|
|
12
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/creator> "John Doe" .
|
|
13
|
-
<http://id.psu.edu/object42> <http://purl.org/dc/terms/identifier> "old:identifier:7779" .
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/created> "2010-12-31"^^<http://www.w3.org/2001/XMLSchema#date> .
|
|
2
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/title> "Title of work" .
|
|
3
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/publisher> "Penn State" .
|
|
4
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://xmlns.com/foaf/0.1/based_near> "New York, NY, US" .
|
|
5
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://google.com/> .
|
|
6
|
-
<http://localhost:8983/fedora/rest/test/test:1/content> <http://purl.org/dc/terms/title> "Title of datastream" .
|
|
7
|
-
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
<mods version="3.0" xsi:schemaLocation="http://www.loc.gov/mods/v3
|
|
2
|
-
http://www.loc.gov/standards/mods/v3/mods-3-0.xsd" xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
3
|
-
|
|
4
|
-
<titleInfo>
|
|
5
|
-
<nonSort>THE</nonSort>
|
|
6
|
-
<title>ARTICLE TITLE</title>
|
|
7
|
-
<subTitle>SUBTITLE</subTitle>
|
|
8
|
-
</titleInfo>
|
|
9
|
-
<titleInfo type="alternative">
|
|
10
|
-
<title>VARYING FORM OF TITLE</title>
|
|
11
|
-
</titleInfo>
|
|
12
|
-
|
|
13
|
-
<name type="personal">
|
|
14
|
-
<namePart type="family">FAMILY NAME</namePart>
|
|
15
|
-
<namePart type="given">GIVEN NAMES</namePart>
|
|
16
|
-
<namePart type="termsOfAddress">DR.</namePart>
|
|
17
|
-
<displayForm>NAME AS IT APPEARS</displayForm>
|
|
18
|
-
<affiliation>FACULTY, UNIVERSITY</affiliation>
|
|
19
|
-
<role>
|
|
20
|
-
<roleTerm authority="marcrelator" type="text">Creator</roleTerm>
|
|
21
|
-
</role>
|
|
22
|
-
</name>
|
|
23
|
-
<name type="personal">
|
|
24
|
-
<namePart type="family">Lacks</namePart>
|
|
25
|
-
<namePart type="given">Henrietta</namePart>
|
|
26
|
-
<displayForm>HeLa</displayForm>
|
|
27
|
-
<affiliation>Baltimore</affiliation>
|
|
28
|
-
<role>
|
|
29
|
-
<roleTerm authority="marcrelator" type="text">Contributor</roleTerm>
|
|
30
|
-
</role>
|
|
31
|
-
</name>
|
|
32
|
-
<name type="corporate">
|
|
33
|
-
<namePart>NSF</namePart>
|
|
34
|
-
<role>
|
|
35
|
-
<roleTerm authority="marcrelator" type="text">Funder</roleTerm>
|
|
36
|
-
</role>
|
|
37
|
-
</name>
|
|
38
|
-
<name type="conference">
|
|
39
|
-
<namePart>some conference</namePart>
|
|
40
|
-
<role>
|
|
41
|
-
<roleTerm authority="marcrelator" type="text">Host</roleTerm>
|
|
42
|
-
</role>
|
|
43
|
-
</name>
|
|
44
|
-
|
|
45
|
-
<typeOfResource>text</typeOfResource>
|
|
46
|
-
<genre authority="local">journal article</genre>
|
|
47
|
-
|
|
48
|
-
<abstract>ABSTRACT</abstract>
|
|
49
|
-
<subject>
|
|
50
|
-
<topic>TOPIC 1</topic>
|
|
51
|
-
<topic>TOPIC 2</topic>
|
|
52
|
-
</subject>
|
|
53
|
-
<subject authority="AUTHORITY SOURCE (RFCD, LCSH)">
|
|
54
|
-
<topic>CONTROLLED TERM</topic>
|
|
55
|
-
</subject>
|
|
56
|
-
|
|
57
|
-
<language>
|
|
58
|
-
<languageTerm authority="iso639-2b" type="code">en-aus </languageTerm>
|
|
59
|
-
</language>
|
|
60
|
-
|
|
61
|
-
<physicalDescription>
|
|
62
|
-
<internetMediaType>application/pdf</internetMediaType>
|
|
63
|
-
<extent>36 p.</extent>
|
|
64
|
-
</physicalDescription>
|
|
65
|
-
|
|
66
|
-
<relatedItem type="host">
|
|
67
|
-
<titleInfo>
|
|
68
|
-
<title>TITLE OF HOST JOURNAL</title>
|
|
69
|
-
</titleInfo>
|
|
70
|
-
<originInfo>
|
|
71
|
-
<publisher>PUBLISHER</publisher>
|
|
72
|
-
<dateIssued>DATE</dateIssued>
|
|
73
|
-
</originInfo>
|
|
74
|
-
<identifier type="issn">0013-8908</identifier>
|
|
75
|
-
<part>
|
|
76
|
-
<detail type="volume">
|
|
77
|
-
<number>2</number>
|
|
78
|
-
</detail>
|
|
79
|
-
<detail type="level">
|
|
80
|
-
<number>2</number>
|
|
81
|
-
</detail>
|
|
82
|
-
<extent unit="pages">
|
|
83
|
-
<start>195</start>
|
|
84
|
-
<end>230</end>
|
|
85
|
-
</extent>
|
|
86
|
-
<date>FEB. 2007</date>
|
|
87
|
-
</part>
|
|
88
|
-
</relatedItem>
|
|
89
|
-
|
|
90
|
-
<identifier type="uri">http://URL.edu.au/</identifier>
|
|
91
|
-
<identifier type="doi">doi:10.1006/jmbi.1995.0238</identifier>
|
|
92
|
-
<location>
|
|
93
|
-
<url>http://URL.edu.au/</url>
|
|
94
|
-
</location>
|
|
95
|
-
<accessCondition type="restrictionOnAccess">EMBARGO NOTE</accessCondition>
|
|
96
|
-
<accessCondition type="use and reproduction">OPEN ACCESS</accessCondition>
|
|
97
|
-
|
|
98
|
-
</mods>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/created> "2009-10-10"^^<http://www.w3.org/2001/XMLSchema#date> .
|
|
2
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/title> "fake-title" .
|
|
3
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://purl.org/dc/terms/publisher> "publisher1" .
|
|
4
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://xmlns.com/foaf/0.1/based_near> "coverage1" .
|
|
5
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://xmlns.com/foaf/0.1/based_near> "coverage2" .
|
|
6
|
-
<http://localhost:8983/fedora/rest/test/test:1> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://example.org/> .
|
|
7
|
-
|