Package Products :: Package ZenModel :: Module GraphGroup |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenModel.GraphGroup

      1  ##############################################################################
      2  #
      3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
      4  #
      5  # This content is made available according to terms specified in
      6  # License.zenoss under the directory where your Zenoss product is installed.
      7  #
      8  ##############################################################################
      9
     10
     11  __doc__="""GraphGroup
     12
     13  GraphGroup contains the settings, graphDefinitions and collections
     14  that form part of an UberReport.
     15  """
     16
     17
     18  from AccessControl import Permissions
     19  from Globals import InitializeClass
     20  from AccessControl import ClassSecurityInfo
     21  from Products.ZenRelations.RelSchema import *
     22  from ZenModelRM import ZenModelRM
     23
     24
     25 -def manage_addGraphGroup(context, id, REQUEST = None):
     26      ''' This is here so than zope will let us copy/paste/rename
     27      '''
     28      gg = GraphGroup(id)
     29      context._setObject(gg.id, gg)
     30      if REQUEST:
     31          return context.callZenScreen(REQUEST)
     32
     33
     34 -class GraphGroup(ZenModelRM):
     35      '''
     36      '''
     37
     38      meta_type = 'GraphGroup'
     39
     40      sequence = 0
     41      collectionId = ''
     42      graphDefId = ''
     43      combineDevices = False
     44
     45      _properties = (
     46          {'id':'sequence', 'type':'long', 'mode':'w'},
     47          {'id':'collectionId', 'type':'string', 'mode':'w'},
     48          {'id':'graphDefId', 'type':'string', 'mode':'w'},
     49          {'id':'combineDevices', 'type':'boolean', 'mode':'w'},
     50          )
     51
     52      _relations =  (
     53          ('report',
     54              ToOne(ToManyCont, 'Products.ZenModel.MultiGraphReport',
     55                                'graphGroups')),
     56          )
     57
     58      factory_type_information = (
     59      {
     60          'immediate_view' : 'editGraphGroup',
     61          'actions'        :
     62          (
     63              { 'id'            : 'edit'
     64              , 'name'          : 'Graph Group'
     65              , 'action'        : 'editGraphGroup'
     66              , 'permissions'   : ( Permissions.view, )
     67              },
     68          )
     69      },
     70      )
     71
     72      security = ClassSecurityInfo()
     73
     74 -    def __init__(self, newId, collectionId='', graphDefId='', sequence=0,
     75                                              title=None, buildRelations=True):
     76          ZenModelRM.__init__(self, newId, title, buildRelations)
     77          self.collectionId = collectionId
     78          self.graphDefId = graphDefId
     79          self.sequence = sequence
     80
     81
     82 -    def getCollection(self):
     83          ''' Return the referenced collection or None if it doesn't exist
     84          '''
     85          return getattr(self.report.collections, self.collectionId, None)
     86
     87
     88 -    def getGraphDef(self):
     89          ''' Return the referenced graphDef or None if it doesn't exist
     90          '''
     91          return getattr(self.report().graphDefs, self.graphDefId, None)
     92
     93
     94 -    def getCollectionUrl(self):
     95          '''
     96          '''
     97          collection = self.getCollection()
     98          url = None
     99          if collection:
    100              url = collection.getPrimaryUrlPath()
    101          return url
    102
    103
    104 -    def getGraphDefUrl(self):
    105          '''
    106          '''
    107          graphDef = self.getGraphDef()
    108          url = None
    109          if graphDef:
    110              url = graphDef.getPrimaryUrlPath()
    111          return url
    112
    113
    114      # def zmanage_editProperties(self, REQUEST):
    115      #     ''' Save then redirect back to the report
    116      #     '''
    117      #     self.manage_changeProperties(**REQUEST.form)
    118      #     index_object = getattr(self, 'index_object', lambda self: None)
    119      #     index_object()
    120      #     REQUEST['RESPONSE'].redirect(self.report().getPrimaryUrlPath())
    121
    122
    123  InitializeClass(GraphGroup)
    124