87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/orasaurus/db.rb', line 87
def self.sort_by_sql(arr,dbconnection)
puts("*********SORT BY SQL")
ordered_list = Array.new
done_collecting = false
loop_idx = 0
stripped_items = {}
while not done_collecting
loop_idx += 1
arr.each{ |object|
if not ordered_list.include?(object) then
dependency_list = dbconnection.get_dependencies(dbconnection.username,strip_item(object))
dependencies = Array.new
dependency_list.each{ |i| dependencies.push(i.fetch(:object_name).downcase) }
if dependencies.length == 0 then
ordered_list.push(object)
else
matches = ordered_list.select do |match|
dependencies.include?(strip_item(match))
end
matches = matches.sort
if matches.collect{ |m| strip_item(m)}.eql?(dependencies)
ordered_list.push(object)
end
end
end
}
if ordered_list.sort.eql?(arr.sort) then
done_collecting = true
puts "done colecting dependency matches. all objects have been collected and matched."
end
if loop_idx > 30
done_collecting = true
puts "giving up on finishing collection"
puts "difference (missing ones): "
puts arr - ordered_list
end
end
return ordered_list
end
|