-
Notifications
You must be signed in to change notification settings - Fork 124
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
Orders members when converting to AF objects. #3697
Conversation
@@ -81,6 +81,10 @@ | |||
it 'converts member_of_collection_ids back to af_object' do | |||
expect(converter.convert.members.map(&:id)).to match_array [work2.id, work3.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.
If you want to demonstrate the difference between members and ordered_members, you can use match_array here and reverse the order of the ids...
expect(converter.convert.members.map(&:id)).to match_array [work3.id, work2.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.
👍
@@ -81,6 +81,10 @@ | |||
it 'converts member_of_collection_ids back to af_object' do | |||
expect(converter.convert.members.map(&:id)).to match_array [work2.id, work3.id] | |||
end | |||
|
|||
it 'preserves order across conversion' do | |||
expect(converter.convert.ordered_member_ids).to match_array [work2.id, work3.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.
And this should use .to eq
expect(converter.convert.ordered_member_ids).to eq [work2.id, work3.id]
This confirms the order is maintained.
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.
👍
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 change to members is a suggestion. The changed to ordered_members is needed to ensure that order was maintained.
dff6a08
to
f7dba2d
Compare
6588fea
to
fcad364
Compare
Exploring the fileset failures...
What is not clear is why this did not happen before this branch and does with this branch. What is also not clear is why wk2 is repeated, but wk1 is not. A simple fix would be to apply |
1850669
to
23784d7
Compare
Since Hyrax is only interested in one direction, changed parent_works in Hyrax to not depend on parent_works in Hydra::Works. This fixes the problem where parent_works for works and filesets was returning repeated parents. |
8c4d907
to
dff2606
Compare
This solves issues with unordered members not being ordered at all after conversion.
Use a stricter test for the array returned from #ordered_member_ids
related to #3698
Otherwise, during the transformation back and forth, the members could be put on the transformed resource in the wrong order. This fixes a randomly failing condition. Changed wings tests to use ordered_members since that is the relationship used in hyrax.
dff2606
to
6dc3627
Compare
end | ||
|
||
# @param valkyrie [Boolean] Should the returned ids be for Valkyrie or AF objects? | ||
# @return [Enumerable<String> | Enumerable<Valkerie::ID] The ids of the file sets this work contains |
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.
Comment should be rewritten # @return [Enumerable<String> | Enumerable<Valkyrie::ID>] The ids of the file sets this work contains
# # @return [Enumerable<String> | Enumerable<Valkerie::ID] The ids of the works this work is in | ||
# def parent_work_ids(valkyrie: false) | ||
# parent_works(valkyrie: valkyrie).map(&:id) | ||
# end |
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 commented block needs to be removed.
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 can clean the comments, but otherwise this seems to be an excellent solution.
…havior; Fixing a typo. error in the comment for Wings::Pcdm::PcdmValkyrieBehavior#parent_work_ids
Fixes a random error in find_members test where sometimes the results are in the correct order and sometimes not.
a6163ac
to
0532405
Compare
@@ -139,7 +139,7 @@ def parent_works(valkyrie: false) | |||
end | |||
|
|||
# @param valkyrie [Boolean] Should the returned ids be for Valkyrie or AF objects? | |||
# @return [Enumerable<String> | Enumerable<Valkyrie::ID>] The ids of the file sets this work contains | |||
# @return [Enumerable<String> | Enumerable<Valkerie::ID>] The ids of the works this work is contained in |
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.
Valkerie?
Adding members via
#members=
does not add the member to the ordered relation, so that after a save,#member_ids
contains objects, but#ordered_member_ids
is empty. Since many parts of the code use#ordered_members
, the converter should order the members.