sdb_dal 0.0.1
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.
- data/lib/sdb_dal/and_condition.rb +10 -0
- data/lib/sdb_dal/attribute_range.rb +57 -0
- data/lib/sdb_dal/domain_attribute_description.rb +83 -0
- data/lib/sdb_dal/domain_object.rb +642 -0
- data/lib/sdb_dal/domain_object_cache_item.rb +14 -0
- data/lib/sdb_dal/equals_condition.rb +18 -0
- data/lib/sdb_dal/geo.rb +188 -0
- data/lib/sdb_dal/index_description.rb +29 -0
- data/lib/sdb_dal/is_null_transform.rb +16 -0
- data/lib/sdb_dal/lazy_loading_text.rb +27 -0
- data/lib/sdb_dal/memory_repository.rb +168 -0
- data/lib/sdb_dal/memory_storage.rb +29 -0
- data/lib/sdb_dal/or_condition.rb +53 -0
- data/lib/sdb_dal/query_string_auth_generator.rb +166 -0
- data/lib/sdb_dal/reference.rb +28 -0
- data/lib/sdb_dal/repository.rb +366 -0
- data/lib/sdb_dal/s3.rb +594 -0
- data/lib/sdb_dal/sdb_formatter.rb +119 -0
- data/lib/sdb_dal/starts_with_condition.rb +21 -0
- data/lib/sdb_dal/storage.rb +188 -0
- data/lib/sdb_dal/tag_cloud.rb +56 -0
- data/lib/sdb_dal/tracker_description.rb +26 -0
- data/lib/sdb_dal.rb +8 -0
- metadata +75 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
module SdbDal
|
2
|
+
|
3
|
+
class AttributeRange
|
4
|
+
attr_accessor :less_than
|
5
|
+
attr_accessor :greater_than
|
6
|
+
attr_accessor :less_than_or_equal_to
|
7
|
+
attr_accessor :greater_than_or_equal_to
|
8
|
+
attr_accessor :attribute_description #if this exists we act on objects else we act on attributes
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
|
12
|
+
self.attribute_description=options[:attribute_description]
|
13
|
+
|
14
|
+
self.less_than=options[:less_than]
|
15
|
+
self.greater_than=options[:greater_than]
|
16
|
+
self.less_than_or_equal_to=options[:less_than_or_equal_to]
|
17
|
+
self.greater_than_or_equal_to=options[:greater_than_or_equal_to]
|
18
|
+
|
19
|
+
end
|
20
|
+
def matches?(arg)
|
21
|
+
value=arg
|
22
|
+
if self.attribute_description
|
23
|
+
#its an object so pull out the value
|
24
|
+
value=arg[attribute_description.name]
|
25
|
+
end
|
26
|
+
return false if value==nil
|
27
|
+
return false if self.less_than && (value <=> self.less_than) >-1
|
28
|
+
return false if self.less_than_or_equal_to && (value <=> self.less_than_or_equal_to) ==1
|
29
|
+
return false if self.greater_than && (value<=>self.greater_than) <1
|
30
|
+
return false if self.greater_than_or_equal_to &&(value<=>self.greater_than_or_equal_to) ==-1
|
31
|
+
|
32
|
+
return true
|
33
|
+
end
|
34
|
+
def to_sdb_query
|
35
|
+
query=''
|
36
|
+
if self.less_than
|
37
|
+
query << " '#{attribute_description.name}' < '#{ attribute_description.format_for_sdb( self.less_than)}'"
|
38
|
+
end
|
39
|
+
if self.greater_than
|
40
|
+
query << ' and ' if query.length>0
|
41
|
+
query << " '#{attribute_description.name}' > '#{ attribute_description.format_for_sdb( self.greater_than)}'"
|
42
|
+
end
|
43
|
+
if self.less_than_or_equal_to
|
44
|
+
query << ' and ' if query.length>0
|
45
|
+
query << " '#{attribute_description.name}' <= '#{ attribute_description.format_for_sdb( self.less_than_or_equal_to)}'"
|
46
|
+
end
|
47
|
+
if self.greater_than_or_equal_to
|
48
|
+
query << ' and ' if query.length>0
|
49
|
+
query << " '#{attribute_description.name}' >= '#{ attribute_description.format_for_sdb( self.greater_than_or_equal_to)}'"
|
50
|
+
end
|
51
|
+
|
52
|
+
return query
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module SdbDal
|
2
|
+
require File.dirname(__FILE__) +'/sdb_formatter.rb'
|
3
|
+
class DomainAttributeDescription
|
4
|
+
include SdbFormatter
|
5
|
+
attr_accessor :name
|
6
|
+
attr_accessor :value_type
|
7
|
+
attr_accessor :is_primary_key
|
8
|
+
attr_accessor :is_collection
|
9
|
+
|
10
|
+
|
11
|
+
def initialize(name,type,options)
|
12
|
+
self.name=name
|
13
|
+
self.value_type=type
|
14
|
+
self.is_collection=(type==:reference_set)
|
15
|
+
self.is_collection ||= ( options.has_key?(:is_collection) and options[:is_collection])
|
16
|
+
|
17
|
+
self.is_primary_key=options.has_key?(:is_primary_key) && options[:is_primary_key]==true
|
18
|
+
end
|
19
|
+
def is_clob
|
20
|
+
return self.value_type==:clob
|
21
|
+
end
|
22
|
+
def format_for_sdb(value)
|
23
|
+
return format_for_sdb_single( value) unless self.is_collection==true
|
24
|
+
result=[]
|
25
|
+
value.each do |single_value|
|
26
|
+
result<<format_for_sdb_single( single_value)
|
27
|
+
end
|
28
|
+
result
|
29
|
+
end
|
30
|
+
def format_for_sdb_single(value)
|
31
|
+
return nil if value == nil && self.value_type!=:boolean
|
32
|
+
if self.value_type==:integer
|
33
|
+
return format_integer(value)
|
34
|
+
elsif self.value_type==:reference_set
|
35
|
+
return format_reference_set(value)
|
36
|
+
elsif self.value_type==:date
|
37
|
+
return format_date(value)
|
38
|
+
elsif self.value_type==:boolean
|
39
|
+
return format_boolean(value)
|
40
|
+
elsif self.value_type==:unsigned_integer
|
41
|
+
return format_unsigned_integer(value)
|
42
|
+
elsif self.value_type==:float
|
43
|
+
return format_float(value)
|
44
|
+
|
45
|
+
else
|
46
|
+
return format_string(value.to_s)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
def parse_from_sdb( value)
|
51
|
+
return parse_from_sdb_single( value) unless self.is_collection==true
|
52
|
+
return [] unless value
|
53
|
+
|
54
|
+
result=[]
|
55
|
+
value.each do |single_value|
|
56
|
+
result<<parse_from_sdb_single( single_value)
|
57
|
+
end
|
58
|
+
result
|
59
|
+
end
|
60
|
+
def parse_from_sdb_single( value)
|
61
|
+
|
62
|
+
return nil if value==nil
|
63
|
+
|
64
|
+
|
65
|
+
if self.value_type==:integer
|
66
|
+
return parse_integer(value)
|
67
|
+
elsif self.value_type==:date
|
68
|
+
return parse_date(value)
|
69
|
+
elsif self.value_type==:reference_set
|
70
|
+
return parse_reference_set(value)
|
71
|
+
elsif self.value_type==:boolean
|
72
|
+
return parse_boolean(value)
|
73
|
+
elsif self.value_type==:unsigned_integer
|
74
|
+
return parse_unsigned_integer(value)
|
75
|
+
elsif self.value_type==:float
|
76
|
+
return parse_float(value)
|
77
|
+
else
|
78
|
+
return value.to_s
|
79
|
+
end
|
80
|
+
return value
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|