1
2
3
4
5
6
7
8
9
10
11
12
13
14 from Globals import InitializeClass
15 from AccessControl import ClassSecurityInfo
16
17 from ManagedEntity import ManagedEntity
18
19 from Products.ZenRelations.RelSchema import *
20
22 """
23 MEProduct is a ManagedEntity that needs to track is manufacturer.
24 For instance software and hardware.
25 """
26
27 _prodKey = None
28 _manufacturer = None
29
30 _relations = ManagedEntity._relations + (
31 ("productClass", ToOne(ToMany, "Products.ZenModel.ProductClass", "instances")),
32 )
33
34 security = ClassSecurityInfo()
35
36
37 security.declareProtected('View', 'getProductName')
39 """
40 Gets the Products's Name (id)
41 """
42 productClass = self.productClass()
43 if productClass:
44 return productClass.name and productClass.name or productClass.id
45 return ''
46 getModelName = getProductName
47
48
49 security.declareProtected('View', 'getProductHref')
51 """
52 Gets the Products's PrimaryHref
53 """
54 productClass = self.productClass()
55 if productClass:
56 return productClass.getPrimaryHref()
57 return ''
58
59
60 security.declareProtected('View', 'getManufacturer')
62 if self.productClass():
63 return self.productClass().manufacturer()
64
65
66 security.declareProtected('View', 'getManufacturerName')
68 """
69 Gets the Manufacturer Name(Id)
70 """
71 manuf = self.getManufacturer()
72 if manuf: return manuf.getId()
73 return ""
74
75
76 security.declareProtected('View', 'getManufacturerLink')
78 """
79 Gets the Manufacturer PrimaryLink
80 """
81 if self.productClass():
82 return self.productClass().manufacturer.getPrimaryLink(target)
83 return ""
84
85
86 security.declareProtected('View', 'getManufacturerLink')
88 """
89 Gets the Manufacturer's PrimaryHref
90 """
91 if self.productClass():
92 return self.productClass().manufacturer.getPrimaryHref()
93 return ""
94
95
97 """
98 Return the arguments to the setProductKey method so we can avoid
99 changing the object model when nothing has changed.
100 """
101 if self._manufacturer is not None:
102 return (self._prodKey, self._manufacturer)
103 elif self._prodKey is not None:
104 return self._prodKey
105 else:
106 pclass = self.productClass()
107 if pclass:
108 return pclass.getProductKey()
109 else:
110 return ""
111
112
114 """
115 Gets the Product's PrimaryLink
116 """
117 return self.productClass.getPrimaryLink(target)
118
119
121 """Return list of tuples with product context for this product.
122 """
123 prod = self.productClass()
124 if prod:
125 prodcontext = self.primaryAq()
126 return prodcontext.zenPropertyItems()
127 return []
128
129
131 """
132 Sets the description of the underlying ProductClass
133 """
134
135 prod = self.productClass()
136
137 if prod:
138 prod.description = description
139
140
142 """
143 Gets the description of the underlying ProductClass
144 """
145
146 prod = self.productClass()
147
148 if prod: result = prod.description
149 else : result = None
150
151 return result
152
153
156
157 InitializeClass(MEProduct)
158