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 or (at your
      8  # option) any later version as published by 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.titleOrId()
     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.titleOrId()
     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.productClass() is None:
    102              return ""
    103          elif self._manufacturer is not None:
    104              return (self._prodKey, self._manufacturer)
    105          elif self._prodKey is not None:
    106              return self._prodKey
    107          else:
    108              pclass = self.productClass()
    109              return pclass.getProductKey()
    110
    111 -    def getProductLink(self, target=None):
    112          """
    113          Gets the Product's PrimaryLink
    114          """
    115          return self.productClass.getPrimaryLink(target)
    116
    117
    118 -    def getProductContext(self):
    119          """Return list of tuples with product context for this product.
    120          """
    121          prod = self.productClass()
    122          if prod:
    123              prodcontext = self.primaryAq()
    124              return prodcontext.zenPropertyItems()
    125          return []
    126
    127
    128 -    def setDescription(self, description):
    129          """
    130          Sets the description of the underlying ProductClass
    131          """
    132
    133          prod = self.productClass()
    134
    135          if prod:
    136              prod.description = description
    137
    138
    139 -    def getDescription(self):
    140          """
    141          Gets the description of the underlying ProductClass
    142          """
    143
    144          prod = self.productClass()
    145
    146          if prod: result = prod.description
    147          else   : result = None
    148
    149          return result
    150
    151
    152 -    def getDeviceLink(self, screen='devicedetail'):
    153          return super(MEProduct, self).getDeviceLink(screen)
    154
    155  InitializeClass(MEProduct)
    156