Skip to content
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

centralize the list of collection classes #5207

Closed
wants to merge 4 commits into from
Closed

centralize the list of collection classes #5207

wants to merge 4 commits into from

Conversation

elrayle
Copy link
Contributor

@elrayle elrayle commented Oct 19, 2021

This centralizes the list of collection classes to Hyrax.config.collection_classes.

Places where any collection class could be input or processing occurs across all collection classes were updated to use Hyrax.config.collection_classes. Remaining single references to ::Collection were updated to Hyrax.config.collection_class. These changes allow for almost all remaining uses of ::Collection to be removed.

Exceptions:

  • work_form which is only used with ActiveFedora
  • PermissionTemplate #collection which is deprecated and only works with ::Collection
  • Hyrax::Collections::MigrationService which performs a migration dependent on reading in the collection as a ::Collection

This PR does not update CollectionAbiility as it is being updated in PR #5206. Whichever PR is merged first, there will be a small fix required to get abilities to reference the collection_classes config instead of creating the list in the CollectionAbility class.

@samvera/hyrax-code-reviewers

@elrayle elrayle marked this pull request as draft October 19, 2021 13:35
@no-reply
Copy link
Contributor

i think this is a good goal, but maybe needs some more consideration.

in some cases (e.g. on the search side) i think we want/need to continue to find indexed data under model ::Collection. in part this is because Wings indexes to the Solr core used by ActiveFedora using that Collection model. but it also seems nicer to downstream apps opting into valkyrie anyway---they may not want to force a large scale re-index as a prerequisite to going live with a config switch.

on the flip side, i think we've encountered some other cases where we want to include Hyrax::PcdmCollection in the config regardless of settings. you've covered this case here, but i think maybe this blanket approach is too blunt (or at least that's a possible interpretation of some of the failing tests?).

so far i've only been able to approach this case-by-case, but if we could understand the whole problem space, i think that would help move this forward.

@elrayle
Copy link
Contributor Author

elrayle commented Oct 29, 2021

@no-reply See what you think about the new approach to determining the list of collection classes.

WAS

   def collection_classes
      [collection_model.constantize, Hyrax::PcdmCollection].uniq
    end

NEW APPROACH

   def collection_classes
      klasses = [collection_class, Hyrax::PcdmCollection]
      klasses << ::Collection if defined? ::Collection
      klasses.uniq
    end

@no-reply
Copy link
Contributor

i think #5229 clears the remaining failing test in this PR.

@elrayle elrayle force-pushed the col_classes branch 3 times, most recently from 30be1c0 to bbedb91 Compare October 29, 2021 13:23
@elrayle elrayle marked this pull request as ready for review October 29, 2021 14:30
@@ -13,7 +13,7 @@

it 'searches for valid work types' do
expect(builder.filter_models(solr_params))
.to contain_exactly("{!terms f=has_model_ssim}Monograph,#{Hyrax.config.collection_class}")
.to contain_exactly("{!terms f=has_model_ssim}Monograph,#{Hyrax.collection_classes.join(',')}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@no-reply This line is modified in PR #5229. Since this test passes with the change here, I'm not sure how the test passes in 5229 without including collection classes. Any thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5229 is designed to make this pass in the context of #5169. it still tests the same behavior, just using a different approach that tests separately for each class we want to see included.

This centralizes the list of collection classes to `Hyrax.config.collection_classes`.
Places where any collection class could be input or processing occurs across all collection classes were updated to use `Hyrax.config.collection_classes`.  Remaining single references to `::Collection` were updated to `Hyrax.config.collection_class`.  These changes allow for almost all remaining uses of `::Collection` to be removed.

Exceptions:
* work_form which is only used with ActiveFedora
* `PermissionTemplate #collection` which is deprecated and only works with `::Collection`
* `Hyrax::Collections::MigrationService` which performs a migration dependent on reading in the collection as a `::Collection`
@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had activity for 30 days. It will be closed if no further activity occurs within 14 days. Thank you for your contributions.

@stale stale bot added the stale label Jan 9, 2022
@elrayle elrayle removed the stale label Jan 12, 2022
Copy link
Member

@cjcolvar cjcolvar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good change to me. Is it still relevant? How bad of a rebase will it be to bring this up to date?

@@ -3,7 +3,7 @@
<td></td>
<td>
<div class="media">
<span class="<%= Hyrax::ModelIcon.css_class_for(::Collection) %> collection-icon-small pull-left"></span>
<span class="<%= Hyrax::ModelIcon.css_class_for(Hyrax.config.collection_class) %> collection-icon-small pull-left"></span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be changed like the change in app/views/hyrax/collections/_media_display.html.erb?

Suggested change
<span class="<%= Hyrax::ModelIcon.css_class_for(Hyrax.config.collection_class) %> collection-icon-small pull-left"></span>
<span class="<%= collection_model_icon %> collection-icon-small pull-left"></span>

@@ -24,6 +24,13 @@ def available_parent_collections_data(collection:)
end.to_json
end

##
# @since 3.1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated to 3.4.0?

Suggested change
# @since 3.1.0
# @since 3.4.0

@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had activity for 30 days. It will be closed if no further activity occurs within 14 days. Thank you for your contributions.

@stale stale bot added the stale label Apr 17, 2022
@stale stale bot closed this May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants