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