fedora-migrate 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77fed55ecdbf64c57627ad65017d99be9f1424a1
4
- data.tar.gz: fb0bfbb69e5d0efd99521bee4c3434218ae8f672
3
+ metadata.gz: afdd2ed8a8cab6fdfceb3d664b9d0896d5de100d
4
+ data.tar.gz: d57679b333b481bdd286714f8b60999c3a900c71
5
5
  SHA512:
6
- metadata.gz: 4943665d395ae6e0d45f152f00eca3d7a9075c876be7757ec146d63b16b420db67ce3be520546bdbd0ce3cff1e10a6fc3071ff05c656459cc68e1a40cbcf5a34
7
- data.tar.gz: 23f37bbb636630151e125384ddc00ef2c198209d0fa1aa2983abeb16dc5b07e34a1470ad26b1451ac4b8326708e2c48fbbcd05ba40baabb120300ce1fb915105
6
+ metadata.gz: 26514e72b1474f3183cde29bef91fad5ddeabfd645741494aae86ddba7f277cfb33d80041888adfa3e23a55eef95a66a1bd08caeaa840447fe7bc88fc2be3f34
7
+ data.tar.gz: cb6530245637ca3b7e970d00a22146dc36f311206933ccff9cbfa1884edd1ad6c5f12d66fd9b03d05656bb0c03b05f9386f585ba3a07ce2ad9e86b179673b64a
@@ -1,18 +1,10 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  sudo: false
3
4
  rvm:
4
- - 2.2.0
5
- - 2.2.1
6
- - 2.3.0
5
+ - 2.3.1
7
6
  env:
8
7
  global:
9
8
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
10
- notifications:
11
- irc:
12
- channels:
13
- - "irc.freenode.org#scholarsphere"
14
- - "irc.freenode.org#projecthydra"
15
- template:
16
- - "%{repository}//%{branch}@%{commit} by %{author}: %{message} - %{build_url}"
17
9
  before_script:
18
10
  - jdk_switcher use oraclejdk8
