-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop digitization_work_order plugin requirement by including all the …
…bits we need
- Loading branch information
Showing
12 changed files
with
1,654 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Placeholder | ||
ASpaceGems.setup if defined? ASpaceGems | ||
|
||
gem "write_xlsx", "1.01.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class BulkUpdaterSmallTree | ||
|
||
def self.for_resource(resource_id) | ||
Resource.get_or_die(resource_id).bulk_updater_quick_tree | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
module Trees | ||
def bulk_updater_quick_tree | ||
links = {} | ||
properties = {} | ||
|
||
root_type = self.class.root_type | ||
node_type = self.class.node_type | ||
|
||
top_nodes = [] | ||
|
||
container_info = bulk_updater_fetch_container_info | ||
|
||
query = build_node_query | ||
|
||
offset = 0 | ||
loop do | ||
nodes = query.limit(NODE_PAGE_SIZE, offset) | ||
|
||
nodes.each do |node| | ||
if node.parent_id | ||
links[node.parent_id] ||= [] | ||
links[node.parent_id] << [node.position, node.id] | ||
else | ||
top_nodes << [node.position, node.id] | ||
end | ||
|
||
properties[node.id] = { | ||
:title => node.display_string, | ||
:uri => self.class.uri_for(node_type, node.id), | ||
:ref_id => node[:ref_id], | ||
:component_id => node[:component_id], | ||
:container => container_info.fetch(node.id, nil), | ||
} | ||
|
||
# Drop out nils to keep the object size as small as possible | ||
properties[node.id].keys.each do |key| | ||
properties[node.id].delete(key) if properties[node.id][key].nil? | ||
end | ||
end | ||
|
||
if nodes.empty? | ||
break | ||
else | ||
offset += NODE_PAGE_SIZE | ||
end | ||
end | ||
|
||
result = { | ||
:title => self.title, | ||
:identifier => Identifiers.format(Identifiers.parse(self.identifier)), | ||
:children => top_nodes.sort_by(&:first).map {|_, node| self.class.assemble_tree(node, links, properties)}, | ||
:uri => self.class.uri_for(root_type, self.id) | ||
} | ||
|
||
result | ||
end | ||
|
||
|
||
private | ||
|
||
def bulk_updater_containers_ds | ||
TopContainer.linked_instance_ds | ||
.join(:archival_object, :id => :instance__archival_object_id) | ||
.left_join(:enumeration_value___top_container_type, :id => :top_container__type_id) | ||
.left_join(:enumeration_value___sub_container_type_2, :id => :sub_container__type_2_id) | ||
.left_join(:enumeration_value___sub_container_type_3, :id => :sub_container__type_3_id) | ||
.filter(:archival_object__root_record_id => self.id) | ||
.select(Sequel.as(:archival_object__id, :archival_object_id), | ||
Sequel.as(:top_container__barcode, :top_container_barcode), | ||
Sequel.as(:top_container_type__value, :top_container_type), | ||
Sequel.as(:top_container__indicator, :top_container_indicator), | ||
Sequel.as(:sub_container_type_2__value, :sub_container_type_2), | ||
Sequel.as(:sub_container__indicator_2, :sub_container_indicator_2), | ||
Sequel.as(:sub_container_type_3__value, :sub_container_type_3), | ||
Sequel.as(:sub_container__indicator_3, :sub_container_indicator_3)) | ||
end | ||
|
||
|
||
def bulk_updater_fetch_container_info | ||
result = {} | ||
|
||
bulk_updater_containers_ds.each do |row| | ||
result[row[:archival_object_id]] = [ | ||
# BoxType Indicator [Barcode] | ||
[row[:top_container_type], | ||
row[:top_container_indicator], | ||
row[:top_container_barcode] ? ('[' + row[:top_container_barcode] + ']') : nil].compact.join(': '), | ||
|
||
# BoxType_2 Indicator_2 | ||
[row[:sub_container_type_2], row[:sub_container_indicator_2]].compact.join(': '), | ||
|
||
# BoxType_3 Indicator_3 | ||
[row[:sub_container_type_3], row[:sub_container_indicator_3]].compact.join(': '), | ||
].reject(&:empty?).join(', ') | ||
end | ||
|
||
result | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.