diametric 0.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +28 -0
- data/Jarfile +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +264 -0
- data/Rakefile +49 -0
- data/bin/datomic-rest +33 -0
- data/bin/download-datomic +13 -0
- data/datomic_version.yml +4 -0
- data/diametric-java.gemspec +39 -0
- data/ext/diametric/DiametricCollection.java +147 -0
- data/ext/diametric/DiametricConnection.java +113 -0
- data/ext/diametric/DiametricDatabase.java +107 -0
- data/ext/diametric/DiametricEntity.java +90 -0
- data/ext/diametric/DiametricListenableFuture.java +47 -0
- data/ext/diametric/DiametricObject.java +66 -0
- data/ext/diametric/DiametricPeer.java +414 -0
- data/ext/diametric/DiametricService.java +102 -0
- data/ext/diametric/DiametricUUID.java +61 -0
- data/ext/diametric/DiametricUtils.java +183 -0
- data/lib/boolean_type.rb +3 -0
- data/lib/diametric.rb +42 -0
- data/lib/diametric/config.rb +54 -0
- data/lib/diametric/config/environment.rb +42 -0
- data/lib/diametric/entity.rb +659 -0
- data/lib/diametric/errors.rb +13 -0
- data/lib/diametric/generators/active_model.rb +42 -0
- data/lib/diametric/persistence.rb +48 -0
- data/lib/diametric/persistence/common.rb +82 -0
- data/lib/diametric/persistence/peer.rb +154 -0
- data/lib/diametric/persistence/rest.rb +107 -0
- data/lib/diametric/query.rb +259 -0
- data/lib/diametric/railtie.rb +52 -0
- data/lib/diametric/rest_service.rb +74 -0
- data/lib/diametric/service_base.rb +77 -0
- data/lib/diametric/transactor.rb +86 -0
- data/lib/diametric/version.rb +3 -0
- data/lib/diametric_service.jar +0 -0
- data/lib/tasks/create_schema.rb +27 -0
- data/lib/tasks/diametric_config.rb +45 -0
- data/lib/value_enums.rb +8 -0
- data/spec/conf_helper.rb +55 -0
- data/spec/config/free-transactor-template.properties +73 -0
- data/spec/config/logback.xml +59 -0
- data/spec/data/seattle-data0.dtm +452 -0
- data/spec/data/seattle-data1.dtm +326 -0
- data/spec/developer_create_sample.rb +39 -0
- data/spec/developer_query_spec.rb +120 -0
- data/spec/diametric/config_spec.rb +60 -0
- data/spec/diametric/entity_spec.rb +476 -0
- data/spec/diametric/peer_api_spec.rb +147 -0
- data/spec/diametric/persistence/peer_many2many_spec.rb +76 -0
- data/spec/diametric/persistence/peer_spec.rb +27 -0
- data/spec/diametric/persistence/rest_spec.rb +30 -0
- data/spec/diametric/persistence_spec.rb +59 -0
- data/spec/diametric/query_spec.rb +118 -0
- data/spec/diametric/rest_service_spec.rb +56 -0
- data/spec/diametric/transactor_spec.rb +68 -0
- data/spec/integration_spec.rb +107 -0
- data/spec/parent_child_sample.rb +42 -0
- data/spec/peer_integration_spec.rb +121 -0
- data/spec/peer_seattle_spec.rb +200 -0
- data/spec/rc2013_seattle_big.rb +82 -0
- data/spec/rc2013_seattle_small.rb +60 -0
- data/spec/rc2013_simple_sample.rb +72 -0
- data/spec/seattle_integration_spec.rb +106 -0
- data/spec/simple_validation_sample.rb +31 -0
- data/spec/spec_helper.rb +63 -0
- data/spec/support/entities.rb +157 -0
- data/spec/support/gen_entity_class.rb +9 -0
- data/spec/support/persistence_examples.rb +104 -0
- data/spec/test_version_file.yml +4 -0
- metadata +290 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'conf_helper'
|
2
|
+
require 'support/entities'
|
3
|
+
|
4
|
+
describe "Seattle Sample", :jruby => true do
|
5
|
+
context Community do
|
6
|
+
before(:all) do
|
7
|
+
datomic_uri = "datomic:mem://seattle-#{SecureRandom.uuid}"
|
8
|
+
@conn = Diametric::Persistence::Peer.connect(datomic_uri)
|
9
|
+
Neighborhood.create_schema(@conn).get
|
10
|
+
District.create_schema(@conn).get
|
11
|
+
Community.create_schema(@conn).get
|
12
|
+
filename = File.join(File.dirname(__FILE__), "data", "seattle-data0.dtm")
|
13
|
+
list = Diametric::Persistence::Utils.read_all(filename)
|
14
|
+
map = @conn.transact(list.first).get
|
15
|
+
end
|
16
|
+
|
17
|
+
after(:all) do
|
18
|
+
@conn.release
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should do queries" do
|
22
|
+
query = Diametric::Query.new(Community, @conn)
|
23
|
+
results = query.all #150
|
24
|
+
binding.pry
|
25
|
+
|
26
|
+
query = Diametric::Query.new(Neighborhood, @conn, true).where(:name => "Capitol Hill")
|
27
|
+
binding.pry
|
28
|
+
# Navigating up
|
29
|
+
#
|
30
|
+
# 6 communities have their neighborhood whoose name is "Capitol
|
31
|
+
# Hill"
|
32
|
+
#
|
33
|
+
communities = query.first.community_from_this_neighborhood(@conn)
|
34
|
+
binding.pry
|
35
|
+
|
36
|
+
communities.size.should == 6
|
37
|
+
|
38
|
+
communities.collect(&:name).should =~
|
39
|
+
["15th Ave Community",
|
40
|
+
"Capitol Hill Community Council",
|
41
|
+
"Capitol Hill Housing",
|
42
|
+
"Capitol Hill Triangle",
|
43
|
+
"CHS Capitol Hill Seattle Blog",
|
44
|
+
"KOMO Communities - Captol Hill"]
|
45
|
+
binding.pry
|
46
|
+
|
47
|
+
#
|
48
|
+
# Adds another set of data
|
49
|
+
#
|
50
|
+
# Makes sure "before" state
|
51
|
+
#
|
52
|
+
query = Diametric::Query.new(Community, @conn)
|
53
|
+
results = query.all
|
54
|
+
results.size.should == 150
|
55
|
+
binding.pry
|
56
|
+
|
57
|
+
past = Time.now
|
58
|
+
|
59
|
+
binding.pry
|
60
|
+
|
61
|
+
filename1 = File.join(File.dirname(__FILE__), "data", "seattle-data1.dtm")
|
62
|
+
list = Diametric::Persistence::Utils.read_all(filename1)
|
63
|
+
|
64
|
+
map2 = @conn.transact(list.first).get
|
65
|
+
query = Diametric::Query.new(Community, @conn)
|
66
|
+
results = query.all
|
67
|
+
results.size.should == 258
|
68
|
+
|
69
|
+
binding.pry
|
70
|
+
|
71
|
+
past_db = @conn.db.as_of(past)
|
72
|
+
|
73
|
+
binding.pry
|
74
|
+
|
75
|
+
query = Diametric::Query.new(Community, past_db)
|
76
|
+
results = query.all
|
77
|
+
results.size.should == 150
|
78
|
+
|
79
|
+
binding.pry
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'conf_helper'
|
2
|
+
require 'support/entities'
|
3
|
+
|
4
|
+
describe Diametric::Entity, :jruby => true do
|
5
|
+
context Community do
|
6
|
+
before(:all) do
|
7
|
+
datomic_uri = "datomic:mem://community-#{SecureRandom.uuid}"
|
8
|
+
@conn = Diametric::Persistence::Peer.connect(datomic_uri)
|
9
|
+
Neighborhood.create_schema(@conn).get
|
10
|
+
District.create_schema(@conn).get
|
11
|
+
Community.create_schema(@conn).get
|
12
|
+
binding.pry
|
13
|
+
end
|
14
|
+
after(:all) do
|
15
|
+
@conn.release
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should save instance" do
|
19
|
+
district = District.new
|
20
|
+
district.name = "East"
|
21
|
+
district.region = District::Region::E
|
22
|
+
binding.pry
|
23
|
+
neighborhood = Neighborhood.new
|
24
|
+
neighborhood.name = "Capitol Hill"
|
25
|
+
neighborhood.district = district
|
26
|
+
community = Community.new
|
27
|
+
community.name = "15th Ave Community"
|
28
|
+
community.url = "http://groups.yahoo.com/group/15thAve_Community/"
|
29
|
+
community.neighborhood = neighborhood
|
30
|
+
community.category = ["15th avenue residents"]
|
31
|
+
community.orgtype = Community::Orgtype::COMMUNITY
|
32
|
+
community.type = Community::Type::EMAIL_LIST
|
33
|
+
binding.pry
|
34
|
+
res = community.save(@conn)
|
35
|
+
binding.pry
|
36
|
+
|
37
|
+
query = Diametric::Query.new(Community, @conn, true)
|
38
|
+
community = query.where(:name => "15th Ave Community").first
|
39
|
+
binding.pry
|
40
|
+
puts "community.name: #{community.name}"
|
41
|
+
puts "community.url: #{community.url}"
|
42
|
+
puts "community.category: #{community.category}"
|
43
|
+
puts "community.category: #{community.category.to_a.join(",")}"
|
44
|
+
puts "community.orgtype: #{community.orgtype}"
|
45
|
+
puts "community.orgtype == Community::Orgtype::COMMUNITY ? #{community.orgtype == Community::Orgtype::COMMUNITY}"
|
46
|
+
puts "community.type: #{community.type}"
|
47
|
+
puts "community.type == Community::Type::EMAIL_LIST ? #{community.type == Community::Type::EMAIL_LIST}"
|
48
|
+
binding.pry
|
49
|
+
puts "community.neighborhood.dbid: #{community.neighborhood.dbid}"
|
50
|
+
puts "community.neighborhood.name: #{community.neighborhood.name}"
|
51
|
+
binding.pry
|
52
|
+
puts "community.neighborhood.district.dbid: #{community.neighborhood.district.dbid}"
|
53
|
+
puts "community.neighborhood.district.name: #{community.neighborhood.district.name}"
|
54
|
+
puts "community.neighborhood.district.region: #{community.neighborhood.district.region}"
|
55
|
+
puts "community.neighborhood.district.region == District::Region::E ? #{community.neighborhood.district.region == District::Region::E}"
|
56
|
+
binding.pry
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'conf_helper'
|
2
|
+
|
3
|
+
class Person
|
4
|
+
include Diametric::Entity
|
5
|
+
include Diametric::Persistence::Peer
|
6
|
+
|
7
|
+
attribute :name, String
|
8
|
+
attribute :nerd_rate, Integer
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "RailsConf 2013", :jruby => true do
|
12
|
+
context Person do
|
13
|
+
before(:all) do
|
14
|
+
datomic_uri = "datomic:mem://person-#{SecureRandom.uuid}"
|
15
|
+
@conn = Diametric::Persistence::Peer.connect(datomic_uri)
|
16
|
+
binding.pry
|
17
|
+
end
|
18
|
+
after(:all) do
|
19
|
+
@conn.release
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should create schema and save instaces" do
|
23
|
+
binding.pry
|
24
|
+
Person.create_schema(@conn).get
|
25
|
+
|
26
|
+
foo = Person.new
|
27
|
+
foo.name = "Yoko"
|
28
|
+
foo.nerd_rate = 50
|
29
|
+
binding.pry
|
30
|
+
foo.save
|
31
|
+
|
32
|
+
bar = Person.new(:name => "Clinton", :nerd_rate => 98)
|
33
|
+
binding.pry
|
34
|
+
bar.save
|
35
|
+
|
36
|
+
query = Diametric::Query.new(Person, @conn.db, true)
|
37
|
+
result = query.all
|
38
|
+
binding.pry
|
39
|
+
|
40
|
+
query = Diametric::Query.new(Person, @conn.db, true).where(:name => "Yoko")
|
41
|
+
result = query.all
|
42
|
+
binding.pry
|
43
|
+
|
44
|
+
past = Time.now
|
45
|
+
binding.pry
|
46
|
+
|
47
|
+
yoko = result.first
|
48
|
+
yoko.update_attributes(:nerd_rate => 70)
|
49
|
+
binding.pry
|
50
|
+
|
51
|
+
query = Diametric::Query.new(Person, @conn.db, true).where(:name => "Yoko")
|
52
|
+
result = query.all
|
53
|
+
binding.pry
|
54
|
+
|
55
|
+
past_db = @conn.db.as_of(past)
|
56
|
+
binding.pry
|
57
|
+
|
58
|
+
query = Diametric::Query.new(Person, past_db, true).where(:name => "Yoko")
|
59
|
+
result = query.all
|
60
|
+
binding.pry
|
61
|
+
|
62
|
+
query = Diametric::Query.new(Person, @conn.db, true).filter(:>, :nerd_rate, 60)
|
63
|
+
result = query.all
|
64
|
+
binding.pry
|
65
|
+
|
66
|
+
query = Diametric::Query.new(Person, past_db, true).filter(:>, :nerd_rate, 60)
|
67
|
+
result = query.all
|
68
|
+
binding.pry
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'diametric/entity'
|
3
|
+
require 'datomic/client'
|
4
|
+
|
5
|
+
describe "Seattle Sample", :integration => true, :jruby => true do
|
6
|
+
context Diametric::Persistence::Utils do
|
7
|
+
before(:all) do
|
8
|
+
datomic_uri = "datomic:mem://utils-#{SecureRandom.uuid}"
|
9
|
+
@u_conn = Diametric::Persistence::Peer.connect(datomic_uri)
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:all) do
|
13
|
+
@u_conn.release
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should read all data from filename" do
|
17
|
+
filename = File.join(File.dirname(__FILE__), "data", "seattle-data0.dtm")
|
18
|
+
list = Diametric::Persistence::Utils.read_all(filename)
|
19
|
+
list.first.size.should == 450
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should transact data read from file" do
|
23
|
+
Neighborhood.create_schema(@u_conn).get
|
24
|
+
District.create_schema(@u_conn).get
|
25
|
+
Community.create_schema(@u_conn).get
|
26
|
+
filename = File.join(File.dirname(__FILE__), "data", "seattle-data0.dtm")
|
27
|
+
list = Diametric::Persistence::Utils.read_all(filename)
|
28
|
+
map = @u_conn.transact(list.first).get
|
29
|
+
map.should_not be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context Community do
|
34
|
+
before(:all) do
|
35
|
+
datomic_uri = "datomic:mem://community-#{SecureRandom.uuid}"
|
36
|
+
@s_conn1 = Diametric::Persistence::Peer.connect(datomic_uri)
|
37
|
+
Neighborhood.create_schema(@s_conn1).get
|
38
|
+
District.create_schema(@s_conn1).get
|
39
|
+
Community.create_schema(@s_conn1).get
|
40
|
+
filename = File.join(File.dirname(__FILE__), "data", "seattle-data0.dtm")
|
41
|
+
list = Diametric::Persistence::Utils.read_all(filename)
|
42
|
+
map = @s_conn1.transact(list.first).get
|
43
|
+
end
|
44
|
+
|
45
|
+
after(:all) do
|
46
|
+
@s_conn1.release
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should get all community names" do
|
50
|
+
query = Diametric::Query.new(Community, @s_conn1)
|
51
|
+
results = query.all
|
52
|
+
results.size.should == 150
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should get reverse reference" do
|
56
|
+
query = Diametric::Query.new(Neighborhood, @s_conn1, true).where(:name => "Capitol Hill")
|
57
|
+
communities = query.first.community_from_this_neighborhood(@s_conn1)
|
58
|
+
communities.size.should == 6
|
59
|
+
communities.collect(&:name).should =~
|
60
|
+
["15th Ave Community",
|
61
|
+
"Capitol Hill Community Council",
|
62
|
+
"Capitol Hill Housing",
|
63
|
+
"Capitol Hill Triangle",
|
64
|
+
"CHS Capitol Hill Seattle Blog",
|
65
|
+
"KOMO Communities - Captol Hill"]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context Community do
|
70
|
+
before(:all) do
|
71
|
+
datomic_uri = "datomic:mem://community-#{SecureRandom.uuid}"
|
72
|
+
@s_conn2 = Diametric::Persistence::Peer.connect(datomic_uri)
|
73
|
+
Neighborhood.create_schema(@s_conn2).get
|
74
|
+
District.create_schema(@s_conn2).get
|
75
|
+
Community.create_schema(@s_conn2).get
|
76
|
+
filename0 = File.join(File.dirname(__FILE__), "data", "seattle-data0.dtm")
|
77
|
+
list = Diametric::Persistence::Utils.read_all(filename0)
|
78
|
+
map0 = @s_conn2.transact(list.first).get
|
79
|
+
end
|
80
|
+
|
81
|
+
after(:all) do
|
82
|
+
@s_conn2.release
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should add another set of data" do
|
86
|
+
query = Diametric::Query.new(Community, @s_conn2)
|
87
|
+
results = query.all
|
88
|
+
results.size.should == 150
|
89
|
+
|
90
|
+
past = Time.now
|
91
|
+
|
92
|
+
filename1 = File.join(File.dirname(__FILE__), "data", "seattle-data1.dtm")
|
93
|
+
list = Diametric::Persistence::Utils.read_all(filename1)
|
94
|
+
|
95
|
+
map2 = @s_conn2.transact(list.first).get
|
96
|
+
query = Diametric::Query.new(Community, @s_conn2)
|
97
|
+
results = query.all
|
98
|
+
results.size.should == 258
|
99
|
+
|
100
|
+
past_db = @s_conn2.db.as_of(past)
|
101
|
+
query = Diametric::Query.new(Community, past_db)
|
102
|
+
results = query.all
|
103
|
+
results.size.should == 150
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'conf_helper'
|
2
|
+
|
3
|
+
class Person
|
4
|
+
include Diametric::Entity
|
5
|
+
include Diametric::Persistence::Peer
|
6
|
+
|
7
|
+
attribute :name, String
|
8
|
+
validates_presence_of :name
|
9
|
+
attribute :nerd_rate, Integer
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "RailsConf 2013", :jruby => true do
|
13
|
+
context Person do
|
14
|
+
before(:all) do
|
15
|
+
datomic_uri = "datomic:mem://person-#{SecureRandom.uuid}"
|
16
|
+
@conn = Diametric::Persistence::Peer.connect(datomic_uri)
|
17
|
+
end
|
18
|
+
after(:all) do
|
19
|
+
@conn.release
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should create schema and save instaces" do
|
23
|
+
binding.pry
|
24
|
+
Person.create_schema(@conn).get
|
25
|
+
|
26
|
+
foo = Person.new
|
27
|
+
binding.pry
|
28
|
+
foo.save
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
4
|
+
require 'lock_jar'
|
5
|
+
jar_file = File.join(File.dirname(__FILE__), "..", "Jarfile")
|
6
|
+
lock_file = File.join(File.dirname(__FILE__), "..", "Jarfile.lock")
|
7
|
+
LockJar.lock(jar_file)
|
8
|
+
LockJar.install(lock_file)
|
9
|
+
LockJar.load(lock_file)
|
10
|
+
end
|
11
|
+
require 'diametric'
|
12
|
+
require 'diametric/rest_service'
|
13
|
+
require 'diametric/transactor'
|
14
|
+
Dir["./spec/support/**/*.rb"].each {|f| require f}
|
15
|
+
|
16
|
+
RSpec.configure do |c|
|
17
|
+
# c.fail_fast = true
|
18
|
+
|
19
|
+
c.filter_run_excluding :integration => true unless ENV['INTEGRATION']
|
20
|
+
c.filter_run_excluding :jruby => (not is_jruby?)
|
21
|
+
c.filter_run_excluding :service => true unless ENV['RESTSERVICE']
|
22
|
+
c.filter_run_excluding :transactor => true unless ENV['TRANSACTOR']
|
23
|
+
|
24
|
+
c.filter_run_including :focused => true
|
25
|
+
c.alias_example_to :fit, :focused => true
|
26
|
+
|
27
|
+
c.run_all_when_everything_filtered = true
|
28
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
29
|
+
|
30
|
+
c.before(:suite) do
|
31
|
+
@rest = Diametric::RestService.new("spec/test_version_file.yml", "tmp/datomic")
|
32
|
+
@rest.start(:port => 46291, :db_alias => @storage, :uri => "datomic:mem://")
|
33
|
+
PID = @rest.pid
|
34
|
+
if ENV['TRANSACTOR']
|
35
|
+
FileUtils.cp(File.join('spec', 'config', 'logback.xml'), File.join('bin', 'logback.xml'))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
c.after(:suite) do
|
40
|
+
Diametric::Persistence::Peer.shutdown(true) if is_jruby?
|
41
|
+
Process.kill("HUP", PID)
|
42
|
+
if ENV['TRANSACTOR']
|
43
|
+
FileUtils.rm(File.join('bin', 'logback.xml'), :force => true)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
shared_examples "ActiveModel" do |model|
|
49
|
+
require 'test/unit/assertions'
|
50
|
+
require 'active_model/lint'
|
51
|
+
include Test::Unit::Assertions
|
52
|
+
include ActiveModel::Lint::Tests
|
53
|
+
|
54
|
+
active_model_lints = ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/)
|
55
|
+
|
56
|
+
let(:model) { subject }
|
57
|
+
|
58
|
+
active_model_lints.each do |test_name|
|
59
|
+
it "#{test_name.sub(/^test_/, '')}" do
|
60
|
+
send(test_name)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'diametric/entity'
|
4
|
+
require 'diametric/persistence'
|
5
|
+
require 'diametric/persistence/peer'
|
6
|
+
require 'diametric/persistence/rest'
|
7
|
+
|
8
|
+
# Prevent CRuby from blowing up
|
9
|
+
module Diametric
|
10
|
+
module Persistence
|
11
|
+
module Peer
|
12
|
+
end
|
13
|
+
module Utils
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Person
|
19
|
+
include Diametric::Entity
|
20
|
+
|
21
|
+
attribute :name, String, :index => true
|
22
|
+
attribute :email, String, :cardinality => :many
|
23
|
+
attribute :birthday, DateTime
|
24
|
+
attribute :awesome, :boolean, :doc => "Is this person awesome?"
|
25
|
+
attribute :ssn, String, :unique => :value
|
26
|
+
attribute :secret_name, String, :unique => :identity
|
27
|
+
attribute :bio, String, :fulltext => true
|
28
|
+
attribute :middle_name, String, :default => "Danger"
|
29
|
+
attribute :nicknames, String, :cardinality => :many, :default => ["Buddy", "Pal"]
|
30
|
+
attribute :parent, Ref, :cardinality => :many, :doc => "A person's parent"
|
31
|
+
end
|
32
|
+
|
33
|
+
class Goat
|
34
|
+
include Diametric::Entity
|
35
|
+
|
36
|
+
attribute :name, String
|
37
|
+
attribute :birthday, DateTime
|
38
|
+
end
|
39
|
+
|
40
|
+
class Robin
|
41
|
+
include Diametric::Entity
|
42
|
+
include Diametric::Persistence::REST
|
43
|
+
|
44
|
+
attribute :name, String
|
45
|
+
validates_presence_of :name
|
46
|
+
attribute :age, Integer
|
47
|
+
end
|
48
|
+
|
49
|
+
class Penguin
|
50
|
+
include Diametric::Entity
|
51
|
+
include Diametric::Persistence::Peer
|
52
|
+
|
53
|
+
attribute :name, String
|
54
|
+
attribute :age, Integer
|
55
|
+
end
|
56
|
+
|
57
|
+
class Rat
|
58
|
+
include Diametric::Entity
|
59
|
+
include Diametric::Persistence::Peer
|
60
|
+
|
61
|
+
attribute :name, String, :index => true
|
62
|
+
attribute :age, Integer
|
63
|
+
end
|
64
|
+
|
65
|
+
class Mouse
|
66
|
+
include Diametric::Entity
|
67
|
+
include Diametric::Persistence::REST
|
68
|
+
|
69
|
+
attribute :name, String, :index => true
|
70
|
+
attribute :age, Integer
|
71
|
+
end
|
72
|
+
|
73
|
+
class Author
|
74
|
+
include Diametric::Entity
|
75
|
+
include Diametric::Persistence::Peer
|
76
|
+
|
77
|
+
attribute :name, String
|
78
|
+
attribute :books, Ref, :cardinality => :many
|
79
|
+
end
|
80
|
+
|
81
|
+
class Book
|
82
|
+
include Diametric::Entity
|
83
|
+
include Diametric::Persistence::Peer
|
84
|
+
|
85
|
+
attribute :title, String
|
86
|
+
attribute :authors, Ref, :cardinality => :many
|
87
|
+
end
|
88
|
+
|
89
|
+
class Choice
|
90
|
+
include Diametric::Entity
|
91
|
+
include Diametric::Persistence::Peer
|
92
|
+
|
93
|
+
attribute :item, String
|
94
|
+
attribute :checked, Boolean
|
95
|
+
end
|
96
|
+
|
97
|
+
class Customer
|
98
|
+
include Diametric::Entity
|
99
|
+
include Diametric::Persistence::Peer
|
100
|
+
|
101
|
+
attribute :name, String
|
102
|
+
attribute :id, UUID
|
103
|
+
end
|
104
|
+
|
105
|
+
class Account
|
106
|
+
include Diametric::Entity
|
107
|
+
include Diametric::Persistence::Peer
|
108
|
+
|
109
|
+
attribute :name, String
|
110
|
+
attribute :deposit, Float, :cardinality => :many
|
111
|
+
attribute :amount, Double
|
112
|
+
end
|
113
|
+
|
114
|
+
class Organization
|
115
|
+
include Diametric::Entity
|
116
|
+
include Diametric::Persistence::REST
|
117
|
+
|
118
|
+
attribute :name, String, :cardinality => :one, :fulltext => true, :doc => "A organization's name"
|
119
|
+
attribute :url, String, :cardinality => :one, :doc => "A organization's url"
|
120
|
+
attribute :neighborhood, Ref, :cardinality => :one, :doc => "A organization's neighborhood"
|
121
|
+
attribute :category, String, :cardinality => :many, :fulltext => true, :doc => "All organization categories"
|
122
|
+
attribute :orgtype, Ref, :cardinality => :one, :doc => "A organization orgtype enum value"
|
123
|
+
attribute :type, Ref, :cardinality => :one, :doc => "A organization type enum value"
|
124
|
+
enum :orgtype, [:community, :commercial, :nonprofit, :personal]
|
125
|
+
enum :type, [:email_list, :twitter, :facebook_page, :blog, :website, :wiki, :myspace, :ning]
|
126
|
+
end
|
127
|
+
|
128
|
+
class Community
|
129
|
+
include Diametric::Entity
|
130
|
+
include Diametric::Persistence::Peer
|
131
|
+
|
132
|
+
attribute :name, String, :cardinality => :one, :fulltext => true, :doc => "A community's name"
|
133
|
+
attribute :url, String, :cardinality => :one, :doc => "A community's url"
|
134
|
+
attribute :neighborhood, Ref, :cardinality => :one, :doc => "A community's neighborhood"
|
135
|
+
attribute :category, String, :cardinality => :many, :fulltext => true, :doc => "All community categories"
|
136
|
+
attribute :orgtype, Ref, :cardinality => :one, :doc => "A community orgtype enum value"
|
137
|
+
attribute :type, Ref, :cardinality => :one, :doc => "A community type enum value"
|
138
|
+
enum :orgtype, [:community, :commercial, :nonprofit, :personal]
|
139
|
+
enum :type, [:email_list, :twitter, :facebook_page, :blog, :website, :wiki, :myspace, :ning]
|
140
|
+
end
|
141
|
+
|
142
|
+
class Neighborhood
|
143
|
+
include Diametric::Entity
|
144
|
+
include Diametric::Persistence::Peer
|
145
|
+
|
146
|
+
attribute :name, String, :cardinality => :one, :unique => :identity, :doc => "A unique neighborhood name (upsertable)"
|
147
|
+
attribute :district, Ref, :cardinality => :one, :doc => "A neighborhood's district"
|
148
|
+
end
|
149
|
+
|
150
|
+
class District
|
151
|
+
include Diametric::Entity
|
152
|
+
include Diametric::Persistence::Peer
|
153
|
+
|
154
|
+
attribute :name, String, :cardinality => :one, :unique => :identity, :doc => "A unique district name (upsertable)"
|
155
|
+
attribute :region, Ref, :cardinality => :one, :doc => "A district region enum value"
|
156
|
+
enum :region, [:n, :ne, :e, :se, :s, :sw, :w, :nw]
|
157
|
+
end
|