Bumping version for release.
[PyCIM.git] / CIM14 / IEC61968 / Customers / Customer.py
blob364a3fc491b9915236e6d13840a96760027ec7e3
1 # Copyright (C) 2010 Richard Lincoln
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA
17 from CIM14.IEC61968.Common.Organisation import Organisation
19 class Customer(Organisation):
20 """Organisation receiving services from ServiceSupplier.
21 """
23 def __init__(self, kind="residentialAndCommercial", pucNumber='', specialNeed='', vip=False, status=None, Works=None, CustomerAgreements=None, EndDeviceAssets=None, *args, **kw_args):
24 """Initialises a new 'Customer' instance.
26 @param kind: Kind of customer. Values are: "residentialAndCommercial", "residentialStreetlightOthers", "residentialAndStreetlight", "pumpingLoad", "energyServiceSupplier", "windMachine", "residential", "internalUse", "residentialFarmService", "other", "energyServiceScheduler", "commercialIndustrial"
27 @param pucNumber: (if applicable) Public Utility Commission identification number.
28 @param specialNeed: True if customer organisation has special service needs such as life support, hospitals, etc.
29 @param vip: True if this is an important customer. Importance is for matters different than those in 'specialNeed' attribute.
30 @param status: Status of this customer.
31 @param Works: All the works performed for this customer.
32 @param CustomerAgreements: All agreements of this customer.
33 @param EndDeviceAssets: All end device assets of this customer.
34 """
35 #: Kind of customer. Values are: "residentialAndCommercial", "residentialStreetlightOthers", "residentialAndStreetlight", "pumpingLoad", "energyServiceSupplier", "windMachine", "residential", "internalUse", "residentialFarmService", "other", "energyServiceScheduler", "commercialIndustrial"
36 self.kind = kind
38 #: (if applicable) Public Utility Commission identification number.
39 self.pucNumber = pucNumber
41 #: True if customer organisation has special service needs such as life support, hospitals, etc.
42 self.specialNeed = specialNeed
44 #: True if this is an important customer. Importance is for matters different than those in 'specialNeed' attribute.
45 self.vip = vip
47 self.status = status
49 self._Works = []
50 self.Works = [] if Works is None else Works
52 self._CustomerAgreements = []
53 self.CustomerAgreements = [] if CustomerAgreements is None else CustomerAgreements
55 self._EndDeviceAssets = []
56 self.EndDeviceAssets = [] if EndDeviceAssets is None else EndDeviceAssets
58 super(Customer, self).__init__(*args, **kw_args)
60 _attrs = ["kind", "pucNumber", "specialNeed", "vip"]
61 _attr_types = {"kind": str, "pucNumber": str, "specialNeed": str, "vip": bool}
62 _defaults = {"kind": "residentialAndCommercial", "pucNumber": '', "specialNeed": '', "vip": False}
63 _enums = {"kind": "CustomerKind"}
64 _refs = ["status", "Works", "CustomerAgreements", "EndDeviceAssets"]
65 _many_refs = ["Works", "CustomerAgreements", "EndDeviceAssets"]
67 # Status of this customer.
68 status = None
70 def getWorks(self):
71 """All the works performed for this customer.
72 """
73 return self._Works
75 def setWorks(self, value):
76 for p in self._Works:
77 filtered = [q for q in p.Customers if q != self]
78 self._Works._Customers = filtered
79 for r in value:
80 if self not in r._Customers:
81 r._Customers.append(self)
82 self._Works = value
84 Works = property(getWorks, setWorks)
86 def addWorks(self, *Works):
87 for obj in Works:
88 if self not in obj._Customers:
89 obj._Customers.append(self)
90 self._Works.append(obj)
92 def removeWorks(self, *Works):
93 for obj in Works:
94 if self in obj._Customers:
95 obj._Customers.remove(self)
96 self._Works.remove(obj)
98 def getCustomerAgreements(self):
99 """All agreements of this customer.
101 return self._CustomerAgreements
103 def setCustomerAgreements(self, value):
104 for x in self._CustomerAgreements:
105 x.Customer = None
106 for y in value:
107 y._Customer = self
108 self._CustomerAgreements = value
110 CustomerAgreements = property(getCustomerAgreements, setCustomerAgreements)
112 def addCustomerAgreements(self, *CustomerAgreements):
113 for obj in CustomerAgreements:
114 obj.Customer = self
116 def removeCustomerAgreements(self, *CustomerAgreements):
117 for obj in CustomerAgreements:
118 obj.Customer = None
120 def getEndDeviceAssets(self):
121 """All end device assets of this customer.
123 return self._EndDeviceAssets
125 def setEndDeviceAssets(self, value):
126 for x in self._EndDeviceAssets:
127 x.Customer = None
128 for y in value:
129 y._Customer = self
130 self._EndDeviceAssets = value
132 EndDeviceAssets = property(getEndDeviceAssets, setEndDeviceAssets)
134 def addEndDeviceAssets(self, *EndDeviceAssets):
135 for obj in EndDeviceAssets:
136 obj.Customer = self
138 def removeEndDeviceAssets(self, *EndDeviceAssets):
139 for obj in EndDeviceAssets:
140 obj.Customer = None