hydra-works 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +17 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +14 -0
  6. data/CONTRIBUTING.md +115 -0
  7. data/Gemfile +14 -0
  8. data/LICENSE +16 -0
  9. data/README.md +80 -0
  10. data/Rakefile +23 -0
  11. data/hydra-works.gemspec +33 -0
  12. data/lib/hydra/works.rb +81 -0
  13. data/lib/hydra/works/models/collection.rb +5 -0
  14. data/lib/hydra/works/models/concerns/aggregates_collections.rb +16 -0
  15. data/lib/hydra/works/models/concerns/aggregates_generic_files.rb +20 -0
  16. data/lib/hydra/works/models/concerns/aggregates_generic_works.rb +20 -0
  17. data/lib/hydra/works/models/concerns/collection_behavior.rb +28 -0
  18. data/lib/hydra/works/models/concerns/generic_file/contained_files.rb +22 -0
  19. data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +32 -0
  20. data/lib/hydra/works/models/concerns/generic_file/mime_types.rb +69 -0
  21. data/lib/hydra/works/models/concerns/generic_file_behavior.rb +25 -0
  22. data/lib/hydra/works/models/concerns/generic_work_behavior.rb +30 -0
  23. data/lib/hydra/works/models/generic_file.rb +17 -0
  24. data/lib/hydra/works/models/generic_work.rb +9 -0
  25. data/lib/hydra/works/processor.rb +9 -0
  26. data/lib/hydra/works/services/collection/add_collection.rb +19 -0
  27. data/lib/hydra/works/services/collection/add_generic_work.rb +19 -0
  28. data/lib/hydra/works/services/collection/add_related_object.rb +19 -0
  29. data/lib/hydra/works/services/collection/get_collections.rb +17 -0
  30. data/lib/hydra/works/services/collection/get_generic_works.rb +17 -0
  31. data/lib/hydra/works/services/collection/get_related_objects.rb +17 -0
  32. data/lib/hydra/works/services/collection/remove_collection.rb +19 -0
  33. data/lib/hydra/works/services/collection/remove_generic_work.rb +20 -0
  34. data/lib/hydra/works/services/collection/remove_related_object.rb +19 -0
  35. data/lib/hydra/works/services/generic_file/add_file.rb +55 -0
  36. data/lib/hydra/works/services/generic_file/add_generic_file.rb +19 -0
  37. data/lib/hydra/works/services/generic_file/add_original_file.rb +11 -0
  38. data/lib/hydra/works/services/generic_file/add_related_object.rb +19 -0
  39. data/lib/hydra/works/services/generic_file/add_versioned_original_file.rb +10 -0
  40. data/lib/hydra/works/services/generic_file/generate/thumbnail.rb +19 -0
  41. data/lib/hydra/works/services/generic_file/get_generic_files.rb +17 -0
  42. data/lib/hydra/works/services/generic_file/get_related_objects.rb +17 -0
  43. data/lib/hydra/works/services/generic_file/remove_generic_file.rb +20 -0
  44. data/lib/hydra/works/services/generic_file/remove_related_object.rb +19 -0
  45. data/lib/hydra/works/services/generic_file/upload_file.rb +32 -0
  46. data/lib/hydra/works/services/generic_work/add_generic_file.rb +19 -0
  47. data/lib/hydra/works/services/generic_work/add_generic_work.rb +19 -0
  48. data/lib/hydra/works/services/generic_work/add_related_object.rb +19 -0
  49. data/lib/hydra/works/services/generic_work/get_generic_files.rb +17 -0
  50. data/lib/hydra/works/services/generic_work/get_generic_works.rb +17 -0
  51. data/lib/hydra/works/services/generic_work/get_related_objects.rb +17 -0
  52. data/lib/hydra/works/services/generic_work/move_generic_file.rb +19 -0
  53. data/lib/hydra/works/services/generic_work/remove_generic_file.rb +20 -0
  54. data/lib/hydra/works/services/generic_work/remove_generic_work.rb +20 -0
  55. data/lib/hydra/works/services/generic_work/remove_related_object.rb +19 -0
  56. data/lib/hydra/works/version.rb +5 -0
  57. data/lib/hydra/works/vocab/works_terms.rb +12 -0
  58. data/spec/fixtures/sample-file.pdf +0 -0
  59. data/spec/fixtures/updated-file.txt +1 -0
  60. data/spec/hydra/works/models/collection_spec.rb +41 -0
  61. data/spec/hydra/works/models/concerns/file/contained_files_spec.rb +113 -0
  62. data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +12 -0
  63. data/spec/hydra/works/models/generic_file_spec.rb +45 -0
  64. data/spec/hydra/works/models/generic_work_spec.rb +50 -0
  65. data/spec/hydra/works/services/collection/add_collection_spec.rb +166 -0
  66. data/spec/hydra/works/services/collection/add_generic_work_spec.rb +155 -0
  67. data/spec/hydra/works/services/collection/add_related_object_spec.rb +149 -0
  68. data/spec/hydra/works/services/collection/get_collections_spec.rb +35 -0
  69. data/spec/hydra/works/services/collection/get_generic_works_spec.rb +35 -0
  70. data/spec/hydra/works/services/collection/get_related_objects_spec.rb +49 -0
  71. data/spec/hydra/works/services/collection/remove_collection_spec.rb +133 -0
  72. data/spec/hydra/works/services/collection/remove_generic_work_spec.rb +133 -0
  73. data/spec/hydra/works/services/collection/remove_related_object_spec.rb +128 -0
  74. data/spec/hydra/works/services/generic_file/add_file_spec.rb +28 -0
  75. data/spec/hydra/works/services/generic_file/add_generic_file_spec.rb +174 -0
  76. data/spec/hydra/works/services/generic_file/add_related_object_spec.rb +150 -0
  77. data/spec/hydra/works/services/generic_file/generate/thumbnail_spec.rb +21 -0
  78. data/spec/hydra/works/services/generic_file/get_generic_files_spec.rb +19 -0
  79. data/spec/hydra/works/services/generic_file/get_related_objects_spec.rb +45 -0
  80. data/spec/hydra/works/services/generic_file/remove_generic_file_spec.rb +124 -0
  81. data/spec/hydra/works/services/generic_file/remove_related_object_spec.rb +123 -0
  82. data/spec/hydra/works/services/generic_file/upload_file_spec.rb +82 -0
  83. data/spec/hydra/works/services/generic_work/add_generic_file_spec.rb +156 -0
  84. data/spec/hydra/works/services/generic_work/add_generic_work_spec.rb +157 -0
  85. data/spec/hydra/works/services/generic_work/add_related_object_spec.rb +148 -0
  86. data/spec/hydra/works/services/generic_work/get_generic_files_spec.rb +35 -0
  87. data/spec/hydra/works/services/generic_work/get_generic_works_spec.rb +35 -0
  88. data/spec/hydra/works/services/generic_work/get_related_objects_spec.rb +46 -0
  89. data/spec/hydra/works/services/generic_work/move_generic_file_spec.rb +21 -0
  90. data/spec/hydra/works/services/generic_work/remove_generic_file_spec.rb +132 -0
  91. data/spec/hydra/works/services/generic_work/remove_generic_work_spec.rb +133 -0
  92. data/spec/hydra/works/services/generic_work/remove_related_object_spec.rb +128 -0
  93. data/spec/hydra/works_spec.rb +149 -0
  94. data/spec/spec_helper.rb +40 -0
  95. data/use-cases/conference_event_use_case.md +16 -0
  96. data/use-cases/lafayette_college_geospatial_use_case.md +80 -0
  97. data/use-cases/northwestern_adminset_use-case.md +19 -0
  98. data/use-cases/northwestern_displayset_use_case.md +23 -0
  99. data/use-cases/northwestern_playlist_use_case.md +21 -0
  100. data/use-cases/princeton_book_use_case.md +117 -0
  101. data/use-cases/scholarsphere_use_case.md +32 -0
  102. data/use-cases/stanford_data_model_use_case.md +86 -0
  103. data/use-cases/ucin_linked_resource_use_case.md +21 -0
  104. metadata +338 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d6c159583f12e0a02124bcf92dce3d86fc33736a
