-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* validate collections, generic_works, and generic_files (there are known failures) * refactor file_behavior to generic_file_behavior * refactor work_behavior to generic_work_behavior * make setters/getters match pcdm approach * add tests following the pcdm pattern * add first take on README * get active_fedora gem from stable branch * add hardcoded RDFVocabulary -- need to switch to generated when ready * remove TODOs and make new issues -- A few TODOs remain for known issues in progress. They identify the location where work is actively being done. They are all marked with issue numbers.
- Loading branch information
Showing
18 changed files
with
1,179 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,93 @@ | ||
## What is this? | ||
# Hydra::Works | ||
[![Build Status](https://travis-ci.org/projecthydra-labs/hydra-works.svg?branch=master)](https://travis-ci.org/projecthydra-labs/hydra-works) | ||
[![Coverage Status](https://coveralls.io/repos/projecthydra-labs/hydra-works/badge.svg?branch=master)](https://coveralls.io/r/projecthydra-labs/hydra-works?branch=master) | ||
|
||
This is a project to establish a standard base data model for Hydra and perhaps other Fedora projects. | ||
Hydra implementation of a works model based on the [Portland Common Data Model](https://github.com/projecthydra-labs/hydra-pcdm) (PCDM). | ||
|
||
It is currently in _MAJOR_ flux and should not be used for code you care about. | ||
|
||
It currently works for ActiveFedora 9 (Fedora 4). | ||
## Installation | ||
|
||
## Application Profile | ||
https://docs.google.com/document/d/1o-Iq1oKN_W5NXXDQC81pxkhibOz_AhZlY7IShxPTR5M/edit | ||
Add these lines to your application's Gemfile: | ||
|
||
```ruby | ||
gem 'active-fedora', github: 'projecthydra/active_fedora' # hydra-pcdm requires an unreleased version of ActiveFedora | ||
gem 'hydra-pcdm', github: 'projecthydra-labs/hydra-pcdm' | ||
gem 'hydra-works', github: 'projecthydra-labs/hydra-works' | ||
``` | ||
|
||
Substitute another branch name for 'master' to test out a branch under development. | ||
<!-- Temporarily comment out until gem is published. | ||
gem 'hydra-pcdm' | ||
--> | ||
|
||
And then execute: | ||
``` | ||
$ bundle | ||
``` | ||
<!-- Temporarily comment out until gem is published. | ||
Or install it yourself as: | ||
$ gem install hydra-works | ||
--> | ||
|
||
## Access Controls | ||
We are using [Web ACL](http://www.w3.org/wiki/WebAccessControl) as implemented by [hydra-access](https://github.com/projecthydra/hydra-head/tree/master/hydra-access-controls) controls | ||
|
||
## Hydra Works Model | ||
|
||
PCDM Reference: [Portland Common Data Model](https://wiki.duraspace.org/x/9IoOB) | ||
|
||
![Hydra Works Model Definition](https://docs.google.com/presentation/d/1d43d5o2d0x6NyI1tjjuJN6BDI9F9XYxZ1_9_EoZbAyE/edit#slide=id.p8) | ||
|
||
|
||
## Usage | ||
|
||
Hydra-works provides three classes: | ||
``` | ||
Hydra::Works::Collection - a collection aggregates collections and generic works | ||
Hydra::Works::GenericWork - a generic work aggregates generic works and generic files | ||
Hydra::Works::GenericFile - a generic file aggregates generic files and contains pcdm files | ||
``` | ||
|
||
A `Hydra::PCDM::File` is a NonRDFSource &emdash; a bitstream. You can use this to store content. A PCDM::File is contained by a PCDM::Object. A `File` has some attached technical metadata, but no descriptive metadata. A `Hydra::PCDM::Object` contains files and other objects and may have descriptive metadata. A `Hydra::PCDM::Collection` can contain other `Collection`s or `Object`s but not `File`s. A `Collection` also may have descriptive metadata. | ||
|
||
Typically usage involves extending the behavior provided by this gem. In your application you can write something like this: | ||
|
||
```ruby | ||
|
||
class Collection < ActiveFedora::Base | ||
include Hydra::PCDM::CollectionBehavior | ||
include Hydra::Works::CollectionBehavior | ||
end | ||
|
||
class BookWork < ActiveFedora::Base | ||
include Hydra::PCDM::ObjectBehavior | ||
include Hydra::Works::GenericWorkBehavior | ||
end | ||
|
||
class BookFiles < ActiveFedora::Base | ||
include Hydra::PCDM::ObjectBehavior | ||
include Hydra::Works::GenericFileBehavior | ||
end | ||
|
||
|
||
c1 = Collection.create | ||
bw1 = BookWork.create | ||
bf1 = BookFiles.create | ||
|
||
bf1.save | ||
bw1.generic_files = [bf1] | ||
bw1.save | ||
c1.generic_works = [bw1] | ||
# c1.members << b1 # This should work in the future | ||
c1.save | ||
|
||
|
||
# This section waiting on https://github.com/projecthydra-labs/hydra-pcdm/pull/52 | ||
# f1 = b1.files.build | ||
# f1.conent = "The quick brown fox jumped over the lazy dog." | ||
# b1.save | ||
``` | ||
|
||
## How to contribute | ||
If you'd like to contribute to this effort, please check out the [Contributing Guide](CONTRIBUTING.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module Hydra::Works | ||
module GenericFileBehavior | ||
extend ActiveSupport::Concern | ||
include Hydra::PCDM::ObjectBehavior | ||
|
||
# TODO: Extend rdf type to include RDFVocabularies::HydraWorks.GenericFile (see issue #71) | ||
# included do | ||
# type RDFVocabularies::WorksTerms.GenericFile | ||
# end | ||
|
||
# behavior: | ||
# 1) Hydra::Works::GenericFile can contain (pcdm:hasFile) Hydra::PCDM::File (inherits from Hydra::PCDM::Object) | ||
# 2) Hydra::Works::GenericFile can contain (pcdm:hasRelatedFile) Hydra::PCDM::File (inherits from Hydra::PCDM::Object) | ||
# 3) Hydra::Works::GenericFile can aggregate (pcdm:hasMember) Hydra::Works::GenericFile | ||
|
||
# 4) Hydra::Works::GenericFile can NOT aggregate anything else | ||
|
||
# 5) Hydra::Works::GenericFile can have descriptive metadata | ||
# 6) Hydra::Works::GenericFile can have access metadata | ||
|
||
|
||
|
||
# TODO: Not sure how to handle work1.generic_files << new_generic_file. (see issue #45) | ||
# Want to override << on work1.generic_files to check that new_work Hydra::Works.generic_file? | ||
|
||
|
||
def generic_files= generic_files | ||
raise ArgumentError, "each generic_file must be a hydra works generic file" unless generic_files.all? { |w| Hydra::Works.generic_file? w } | ||
raise ArgumentError, "a generic file can't be an ancestor of itself" if object_ancestor?(generic_files) | ||
self.members = generic_files | ||
end | ||
|
||
def generic_files | ||
members.to_a.select { |m| Hydra::Works.generic_file? m } | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module Hydra::Works | ||
module GenericWorkBehavior | ||
extend ActiveSupport::Concern | ||
include Hydra::PCDM::ObjectBehavior | ||
|
||
# TODO: Extend rdf type to include RDFVocabularies::WorksTerms.GenericWork (see issue #71) | ||
# included do | ||
# type RDFVocabularies::WorksTerms.GenericWork | ||
# end | ||
|
||
|
||
# behavior: | ||
# 1) Hydra::Works::GenericWork can aggregate Hydra::Works::GenericWork | ||
# 2) Hydra::Works::GenericWork can aggregate Hydra::Works::GenericFile | ||
|
||
# 3) Hydra::Works::GenericWork can NOT aggregate Hydra::PCDM::Collection | ||
# 4) Hydra::Works::GenericWork can NOT aggregate Hydra::Works::Collection | ||
# 5) Hydra::Works::GenericWork can NOT aggregate Works::Object unless it is also a Hydra::Works::GenericFile | ||
# 6) Hydra::Works::GenericWork can NOT contain PCDM::File | ||
# 7) Hydra::Works::GenericWork can NOT aggregate non-PCDM object | ||
|
||
# 8) Hydra::Works::GenericWork can NOT contain Hydra::Works::File | ||
|
||
# 9) Hydra::Works::GenericWork can have descriptive metadata | ||
# 10) Hydra::Works::GenericWork can have access metadata | ||
|
||
|
||
# TODO: Not sure how to handle work1.generic_works << new_generic_work. (see issue #45) | ||
# Want to override << on work1.generic_works to check that new_work Hydra::Works.generic_work? | ||
# TODO: Not sure how to handle work1.generic_files << new_generic_file. (see issue #45) | ||
# Want to override << on work1.generic_files to check that new_work Hydra::Works.generic_file? | ||
|
||
|
||
def generic_works= generic_works | ||
raise ArgumentError, "each generic_work must be a hydra works generic work" unless generic_works.all? { |w| Hydra::Works.generic_work? w } | ||
raise ArgumentError, "a generic work can't be an ancestor of itself" if object_ancestor?(generic_works) | ||
self.members = self.generic_files + generic_works | ||
end | ||
|
||
def generic_works | ||
members.to_a.select { |m| Hydra::Works.generic_work? m } | ||
end | ||
|
||
def generic_files= generic_files | ||
raise ArgumentError, "each generic_file must be a hydra works generic file" unless generic_files.all? { |w| Hydra::Works.generic_file? w } | ||
self.members = self.generic_works + generic_files | ||
end | ||
|
||
def generic_files | ||
members.to_a.select { |m| Hydra::Works.generic_file? m } | ||
end | ||
|
||
def contains= files | ||
raise NoMethodError, "works can not contain files" | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.