@@ -0,0 +1,159 @@
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
+ ## Code of Conduct
7
+
8
+ The Hydra community is dedicated to providing a welcoming and positive experience for all its
9
+ members, whether they are at a formal gathering, in a social setting, or taking part in activities
10
+ online. Please see our [Code of Conduct](https://wiki.duraspace.org/display/hydra/Code+of+Conduct)
11
+ for more information.
12
+
13
+ ## Hydra Project Intellectual Property Licensing and Ownership
14
+
15
+ All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
16
+ If the contributor works for an institution, the institution must have a Corporate Contributor License Agreement (cCLA) on file.
17
+
18
+ https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership
19
+
20
+ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
21
+
22
+ ## Contribution Tasks
23
+
24
+ * Reporting Issues
25
+ * Making Changes
26
+ * Documenting Code
27
+ * Committing Changes
28
+ * Submitting Changes
29
+ * Reviewing and Merging Changes
30
+
31
+ ### Reporting Issues
32
+
33
+ * Make sure you have a [GitHub account](https://github.com/signup/free)
34
+ * Submit a [Github issue](./issues) by:
35
+ * Clearly describing the issue
36
+ * Provide a descriptive summary
37
+ * Explain the expected behavior
38
+ * Explain the actual behavior
39
+ * Provide steps to reproduce the actual behavior
40
+
41
+ ### Making Changes
42
+
43
+ * Fork the repository on GitHub
44
+ * Create a topic branch from where you want to base your work.
45
+ * This is usually the master branch.
46
+ * To quickly create a topic branch based on master; `git branch fix/master/my_contribution master`
47
+ * Then checkout the new branch with `git checkout fix/master/my_contribution`.
48
+ * Please avoid working directly on the `master` branch.
49
+ * You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
50
+ * Make sure you have added sufficient tests and documentation for your changes.
51
+ * Test functionality with RSpec; est features / UI with Capybara.
52
+ * Run _all_ the tests to assure nothing else was accidentally broken.
53
+
54
+ ### Documenting Code
55
+
56
+ * All new public methods, modules, and classes should include inline documentation in [YARD](http://yardoc.org/).
57
+ * Documentation should seek to answer the question "why does this code exist?"
58
+ * Document private / protected methods as desired.
59
+ * If you are working in a file with no prior documentation, do try to document as you gain understanding of the code.
60
+ * If you don't know exactly what a bit of code does, it is extra likely that it needs to be documented. Take a stab at it and ask for feedback in your pull request. You can use the 'blame' button on GitHub to identify the original developer of the code and @mention them in your comment.
61
+ * This work greatly increases the usability of the code base and supports the on-ramping of new committers.
62
+ * We will all be understanding of one another's time constraints in this area.
63
+ * YARD examples:
64
+ * [Hydra::Works::RemoveGenericFile](https://github.com/projecthydra-labs/hydra-works/blob/master/lib/hydra/works/services/generic_work/remove_generic_file.rb)
65
+ * [ActiveTriples::LocalName::Minter](https://github.com/ActiveTriples/active_triples-local_name/blob/master/lib/active_triples/local_name/minter.rb)
66
+ * [Getting started with YARD](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md)
67
+
68
+ ### Committing changes
69
+
70
+ * Make commits of logical units.
71
+ * Your commit should include a high level description of your work in HISTORY.textile
72
+ * Check for unnecessary whitespace with `git diff --check` before committing.
73
+ * Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
74
+ * 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)
75
+
76
+ ```
77
+ Present tense short summary (50 characters or less)
78
+
79
+ More detailed description, if necessary. It should be wrapped to 72
80
+ characters. Try to be as descriptive as you can, even if you think that
81
+ the commit content is obvious, it may not be obvious to others. You
82
+ should add such description also if it's already present in bug tracker,
83
+ it should not be necessary to visit a webpage to check the history.
84
+
85
+ Include Closes #<issue-number> when relavent.
86
+
87
+ Description can have multiple paragraphs and you can use code examples
88
+ inside, just indent it with 4 spaces:
89
+
90
+ class PostsController
91
+ def index
92
+ respond_to do |wants|
93
+ wants.html { render 'index' }
94
+ end
95
+ end
96
+ end
97
+
98
+ You can also add bullet points:
99
+
100
+ - you can use dashes or asterisks
101
+
102
+ - also, try to indent next line of a point for readability, if it's too
103
+ long to fit in 72 characters
104
+ ```
105
+
106
+ ### Submitting Changes
107
+
108
+ * Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
109
+ * Make sure your branch is up to date with its parent branch (i.e. master)
110
+ * `git checkout master`
111
+ * `git pull --rebase`
112
+ * `git checkout <your-branch>`
113
+ * `git rebase master`
114
+ * It is a good idea to run your tests again.
115
+ * If you've made more than one commit take a moment to consider whether squashing commits together would help improve their logical grouping.
116
+ * [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
117
+ * `git rebase --interactive master` ([See Github help](https://help.github.com/articles/interactive-rebase))
118
+ * 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.
119
+ * Push your changes to a topic branch in your fork of the repository.
120
+ * Submit a pull request from your fork to the project.
121
+
122
+ ### Reviewing and Merging Changes
123
+
124
+ We adopted [Github's Pull Request Review](https://help.github.com/articles/about-pull-request-reviews/) for our repositories.
125
+ Common checks that may occur in our repositories:
126
+
127
+ 1. Travis CI - where our automated tests are running
128
+ 2. Hound CI - where we check for style violations
129
+ 3. Approval Required - Github enforces at least one person approve a pull request. Also, all reviewers that have chimed in must approve.
130
+ 4. CodeClimate - is our code remaining healthy (at least according to static code analysis)
131
+
132
+ If one or more of the required checks failed (or are incomplete), the code should not be merged (and the UI will not allow it). If all of the checks have passed, then anyone on the project (including the pull request submitter) may merge the code.
133
+
134
+ *Example: Carolyn submits a pull request, Justin reviews the pull request and approves. However, Justin is still waiting on other checks (Travis CI is usually the culprit), so he does not merge the pull request. Eventually, all of the checks pass. At this point, Carolyn or anyone else may merge the pull request.*
135
+
136
+ #### Things to Consider When Reviewing
137
+
138
+ First, the person contributing the code is putting themselves out there. Be mindful of what you say in a review.
139
+
140
+ * Ask clarifying questions
141
+ * State your understanding and expectations
142
+ * Provide example code or alternate solutions, and explain why
143
+
144
+ This is your chance for a mentoring moment of another developer. Take time to give an honest and thorough review of what has changed. Things to consider:
145
+
146
+ * Does the commit message explain what is going on?
147
+ * Does the code changes have tests? _Not all changes need new tests, some changes are refactors_
148
+ * Do new or changed methods, modules, and classes have documentation?
149
+ * Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
150
+ * Does the description of the new/changed specs match your understanding of what the spec is doing?
151
+
152
+ If you are uncertain, bring other contributors into the conversation by assigning them as a reviewer.
153
+
154
+ # Additional Resources
155
+
156
+ * [General GitHub documentation](http://help.github.com/)
157
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
158
+ * [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
159
+ * [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
data/README.md CHANGED
@@ -52,7 +52,7 @@ as an example:
52
52
  ``` ruby
53
53
  desc "Migrate all my objects"
54
54
  task migrate: :environment do
55
- results = FedoraMigrate.migrate_repository("mynamespace")
55
+ results = FedoraMigrate.migrate_repository(namespace: "mynamespace", options: {})
56
56
  puts results
57
57
  end
58
58
  ```
@@ -101,7 +101,7 @@ However, you are required to define any and all RDF properties on your object in
101
101
 
102
102
  ``` ruby
103
103
  class RDFObject < ActiveFedora::Base
104
- property :title, predicate: ::RDF::DC.title do |index|
104
+ property :title, predicate: ::RDF::Vocab::DC.title do |index|
105
105
  index.as :stored_searchable, :facetable
106
106
  end
107
107
  contains "content", class_name: "ActiveFedora::File"
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "hydra-head", "~> 9.5"
22
21
  spec.add_dependency "rubydora", "~> 1.8"
23
22
  spec.add_dependency "rchardet"
23
+ spec.add_dependency "rdf-rdfxml"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.7"
26
26
  spec.add_development_dependency "equivalent-xml"
27
- spec.add_development_dependency "hydra-collections", "~> 5.0"
27
+ spec.add_development_dependency "curation_concerns", '~> 1.6'
28
+ spec.add_development_dependency "active-fedora", '~> 10.2'
28
29
  spec.add_development_dependency "jettywrapper"
29
30
  spec.add_development_dependency "rake", "~> 10.0"
30
31
  spec.add_development_dependency "rspec"
@@ -22,7 +22,7 @@ module FedoraMigrate
22
22
  end
23
23
 
24
24
  def move_content
25
- target.content = source.content
25
+ target.content = StringIO.new(source.content)
26
26
  target.original_name = source.label.try(:gsub, /"/, '\"')
27
27
  target.mime_type = source.mimeType
28
28
  save
@@ -22,9 +22,21 @@ module FedoraMigrate
22
22
  end
23
23
 
24
24
  def vet(model)
25
+ klass = class_from_model(model)
26
+ klass ||= namespaced_class_from_model(model)
27
+ Logger.debug "rejecting #{model} for target" if klass.nil?
28
+ klass
29
+ end
30
+
31
+ def class_from_model(model)
25
32
  FedoraMigrate::Mover.id_component(model).constantize
26
33
  rescue NameError
27
- Logger.debug "rejecting #{model} for target"
34
+ nil
35
+ end
36
+
37
+ def namespaced_class_from_model(model)
38
+ FedoraMigrate::Mover.id_component(model).split(/_/).map(&:camelize).join('::').constantize
39
+ rescue NameError
28
40
  nil
29
41
  end
30
42
 
@@ -1,3 +1,3 @@
1
1
  module FedoraMigrate
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.5.0".freeze
3
3
  end
@@ -17,9 +17,9 @@ describe FedoraMigrate::ObjectMover do
17
17
 
18
18
  Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
19
19
  class GenericFile < ActiveFedora::Base
20
- contains "content", class_name: "ExampleModel::VersionedDatastream"
21
- contains "thumbnail", class_name: "ActiveFedora::Datastream"
22
- contains "characterization", class_name: "ActiveFedora::Datastream"
20
+ has_subresource "content", class_name: "ExampleModel::VersionedDatastream"
21
+ has_subresource "thumbnail", class_name: "ActiveFedora::File"
22
+ has_subresource "characterization", class_name: "ActiveFedora::File"
23
23
  end
24
24
  end
25
25
 
@@ -6,10 +6,17 @@ describe ExampleModel::Collection do
6
6
  let(:missing_file) { "x346dj07p" }
7
7
 
8
8
  before do
9
+ Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
10
+ class GenericFile < ExampleModel::GenericFile
11
+ end
9
12
  FedoraMigrate::ObjectMover.new(FedoraMigrate.find("scholarsphere:#{collection}"), described_class.new(collection)).migrate
10
13
  files.each { |f| FedoraMigrate::ObjectMover.new(FedoraMigrate.find("scholarsphere:#{f}"), ExampleModel::MigrationObject.new(f)).migrate }
11
14
  end
12
15
 
16
+ after do
17
+ Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
18
+ end
19
+
13
20
  context "when migrating relationships" do
14
21
  let(:migrated_collection) { described_class.first }
15
22
  let(:error_message) do
@@ -45,9 +45,9 @@ describe FedoraMigrate::ObjectMover do
45
45
  before do
46
46
  Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
47
47
  class GenericFile < ActiveFedora::Base
48
- contains "content", class_name: "ExampleModel::VersionedDatastream"
49
- contains "thumbnail", class_name: "ActiveFedora::Datastream"
50
- contains "characterization", class_name: "ActiveFedora::Datastream"
48
+ has_subresource "content", class_name: "ExampleModel::VersionedDatastream"
49
+ has_subresource "thumbnail", class_name: "ActiveFedora::File"
50
+ has_subresource "characterization", class_name: "ActiveFedora::File"
51
51
  end
52
52
  end
53
53
 
@@ -5,10 +5,10 @@ describe FedoraMigrate::ObjectMover do
5
5
  Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
6
6
  class GenericFile < ActiveFedora::Base
7
7
  belongs_to :batch, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
8
- property :title, predicate: ::RDF::DC.title do |index|
8
+ property :title, predicate: ::RDF::Vocab::DC.title do |index|
9
9
  index.as :stored_searchable, :facetable
10
10
  end
11
- property :creator, predicate: ::RDF::DC.creator do |index|
11
+ property :creator, predicate: ::RDF::Vocab::DC.creator do |index|
12
12
  index.as :stored_searchable, :facetable
13
13
  end
14
14
  end
@@ -18,14 +18,7 @@ describe FedoraMigrate do
18
18
  context "when all target objects are defined" do
19
19
  before do
20
20
  Object.send(:remove_const, :GenericFile) if defined?(GenericFile)
21
- class GenericFile < ExampleModel::MigrationObject
22
- belongs_to :batch, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
23
- property :title, predicate: ::RDF::DC.title do |index|
24
- index.as :stored_searchable, :facetable
25
- end
26
- property :creator, predicate: ::RDF::DC.creator do |index|
27
- index.as :stored_searchable, :facetable
28
- end
21
+ class GenericFile < ExampleModel::GenericFile
29
22
  end
30
23
 
31
24
  Object.send(:remove_const, :Batch) if defined?(Batch)
@@ -23,7 +23,7 @@ describe FedoraMigrate::ObjectMover do
23
23
  end
24
24
 
25
25
  it "is migrated in the order they were created with their original creation dates" do
26
- pending "Requires fix to Fedora 4.4; awaiting release"
26
+ # requires Fedora 4.5
27
27
  expect(desc_metadata_source_versions[0].createDate.to_i).to eql date_created_by_application("version1")
28
28
  expect(desc_metadata_source_versions[1].createDate.to_i).to eql date_created_by_application("version2")
29
29
  expect(desc_metadata_source_versions[2].createDate.to_i).to eql date_created_by_application("version3")
@@ -1,16 +1,20 @@
1
1
  # Shenanigans because we're not in a Rails environment and we need to load bits of
2
2
  # code that depend on Rails in order to test migrating objects.
3
3
  Hydra::Engine.config.autoload_paths.each { |path| $LOAD_PATH.unshift path }
4
+
4
5
  # in gem version 2.4, .find_by_name isn't pulling up gems given in the Gemfile
5
6
  # as opposed to those in the gemspec file.
6
7
  # This is a workaround:
7
8
  Gem::Specification.all.each do |g|
8
9
  HAC_DIR = g.gem_dir if g.name == "hydra-access-controls"
9
- HCL_DIR = g.gem_dir if g.name == "hydra-collections"
10
+ HCC_DIR = g.gem_dir if g.name == "curation_concerns"
10
11
  HCR_DIR = g.gem_dir if g.name == "hydra-core"
11
12
  BKL_DIR = g.gem_dir if g.name == "blacklight"
12
13
  end
13
14
 
15
+ # CurationConcerns relies on ActionController::Base
16
+ require 'action_controller'
17
+
14
18
  # Load Rails-specific bits of blacklight
15
19
  require BKL_DIR + '/app/controllers/concerns/blacklight/request_builders'
16
20
  require BKL_DIR + '/app/controllers/concerns/blacklight/search_helper'
@@ -20,6 +24,7 @@ require HAC_DIR + '/app/vocabularies/acl'
20
24
  require HAC_DIR + '/app/vocabularies/hydra/acl'
21
25
  require HAC_DIR + '/app/models/role_mapper'
22
26
  require HAC_DIR + '/app/models/ability'
27
+ require HAC_DIR + '/app/models/hydra/access_control'
23
28
  require HAC_DIR + '/app/models/hydra/access_controls/access_control_list'
24
29
  require HAC_DIR + '/app/models/hydra/access_controls/permission'
25
30
  require HAC_DIR + '/app/models/hydra/access_controls/embargo'
@@ -29,22 +34,35 @@ require HAC_DIR + '/app/services/hydra/lease_service'
29
34
  require HAC_DIR + '/app/services/hydra/embargo_service'
30
35
  require HAC_DIR + '/app/validators/hydra/future_date_validator'
31
36
 
32
- # Loading hydra-collections
33
- require 'hydra-collections'
34
- require HCR_DIR + '/app/models/concerns/hydra/model_methods'
35
- require HCL_DIR + '/app/models/concerns/hydra/collections/metadata'
36
- require HCL_DIR + '/app/models/concerns/hydra/collections/relations'
37
- require HCL_DIR + '/app/models/concerns/hydra/collection'
37
+ # Loading curation_concerns
38
+ require 'curation_concerns'
39
+ require HCR_DIR + '/app/models/concerns/hydra/models'
40
+ require HCC_DIR + '/app/models/concerns/curation_concerns/basic_metadata'
41
+ require HCC_DIR + '/app/models/concerns/curation_concerns/required_metadata'
42
+ require HCC_DIR + '/app/models/concerns/curation_concerns/collection'
43
+ require HCC_DIR + '/app/services/curation_concerns/derivative_path'
44
+ require HCC_DIR + '/app/services/curation_concerns/thumbnail_path_service'
45
+ require HCC_DIR + '/app/services/curation_concerns/indexes_thumbnails'
46
+ require HCC_DIR + '/app/services/curation_concerns/noid'
47
+ require HCC_DIR + '/app/models/concerns/curation_concerns/human_readable_type'
48
+ require HCC_DIR + '/app/models/concerns/curation_concerns/has_representative'
49
+ require HCC_DIR + '/app/models/concerns/curation_concerns/permissions/readable'
50
+ require HCC_DIR + '/app/models/concerns/curation_concerns/permissions/writable'
51
+ require HCC_DIR + '/app/models/concerns/curation_concerns/permissions'
52
+ require HCC_DIR + '/app/validators/has_one_title_validator'
53
+ require HCC_DIR + '/app/models/concerns/curation_concerns/collection_behavior'
54
+ require HCC_DIR + '/app/indexers/curation_concerns/file_set_indexer'
55
+ require HCC_DIR + '/app/indexers/curation_concerns/collection_indexer'
38
56
 
39
57
  module ExampleModel
40
58
  class RDFProperties < ActiveFedora::Base
41
- property :title, predicate: ::RDF::DC.title do |index|
59
+ property :title, predicate: ::RDF::Vocab::DC.title do |index|
42
60
  index.as :stored_searchable, :facetable
43
61
  end
44
- property :creator, predicate: ::RDF::DC.creator do |index|
62
+ property :creator, predicate: ::RDF::Vocab::DC.creator do |index|
45
63
  index.as :stored_searchable, :facetable
46
64
  end
47
- property :description, predicate: ::RDF::DC.description do |index|
65
+ property :description, predicate: ::RDF::Vocab::DC.description do |index|
48
66
  index.type :text
49
67
  index.as :stored_searchable
50
68
  end
@@ -55,43 +73,85 @@ module ExampleModel
55
73
  end
56
74
 
57
75
  class VersionedContent < ActiveFedora::Base
58
- contains "content", class_name: "ExampleModel::VersionedDatastream"
76
+ has_subresource "content", class_name: "ExampleModel::VersionedDatastream"
59
77
  end
60
78
 
61
79
  class MigrationObject < ActiveFedora::Base
62
80
  include Hydra::AccessControls::Permissions
63
- contains "content", class_name: "ExampleModel::VersionedDatastream"
64
- contains "thumbnail", class_name: "ActiveFedora::File"
65
- contains "characterization", class_name: "ActiveFedora::File"
81
+ has_subresource "content", class_name: "ExampleModel::VersionedDatastream"
82
+ has_subresource "thumbnail", class_name: "ActiveFedora::File"
83
+ has_subresource "characterization", class_name: "ActiveFedora::File"
66
84
  end
67
85
 
68
86
  class OmDatastreamExample < ActiveFedora::Base
69
- contains "characterization", class_name: "ActiveFedora::OmDatastream"
87
+ has_subresource "characterization", class_name: "ActiveFedora::OmDatastream"
70
88
  end
71
89
 
72
90
  class RDFObject < ActiveFedora::Base
73
- property :title, predicate: ::RDF::DC.title do |index|
91
+ property :title, predicate: ::RDF::Vocab::DC.title do |index|
74
92
  index.as :stored_searchable, :facetable
75
93
  end
76
94
 
77
- property :description, predicate: ::RDF::DC.description
95
+ property :description, predicate: ::RDF::Vocab::DC.description
78
96
 
79
- property :date_uploaded, predicate: ::RDF::DC.dateSubmitted, multiple: false do |index|
97
+ property :date_uploaded, predicate: ::RDF::Vocab::DC.dateSubmitted, multiple: false do |index|
80
98
  index.type :date
81
99
  index.as :stored_sortable
82
100
  end
83
101
 
84
- property :date_modified, predicate: ::RDF::DC.modified, multiple: false do |index|
102
+ property :date_modified, predicate: ::RDF::Vocab::DC.modified, multiple: false do |index|
85
103
  index.type :date
86
104
  index.as :stored_sortable
87
105
  end
88
106
 
89
- contains "content", class_name: "ExampleModel::VersionedDatastream"
90
- contains "thumbnail", class_name: "ActiveFedora::File"
91
- contains "characterization", class_name: "ActiveFedora::File"
107
+ has_subresource "content", class_name: "ExampleModel::VersionedDatastream"
108
+ has_subresource "thumbnail", class_name: "ActiveFedora::File"
109
+ has_subresource "characterization", class_name: "ActiveFedora::File"
92
110
  end
93
111
 
94
112
  class Collection < ActiveFedora::Base
95
- include Hydra::Collection
113
+ include CurationConcerns::CollectionBehavior
114
+ include CurationConcerns::BasicMetadata
115
+
116
+ # we're not messing with validators here
117
+ clear_validators!
118
+ has_and_belongs_to_many :members, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base", after_remove: :remove_member
119
+
120
+ def remove_member(_m)
121
+ end
122
+
123
+ # Overriding the below to allow GenericFile for tests
124
+ # Compute the sum of each file in the collection using Solr to
125
+ # avoid having to access Fedora
126
+ #
127
+ # @return [Fixnum] size of collection in bytes
128
+ # @raise [RuntimeError] unsaved record does not exist in solr
129
+ def bytes
130
+ return 0 if member_ids.count == 0
131
+
132
+ raise "Collection must be saved to query for bytes" if new_record?
133
+
134
+ # One query per member_id because Solr is not a relational database
135
+ sizes = member_ids.collect do |work_id|
136
+ query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::GenericFile.to_class_uri)
137
+ argz = { fl: "id, #{file_size_field}",
138
+ fq: "{!join from=#{member_ids_field} to=id}id:#{work_id}"
139
+ }
140
+ files = ActiveFedora::SolrService.query(query, argz)
141
+ files.reduce(0) { |sum, f| sum + f[file_size_field].to_i }
142
+ end
143
+
144
+ sizes.reduce(0, :+)
145
+ end
146
+ end
147
+
148
+ class GenericFile < MigrationObject
149
+ belongs_to :batch, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
150
+ property :title, predicate: ::RDF::Vocab::DC.title do |index|
151
+ index.as :stored_searchable, :facetable
152
+ end
153
+ property :creator, predicate: ::RDF::Vocab::DC.creator do |index|
154
+ index.as :stored_searchable, :facetable
155
+ end
96
156
  end
97
157
  end
@@ -33,7 +33,7 @@ describe FedoraMigrate::ContentMover do
33
33
 
34
34
  describe "#move_content" do
35
35
  before do
36
- allow(target).to receive(:content=).with("foo")
36
+ allow(target).to receive(:content=)
37
37
  allow(target).to receive(:original_name=).with("label")
38
38
  allow(target).to receive(:mime_type=).with("mimetype")
39
39
  allow(target).to receive(:save).and_return(true)
@@ -25,4 +25,10 @@ describe FedoraMigrate::TargetConstructor do
25
25
  subject { described_class.new(mock_source) }
26
26
  its(:target) { is_expected.to be_nil }
27
27
  end
28
+
29
+ context "with a namespaced model" do
30
+ let(:list) { "info:fedora/afmodel:Enumerator_Lazy" }
31
+ subject { described_class.new(mock_source) }
32
+ its(:target) { is_expected.to eql Enumerator::Lazy }
33
+ end
28
34
  end
metadata CHANGED
@@ -1,45 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedora-migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Wead
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-08 00:00:00.000000000 Z
11
+ date: 2017-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: hydra-head
14
+ name: rubydora
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '9.5'
19
+ version: '1.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '9.5'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rubydora
28
+ name: rchardet
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.8'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.8'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rchardet
42
+ name: rdf-rdfxml
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -81,19 +81,33 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: hydra-collections
84
+ name: curation_concerns
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: active-fedora
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '5.0'
103
+ version: '10.2'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '5.0'
110
+ version: '10.2'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: jettywrapper
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -163,6 +177,7 @@ files:
163
177
  - ".rubocop.yml"
164
178
  - ".rubocop_todo.yml"
165
179
  - ".travis.yml"
180
+ - CONTRIBUTING.md
166
181
  - Gemfile
167
182
  - LICENSE
168
183
  - README.md