| 6000 |
mandeep.dh |
1 |
'''
|
|
|
2 |
Created on 11-Sep-2012
|
|
|
3 |
|
|
|
4 |
@author: mandeep
|
|
|
5 |
'''
|
|
|
6 |
from elixir.entity import Entity
|
|
|
7 |
from elixir.fields import Field
|
|
|
8 |
from elixir.options import using_options, using_table_options
|
|
|
9 |
from sqlalchemy.types import Enum, Integer, DateTime, String
|
|
|
10 |
|
|
|
11 |
class BaseOrder(Entity):
|
|
|
12 |
'''
|
|
|
13 |
classdocs
|
|
|
14 |
'''
|
|
|
15 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
16 |
idPrefix = Field(String(8))
|
|
|
17 |
transactionId = Field(Integer)
|
|
|
18 |
creationTimestamp = Field(DateTime)
|
|
|
19 |
amount = Field(Integer)
|
|
|
20 |
customerId = Field(Integer)
|
|
|
21 |
customerEmailId = Field(String(256))
|
|
|
22 |
invoiceNumber = Field(Integer)
|
|
|
23 |
orderType = Field(Enum('B2C', 'B2Cbulk', 'B2B'))
|
|
|
24 |
using_options(shortnames=True, inheritance='multi')
|
|
|
25 |
using_table_options(mysql_engine="InnoDB")
|
|
|
26 |
|
|
|
27 |
def __init__(self):
|
|
|
28 |
'''
|
|
|
29 |
Constructor
|
|
|
30 |
'''
|
|
|
31 |
|
|
|
32 |
def to_thrift_object(self, thriftObject):
|
|
|
33 |
'''
|
|
|
34 |
Copies attributes to thrift object
|
|
|
35 |
'''
|
|
|
36 |
thriftObject.amount = self.amount
|
|
|
37 |
thriftObject.creationTimestamp = self.creationTimestamp
|
|
|
38 |
thriftObject.customerEmailId = self.customerEmailId
|
|
|
39 |
thriftObject.customerId = self.customerId
|
|
|
40 |
thriftObject.id = self.idPrefix + self.id
|
|
|
41 |
thriftObject.invoiceNumber = self.invoiceNumber
|
|
|
42 |
thriftObject.orderType = self.orderType
|
|
|
43 |
thriftObject.transactionId = self.transactionId
|
|
|
44 |
|
|
|
45 |
def from_thrift_object(self, thriftBaseOrder):
|
|
|
46 |
self.amount = thriftBaseOrder.amount
|
|
|
47 |
self.creationTimestamp = thriftBaseOrder.creationTimestamp
|
|
|
48 |
self.customerEmailId = thriftBaseOrder.customerEmailId
|
|
|
49 |
self.customerId = thriftBaseOrder.customerId
|
|
|
50 |
self.id = thriftBaseOrder.id.split(self.idPrefix)[1]
|
|
|
51 |
self.invoiceNumber = thriftBaseOrder.invoiceNumber
|
|
|
52 |
self.orderType = thriftBaseOrder.orderType
|
|
|
53 |
self.transactionId = thriftBaseOrder.transactionId
|
|
|
54 |
|
|
|
55 |
def is_valid(self):
|
|
|
56 |
return True
|