class Dgrid::API::Workspace::Backup_0_2
¶ ↑
Public Class Methods
backed_up_classes()
click to toggle source
# File lib/dgrid/api/workspace.rb, line 464 def self.backed_up_classes self.entity_classes end
entity_classes()
click to toggle source
# File lib/dgrid/api/workspace.rb, line 458 def self.entity_classes # This is the only real difference between versions 0_1 and 0_2 # Incident promoted to base-level entity and Keywords added. @@entity_classes ||= predecessor.entity_classes + [Incident, Keyword] end
Protected Class Methods
predecessor()
click to toggle source
# File lib/dgrid/api/workspace.rb, line 484 def self.predecessor Backup_0_1 end
Public Instance Methods
migrate_from_predecessor(predecessor)
click to toggle source
# File lib/dgrid/api/workspace.rb, line 468 def migrate_from_predecessor(predecessor) pred_entity_classes = Set.new(predecessor.class.entity_classes) self.class.entity_classes.each do |entity_class| if pred_entity_classes.include?(entity_class) pred_entities = predecessor.get_entities_hash(entity_class) set_entities_hash(my_entity_class,pred_entities.clone) end end if self.incidents_are_entities? && !pred_entity_classes.include?(Incident) migrate_item_subord_incidents_to_entity_incidents(predecessor) end end
Private Instance Methods
ensure_links_include_item_incident(links_hash,item_id,incident_id)
click to toggle source
# File lib/dgrid/api/workspace.rb, line 506 def ensure_links_include_item_incident(links_hash,item_id,incident_id) if !links_include_relationship_between(links_hash,Item,item_id,Incident,incident_id) new_link_id = generate_new_link_id links_hash[new_link_id] = { :left_type => Item.name, :left_guid => item_id, :right_type => Incident.guid, :right_id => incident_id, :description => 'item-incident' } end end
links_include_relationship_between(links_hash,type1,guid1,type2,guid2)
click to toggle source
# File lib/dgrid/api/workspace.rb, line 518 def links_include_relationship_between(links_hash,type1,guid1,type2,guid2) links_hash.values.any? { |link| (link[:left_type] == type1 && link[:left_guid] == guid1 && link[:right_type] == type2 && link[:right_guid] == guid2) || (link[:right_type] == type1 && link[:right_guid] == guid1 && link[:left_type] == type2 && link[:left_guid] == guid2) } end
migrate_item_subord_incidents_to_entity_incidents(predecessor)
click to toggle source
# File lib/dgrid/api/workspace.rb, line 493 def migrate_item_subord_incidents_to_entity_incidents(predecessor) pred_item_ids = predecessor.get_entities_hash(Item).keys incidents_hash = {} links_hash = get_entities_hash(Link) pred_item_ids.each do |item_id| item_incidents = incidents(item_id) item_incidents.each_pair do |incident_id,incident_params| incidents_hash[incident_id] = incident_params ensure_links_include_item_incident(links_hash, item_id,incident_id) end end end
restore_weird_special_cases_into(workspace)
click to toggle source
# File lib/dgrid/api/workspace.rb, line 489 def restore_weird_special_cases_into(workspace) # nothing to do, just overriding predecessor's implementation end