Class: AtlasRb::Community
- Defined in:
- lib/atlas_rb/community.rb
Overview
A top-level grouping in the Atlas hierarchy.
Communities are organizational containers — they hold Collections and, optionally, sub-Communities. Most institutional structure (departments, programs, projects) is modeled as a tree of Communities with Collections at the leaves.
See also: Collection, Work.
Constant Summary collapse
- ROUTE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Atlas REST endpoint prefix for this resource.
"/communities/"
Constants inherited from Resource
Constants included from FaradayHelper
FaradayHelper::ASSERTION_AUDIENCE, FaradayHelper::ASSERTION_ISSUER, FaradayHelper::ASSERTION_TTL, FaradayHelper::INSTRUMENTATION_EVENT
Class Method Summary collapse
-
.children(id, nuid: nil, on_behalf_of: nil) ⇒ Array<String>?
List the immediate children (sub-Communities and Collections) of a Community.
-
.create(id = nil, xml_path = nil, nuid: nil, on_behalf_of: nil, depositor: nil) ⇒ Hash
Create a new Community, optionally seeded with MODS metadata.
-
.find(id, nuid: nil, on_behalf_of: nil) ⇒ Hash?
Fetch a single Community by ID.
-
.mods(id, kind = nil, nuid: nil, on_behalf_of: nil) ⇒ String?
Fetch the Community's MODS representation in the requested format.
Methods inherited from Resource
class_for, descendant_works, find_many, history, mods_version, mods_versions, permissions, preview, put_mods, reparent, set_permissions, set_thumbnails, tombstone
Methods included from FaradayHelper
#connection, #multipart, #read_body, #read_raw, #system_connection, #with_file_part
Class Method Details
.children(id, nuid: nil, on_behalf_of: nil) ⇒ Array<String>?
List the immediate children (sub-Communities and Collections) of a Community.
The endpoint returns just the noids; resolve each through Resource.find (which dispatches by type) when richer payloads are needed.
children answers noids only. To render them, resolve the whole list in
one call with Resource.find_many, which returns a
title/thumbnail digest per id — calling find per noid costs a
round-trip per child. For a whole subtree flattened to Works, use
Resource.descendant_works.
120 121 122 |
# File 'lib/atlas_rb/community.rb', line 120 def self.children(id, nuid: nil, on_behalf_of: nil) read_body(connection({}, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id + '/children')) end |
.create(id = nil, xml_path = nil, nuid: nil, on_behalf_of: nil, depositor: nil) ⇒ Hash
Create a new Community, optionally seeded with MODS metadata.
Pass id = nil to create a top-level Community; pass a Community ID to
nest the new Community beneath an existing one.
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/atlas_rb/community.rb', line 77 def self.create(id = nil, xml_path = nil, nuid: nil, on_behalf_of: nil, depositor: nil) params = { parent_id: id } params[:depositor] = depositor if depositor result = AtlasRb::Mash.new(write_resource( connection(params, nuid, on_behalf_of: on_behalf_of).post(ROUTE) ))["community"] return result if xml_path.to_s.empty? # The MODS seed is a second call: create takes the parent and the # provenance slots, and the document goes through the write that owns it. AtlasRb::Resource.put_mods(result["id"], xml_path, nuid: nuid, on_behalf_of: on_behalf_of) find(result["id"], nuid: nuid, on_behalf_of: on_behalf_of) end |
.find(id, nuid: nil, on_behalf_of: nil) ⇒ Hash?
Fetch a single Community by ID.
34 35 36 37 |
# File 'lib/atlas_rb/community.rb', line 34 def self.find(id, nuid: nil, on_behalf_of: nil) body = fetch_resource(ROUTE + id, nuid: nuid, on_behalf_of: on_behalf_of) body && AtlasRb::Mash.new(body)["community"] end |
.mods(id, kind = nil, nuid: nil, on_behalf_of: nil) ⇒ String?
Fetch the Community's MODS representation in the requested format.
146 147 148 149 150 151 |
# File 'lib/atlas_rb/community.rb', line 146 def self.mods(id, kind = nil, nuid: nil, on_behalf_of: nil) # json default, html, xml read_raw(connection({}, nuid, on_behalf_of: on_behalf_of).get( ROUTE + id + '/mods' + (kind.to_s.empty? ? '' : ".#{kind}") )) end |