hydra-head 3.0.0pre1 → 3.0.0pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -4
- data/HOW_TO_GET_STARTED.textile +571 -0
- data/HYDRA_ACCESS_CONTROLS.textile +27 -0
- data/INITIAL_APP_MODS.textile +239 -0
- data/README.textile +22 -7
- data/README_RAILS3_CHANGES.textile +23 -2
- data/app/views/catalog/_sort_and_per_page.html.erb +3 -2
- data/app/views/catalog/show.html.erb +1 -1
- data/lib/generators/hydra/cucumber_support_generator.rb +29 -0
- data/lib/generators/hydra/head_generator.rb +6 -14
- data/lib/generators/hydra/hyhead_fixtures_generator.rb +27 -0
- data/lib/generators/hydra/templates/config/initializers/fedora_config.rb +3 -1
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra/access_controls_evaluation.rb +8 -4
- data/lib/hydra/{fixtures.rb → fixture_loader.rb} +14 -9
- data/lib/railties/hydra-fixtures.rake +5 -5
- data/tasks/hydra-head.rake +36 -25
- data/test_support/features/file_upload.feature +1 -1
- data/test_support/features/mods_asset_search_result.feature +12 -1
- data/test_support/features/step_definitions/edit_metadata_steps.rb +2 -2
- data/test_support/features/step_definitions/show_document_steps.rb +4 -0
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +62 -10
- data/vendor/cache/addressable-2.2.6.gem +0 -0
- data/vendor/cache/launchy-2.0.4.gem +0 -0
- data/vendor/cache/mediashelf-loggable-0.4.3.gem +0 -0
- data/vendor/cache/multipart-post-1.1.3.gem +0 -0
- metadata +15 -13
- data/lib/generators/hydra/templates/migrations/add_user_attributes_table.rb +0 -15
- data/test_support/features/html_validity.feature +0 -47
- data/vendor/cache/launchy-2.0.3.gem +0 -0
- data/vendor/cache/mediashelf-loggable-0.4.2.gem +0 -0
- data/vendor/cache/multipart-post-1.1.2.gem +0 -0
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hydra-head (
|
4
|
+
hydra-head (3.0.0pre1)
|
5
5
|
RedCloth (= 4.2.3)
|
6
6
|
active-fedora (>= 2.3.3)
|
7
7
|
blacklight (= 3.0.0)
|
@@ -81,6 +81,7 @@ GEM
|
|
81
81
|
activemodel (= 3.0.9)
|
82
82
|
activesupport (= 3.0.9)
|
83
83
|
activesupport (3.0.9)
|
84
|
+
addressable (2.2.6)
|
84
85
|
arel (2.0.10)
|
85
86
|
blacklight (3.0.0)
|
86
87
|
kaminari
|
@@ -139,7 +140,8 @@ GEM
|
|
139
140
|
json_pure (1.5.3)
|
140
141
|
kaminari (0.12.4)
|
141
142
|
rails (>= 3.0.0)
|
142
|
-
launchy (2.0.
|
143
|
+
launchy (2.0.4)
|
144
|
+
addressable (~> 2.2.6)
|
143
145
|
linecache (0.46)
|
144
146
|
rbx-require-relative (> 0.0.4)
|
145
147
|
logger (1.2.8)
|
@@ -149,10 +151,10 @@ GEM
|
|
149
151
|
mime-types (~> 1.16)
|
150
152
|
treetop (~> 1.4.8)
|
151
153
|
marc (0.4.3)
|
152
|
-
mediashelf-loggable (0.4.
|
154
|
+
mediashelf-loggable (0.4.5)
|
153
155
|
mime-types (1.16)
|
154
156
|
mocha (0.9.12)
|
155
|
-
multipart-post (1.1.
|
157
|
+
multipart-post (1.1.3)
|
156
158
|
nokogiri (1.5.0)
|
157
159
|
om (1.2.5)
|
158
160
|
nokogiri (>= 1.4.2)
|
@@ -0,0 +1,571 @@
|
|
1
|
+
h1. Getting Started Building Your Own Hydra Application
|
2
|
+
|
3
|
+
|
4
|
+
*!!! This is a WORK IN PROGRESS !!!*
|
5
|
+
|
6
|
+
h3. What you will learn from this document:
|
7
|
+
|
8
|
+
Set up a Hydra application (a rails app that uses the hydra-head plugin) and run it
|
9
|
+
Define a new Content Type called JournalArticle
|
10
|
+
# Define the ActiveFedora Model for JournalArticles
|
11
|
+
# Index JournalArticles into solr
|
12
|
+
# Customize how JournalArticles appear in search results
|
13
|
+
# Define JournalArticles “show” view
|
14
|
+
# Define JournalArticles “edit” view
|
15
|
+
|
16
|
+
h2. Set up a new Hydra Head
|
17
|
+
|
18
|
+
See "README":http://hudson.projecthydra.org/job/hydra-head-rails3-plugin/Documentation/file.README.html for instructions on creating a new Hydra Head
|
19
|
+
|
20
|
+
h3. Starting the App out of the Box
|
21
|
+
|
22
|
+
h4. (1) Migrate the development databases.
|
23
|
+
|
24
|
+
From the rails application root directory:
|
25
|
+
|
26
|
+
<pre>
|
27
|
+
rake db:migrate
|
28
|
+
</pre>
|
29
|
+
|
30
|
+
h4. (2) Start Jetty, pre-configured with Fedora and Solr
|
31
|
+
|
32
|
+
_Stop any copies of jetty (or anything else using port 8983) before running this command._
|
33
|
+
(Note that java 1.6 must be invoked by the "java" command or Fedora won't work.)
|
34
|
+
|
35
|
+
<pre>
|
36
|
+
rake hydra:jetty:config
|
37
|
+
rake hydra:jetty:start
|
38
|
+
</pre>
|
39
|
+
|
40
|
+
This will start up a pre-configured jetty instance running Fedora and Solr on port 8983.
|
41
|
+
|
42
|
+
Ensure Solr is running: "http://localhost:8983/solr/development/admin":http://localhost:8983/solr/development/admin should show the Solr admin page. You should be able to click on the Statistics link (or go to "http://localhost:8983/solr/development/admin/stats.jsp":http://localhost:8983/solr/development/admin/stats.jsp) and there should be more than 0 documents in the index if you loaded the features properly. Or look for documents in "http://localhost:8983/solr/development/select?q={!defType=dismax}*:*"http://localhost:8983/solr/development/select?q={!defType=dismax}*:*
|
43
|
+
|
44
|
+
Ensure Fedora is running: "http://127.0.0.1:8983/fedora/describe":http://127.0.0.1:8983/fedora/describe should show the Fedora Repository Information View. The following query should return objects: "http://localhost:8983/fedora/objects?pid=true&title=true&terms=&query=&maxResults=20":http://localhost:8983/fedora/objects?pid=true&title=true&terms=&query=&maxResults=20
|
45
|
+
|
46
|
+
h4. (2.5) Import some Sample Content (other than fixtures??)
|
47
|
+
|
48
|
+
h4. (3) Start the Rails Application
|
49
|
+
|
50
|
+
<pre>
|
51
|
+
rails server
|
52
|
+
</pre>
|
53
|
+
|
54
|
+
To ensure the rails app is running, go to "http://localhost:3000/":http://localhost:3000/
|
55
|
+
|
56
|
+
h3. Ensure your Hydra App is set up properly
|
57
|
+
|
58
|
+
Run cucumber tests ... except they are for test, not development environment ...
|
59
|
+
|
60
|
+
h4. Import the Fixture/Test Objects
|
61
|
+
|
62
|
+
Grab the test/fixture objects that the hydra-head gem's tests rely on. These objects are useful for getting a sense of how hydra works, but you will want to delete them later and create your own
|
63
|
+
fixtures to run your application's tests against.
|
64
|
+
|
65
|
+
First, use the hydra:hyhead_fixtures generator to put the fixture xml files into test_support/fixtures
|
66
|
+
|
67
|
+
<pre>
|
68
|
+
rails g hydra:hyhead_fixtures
|
69
|
+
</pre>
|
70
|
+
|
71
|
+
Now use the hydra:fixtures:refresh rake task to import the fixtures into Fedora and Solr
|
72
|
+
|
73
|
+
<pre>
|
74
|
+
rake hydra:fixtures:refresh RAILS_ENV=test
|
75
|
+
</pre>
|
76
|
+
|
77
|
+
If you want to see the fixture objects in your development environment, run the rake task again without RAILS_ENV set.
|
78
|
+
|
79
|
+
<pre>
|
80
|
+
rake hydra:fixtures:refresh
|
81
|
+
</pre>
|
82
|
+
|
83
|
+
h4. Run the Hydra-Head gem's RSpec Tests
|
84
|
+
|
85
|
+
<pre>
|
86
|
+
rake hyhead:spec
|
87
|
+
</pre>
|
88
|
+
|
89
|
+
This will print out a lot of information while the tests run. If all the tests passed, you will see something like this (the important part is "0 failures"):
|
90
|
+
|
91
|
+
<pre>
|
92
|
+
...
|
93
|
+
Finished in 22.53 seconds
|
94
|
+
240 examples, 0 failures, 19 pending
|
95
|
+
</pre>
|
96
|
+
|
97
|
+
h4. Run the Hydra-Head gem's Cucumber Tests
|
98
|
+
|
99
|
+
Before running the cucumber tests, you have to remove the default index.html file that Rails provides
|
100
|
+
|
101
|
+
<pre>
|
102
|
+
rm public/index.html
|
103
|
+
</pre>
|
104
|
+
|
105
|
+
Now run the cucumber tests
|
106
|
+
|
107
|
+
<pre>
|
108
|
+
rake hyhead:cucumber
|
109
|
+
</pre>
|
110
|
+
|
111
|
+
This will print out a lot of information while the tests run. If all the tests passed, you will see something like this (the important part is that the number of scenarios equals the number of tests passed):
|
112
|
+
|
113
|
+
<pre>
|
114
|
+
37 scenarios (37 passed)
|
115
|
+
215 steps (215 passed)
|
116
|
+
0m45.591s
|
117
|
+
</pre>
|
118
|
+
|
119
|
+
h3. Exploring what comes out of the box
|
120
|
+
|
121
|
+
* log in, create sample account
|
122
|
+
* use facets
|
123
|
+
* run a search
|
124
|
+
* look at one of the sample objects
|
125
|
+
* edit one of the sample objects
|
126
|
+
* create a new MODS article …
|
127
|
+
* upload a file …
|
128
|
+
* change the permissions on the new article, making it visible to the public (before setting permissions, prove that you can’t see it when logged out, then change permissions, log out again & prove that it’s visible)
|
129
|
+
|
130
|
+
|
131
|
+
h2. Making local changes to your Hydra Application
|
132
|
+
|
133
|
+
In order to make it easy to get any new functionality added to the hydra stack (see "README":http://hudson.projecthydra.org/job/hydra-head-rails3-plugin/Documentation/file.README.html), while retaining your Hydra application's localizations, your local hydra application code should be set up to override the upstream Hydra stack code.
|
134
|
+
|
135
|
+
Luckily, rails engines has made this easy - the Hydra code is organized so your localizations are kept separate from the core hydra application code.
|
136
|
+
|
137
|
+
Moreover, to ensure your localizations won't be broken by upgrading the Hydra core code, we STRONGLY recommend that you write tests for every local change you make. This will allow you to ensure that upgrading the core code doesn't break any local changes you have made.
|
138
|
+
|
139
|
+
So, two key points:
|
140
|
+
|
141
|
+
<b>
|
142
|
+
# always write tests for your local modifications
|
143
|
+
# always change code at the app level, and never change anything in vendor/plugins.
|
144
|
+
</b>
|
145
|
+
|
146
|
+
"INITIAL_APP_MODS":http://hudson.projecthydra.org/job/hydra-head-rails3-plugin/Documentation/file.INITIAL_APP_MODS.html explains how to make two basic changes to your hydra rails application and how to write the appropriate tests for them.
|
147
|
+
|
148
|
+
|
149
|
+
h2. The new Content Type: JournalArticle
|
150
|
+
|
151
|
+
In this tutorial, we are creating a new JournalArticle content type. This will allow us to create Journal Articles in a Fedora Repository, collect custom metadata for them, index them in solr, and display that custom metadata in the user interface.
|
152
|
+
|
153
|
+
In order to describe our Fedora objects, we can use whatever metadata schemas suit our needs. Some metadata schemas currently being used in Hydra Heads include MODS, Dublin Core, EAD, PBcore, EAC-CPF and VRE. This list continues to grow as people set up Hydra Heads to deal with their own specialized content.
|
154
|
+
|
155
|
+
The JournalArticle content type will use MODS (handily available in hydra-head) to track descriptive metadata about Articles. Some of the metadata is common to many types of content:
|
156
|
+
|
157
|
+
* title
|
158
|
+
* author (first name, last name, role)
|
159
|
+
* abstract
|
160
|
+
|
161
|
+
Other metadata fields are more specifically relevant to journal articles, but they still fit into the MODS schema:
|
162
|
+
|
163
|
+
* journal title
|
164
|
+
* publication date
|
165
|
+
* journal volume
|
166
|
+
* journal issue
|
167
|
+
* start page
|
168
|
+
* end page
|
169
|
+
|
170
|
+
In addition to the MODS metadata, JournalArticle objects will use Hydra Rights Metadata to track information about licenses, rights, and which people/groups should be able to discover, view, and/or edit each Journal Article.
|
171
|
+
|
172
|
+
h2. Define the ActiveFedora Model for JournalArticles
|
173
|
+
|
174
|
+
The first thing to do when adding a new content type is to create the ActiveFedora Model. This model is a Ruby class that uses ActiveFedora to tell the application the structure of your content and its metadata.
|
175
|
+
|
176
|
+
The model we create can be used in any application with ActiveFedora and OM (Opinionated Metadata), not just in a Hydra Head. For example, ActiveFedora models can be used in batch scripts, command line utilities, and robots that perform automated actions on your fedora objects based on information and behaviors stored in their ActiveFedora models.
|
177
|
+
|
178
|
+
h4. Where to find the full tutorial on defining ActiveFedora Models
|
179
|
+
|
180
|
+
This tutorial will only cover the very basics of defining an ActiveFedora Model and defining OM terminologies for its XML datastreams. For a complete introduction to those topics, see the "ActiveFedora Console Tour":http://hudson.projecthydra.org/job/active_fedora/Documentation/file.CONSOLE_GETTING_STARTED.html and the tutorials included in the "OM documentation":http://hudson.projecthydra.org/job/om/Documentation/.
|
181
|
+
|
182
|
+
h3. Tests to Define Expected Behaviors
|
183
|
+
|
184
|
+
(<b>MUST HAVE EXAMPLES HERE PERTINENT TO EXPECTED JOURNAL ARTICLE BEHAVIORS</b>)
|
185
|
+
|
186
|
+
h4. Run the tests
|
187
|
+
|
188
|
+
The test code should execute but the tests should fail because we haven't written the code yet.
|
189
|
+
|
190
|
+
h3. Defining the Datastreams
|
191
|
+
|
192
|
+
A Fedora object is made up of any number of _datastreams_. Datastreams can have content of any type and each datastream is identified by a _datastream id_ or _dsid_. The ActiveFedora model tells us which datastreams to expect or create in an object and tells us what kind of content is expected inside each datastream.
|
193
|
+
|
194
|
+
For our JournalArticle model, we're particularly interested datastreams with XML content because a JournalArticle object is basically a container for XML metadata. The actual content of the Article (PDF,text,whatever.) will be stored in a separate Fedora object, a _primitive_, with the RDF isPartOf relationship connecting the JournalArticle (primarily metadata) to its content (any number of primitives with files in them). For more information about datastreams, primitives, and where the actual content of an object lives, see the Reference links at the end of this tutorial.
|
195
|
+
|
196
|
+
h3. descMetadata -- the Descriptive Metadata Datastream
|
197
|
+
|
198
|
+
Our MODS xml will go into a datastream with the datastream id of _descMetadata_. Technically, we could give it any name we want but the Hydra community has come up with some conventions to make things simpler. One of these conventions is to always put descriptive metadata in a datastream called descMetadata.
|
199
|
+
|
200
|
+
As we said above, we want to create MODS metadata that keeps track of title, author (first name/last name/role), publication date, abstract, journal title, journal volume, journal issue, start page and end page. In order to do this we will use ActiveFedora to define a special type of Ruby object that uses OM to read and modify XML.
|
201
|
+
|
202
|
+
Example of the MODS XML we will be creating:
|
203
|
+
|
204
|
+
<pre>
|
205
|
+
<mods xmlns="http://www.loc.gov/mods/v3" version="3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3
|
206
|
+
http://www.loc.gov/standards/mods/v3/mods-3-0.xsd">
|
207
|
+
<titleInfo>
|
208
|
+
<title>ARTICLE TITLE</title> <!-- title -->
|
209
|
+
</titleInfo>
|
210
|
+
<name type="personal">
|
211
|
+
<namePart type="family">FAMILY NAME</namePart> <!-- author last name -->
|
212
|
+
<namePart type="given">GIVEN NAMES</namePart> <!-- author first name -->
|
213
|
+
<role>
|
214
|
+
<roleTerm authority="marcrelator" type="text">Creator</roleTerm> <!-- author role -->
|
215
|
+
</role>
|
216
|
+
</name>
|
217
|
+
<abstract>ABSTRACT</abstract> <!-- abstract -->
|
218
|
+
<relatedItem type="host">
|
219
|
+
<titleInfo>
|
220
|
+
<title>TITLE OF HOST JOURNAL</title> <!-- journal title -->
|
221
|
+
</titleInfo>
|
222
|
+
<part>
|
223
|
+
<detail type="volume">
|
224
|
+
<number>2</number> <!-- journal volume -->
|
225
|
+
</detail>
|
226
|
+
<detail type="level">
|
227
|
+
<number>2</number> <!-- journal issue -->
|
228
|
+
</detail>
|
229
|
+
<extent unit="pages">
|
230
|
+
<start>195</start> <!-- start page -->
|
231
|
+
<end>230</end> <!-- end page -->
|
232
|
+
</extent>
|
233
|
+
<date>FEB. 2007</date> <!-- publication date -->
|
234
|
+
</part>
|
235
|
+
</relatedItem>
|
236
|
+
</mods>
|
237
|
+
</pre>
|
238
|
+
|
239
|
+
The constraints of a metadata schema sometimes force us to put information into structures that don't map directly to the vocabulary that we use when talking about that information. The "title" has ended up in a spot that you might call the "mods titleInfo title" and the "start page" has ended up in a spot that you might call the <pre>"mods host-relatedItem part pages-extent start"</pre> or <pre>"//mods/relatedItem[@type=host]/part/extent[@unit='pages']/start"</pre> ... quite the mouthful, isn't it? This is where OM comes in. OM lets us define a Terminology that will allow us to access values in the xml based on our natural vocabulary (title, start page, etc.) while also allowing us to access those same values using the more cumbersome XML-speak when necessary.
|
240
|
+
|
241
|
+
h4. WRITE TESTS HERE! (for the expected behaviors of a descMetadata datastream model?)
|
242
|
+
|
243
|
+
specs to test model? features?
|
244
|
+
|
245
|
+
h4. Coding the descMetadata Datastream model
|
246
|
+
|
247
|
+
Here's how we define the datastream class for the descMetadata. Notice that we use set_terminology which defines its OM Terminology.
|
248
|
+
|
249
|
+
<b><i>Create a new file in app/models called journal_article_mods_datastream.rb</i></b> and put this into it (NOTE: you could also save this file as lib/journal_article_mods_datastream.rb and get the same results):
|
250
|
+
|
251
|
+
<pre>
|
252
|
+
# a Fedora Datastream object containing Mods XML for the descMetadata
|
253
|
+
# datastream in the Journal Article hydra content type, defined using
|
254
|
+
# ActiveFedora and OM.
|
255
|
+
|
256
|
+
class JournalArticleModsDatastream < ActiveFedora::NokogiriDatastream
|
257
|
+
|
258
|
+
# OM (Opinionated Metadata) terminology mapping for the mods xml
|
259
|
+
set_terminology do |t|
|
260
|
+
t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
|
261
|
+
t.title_info(:path=>"titleInfo") {
|
262
|
+
t.main_title(:index_as=>[:facetable],:path=>"title", :label=>"title")
|
263
|
+
}
|
264
|
+
t.author {
|
265
|
+
t.first_name(:path=>"namePart", :attributes=>{:type=>"given"})
|
266
|
+
t.last_name(:path=>"namePart", :attributes=>{:type=>"family"})
|
267
|
+
t.role {
|
268
|
+
t.text(:path=>"roleTerm",:attributes=>{:type=>"text"})
|
269
|
+
}
|
270
|
+
}
|
271
|
+
t.abstract
|
272
|
+
t.journal(:path=>'relatedItem', :attributes=>{:type=>"host"}) {
|
273
|
+
t.title_info(:ref=>[:title_info])
|
274
|
+
t.issue(:path=>"part") {
|
275
|
+
t.volume(:path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
|
276
|
+
t.level(:path=>"detail", :attributes=>{:type=>"number"}, :default_content_path=>"number")
|
277
|
+
t.pages(:path=>"extent", :attributes=>{:unit=>"pages"}) {
|
278
|
+
t.start
|
279
|
+
t.end
|
280
|
+
}
|
281
|
+
t.date
|
282
|
+
}
|
283
|
+
}
|
284
|
+
|
285
|
+
# these proxy declarations allow you to use more familiar term/field names that hide the details of the XML structure
|
286
|
+
t.title(:proxy=>[:title_info, :main_title])
|
287
|
+
t.start_page(:proxy=>[:journal, :issue, :pages, :start])
|
288
|
+
t.end_page(:proxy=>[:journal, :issue, :pages, :end])
|
289
|
+
t.publication_date(:proxy=>[:journal, :issue, :date])
|
290
|
+
|
291
|
+
end # set_terminology
|
292
|
+
|
293
|
+
end # class
|
294
|
+
</pre>
|
295
|
+
|
296
|
+
This will allow you to access the metadata values like this when dealing with a JournalArticleModsDatastream object:
|
297
|
+
|
298
|
+
<pre>
|
299
|
+
ds.term_values(:author, :first_name)
|
300
|
+
ds.term_values(:start_page)
|
301
|
+
ds.term_values(:journal, :issue, :pages, :start) # same result as the previous line, but more detailed reference to the xml node
|
302
|
+
</pre>
|
303
|
+
|
304
|
+
<b>(CAN WE DO TESTING NOW? OR DO WE NEED TO DEAL WITH THE ENTIRE FEDORA OBJECT BEFORE TESTING?)</b>
|
305
|
+
|
306
|
+
h3. rightsMetadata -- The Hydra Rights Metadata Datastream
|
307
|
+
|
308
|
+
The hydra-head plugin provides a class definition for the rightsMetadata datastream, so you won't have to define the OM Terminology yourself. The definition is in the hydra-head plugin code in "lib/hydra/rights_metadata.rb":https://github.com/projecthydra/hydra-head/blob/master/lib/hydra/rights_metadata.rb.
|
309
|
+
|
310
|
+
Here's an example of what rightsMetadata XML looks like:
|
311
|
+
|
312
|
+
<pre>
|
313
|
+
<rightsMetadata xmlns="http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1">
|
314
|
+
<copyright>
|
315
|
+
<human>(c)2009 The Hydra Project</human>
|
316
|
+
<human type="someSpecialisedType">Blah Blah</human>
|
317
|
+
<human type="aDifferentType">More blah</human>
|
318
|
+
<machine><a rel="license" href="http://creativecommons.org/licenses/publicdomain/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/publicdomain/88x31.png" /></a><br />This work is in the <a rel="license" href="http://creativecommons.org/licenses/publicdomain/">Public Domain</a>.</machine>
|
319
|
+
</copyright>
|
320
|
+
<access type="discover">
|
321
|
+
<human></human>
|
322
|
+
<machine>
|
323
|
+
<policy>hydra-policy:4502</policy>
|
324
|
+
<group>public</group>
|
325
|
+
</machine>
|
326
|
+
</access>
|
327
|
+
<access type="read">
|
328
|
+
<human></human>
|
329
|
+
<machine>
|
330
|
+
<group>public</group>
|
331
|
+
</machine>
|
332
|
+
</access>
|
333
|
+
<access type="edit">
|
334
|
+
<human></human>
|
335
|
+
<machine>
|
336
|
+
<person>researcher1</person>
|
337
|
+
<group>archivist</group>
|
338
|
+
</machine>
|
339
|
+
</access>
|
340
|
+
<access type="etc">
|
341
|
+
<!-- etc -->
|
342
|
+
</access>
|
343
|
+
<use>
|
344
|
+
<human>You are free to re-distribute this object, but you cannot change it or sell it. </human>
|
345
|
+
<machine><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/us/88x31.png" /></a><br />This <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Sound" rel="dc:type">work</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/">Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License</a>.</machine>
|
346
|
+
</use>
|
347
|
+
|
348
|
+
</rightsMetadata>
|
349
|
+
</pre>
|
350
|
+
|
351
|
+
h3. RELS-EXT & DC Datastreams (Fedora defaults)
|
352
|
+
|
353
|
+
There are two special datastreams that Fedora creates for you -- the DC datastream and the RELS-EXT datastream. We don't really use the DC datastream. It contains simple Dublin Core metadata that mainly exists for Fedora's internal use. The RELS-EXT datastream contains RDF representing the relationships between the objects in a Fedora repository. ActiveFedora and Hydra both use these RDF relationships in a number of ways. For more information about how to work with RDF relationships in ActiveFedora, see the ActiveFedora documentation links at the end of this tutorial.
|
354
|
+
|
355
|
+
h2. Defining the Model and adding the Datastreams to it
|
356
|
+
|
357
|
+
<b><i>Create a file in app/models called journal_article.rb</i></b> and put these lines into it:
|
358
|
+
|
359
|
+
<pre>
|
360
|
+
# a Fedora object for the Journal Article hydra content type
|
361
|
+
class JournalArticle < ActiveFedora::Base
|
362
|
+
include Hydra::ModelMethods
|
363
|
+
|
364
|
+
has_metadata :name => "descMetadata", :type=> JournalArticleModsDatastream
|
365
|
+
has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
|
366
|
+
end
|
367
|
+
</pre>
|
368
|
+
|
369
|
+
<b>(CAN WE DO TESTING NOW?)</b>
|
370
|
+
|
371
|
+
|
372
|
+
h2. Test Your Work
|
373
|
+
|
374
|
+
<b>THE TESTS WE WROTE ABOVE SHOULD PASS NOW ...</b>
|
375
|
+
|
376
|
+
(specs? if features ... jetty must be running?)
|
377
|
+
|
378
|
+
h2. Loading your new Model in the Rails App
|
379
|
+
|
380
|
+
If you have put the new files you've created into app/models and/or the lib directory, then they will be automatically loaded by the application when you run it using script/server or script/console.
|
381
|
+
|
382
|
+
h2. Creating new JournalArticle Objects
|
383
|
+
|
384
|
+
Start up Fedora and Solr on port 8983, assuming they are not already running:
|
385
|
+
|
386
|
+
<pre>rake hydra:jetty:start</pre>
|
387
|
+
|
388
|
+
Create a JournalArticle object using the console (rather than from the UI of the rails app)
|
389
|
+
|
390
|
+
<pre>script/console</pre>
|
391
|
+
|
392
|
+
Type these lines at the console command line:
|
393
|
+
|
394
|
+
<pre>
|
395
|
+
article = JournalArticle.new
|
396
|
+
article.save
|
397
|
+
# In case you're curious, explore a bit...
|
398
|
+
article.pid
|
399
|
+
article.datastreams.keys
|
400
|
+
article.datastreams["descMetadata"].class
|
401
|
+
article.datastreams["rightsMetadata"].class
|
402
|
+
article.relationships
|
403
|
+
</pre>
|
404
|
+
|
405
|
+
h2. Getting metadata into JournalArticle Objects
|
406
|
+
|
407
|
+
h2. Index JournalArticles into Solr
|
408
|
+
|
409
|
+
By default, ActiveFedora automatically updates Solr whenever you save an object to Fedora. If you want to re-index it, all you have to do is load an instance of the object and call its update_index method. For example, if you wanted to update an object that has a pid "changeme:30", you could do it like this:
|
410
|
+
|
411
|
+
<pre>
|
412
|
+
article = JournalArticle.load_instance("changeme:30")
|
413
|
+
article.update_index
|
414
|
+
</pre>
|
415
|
+
|
416
|
+
In reality, when you want to re-index an object in Solr, you should use Solrizer. Solrizer is specifically designed to help you keep your solr indexes up to date.
|
417
|
+
|
418
|
+
"Solrizer Documentation":http://hudson.projecthydra.org/job/solrizer/Documentation/
|
419
|
+
|
420
|
+
"Solrizer on GitHub":https://github.com/projecthydra/solrizer
|
421
|
+
|
422
|
+
Solrizer is able to figure out how to index XML based on the OM Terminologies you've defined. It defaults to indexing nearly everything in generic ways, but there are many ways to customize this behavior. See the "Solrizer Documentation":http://hudson.projecthydra.org/job/solrizer/Documentation/ for more information about how it works.
|
423
|
+
|
424
|
+
h2. Basic Access Controls
|
425
|
+
|
426
|
+
The access controls in the hydra-head plugin work on the assumption that you will put your access controls information into a datastream called rightsMetadata and then index the values from that datastream into Solr. The plugin provides all the tools that you need in order to do this. Most of the work is handled for you by this line in your model:
|
427
|
+
|
428
|
+
<pre>
|
429
|
+
has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
|
430
|
+
</pre>
|
431
|
+
|
432
|
+
The plugin defaults to *denying access* when the permissions are unclear. This means that in cases where there is no rightsMetadata datastream or the information in the datastream is unclear or incomplete, the Hydra head will act like the object does not exist. _The object will not show up in search results and you will not be able to view it._
|
433
|
+
|
434
|
+
To give yourself permission to view and edit an object, you need to set those permissions. For example, if we want the object to show up in search results for everyone but we only want a user called archivist1 to edit it, we can do the following:
|
435
|
+
|
436
|
+
<pre>
|
437
|
+
article = JournalArticle.load_instance("changeme:30")
|
438
|
+
article.permissions({"group"=>"public"}, "read")
|
439
|
+
article.permissions({"person"=>"archivist1"}, "edit")
|
440
|
+
article.save
|
441
|
+
</pre>
|
442
|
+
|
443
|
+
hydra-head provides you with tools to expose a permissions editor to your end-users. This allows them to control who can discover/read/download/edit the objects they create.
|
444
|
+
|
445
|
+
h2. Logging into the Hydra Head and creating a User Account
|
446
|
+
|
447
|
+
Blacklight & the hydra-head plugin provide a basic user authentication that is meant to be replaced by code that connects to your institutional authentication system like LDAP or Shibboleth. While setting up this sample hydra-head, you need to create user accounts in that system. To do this, run the application, visit http://localhost:3000 and click on "login" then click on "create an account" below the login form.
|
448
|
+
|
449
|
+
In thes sample above, we gave "edit" permissions to a user called "archivist1", so create an account with that login id. Choose whatever email & password you want. Now you can log in as that user when you want to test features that require you to be logged into the hydra head.
|
450
|
+
|
451
|
+
h2. Defining Custom Views
|
452
|
+
|
453
|
+
Now that you've created a couple objects and indexed them, you can view them in the application. Remember, _objects will not show up in search results unless the permissions are set properly in rightsMetadata_.
|
454
|
+
|
455
|
+
h3. Add a link to create an Article
|
456
|
+
|
457
|
+
First, we need to add a link to the Hydra Head that lets you create Journal Articles. To do this, you need to override the _add_asset_links view partial. Here's the cucumber test for what you want:
|
458
|
+
|
459
|
+
<pre>
|
460
|
+
Feature: Button to Add Articles
|
461
|
+
In order to create Journal Articles
|
462
|
+
As a person with submit permissions
|
463
|
+
I want to see a button for adding articles
|
464
|
+
|
465
|
+
Scenario: button to add articles on home page
|
466
|
+
Given I am logged in as "archivist1"
|
467
|
+
When I am on the home page
|
468
|
+
Then I should not see "Add a MODS Asset"
|
469
|
+
And I should see "Add an Article"
|
470
|
+
</pre>
|
471
|
+
|
472
|
+
hydra-head puts a list of "add asset" links into the user_util_links section of the page. This list is defined in app/views/_add_asset_links.html.erb. By default, this list includes links for adding Images, MODS Assets and Generic Content. We want it to have just one link -- create an Article. To override the list, create a file at app/views/_add_asset_links.html.erb and put this into it:
|
473
|
+
|
474
|
+
<pre>
|
475
|
+
<div id="select-item-box">
|
476
|
+
<ul id="select-item-list">
|
477
|
+
<li>
|
478
|
+
<%= link_to_create_asset 'Add an Article', 'journal_article' %>
|
479
|
+
</li>
|
480
|
+
</ul>
|
481
|
+
</div>
|
482
|
+
</pre>
|
483
|
+
|
484
|
+
Now start your application and visit http://localhost:3000
|
485
|
+
|
486
|
+
h3. Default Views
|
487
|
+
|
488
|
+
|
489
|
+
JournalArticles will show up with the default views until you create custom views for that content type
|
490
|
+
|
491
|
+
search results, facets
|
492
|
+
detail & edit views
|
493
|
+
|
494
|
+
h3. Customize how JournalArticles appear in search results
|
495
|
+
|
496
|
+
h3. Change the Search Result Headings
|
497
|
+
|
498
|
+
h3. Define JournalArticles “show” view
|
499
|
+
|
500
|
+
|
501
|
+
h3. Define JournalArticles “edit” view
|
502
|
+
|
503
|
+
|
504
|
+
displaying MODS edit
|
505
|
+
rednering permissions_edit views
|
506
|
+
rendering file uploader
|
507
|
+
|
508
|
+
h3. The File List
|
509
|
+
|
510
|
+
|
511
|
+
-- show & edit
|
512
|
+
|
513
|
+
h2. Access Controls (Example)
|
514
|
+
|
515
|
+
|
516
|
+
Create an object, edit permissions, see that permissions have changed.
|
517
|
+
|
518
|
+
h2. Miscellaneous
|
519
|
+
|
520
|
+
|
521
|
+
* Adding a Facet
|
522
|
+
* Link to info on overriding styling
|
523
|
+
* Overriding Helpers
|
524
|
+
|
525
|
+
|
526
|
+
h2. Reference
|
527
|
+
|
528
|
+
|
529
|
+
h3. Documentation & More Tutorials
|
530
|
+
|
531
|
+
h4. API Docs
|
532
|
+
|
533
|
+
ActiveFedora API Docs
|
534
|
+
OM API Docs
|
535
|
+
|
536
|
+
h4. Tutorials
|
537
|
+
|
538
|
+
"ActiveFedora Console Tour":http://hudson.projecthydra.org/job/active_fedora/Documentation/file.CONSOLE_GETTING_STARTED.html
|
539
|
+
"OM-based NokogiriDatastreams":http://hudson.projecthydra.org/job/active_fedora/Documentation/file.NOKOGIRI_DATASTREAMS.html
|
540
|
+
"OM Documentation":http://hudson.projecthydra.org/job/om/Documentation/
|
541
|
+
|
542
|
+
h3. Hydra Modeling Conventions
|
543
|
+
|
544
|
+
|
545
|
+
h4. Reference info on the Hydra Wiki
|
546
|
+
|
547
|
+
|
548
|
+
"Hydra objects, content models(cModels) and disseminators":https://wiki.duraspace.org/display/hydra/Hydra+objects%2C+content+models+%28cModels%29+and+disseminators
|
549
|
+
|
550
|
+
"Don’t Call it a Content Model":https://wiki.duraspace.org/display/hydra/Don%27t+call+it+a+%27content+model%27%21
|
551
|
+
|
552
|
+
h4. genericContent cModel
|
553
|
+
|
554
|
+
* descMetadata (required): Descriptive Metadata like MODS or DC. MODS is recommended
|
555
|
+
* rightsMetadata (recommended): Rights, License, and Permissions information. Hydra rightsMetadata XML is recommended.
|
556
|
+
h4. Understanding Parts (Where will my uploaded files go?)
|
557
|
+
|
558
|
+
h5. Primitives contain actual files
|
559
|
+
|
560
|
+
bq. A primitive is a fundamental atom object that bears an actual file payload. They are single, (near-) universal content types which may either stand-alone or be incorporated into higher order content types (in a book or ETD, e.g.).
|
561
|
+
|
562
|
+
h5. Higher Level Objects
|
563
|
+
|
564
|
+
bq. Higher Level Objects represent higher-level, molecular objects that may have primitives and/or other Higher-level objects as children.
|
565
|
+
|
566
|
+
h5. Relationships
|
567
|
+
|
568
|
+
"isPartOf":info:fedora/fedora-system:def/relations-external#isPartOf -- Hydra reserves this predicate for use in representing part-whole relationships between objects. This occurs most often when representing which Primitives (ie. an uploaded PDF) are _part_ of a Higher Level object (ie. a MODS Article)
|
569
|
+
|
570
|
+
|
571
|
+
h3. How to Add a New Facet
|