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

# Source Code for Module Products.ZenModel.MEProduct

      1  ###########################################################################
      2  #
      3  # This program is part of Zenoss Core, an open source monitoring platform.
      4  # Copyright (C) 2007, Zenoss Inc.
      5  #
      6  # This program is free software; you can redistribute it and/or modify it
      7  # under the terms of the GNU General Public License version 2 as published by
      8  # the Free Software Foundation.
      9  #
     10  # For complete information please visit: http://www.zenoss.com/oss/
     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
     21 -class MEProduct(ManagedEntity):
     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')
     38 -    def getProductName(self):
     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')
     50 -    def getProductHref(self):
     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')
     61 -    def getManufacturer(self):
     62          if self.productClass():
     63              return self.productClass().manufacturer()
     64
     65
     66      security.declareProtected('View', 'getManufacturerName')
     67 -    def getManufacturerName(self):
     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')
     77 -    def getManufacturerLink(self, target=None):
     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')
     87 -    def getManufacturerHref(self):
     88          """
     89          Gets the Manufacturer's PrimaryHref
     90          """
     91          if self.productClass():
     92              return self.productClass().manufacturer.getPrimaryHref()
     93          return ""
     94
     95
     96 -    def getProductKey(self):
     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
    113 -    def getProductLink(self, target=None):
    114          """
    115          Gets the Product's PrimaryLink
    116          """
    117          return self.productClass.getPrimaryLink(target)
    118
    119
    120 -    def getProductContext(self):
    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
    130 -    def setDescription(self, description):
    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
    141 -    def getDescription(self):
    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
    154 -    def getDeviceLink(self, screen='devicedetail'):
    155          return super(MEProduct, self).getDeviceLink(screen)
    156
    157  InitializeClass(MEProduct)
    158