4
+ data.tar.gz: 182817aa5b0783ec5f25ff9491c31c1cb69816f1
5
+ SHA512:
6
+ metadata.gz: f644d698b6e0d8a4260b4b42b45abf73ac69b8bdd85b837570edde1ff2d4e00c9520c0e9f3fc2b631b465a74f1643aeca55224ddf444cf74d3dce77de78e10d8
7
+ data.tar.gz: 1db7afa2cfdc7635f96f86f2d64664cfac6123ec0dd73714bb6540783af845ecf4ed9484a0fff632d3afa9bb75151e8fc4a6885ddfa4f34cff89ef0ac19ca964
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ spec/internal
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ jetty
17
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ bundler_args: --without debug
5
+ env:
6
+ global:
7
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
8
+ rvm:
9
+ - 2.1
10
+ - 2.2
11
+ - jruby-19mode
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: jruby-19mode
@@ -0,0 +1,115 @@
1
+ # How to Contribute
2
+
3
+ We want your help to make Project Hydra great.
4
+ There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
5
+
6
+ ## Hydra Project Intellectual Property Licensing and Ownership
7
+
8
+ All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
9
+ If the contributor works for an institution, the institution must have a Corporate Contributor License Agreement (cCLA) on file.
10
+
11
+ https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership
12
+
13
+ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
14
+
15
+ ## Contribution Tasks
16
+
17
+ * Reporting Issues
18
+ * Making Changes
19
+ * Submitting Changes
20
+ * Merging Changes
21
+
22
+ ### Reporting Issues
23
+
24
+ * Make sure you have a [GitHub account](https://github.com/signup/free)
25
+ * Submit a [Github issue](./issues) by:
26
+ * Clearly describing the issue
27
+ * Provide a descriptive summary
28
+ * Explain the expected behavior
29
+ * Explain the actual behavior
30
+ * Provide steps to reproduce the actual behavior
31
+
32
+ ### Making Changes
33
+
34
+ * Fork the repository on GitHub
35
+ * Create a topic branch from where you want to base your work.
36
+ * This is usually the master branch.
37
+ * To quickly create a topic branch based on master; `git branch fix/master/my_contribution master`
38
+ * Then checkout the new branch with `git checkout fix/master/my_contribution`.
39
+ * Please avoid working directly on the `master` branch.
40
+ * You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
41
+ * Make commits of logical units.
42
+ * Your commit should include a high level description of your work in HISTORY.textile
43
+ * Check for unnecessary whitespace with `git diff --check` before committing.
44
+ * Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
45
+ * If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages)
46
+
47
+ ```
48
+ Present tense short summary (50 characters or less)
49
+
50
+ More detailed description, if necessary. It should be wrapped to 72
51
+ characters. Try to be as descriptive as you can, even if you think that
52
+ the commit content is obvious, it may not be obvious to others. You
53
+ should add such description also if it's already present in bug tracker,
54
+ it should not be necessary to visit a webpage to check the history.
55
+
56
+ Include Closes #<issue-number> when relavent.
57
+
58
+ Description can have multiple paragraphs and you can use code examples
59
+ inside, just indent it with 4 spaces:
60
+
61
+ class PostsController
62
+ def index
63
+ respond_with Post.limit(10)
64
+ end
65
+ end
66
+
67
+ You can also add bullet points:
68
+
69
+ - you can use dashes or asterisks
70
+
71
+ - also, try to indent next line of a point for readability, if it's too
72
+ long to fit in 72 characters
73
+ ```
74
+
75
+ * Make sure you have added the necessary tests for your changes.
76
+ * Run _all_ the tests to assure nothing else was accidentally broken.
77
+ * When you are ready to submit a pull request
78
+
79
+ ### Submitting Changes
80
+
81
+ * Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
82
+ * Make sure your branch is up to date with its parent branch (i.e. master)
83
+ * `git checkout master`
84
+ * `git pull --rebase`
85
+ * `git checkout <your-branch>`
86
+ * `git rebase master`
87
+ * It is likely a good idea to run your tests again.
88
+ * If you've made more than one commit take a moment to consider whether squashing commits together would help improve their logical grouping.
89
+ * [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
90
+ * `git rebase --interactive HEAD~<number-of-commits>` ([See Github help](https://help.github.com/articles/interactive-rebase))
91
+ * To determine the number of commits on your branch: `git log master..<your-branch> --oneline | wc -l`
92
+ * Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on.
93
+ * Push your changes to a topic branch in your fork of the repository.
94
+ * Submit a pull request from your fork to the project.
95
+
96
+ ### Merging Changes
97
+
98
+ * It is considered "poor from" to merge your own request.
99
+ * Please take the time to review the changes and get a sense of what is being changed. Things to consider:
100
+ * Does the commit message explain what is going on?
101
+ * Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
102
+ * Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
103
+ * Did the Travis tests complete successfully?
104
+ * If you are uncertain, bring other contributors into the conversation by creating a comment that includes their @username.
105
+ * If you like the pull request, but want others to chime in, create a +1 comment and tag a user.
106
+
107
+ ## New Developers
108
+ A great way to get new developers involved and to learn the process is to have them go through the Hierarchy of Promises and create a pull request to improve it.
109
+
110
+ # Additional Resources
111
+
112
+ * [General GitHub documentation](http://help.github.com/)
113
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
114
+ * [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
115
+ * [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hydra-works.gemspec
4
+ gemspec
5
+
6
+ gem 'activefedora-aggregation', github: 'projecthydra-labs/activefedora-aggregation'
7
+ gem 'active-fedora', github: 'projecthydra/active_fedora', branch: 'master'
8
+ gem 'slop', '~> 3.6' # For byebug
9
+
10
+ unless ENV['CI']
11
+ gem 'pry'
12
+ gem 'pry-byebug'
13
+ gem 'byebug'
14
+ end
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ ##########################################################################
2
+ #
3
+ # Copyright 2014 University of Notre Dame, Northwestern University, and Data Curation Experts
4
+ # Additional copyright may be held by others, as reflected in the commit log
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # 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.
@@ -0,0 +1,80 @@
1
+ # Hydra::Works
2
+ [![Build Status](https://travis-ci.org/projecthydra-labs/hydra-works.svg?branch=master)](https://travis-ci.org/projecthydra-labs/hydra-works)
3
+ [![Coverage Status](https://coveralls.io/repos/projecthydra-labs/hydra-works/badge.svg?branch=master)](https://coveralls.io/r/projecthydra-labs/hydra-works?branch=master)
4
+
5
+ The Hydra::Works gem provides a set of [Portland Common Data Model](https://wiki.duraspace.org/display/FF/Portland+Common+Data+Model)-compliant models and associated behaviors around the broad concept of multi-file "works", the need for which was expressed by a variety of [community use cases](https://github.com/projecthydra-labs/hydra-works/tree/master/use-cases). The Hydra::Works domain model includes:
6
+
7
+ * **GenericFile**: a *pcdm:Object* that encapsulates one or more directly related *pcdm:File*s, such as a PDF document, its derivatives, and extracted full-text
8
+ * **GenericWork**: a *pcdm:Object* that holds zero or more **GenericFile**s and zero or more **GenericWork**s
9
+ * **Collection**: a *pcdm:Collection* that indirectly contains zero or more **GenericWork**s and zero or more **Collection**s
10
+
11
+ View [a diagram of the domain model](https://docs.google.com/drawings/d/1-NkkRPpGpZGoTimEpYTaGM1uUPRaT0SamuWDITvtG_8/edit).
12
+
13
+ ## Installation
14
+
15
+ Add these lines to your application's Gemfile:
16
+
17
+ # hydra-pcdm requires an unreleased version of ActiveFedora
18
+ gem 'active-fedora', github: 'projecthydra/active_fedora'
19
+ gem 'hydra-pcdm', github: 'projecthydra-labs/hydra-pcdm'
20
+ gem 'hydra-works', github: 'projecthydra-labs/hydra-works'
21
+
22
+ And then execute:
23
+
24
+ $ bundle install
25
+
26
+ Or install it yourself:
27
+
28
+ $ gem install hydra-works
29
+
30
+ ## Usage
31
+
32
+ Usage involves extending the behavior provided by this gem. In your application, you can create Hydra::Works-based models like so:
33
+
34
+ ```ruby
35
+ class Collection < ActiveFedora::Base
36
+ include Hydra::Works::CollectionBehavior
37
+ end
38
+
39
+ class BookWork < ActiveFedora::Base
40
+ include Hydra::Works::GenericWorkBehavior
41
+ end
42
+
43
+ class BookFiles < ActiveFedora::Base
44
+ include Hydra::Works::GenericFileBehavior
45
+ end
46
+
47
+ c1 = Collection.create
48
+ bw1 = BookWork.create
49
+ bf1 = BookFiles.create
50
+
51
+ Hydra::Works::AddGenericWorkToCollection(c1,bw1)
52
+ Hydra::Works::AddGenericFileToGenericWork(bw1,bf1)
53
+ c1.save
54
+ bw1.save
55
+ bf1.save
56
+
57
+ f1 = bf1.files.build
58
+ f1.content = "The quick brown fox jumped over the lazy dog."
59
+ bf1.save
60
+ ```
61
+
62
+ ## Access controls
63
+
64
+ We are using [Web ACL](http://www.w3.org/wiki/WebAccessControl) as implemented by [hydra-access-controls](https://github.com/projecthydra/hydra-head/tree/master/hydra-access-controls).
65
+
66
+ ## How to contribute
67
+
68
+ If you'd like to contribute to this effort, please check out the [Contributing Guide](CONTRIBUTING.md)
69
+
70
+ ## Development
71
+
72
+ To set up for running the test suite, you need a copy of jetty
73
+
74
+ $ rake jetty:clean
75
+
76
+ To run the test suite, generate the test app (which goes into spec/internal) and start jetty (if it's not already running)
77
+
78
+ $ rails engine_cart:generate
79
+ $ rake jetty:start
80
+ $ rake spec
@@ -0,0 +1,23 @@
1
+ require "bundler/gem_tasks"
2
+ require 'jettywrapper'
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+ require 'engine_cart/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ Jettywrapper.hydra_jetty_version = "master"
9
+
10
+ desc 'Spin up hydra-jetty and run specs'
11
+ task ci: ['jetty:clean'] do
12
+ puts 'running continuous integration'
13
+ jetty_params = Jettywrapper.load_config
14
+ jetty_params[:startup_wait]= 90
15
+ error = Jettywrapper.wrap(jetty_params) do
16
+ Rake::Task['spec'].invoke
17
+ end
18
+ raise "test failures: #{error}" if error
19
+ end
20
+
21
+ task default: :ci
22
+
23
+
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hydra/works/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hydra-works"
8
+ spec.version = Hydra::Works::VERSION
9
+ spec.authors = ["Justin Coyne"]
10
+ spec.email = ["justin@curationexperts.com"]
11
+ spec.summary = %q{Fundamental repository data model for hydra}
12
+ spec.description = %q{Using this data model should enable easy collaboration amongst hydra projects.}
13
+ spec.homepage = ""
14
+ spec.license = "APACHE2"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "hydra-pcdm", "~> 0.0.1"
22
+ spec.add_dependency "hydra-derivatives", "~> 1.1.0"
23
+ spec.add_dependency "activefedora-aggregation", "~> 0.2.0"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec-rails", "~> 3.1"
28
+ spec.add_development_dependency "engine_cart", "~> 0"
29
+ spec.add_development_dependency "sqlite3"
30
+ spec.add_development_dependency 'jettywrapper', '>= 2.0.0'
31
+ spec.add_development_dependency 'coveralls'
32
+ spec.add_development_dependency 'rspec'
33
+ end
@@ -0,0 +1,81 @@
1
+ require 'hydra/works/version'
2
+ require 'active_fedora/aggregation'
3
+ require 'hydra/pcdm'
4
+ require 'hydra/derivatives'
5
+ require 'hydra/works/processor'
6
+
7
+ module Hydra
8
+ module Works
9
+
10
+ # vocabularies
11
+ autoload :WorksVocabularies, 'hydra/works/vocab/works_terms'
12
+
13
+ # models
14
+ autoload :Collection, 'hydra/works/models/collection'
15
+ autoload :GenericWork, 'hydra/works/models/generic_work'
16
+ autoload :GenericFile, 'hydra/works/models/generic_file'
17
+
18
+ #behaviors
19
+ autoload :CollectionBehavior, 'hydra/works/models/concerns/collection_behavior'
20
+ autoload :GenericWorkBehavior, 'hydra/works/models/concerns/generic_work_behavior'
21
+ autoload :GenericFileBehavior, 'hydra/works/models/concerns/generic_file_behavior'
22
+ autoload :AggregatesGenericFiles, 'hydra/works/models/concerns/aggregates_generic_files'
23
+ autoload :AggregatesGenericWorks, 'hydra/works/models/concerns/aggregates_generic_works'
24
+ autoload :AggregatesCollections, 'hydra/works/models/concerns/aggregates_collections'
25
+ autoload :GenericFile, 'hydra/works/models/generic_file'
26
+
27
+ # collection services
28
+ autoload :AddCollectionToCollection, 'hydra/works/services/collection/add_collection'
29
+ autoload :AddGenericWorkToCollection, 'hydra/works/services/collection/add_generic_work'
30
+ autoload :AddRelatedObjectToCollection, 'hydra/works/services/collection/add_related_object'
31
+ autoload :GetCollectionsFromCollection, 'hydra/works/services/collection/get_collections'
32
+ autoload :GetGenericWorksFromCollection, 'hydra/works/services/collection/get_generic_works'
33
+ autoload :GetRelatedObjectsFromCollection, 'hydra/works/services/collection/get_related_objects'
34
+ autoload :RemoveCollectionFromCollection, 'hydra/works/services/collection/remove_collection'
35
+ autoload :RemoveGenericWorkFromCollection, 'hydra/works/services/collection/remove_generic_work'
36
+ autoload :RemoveRelatedObjectFromCollection, 'hydra/works/services/collection/remove_related_object'
37
+
38
+ # generic_work services
39
+ autoload :AddGenericWorkToGenericWork, 'hydra/works/services/generic_work/add_generic_work'
40
+ autoload :AddGenericFileToGenericWork, 'hydra/works/services/generic_work/add_generic_file'
41
+ autoload :AddRelatedObjectToGenericWork, 'hydra/works/services/generic_work/add_related_object'
42
+ autoload :GetGenericWorksFromGenericWork, 'hydra/works/services/generic_work/get_generic_works'
43
+ autoload :GetGenericFilesFromGenericWork, 'hydra/works/services/generic_work/get_generic_files'
44
+ autoload :GetRelatedObjectsFromGenericWork, 'hydra/works/services/generic_work/get_related_objects'
45
+ autoload :MoveGenericFileToGenericWork, 'hydra/works/services/generic_work/move_generic_file'
46
+ autoload :RemoveGenericWorkFromGenericWork, 'hydra/works/services/generic_work/remove_generic_work'
47
+ autoload :RemoveGenericFileFromGenericWork, 'hydra/works/services/generic_work/remove_generic_file'
48
+ autoload :RemoveRelatedObjectFromGenericWork, 'hydra/works/services/generic_work/remove_related_object'
49
+
50
+ # generic_file services
51
+ autoload :AddGenericFileToGenericFile, 'hydra/works/services/generic_file/add_generic_file'
52
+ autoload :AddFileToGenericFile, 'hydra/works/services/generic_file/add_file'
53
+ autoload :AddRelatedObjectToGenericFile, 'hydra/works/services/generic_file/add_related_object'
54
+ autoload :GetGenericWorksFromGenericFile, 'hydra/works/services/generic_file/get_generic_works'
55
+ autoload :GetGenericFilesFromGenericFile, 'hydra/works/services/generic_file/get_generic_files'
56
+ autoload :GetRelatedObjectsFromGenericFile, 'hydra/works/services/generic_file/get_related_objects'
57
+ autoload :RemoveGenericFileFromGenericFile, 'hydra/works/services/generic_file/remove_generic_file'
58
+ autoload :RemoveRelatedObjectFromGenericFile, 'hydra/works/services/generic_file/remove_related_object'
59
+ autoload :UploadFileToGenericFile, 'hydra/works/services/generic_file/upload_file'
60
+ autoload :AddOriginalFile, 'hydra/works/services/generic_file/add_original_file'
61
+ autoload :AddVersionedOriginalFile, 'hydra/works/services/generic_file/add_versioned_original_file'
62
+ autoload :GenerateThumbnail, 'hydra/works/services/generic_file/generate/thumbnail'
63
+
64
+ # model validations
65
+ def self.collection? collection
66
+ return false unless collection.respond_to? :type
67
+ collection.type.include? WorksVocabularies::WorksTerms.Collection
68
+ end
69
+
70
+ def self.generic_work? generic_work
71
+ return false unless generic_work.respond_to? :type
72
+ generic_work.type.include? WorksVocabularies::WorksTerms.GenericWork
73
+ end
74
+
75
+ def self.generic_file? generic_file
76
+ return false unless generic_file.respond_to? :type
77
+ generic_file.type.include? WorksVocabularies::WorksTerms.GenericFile
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,5 @@
1
+ module Hydra::Works
2
+ class Collection < ActiveFedora::Base
3
+ include Hydra::Works::CollectionBehavior
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ module Hydra::Works
2
+ # Allows instances of a class to aggregate (pcdm:hasMember) hydra-works collections
3
+ module AggregatesCollections
4
+
5
+ def collections= collections
6
+ raise ArgumentError, "each collection must be a hydra works collection" unless collections.all? { |c| Hydra::Works.collection? c }
7
+ raise ArgumentError, "a collection can't be an ancestor of itself" if collection_ancestor?(collections)
8
+ self.members = self.generic_works + collections
9
+ end
10
+
11
+ def collections
12
+ members.to_a.select { |m| Hydra::Works.collection? m }
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ module Hydra::Works
2
+ # Allows instances of a class to aggregate (pcdm:hasMember) hydra-works generic files
3
+ module AggregatesGenericFiles
4
+
5
+ def generic_files= generic_files
6
+ raise ArgumentError, "each generic_file must be a hydra works generic file" unless generic_files.all? { |w| Hydra::Works.generic_file? w }
7
+ raise ArgumentError, "a generic file can't be an ancestor of itself" if object_ancestor?(generic_files)
8
+ if self.respond_to?(:generic_works)
9
+ self.members = self.generic_works + generic_files
10
+ else
11
+ self.members = generic_files
12
+ end
13
+ end
14
+
15
+ def generic_files
16
+ members.to_a.select { |m| Hydra::Works.generic_file? m }
17
+ end
18
+ end
19
+
20
+ end