16
16
# specific language governing permissions and limitations
17
17
# under the License.
18
18
#
19
-
20
19
from datetime import datetime
21
20
22
21
import grakn_protocol .protobuf .concept_pb2 as concept_proto
@@ -77,13 +76,13 @@ def is_datetime(self):
77
76
78
77
class BooleanAttribute (Attribute ):
79
78
80
- def __init__ (self , iid : str , value : bool ):
81
- super (BooleanAttribute , self ).__init__ (iid )
79
+ def __init__ (self , iid : str , type_ , value : bool ):
80
+ super (BooleanAttribute , self ).__init__ (iid , type_ )
82
81
self ._value = value
83
82
84
83
@staticmethod
85
84
def _of (thing_proto : concept_proto .Thing ):
86
- return BooleanAttribute (concept_proto_reader .iid (thing_proto .iid ), thing_proto .value .boolean )
85
+ return BooleanAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), thing_proto .value .boolean )
87
86
88
87
def get_value (self ):
89
88
return self ._value
@@ -92,13 +91,13 @@ def is_boolean(self):
92
91
return True
93
92
94
93
def as_remote (self , transaction ):
95
- return RemoteBooleanAttribute (transaction , self .get_iid (), self .get_value ())
94
+ return RemoteBooleanAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
96
95
97
96
98
97
class RemoteBooleanAttribute (RemoteAttribute ):
99
98
100
- def __init__ (self , transaction , iid : str , value : bool ):
101
- super (RemoteBooleanAttribute , self ).__init__ (transaction , iid )
99
+ def __init__ (self , transaction , iid : str , type_ , value : bool ):
100
+ super (RemoteBooleanAttribute , self ).__init__ (transaction , iid , type_ )
102
101
self ._value = value
103
102
104
103
def get_value (self ):
@@ -108,18 +107,18 @@ def is_boolean(self):
108
107
return True
109
108
110
109
def as_remote (self , transaction ):
111
- return RemoteBooleanAttribute (transaction , self .get_iid (), self .get_value ())
110
+ return RemoteBooleanAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
112
111
113
112
114
113
class LongAttribute (Attribute ):
115
114
116
- def __init__ (self , iid : str , value : int ):
117
- super (LongAttribute , self ).__init__ (iid )
115
+ def __init__ (self , iid : str , type_ , value : int ):
116
+ super (LongAttribute , self ).__init__ (iid , type_ )
118
117
self ._value = value
119
118
120
119
@staticmethod
121
120
def _of (thing_proto : concept_proto .Thing ):
122
- return LongAttribute (concept_proto_reader .iid (thing_proto .iid ), thing_proto .value .long )
121
+ return LongAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), thing_proto .value .long )
123
122
124
123
def get_value (self ):
125
124
return self ._value
@@ -128,13 +127,13 @@ def is_long(self):
128
127
return True
129
128
130
129
def as_remote (self , transaction ):
131
- return RemoteLongAttribute (transaction , self .get_iid (), self .get_value ())
130
+ return RemoteLongAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
132
131
133
132
134
133
class RemoteLongAttribute (RemoteAttribute ):
135
134
136
- def __init__ (self , transaction , iid : str , value : int ):
137
- super (RemoteLongAttribute , self ).__init__ (transaction , iid )
135
+ def __init__ (self , transaction , iid : str , type_ , value : int ):
136
+ super (RemoteLongAttribute , self ).__init__ (transaction , iid , type_ )
138
137
self ._value = value
139
138
140
139
def get_value (self ):
@@ -144,18 +143,18 @@ def is_long(self):
144
143
return True
145
144
146
145
def as_remote (self , transaction ):
147
- return RemoteLongAttribute (transaction , self .get_iid (), self .get_value ())
146
+ return RemoteLongAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
148
147
149
148
150
149
class DoubleAttribute (Attribute ):
151
150
152
- def __init__ (self , iid : str , value : float ):
153
- super (DoubleAttribute , self ).__init__ (iid )
151
+ def __init__ (self , iid : str , type_ , value : float ):
152
+ super (DoubleAttribute , self ).__init__ (iid , type_ )
154
153
self ._value = value
155
154
156
155
@staticmethod
157
156
def _of (thing_proto : concept_proto .Thing ):
158
- return DoubleAttribute (concept_proto_reader .iid (thing_proto .iid ), thing_proto .value .double )
157
+ return DoubleAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), thing_proto .value .double )
159
158
160
159
def get_value (self ):
161
160
return self ._value
@@ -164,13 +163,13 @@ def is_double(self):
164
163
return True
165
164
166
165
def as_remote (self , transaction ):
167
- return RemoteDoubleAttribute (transaction , self .get_iid (), self .get_value ())
166
+ return RemoteDoubleAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
168
167
169
168
170
169
class RemoteDoubleAttribute (RemoteAttribute ):
171
170
172
- def __init__ (self , transaction , iid : str , value : float ):
173
- super (RemoteDoubleAttribute , self ).__init__ (transaction , iid )
171
+ def __init__ (self , transaction , iid : str , type_ , value : float ):
172
+ super (RemoteDoubleAttribute , self ).__init__ (transaction , iid , type_ )
174
173
self ._value = value
175
174
176
175
def get_value (self ):
@@ -180,18 +179,18 @@ def is_double(self):
180
179
return True
181
180
182
181
def as_remote (self , transaction ):
183
- return RemoteDoubleAttribute (transaction , self .get_iid (), self .get_value ())
182
+ return RemoteDoubleAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
184
183
185
184
186
185
class StringAttribute (Attribute ):
187
186
188
- def __init__ (self , iid : str , value : str ):
189
- super (StringAttribute , self ).__init__ (iid )
187
+ def __init__ (self , iid : str , type_ , value : str ):
188
+ super (StringAttribute , self ).__init__ (iid , type_ )
190
189
self ._value = value
191
190
192
191
@staticmethod
193
192
def _of (thing_proto : concept_proto .Thing ):
194
- return StringAttribute (concept_proto_reader .iid (thing_proto .iid ), thing_proto .value .string )
193
+ return StringAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), thing_proto .value .string )
195
194
196
195
def get_value (self ):
197
196
return self ._value
@@ -200,13 +199,13 @@ def is_string(self):
200
199
return True
201
200
202
201
def as_remote (self , transaction ):
203
- return RemoteStringAttribute (transaction , self .get_iid (), self .get_value ())
202
+ return RemoteStringAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
204
203
205
204
206
205
class RemoteStringAttribute (RemoteAttribute ):
207
206
208
- def __init__ (self , transaction , iid : str , value : str ):
209
- super (RemoteStringAttribute , self ).__init__ (transaction , iid )
207
+ def __init__ (self , transaction , iid : str , type_ , value : str ):
208
+ super (RemoteStringAttribute , self ).__init__ (transaction , iid , type_ )
210
209
self ._value = value
211
210
212
211
def get_value (self ):
@@ -216,18 +215,18 @@ def is_string(self):
216
215
return True
217
216
218
217
def as_remote (self , transaction ):
219
- return RemoteStringAttribute (transaction , self .get_iid (), self .get_value ())
218
+ return RemoteStringAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
220
219
221
220
222
221
class DateTimeAttribute (Attribute ):
223
222
224
- def __init__ (self , iid : str , value : datetime ):
225
- super (DateTimeAttribute , self ).__init__ (iid )
223
+ def __init__ (self , iid : str , type_ , value : datetime ):
224
+ super (DateTimeAttribute , self ).__init__ (iid , type_ )
226
225
self ._value = value
227
226
228
227
@staticmethod
229
228
def _of (thing_proto : concept_proto .Thing ):
230
- return DateTimeAttribute (concept_proto_reader .iid (thing_proto .iid ), datetime .fromtimestamp (float (thing_proto .value .date_time ) / 1000.0 ))
229
+ return DateTimeAttribute (concept_proto_reader .iid (thing_proto .iid ), concept_proto_reader . attribute_type ( thing_proto . type ), datetime .fromtimestamp (float (thing_proto .value .date_time ) / 1000.0 ))
231
230
232
231
def get_value (self ):
233
232
return self ._value
@@ -236,13 +235,13 @@ def is_datetime(self):
236
235
return True
237
236
238
237
def as_remote (self , transaction ):
239
- return RemoteDateTimeAttribute (transaction , self .get_iid (), self .get_value ())
238
+ return RemoteDateTimeAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
240
239
241
240
242
241
class RemoteDateTimeAttribute (RemoteAttribute ):
243
242
244
- def __init__ (self , transaction , iid : str , value : datetime ):
245
- super (RemoteDateTimeAttribute , self ).__init__ (transaction , iid )
243
+ def __init__ (self , transaction , iid : str , type_ , value : datetime ):
244
+ super (RemoteDateTimeAttribute , self ).__init__ (transaction , iid , type_ )
246
245
self ._value = value
247
246
248
247
def get_value (self ):
@@ -252,4 +251,4 @@ def is_datetime(self):
252
251
return True
253
252
254
253
def as_remote (self , transaction ):
255
- return RemoteDateTimeAttribute (transaction , self .get_iid (), self .get_value ())
254
+ return RemoteDateTimeAttribute (transaction , self .get_iid (), self .get_type (), self . get_value ())
0 commit comments