active-orient 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +8 -3
- data/Guardfile +12 -4
- data/README.md +221 -201
- data/VERSION +1 -1
- data/active-orient.gemspec +3 -2
- data/bin/active-orient-console +35 -0
- data/config/boot.rb +84 -16
- data/config/config.yml +10 -0
- data/config/connect.yml +6 -2
- data/create_project +19 -0
- data/examples/books.rb +86 -39
- data/examples/createTime.rb +91 -0
- data/examples/streets.rb +85 -84
- data/examples/test_commands.rb +92 -0
- data/examples/test_commands_2.rb +54 -0
- data/examples/test_commands_3.rb +48 -0
- data/examples/test_commands_4.rb +28 -0
- data/examples/time_graph/Gemfile +21 -0
- data/examples/time_graph/Guardfile +26 -0
- data/examples/time_graph/README.md +129 -0
- data/examples/time_graph/bin/active-orient-console +35 -0
- data/examples/time_graph/config/boot.rb +119 -0
- data/examples/time_graph/config/config.yml +8 -0
- data/examples/time_graph/config/connect.yml +17 -0
- data/examples/time_graph/config/init_db.rb +59 -0
- data/examples/time_graph/createTime.rb +51 -0
- data/examples/time_graph/lib/createTime.rb +82 -0
- data/examples/time_graph/model/day_of.rb +3 -0
- data/examples/time_graph/model/e.rb +6 -0
- data/examples/time_graph/model/edge.rb +53 -0
- data/examples/time_graph/model/monat.rb +19 -0
- data/examples/time_graph/model/stunde.rb +16 -0
- data/examples/time_graph/model/tag.rb +29 -0
- data/examples/time_graph/model/time_base.rb +6 -0
- data/examples/time_graph/model/time_of.rb +4 -0
- data/examples/time_graph/model/v.rb +3 -0
- data/examples/time_graph/model/vertex.rb +32 -0
- data/examples/time_graph/spec/lib/create_time_spec.rb +50 -0
- data/examples/time_graph/spec/rest_helper.rb +37 -0
- data/examples/time_graph/spec/spec_helper.rb +46 -0
- data/lib/active-orient.rb +56 -6
- data/lib/base.rb +149 -147
- data/lib/base_properties.rb +40 -41
- data/lib/class_utils.rb +301 -0
- data/lib/database_utils.rb +97 -0
- data/lib/init.rb +35 -0
- data/lib/java-api.rb +437 -0
- data/lib/jdbc.rb +211 -0
- data/lib/model/edge.rb +53 -0
- data/lib/model/model.rb +77 -0
- data/lib/model/the_class.rb +480 -0
- data/lib/model/the_record.rb +310 -0
- data/lib/model/vertex.rb +32 -0
- data/lib/orient.rb +113 -50
- data/lib/orientdb_private.rb +48 -0
- data/lib/other.rb +280 -0
- data/lib/query.rb +71 -73
- data/lib/rest/change.rb +124 -0
- data/lib/rest/create.rb +474 -0
- data/lib/rest/delete.rb +133 -0
- data/lib/rest/operations.rb +150 -0
- data/lib/rest/read.rb +150 -0
- data/lib/rest/rest.rb +111 -0
- data/lib/rest_disabled.rb +24 -0
- data/lib/support.rb +387 -296
- data/old_lib_functions/two_general_class.rb +139 -0
- data/usecase.md +49 -36
- data/usecase_oo.md +59 -0
- metadata +73 -9
- data/lib/model.rb +0 -461
- data/lib/rest.rb +0 -1036
- data/test.rb +0 -4
data/examples/streets.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
=begin
|
2
2
|
Streets Example
|
3
3
|
|
4
|
-
|
5
4
|
We load german cities from wikipedia and parse the document for cities and countries(states).
|
6
5
|
Further we load a collection of popular streetnames from a web-side called »strassen-in-deutschland«
|
7
6
|
|
@@ -15,115 +14,117 @@ At last we print the connected cities.
|
|
15
14
|
module DataImport
|
16
15
|
def read_german_street_names
|
17
16
|
doc = Nokogiri::HTML(open('http://www.strassen-in-deutschland.de/die-haeufigsten-strassennamen-in-deutschland.html'))
|
18
|
-
strassen = doc.css('
|
17
|
+
strassen = doc.css("td[data-header='Straßenname: '] a") # identified via css-inspector in browser
|
19
18
|
# search for the css and include only links, then display the text-part
|
20
19
|
strassen.children.map( &:to_s )[3..-1] # omit the first three (strassen in deutschland, straßenverzeichnis, straßen)
|
21
20
|
end
|
22
21
|
|
23
|
-
def read_german_cities_from_wikipedia
|
24
|
-
# we extract <li> -elements and use the text until "("
|
22
|
+
def read_german_cities_from_wikipedia
|
23
|
+
# we extract <li> -elements and use the text until "("
|
25
24
|
#doc.xpath("//li").at(80)
|
26
|
-
# => #<Nokogiri::XML::Element:0x1ba551c name="li" children=[#<Nokogiri::XML::Element:0x1ba533c name="a" attributes=[#<Nokogiri::XML::Attr:0x1ba52d8 name="href" value="/wiki/Angerm%C3%BCnde">, #<Nokogiri::XML::Attr:0x1ba52c4 name="title" value="Angermünde">] children=[#<Nokogiri::XML::Text:0x1ba4c84 "Angermünde">]>, #<Nokogiri::XML::Text:0x1ba4ae0 " (Brandenburg)">]>
|
25
|
+
# => #<Nokogiri::XML::Element:0x1ba551c name="li" children=[#<Nokogiri::XML::Element:0x1ba533c name="a" attributes=[#<Nokogiri::XML::Attr:0x1ba52d8 name="href" value="/wiki/Angerm%C3%BCnde">, #<Nokogiri::XML::Attr:0x1ba52c4 name="title" value="Angermünde">] children=[#<Nokogiri::XML::Text:0x1ba4c84 "Angermünde">]>, #<Nokogiri::XML::Text:0x1ba4ae0 " (Brandenburg)">]>
|
27
26
|
|
28
27
|
doc = Nokogiri::HTML(open('https://en.wikipedia.org/wiki/List_of_cities_and_towns_in_Germany'))
|
28
|
+
print doc
|
29
29
|
doc.xpath("//li").map{|x| x.text[0 .. x.text.index('(')-2] if x.text.index('(').present? }.compact
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def read_german_cities_and_states_from_wikipedia
|
33
33
|
doc =
|
34
|
-
|
35
|
-
doc.xpath("//li").map do |x|
|
36
|
-
if x.text.index('(').present?
|
37
|
-
|
34
|
+
Nokogiri::HTML(open('https://en.wikipedia.org/wiki/List_of_cities_and_towns_in_Germany'))
|
35
|
+
doc.xpath("//li").map do |x|
|
36
|
+
if x.text.index('(').present?
|
37
|
+
[ x.text[0 .. x.text.index('(')-2] , x.text[ x.text.index('(')+1 .. x.text.index(')')-1] ]
|
38
38
|
end
|
39
39
|
end.compact
|
40
|
-
end
|
40
|
+
end
|
41
41
|
|
42
42
|
end # module
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
{ citi_idx: :unique }
|
63
|
-
end
|
64
|
-
ActiveOrient::Model::Street.create_property :name , type: :string, index: :notunique
|
65
|
-
ActiveOrient::Model::Connects.create_property :distance, type: :integer, index: :notunique
|
66
|
-
ActiveOrient::OrientDB.logger.info { "Vertex- and Edge-Classes rebuilded" }
|
44
|
+
class StreetExample
|
45
|
+
|
46
|
+
include DataImport
|
47
|
+
def initialize db, rebuild: true
|
48
|
+
if rebuild
|
49
|
+
db.delete_class :State
|
50
|
+
db.delete_class :City
|
51
|
+
db.delete_class :Street
|
52
|
+
db.delete_class :CONNECTS
|
53
|
+
db.create_vertex_class :State
|
54
|
+
db.create_vertex_class :City
|
55
|
+
db.create_vertex_class :Street
|
56
|
+
db.create_edge_class :CONNECTS
|
57
|
+
ActiveOrient::Model::State.create_property( :name, type: :string, index: :unique )
|
58
|
+
ActiveOrient::Model::City.create_properties( { name: { type: :string },
|
59
|
+
state: { type: :link, :linked_class => 'State' } }
|
60
|
+
) do
|
61
|
+
{ citi_idx: :unique }
|
67
62
|
end
|
63
|
+
ActiveOrient::Model::Street.create_property :name , type: :string, index: :notunique
|
64
|
+
ActiveOrient::Model::CONNECTS.create_property :distance, type: :integer, index: :notunique
|
65
|
+
ActiveOrient::OrientDB.logger.progname = "StreetsExample#Initialize"
|
66
|
+
ActiveOrient::OrientDB.logger.info { "Vertex- and Edge-Classes rebuilded" }
|
68
67
|
end
|
68
|
+
end
|
69
69
|
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
C.create_edge :from => street_record, :to => cities
|
71
|
+
def read_from_web
|
72
|
+
read_german_cities_and_states_from_wikipedia.each do |city,state|
|
73
|
+
state = State.update_or_create( where: { name: state }).first
|
74
|
+
City.create name: city, state: "##{state.rid}"
|
75
|
+
end
|
76
|
+
ActiveOrient::OrientDB.logger.progname = "StreetsExample#ReadFromWeb"
|
77
|
+
ActiveOrient::OrientDB.logger.info { "#{City.count} Cities imported from Wikipedia " }
|
78
|
+
|
79
|
+
cities_rids = City.all.map &:rid
|
80
|
+
read_german_street_names.each_with_index do |street, i|
|
81
|
+
street_record = Street.create name: street
|
82
|
+
count = i
|
83
|
+
cities = Array.new
|
84
|
+
while count < cities_rids.size && cities.size < 5 do
|
85
|
+
cities << cities_rids[count]
|
86
|
+
count = count + i
|
89
87
|
end
|
90
|
-
|
88
|
+
C.create_edge :from => street_record, :to => cities
|
91
89
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
90
|
+
ActiveOrient::OrientDB.logger.progname = "StreetsExample#ReadFromWeb"
|
91
|
+
ActiveOrient::OrientDB.logger.info { "#{C.count} Edges between Streets and Cities created " }
|
92
|
+
end
|
93
|
+
|
94
|
+
def display_streets_per_state
|
95
|
+
State.all.each do |state|
|
96
|
+
streets= Street.all.map do |street |
|
97
|
+
if street.connects.in.detect{|x| x.state == state }
|
98
|
+
street.name + " connects " + street.connects.in.map( &:name ).join('; ')
|
99
|
+
end
|
100
|
+
end.compact
|
101
|
+
unless streets.empty?
|
102
|
+
puts "..................................."
|
103
|
+
puts state.name
|
104
|
+
puts "..................................."
|
105
|
+
puts streets.join("\n")
|
106
106
|
end
|
107
107
|
end
|
108
|
-
|
108
|
+
end
|
109
|
+
end
|
109
110
|
|
110
111
|
if $0 == __FILE__
|
111
112
|
|
112
|
-
require '../config/boot'
|
113
|
-
require 'open-uri'
|
114
|
-
require 'nokogiri'
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
113
|
+
require '../config/boot'
|
114
|
+
require 'open-uri'
|
115
|
+
require 'nokogiri'
|
116
|
+
|
117
|
+
ActiveOrient::OrientDB.default_server= { user: 'root', password: 'tretretre' }
|
118
|
+
r = ActiveOrient::OrientDB.new database: 'StreetTest'
|
119
|
+
ActiveOrient::OrientDB.logger.level = Logger::INFO
|
120
|
+
s= StreetExample.new r, rebuild: true
|
121
|
+
|
122
|
+
City = r.open_class :City
|
123
|
+
State = r.open_class :State
|
124
|
+
Street = r.open_class :Street
|
125
|
+
C = r.open_class :CONNECTS
|
126
|
+
|
127
|
+
s.read_from_web if City.count.zero?
|
128
|
+
s.display_streets_per_state
|
128
129
|
|
129
130
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'awesome_print'
|
2
|
+
require_relative "../lib/active-orient.rb"
|
3
|
+
|
4
|
+
# Start server
|
5
|
+
ActiveOrient::OrientDB.default_server = { user: 'root', password: 'tretretre' }
|
6
|
+
|
7
|
+
# Select database
|
8
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
9
|
+
r.delete_database database: 'NewTest'
|
10
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
11
|
+
|
12
|
+
print "\n"+"*"*20+"DATABASE"+"*"*20+"\n"
|
13
|
+
|
14
|
+
print "#{r.get_resource} \n" # <--- See the address of the server
|
15
|
+
print "#{r.get_databases} \n" # <--- List available databases
|
16
|
+
|
17
|
+
# r.create_database(database: "Onetwothree") # <--- Create a new database
|
18
|
+
print "#{r.database} \n" # <--- See the working database
|
19
|
+
|
20
|
+
# r.delete_database database: "Onetwothree" # <--- Delete an old database
|
21
|
+
|
22
|
+
print "\n"+"*"*20+"CLASSES"+"*"*20+"\n"
|
23
|
+
|
24
|
+
ap r.get_classes, :indent => -2 # <--- See available classes
|
25
|
+
print "#{r.get_classes 'name'} \n" # <--- See the names of the available classes
|
26
|
+
|
27
|
+
print "#{r.class_hierarchy} \n" # <--- See hierarchy of the classes
|
28
|
+
print "#{r.class_hierarchy base_class: 'V'} \n" # <--- See hierarchy under V (Vectors classes)
|
29
|
+
print "#{r.class_hierarchy base_class: 'E'} \n" # <--- See hierarchy under E (Edges classes)
|
30
|
+
|
31
|
+
print "#{r.database_classes} \n" # See classes without including System classes
|
32
|
+
print "#{r.database_classes include_system_classes: true} \n " # See classes including System classes
|
33
|
+
print "#{r.inspect_classes} \n" # Same as r.database_classes
|
34
|
+
|
35
|
+
|
36
|
+
doc1 = r.create_class "DocumentTest" # Create Document/Vertex/Edge class
|
37
|
+
doc2 = r.create_class "DocumentArriveTest"
|
38
|
+
ver1 = r.create_vertex_class "VertexTest"
|
39
|
+
ver2 = r.create_vertex_class "Vertex_ArriveTest"
|
40
|
+
edg1 = r.create_edge_class "EdgeTest"
|
41
|
+
ver1 = r.open_class "VertexTest" # Same as create_class
|
42
|
+
|
43
|
+
print "\n"+"*"*20+"RECORDS"+"*"*20+"\n"
|
44
|
+
|
45
|
+
a = doc1.create name: "Doc1"
|
46
|
+
a2 = doc1.create name: "Doc12"
|
47
|
+
b = doc2.create name: "Doc2"
|
48
|
+
b2 = doc2.create name: "Doc22"
|
49
|
+
aver = ver1.create vname: "Ver1"
|
50
|
+
aver2 = ver1.create vname: "Ver12"
|
51
|
+
bver = ver2.create vname: "Ver2"
|
52
|
+
bver2 = ver2.create vname: "Ver22"
|
53
|
+
|
54
|
+
edg1.create_edge attributes: {famname: "edg1"}, from: aver, to: [bver, bver2], unique: true
|
55
|
+
nex = edg1.create_edge attributes: {familyname: "edg2"}, from: aver, to: [bver, bver2], unique: true # <--- We don't overwrite since we select a unique
|
56
|
+
nex1 = edg1.create_edge attributes: {familyname: "edg3"}, from: aver, to: [bver, bver2]
|
57
|
+
nex2 = edg1.create_edge attributes: {familyname: "edg4"}, from: aver, to: [bver, bver2]
|
58
|
+
|
59
|
+
print "#{nex1}"
|
60
|
+
print "\n\n BVER = #{bver.rid} \n" # Check the RID of the vertex
|
61
|
+
r.delete_edge nex1, nex2 # Used to delete edges
|
62
|
+
r.delete_class doc2 # Used to delete a class
|
63
|
+
doc2 = r.create_class "Document_Arrive_Test"
|
64
|
+
|
65
|
+
print "\n"+"*"*20+"PROPERTY"+"*"*20+"\n"
|
66
|
+
|
67
|
+
r.create_property doc2, :name, type: :string, index: :string #add one property
|
68
|
+
doc2.create_property :familyname, type: :string, index: :string #the same but starting directly from the class
|
69
|
+
r.create_properties doc2, {age: {type: :integer}, address: {type: :string}} #add more properties
|
70
|
+
doc2.create_properties({feetsize: {type: :integer}, country: {type: :string}})
|
71
|
+
b = doc2.create name: "Lucas", age: 91 #add more properties directly from the class
|
72
|
+
|
73
|
+
print "\n"+"*"*20+"\n"
|
74
|
+
r.delete_property doc2, "age" #delete one property
|
75
|
+
doc2.delete_property "country" #delete one property directly from the class
|
76
|
+
print "\n"+"*"*20+"\n"
|
77
|
+
|
78
|
+
ap r.get_class_properties doc2 #get the properties of a class
|
79
|
+
ap doc2.get_class_properties #get the properties of a class directly from the class
|
80
|
+
|
81
|
+
print "\n"+"*"*20+"\n"
|
82
|
+
|
83
|
+
r.print_class_properties doc2 #get the properties of a class in nice way
|
84
|
+
doc2.print_class_properties #get the properties of a class in nice way directly from the class
|
85
|
+
|
86
|
+
gg = r.create_document doc2, attributes: {name: "Test"}
|
87
|
+
hh = doc2.create_document attributes: {name: "Code"}
|
88
|
+
|
89
|
+
r.delete_document gg, hh # delete a document from database
|
90
|
+
doc2.delete_document hh # delete a document from a class
|
91
|
+
|
92
|
+
r.create_index doc2, name: "name" #Create index
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'awesome_print'
|
2
|
+
require_relative "../lib/active-orient.rb"
|
3
|
+
|
4
|
+
# Start server
|
5
|
+
ActiveOrient::OrientDB.default_server= { user: 'root', password: 'tretretre' }
|
6
|
+
|
7
|
+
# Select database
|
8
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
9
|
+
|
10
|
+
#r.delete_class "Document_Test"
|
11
|
+
doc1 = r.create_class "DocumentTest" # Create Document/Vertex/Edge class
|
12
|
+
doc2 = r.create_class "DocumentArrive_Test"
|
13
|
+
ver1 = r.create_vertex_class "VertexTest"
|
14
|
+
ver2 = r.create_vertex_class "VertexArriveTest"
|
15
|
+
edg1 = r.create_edge_class "EdgeTest"
|
16
|
+
ver1 = r.open_class "VertexTest" # Same as create_class
|
17
|
+
|
18
|
+
par = r.get_documents from: "DocumentTest", where: {name: "Doc1"} # Get documents
|
19
|
+
par = doc1.get_documents where: {name: "Doc1"} # Same as above
|
20
|
+
print "0 "
|
21
|
+
ap par, :indent => -2
|
22
|
+
|
23
|
+
num = r.count_documents from: "DocumentTest", where: {name: "Doc1"}
|
24
|
+
num2 = doc1.count where: {name: "Doc1"}
|
25
|
+
print "\n1 COUNT: #{num2} \n\n"
|
26
|
+
|
27
|
+
r.create_or_update_document doc1, set: {familyname: "John"}, where: {name: "Doc1"}
|
28
|
+
r.update_or_create_documents doc1, where: {name: "Doc1"}, set: {age: 91}
|
29
|
+
doc1.update_or_create_documents where: {name: "Doc1"}, set: {age: 91}
|
30
|
+
doc1.update_or_create_documents where: {name: "Doc2"}, set: {age: 91}
|
31
|
+
par = doc1.get_documents where: {name: "Doc1"}
|
32
|
+
#ap par, :indent => -2
|
33
|
+
|
34
|
+
print "2 #{par[0].attributes} \n\n" # Access attributes
|
35
|
+
print "3 #{par[0].metadata} \n\n" # Access metadata
|
36
|
+
|
37
|
+
r.delete_documents doc1, where: {name: "Doc2"}
|
38
|
+
doc1.delete_documents where: {name: "Doc2"}
|
39
|
+
|
40
|
+
a = r.get_document "1:0" # Get by RID
|
41
|
+
|
42
|
+
r.patch_document "1:0" do {name: "is a test"} end
|
43
|
+
|
44
|
+
r.update_documents doc1, set: {age: 191}, where: {name: "Doc1"} # Update a document
|
45
|
+
doc1.update_documents set: {age: 191}, where: {name: "Doc1"}
|
46
|
+
|
47
|
+
a = r.execute "Document_Test" do # To execute commands
|
48
|
+
[{type: "cmd", language: 'sql', command: "SELECT * FROM DocumentTest WHERE name = 'Doc1'"}]
|
49
|
+
end
|
50
|
+
print "\n4 #{a} \n \n"
|
51
|
+
|
52
|
+
a = r.classname doc1
|
53
|
+
a = doc1.classname
|
54
|
+
print "5 #{a} \n \n"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'awesome_print'
|
2
|
+
require_relative "../lib/active-orient.rb"
|
3
|
+
|
4
|
+
# Start server
|
5
|
+
ActiveOrient::OrientDB.default_server= { user: 'root', password: 'tretretre' }
|
6
|
+
|
7
|
+
# Select database
|
8
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
9
|
+
|
10
|
+
doc1 = r.create_class "DocumentTest"
|
11
|
+
ver1 = r.create_vertex_class "VertexTest"
|
12
|
+
a = doc1.create name: "Doc1"
|
13
|
+
v = ver1.create name: "Ver"
|
14
|
+
|
15
|
+
out = doc1.orientdb_class name: "Doc2345" # Used to instantiate an ActiveOrient Model
|
16
|
+
print "1 #{out} \n"
|
17
|
+
|
18
|
+
out = ver1.autoload_object "16:35" # Used to get a record by rid
|
19
|
+
print "2 #{out} \n"
|
20
|
+
|
21
|
+
print "3 #{ver1.superClass} \n" # Check superClass of the class
|
22
|
+
|
23
|
+
print "4 #{v.class} \n"
|
24
|
+
|
25
|
+
print "5 #{doc1} \n"
|
26
|
+
|
27
|
+
print "6 #{a} \n"
|
28
|
+
|
29
|
+
print "7 #{v} \n"
|
30
|
+
|
31
|
+
a = v.classname # Class of v
|
32
|
+
print "8 #{a} \n"
|
33
|
+
|
34
|
+
a = v.rid
|
35
|
+
print "9 #{a} \n" # RID of v
|
36
|
+
|
37
|
+
a = ver1.count where: {name: "Ver"}
|
38
|
+
print "10 #{a} \n"
|
39
|
+
|
40
|
+
print "11 #{v.to_human} \n" # Human version
|
41
|
+
|
42
|
+
print "12 #{v.content_attributes} \n" # Return attributes
|
43
|
+
|
44
|
+
print "13 #{v.default_attributes} \n" # Return created and updated
|
45
|
+
|
46
|
+
print "14 #{v.set_attribute_defaults} \n" # Set up
|
47
|
+
|
48
|
+
print "15 #{v.metadata} \n" # Set up
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative "../lib/active-orient.rb"
|
2
|
+
|
3
|
+
ActiveOrient::OrientDB.default_server = { user: 'root', password: 'tretretre' }
|
4
|
+
r = ActiveOrient::OrientDB.new database: 'NewTest'
|
5
|
+
|
6
|
+
doc1 = r.open_class "DocumentTest" # Create Document/Vertex/Edge class
|
7
|
+
doc2 = r.open_class "DocumentArrive_Test"
|
8
|
+
doc1.create_property :familyname, type: :string
|
9
|
+
doc1.create_property :family, type: :linkset, other_class: "DocumentTest"
|
10
|
+
|
11
|
+
a1 = doc1.create name: "DocA", value: 34
|
12
|
+
a2 = doc1.create name: "DocB", value: 34
|
13
|
+
a3 = doc1.create name: "DocC", value: 34
|
14
|
+
a4 = doc1.create name: "DocD", value: 30
|
15
|
+
doc1.create name: "DocE", value: 30
|
16
|
+
doc1.create name: "DocF", value: 30
|
17
|
+
|
18
|
+
print "#{a1.ciao} \n"
|
19
|
+
a1.family = [a2, a3]
|
20
|
+
print "#{a1["family"].name} \n"
|
21
|
+
print "---> #{a1.family.class}\n"
|
22
|
+
a1["family"] << a4
|
23
|
+
print "#{a1.family.name} \n"
|
24
|
+
|
25
|
+
|
26
|
+
# ActiveOrient::OrientDB.methods.each do |m|
|
27
|
+
# print "#{m} \n"
|
28
|
+
# end
|
@@ -0,0 +1,21 @@
|
|
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
|