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

Implement Valkyrie native Collections as PcdmCollection #4076

Merged
merged 4 commits into from
Oct 17, 2019

Conversation

no-reply
Copy link
Contributor

Add a PCDM style collection in native Valkyrie, with support for
membership. Extract Work membership tests into shared examples for use across
PCDM/Works models.

We name the Collection model Hyrax::PcdmCollection to avoid application layer
collisions with ::Collection when referring to it from a Hyrax module. That
is: we don't want to introduce a Hyrax::Collection without warning adopters.

@samvera/hyrax-code-reviewers

Tom Johnson added 4 commits October 14, 2019 17:20
Add a PCDM style collection in native Valkyrie, with support for
membership. Extract Work membership tests into shared examples for use across
PCDM/Works models.

We name the Collection model `Hyrax::PcdmCollection` to avoid application layer
collisions with `::Collection` when referring to it from a Hyrax module. That
is: we don't want to introduce a `Hyrax::Collection` without warning adopters.
`Schema` is a base level dependency for much of Hyrax post-Valkyrie, so putting
it in `lib` seems to make sense. This makes it easy to require independently
when it needs to be used in, e.g. `Wings`.
Collections in Hyrax need a collection type. We link them to a `GlobalID` for a
`CollectionType` using `#collection_type_gid`. This closely mirrors the old
`Hyrax::CollectionBehavior` approach.
Setup a mapping between `Hyrax::PcdmCollection` and `::Collection` for use in
Wings adapters.

Introduce a `:hyrax_collection` factory with some basic membership accessors.
Copy link
Contributor

@hweng hweng left a comment

Choose a reason for hiding this comment

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

It looks good to me.
Is this your intention to keep the model as short as only include attributes?

Can i know what's our plan for those callbacks, validation, indexer, member_object methods and permission templates, as well as those mixins modules in collection_behavior.rb?

@hweng
Copy link
Contributor

hweng commented Oct 15, 2019

Are we planning to use dry-transactions + pub/sub style for callbacks?and push indexer, member_object, permission templates to app/services/hyrax/collection? Correct me if i am wrong.

include Hyrax::Schema(:core_metadata)

attribute :collection_type_gid, Valkyrie::Types::String
attribute :member_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID).meta(ordered: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that fine to add collection_type, collection_type= in the model?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't supply a collection_type setter without the _gid suffix in the current CollectionBehavior implementation. There is a ticket to refine that implementation, though it might be a wontfix until after the ActiveFedora behavior is removed.

I'm not necessarily against putting them in now, but I'm a bit worried about the impact on Wings. Keeping symmetry between Valkyrie and ActiveFedora properties simplifies things a bit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha. Sounds reasonable.

@no-reply
Copy link
Contributor Author

Is this your intention to keep the model as short as only include attributes?

That's my notion, yes. Attributes and code explicitly involved in managing them.

Obviously, we inherit Valkyrie::Resource so other code directly impacting the concerns is bundled there (e.g. Draper decoration, we choose to use it). Is this your intention to keep the model as short as only include attributes?

@no-reply
Copy link
Contributor Author

Are we planning to use dry-transactions + pub/sub style for callbacks?and push indexer, member_object, permission templates to app/services/hyrax/collection? Correct me if i am wrong.

Indexing is already a separate service in Hyrax (see: app/indexers), though there's some work we need to do to figure out the ideal approach for Valkyrie. see: samvera/valkyrie#598

I think not dry-transaction, since development has been discontinued. I'm playing with its replacement at https://github.com/samvera/hyrax/compare/transaction-to-monads. That's one pattern we could consider using.


Re: Callbacks, I think this might be a bit case-by-case.

The Do notation approach above could probably be used for many of these cases. the Figgy-style ChangeSetPersister approach is probably also worth considering. For some callbacks (e.g. those in Hyrax.config.callback), dry-events style pub-sub seem good.

For others (e.g. those in CollectionNesting), just an external service that needs to be called explicitly (and only sometimes) is probably fine.


Membership is already handled here. I'm not sure what else is needed on this front. Any ideas?


Permissions are handled by Hyrax::AccessControl and Hyrax::AccessControlList, while template application is also an external service in Hyrax already. I think some further work on admin sets and permission templates in native Valkyrie is still called for.


@hweng does this help answer your questions? I realize there's still a lot to decide here, but I think it's best to take these things one at a time.

@hweng
Copy link
Contributor

hweng commented Oct 16, 2019

@no-reply Your approach https://github.com/samvera/hyrax/compare/transaction-to-monads looks good to me.

Regarding the callbacks, do you consider to add them as steps in Transactions?
For instance, save lib/hyrax/transactions/steps/save.rb

module Hyrax
  module Transactions
    module Steps
       class Save
         include Dry::Monads[:result]

         step :before_save
         Step :call
         step :after_save

        def before_save(&block); end 
    
        def after_save(&block); end 
        .....

Or if you have any concern about it?

@hweng
Copy link
Contributor

hweng commented Oct 16, 2019

Regarding the Permissions:

There are some local Permissions code in collection_behavior.rb and admit_set.rb, do you think it is safe to remove or should put it somewhere?
https://github.com/samvera/hyrax/blob/master/app/models/concerns/hyrax/collection_behavior.rb#L131-L162

@hweng
Copy link
Contributor

hweng commented Oct 16, 2019

For Membership, Do we still want to keep these methods add_member_objects, member_objects:

https://github.com/samvera/hyrax/blob/master/app/models/concerns/hyrax/collection_behavior.rb#L55-L83

module Hyrax
##
# Valkyrie model for Collection domain objects in the Hydra Works model.
class PcdmCollection < Hyrax::Resource
Copy link
Contributor

Choose a reason for hiding this comment

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

I am concerned that we are establishing inconsistent naming of the Works Model classes. See my comments in PR #4084 RE: name of PcdmFileSet

https://github.com/samvera/hyrax/pull/4084/files/a5ab3ca30ca078c8c4ced3da56f5ff6c9b9922d9#r335705853

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my follow-up on the linked discussion.

@hweng
Copy link
Contributor

hweng commented Oct 17, 2019

@no-reply This PR looks good to me. I agree with you that there is still a lot to decide, might be best to discuss in the separate tickets.

@no-reply no-reply merged commit 3a02960 into master Oct 17, 2019
@no-reply no-reply deleted the native-collection branch October 17, 2019 20:55
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.

4 participants