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
.Document
import Document
20 """Document used to request, initiate, track and record work. This is synonymous with Work Breakdown Structure (WBS), which is traversed through the (currently informative) recursive association of Work. Note that the work name is equal to the WBS name, which is given in the inherited 'name' attribute.
23 def __init__(self
, kind
="construction", priority
='', requestDateTime
='', Customers
=None, *args
, **kw_args
):
24 """Initialises a new 'Work' instance.
26 @param kind: Kind of work. Values are: "construction", "maintenance", "reconnect", "meter", "service", "disconnect", "inspection", "other"
27 @param priority: Priority of work.
28 @param requestDateTime: Date and time work was requested.
29 @param Customers: All the customers for which this work is performed.
31 #: Kind of work. Values are: "construction", "maintenance", "reconnect", "meter", "service", "disconnect", "inspection", "other"
35 self
.priority
= priority
37 #: Date and time work was requested.
38 self
.requestDateTime
= requestDateTime
41 self
.Customers
= [] if Customers
is None else Customers
43 super(Work
, self
).__init
__(*args
, **kw_args
)
45 _attrs
= ["kind", "priority", "requestDateTime"]
46 _attr_types
= {"kind": str, "priority": str, "requestDateTime": str}
47 _defaults
= {"kind": "construction", "priority": '', "requestDateTime": ''}
48 _enums
= {"kind": "WorkKind"}
50 _many_refs
= ["Customers"]
52 def getCustomers(self
):
53 """All the customers for which this work is performed.
55 return self
._Customers
57 def setCustomers(self
, value
):
58 for p
in self
._Customers
:
59 filtered
= [q
for q
in p
.Works
if q
!= self
]
60 self
._Customers
._Works
= filtered
62 if self
not in r
._Works
:
64 self
._Customers
= value
66 Customers
= property(getCustomers
, setCustomers
)
68 def addCustomers(self
, *Customers
):
70 if self
not in obj
._Works
:
71 obj
._Works
.append(self
)
72 self
._Customers
.append(obj
)
74 def removeCustomers(self
, *Customers
):
76 if self
in obj
._Works
:
77 obj
._Works
.remove(self
)
78 self
._Customers
.remove(obj
)