cul_scv_hydra 0.19.5 → 0.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fad820d73e4e3ccbebdc24acffefc6fe7e1c50f3
4
- data.tar.gz: c134d0ba8f07b271dd19fbf7db1e88ae3da3452a
3
+ metadata.gz: 46d4b43e9073bab05dbc6a72b36d3a0ea1120ee1
4
+ data.tar.gz: 5c2392b7aecea8c413aa0e2729987fb15ef400b1
5
5
  SHA512:
6
- metadata.gz: 3f75bf09c701b26a0f25c3298029895a8354383772be2beb6648bad503faae8c685f63876034b6dd883e41219de27594cc1c305782a47b41690c06bf64c704ef
7
- data.tar.gz: faae4690e145ec50beb4e77e95d85446d21e8ff594f0e50d12846855287ee5c48afc7bd96d1ee75587a55c747027ee0f23d55481589138bbce93ebb3dbc36d0a
6
+ metadata.gz: ca1e49735e2168b74d6942ad4c7b7c51bb055fa24937278c58b92eb5c9a9b7b2c22d587847506d3fea688f46dcefd1e8965a6dc27d6775a96c4ff3179f9b06ab
7
+ data.tar.gz: 5ab6897aa13e0c987f1103b21866d474a7cabff4fdc1ec872947728ff46304a1aeffe9d335aa0f5392dbf314d4336f5ecbdd920c995e2b8bacf55df5bba41d3e
@@ -0,0 +1,17 @@
1
+ module NFO
2
+ module Common
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ property :belongsToContainer, predicate: RDF::NFO[:"#belongsToContainer"], multivalue: false do |ix|
6
+ ix.as :stored_sortable
7
+ end
8
+ end
9
+
10
+ def to_solr(solr_doc={})
11
+ solr_doc = super(solr_doc)
12
+ if solr_doc['']
13
+ end
14
+ solr_doc
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ module NFO
2
+ class FileDataObject < ORE::Proxy
3
+ include NIE::InformationElement
4
+ include NFO::Common
5
+ def initialize(proxy_for_uri, context_uri, *args)
6
+ super(proxy_for_uri, context_uri, *args)
7
+ self.get_values(:type) << RDF::NFO[:"#FileDataObject"]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module NFO
2
+ class Folder < ORE::Proxy
3
+ include NIE::InformationElement
4
+ include NFO::Common
5
+ def initialize(proxy_for_uri, context_uri, *args)
6
+ super(proxy_for_uri, context_uri, *args)
7
+ self.get_values(:type) << RDF::NFO[:"#Folder"]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module NIE
2
+ module InformationElement
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ property :isPartOf, predicate: RDF::NIE[:"#isPartOf"], multivalue: true do |ix|
6
+ ix.as :symbol
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,123 @@
1
+ # A named graph describing the location of a Resource in a virtual nested structure
2
+ require 'digest'
3
+ module ORE
4
+ class Proxy < ActiveTriples::Resource
5
+ include Digest
6
+ include Solrizer::Common
7
+ include ActiveFedora::Rdf::Indexing
8
+
9
+ module Id
10
+ class Descriptor < Solrizer::Descriptor
11
+ def name_and_converter(field_name, field_type)
12
+ ['id']
13
+ end
14
+ end
15
+ def self.id_for2(proxy_in, proxy_for)
16
+ path = proxy_for.to_s
17
+ path = path.sub(/^info.fedora\/[^\/]+\/structMetadata\//,'')
18
+ "urn:proxy:#{proxy_in ? Digest::MD5.hexdigest(proxy_in.to_s) : '' }:#{path}"
19
+ end
20
+ end
21
+ def self.type
22
+ RDF::ORE.Proxy
23
+ end
24
+ property :id, predicate: RDF.nodeID, multivalue: false do |ix|
25
+ ix.as Id::Descriptor.new
26
+ end
27
+ property :isAggregatedBy, predicate: RDF::ORE.isAggregatedBy, multivalue: false do |ix|
28
+ ix.as :stored_sortable
29
+ end
30
+ property :lineage, predicate: RDF::ORE.lineage, multivalue: false do |ix|
31
+ ix.as :stored_sortable
32
+ end
33
+ property :proxyFor, predicate: RDF::ORE.proxyFor, multivalue: false do |ix|
34
+ ix.as :stored_sortable
35
+ end
36
+ property :proxyIn, predicate: RDF::ORE.proxyIn, multivalue: false do |ix|
37
+ ix.as :stored_sortable
38
+ end
39
+ property :index, predicate: RDF::OLO.index, multivalue: false do |ix|
40
+ ix.as :stored_sortable
41
+ ix.type :integer
42
+ end
43
+ property :format, predicate: RDF::DC.format, multivalue: false do |ix|
44
+ ix.as :stored_sortable
45
+ end
46
+ property :extent, predicate: RDF::DC.extent, multivalue: false do |ix|
47
+ ix.as :displayable
48
+ end
49
+ property :label, predicate: RDF::RDFS.label, multivalue: false do |ix|
50
+ ix.as :stored_sortable
51
+ end
52
+ property :hasModel, predicate: RDF::FCREPO3::MODEL.hasModel, multivalue: false do |ix|
53
+ ix.as :stored_sortable
54
+ end
55
+
56
+ def initialize(proxy_resource_uri, graph_context_uri, *args)
57
+ proxy_resource_uri = RDF::URI(proxy_resource_uri)
58
+ super(proxy_resource_uri,*args)
59
+ update(RDF::Statement(rdf_subject,RDF.nodeID,proxy_resource_uri))
60
+ self.proxyIn = graph_context_uri
61
+ self.proxyFor = proxy_resource_uri
62
+ end
63
+
64
+ # override to obscure attempts to identify a containing Datastream
65
+ def apply_prefix(name)
66
+ name
67
+ end
68
+
69
+ def resource
70
+ self
71
+ end
72
+
73
+ def to_json
74
+ to_solr.with_indifferent_access
75
+ end
76
+
77
+ def to_solr(solr_doc = {}) # :nodoc:
78
+ fields.each do |field_key, field_info|
79
+ values = resource.get_values(field_key.to_sym).result || []
80
+ values = [values] unless values.is_a? Array
81
+ values.each do |val|
82
+ if val.kind_of? RDF::URI
83
+ val = val.to_s
84
+ elsif val.kind_of? ActiveTriples::Resource
85
+ val = val.solrize
86
+ end
87
+ self.class.create_and_insert_terms(apply_prefix(field_key), val, field_info[:behaviors], solr_doc)
88
+ end
89
+ end
90
+ solr_doc
91
+ end
92
+ # returns a Hash, e.g.: {field => {:values => [], :type => :something, :behaviors => []}, ...}
93
+ def fields
94
+ field_map = {}.with_indifferent_access
95
+ insert_field_map(:type, type_config(),field_map)
96
+ self.class.properties.each do |name, config|
97
+ insert_field_map(name, config, field_map)
98
+ end
99
+ field_map
100
+ end
101
+
102
+ def insert_field_map(name, config, field_map={})
103
+ type = config[:type]
104
+ behaviors = config[:behaviors]
105
+ return field_map unless type and behaviors
106
+ return field_map if config[:class_name] && config[:class_name] < ActiveFedora::Base
107
+ resource.query(:subject => rdf_subject, :predicate => config[:predicate]).each_statement do |statement|
108
+ field_map[name] ||= {:values => [], :type => type, :behaviors => behaviors, term: config[:term]}
109
+ field_map[name][:values] << statement.object.to_s
110
+ end
111
+ field_map
112
+ end
113
+
114
+ def type_config
115
+ @type_node_config ||= begin
116
+ config = ActiveTriples::NodeConfig.new(:type, RDF.type)
117
+ config.with_index {|ix| ix.as :symbol }
118
+ config
119
+ end
120
+ end
121
+
122
+ end
123
+ end
@@ -0,0 +1,47 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rdf'
3
+ module RDF
4
+ class SC < RDF::StrictVocabulary("http://www.shared-canvas.org/ns/")
5
+ term :Manifest,
6
+ type: "rdfs:Class".freeze
7
+ term :Sequence,
8
+ type: "rdfs:Class".freeze
9
+ term :Canvas,
10
+ type: "rdfs:Class".freeze
11
+ # IIIF 'attribution'
12
+ property :attributionLabel
13
+ # IIIF 'service'
14
+ property :hasRelatedService
15
+ # IIIF 'seeAlso'
16
+ property :hasRelatedDescription
17
+ # IIIF 'sequences'
18
+ # range is a collection of Sequence
19
+ property :hasSequences
20
+
21
+ property :withinManifest,
22
+ range: "http://www.shared-canvas.org/ns/Manifest".freeze,
23
+ subPropertyOf: "dc:isPartOf".freeze
24
+ property :withinSequence,
25
+ range: "http://www.shared-canvas.org/ns/Sequence".freeze,
26
+ subPropertyOf: "dc:isPartOf".freeze
27
+
28
+ # IIIF 'canvases'
29
+ # range is a collection of Canvas
30
+ property :hasCanvases
31
+ # IIIF 'resources'
32
+ property :hasAnnotations
33
+ # IIIF 'images'
34
+ property :hasImageAnnotations
35
+ # IIIF 'otherContent'
36
+ property :hasLists
37
+ # IIIF 'structures'
38
+ property :hasRanges
39
+ # IIIF 'metadata'
40
+ # range is a collection of Resource
41
+ property :metadataLabels
42
+ # IIIF 'viewingDirection'
43
+ property :viewingDirection
44
+ # IIIF 'viewingHint'
45
+ property :viewingHint
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ module SC
2
+ class Canvas < ORE::Proxy
3
+ include NIE::InformationElement
4
+ property :belongsToContainer, predicate: RDF::DC[:isPartOf], multivalue: false do |ix|
5
+ ix.as :stored_sortable
6
+ end
7
+ def initialize(proxy_for_uri, context_uri, *args)
8
+ super(proxy_for_uri, context_uri, *args)
9
+ self.get_values(:type) << RDF::SC[:Canvas]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ module SC
2
+ class Sequence < ORE::Proxy
3
+ include NIE::InformationElement
4
+ property :viewingDirection, predicate: RDF::SC[:viewingDirection], multivalue: false do |ix|
5
+ ix.as :stored_sortable
6
+ end
7
+ property :viewingHint, predicate: RDF::SC[:viewingHint], multivalue: false do |ix|
8
+ ix.as :stored_sortable
9
+ end
10
+ property :canvases, predicate: RDF::SC[:hasCanvases], multivalue: true do |ix|
11
+ ix.as :symbol
12
+ end
13
+ property :belongsToContainer, predicate: RDF::DC[:isPartOf], multivalue: false do |ix|
14
+ ix.as :stored_sortable
15
+ end
16
+ def initialize(proxy_for_uri, context_uri, *args)
17
+ super(proxy_for_uri, context_uri, *args)
18
+ self.get_values(:type) << RDF::SC[:Sequence]
19
+ end
20
+ end
21
+ end
@@ -125,6 +125,52 @@ class StructMetadata < ::ActiveFedora::Datastream
125
125
  doc
126
126
  end
127
127
 
128
+ def proxies
129
+ divs = divs_with_attribute(true)
130
+ graph_context_uri = RDF::URI("info:fedora/#{self.pid}")
131
+ file_system = self.type.eql?(RDF::NFO[:"#Filesystem"].to_s)
132
+ divs.collect do |div|
133
+ proxy_uri_chain = proxy_uri_chain_for(div)
134
+ proxy_resource_uri = proxy_uri_chain.pop
135
+ if div['CONTENTIDS']
136
+ subclass = file_system ?
137
+ NFO::FileDataObject : SC::Canvas
138
+ proxy = subclass.new(proxy_resource_uri, graph_context_uri)
139
+ proxy.proxyFor = RDF::URI(div['CONTENTIDS'])
140
+ else
141
+ subclass = file_system ?
142
+ NFO::Folder : SC::Sequence
143
+ proxy = subclass.new(proxy_resource_uri, graph_context_uri)
144
+ end
145
+ if div.parent and div.parent.name == 'div'
146
+ proxy.belongsToContainer = proxy_uri_for(div.parent)
147
+ end
148
+ proxy.isPartOf = proxy_uri_chain unless proxy_uri_chain.empty?
149
+ proxy.index = div['ORDER']
150
+ proxy.label = div['LABEL']
151
+ proxy
152
+ end
153
+ end
154
+
155
+ private
156
+ def ancestors(node)
157
+ current = node
158
+ labels = []
159
+ while (current.name == 'div')
160
+ labels.unshift URI.escape(current['LABEL'])
161
+ current = current.parent
162
+ end
163
+ labels
164
+ end
165
+ def proxy_uri_chain_for(node)
166
+ uris = []
167
+ ancestors(node).inject(RDF::URI("info:fedora/#{self.pid}/#{self.dsid}")) {|m,a| (uris << m/a).last}
168
+ uris
169
+ end
170
+ def proxy_uri_for(node)
171
+ # uri = segments.inject(base_uri) {|m,a| m/a}
172
+ ancestors(node).inject(RDF::URI("info:fedora/#{self.pid}/#{self.dsid}")) {|m,a| m/a}
173
+ end
128
174
  end
129
175
  end
130
176
  end
@@ -49,4 +49,20 @@ class GenericAggregator < ::ActiveFedora::Base
49
49
  solr_doc
50
50
  end
51
51
 
52
+ def proxies
53
+ datastreams['structMetadata'] ? datastreams['structMetadata'].proxies : []
54
+ end
55
+ def update_index
56
+ super
57
+ if has_struct_metadata?()
58
+ conn = ActiveFedora::SolrService.instance.conn
59
+ # delete by query proxyIn_ssi: internal_uri
60
+ conn.delete_by_query("proxyIn_ssi:#{RSolr.escape(internal_uri())}")
61
+
62
+ # reindex proxies
63
+ proxy_docs = proxies().collect {|p| p.to_solr}
64
+ conn.add(proxy_docs, params: {softCommit: true})
65
+ conn.commit
66
+ end
67
+ end
52
68
  end
data/config/fedora.yml CHANGED
@@ -1,11 +1,11 @@
1
- development:
1
+ alcott: &alcott
2
+ :url: http://alcott.cul.columbia.edu:8080/fedora
2
3
  :user: fedoraAdmin
3
- :password: fedoraAdmin
4
- :url: http://localhost:8983/fedora-test
5
- :time_zone: "America/New_York"
6
-
7
- test:
4
+ :password: f+BULUS*^
5
+ default: &default
6
+ :url: http://127.0.0.1:8983/fedora
8
7
  :user: fedoraAdmin
9
8
  :password: fedoraAdmin
10
- :url: http://localhost:8983/fedora-test
11
- :time_zone: "America/New_York"
9
+ development: *alcott
10
+ test: *default
11
+ production: *alcott
@@ -0,0 +1,12 @@
1
+ <info:fedora/marcorg:nnc> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.loc.gov/mads/rdf/v1#CorporateName> .
2
+ <info:fedora/marcorg:nnc> <http://www.loc.gov/mads/rdf/v1#hasReciprocalAuthority> <http://id.loc.gov/vocabulary/organizations/nnc> .
3
+ <info:fedora/marcorg:nnc> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.loc.gov/mads/rdf/v1#Authority> .
4
+ <info:fedora/marcorg:nnc> <http://www.loc.gov/mads/rdf/v1#code> "NNC"^^<http://id.loc.gov/datatypes/orgs/code> .
5
+ <info:fedora/marcorg:nnc> <http://www.loc.gov/mads/rdf/v1#code> "nnc"^^<http://id.loc.gov/datatypes/orgs/normalized> .
6
+ <info:fedora/marcorg:nnc> <http://www.loc.gov/mads/rdf/v1#authoritativeLabel> "Butler Library"@en .
7
+ <info:fedora/marcorg:nnc> <http://www.loc.gov/mads/rdf/v1#hasAbbreviationVariant> _:bnodereponncfacet .
8
+ <info:fedora/marcorg:nnc> <http://www.loc.gov/mads/rdf/v1#hasExpansionVariant> _:bnodereponncfull .
9
+ _:bnodereponncfacet <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.loc.gov/mads/rdf/v1#Variant> .
10
+ _:bnodereponncfacet <http://www.loc.gov/mads/rdf/v1#variantLabel> "Butler Library"@en .
11
+ _:bnodereponncfull <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.loc.gov/mads/rdf/v1#Variant> .
12
+ _:bnodereponncfull <http://www.loc.gov/mads/rdf/v1#variantLabel> "Butler Library, Columbia University"@en
@@ -72,4 +72,4 @@
72
72
  :foaf_depicts: depicts
73
73
  :foaf_depiction: depiction
74
74
  http://www.w3.org/1999/02/22-rdf-syntax-ns#:
75
- :rdf_type: type
75
+ :rdf_type: type
data/config/subs.yml ADDED
@@ -0,0 +1,12 @@
1
+ development:
2
+ djatoka_server: "http://iris.cul.columbia.edu:8080"
3
+ fedora_server: "http://sayers.cul.columbia.edu:8080"
4
+ php_server: "http://bach.cul.columbia.edu/dev"
5
+ test:
6
+ djatoka_server: "http://iris.cul.columbia.edu:8080"
7
+ fedora_server: "http://sayers.cul.columbia.edu:8080"
8
+ php_server: "http://bach.cul.columbia.edu/dev"
9
+ production:
10
+ djatoka_server: "http://iris.cul.columbia.edu:8080"
11
+ fedora_server: "http://alcott.cul.columbia.edu:8080"
12
+ php_server: "http://bach.cul.columbia.edu"