-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverse Collection membership #901
Conversation
@@ -115,6 +115,7 @@ def form_class | |||
|
|||
def build_form | |||
@form = form_class.new(curation_concern, current_ability) | |||
@collections = Collection.all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value of this method has changed, which may or may not be an issue. I'm also concerned about adding another instance variable for the view to use.
Suggestion:
- Add form_class#collections_for_select method that can be referenced in the view
ca5e080
to
ac1931a
Compare
@jeremyf thanks for your comments — I've pushed another commit to address them. |
27ee033
to
e18cb74
Compare
This is still preliminary for us but in order to get this to work for our sufia 7.1.0 based app, in our project's Gemfile we had to include
and make one more modification to curation_concerns
|
We need an automated data migration method to do this. |
b6fa608
to
4c3329d
Compare
@escowles The problem that I was trying to solve is that Sufia doesn't use an Actor like your Plum does, so needed a place to populate member_of_collections. Where the collection added members seemed logical to me. Shouldn't the inverted collection membership apply to all members regardless of class? Sufia also needs member_of_collection_ids set. Would you be agreeable to adding this to the add_member_objects helper method? |
Sufia calls
So I think that member_of_collections should be set somewhere in curation_concerns. |
Did @tpendragon last commit to this branch step on some of @escowles work? b6fa608 doesn't seem to exist. |
Er, maybe? @escowles can you check? I thought I just got rid of the AF lock. |
…ixes ualbertalib/HydraNorth#1126 * use latest fcrepo4 (4.6.0) * add debugging tools to Gemfile * still need to override curation_concerns for some missing behaviour * configure Collection faceting
@escowles that sounds like a no to me. Rebase away! |
e29f93c
to
c2fca95
Compare
@escowles We have a broken build due to dependencies on RDF. |
@escowles this last change (requiring RDF 2.1) is going to be a breaking change for folks who want the ordering behavior present in RDF 1. |
@jcoyne I know — but I thought it was unavoidable because we're requiring a version of AF that requires RDF 2.x. But I just checked and noticed that |
54af92e
to
082e146
Compare
@escowles Were those two tests really unused? They seem to be around the collection show page "remove member" functionality. |
@tpendragon I removed the tests because this PR removes the underlying functionality, since collection membership is now managed through the work edit form instead of through the collection edit form. I'm not opposed to reimplementing that functionality if people think it's useful. But this PR is already big enough I thought it was better to not add new stuff to it. |
@escowles I think we should maintain the current UI's functionality - it feels unexpected that it would change. |
@@ -10,6 +10,11 @@ def generate_solr_document | |||
# Index the size of the collection in bytes | |||
solr_doc[Solrizer.solr_name(:bytes, STORED_LONG)] = object.bytes | |||
solr_doc['thumbnail_path_ss'] = thumbnail_path | |||
|
|||
object.in_collections.each do |col| | |||
solr_doc['member_of_collection_ids_ssim'] = col.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can collections only belong to one other collection? Is that why you are using =
here instead of <<
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this should be using <<
instead of =
to allow the object to be in multiple collections — I'll update that.
bcd7ab1
to
c57f134
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few last changes to suggest. Thanks for working on this!
@@ -0,0 +1,6 @@ | |||
<% if @form.respond_to? :member_of_collection_ids %> | |||
<div class="row" with-headroom"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@escowles You've either got an extraneous or a missing "
here.
@@ -45,6 +45,7 @@ Gem::Specification.new do |spec| | |||
spec.add_dependency 'dry-struct', '~> 0.1' | |||
spec.add_dependency 'flot-rails', '~> 0.0.7' | |||
spec.add_dependency 'highcharts-rails' | |||
spec.add_dependency 'hydra-pcdm', '~> 0.9.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of pinning hydra-pcdm in CC, should we update the hydra-works gemspec and let CC's dependence on HW pick up the right version of HP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've uddated samvera/hydra-works#303 to make HW require hydra-pcdm >= 0.9.0
. I can update this PR to use that once it's released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged, @escowles. Thanks! HW now needs a release and this PR can then point at the new release.
@@ -1,4 +1,6 @@ | |||
# placeholder to use for pinning against specific gem commit references | |||
gem 'hydra-pcdm', github:'projecthydra/hydra-pcdm', branch: 'master' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these still needed? I'd like to see these taken out before we merge this PR -- and then we can cut the 2.0 release soon thereafter.
@escowles Would you like to squash the commits, or do you think they're good logical chunks that should remain separate? I could go either way. |
@@ -9,6 +9,7 @@ def self.build(curation_concern, current_user) | |||
|
|||
def self.stack_actors(curation_concern) | |||
[AddToCollectionActor, | |||
AddAsMemberOfCollectionsActor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we making this a new actor and not replacing AddToCollectionActor
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention was to leave the existing membership functionality for Collections to continue to have member Collections. But I could just replace AddToCollectionActor
if that makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Collections use the ActorStack, so I think we can get rid of it, right?
fe94e88
to
96eb177
Compare
@mjgiarlo I've rebased and squashed this PR, now depending on hydra-works 0.15. |
@@ -9,6 +9,7 @@ def self.build(curation_concern, current_user) | |||
|
|||
def self.stack_actors(curation_concern) | |||
[AddToCollectionActor, | |||
AddAsMemberOfCollectionsActor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Collections use the ActorStack, so I think we can get rid of it, right?
96eb177
to
ca7f07e
Compare
…collections to link to Collections
ca7f07e
to
3f2cb49
Compare
@jcoyne I've removed the AddToCollectionActor to avoid that duplication. |
|
||
def add_member_objects(new_member_ids) | ||
Array(new_member_ids).each do |member_id| | ||
member = ActiveFedora::Base.find(member_id, cast: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cast: true
doesn't do anything (anymore). please remove that.
@@ -10,5 +10,17 @@ def add_members(new_member_ids) | |||
return if new_member_ids.nil? || new_member_ids.empty? | |||
members << ActiveFedora::Base.find(new_member_ids) | |||
end | |||
|
|||
def add_member_objects(new_member_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some documentation here about how this adds the association on the member side. If you wouldn't mind, please also add some documentation to add_members
too.
*presenter_factory_arguments) | ||
end | ||
|
||
def member_of_collection_presenters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add method documentation here.
@@ -84,8 +82,12 @@ def composite_presenter_class | |||
|
|||
# @return [Array<CollectionPresenter>] presenters for the collections that this work is a member of | |||
def collection_presenters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this method still needed?
<% end %> | ||
</li> | ||
<% end %> | ||
<% if can? :collect, document %> | ||
<% if can?(:collect, document) && document.collection? %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check required. Isn't this used on a show page for a collection (which ensures that document is a Collection)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this template used at all?
@@ -1,7 +1,6 @@ | |||
<% provide :page_title, curation_concern_page_title(@collection) %> | |||
|
|||
<h1>Edit <%= @collection %> <span class="human_readable_type">(<%= @collection.human_readable_type %>)</span></h1> | |||
|
|||
<h1>Edit <%= @collection.first_title %> <span class="human_readable_type">(<%= @collection.human_readable_type %>)</span></h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use @collection.to_s
for the title rather than first_title
.
@@ -0,0 +1,6 @@ | |||
<% if @form.respond_to? :member_of_collection_ids %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to check this? Shouldn't it always be present?
@@ -0,0 +1,12 @@ | |||
<% if defined?(presenter.member_of_collection_presenters) && presenter.member_of_collection_presenters.size > 0 %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to check for defined?(presenter.member_of_collection_presenters)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called from _attributes.html.erb for everything (including FileSets that don't have a member_of_collection_presenters method). We can move this logic into _attribute.html.erb if that seems better.
<td> | ||
<ul class="member_of_collections"> | ||
<% presenter.member_of_collection_presenters.each do |p| %> | ||
<li><%= link_to p.title.first, main_app.collection_path(p.id), class: 'collection-link' %></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we encapsulate p.title.first
in a method (#to_s
perhaps)?
@jcoyne I've added some docs and removed some unnecessary methods and checks leftover from when I was trying to support both the member and member_of membership modes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more thing. Then we can merge it.
@@ -0,0 +1,12 @@ | |||
<% if defined?(presenter.member_of_collection_presenters) && presenter.member_of_collection_presenters.size > 0 %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Let's get rid of this check here and put it in the _attributes
partial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've moved the check into the _attributes
partial.
I'm dismissing @mjgiarlo's review because all those changes have been made. |
Improve scalability of Collections by linking from Objects to Collections (instead of linking from Collections to their member Objects).
This PR removes the existing functionality to link from Collections to Objects. Objects are typically members of one or a small number of Collections, but some Collections can have 10,000 or more member Objects. While there is ongoing work to address the issue, Fedora performance for Collections that link to that many Objects with pcdm:hasMember is poor, so this PR dramatically improves performance by avoiding that bottleneck.
@projecthydra/sufia-code-reviewers