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,97 @@
|
|
1
|
+
### OUTDATED ####
|
2
|
+
### Please do not use anymore.
|
3
|
+
### Insteed take a look to the Rspec-files in /spec/lib
|
4
|
+
|
5
|
+
|
6
|
+
require 'awesome_print'
|
7
|
+
require_relative "../lib/active-orient.rb"
|
8
|
+
|
9
|
+
# Start server
|
10
|
+
ActiveOrient::OrientDB.default_server = { user: 'root', password: 'tretretre' }
|
11
|
+
|
12
|
+
# Select database
|
13
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
14
|
+
r.delete_database database: 'NewTest'
|
15
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
16
|
+
|
17
|
+
print "\n"+"*"*20+"DATABASE"+"*"*20+"\n"
|
18
|
+
|
19
|
+
print "#{r.get_resource} \n" # <--- See the address of the server
|
20
|
+
print "#{r.get_databases} \n" # <--- List available databases
|
21
|
+
|
22
|
+
# r.create_database(database: "Onetwothree") # <--- Create a new database
|
23
|
+
print "#{r.database} \n" # <--- See the working database
|
24
|
+
|
25
|
+
# r.delete_database database: "Onetwothree" # <--- Delete an old database
|
26
|
+
|
27
|
+
print "\n"+"*"*20+"CLASSES"+"*"*20+"\n"
|
28
|
+
|
29
|
+
ap r.get_classes, :indent => -2 # <--- See available classes
|
30
|
+
print "#{r.get_classes 'name'} \n" # <--- See the names of the available classes
|
31
|
+
|
32
|
+
print "#{r.class_hierarchy} \n" # <--- See hierarchy of the classes
|
33
|
+
print "#{r.class_hierarchy base_class: 'V'} \n" # <--- See hierarchy under V (Vectors classes)
|
34
|
+
print "#{r.class_hierarchy base_class: 'E'} \n" # <--- See hierarchy under E (Edges classes)
|
35
|
+
|
36
|
+
print "#{r.database_classes} \n" # See classes without including System classes
|
37
|
+
print "#{r.database_classes include_system_classes: true} \n " # See classes including System classes
|
38
|
+
print "#{r.inspect_classes} \n" # Same as r.database_classes
|
39
|
+
|
40
|
+
|
41
|
+
doc1 = r.create_class "DocumentTest" # Create Document/Vertex/Edge class
|
42
|
+
doc2 = r.create_class "DocumentArriveTest"
|
43
|
+
ver1 = r.create_vertex_class "VertexTest"
|
44
|
+
ver2 = r.create_vertex_class "Vertex_ArriveTest"
|
45
|
+
edg1 = r.create_edge_class "EdgeTest"
|
46
|
+
ver1 = r.open_class "VertexTest" # Same as create_class
|
47
|
+
|
48
|
+
print "\n"+"*"*20+"RECORDS"+"*"*20+"\n"
|
49
|
+
|
50
|
+
a = doc1.create name: "Doc1"
|
51
|
+
a2 = doc1.create name: "Doc12"
|
52
|
+
b = doc2.create name: "Doc2"
|
53
|
+
b2 = doc2.create name: "Doc22"
|
54
|
+
aver = ver1.create vname: "Ver1"
|
55
|
+
aver2 = ver1.create vname: "Ver12"
|
56
|
+
bver = ver2.create vname: "Ver2"
|
57
|
+
bver2 = ver2.create vname: "Ver22"
|
58
|
+
|
59
|
+
edg1.create_edge attributes: {famname: "edg1"}, from: aver, to: [bver, bver2], unique: true
|
60
|
+
nex = edg1.create_edge attributes: {familyname: "edg2"}, from: aver, to: [bver, bver2], unique: true # <--- We don't overwrite since we select a unique
|
61
|
+
nex1 = edg1.create_edge attributes: {familyname: "edg3"}, from: aver, to: [bver, bver2]
|
62
|
+
nex2 = edg1.create_edge attributes: {familyname: "edg4"}, from: aver, to: [bver, bver2]
|
63
|
+
|
64
|
+
print "#{nex1}"
|
65
|
+
print "\n\n BVER = #{bver.rid} \n" # Check the RID of the vertex
|
66
|
+
r.delete_edge nex1, nex2 # Used to delete edges
|
67
|
+
r.delete_class doc2 # Used to delete a class
|
68
|
+
doc2 = r.create_class "Document_Arrive_Test"
|
69
|
+
|
70
|
+
print "\n"+"*"*20+"PROPERTY"+"*"*20+"\n"
|
71
|
+
|
72
|
+
r.create_property doc2, :name, type: :string, index: :string #add one property
|
73
|
+
doc2.create_property :familyname, type: :string, index: :string #the same but starting directly from the class
|
74
|
+
r.create_properties doc2, {age: {type: :integer}, address: {type: :string}} #add more properties
|
75
|
+
doc2.create_properties({feetsize: {type: :integer}, country: {type: :string}})
|
76
|
+
b = doc2.create name: "Lucas", age: 91 #add more properties directly from the class
|
77
|
+
|
78
|
+
print "\n"+"*"*20+"\n"
|
79
|
+
r.delete_property doc2, "age" #delete one property
|
80
|
+
doc2.delete_property "country" #delete one property directly from the class
|
81
|
+
print "\n"+"*"*20+"\n"
|
82
|
+
|
83
|
+
ap r.get_class_properties doc2 #get the properties of a class
|
84
|
+
ap doc2.get_class_properties #get the properties of a class directly from the class
|
85
|
+
|
86
|
+
print "\n"+"*"*20+"\n"
|
87
|
+
|
88
|
+
r.print_class_properties doc2 #get the properties of a class in nice way
|
89
|
+
doc2.print_class_properties #get the properties of a class in nice way directly from the class
|
90
|
+
|
91
|
+
gg = r.create_document doc2, attributes: {name: "Test"}
|
92
|
+
hh = doc2.create_document attributes: {name: "Code"}
|
93
|
+
|
94
|
+
r.delete_document gg, hh # delete a document from database
|
95
|
+
doc2.delete_document hh # delete a document from a class
|
96
|
+
|
97
|
+
r.create_index doc2, name: "name" #Create index
|
@@ -0,0 +1,59 @@
|
|
1
|
+
### OUTDATED ####
|
2
|
+
### Please do not use anymore.
|
3
|
+
### Insteed take a look to the Rspec-files in /spec/lib
|
4
|
+
|
5
|
+
|
6
|
+
require 'awesome_print'
|
7
|
+
require_relative "../lib/active-orient.rb"
|
8
|
+
|
9
|
+
# Start server
|
10
|
+
ActiveOrient::OrientDB.default_server= { user: 'root', password: 'tretretre' }
|
11
|
+
|
12
|
+
# Select database
|
13
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
14
|
+
|
15
|
+
#r.delete_class "Document_Test"
|
16
|
+
doc1 = r.create_class "DocumentTest" # Create Document/Vertex/Edge class
|
17
|
+
doc2 = r.create_class "DocumentArrive_Test"
|
18
|
+
ver1 = r.create_vertex_class "VertexTest"
|
19
|
+
ver2 = r.create_vertex_class "VertexArriveTest"
|
20
|
+
edg1 = r.create_edge_class "EdgeTest"
|
21
|
+
ver1 = r.open_class "VertexTest" # Same as create_class
|
22
|
+
|
23
|
+
par = r.get_documents from: "DocumentTest", where: {name: "Doc1"} # Get documents
|
24
|
+
par = doc1.get_documents where: {name: "Doc1"} # Same as above
|
25
|
+
print "0 "
|
26
|
+
ap par, :indent => -2
|
27
|
+
|
28
|
+
num = r.count_documents from: "DocumentTest", where: {name: "Doc1"}
|
29
|
+
num2 = doc1.count where: {name: "Doc1"}
|
30
|
+
print "\n1 COUNT: #{num2} \n\n"
|
31
|
+
|
32
|
+
r.create_or_update_document doc1, set: {familyname: "John"}, where: {name: "Doc1"}
|
33
|
+
r.update_or_create_documents doc1, where: {name: "Doc1"}, set: {age: 91}
|
34
|
+
doc1.update_or_create_documents where: {name: "Doc1"}, set: {age: 91}
|
35
|
+
doc1.update_or_create_documents where: {name: "Doc2"}, set: {age: 91}
|
36
|
+
par = doc1.get_documents where: {name: "Doc1"}
|
37
|
+
#ap par, :indent => -2
|
38
|
+
|
39
|
+
print "2 #{par[0].attributes} \n\n" # Access attributes
|
40
|
+
print "3 #{par[0].metadata} \n\n" # Access metadata
|
41
|
+
|
42
|
+
r.delete_documents doc1, where: {name: "Doc2"}
|
43
|
+
doc1.delete_documents where: {name: "Doc2"}
|
44
|
+
|
45
|
+
a = r.get_document "1:0" # Get by RID
|
46
|
+
|
47
|
+
r.patch_document "1:0" do {name: "is a test"} end
|
48
|
+
|
49
|
+
r.update_documents doc1, set: {age: 191}, where: {name: "Doc1"} # Update a document
|
50
|
+
doc1.update_documents set: {age: 191}, where: {name: "Doc1"}
|
51
|
+
|
52
|
+
a = r.execute "Document_Test" do # To execute commands
|
53
|
+
[{type: "cmd", language: 'sql', command: "SELECT * FROM DocumentTest WHERE name = 'Doc1'"}]
|
54
|
+
end
|
55
|
+
print "\n4 #{a} \n \n"
|
56
|
+
|
57
|
+
a = r.classname doc1
|
58
|
+
a = doc1.classname
|
59
|
+
print "5 #{a} \n \n"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
### OUTDATED ####
|
2
|
+
### Please do not use anymore.
|
3
|
+
### Insteed take a look to the Rspec-files in /spec/lib
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
require 'awesome_print'
|
9
|
+
require_relative "../lib/active-orient.rb"
|
10
|
+
|
11
|
+
# Start server
|
12
|
+
ActiveOrient::OrientDB.default_server= { user: 'root', password: 'tretretre' }
|
13
|
+
|
14
|
+
# Select database
|
15
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
16
|
+
|
17
|
+
doc1 = r.create_class "DocumentTest"
|
18
|
+
ver1 = r.create_vertex_class "VertexTest"
|
19
|
+
a = doc1.create name: "Doc1"
|
20
|
+
v = ver1.create name: "Ver"
|
21
|
+
|
22
|
+
out = doc1.orientdb_class name: "Doc2345" # Used to instantiate an ActiveOrient Model
|
23
|
+
print "1 #{out} \n"
|
24
|
+
|
25
|
+
out = ver1.autoload_object "16:35" # Used to get a record by rid
|
26
|
+
print "2 #{out} \n"
|
27
|
+
|
28
|
+
print "3 #{ver1.superClass} \n" # Check superClass of the class
|
29
|
+
|
30
|
+
print "4 #{v.class} \n"
|
31
|
+
|
32
|
+
print "5 #{doc1} \n"
|
33
|
+
|
34
|
+
print "6 #{a} \n"
|
35
|
+
|
36
|
+
print "7 #{v} \n"
|
37
|
+
|
38
|
+
a = v.classname # Class of v
|
39
|
+
print "8 #{a} \n"
|
40
|
+
|
41
|
+
a = v.rid
|
42
|
+
print "9 #{a} \n" # RID of v
|
43
|
+
|
44
|
+
a = ver1.count where: {name: "Ver"}
|
45
|
+
print "10 #{a} \n"
|
46
|
+
|
47
|
+
print "11 #{v.to_human} \n" # Human version
|
48
|
+
|
49
|
+
print "12 #{v.content_attributes} \n" # Return attributes
|
50
|
+
|
51
|
+
print "13 #{v.default_attributes} \n" # Return created and updated
|
52
|
+
|
53
|
+
print "14 #{v.set_attribute_defaults} \n" # Set up
|
54
|
+
|
55
|
+
print "15 #{v.metadata} \n" # Set up
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
### OUTDATED ####
|
3
|
+
### Please do not use anymore.
|
4
|
+
### Insteed take a look to the Rspec-files in /spec/lib
|
5
|
+
|
6
|
+
require_relative "../lib/active-orient.rb"
|
7
|
+
|
8
|
+
ActiveOrient::OrientDB.default_server = { user: 'root', password: 'tretretre' }
|
9
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
10
|
+
|
11
|
+
doc1 = r.open_class "DocumentTest" # Create Document/Vertex/Edge class
|
12
|
+
doc2 = r.open_class "DocumentArrive_Test"
|
13
|
+
doc1.create_property :familyname, type: :string
|
14
|
+
doc1.create_property :family, type: :linkset, other_class: "DocumentTest"
|
15
|
+
|
16
|
+
a1 = doc1.create name: "DocA", value: 34
|
17
|
+
a2 = doc1.create name: "DocB", value: 34
|
18
|
+
a3 = doc1.create name: "DocC", value: 34
|
19
|
+
a4 = doc1.create name: "DocD", value: 30
|
20
|
+
doc1.create name: "DocE", value: 30
|
21
|
+
doc1.create name: "DocF", value: 30
|
22
|
+
|
23
|
+
print "#{a1.ciao} \n"
|
24
|
+
a1.family = [a2, a3]
|
25
|
+
print "#{a1["family"].name} \n"
|
26
|
+
print "---> #{a1.family.class}\n"
|
27
|
+
a1["family"] << a4
|
28
|
+
print "#{a1.family.name} \n"
|
29
|
+
|
30
|
+
|
31
|
+
# ActiveOrient::OrientDB.methods.each do |m|
|
32
|
+
# print "#{m} \n"
|
33
|
+
# end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
The Time-Graph Example is outsourced and lives as a seperate gem.
|
2
|
+
|
3
|
+
https://github.com/topofocus/orientdb_time_graph
|
4
|
+
|
5
|
+
from the readme:
|
6
|
+
|
7
|
+
# Time Graph
|
8
|
+
|
9
|
+
Simple Time Graph using ActiveOrient/OrientDB.
|
10
|
+
|
11
|
+
*Prerequisites* :
|
12
|
+
* Install and setup OrientDB
|
13
|
+
* Run "Bundle install" and "Bundle update"
|
14
|
+
* customize config/connect.yml
|
15
|
+
|
16
|
+
**or** start a new project and include the gem in the usual manner.
|
17
|
+
|
18
|
+
To play around, start the console by
|
19
|
+
```
|
20
|
+
cd bin
|
21
|
+
./active-orient-console t # test-modus
|
22
|
+
```
|
23
|
+
The Database is automatically initialized and the following hierarchy is build:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
- E # ruby-class
|
27
|
+
- - month_of TG::MONTH_OF
|
28
|
+
- - day_of TG::DAY_OF
|
29
|
+
- - time_of TG::TIME_OF
|
30
|
+
- - grid_of TG::GRID_OF
|
31
|
+
- V
|
32
|
+
- - time_base TG::TimeBase
|
33
|
+
- - - jahr TG::Jahr
|
34
|
+
- - - monat TG::Monat
|
35
|
+
- - - stunde TG::Stunde
|
36
|
+
- - - tag TG::Tag
|
37
|
+
```
|
38
|
+
This Graph is realized
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Jahr -- [Month_of] -- Monat --[DAY_OF]-- Tag --[TIME_OF]-- Stunde
|
42
|
+
```
|
43
|
+
and populated by calling
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
TG::TimeGraph.populate( a single year or a range ) # default: 1900 .. 2050
|
47
|
+
```
|
48
|
+
If only one year is specified, a Monat--Tag--Stunde-Grid is build, otherwise a Jahr--Monat--Tag one.
|
49
|
+
You can check the Status by calling
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
TG::TimeGraph.populate 2000 -2003
|
53
|
+
TG.info
|
54
|
+
-------------- TIME GRAPH ------------------
|
55
|
+
Allocated Years :
|
56
|
+
2000; 2001; 2002; 2003
|
57
|
+
|
58
|
+
```
|
59
|
+
In the Model-directory, customized methods simplify the usage of the graph.
|
60
|
+
|
61
|
+
Some Examples:
|
62
|
+
Assuming, you build a standard day-based grid
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
|
66
|
+
include TG # we can omit the TG prefix
|
67
|
+
|
68
|
+
Jahr[2000] # --> returns a single object
|
69
|
+
=> #<TG::Jahr:0x00000004ced160 @metadata={"type"=>"d", "class"=>"jahr", "version"=>13, "fieldTypes"=>"out_month_of=g", "cluster"=>34, "record"=>101}, @d=nil, @attributes={"value"=>2000, "out_month_of"=>["#53:1209", "#54:1209", "#55:1209", "#56:1209", "#53:1210", "#54:1210", "#55:1210", "#56:1210", "#53:1211", "#54:1211", "#55:1211", "#56:1211"], "created_at"=>Fri, 09 Sep 2016 10:14:30 +0200}>
|
70
|
+
|
71
|
+
|
72
|
+
Jahr[2000 .. 2005].value # returns an array
|
73
|
+
=> [2003, 2000, 2004, 2001, 2005, 2002]
|
74
|
+
|
75
|
+
Jahr[2000 .. 2005].monat(5..7).value # returns the result of the month-attribute (or method)
|
76
|
+
=> [[5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7]]
|
77
|
+
|
78
|
+
Jahr[2000].monat(4, 7).tag(4, 15,24 ).datum # adresses methods or attributes of the specified day's
|
79
|
+
=> [["4.4.2000", "15.4.2000", "24.4.2000"], ["4.7.2000", "15.7.2000", "24.7.2000"]]
|
80
|
+
## unfortunatly »Jahr[2000 .. 2015].monat( 3,5 ).tag( 4 ..6 ).datum « does not fits now
|
81
|
+
## instead »Jahr[2000..2015].map{|y| y.monat( 3,5 ).tag( 4 ..6 ).datum } « does the job.
|
82
|
+
```
|
83
|
+
|
84
|
+
To filter datasets in that way, anything represented is queried from the database. In contrast to
|
85
|
+
a pure ruby implementation, this works for small and large grid's.
|
86
|
+
|
87
|
+
Obviously, you can do neat ruby-array playings, which are limited to the usual sizes.
|
88
|
+
For example. As »TAG[31]« returns an array, the elements can be treated with ruby flavour:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
|
92
|
+
Tag[31][2..4].datum # display three months with 31 days
|
93
|
+
=> ["31.10.1901", "31.1.1902", "31.5.1902"]
|
94
|
+
|
95
|
+
```
|
96
|
+
First all Tag-Objects with the Value 31 are queried. This gives »Jan, Mar, May ..«. Then one can inspect the array, in this case by slicing a range.
|
97
|
+
|
98
|
+
Not surprisingly, the first occurence of the day is not the earliest date in the grid. Its just the first one,
|
99
|
+
fetched from the database.
|
100
|
+
|
101
|
+
``` ruby
|
102
|
+
Tag[1][1].datum
|
103
|
+
=> "1.5.1900" # Tag[1][0] correctly fetches "1.1.1900"
|
104
|
+
Tag[1].last.datum
|
105
|
+
=> "1.11.2050"
|
106
|
+
## however,
|
107
|
+
Jahr[2050].monat(12).tag(1) # exists:
|
108
|
+
=> [["1.12.2050"]]
|
109
|
+
```
|
110
|
+
|
111
|
+
## Horizontal Connections
|
112
|
+
|
113
|
+
Besides the hierarchically TimeGraph »Jahr <-->Monat <--> Tag <--> Stunde« the Vertices are connected
|
114
|
+
horizontally via »grid_to«-Edges. This enables an easy access to the neighbours.
|
115
|
+
|
116
|
+
On the TG::TimeBase-Level a method »environment« is implemented, that gathers the adjacent vertices
|
117
|
+
via traverse.
|
118
|
+
|
119
|
+
``` ruby
|
120
|
+
start = TG::Jahr[2000].monat(4).tag(7).first.first
|
121
|
+
start.environment(3).datum
|
122
|
+
=> ["4.4.2000", "5.4.2000", "6.4.2000", "7.4.2000", "8.4.2000", "9.4.2000", "10.4.2000"]
|
123
|
+
|
124
|
+
2.3.1 :003 > start.environment(3,4).datum
|
125
|
+
=> ["4.4.2000", "5.4.2000", "6.4.2000", "7.4.2000", "8.4.2000", "9.4.2000", "10.4.2000", "11.4.2000"]
|
126
|
+
|
127
|
+
start.environment(0,3).datum
|
128
|
+
=> ["7.4.2000", "8.4.2000", "9.4.2000", "10.4.2000"]
|
129
|
+
```
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
## Diary
|
134
|
+
|
135
|
+
lets create a simple diary
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
include TG
|
139
|
+
TimeiGraph.populate 2016
|
140
|
+
ORD.create_vertex_class :termin
|
141
|
+
=> Termin
|
142
|
+
ORD.create_edge_class :date_of
|
143
|
+
=> DATE_OF
|
144
|
+
DATE_OF.uniq_index # put contrains to the edge-class, accept only one entry per item
|
145
|
+
|
146
|
+
DATE_OF.create from: Monat[8].tag(9).stunde(12),
|
147
|
+
to: Termin.create( short: 'Mittagessen',
|
148
|
+
long: 'Schweinshaxen essen mit Lieschen Müller',
|
149
|
+
location: 'Hofbauhaus, München' )
|
150
|
+
=> #<DATE_OF:0x0000000334e038 (..) @attributes={"out"=>"#21:57", "in"=>"#41:0", (..)}>
|
151
|
+
# create some regular events
|
152
|
+
# attach breakfirst at 9 o clock from the 10th to the 21st Day in the current month
|
153
|
+
DATE_OF.create from: Monat[8].tag(10 .. 21).stunde( 9 ), to: Termin.create( :short => 'Frühstück' )
|
154
|
+
=> #<DATE_OF:0x000000028d5688 @metadata={(..) "cluster"=>45, "record"=>8},
|
155
|
+
@attributes={"out"=>"#22:188", "in"=>"#42:0",(..)}>
|
156
|
+
|
157
|
+
t = Termin.where short: 'Frühstück'
|
158
|
+
t.in_date_of.out.first.datum
|
159
|
+
=> ["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"]
|
160
|
+
|
161
|
+
```
|
162
|
+
|
data/lib/active-orient.rb
CHANGED
@@ -1,11 +1,77 @@
|
|
1
|
-
require "support.rb"
|
2
|
-
require "base.rb"
|
3
|
-
require "base_properties.rb"
|
4
1
|
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
module OrientDB
|
3
|
+
UsingJava = RUBY_PLATFORM == 'java' ? true : false
|
4
|
+
unless UsingJava
|
5
|
+
DocumentDatabase = nil
|
6
|
+
DocumentDatabasePool = nil
|
7
|
+
DocumentDatabasePooled = nil
|
8
|
+
GraphDatabase = nil
|
9
|
+
OTraverse = nil
|
10
|
+
Document = nil
|
11
|
+
IndexType = nil
|
12
|
+
OClassImpl = nil
|
13
|
+
PropertyImpl = nil
|
14
|
+
Schema = nil
|
15
|
+
SchemaProxy = nil
|
16
|
+
SchemaType = nil
|
17
|
+
SQLCommand = nil
|
18
|
+
SQLSynchQuery = nil
|
19
|
+
User = nil
|
20
|
+
RemoteStorage = nil
|
21
|
+
ServerAdmin = nil
|
22
|
+
# defined in other.rb
|
23
|
+
#JavaDate
|
24
|
+
#RecordList = nil
|
25
|
+
# RidBag = nil
|
26
|
+
# RecordSet = nil
|
27
|
+
end
|
28
|
+
end # module OrientDB
|
29
|
+
require 'active_model'
|
30
|
+
#require 'active_model/serializers'
|
31
|
+
require_relative "support/orientquery.rb"
|
32
|
+
require_relative "support/conversions.rb"
|
33
|
+
#require_relative "support/logging.rb"
|
34
|
+
require_relative "base.rb"
|
35
|
+
require_relative "base_properties.rb"
|
36
|
+
require_relative "support/orient.rb"
|
37
|
+
#require_relative "query.rb"
|
38
|
+
if OrientDB::UsingJava
|
39
|
+
require_relative 'java-api.rb'
|
40
|
+
end
|
41
|
+
require_relative "orientdb_private.rb" # manage private functions
|
42
|
+
require_relative "database_utils.rb" #common methods without rest.specific content
|
43
|
+
require_relative "class_utils.rb" #common methods without rest.specific content
|
44
|
+
require_relative "other.rb"
|
45
|
+
require_relative "rest/rest.rb"
|
46
|
+
require_relative "model/model.rb"
|
47
|
+
require 'active_support/core_ext/string' # provides blank?, present?, presence etc
|
48
|
+
require_relative 'init.rb'
|
49
|
+
# create Base Classes
|
50
|
+
|
51
|
+
require_relative "model/vertex.rb"
|
52
|
+
require_relative "model/edge.rb"
|
53
|
+
|
54
|
+
require_relative "railtie" if defined?(Rails)
|
55
|
+
|
56
|
+
module ActiveOrient
|
57
|
+
mattr_accessor :database
|
58
|
+
mattr_accessor :database_classes
|
59
|
+
mattr_accessor :default_server
|
60
|
+
|
61
|
+
## displays all allocated classes
|
62
|
+
##
|
63
|
+
## usage:
|
64
|
+
## puts ActiveOrient::show_classes
|
65
|
+
#
|
66
|
+
#
|
67
|
+
def self.show_classes
|
68
|
+
|
69
|
+
'-'* 45+"\n"+
|
70
|
+
"Database Class -> ActiveOrient ClassName\n"+
|
71
|
+
'-'* 45+"\n"+
|
72
|
+
ActiveOrient.database_classes.map{|x,y| "#{"%15s"% x} -> #{y.to_s}" }.join("\n") + "\n"+
|
73
|
+
'-'* 45 + "\n"
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
8
77
|
|
9
|
-
logger = Logger.new '/dev/stdout'
|
10
|
-
ActiveOrient::Model.logger = logger
|
11
|
-
ActiveOrient::OrientDB.logger = logger
|