Closed escowles closed 8 years ago
I'm not sure why Coveralls thinks two lines aren't covered — there are explicit tests for them: https://github.com/projecthydra/hydra-pcdm/blob/d60390af942403daa554e460d2e6ada7efb76d95/spec/hydra/pcdm/models/object_spec.rb#L23 https://github.com/projecthydra/hydra-pcdm/blob/d60390af942403daa554e460d2e6ada7efb76d95/spec/hydra/pcdm/models/object_spec.rb#L538
Hi Esme, Thanks for the great presentation at Cornell last week. I have a question about member_of. I am able through the rails console to create a FileSet < ActiveFedora::Base include ::CuractionConcerns::FileSetBehavior object and a Page < ActiveFedora::Base include ::CurationConcerns::WorkBehavior object that I can then do a FileSet.member_of << Book FileSet.save in the rails console and it persists. However if I try to create a Book < ActiveFedora include ::CurationConcerns::WorkBehavior object and do a Page.member_of << Book in the console it returns without an error, but when I save and then do Page.member_of I get [] no persistence. Any ideas?
@jac244 Are you sure it returns without an error? Adding a Work as a member_of_collections
and saving should return false, and you should see a validation error in page.errors
. This line defines the validator that checks that member_of_collections
is only used to link to Collections:
https://github.com/projecthydra/hydra-pcdm/pull/227/files#diff-b15145c2b5c6d3acb3a84cd517d09a8dR27
The rationale for this validator is that the member_of relationship makes an unordered list of members. But members of a Work are typically ordered. They can be accessed without order for the times when it's not important what order they are in. But most of the use cases I know of for child Works are ordered. Do you have a use for unordered child Works?
Hi Esmé,
I am not calling member_of_collections. Below is a more detailed explanation of what I am doing as posted in hydra-tech google groups.
I have a FileSet object declared as:
class FileSet < ActiveFedora::Base include ::CurationConcerns::FileSetBehavior
and a Page object declared as:
class Page < ActiveFedora::Base include ::CurationConcerns::WorkBehavior include ::BasicMetadata include ::RequiredMetadata
I have previously created objects and when I access them in the rails console using p = Page.find(pid) and fs = FileSet.find(pid), and then assign fs.member_of << p and then fs.save everything works as expected. Closing the console and then restarting and doing fs = FileSet.find(pid) and then fs.member_of returns the membership as it should.
However... I also have Book objects declared as:
class Book < ActiveFedora::Base include ::CurationConcerns::WorkBehavior include ::BasicMetadata include ::RequiredMetadata include ::CollectionIndexing
So when I try in the console to do a b = Book.find(pid), p = Page.find(pid), p.member_of << b the console returns with the Book object in [ ]. I then do p.save and the console returns >true. Unfortunately when I then do p.member_of the console returns > [ ].
Anyone know why this is the case? Is it because of the difference between CurationsConcerns::FileSetBehavior and CurationsConcerns::WorkBehavior?
I tried adding the CurationsConcerns::FileSetBehavior to the Page object but that resulted in a SystemStackError: stack level too deep
Thanks in advance for any help.
From: Esmé Cowles notifications@github.com Sent: Friday, August 12, 2016 11:26 AM To: projecthydra/hydra-pcdm Cc: John A. Cline; Mention Subject: Re: [projecthydra/hydra-pcdm] Adding #member_of_collections (#227)
@jac244https://github.com/jac244 Are you sure it returns without an error? Adding a Work as a member_of_collections and saving should return false, and you should see a validation error in page.errors. This line defines the validator that checks that member_of_collections is only used to link to Collections.
The rationale for this validator is that the member_of relationship makes an unordered list of members. But members of a Work are typically ordered. They can be accessed without order for the times when it's not important what order they are in. But most of the use cases I know of for child Works are ordered. Do you have a use for unordered child Works?
You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/projecthydra/hydra-pcdm/pull/227#issuecomment-239477251, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AELxVnP4i9gH0R3P7Y40eQP5IaX1Vd8Vks5qfJChgaJpZM4JXJJq.
:+1: looking at the coveralls thing, just in case that's a red flag; will merge in a moment.