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

Use class methods for Valkyrie model duck‐typing #6421

Merged
merged 3 commits into from
Nov 8, 2023
Merged

Conversation

marrus-sh
Copy link
Collaborator

@marrus-sh marrus-sh commented Nov 7, 2023

It may be necessary to determine whether a model class represents a PCDM Object, File Set, etc, not just a model instance. This commit defines the former and aliases and deprecates the latter.

collection? and pcdm_collection? are split, in that Hyrax::AdministrativeSet and Hyrax::PcdmCollection are both the former, but not both the latter. Is this right, or should those methods be synonyms? They’re effectively synonyms now.

work? is an alias for pcdm_object? & !file_set?.

Hyrax::PcdmCollection used to think it was a pcdm_object?, but it shouldn’t have.

There’s probably a fair amount of model.try(:work?) which needs to be changed to model.class.try(:work?) || model.try(:work?) before the old methods can be removed. We’ll need to support both for as long as we support ActiveFedora, but normalizing on a single place for querying this information, and having that place be the model class, seemed desirable for Valkyrie resources. For the time being, we’ll just support both.

Notably, this enables the use of these methods for determining which form or indexer to use for a class of resource, instead of relying on class inheritance checks.

@no-reply
Copy link
Contributor

no-reply commented Nov 7, 2023

This commit defines the former and aliases and deprecates the latter.

why deprecate and not just keep them?

@no-reply
Copy link
Contributor

no-reply commented Nov 7, 2023

collection? and pcdm_collection? are split, in that Hyrax::AdministrativeSet and Hyrax::PcdmCollection are both the former, but not both the latter. Is this right, or should those methods be synonyms?

i think Admin Sets are ambiguous at the abstract model layer. initially, they were introduced without reference to any PCDM or Hydra::Works concepts. the Collections Extensions work effort later tried (incompletely) to wrap them into the Collection Types concept; so an Admin Set would be "just" a Collection with a certain Collection Type.

i can't see any downsides to treating AdministrativeSet instances as pcdm:Collections, and would suggest we move formally in that direction going forward, but it may be appropriate for @dlpierce, @rjkati, and @samvera/hyrax-metadataists to weigh in?

@marrus-sh
Copy link
Collaborator Author

i can't see any downsides to treating AdministrativeSet instances as pcdm:Collections, and would suggest we move formally in that direction going forward

the (extremely slight) conceptual convenience to treating them separately is that they use different forms. but it’s easy enough to just check if something is an admin set first, prior to checking if it is a PCDM collection

@marrus-sh
Copy link
Collaborator Author

This commit defines the former and aliases and deprecates the latter.

why deprecate and not just keep them?

Honestly I was going back and forth about this; it seemed kind of weird to have both (considering that it would be unexpected if they disagreed), but the convenience might outweigh those concerns. They can’t be removed in the near term regardless, so I guess it just depends whether removing them in the long term is desirable or not. (If so, it seems better to start issuing deprecation warnings as soon as possible.)

@marrus-sh marrus-sh force-pushed the valkyrie_duck branch 2 times, most recently from 5b873ec to 00d6c2a Compare November 8, 2023 00:05
@marrus-sh
Copy link
Collaborator Author

@no-reply just pushed two additional commits:

  • remove the deprecation on the instance methods but add tests to the shared specs that they match the default implementation

  • make AdministrativeSet return true for pcdm_collection?

It may be necessary to determine whether a model *class* represents a
PCDM Object, File Set, etc, not just a model *instance*. This commit
defines the former and aliases and deprecates the latter.

`collection?` and `pcdm_collection?` are split, in that
`Hyrax::AdministrativeSet` and `Hyrax::PcdmCollection` are both the
former, but not both the latter. Is this right, or should those
methods be synonyms?

`work?` is an alias for `pcdm_object? & !file_set?`.

`Hyrax::PcdmCollection` used to think it was a `pcdm_object?`, but it
shouldn’t have.

There’s probably a fair amount of `model.try(:work?)` which needs to be changed
to `model.class.try(:work?) || model.try(:work?)` before the old methods can be
removed. We’ll need to support both for as long as we support ActiveFedora, but
normalizing on a single place for querying this information, and having that
place be the model class, seemed desirable for Valkyrie resources.

Notably, this enables the use of these methods for determining which form or
indexer to use for a class of resource, instead of relying on class inheritance
checks.
In discussion, it sounded like deprecating these wasn’t worth it.
Instead, add tests to the `Hyrax::Resource` shared examples to affirm
that the instance and class methods match for all of these values.
It seems like there has been an attempt to consider administrative sets
as kinds of collections in the PCDM model, and we should push ahead with
that going forward.

This means that `:collection?` and `:pcdm_collection?` are effectively
synonyms. I prefer the latter (because it mirrors `:pcdm_object?`), but
it’s new and most Hyrax code currently uses the former.
@no-reply no-reply merged commit 43a77c9 into main Nov 8, 2023
4 checks passed
@no-reply no-reply deleted the valkyrie_duck branch November 8, 2023 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants