Update README.rst
[PyCIM.git] / CIM14 / IEC61968 / Customers / Customer.py
blob9e908a76071a7704f3a05c3108e84198d0a5979c
1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 # IN THE SOFTWARE.
21 from CIM14.IEC61968.Common.Organisation import Organisation
23 class Customer(Organisation):
24 """Organisation receiving services from ServiceSupplier.
25 """
27 def __init__(self, kind="residentialAndCommercial", pucNumber='', specialNeed='', vip=False, status=None, Works=None, CustomerAgreements=None, EndDeviceAssets=None, *args, **kw_args):
28 """Initialises a new 'Customer' instance.
30 @param kind: Kind of customer. Values are: "residentialAndCommercial", "residentialStreetlightOthers", "residentialAndStreetlight", "pumpingLoad", "energyServiceSupplier", "windMachine", "residential", "internalUse", "residentialFarmService", "other", "energyServiceScheduler", "commercialIndustrial"
31 @param pucNumber: (if applicable) Public Utility Commission identification number.
32 @param specialNeed: True if customer organisation has special service needs such as life support, hospitals, etc.
33 @param vip: True if this is an important customer. Importance is for matters different than those in 'specialNeed' attribute.
34 @param status: Status of this customer.
35 @param Works: All the works performed for this customer.
36 @param CustomerAgreements: All agreements of this customer.
37 @param EndDeviceAssets: All end device assets of this customer.
38 """
39 #: Kind of customer. Values are: "residentialAndCommercial", "residentialStreetlightOthers", "residentialAndStreetlight", "pumpingLoad", "energyServiceSupplier", "windMachine", "residential", "internalUse", "residentialFarmService", "other", "energyServiceScheduler", "commercialIndustrial"
40 self.kind = kind
42 #: (if applicable) Public Utility Commission identification number.
43 self.pucNumber = pucNumber
45 #: True if customer organisation has special service needs such as life support, hospitals, etc.
46 self.specialNeed = specialNeed
48 #: True if this is an important customer. Importance is for matters different than those in 'specialNeed' attribute.
49 self.vip = vip
51 self.status = status
53 self._Works = []
54 self.Works = [] if Works is None else Works
56 self._CustomerAgreements = []
57 self.CustomerAgreements = [] if CustomerAgreements is None else CustomerAgreements
59 self._EndDeviceAssets = []
60 self.EndDeviceAssets = [] if EndDeviceAssets is None else EndDeviceAssets
62 super(Customer, self).__init__(*args, **kw_args)
64 _attrs = ["kind", "pucNumber", "specialNeed", "vip"]
65 _attr_types = {"kind": str, "pucNumber": str, "specialNeed": str, "vip": bool}
66 _defaults = {"kind": "residentialAndCommercial", "pucNumber": '', "specialNeed": '', "vip": False}
67 _enums = {"kind": "CustomerKind"}
68 _refs = ["status", "Works", "CustomerAgreements", "EndDeviceAssets"]
69 _many_refs = ["Works", "CustomerAgreements", "EndDeviceAssets"]
71 # Status of this customer.
72 status = None
74 def getWorks(self):
75 """All the works performed for this customer.
76 """
77 return self._Works
79 def setWorks(self, value):
80 for p in self._Works:
81 filtered = [q for q in p.Customers if q != self]
82 self._Works._Customers = filtered
83 for r in value:
84 if self not in r._Customers:
85 r._Customers.append(self)
86 self._Works = value
88 Works = property(getWorks, setWorks)
90 def addWorks(self, *Works):
91 for obj in Works:
92 if self not in obj._Customers:
93 obj._Customers.append(self)
94 self._Works.append(obj)
96 def removeWorks(self, *Works):
97 for obj in Works:
98 if self in obj._Customers:
99 obj._Customers.remove(self)
100 self._Works.remove(obj)
102 def getCustomerAgreements(self):
103 """All agreements of this customer.
105 return self._CustomerAgreements
107 def setCustomerAgreements(self, value):
108 for x in self._CustomerAgreements:
109 x.Customer = None
110 for y in value:
111 y._Customer = self
112 self._CustomerAgreements = value
114 CustomerAgreements = property(getCustomerAgreements, setCustomerAgreements)
116 def addCustomerAgreements(self, *CustomerAgreements):
117 for obj in CustomerAgreements:
118 obj.Customer = self
120 def removeCustomerAgreements(self, *CustomerAgreements):
121 for obj in CustomerAgreements:
122 obj.Customer = None
124 def getEndDeviceAssets(self):
125 """All end device assets of this customer.
127 return self._EndDeviceAssets
129 def setEndDeviceAssets(self, value):
130 for x in self._EndDeviceAssets:
131 x.Customer = None
132 for y in value:
133 y._Customer = self
134 self._EndDeviceAssets = value
136 EndDeviceAssets = property(getEndDeviceAssets, setEndDeviceAssets)
138 def addEndDeviceAssets(self, *EndDeviceAssets):
139 for obj in EndDeviceAssets:
140 obj.Customer = self
142 def removeEndDeviceAssets(self, *EndDeviceAssets):
143 for obj in EndDeviceAssets:
144 obj.Customer = None