diff --git a/README.md b/README.md index d555ba6..6d3cc7c 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,24 @@ # Child Publisher -An ArchivesSpace plugin that adds the ability to publish and unpublish all child records of an archival object. +An ArchivesSpace plugin that adds the ability to publish and unpublish all child +records of an archival object. -Developed against ArchivesSpace v2.4.0 by Hudson Molonglo for Yale University. +Developed against ArchivesSpace v2.7.1 by Hudson Molonglo for Yale University. ## Summary -Two new options are available in the `More` menu on the component toolbar for components that have children - `Publish this and all children` and `Unpublish all children`. When selected, all child components of the current component will be published or unpublished respectively. +Two new options are available in the `More` menu on the component toolbar for +components that have children - `Publish this and all children` and +`Unpublish all children`. When selected, all child components of the current +component will be published or unpublished respectively. -In the case of publication the current record is also published. When unpublishing the published state of the current component and its nested records is unchanged. +In the case of publication the current record is also published. When +unpublishing the published state of the current component and its nested records +is unchanged. -The published state of some `Note` records attached to child components is also unchanged. +The published state of some `Note` records attached to child components is also +unchanged. Currently, this filtering is not configurable. @@ -20,28 +27,20 @@ Currently, this filtering is not configurable. Follow standard ArchivesSpace plugin installation procedures. -This plugin is not dependent on any additional gems, does not require any database migrations, and does not override any existing templates. - -It does override some backend methods, see below. +This plugin is not dependent on any additional gems, does not require any +database migrations, and does not override any existing templates. ## Customization -To enable the filtering mentioned above this plugin overrides two backend methods, namely: - - - `ObjectGraph.calculate_object_graph(object_graph, opts = {})` - - `Notes.calculate_object_graph(object_graph, opts = {})` - -These methods have been changed to accept `opts` keyed on a model with a value that is a Sequel dataset on that model. They allow for filtering of nested records and notes respectively. - -There are other implementations of `calculate_object_graph(object_graph, opts = {})` that have not yet been overridden to support filtering with opts like this - the goal was to override as little as possible. - -To customize the filtering behavior, call `ChildPublishing.add_filter(filter)`. For example: +To customize the filtering behavior, call `ChildPublishing.add_filter(filter)`. +For example: ```ruby # turn off the default note filtering ChildPublishing.add_filter(Note) ``` -See [here](https://github.com/hudmol/child_publisher/blob/master/backend/plugin_init.rb) for the call that sets the Note filter. +See [here](https://github.com/hudmol/child_publisher/blob/master/backend/plugin_init.rb) +for the call that sets the Note filter. diff --git a/backend/model/ASModel_object_graph.rb b/backend/model/ASModel_object_graph.rb deleted file mode 100644 index 3551d4a..0000000 --- a/backend/model/ASModel_object_graph.rb +++ /dev/null @@ -1,29 +0,0 @@ -module ObjectGraph - module ClassMethods - - def calculate_object_graph(object_graph, opts = {}) - - object_graph.models.each do |model| - next unless model.respond_to?(:nested_records) - model.nested_records.each do |nr| - association = nr[:association] - - if association[:type] != :many_to_many - nested_model = Kernel.const_get(association[:class_name]) - - ids = (opts[nested_model] || nested_model).filter(association[:key] => object_graph.ids_for(model)). - select(:id).map {|row| - row[:id] - } - - object_graph.add_objects(nested_model, ids) - end - end - end - - object_graph - end - - end - -end diff --git a/backend/model/mixins/notes.rb b/backend/model/mixins/notes.rb deleted file mode 100644 index a38d958..0000000 --- a/backend/model/mixins/notes.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Notes - module ClassMethods - def calculate_object_graph(object_graph, opts = {}) - super - - column = "#{self.table_name}_id".intern - - ids = (opts[Note] || Note).filter(column => object_graph.ids_for(self)). - map {|row| row[:id]} - - object_graph.add_objects(Note, ids) - end - end -end