|
From: <jt...@hy...> - 2007-03-27 23:42:06
|
Author: jtravis Date: 2007-03-27 15:42:02 -0800 (Tue, 27 Mar 2007) New Revision: 3930 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3930 Added: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/AppdefLiveDataCategory.groovy trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/CategoryInfo.groovy Log: Add Categories for live data, and a utility class to store the current user Added: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/AppdefLiveDataCategory.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/AppdefLiveDataCategory.groovy (rev 0) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/AppdefLiveDataCategory.groovy 2007-03-27 23:42:02 UTC (rev 3930) @@ -0,0 +1,60 @@ +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.livedata.shared.LiveDataResult +import org.hyperic.hq.ui.rendit.helpers.LiveDataHelper +import org.hyperic.hq.appdef.shared.AppdefEntityID + +import groovy.lang.DelegatingMetaClass + +/** + * This category adds utility methods to appdef types, to interface with + * LiveData. + */ +class AppdefLiveDataCategory { + /** + * AppdefEntityID.liveDataCommands + * See also: LiveDataHelper.getCommands + */ + static String[] getLiveDataCommands(AppdefEntityID ent) { + def ldh = new LiveDataHelper(CategoryInfo.user) + ldh.getCommands(ent) + } + + static String[] getLiveDataCommands(AppdefResourceValue ent) { + getLiveDataCommands(ent.entityId) + } + + /** + * AppdefEntityID.getLiveData(command, ?optionalConfigMap?) + * See also: LiveDataHelper.getData + * + * The optional config map is .. optional, but if specified, must be a + * map of string keys and string values, specifying the configuration to + * pass to the command + */ + static LiveDataResult getLiveData(AppdefEntityID ent, String command, + Object[] args) + { + def ldh = new LiveDataHelper(CategoryInfo.user) + def config + + if (args.length == 0) { + config = [:] + } else if (args.length == 1) { + config = args[0] + } else { + throw new IllegalArgumentException("Too many arguments to " + + "getLiveData()") + } + + ldh.getData(ent, command, config) + } + + static LiveDataResult getLiveData(AppdefResourceValue ent, String command, + Object[] args) + { + getLiveData(ent.entityId, command, args) + } +} Added: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/CategoryInfo.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/CategoryInfo.groovy (rev 0) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/metaclass/CategoryInfo.groovy 2007-03-27 23:42:02 UTC (rev 3930) @@ -0,0 +1,16 @@ +package org.hyperic.hq.ui.rendit.metaclass + +/** + * This class holds onto data that is used by the categories + */ +class CategoryInfo { + private static final ThreadLocal USER = new ThreadLocal() + + static void setUser(user) { + USER.set(user) + } + + static getUser() { + USER.get() + } +} |