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      _relations = ManagedEntity._relations + (
     28          ("productClass", ToOne(ToMany, "Products.ZenModel.ProductClass", "instances")),
     29      )
     30
     31      security = ClassSecurityInfo()
     32
     33
     34      security.declareProtected('View', 'getProductName')
     35 -    def getProductName(self):
     36          productClass = self.productClass()
     37          if productClass:
     38              return productClass.name and productClass.name or productClass.id
     39          return ''
     40      getModelName = getProductName
     41
     42
     43      security.declareProtected('View', 'getManufacturer')
     44 -    def getManufacturer(self):
     45          if self.productClass():
     46              return self.productClass().manufacturer()
     47
     48
     49      security.declareProtected('View', 'getManufacturerName')
     50 -    def getManufacturerName(self):
     51          manuf = self.getManufacturer()
     52          if manuf: return manuf.getId()
     53          return ""
     54
     55
     56      security.declareProtected('View', 'getManufacturerLink')
     57 -    def getManufacturerLink(self):
     58          if self.productClass():
     59              return self.productClass().manufacturer.getPrimaryLink()
     60          return ""
     61
     62
     63 -    def getProductKey(self):
     64          """Get the product class of this software.
     65          """
     66          pclass = self.productClass()
     67          if pclass: return pclass.getProductKey()
     68          return ""
     69
     70
     71 -    def getProductLink(self):
     72          return self.productClass.getPrimaryLink()
     73
     74
     75 -    def getProductContext(self):
     76          """Return list of tuples with product context for this product.
     77          """
     78          prod = self.productClass()
     79          if prod:
     80              prodcontext = self.primaryAq()
     81              return prodcontext.zenPropertyItems()
     82          return []
     83
     84
     85 -    def setDescription(self, description):
     86          """
     87          Sets the description of the underlying ProductClass
     88          """
     89
     90          prod = self.productClass()
     91
     92          if prod:
     93              prod.description = description
     94
     95
     96 -    def getDescription(self):
     97          """
     98          Gets the description of the underlying ProductClass
     99          """
    100
    101          prod = self.productClass()
    102
    103          if prod: result = prod.description
    104          else   : result = None
    105
    106          return result
    107
    108
    109  InitializeClass(MEProduct)
    110