active-orient 0.42 → 0.79
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/Gemfile +13 -5
- data/Guardfile +12 -4
- data/README.md +67 -280
- data/VERSION +1 -1
- data/active-orient.gemspec +6 -5
- data/bin/active-orient-0.6.gem +0 -0
- data/bin/active-orient-console +85 -0
- data/config/boot.rb +72 -1
- data/config/config.yml +10 -0
- data/config/connect.yml +9 -4
- data/examples/books.rb +92 -40
- data/examples/streets.rb +89 -85
- data/examples/test_commands.rb +97 -0
- data/examples/test_commands_2.rb +59 -0
- data/examples/test_commands_3.rb +55 -0
- data/examples/test_commands_4.rb +33 -0
- data/examples/time_graph.md +162 -0
- data/lib/active-orient.rb +75 -9
- data/lib/base.rb +238 -169
- data/lib/base_properties.rb +68 -60
- data/lib/class_utils.rb +226 -0
- data/lib/database_utils.rb +98 -0
- data/lib/init.rb +79 -0
- data/lib/java-api.rb +442 -0
- data/lib/jdbc.rb +211 -0
- data/lib/model/custom.rb +26 -0
- data/lib/model/edge.rb +70 -0
- data/lib/model/model.rb +134 -0
- data/lib/model/the_class.rb +607 -0
- data/lib/model/the_record.rb +266 -0
- data/lib/model/vertex.rb +236 -0
- data/lib/orientdb_private.rb +48 -0
- data/lib/other.rb +371 -0
- data/lib/railtie.rb +68 -0
- data/lib/rest/change.rb +147 -0
- data/lib/rest/create.rb +279 -0
- data/lib/rest/delete.rb +134 -0
- data/lib/rest/operations.rb +211 -0
- data/lib/rest/read.rb +171 -0
- data/lib/rest/rest.rb +112 -0
- data/lib/rest_disabled.rb +24 -0
- data/lib/support/logging.rb +38 -0
- data/lib/support/orient.rb +196 -0
- data/lib/support/orientquery.rb +469 -0
- data/rails.md +154 -0
- data/rails/activeorient.rb +32 -0
- data/rails/config.yml +10 -0
- data/rails/connect.yml +17 -0
- metadata +65 -24
- data/active-orient-0.4.gem +0 -0
- data/active-orient-0.41.gem +0 -0
- data/lib/model.rb +0 -468
- data/lib/orient.rb +0 -98
- data/lib/query.rb +0 -88
- data/lib/rest.rb +0 -1059
- data/lib/support.rb +0 -372
- data/test.rb +0 -4
- data/usecase.md +0 -91
@@ -0,0 +1,48 @@
|
|
1
|
+
module OrientDbPrivate
|
2
|
+
private
|
3
|
+
|
4
|
+
def translate_property_hash field, type: nil, linked_class: nil, **args
|
5
|
+
type = type.presence || args[:propertyType].presence || args[:property_type]
|
6
|
+
linked_class = linked_class.presence || args[:linkedClass] || args[:other_class]
|
7
|
+
if type.present?
|
8
|
+
if linked_class.nil?
|
9
|
+
{field => {propertyType: type.to_s.upcase}}
|
10
|
+
else
|
11
|
+
{field => {propertyType: type.to_s.upcase, linkedClass: classname(linked_class)}}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def property_uri this_classname
|
17
|
+
if block_given?
|
18
|
+
"property/#{@database}/#{this_classname}/" << yield
|
19
|
+
else
|
20
|
+
"property/#{@database}/#{this_classname}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.simple_uri *names
|
25
|
+
names.each do |name|
|
26
|
+
m_name = ("#{name.to_s}_uri").to_sym
|
27
|
+
define_method(m_name) do |&b|
|
28
|
+
if b
|
29
|
+
"#{name.to_s}/#{@database}/#{b.call}"
|
30
|
+
else
|
31
|
+
"#{name.to_s}/#{@database}"
|
32
|
+
end # branch
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.sql_uri *names
|
38
|
+
names.each do |name|
|
39
|
+
define_method(("#{name.to_s}_sql_uri").to_sym) do
|
40
|
+
"#{name.to_s}/#{@database}/sql/"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
simple_uri :database, :document, :class, :batch, :function
|
46
|
+
sql_uri :command, :query
|
47
|
+
|
48
|
+
end
|
data/lib/other.rb
ADDED
@@ -0,0 +1,371 @@
|
|
1
|
+
|
2
|
+
class Array
|
3
|
+
# Class extentions to manage to_orient and from_orient
|
4
|
+
def to_orient
|
5
|
+
map( &:to_orient) # .join(',')
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_or
|
9
|
+
"["+ map( &:to_or).join(', ')+"]"
|
10
|
+
end
|
11
|
+
|
12
|
+
def from_orient
|
13
|
+
map &:from_orient
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_human
|
17
|
+
map &:to_human
|
18
|
+
end
|
19
|
+
# used to enable
|
20
|
+
# def abc *key
|
21
|
+
# where key is a Range, an comma separated List or an item
|
22
|
+
# aimed to support #compose_where
|
23
|
+
def analyse # :nodoc:
|
24
|
+
if first.is_a?(Range)
|
25
|
+
first
|
26
|
+
elsif size ==1
|
27
|
+
first
|
28
|
+
else
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Symbol
|
36
|
+
def to_a
|
37
|
+
[ self ]
|
38
|
+
end
|
39
|
+
# symbols are masked with ":{symbol}:"
|
40
|
+
def to_orient
|
41
|
+
":"+self.to_s+":"
|
42
|
+
end
|
43
|
+
def to_or
|
44
|
+
"'"+self.to_orient+"'"
|
45
|
+
end
|
46
|
+
|
47
|
+
# inserted to prevent error message while initialising a model-recorda
|
48
|
+
=begin
|
49
|
+
2.6.1 :008 > ii.first.attributes
|
50
|
+
=> {:zwoebelkuchen=>[7, 9, 9, 7, 8, 8, 3, 6, 9, ":zt:", ":zt:", ":zg:", ":zg:", ":tzu:", ":grotte:"], :created_at=>Wed, 27 Mar 2019 14:59:45 +0000}
|
51
|
+
2.6.1 :009 > ii.first.send :zwoebelkuchen
|
52
|
+
key zwoebelkuchen
|
53
|
+
iv [7, 9, 9, 7, 8, 8, 3, 6, 9, ":zt:", ":zt:", ":zg:", ":zg:", ":tzu:", ":grotte:"]
|
54
|
+
27.03.(15:00:36)ERROR->MethodMissing -> Undefined method: coerce -- Args: [Wed, 27 Mar 2019 14:59:45 +0000]
|
55
|
+
27.03.(15:00:36)ERROR-> The Message undefined method `coerce' for :zt:Symbol
|
56
|
+
27.03.(15:00:36)ERROR-> /home/dev/topo/activeorient/lib/support/orient.rb:129:in `block in method_missing'
|
57
|
+
/home/dev/topo/activeorient/lib/support/orient.rb:129:in `map'
|
58
|
+
/home/dev/topo/activeorient/lib/support/orient.rb:129:in `method_missing'
|
59
|
+
/home/ubuntu/.rvm/gems/ruby-2.6.1/gems/activesupport-5.2.2.1/lib/active_support/core_ext/date/calculations.rb:140:in `<=>'
|
60
|
+
/home/ubuntu/.rvm/gems/ruby-2.6.1/gems/activesupport-5.2.2.1/lib/active_support/core_ext/date/calculations.rb:140:in `compare_with_coercion'
|
61
|
+
/home/ubuntu/.rvm/gems/ruby-2.6.1/gems/activesupport-5.2.2.1/lib/active_support/core_ext/date_time/calculations.rb:208:in `<=>'
|
62
|
+
/home/dev/topo/activeorient/lib/support/orient.rb:36:in `=='
|
63
|
+
/home/dev/topo/activeorient/lib/support/orient.rb:36:in `key'
|
64
|
+
/home/dev/topo/activeorient/lib/support/orient.rb:36:in `initialize'
|
65
|
+
/home/dev/topo/activeorient/lib/base.rb:216:in `new'
|
66
|
+
/home/dev/topo/activeorient/lib/base.rb:216:in `[]'
|
67
|
+
/home/dev/topo/activeorient/lib/base_properties.rb:110:in `block in define_property_methods'
|
68
|
+
(irb):9:in `irb_binding'
|
69
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb/workspace.rb:85:in `eval'
|
70
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb/workspace.rb:85:in `evaluate'
|
71
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb/context.rb:385:in `evaluate'
|
72
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb.rb:493:in `block (2 levels) in eval_input'
|
73
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb.rb:647:in `signal_status'
|
74
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb.rb:490:in `block in eval_input'
|
75
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
|
76
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb/ruby-lex.rb:232:in `loop'
|
77
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
|
78
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb/ruby-lex.rb:231:in `catch'
|
79
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
|
80
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb.rb:489:in `eval_input'
|
81
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb.rb:428:in `block in run'
|
82
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb.rb:427:in `catch'
|
83
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb.rb:427:in `run'
|
84
|
+
/home/ubuntu/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/irb.rb:383:in `start'
|
85
|
+
./active-orient-console:51:in `<main>'
|
86
|
+
=end
|
87
|
+
|
88
|
+
def coerce a #nodoc#
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class Object
|
94
|
+
def from_orient
|
95
|
+
self
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_orient
|
99
|
+
self
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
class Date
|
105
|
+
def to_orient
|
106
|
+
if RUBY_PLATFORM == 'java'
|
107
|
+
java.util.Date.new( year-1900, month-1, day , 0, 0 , 0 ) ## Jahr 0 => 1900
|
108
|
+
else
|
109
|
+
self
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
class Numeric
|
116
|
+
|
117
|
+
def to_or
|
118
|
+
# "#{self.to_s}"
|
119
|
+
self
|
120
|
+
end
|
121
|
+
|
122
|
+
def to_a
|
123
|
+
[ self ]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
class String
|
128
|
+
def capitalize_first_letter
|
129
|
+
self.sub(/^(.)/) { $1.capitalize }
|
130
|
+
end
|
131
|
+
### as_json has unexpected side-effects, needs further consideration
|
132
|
+
# def as_json o=nil
|
133
|
+
# if rid?
|
134
|
+
# rid
|
135
|
+
# else
|
136
|
+
# super o
|
137
|
+
# end
|
138
|
+
# end
|
139
|
+
|
140
|
+
def where **args
|
141
|
+
if rid?
|
142
|
+
from_orient.where **args
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def from_orient
|
147
|
+
if rid?
|
148
|
+
ActiveOrient::Model.autoload_object self
|
149
|
+
elsif
|
150
|
+
self =~ /^:.*:$/
|
151
|
+
self[1..-2].to_sym
|
152
|
+
else
|
153
|
+
self
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
alias expand from_orient
|
158
|
+
# if the string contains "#xx:yy" omit quotes
|
159
|
+
def to_orient
|
160
|
+
rid? ? "#"+rid : self # return the string (not the quoted string. this is to_or)
|
161
|
+
end
|
162
|
+
|
163
|
+
# a rid is either #nn:nn or nn:nn
|
164
|
+
def rid?
|
165
|
+
self =~ /\A[#]{,1}[0-9]{1,}:[0-9]{1,}\z/
|
166
|
+
end
|
167
|
+
|
168
|
+
# return a valid rid (format: "nn:mm") or nil
|
169
|
+
def rid
|
170
|
+
self["#"].nil? ? self : self[1..-1] if rid?
|
171
|
+
end
|
172
|
+
|
173
|
+
def to_classname
|
174
|
+
if self[0] == '$'
|
175
|
+
self[1..-1]
|
176
|
+
else
|
177
|
+
self
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def to_or
|
182
|
+
quote
|
183
|
+
end
|
184
|
+
|
185
|
+
def to_a
|
186
|
+
[ self ]
|
187
|
+
end
|
188
|
+
|
189
|
+
def quote
|
190
|
+
str = self.dup
|
191
|
+
if str[0, 1] == "'" && str[-1, 1] == "'"
|
192
|
+
self
|
193
|
+
else
|
194
|
+
last_pos = 0
|
195
|
+
while (pos = str.index("'", last_pos))
|
196
|
+
str.insert(pos, "\\") if pos > 0 && str[pos - 1, 1] != "\\"
|
197
|
+
last_pos = pos + 1
|
198
|
+
end
|
199
|
+
"'#{str}'"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def coerce a #nodoc#
|
204
|
+
nil
|
205
|
+
end
|
206
|
+
|
207
|
+
def to_human
|
208
|
+
self
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
class Hash #WithIndifferentAccess
|
213
|
+
|
214
|
+
# converts "abc" => {anything} to :abc => {anything}
|
215
|
+
# converts "nn" => {anything} to nn => {anything}
|
216
|
+
def to_orient # converts hast from activeorient to db
|
217
|
+
substitute_hash = {} # HashWithIndifferentAccess.new
|
218
|
+
# puts "here to hash"
|
219
|
+
#keys.each{|k| puts self[k].inspect}
|
220
|
+
keys.each do |k|
|
221
|
+
orient_k = case k
|
222
|
+
when Numeric
|
223
|
+
k
|
224
|
+
when Symbol, String
|
225
|
+
k.to_s
|
226
|
+
else
|
227
|
+
nil
|
228
|
+
end
|
229
|
+
substitute_hash[orient_k] = self[k].to_orient
|
230
|
+
end
|
231
|
+
substitute_hash
|
232
|
+
end
|
233
|
+
|
234
|
+
def from_orient # converts hash from db to activeorient
|
235
|
+
#puts "here hash.from_orient --> #{self.inspect}"
|
236
|
+
if keys.include?("@class" )
|
237
|
+
ActiveOrient::Model.orientdb_class( name: self["@class"] ).new self
|
238
|
+
else
|
239
|
+
substitute_hash = Hash.new
|
240
|
+
keys.each do |k|
|
241
|
+
orient_k = if k.to_s.to_i.to_s == k.to_s
|
242
|
+
k.to_i
|
243
|
+
else
|
244
|
+
k.to_sym
|
245
|
+
end
|
246
|
+
|
247
|
+
substitute_hash[orient_k] = self[k].from_orient
|
248
|
+
end
|
249
|
+
substitute_hash
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
# converts a hash to a string appropiate to include in raw queries
|
254
|
+
def to_or
|
255
|
+
"{ " + to_orient.map{|k,v| "#{k.to_s.to_or}: #{v.to_or}"}.join(',') + "}"
|
256
|
+
end
|
257
|
+
## needs testing!!
|
258
|
+
# def as_json o=nli
|
259
|
+
# #puts "here hash"
|
260
|
+
# substitute_hash = Hash.new
|
261
|
+
# keys.each{|k| substitute_hash[k] = self[k].as_json}
|
262
|
+
# substitute_hash
|
263
|
+
# end
|
264
|
+
# def nested_under_indifferent_access
|
265
|
+
# HashWithIndifferentAccess.new self
|
266
|
+
# self
|
267
|
+
# end
|
268
|
+
end
|
269
|
+
|
270
|
+
#class RecordList
|
271
|
+
# def from_orient
|
272
|
+
# map &:from_orient
|
273
|
+
# end
|
274
|
+
#end
|
275
|
+
if RUBY_PLATFORM == 'java'
|
276
|
+
|
277
|
+
## JavaMath:.BigDecimal does not premit mathematical operations
|
278
|
+
## We convert it to RubyBigDecimal to represent it (if present in the DB) and upon loading from the DB
|
279
|
+
|
280
|
+
class Java::JavaMath::BigDecimal
|
281
|
+
def to_f
|
282
|
+
BigDecimal.new self.to_s
|
283
|
+
end
|
284
|
+
|
285
|
+
def from_orient
|
286
|
+
BigDecimal.new self.to_s
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
290
|
+
class Java::ComOrientechnologiesOrientCoreDbRecordRidbag::ORidBag
|
291
|
+
def from_orient
|
292
|
+
to_a.from_orient
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
class Java::ComOrientechnologiesOrientCoreDbRecord::OTrackedList
|
297
|
+
# class RecordList
|
298
|
+
# Basisklasse
|
299
|
+
# Java::ComOrientechnologiesOrientCoreDbRecord::ORecordLazyList
|
300
|
+
# Methode get(Index): gibt das Dokument (Java::ComOrientechnologiesOrientCoreRecordImpl::ODocument) zurück
|
301
|
+
## base = ActiveOrient::Model::Base.first
|
302
|
+
## base.document.first_list
|
303
|
+
# => #<OrientDB::RecordList:[#21:0, #22:0, #23:0, #24:0, #21:1, #22:1, #23:1, #24:1, #21:2, #22:2]>
|
304
|
+
## base.first_list.get(3)
|
305
|
+
# => <OrientDB::Document:first_list:#24:0 second_list:#<OrientDB::RecordList:[#27:17, #28:17, #25:18, #26:18, #27:18, #28:18, #25:19, #26:19, #27:19, #28:19]> label:3>
|
306
|
+
## base.first_list[3]
|
307
|
+
# => #<ActiveOrient::Model::FirstList:0x18df26a1 (...)
|
308
|
+
## base.first_list[3].second_list[5]
|
309
|
+
# => #<ActiveOrient::Model::SecondList: (...)
|
310
|
+
## base.first_list.get(3).second_list.get(5)
|
311
|
+
# => <OrientDB::Document:second_list:#28:18 label:5>
|
312
|
+
#
|
313
|
+
def from_orient
|
314
|
+
map &:from_orient
|
315
|
+
self
|
316
|
+
end
|
317
|
+
def to_orient
|
318
|
+
self
|
319
|
+
end
|
320
|
+
|
321
|
+
#def add value
|
322
|
+
# puts "ASDSD"
|
323
|
+
#end
|
324
|
+
#
|
325
|
+
def to_a
|
326
|
+
super.map &:from_orient
|
327
|
+
end
|
328
|
+
def first
|
329
|
+
super.from_orient
|
330
|
+
end
|
331
|
+
def last
|
332
|
+
super.from_orient
|
333
|
+
end
|
334
|
+
def [] val
|
335
|
+
super.from_orient
|
336
|
+
|
337
|
+
end
|
338
|
+
|
339
|
+
def << value
|
340
|
+
#put "I will perform the insert"
|
341
|
+
value = value.document if value.is_a?( ActiveOrient::Model ) && value.document.present?
|
342
|
+
add value
|
343
|
+
#save
|
344
|
+
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
class Java::ComOrientechnologiesOrientCoreDbRecord::OTrackedMap
|
349
|
+
def from_orient
|
350
|
+
|
351
|
+
# puts self.inspect
|
352
|
+
# puts self.keys.inspect
|
353
|
+
HashWithIndifferentAccess.new(self)
|
354
|
+
# Kernel.exit
|
355
|
+
# map &:from_orient
|
356
|
+
# to_a.from_orient
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|
360
|
+
class Java::JavaUtil::Date
|
361
|
+
def from_orient
|
362
|
+
Date.new(year+1900, month+1, date )
|
363
|
+
end
|
364
|
+
def to_orient
|
365
|
+
self
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
|
370
|
+
end
|
371
|
+
|
data/lib/railtie.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
module ActiveOrient
|
3
|
+
class Railtie < Rails::Railtie
|
4
|
+
puts "Railtie included!!"
|
5
|
+
initializer 'active_orient.logger' do
|
6
|
+
ActiveSupport.on_load(:active_orient) do
|
7
|
+
ActiveOrient::Base.logger = Rails.logger
|
8
|
+
ActiveOrient::OrientDB.logger = Rails.logger
|
9
|
+
#self.logger ||= Rails.logger
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
initializer 'active_orient.initialize_database_access' do
|
15
|
+
# config.active_orient = ActiveSupport::OrderedOptions.new
|
16
|
+
begin
|
17
|
+
config_file = Rails.root.join('config', 'config.yml')
|
18
|
+
configyml = YAML.load_file( config_file )[:active_orient]
|
19
|
+
connect_file = Rails.root.join('config', 'connect.yml')
|
20
|
+
connectyml = YAML.load_file( connect_file )[:orientdb][:admin]
|
21
|
+
databaseyml = YAML.load_file( connect_file )[:orientdb][:database]
|
22
|
+
rescue Errno::ENOENT => e
|
23
|
+
Rails.logger.error{ "config/connect.yml/config.yml not present" }
|
24
|
+
puts "config/***yml not present"
|
25
|
+
Rails.logger.error{ "Using defaults to connect database-server" }
|
26
|
+
puts "Using defaults to connect database-server"
|
27
|
+
end
|
28
|
+
## Rails.root is a Pathname, as well as model_dir
|
29
|
+
ActiveOrient::Model.model_dir = Rails.root.join configyml.present? ? configyml[:model_dir] : "app/model"
|
30
|
+
|
31
|
+
# set the database
|
32
|
+
ActiveOrient.database = databaseyml[Rails.env.to_sym] || 'temp'
|
33
|
+
|
34
|
+
# don't allocate models if no file is provided
|
35
|
+
ActiveOrient::Model.keep_models_without_file = false
|
36
|
+
|
37
|
+
if connectyml.present? and connectyml[:user].present? and connectyml[:pass].present?
|
38
|
+
ActiveOrient.default_server= { user: connectyml[:user], password: connectyml[:pass] ,
|
39
|
+
server: 'localhost', port: 2480 }
|
40
|
+
end
|
41
|
+
ActiveOrient::Init.define_namespace namespace: :object
|
42
|
+
::DB = ::ORD = ActiveOrient::OrientDB.new preallocate: true
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
# We're not doing migrations (yet)
|
47
|
+
config.send(:app_generators).orm :active_orient, migration: false
|
48
|
+
console do
|
49
|
+
Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
50
|
+
puts '_'*45
|
51
|
+
puts "ORD points to the REST-Instance, Database: #{ActiveOrient.database}"
|
52
|
+
puts "DB is the API-Instance of the database, DB.db gets the DB-Api-base " if RUBY_PLATFORM == 'java'
|
53
|
+
|
54
|
+
puts '-'* 45
|
55
|
+
ns= case ActiveOrient::Model.namespace
|
56
|
+
when Object
|
57
|
+
"No Prefix, just ClassName#CamelCase"
|
58
|
+
else
|
59
|
+
ActiveOrient::Model.namespace.to_s + "{ClassName.camelcase}"
|
60
|
+
end
|
61
|
+
puts "Namespace for model-classes : #{ns}"
|
62
|
+
puts "Present Classes (Hierarchy) "
|
63
|
+
|
64
|
+
puts ::ORD.class_hierarchy.to_yaml
|
65
|
+
puts ActiveOrient::show_classes
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|