From: <jt...@hy...> - 2007-03-29 18:08:11
|
Author: jtravis Date: 2007-03-29 10:08:07 -0800 (Thu, 29 Mar 2007) New Revision: 3958 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3958 Added: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/MetricHelper.groovy trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/AppdefMetricCategory.groovy Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/dispatcher.groovy Log: Add appdef metric category Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-29 17:38:06 UTC (rev 3957) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-29 18:08:07 UTC (rev 3958) @@ -13,6 +13,7 @@ import org.hyperic.hq.ui.rendit.helpers.LiveDataHelper import org.hyperic.hq.ui.rendit.helpers.ResourceHelper +import org.hyperic.hq.ui.rendit.helpers.MetricHelper import org.hyperic.hq.ui.rendit.helpers.HQHelper import groovy.text.SimpleTemplateEngine @@ -45,6 +46,7 @@ def getResourceHelper() { return new ResourceHelper(getUser()) } def getLiveDataHelper() { return new LiveDataHelper(getUser()) } + def getMetricHelper() { return new MetricHelper(getUser()) } def getHQHelper() { return new HQHelper(getUser()) } /** Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/dispatcher.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/dispatcher.groovy 2007-03-29 17:38:06 UTC (rev 3957) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/dispatcher.groovy 2007-03-29 18:08:07 UTC (rev 3958) @@ -3,6 +3,7 @@ import org.hyperic.hq.ui.rendit.util.UserUtil import org.hyperic.hq.ui.rendit.metaclass.AppdefAppdefCategory import org.hyperic.hq.ui.rendit.metaclass.AppdefLiveDataCategory +import org.hyperic.hq.ui.rendit.metaclass.AppdefMetricCategory import org.hyperic.hq.ui.rendit.metaclass.CategoryInfo import org.hyperic.hq.appdef.shared.AppdefEntityID @@ -18,7 +19,8 @@ class Dispatcher { private static final CATEGORIES = [ AppdefAppdefCategory, - AppdefLiveDataCategory, + AppdefLiveDataCategory, + AppdefMetricCategory, ] private Log log = LogFactory.getLog(Dispatcher.class); Added: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/MetricHelper.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/MetricHelper.groovy (rev 0) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/MetricHelper.groovy 2007-03-29 18:08:07 UTC (rev 3958) @@ -0,0 +1,30 @@ +package org.hyperic.hq.ui.rendit.helpers + +import org.hyperic.util.pager.PageControl +import org.hyperic.hq.measurement.server.session.DerivedMeasurementManagerEJBImpl +import org.hyperic.hq.appdef.shared.AppdefEntityID + +class MetricHelper + extends BaseHelper +{ + MetricHelper(user) { + super(user) + } + + private getDerivedMan() { DerivedMeasurementManagerEJBImpl.one } + + /** + * Returns a map of metric aliases onto the DerivedMeasurementValue + * objects which are enabled for the specified resource + */ + Map getEnabledMetrics(AppdefEntityID id) { + def res = [:] + def metrics = derivedMan.findMeasurements(userVal, id, true, null, + PageControl.PAGE_ALL) + + for (m in metrics) { + res[m.template.alias] = m + } + res + } +} Added: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/AppdefMetricCategory.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/AppdefMetricCategory.groovy (rev 0) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/AppdefMetricCategory.groovy 2007-03-29 18:08:07 UTC (rev 3958) @@ -0,0 +1,21 @@ +package org.hyperic.hq.ui.rendit.metaclass + +import org.hyperic.hq.appdef.shared.PlatformValue +import org.hyperic.hq.appdef.shared.AppdefResourceValue +import org.hyperic.hq.ui.rendit.helpers.MetricHelper +import org.hyperic.hq.appdef.shared.AppdefEntityID + +import groovy.lang.DelegatingMetaClass + +/** + * This category adds measurement methods to appdef types + */ +class AppdefMetricCategory { + /** + * AppdefEntityID.enabledMetrics + * See also: MetricHelper.enabledMetrics + */ + static Map getEnabledMetrics(AppdefEntityID id) { + (new MetricHelper(CategoryInfo.user)).getEnabledMetrics(id) + } +} |