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

Add filters_association that allow specification of multiple parts within an aggregation #45

Closed
elrayle opened this issue Jul 13, 2015 · 1 comment
Assignees

Comments

@elrayle
Copy link
Contributor

elrayle commented Jul 13, 2015

Reference: https://github.com/projecthydra-labs/hydra-pcdm/wiki/Proposed-Interfaces#defining-an-aggregation-with-multiple-filters

Example definition:

aggregates :members, predicate: RDFVocabularies::PCDMTerms.hasMember,
           class_name: "ActiveFedora::Base"

filters_association :members, as: :child_objects, condition: :pcdm_object?
filters_association :members, as: :child_collections, condition: :pcdm_collection?

By defining a filters_association, you get the following methods defined that provide getters/setters with the method name in as: and validation using the method specified in condition:.

child_objects=    # validate with pcdm_object?
child_objects+=   # validate with pcdm_object?
child_objects<<   # validate with pcdm_object?
child_objects     # filter to return only objects

child_collections=    # validate with pcdm_collection?
child_collections+=   # validate with pcdm_collection?
child_collections<<   # validate with pcdm_collection?
child_collections     # filter to return only collections

members=    # validate with pcdm_object and pcdm_collection?
members+=   # validate with pcdm_object and pcdm_collection?
members<<   # validate with pcdm_object and pcdm_collection?
members     # return everything in the aggregation
@elrayle
Copy link
Contributor Author

elrayle commented Jul 13, 2015

Deleting objects also needs to be taken into consideration.

child_objects.delete obj              # delete first occurrence of obj
child_objects.delete obj, nth         # delete nth occurrence of obj relative to the filtered list of child_objects

child_collections.delete col          # delete first occurrence of col
child_collections.delete col, nth     # delete nth occurrence of col relative to the filtered list of child_collections

members.delete obj          # delete first occurrence of obj
members.delete obj, nth     # delete nth occurrence of obj relative to all members
members.delete col          # delete first occurrence of col
members.delete obj, nth     # delete nth occurrence of col relative to all members

See also #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants