active-orient 0.5 → 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/README.md +78 -35
- data/VERSION +1 -1
- data/active-orient.gemspec +4 -4
- data/bin/active-orient-console +8 -5
- data/config/boot.rb +2 -4
- data/config/config.yml +1 -1
- data/config/connect.yml +2 -2
- data/examples/time_graph.md +162 -0
- data/gratefuldeadconcerts.md +94 -0
- data/lib/active-orient.rb +4 -2
- data/lib/base.rb +53 -20
- data/lib/base_properties.rb +2 -3
- data/lib/class_utils.rb +3 -4
- data/lib/database_utils.rb +14 -5
- data/lib/init.rb +11 -1
- data/lib/model/edge.rb +12 -10
- data/lib/model/model.rb +17 -3
- data/lib/model/the_class.rb +60 -40
- data/lib/model/the_record.rb +63 -51
- data/lib/model/vertex.rb +114 -10
- data/lib/orient.rb +24 -33
- data/lib/orientdb_private.rb +31 -31
- data/lib/other.rb +55 -5
- data/lib/rest/change.rb +17 -4
- data/lib/rest/create.rb +38 -24
- data/lib/rest/delete.rb +3 -2
- data/lib/rest/operations.rb +37 -27
- data/lib/rest/read.rb +2 -2
- data/lib/rest/rest.rb +4 -3
- data/lib/support.rb +17 -16
- data/linkmap.md +75 -0
- data/namespace.md +111 -0
- data/rails.md +125 -0
- data/rails/activeorient.rb +53 -0
- data/{examples/time_graph/config → rails}/config.yml +3 -1
- data/{examples/time_graph/config → rails}/connect.yml +2 -2
- data/usecase_oo.md +3 -1
- metadata +21 -38
- data/examples/createTime.rb +0 -91
- data/examples/time_graph/Gemfile +0 -21
- data/examples/time_graph/Guardfile +0 -26
- data/examples/time_graph/README.md +0 -129
- data/examples/time_graph/bin/active-orient-console +0 -35
- data/examples/time_graph/config/boot.rb +0 -119
- data/examples/time_graph/config/init_db.rb +0 -59
- data/examples/time_graph/createTime.rb +0 -51
- data/examples/time_graph/lib/createTime.rb +0 -82
- data/examples/time_graph/model/day_of.rb +0 -3
- data/examples/time_graph/model/e.rb +0 -6
- data/examples/time_graph/model/edge.rb +0 -53
- data/examples/time_graph/model/monat.rb +0 -19
- data/examples/time_graph/model/stunde.rb +0 -16
- data/examples/time_graph/model/tag.rb +0 -29
- data/examples/time_graph/model/time_base.rb +0 -6
- data/examples/time_graph/model/time_of.rb +0 -4
- data/examples/time_graph/model/v.rb +0 -3
- data/examples/time_graph/model/vertex.rb +0 -32
- data/examples/time_graph/spec/lib/create_time_spec.rb +0 -50
- data/examples/time_graph/spec/rest_helper.rb +0 -37
- data/examples/time_graph/spec/spec_helper.rb +0 -46
- data/usecase.md +0 -104
data/examples/createTime.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
if $0 == __FILE__
|
2
|
-
puts "the time-graph example is completely rewritten"
|
3
|
-
puts "changing into the directory and starting the demo in 10 sec."
|
4
|
-
sleep 10
|
5
|
-
print %x{ cd #{File.expand_path(File.dirname(__FILE__))}/time_graph ; ruby createTime.rb }
|
6
|
-
|
7
|
-
Kernel.exit
|
8
|
-
end
|
9
|
-
#require 'time'
|
10
|
-
require '../config/boot'
|
11
|
-
|
12
|
-
## historic stuff
|
13
|
-
|
14
|
-
def create1month
|
15
|
-
|
16
|
-
database_classes = [:hour, :day, :month, :time_base, :time_of ]
|
17
|
-
puts "allocated-database-classes: #{ORD.database_classes.join(" , ")} "
|
18
|
-
puts database_classes.map{|c| ORD.database_classes.include?( c.to_s ) ? c : nil }.compact.size
|
19
|
-
if database_classes.map{|c| ORD.database_classes.include?( c.to_s ) ? c : nil }.compact.size <= 5
|
20
|
-
print " deleting database tables \n"
|
21
|
-
database_classes.each{ | c | d_class= c.to_s.classify.constantize # works if namespace=Object
|
22
|
-
d_class.delete_class if d_class.present? }
|
23
|
-
else
|
24
|
-
puts " omitting deletion of database-classes "
|
25
|
-
end
|
26
|
-
ORD.create_vertex_class :time_base
|
27
|
-
ORD.create_classes( :hour, :day, :month ){ :time_base } # create three vertex classes
|
28
|
-
TimeBase.create_property :value_string, type: :string
|
29
|
-
TimeBase.create_property :value, type: :string
|
30
|
-
ORD.create_edge_class :time_of
|
31
|
-
ORD.create_edge_class :day_of
|
32
|
-
|
33
|
-
|
34
|
-
# hour_class = r.create_vertex_class "Hour", properties: {value_string: {type: :string}, value: {type: :integer}}
|
35
|
-
# hour_class.alter_property property: "value", attribute: "MIN", alteration: 0
|
36
|
-
# hour_class.alter_property property: "value", attribute: "MAX", alteration: 23
|
37
|
-
#
|
38
|
-
# day_class = r.create_vertex_class "Day", properties: {value_string: {type: :string}, value: {type: :integer}}
|
39
|
-
# day_class.alter_property property: "value", attribute: "MIN", alteration: 1
|
40
|
-
# day_class.alter_property property: "value", attribute: "MAX", alteration: 31
|
41
|
-
#
|
42
|
-
# month_class = r.create_vertex_class "Month", properties: {value_string: {type: :string}, value: {type: :integer}}
|
43
|
-
# month_class.alter_property property: "value", attribute: "MIN", alteration: 1
|
44
|
-
# month_class.alter_property property: "value", attribute: "MAX", alteration: 12
|
45
|
-
#
|
46
|
-
|
47
|
-
# timeof_class = r.create_edge_class "TIMEOF"
|
48
|
-
|
49
|
-
timestamp = DateTime.new 2016,2,29 # or strptime "1456704000",'%s'
|
50
|
-
month_vertex =Month.create value_string: "March", value: 3
|
51
|
-
for day in 1..31
|
52
|
-
day_vertex = Day.create value_string: "March #{timestamp.day}", value: day
|
53
|
-
for hour in 0..23
|
54
|
-
print "#{timestamp.year} #{timestamp.month} #{timestamp.day} #{timestamp.hour} \n"
|
55
|
-
hour_vertex = Hour.create value_string: "March #{timestamp.day} #{timestamp.hour}:00", value: hour
|
56
|
-
TimeOf.create_edge from: day_vertex, to: hour_vertex
|
57
|
-
timestamp += Rational(1,24) # + 1 hour
|
58
|
-
end
|
59
|
-
DayOf.create_edge from: month_vertex, to: day_vertex
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
create1month
|
65
|
-
|
66
|
-
print "1 #{Month.all} \n \n"
|
67
|
-
|
68
|
-
firstmonth = Month.first
|
69
|
-
print "2 #{firstmonth.to_human} \n \n"
|
70
|
-
print "2.5 #{firstmonth.value} \n \n"
|
71
|
-
|
72
|
-
puts firstmonth.inspect
|
73
|
-
days = firstmonth.out_day_of
|
74
|
-
print "3 #{days.to_human} \n \n"
|
75
|
-
|
76
|
-
first_day = firstmonth.out_day_of[0].in
|
77
|
-
print "4 #{first_day.to_human} \n \n"
|
78
|
-
|
79
|
-
puts Month.first.out_day_of[0].in.out_time_of[12].inspect
|
80
|
-
thirteen_hour = firstmonth.out_day_of[0].in.out_time_of[12].in
|
81
|
-
print "5 #{thirteen_hour.value} \n \n"
|
82
|
-
print "6 #{thirteen_hour.to_human} \n \n"
|
83
|
-
|
84
|
-
test2 = firstmonth["out_day_of"].map{|x| x["in"]}
|
85
|
-
print "7 #{test2} \n \n"
|
86
|
-
|
87
|
-
mon.add_edge_link name: "days", direction: "out", edge: "time_of"
|
88
|
-
print "8 #{firstmonth.days.map{|x| x.value}} \n \n"
|
89
|
-
|
90
|
-
print "9 #{firstmonth.days.value_string} \n \n"
|
91
|
-
|
data/examples/time_graph/Gemfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
#gemspec
|
3
|
-
gem 'orientdb' , :path => '/home/topo/orientdb-jruby' , :platforms => :jruby
|
4
|
-
## change here to the location of ActiveOrient
|
5
|
-
gem 'active-orient' , :path => '/home/topo/activeorient'
|
6
|
-
|
7
|
-
|
8
|
-
group :development, :test do
|
9
|
-
gem "awesome_print"
|
10
|
-
gem "rspec"
|
11
|
-
gem 'rspec-legacy_formatters'
|
12
|
-
gem 'rspec-its'
|
13
|
-
gem 'rspec-collection_matchers'
|
14
|
-
gem 'rspec-context-private'
|
15
|
-
gem 'guard-jruby-rspec', :platforms => :jruby, :git => 'git://github.com/jkutner/guard-jruby-rspec.git'
|
16
|
-
gem 'guard'#, :platforms => :ruby
|
17
|
-
gem 'guard-rspec'
|
18
|
-
## gem 'database_cleaner'
|
19
|
-
gem 'rb-inotify'
|
20
|
-
gem 'pry'
|
21
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
def fire
|
4
|
-
require "ostruct"
|
5
|
-
|
6
|
-
# Generic Ruby apps
|
7
|
-
rspec = OpenStruct.new
|
8
|
-
rspec.spec = ->(m) { "spec/#{m}_spec.rb" }
|
9
|
-
rspec.spec_dir = "spec"
|
10
|
-
rspec.spec_helper = "spec/spec_helper.rb"
|
11
|
-
|
12
|
-
|
13
|
-
watch(%r{^spec/.+_spec\.rb$})
|
14
|
-
# watch(%r{^spec/usecase/(.+)\.rb$})
|
15
|
-
watch(%r{^model/(.+)\.rb$}) { |m| "spec/model/#{m[1]}_spec.rb" }
|
16
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
17
|
-
# watch(%r{^examples/time_graph/spec/(.+)_spec\.rb$})
|
18
|
-
watch('spec/spec_helper.rb') { "spec" }
|
19
|
-
end
|
20
|
-
|
21
|
-
interactor :simple
|
22
|
-
if RUBY_PLATFORM == 'java'
|
23
|
-
guard( 'jruby-rspec') {fire} #', :spec_paths => ["spec"]
|
24
|
-
else
|
25
|
-
guard( :rspec, cmd: "bundle exec rspec") { fire }
|
26
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
#Example: Time Graph
|
2
|
-
|
3
|
-
The bin-directory contains a customized console-application.
|
4
|
-
Any libraries are included and one can start exploring the features immediately.
|
5
|
-
|
6
|
-
*Prerequisites* :
|
7
|
-
* Edit the Gemfile, update the pathes to include the orientdb_jruby an d activeorient gem
|
8
|
-
* Run "Bundle install" and "Bundle update"
|
9
|
-
* customize config/connect.yml
|
10
|
-
|
11
|
-
There is a rspec-section, run "bundle exec guard", edit the spec-files and start the test by saving the dataset.
|
12
|
-
|
13
|
-
To play around, start the console by
|
14
|
-
cd bin
|
15
|
-
./active-orient-console t # test-modus
|
16
|
-
|
17
|
-
The Database is initialized/resetted by calling
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
ActiveOrient::OrientSetup.init_database
|
21
|
-
```
|
22
|
-
|
23
|
-
This executes the code located in 'config/init_db.rb'
|
24
|
-
|
25
|
-
The following hierarchy is build:
|
26
|
-
|
27
|
-
```ruby
|
28
|
-
- E
|
29
|
-
- - day_of
|
30
|
-
- - time_of
|
31
|
-
- V
|
32
|
-
- - time_base
|
33
|
-
- - - monat
|
34
|
-
- - - stunde
|
35
|
-
- - - tag
|
36
|
-
```
|
37
|
-
And this Graph is realized
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
Monat --[DAY_OF]-- Tag --[TIME_OF]-- Stunde
|
41
|
-
```
|
42
|
-
and populated by calling
|
43
|
-
|
44
|
-
```ruby
|
45
|
-
CreateTime.populate_month # 1 One Month whith appropoiate Days and Hours
|
46
|
-
```
|
47
|
-
|
48
|
-
You can check the Status by counting the recods of the Classes
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
Monat.count # 1
|
52
|
-
Tag.count # 32
|
53
|
-
Stunde.count # 768
|
54
|
-
```
|
55
|
-
which should be equal to the counts of the Edge-Classes DAY_OF and TIME_OF
|
56
|
-
|
57
|
-
In the Model-directory, customized methods simplify the usage of the graph.
|
58
|
-
|
59
|
-
Some Examples:
|
60
|
-
|
61
|
-
```ruby
|
62
|
-
m = Date.today.month # current month
|
63
|
-
|
64
|
-
Monat[m].tag.value
|
65
|
-
=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
|
66
|
-
|
67
|
-
Monat[m].tag[9].stunde[9].value
|
68
|
-
=> 9
|
69
|
-
|
70
|
-
Monat[month].tag[9].next.datum
|
71
|
-
=> "10.8.2016"
|
72
|
-
|
73
|
-
Stunde[9] # [] is defined in model/timebase.rb
|
74
|
-
=> An Array with Stunde-records
|
75
|
-
Stunde[9].datum # datum is defined in model/stunde.rb
|
76
|
-
=> ["0.8.2016 9:00", "1.8.2016 9:00", "2.8.2016 9:00", "3.8.2016 9:00", "4.8.2016 9:00", "5.8.2016 9:00", "6.8.2016 9:00", "7.8.2016 9:00", "8.8.2016 9:00", "9.8.2016 9:00", "10.8.2016 9:00", "11.8.2016 9:00", "12.8.2016 9:00", "13.8.2016 9:00", "14.8.2016 9:00", "15.8.2016 9:00", "16.8.2016 9:00", "17.8.2016 9:00", "18.8.2016 9:00", "19.8.2016 9:00", "20.8.2016 9:00", "21.8.2016 9:00", "22.8.2016 9:00", "23.8.2016 9:00", "24.8.2016 9:00", "25.8.2016 9:00", "26.8.2016 9:00", "27.8.2016 9:00", "28.8.2016 9:00", "29.8.2016 9:00", "30.8.2016 9:00", "31.8.2016 9:00"]
|
77
|
-
|
78
|
-
Stunde[9][8 ..12].datum # call datum on selected Stunde-records
|
79
|
-
=> ["8.8.2016 9:00", "9.8.2016 9:00", "10.8.2016 9:00", "11.8.2016 9:00", "12.8.2016 9:00"]
|
80
|
-
|
81
|
-
```
|
82
|
-
|
83
|
-
then you can assign appointments to these dates
|
84
|
-
|
85
|
-
|
86
|
-
lets create a simple diary
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
ORD.create_vertex_class :termin
|
90
|
-
=> Termin
|
91
|
-
ORD.create_edge_class :date_of
|
92
|
-
=> DATE_OF
|
93
|
-
DATE_OF.create from: Monat[m].tag[9].stunde[12],
|
94
|
-
to: Termin.create( short: 'Mittagessen',
|
95
|
-
long: 'Schweinshaxen essen mit Lieschen Müller',
|
96
|
-
location: 'Hofbauhaus, München' )
|
97
|
-
=> #<DATE_OF:0x0000000334e038 (..) @attributes={"out"=>"#21:57", "in"=>"#41:0", (..)}>
|
98
|
-
# create some regular events
|
99
|
-
# attach breakfirst at 9 o clock from the 10th to the 21st Day in the current month
|
100
|
-
DATE_OF.create from: Stunde[9][10..21], to: Termin.create( :short => 'Frühstück' )
|
101
|
-
=> #<DATE_OF:0x000000028d5688 @metadata={(..) "cluster"=>45, "record"=>8},
|
102
|
-
@attributes={"out"=>"#22:188", "in"=>"#42:0",(..)}>
|
103
|
-
|
104
|
-
t = Termin.where short: 'Frühstück'
|
105
|
-
t.in_time_of.out.first.datum
|
106
|
-
=> ["10.8.2016 9:00", "11.8.2016 9:00", "12.8.2016 9:00", "13.8.2016 9:00", "14.8.2016 9:00", "15.8.2016 9:00", "16.8.2016 9:00", "17.8.2016 9:00", "18.8.2016 9:00", "19.8.2016 9:00", "20.8.2016 9:00", "21.8.2016 9:00"]
|
107
|
-
|
108
|
-
|
109
|
-
```
|
110
|
-
|
111
|
-
|
112
|
-
Another approach, starting with the simple graph
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
```ruby
|
117
|
-
Monat[month].tag.each{|d| d.stunde.each{|s| s.termin=[]; s.save } } # populate hour-vertices
|
118
|
-
# we append our dates to the termin-property
|
119
|
-
Monat[month].tag[9].stunde[8].termin << "Post"
|
120
|
-
Monat[month].tag[9].stunde[9].termin << "zweites Frühstück"
|
121
|
-
Monat[month].tag.each{|t| t.stunde[12].termin << "Mittag"}
|
122
|
-
```
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
## loads the active-orient environment
|
3
|
-
## and starts an interactive shell
|
4
|
-
## Parameter: production (p)
|
5
|
-
## development (d) [default]
|
6
|
-
## test (t)
|
7
|
-
require 'logger'
|
8
|
-
LogLevel = Logger::WARN
|
9
|
-
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
|
10
|
-
|
11
|
-
require 'orientdb' if RUBY_PLATFORM == 'java'
|
12
|
-
require 'yaml'
|
13
|
-
|
14
|
-
puts "ORD points to the REST-Instance, Database: #{ActiveOrient.database}"
|
15
|
-
puts "DB is the API-Instance of the database, DB.db gets the DB-Api-base " if RUBY_PLATFORM == 'java'
|
16
|
-
|
17
|
-
puts '-'* 35
|
18
|
-
ns= case ActiveOrient::Model.namespace
|
19
|
-
when Object
|
20
|
-
"No Prefix, just ClassName#CamelCase"
|
21
|
-
else
|
22
|
-
ActiveOrient::Model.namespace.to_s + "{ClassName.camelcase}"
|
23
|
-
end
|
24
|
-
puts "Namespace for model-classes : #{ns}"
|
25
|
-
puts "Allocated Classes (Hierarchy) ( Modelclasses are Camelized ):"
|
26
|
-
puts '-'* 35
|
27
|
-
|
28
|
-
puts ORD.class_hierarchy.to_yaml
|
29
|
-
|
30
|
-
|
31
|
-
include OrientDB
|
32
|
-
|
33
|
-
require 'irb'
|
34
|
-
ARGV.clear
|
35
|
-
IRB.start(__FILE__)
|
@@ -1,119 +0,0 @@
|
|
1
|
-
## parameters
|
2
|
-
## @namespace : Class on which ActiveOrient::Model's should base
|
3
|
-
## @do_not_preallocate : avoid preallocation upon boot
|
4
|
-
|
5
|
-
require 'bundler/setup'
|
6
|
-
require 'yaml'
|
7
|
-
require 'active-orient'
|
8
|
-
if RUBY_VERSION == 'java'
|
9
|
-
require 'orientdb'
|
10
|
-
end
|
11
|
-
project_root = File.expand_path('../..', __FILE__)
|
12
|
-
#require "#{project_root}/lib/active-orient.rb"
|
13
|
-
# mixin for define_namespace
|
14
|
-
include ActiveOrient::Init
|
15
|
-
|
16
|
-
# make shure that E and V are required first => sort by length
|
17
|
-
models= Dir.glob(File.join( project_root, "model",'**', "*rb")).sort{|x,y| x.size <=> y.size }
|
18
|
-
|
19
|
-
begin
|
20
|
-
connect_file = File.expand_path('../../config/connect.yml', __FILE__)
|
21
|
-
config_file = File.expand_path('../../config/config.yml', __FILE__)
|
22
|
-
connectyml = YAML.load_file( connect_file )[:orientdb][:admin] if connect_file.present?
|
23
|
-
configyml = YAML.load_file( config_file )[:active_orient] if config_file.present?
|
24
|
-
rescue Errno::ENOENT => e
|
25
|
-
ActiveOrient::Base.logger = Logger.new('/dev/stdout')
|
26
|
-
ActiveOrient::OrientDB.logger.error{ "config/connectyml not present" }
|
27
|
-
ActiveOrient::OrientDB.logger.error{ "Using defaults to connect database-server" }
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
e= ARGV.present? ? ARGV.last.downcase : 'development'
|
32
|
-
env = if e =~ /^p/
|
33
|
-
'production'
|
34
|
-
elsif e =~ /^t/
|
35
|
-
'test'
|
36
|
-
else
|
37
|
-
'development'
|
38
|
-
end
|
39
|
-
puts "Using #{env}-environment"
|
40
|
-
|
41
|
-
|
42
|
-
# lib/init.rb
|
43
|
-
define_namespace yml: configyml, namespace: @namespace
|
44
|
-
|
45
|
-
ActiveOrient::Model.model_dir = "#{project_root}/#{ configyml.present? ? configyml[:model_dir] : "model" }"
|
46
|
-
puts "BOOT--> Project-Root: #{project_root}"
|
47
|
-
puts "BOOT--> mode-dir: #{ActiveOrient::Model.model_dir}"
|
48
|
-
|
49
|
-
databaseyml = YAML.load_file( connect_file )[:orientdb][:database]
|
50
|
-
log_file = if config_file.present?
|
51
|
-
dev = YAML.load_file( connect_file )[:orientdb][:logger]
|
52
|
-
if dev.blank? || dev== 'stdout'
|
53
|
-
'/dev/stdout'
|
54
|
-
else
|
55
|
-
project_root+'/log/'+env+'.log'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
logger = Logger.new log_file
|
61
|
-
logger.level = case env
|
62
|
-
when 'production'
|
63
|
-
Logger::ERROR
|
64
|
-
when 'development'
|
65
|
-
Logger::WARN
|
66
|
-
else
|
67
|
-
Logger::INFO
|
68
|
-
end
|
69
|
-
logger.formatter = proc do |severity, datetime, progname, msg|
|
70
|
-
"#{datetime.strftime("%d.%m.(%X)")}#{"%5s" % severity}->#{progname}:..:#{msg}\n"
|
71
|
-
end
|
72
|
-
ActiveOrient::Model.logger = logger
|
73
|
-
ActiveOrient::OrientDB.logger = logger
|
74
|
-
if connectyml.present? and connectyml[:user].present? and connectyml[:pass].present?
|
75
|
-
ActiveOrient.default_server= { user: connectyml[:user], password: connectyml[:pass] ,
|
76
|
-
server: 'localhost', port: 2480 }
|
77
|
-
ActiveOrient.database = @configDatabase.presence || databaseyml[env.to_sym]
|
78
|
-
|
79
|
-
## Include customized NamingConvention for Edges
|
80
|
-
ActiveOrient::Model.orientdb_class name:"E"
|
81
|
-
ActiveOrient::Model.orientdb_class name:"V"
|
82
|
-
class E #< ActiveOrient::Model
|
83
|
-
def self.naming_convention name=nil
|
84
|
-
name.present? ? name.upcase : ref_name.upcase
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
ORD = ActiveOrient::OrientDB.new preallocate: @do_not_preallocate.present? ? false : true
|
90
|
-
if RUBY_PLATFORM == 'java'
|
91
|
-
DB = ActiveOrient::API.new preallocate: false
|
92
|
-
else
|
93
|
-
DB = ORD
|
94
|
-
end
|
95
|
-
|
96
|
-
# ORD.create_classes 'E', 'V'
|
97
|
-
# E.ref_name = 'E'
|
98
|
-
# V.ref_name = 'V'
|
99
|
-
|
100
|
-
# require model files after initializing the database
|
101
|
-
# require "#{project_root}/model/edge.rb"
|
102
|
-
# require "#{project_root}/model/vertex.rb"
|
103
|
-
|
104
|
-
# require db-init and application
|
105
|
-
require "#{project_root}/config/init_db.rb"
|
106
|
-
require "#{project_root}/lib/createTime.rb"
|
107
|
-
|
108
|
-
# thus the classes are predefined and modelfiles just extend the classes
|
109
|
-
#included_models = models.collect { |file| [file, require( file )] }
|
110
|
-
#puts "Included Models: "
|
111
|
-
#puts included_models.collect{|x,y| [ "\t",x.split("/").last , " \t-> " , y].join }.join("\n")
|
112
|
-
else
|
113
|
-
ActiveOrient::Base.logger = Logger.new('/dev/stdout')
|
114
|
-
ActiveOrient::OrientDB.logger.error{ "config/connectyml is misconfigurated" }
|
115
|
-
ActiveOrient::OrientDB.logger.error{ "Database Server is NOT available"}
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# Execute with
|
2
|
-
# ActiveOrient::OrientSetup.init_database
|
3
|
-
#
|
4
|
-
module ActiveOrient
|
5
|
-
module OrientSetup
|
6
|
-
def self.init_database
|
7
|
-
(logger= ActiveOrient::Base.logger).progname= 'OrientSetup#InitDatabase'
|
8
|
-
vertexes = ORD.class_hierarchy base_class: 'time_base'
|
9
|
-
# because edges are not resolved because of the namingconvention
|
10
|
-
edges = ORD.class_hierarchy base_class: 'E'
|
11
|
-
logger.info{ " preallocated-database-classes: #{ORD.database_classes.join(" , ")} " }
|
12
|
-
|
13
|
-
delete_class = -> (c,d) do
|
14
|
-
the_class = ActiveOrient::Model.orientdb_class( name: c, superclass: d)
|
15
|
-
logger.info{ "The Class: "+the_class.to_s }
|
16
|
-
the_class.delete_class
|
17
|
-
end
|
18
|
-
|
19
|
-
logger.info{ " Deleting Class and Classdefinitions" }
|
20
|
-
vertexes.each{|v| delete_class[ v, :time_base ]}
|
21
|
-
delete_class[ :time_base, :V ] if defined?(TimeBase)
|
22
|
-
edges.each{|e| delete_class[ e, :E ] }
|
23
|
-
|
24
|
-
logger.info{ " Creating Classes " }
|
25
|
-
ORD.create_classes 'E', 'V'
|
26
|
-
#E.ref_name = 'E'
|
27
|
-
#V.ref_name = 'V'
|
28
|
-
#ActiveOrient::Init.vertex_and_egde_class
|
29
|
-
ORD.create_vertex_class :time_base # --> TimeBase
|
30
|
-
# hour, day: month cannot be alloacated, because Day is a class of DateTime and thus reserved
|
31
|
-
time_base_classes = ORD.create_classes( :stunde, :tag, :monat ){ :time_base } # --> Hour, Day, Month
|
32
|
-
TimeBase.create_property :value_string, type: :string
|
33
|
-
TimeBase.create_property :value, type: :integer
|
34
|
-
## this puts an uniqe index on child-classes
|
35
|
-
#time_base_classes.each{|y| y.create_index :value }
|
36
|
-
|
37
|
-
# modified naming-convention in model/e.rb
|
38
|
-
edges = ORD.create_edge_class :time_of, :day_of # --> TIME_OF, :DAY_OF
|
39
|
-
edges.each &:uniq_index
|
40
|
-
|
41
|
-
ORD.database_classes # return_value
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
# to_do: define validations
|
46
|
-
# hour_class = r.create_vertex_class "Hour", properties: {value_string: {type: :string}, value: {type: :integer}}
|
47
|
-
# hour_class.alter_property property: "value", attribute: "MIN", alteration: 0
|
48
|
-
# hour_class.alter_property property: "value", attribute: "MAX", alteration: 23
|
49
|
-
#
|
50
|
-
# day_class = r.create_vertex_class "Day", properties: {value_string: {type: :string}, value: {type: :integer}}
|
51
|
-
# day_class.alter_property property: "value", attribute: "MIN", alteration: 1
|
52
|
-
# day_class.alter_property property: "value", attribute: "MAX", alteration: 31
|
53
|
-
#
|
54
|
-
# month_class = r.create_vertex_class "Month", properties: {value_string: {type: :string}, value: {type: :integer}}
|
55
|
-
# month_class.alter_property property: "value", attribute: "MIN", alteration: 1
|
56
|
-
# month_class.alter_property property: "value", attribute: "MAX", alteration: 12
|
57
|
-
#
|
58
|
-
|
59
|
-
# timeof_class = r.create_edge_class "TIMEOF"
|