1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""Location
15
16 $Id: Location.py,v 1.12 2004/04/22 19:08:47 edahl Exp $"""
17
18 __version__ = "$Revision: 1.12 $"[11:-2]
19
20 from Globals import InitializeClass
21 from Globals import DTMLFile
22
23 from AccessControl import ClassSecurityInfo
24
25 from AccessControl import Permissions as permissions
26
27 from Products.ZenRelations.RelSchema import *
28
29 from DeviceOrganizer import DeviceOrganizer
30 from ZenPackable import ZenPackable
31
32 from Products.ZenUtils.jsonutils import json
43
44
45 addLocation = DTMLFile('dtml/addLocation',globals())
46
47
48 -class Location(DeviceOrganizer, ZenPackable):
49 """
50 Location is a DeviceGroup Organizer that manages physical device Locations.
51 """
52
53
54 dmdRootName = "Locations"
55
56 address = ''
57
58 portal_type = meta_type = event_key = 'Location'
59
60 _properties = DeviceOrganizer._properties + (
61 {'id':'address','type':'string','mode':'w'},
62 )
63
64 _relations = DeviceOrganizer._relations + ZenPackable._relations + (
65 ("devices", ToMany(ToOne,"Products.ZenModel.Device","location")),
66 ("networks", ToMany(ToOne,"Products.ZenModel.IpNetwork","location")),
67 )
68
69
70 factory_type_information = (
71 {
72 'immediate_view' : 'deviceOrganizerStatus',
73 'actions' :
74 (
75 { 'id' : 'status'
76 , 'name' : 'Status'
77 , 'action' : 'deviceOrganizerStatus'
78 , 'permissions' : (permissions.view,)
79 },
80 { 'id' : 'events'
81 , 'name' : 'Events'
82 , 'action' : 'viewEvents'
83 , 'permissions' : (permissions.view,)
84 },
85
86
87
88
89
90 { 'id' : 'manage'
91 , 'name' : 'Administration'
92 , 'action' : 'deviceOrganizerManage'
93 , 'permissions' : ('Manage DMD',)
94 },
95 { 'id' : 'geomap'
96 , 'name' : 'Map'
97 , 'action' : 'locationGeoMap'
98 , 'permissions' : (permissions.view,)
99 },
100 )
101 },
102 )
103
104 security = ClassSecurityInfo()
105
106 - def __init__(self, id, description = '', address=''):
109
110
112 """Sets the mailing address for this location"""
113 self.address = address
114
116 """ Returns child link data ready for GMaps """
117 return self.dmd.ZenLinkManager.getChildLinks(self)
118
124
126 """
127 Gather data for Google Maps. This is not a JSON method; it must be put
128 into a data structure appropriate for JS consumption by another method
129 (specifically, getChildGeomapData, below).
130 """
131 worstSeverity = self.getWorstEventSeverity()
132 colors = 'red orange yellow green green'.split()
133 colors.reverse()
134 color = 'green'
135 if worstSeverity:
136 try:
137 color = colors[worstSeverity - 1]
138 except IndexError:
139
140 pass
141 link = self.absolute_url_path()
142 linkToMap = self.numMappableChildren()
143 if linkToMap:
144 link+='/locationGeoMap'
145 summarytext = self.mapTooltip()
146 return [self.address, color, link, summarytext]
147
148 @json
160
162 """ Returns geomap info on cousin nodes that should be
163 included in the view due to outside linking.
164 """
165 data = []
166
167 return data
168
169 InitializeClass(Location)
170