module DatabaseUtils
Public Instance Methods
class_hierarchy(base_class: '', system_classes: nil)
click to toggle source
Returns the class_hierachy
To fetch all Vertices:
class_hieararchy(base_class: 'V').flatten
To fetch all Edges:
class_hierarchy(base_class: 'E').flatten
# File lib/database_utils.rb, line 35 def class_hierarchy base_class: '', system_classes: nil # @actual_class_hash = get_classes('name', 'superClass') #if requery || @all_classes.blank? fv = ->( s ) { @actual_class_hash.find_all{|x| x['superClass']== s}.map{|v| v['name']} } fx = ->( v ) { fv[v.strip].map{|x| ar = fx[x]; ar.empty? ? x : [x, ar]} } if system_classes.present? fx[ base_class.to_s ] else fx[ base_class.to_s ] - system_classes() - [ ["OIdentity", ["ORole", "OUser"]]] - [ ["OShape",["OGeometryCollection","OLineString", "OMultiLineString", "OMultiPoint", "OMultiPolygon", "OPoint", "OPolygon", "ORectangle"] ] ] end end
database_classes(system_classes: nil)
click to toggle source
Returns an array with all names of the classes of the database.
Reads the database-structure and updates the @actual_class_hash (used by class_hierachy and get_db_superclass )
# File lib/database_utils.rb, line 55 def database_classes system_classes: nil @actual_class_hash = get_classes('name', 'superClass') all_classes = get_classes('name').map(&:values).sort.flatten all_user_classes = all_classes - system_classes() all_user_classes.each{|x| ActiveOrient.database_classes[x] = "unset" unless ActiveOrient.database_classes.has_key?(x) } ActiveOrient.database_classes.keys # return an array of database-classnames end
system_classes(abstract: false)
click to toggle source
returns the classes set by OrientDB
Parameter:
abstract: true|false
if abstract: true is given, only basic classes (Abstact-Classes) are returend
# File lib/database_utils.rb, line 10 def system_classes abstract: false basic= [ "ORestricted", "OSchedule", "OTriggered", "OSequence"] ## "ORid" dropped in V2.2 extended = ["OIdentity","ORole", "OUser", "OFunction", "_studio"] v3 = ["OGeometryCollection", "OLineString", "OMultiLineString", "OMultiPoint", "OMultiPolygon", "OPoint", "OPolygon", "ORectangle", "OShape", 'OSecurityPolicy'] ## added in Orentdb 3.0 and 3.1 if abstract basic else basic + extended + v3 end end