samvera / active_fedora

A Rails interface to the Fedora repository, akin to ActiveModel
Other
54 stars 63 forks source link

Should ActiveFedora implement LDP containment principles? #782

Open awead opened 9 years ago

awead commented 9 years ago

What if you could do:

class SomeItems < ActiveFedora:Base
  has_direct_container Box
end
class Box < ActiveFedora:Base
  is_direct_container_for SomeItems, membership: :hasItems
end

And then have similar methods, has_basic_container and has_indirect_container.

awead commented 9 years ago

See also #714

awead commented 9 years ago

This would refactor/replace #780

no-reply commented 9 years ago

:+1: on something like this.

tpendragon commented 9 years ago

:+1: This would be great, and was something I was looking to put in activefedora-aggregations, but I think you're right that it belongs here.

cbeer commented 9 years ago

:+1: to doing it, but the example code does't look right to me. I'm also not sure the thing-that-contains-containers needs to know what type of container it has, does it?

tpendragon commented 9 years ago

@cbeer Seems like that's the case where you'd want it to know, so that it could initialize the container on creation.

I don't really understand what is_direct_container_for does, though.

awead commented 9 years ago

@terrellt @cbeer Yeah, that was just a mock-up, so my code example is probably wrong. I wondered if we needed is_direct_container_for as well and now thinking on it more it seems unnecessary.

tpendragon commented 9 years ago

I think a good start would be

class GenericFile < ActiveFedora::Base
   has_direct_container :files, :member_relation => RDF::DC.hasPart
end

Which will spin up a /files direct container on save with a MemberRelation of RDF::DC.hasPart and a membershipResource of GenericFile's #id, when it's created.

I think has_ implies that the membershipResource is the containing resource, but maybe i'm wrong? It seems like if it's not then the statement would sit somewhere else.

cbeer commented 9 years ago

@terrellt :+1:

awead commented 9 years ago

@terrellt yep!

awead commented 9 years ago

This has been implemented in: 3facdba2b7a07cebde590bdbce976b376d0f8e76 (direct containers) 7a36f432ef2023b0fce0a876d29d72aefc596b44 (indirect containers)