modules/core/domain/src/main/java/org/rhq/core/client/GwtClientUtility.java | 37 + modules/core/domain/src/main/java/org/rhq/core/client/RHQDomain.java | 22 + modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java | 11 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java | 7 modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java | 18 modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java | 24 - modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 25 + modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java | 11 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 147 +++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDefinitionUtility.java | 186 ++++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java | 24 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 60 ++- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java | 6 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java | 35 + modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml | 2 22 files changed, 565 insertions(+), 93 deletions(-)
New commits: commit ab1816d9ecc4cc6e81472538fe30ae767ea0de39 Author: Ian P. Springer <ips@jetengine.(none)> Date: Fri Feb 26 12:28:45 2010 -0500
jmx plugin will no longer log warning if SIGAR is not available; Agent, rather than PC, will log this warning once at startup, and only if the user has not explicitly disabled native support (https://bugzilla.redhat.com/show_bug.cgi?id=568760)
diff --git a/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java b/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java index 3a29fff..229e79e 100644 --- a/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java +++ b/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java @@ -29,7 +29,6 @@ import java.lang.reflect.Method; import java.net.URL; import java.util.HashMap; import java.util.Map; -import java.util.TreeMap;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -48,6 +47,7 @@ public class SystemInfoFactory { private static final String NATIVE_LIBRARY_CLASS_NAME = "org.hyperic.sigar.Sigar";
private static boolean nativeLibraryLoadable; + private static Throwable nativeLibraryLoadThrowable; private static boolean disabled; private static boolean initialized = false;
@@ -76,10 +76,11 @@ public class SystemInfoFactory {
nativeLibraryLoadable = true; } catch (Throwable t) { - nativeLibraryLoadable = false; // can't load the native libs if we don't even have the JNI classes - LOG - .warn("System info API not accessible on this platform (native shared library not found in java.library.path)."); - LOG.trace("Stack trace...", t); + // We don't have the JNI classes (sigar.jar) and/or the native shared library (e.g. libsigar-amd64-linux.so). + // This might be expected (e.g. the admin console WAR (Embedded Jopr) does not include SIGAR), so don't log + // anything, but store the Throwable, so callers can log the cause when appropriate. + nativeLibraryLoadable = false; + nativeLibraryLoadThrowable = t; }
disabled = !nativeLibraryLoadable; // automatically disable native system info iff the native library is not loadable @@ -168,6 +169,17 @@ public class SystemInfoFactory { }
/** + * Returns a Throwable describing why the native library failed to initialize, or null if the native library + * initialized successfully + * + * @return a Throwable describing why the native library failed to initialize, or null if the native library + * initialized successfully + */ + public static Throwable getNativeLibraryLoadThrowable() { + return nativeLibraryLoadThrowable; + } + + /** * This returns <code>true</code> iff the native libraries have actually been initialized. This will return <code> * false</code> if this factory has been {@link #disableNativeSystemInfo() disabled} from the start (i.e. prior to * the first call to {@link #createSystemInfo()} or {@link #getNativeSystemInfoVersion()}). It will also return @@ -306,7 +318,7 @@ public class SystemInfoFactory { private static String findNativeLibrariesRootDirectory() throws Exception { String rootDir = null; File jniLocation = null; - URL jarLocation = null; + URL jarLocation;
if (isNativeSystemInfoAvailable()) { rootDir = System.getProperty("rhq.native-libraries-root-directory"); diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java index 2baf5f5..eb9dfe7 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java @@ -359,6 +359,11 @@ public class AgentMain { private final AgentRestartCounter m_agentRestartCounter = new AgentRestartCounter();
/** + * The -t command line option was specified. + */ + private boolean m_disableNativeSystem; + + /** * The main method that starts the whole thing. * * @param args @@ -2049,9 +2054,20 @@ public class AgentMain { * disabled no matter what this method decides to do. */ private void prepareNativeSystem() { - if (m_configuration.isNativeSystemDisabled() && !SystemInfoFactory.isNativeSystemInfoDisabled()) { - SystemInfoFactory.disableNativeSystemInfo(); - LOG.info(AgentI18NResourceKeys.NATIVE_SYSTEM_DISABLED); + if (m_disableNativeSystem || m_configuration.isNativeSystemDisabled()) { + if (!SystemInfoFactory.isNativeSystemInfoDisabled()) { + SystemInfoFactory.disableNativeSystemInfo(); + LOG.info(AgentI18NResourceKeys.NATIVE_SYSTEM_DISABLED); + } + } else { + if (!SystemInfoFactory.isNativeSystemInfoAvailable()) { + Throwable t = SystemInfoFactory.getNativeLibraryLoadThrowable(); + if (LOG.isDebugEnabled()) { + LOG.debug(AgentI18NResourceKeys.NATIVE_SYSINFO_UNAVAILABLE_DEBUG, t); + } else { + LOG.warn(AgentI18NResourceKeys.NATIVE_SYSINFO_UNAVAILABLE); + } + } }
return; @@ -2807,8 +2823,7 @@ public class AgentMain { }
case 't': { - SystemInfoFactory.disableNativeSystemInfo(); - LOG.info(AgentI18NResourceKeys.NATIVE_SYSTEM_DISABLED); + m_disableNativeSystem = true; } } } diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java index 68da9a6..e789f02 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java @@ -498,6 +498,15 @@ public interface AgentI18NResourceKeys { @I18NMessage("Neither server auto-detection nor polling is enabled - the client will be allowed to start sending commands immediately, but when the server is offline, be prepared for alot of errors to be logged") String NO_AUTO_DETECT = "AgentMain.no-auto-detect";
+ @I18NMessage("Native system info is enabled, but the system info API is not accessible on this platform " + + "(sigar.jar not found in classpath or SIGAR shared library not found in shared library path). " + + "Enable DEBUG logging for more details.") + String NATIVE_SYSINFO_UNAVAILABLE = "AgentMain.native-sysinfo-unavailable"; + + @I18NMessage("Native system info is enabled, but the system info API is not accessible on this platform " + + "(sigar.jar not found in classpath or SIGAR shared library not found in shared library path).") + String NATIVE_SYSINFO_UNAVAILABLE_DEBUG = "AgentMain.native-sysinfo-unavailable-debug"; + @I18NMessage("The agent encountered an error during startup and must abort") String STARTUP_ERROR = "AgentMain.startup-error";
diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java index 84ae286..ce8631a 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. + * Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -37,6 +37,7 @@ import org.apache.commons.logging.LogFactory; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.ProcessScanResult; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.pluginapi.inventory.ManualAddFacet; @@ -66,8 +67,8 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual
public static final String ADDITIONAL_CLASSPATH_ENTRIES = "additionalClassPathEntries";
- /* Ignore certain processes that are managed by their own plugin. For example The Tomcat plugin will - * handle tomcat processes configured for JMX management. + /* Ignore certain processes that are managed by their own plugin. For example, the Tomcat plugin will + * handle Tomcat processes configured for JMX management. */ private static final String[] PROCESS_FILTERS;
@@ -79,7 +80,7 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual processFilters = env.split(","); } } catch (Throwable t) { - log.error("Can't determine process filters, using default. Cause: " + t); + log.error("Can't determine process filters; using default... Cause: " + t); } finally { PROCESS_FILTERS = processFilters; } @@ -135,10 +136,11 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual // }
try { - List<ProcessInfo> processes = context.getSystemInformation().getProcesses("process|basename|match=^java.*"); + List<ProcessScanResult> processes = context.getAutoDiscoveredProcesses();
- for (ProcessInfo process : processes) { - DiscoveredResourceDetails details = discoverProcess(context, process); + for (ProcessScanResult process : processes) { + ProcessInfo processInfo = process.getProcessInfo(); + DiscoveredResourceDetails details = discoverProcess(context, processInfo); if (details != null) { boolean isFiltered = false; for (String filter : PROCESS_FILTERS) { @@ -153,10 +155,11 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual } } } catch (Exception e) { - if (log.isDebugEnabled()) - log.debug("Unable to complete base jmx server discovery.", e); - else - log.warn("Unable to complete base jmx server discovery (enable DEBUG for stack): " + e); + if (log.isDebugEnabled()) { + log.debug("Unable to complete base JMX server discovery.", e); + } else { + log.warn("Unable to complete base JMX server discovery (enable DEBUG for stack): " + e); + } }
return found; @@ -228,12 +231,16 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual String arg = process.getCommandLine()[i];
if (!arg.startsWith("-")) { - if (arg.length() < 200) { // don't use it if its really long, that's an ugly resource name + if (arg.length() <= 200) { name = arg; - break; + } else { + // Truncate it if it's really long for a more palatable Resource name. + name = arg.substring(arg.length() - 200); } + break; } else if (arg.equals("-cp") || arg.equals("-classpath")) { - i++; // skip the next arg, its the classpath, we don't want that as the name + // Skip the next arg - it's the classpath, and we don't want that as the name. + i++; } }
diff --git a/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml index bcec166..a8131c8 100644 --- a/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml @@ -69,6 +69,8 @@
</plugin-configuration>
+ <process-scan name="java" query="process|basename|match=^java.*"/> + <help> <![CDATA[ <p>In order to monitor your Java applications via JMX, you need to expose their MBeans to remote JMX clients.
commit 187d133e8210eda4d80a297379ab64bdff2273f6 Author: Ian P. Springer <ips@jetengine.(none)> Date: Fri Feb 26 12:22:11 2010 -0500
add remaining fields to Alert history table; first pass at implementing deletion for Alerts
diff --git a/modules/core/domain/src/main/java/org/rhq/core/client/GwtClientUtility.java b/modules/core/domain/src/main/java/org/rhq/core/client/GwtClientUtility.java new file mode 100644 index 0000000..0a227e0 --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/client/GwtClientUtility.java @@ -0,0 +1,37 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.core.client; + +/** + * @author Ian Springer + */ +public class GwtClientUtility { + public static String getSimpleName(Class clazz) { + String className = clazz.getName(); + // TODO: Cache the simple names in a static Map<Class, String>. + return className.substring(className.lastIndexOf(".") + 1); + } + + private GwtClientUtility() { + } +} diff --git a/modules/core/domain/src/main/java/org/rhq/core/client/RHQDomain.java b/modules/core/domain/src/main/java/org/rhq/core/client/RHQDomain.java index 4aace32..9669149 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/client/RHQDomain.java +++ b/modules/core/domain/src/main/java/org/rhq/core/client/RHQDomain.java @@ -1,3 +1,25 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.client;
import com.google.gwt.core.client.EntryPoint; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java index 66516d7..796ae01 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java @@ -29,6 +29,7 @@ import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -246,12 +247,14 @@ public class Alert implements Serializable { @Column(name = "RECOVERY_ID") private Integer recoveryId;
+ @JoinColumn(name = "RECOVERY_ID", referencedColumnName = "ID", insertable = false, updatable = false) + @ManyToOne(fetch = FetchType.LAZY) + private AlertDefinition recoveryAlertDefinition; + @Column(name = "WILL_RECOVER", nullable = false) private boolean willRecover;
- - @Column(name ="ACK_TIME") private long ackTime;
@@ -368,6 +371,10 @@ public class Alert implements Serializable { this.recoveryId = actOnTriggerId; }
+ public AlertDefinition getRecoveryAlertDefinition() { + return this.recoveryAlertDefinition; + } + @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java index b1965e4..25aa0d8 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java @@ -59,6 +59,7 @@ public class AlertCriteria extends Criteria { private boolean fetchAlertDefinition; private boolean fetchConditionLogs; private boolean fetchNotificationLogs; + private boolean fetchRecoveryAlertDefinition;
private PageOrdering sortName; // requires overrides private PageOrdering sortCtime; @@ -157,6 +158,10 @@ public class AlertCriteria extends Criteria { this.fetchNotificationLogs = fetchNotificationLogs; }
+ public void fetchRecoveryAlertDefinition(boolean fetchRecoveryAlertDefinition) { + this.fetchRecoveryAlertDefinition = fetchRecoveryAlertDefinition; + } + public void addSortName(PageOrdering sortName) { addSortField("name"); this.sortName = sortName; @@ -170,5 +175,5 @@ public class AlertCriteria extends Criteria { public void addSortPriority(PageOrdering sortPriority) { addSortField("priority"); this.sortPriority = sortPriority; - } + } } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java index 62a2fa2..214be85 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. + * Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -22,12 +22,10 @@ */ package org.rhq.core.domain.criteria;
+import org.rhq.core.client.GwtClientUtility; import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.util.PageControl;
-import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType;
@@ -43,7 +41,6 @@ import java.util.Map; */ @XmlAccessorType(XmlAccessType.FIELD) public abstract class Criteria implements Serializable { - public enum Type { FILTER, FETCH, SORT; } @@ -63,6 +60,7 @@ public abstract class Criteria implements Serializable { protected PageControl pageControlOverrides;
private List<String> orderingFieldNames; + private String alias;
//added no args constructor for bean and JAXB requirement @SuppressWarnings("unused") @@ -85,7 +83,6 @@ public abstract class Criteria implements Serializable { public abstract Class getPersistentClass();
- public String getJPQLFilterOverride(String fieldName) { return filterOverrides.get(fieldName); } @@ -221,8 +218,11 @@ public abstract class Criteria implements Serializable { }
public String getAlias() { - String className = getPersistentClass().getName(); - String simpleClassName = className.substring(className.lastIndexOf(".") + 1); - return simpleClassName.toLowerCase(); + if (this.alias == null) { + // Base alias on persistent class's name: org.rhq.core.domain.ResourceType -> "resourcetype" + String classSimpleName = GwtClientUtility.getSimpleName(getPersistentClass()); + this.alias = classSimpleName.toLowerCase(); + } + return this.alias; } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java index fad909c..27cbebd 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java @@ -61,7 +61,6 @@ public class CoreGUI implements EntryPoint { }); }
- RequestBuilder b = new RequestBuilder(RequestBuilder.GET, "/j_security_check.do?j_username=rhqadmin&j_password=rhqadmin"); try { b.setCallback(new RequestCallback() { @@ -78,13 +77,12 @@ public class CoreGUI implements EntryPoint { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. }
- SubjectGWTServiceAsync subjectService = SubjectGWTServiceAsync.Util.getInstance();
subjectService.login("rhqadmin", "rhqadmin", new AsyncCallback<Subject>() { public void onFailure(Throwable caught) { - System.out.println("failed to login"); - Label loginFailed = new Label("Could not login"); + System.out.println("Failed to login - cause: " + caught); + Label loginFailed = new Label("Failed to login - cause: " + caught); loginFailed.draw(); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java index 1156167..0c000b2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java @@ -46,7 +46,6 @@ public class DemoCanvas extends Canvas { setWidth100(); setHeight100();
- final TabSet topTabSet = new TabSet(); topTabSet.setTabBarPosition(Side.TOP); topTabSet.setWidth100();//(1200); @@ -54,19 +53,17 @@ public class DemoCanvas extends Canvas {
// topTabSet.setTop(50);
- Tab tableTab = new Tab("Resource Search Table"); Tab treeTab = new Tab("Resource Tree"); final Tab configTab = new Tab("Configuration Editor"); Tab alertHistoryTab = new Tab("Alert History");
- // Agent: resource (10005) type (10060) // Raw: 10003 / 10023 // both: 10002 / 10022
- configTab.setPane(new ConfigurationEditor(10005, 10060, ConfigurationEditor.ConfigType.plugin)); - treeTab.setPane(new ResourceTreeView(new Resource(10001))); + //configTab.setPane(new ConfigurationEditor(10005, 10060, ConfigurationEditor.ConfigType.plugin)); + //treeTab.setPane(new ResourceTreeView(new Resource(10001))); tableTab.setPane(new ResourceSearchView()); alertHistoryTab.setPane(new AlertsView());
@@ -74,7 +71,7 @@ public class DemoCanvas extends Canvas { topTabSet.addTab(tableTab); topTabSet.addTab(treeTab); topTabSet.addTab(alertHistoryTab); - + //topTabSet.selectTab(alertHistoryTab);
final Menu configSelectMenu = new Menu(); configSelectMenu.addItem(new MenuItem("Agent")); @@ -107,10 +104,8 @@ public class DemoCanvas extends Canvas { } });
- topTabSet.setTabBarControls(TabBarControls.TAB_SCROLLER, TabBarControls.TAB_PICKER, new MenuButton("Config Resource", configSelectMenu));
- addChild(topTabSet); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java index 864feb3..bf97cca 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java @@ -70,7 +70,7 @@ public class RolesDataSource extends RPCDataSource { }
- public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) { + public void executeFetch(final DSRequest request, final DSResponse response) { final long start = System.currentTimeMillis();
RoleCriteria criteria = new RoleCriteria(); @@ -81,7 +81,7 @@ public class RolesDataSource extends RPCDataSource { Window.alert("Failed to load " + caught.getMessage()); System.err.println("Failed to fetch Resource Data"); response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(requestId, response); + processResponse(request.getRequestId(), response); }
public void onSuccess(PageList<Role> result) { @@ -101,7 +101,7 @@ public class RolesDataSource extends RPCDataSource {
response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set - processResponse(requestId, response); + processResponse(request.getRequestId(), response);
} }); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java index 5de4698..6bfc7a6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java @@ -86,8 +86,7 @@ public class UsersDataSource extends RPCDataSource { }
- - public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) { + public void executeFetch(final DSRequest request, final DSResponse response) { final long start = System.currentTimeMillis();
SubjectCriteria criteria = new SubjectCriteria(); @@ -98,7 +97,7 @@ public class UsersDataSource extends RPCDataSource { Window.alert("Failed to load " + caught.getMessage()); System.err.println("Failed to fetch Resource Data"); response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(requestId, response); + processResponse(request.getRequestId(), response); }
public void onSuccess(PageList<Subject> result) { @@ -122,7 +121,7 @@ public class UsersDataSource extends RPCDataSource {
response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set - processResponse(requestId, response); + processResponse(request.getRequestId(), response); } }); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java index 838a3d4..9e73bbb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.gui.coregui.client.alert;
+import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -27,15 +28,27 @@ import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.rpc.RPCResponse; +import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord; import org.rhq.core.domain.alert.Alert; +import org.rhq.core.domain.alert.AlertCondition; +import org.rhq.core.domain.alert.AlertConditionLog; import org.rhq.core.domain.criteria.AlertCriteria; +import org.rhq.core.domain.measurement.MeasurementConverterClient; +import org.rhq.core.domain.util.OrderingField; import org.rhq.core.domain.util.PageList; +import org.rhq.core.domain.util.PageOrdering; import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set;
/** * @author Ian Springer @@ -58,25 +71,93 @@ public class AlertDataSource extends RPCDataSource { protected AlertDataSource() { super(NAME);
+ setCanMultiSort(true); + DataSourceField idDataField = new DataSourceIntegerField("id", "Id"); idDataField.setPrimaryKey(true); idDataField.setHidden(true);
+ DataSourceField resourceIdDataField = new DataSourceIntegerField("alertDefinition.resource.Id", "Resource Id"); + idDataField.setHidden(true); + DataSourceTextField nameField = new DataSourceTextField("alertDefinition.name", "Name", 100);
+ DataSourceTextField conditionTextField = new DataSourceTextField("conditionText", "Condition Text"); + conditionTextField.setCanSortClientOnly(true); + + DataSourceTextField conditionValueField = new DataSourceTextField("conditionValue", "Condition Value"); + conditionValueField.setCanSortClientOnly(true); + + DataSourceTextField recoveryInfoField = new DataSourceTextField("recoveryInfo", "Recovery Info"); + recoveryInfoField.setCanSortClientOnly(true); + // TODO: Use DataSourceEnumField here? DataSourceTextField priorityField = new DataSourceTextField("alertDefinition.priority", "Priority", 15);
DataSourceTextField ctimeField = new DataSourceTextField("ctime", "Creation Time");
- setFields(idDataField, nameField, priorityField, ctimeField); + setFields(idDataField, nameField, conditionTextField, conditionValueField, recoveryInfoField, priorityField, + ctimeField); + } + + void deleteAlerts(final ListGrid listGrid, final AlertsView alertsView) { + ListGridRecord[] records = listGrid.getSelection(); + final Map<Integer, List<ListGridRecord>> alertIdMap = new HashMap<Integer, List<ListGridRecord>>(); + for (int i = 0, selectionLength = records.length; i < selectionLength; i++) { + ListGridRecord record = records[i]; + Integer resourceId = record.getAttributeAsInt("alertDefinition.resource.id"); + List<ListGridRecord> recordsForResource; + if (alertIdMap.containsKey(resourceId)) { + recordsForResource = alertIdMap.get(resourceId); + } else { + recordsForResource = new ArrayList<ListGridRecord>(); + alertIdMap.put(resourceId, recordsForResource); + } + recordsForResource.add(record); + } + + AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService(); + final Set<Integer> successfulResourceIds = new HashSet<Integer>(); + final Set<Integer> failedResourceIds = new HashSet<Integer>(); + for (final Integer resourceId : alertIdMap.keySet()) { + final List<ListGridRecord> recordsForResource = alertIdMap.get(resourceId); + Integer[] alertIds = new Integer[recordsForResource.size()]; + for (int i = 0; i < recordsForResource.size(); i++) { + ListGridRecord listGridRecord = recordsForResource.get(i); + Integer alertId = listGridRecord.getAttributeAsInt("id"); + alertIds[i] = alertId; + } + + alertService.deleteAlerts(resourceId, alertIds, new AsyncCallback<Void>() { + public void onSuccess(Void blah) { + /*for (ListGridRecord record : recordsForResource) { + removeData(record); + }*/ + successfulResourceIds.add(resourceId); + if (successfulResourceIds.size() + failedResourceIds.size() == alertIdMap.size()) { + alertsView.reportSelectedAlertsDeleted(listGrid); + } + } + + public void onFailure(Throwable caught) { + Window.alert("Failed to delete Alerts for Resource with id " + resourceId + " - cause: " + caught); + System.err.println("Failed to delete Alerts for Resource with id " + resourceId + " - cause: " + caught); + failedResourceIds.add(resourceId); + if (successfulResourceIds.size() + failedResourceIds.size() == alertIdMap.size()) { + // TODO: Report failure. + } + } + }); + } }
- public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) { + protected void executeFetch(final DSRequest request, final DSResponse response) { final long start = System.currentTimeMillis();
AlertCriteria criteria = new AlertCriteria(); criteria.fetchAlertDefinition(true); + criteria.fetchConditionLogs(true); + criteria.fetchRecoveryAlertDefinition(true);
criteria.setPageControl(getPageControl(request, criteria.getAlias()));
@@ -85,28 +166,74 @@ public class AlertDataSource extends RPCDataSource { Window.alert("Failed to fetch Alerts - cause: " + caught); System.err.println("Failed to fetch Alerts - cause: " + caught); response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(requestId, response); + processResponse(request.getRequestId(), response); }
public void onSuccess(PageList<Alert> result) { - System.out.println(result.size() + " Alerts fetched in: " + (System.currentTimeMillis() - start) + "ms"); + long fetchTime = System.currentTimeMillis() - start; + System.out.println(result.size() + " Alerts fetched in: " + fetchTime + "ms");
ListGridRecord[] records = new ListGridRecord[result.size()]; for (int i = 0; i < result.size(); i++) { Alert alert = result.get(i); - ListGridRecord record = new ListGridRecord(); - record.setAttribute("id", alert.getId()); - record.setAttribute("alertDefinition.name", alert.getAlertDefinition().getName()); - record.setAttribute("alertDefinition.priority", alert.getAlertDefinition().getPriority().name()); - record.setAttribute("ctime", DATE_TIME_FORMAT.format(new Date(alert.getCtime()))); + ListGridRecord record = createRecord(alert); records[i] = record; }
response.setData(records); // For paging to work, we have to specify size of full result set. response.setTotalRows(result.getTotalSize()); - processResponse(requestId, response); + processResponse(request.getRequestId(), response); } }); } + + protected void executeRemove(final DSRequest request, final DSResponse response) { + JavaScriptObject data = request.getData (); + ListGridRecord record = new ListGridRecord(data); + Window.alert(String.valueOf(record.getAttributeAsInt("id"))); + } + + private ListGridRecord createRecord(Alert alert) { + ListGridRecord record = new ListGridRecord(); + record.setAttribute("id", alert.getId()); + record.setAttribute("alertDefinition.resource.id", alert.getAlertDefinition().getResource().getId()); + record.setAttribute("alertDefinition.name", alert.getAlertDefinition().getName()); + record.setAttribute("alertDefinition.priority", alert.getAlertDefinition().getPriority().name()); + record.setAttribute("ctime", DATE_TIME_FORMAT.format(new Date(alert.getCtime()))); + + Set<AlertConditionLog> conditionLogs = alert.getConditionLogs(); + String conditionText; + String conditionValue; + if (conditionLogs.size() > 1) { + conditionText = "Multiple Conditions"; + conditionValue = "--"; + } else if (conditionLogs.size() == 1) { + AlertConditionLog conditionLog = conditionLogs.iterator().next(); + AlertCondition condition = conditionLog.getCondition(); + conditionText = AlertDefinitionUtility.formatAlertConditionForDisplay(condition); + conditionValue = conditionLog.getValue(); + if (condition.getMeasurementDefinition() != null) { + conditionValue = MeasurementConverterClient.format(Double.valueOf(conditionLog.getValue()), condition + .getMeasurementDefinition().getUnits(), true); + } + } else { + conditionText = "No Conditions"; + conditionValue = "--"; + } + record.setAttribute("conditionText", conditionText); + record.setAttribute("conditionValue", conditionValue); + + String recoveryInfo = AlertDefinitionUtility.getAlertRecoveryInfo(alert); + record.setAttribute("recoveryInfo", recoveryInfo); + return record; + } + + @Override + protected List<OrderingField> getDefaultOrderingFields(String alias) { + List<OrderingField> orderingFields = new ArrayList<OrderingField>(2); + orderingFields.add(new OrderingField(alias + ".alertDefinition.name", PageOrdering.ASC)); + orderingFields.add(new OrderingField(alias + ".ctime", PageOrdering.DESC)); + return orderingFields; + } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDefinitionUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDefinitionUtility.java new file mode 100644 index 0000000..dcccee7 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDefinitionUtility.java @@ -0,0 +1,186 @@ +/* + * RHQ Management Platform + * Copyright (C) 2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.rhq.enterprise.gui.coregui.client.alert; + +import org.rhq.core.domain.alert.Alert; +import org.rhq.core.domain.alert.AlertCondition; +import org.rhq.core.domain.alert.AlertConditionCategory; +import org.rhq.core.domain.alert.AlertDefinition; +import org.rhq.core.domain.measurement.MeasurementBaseline; +import org.rhq.core.domain.measurement.MeasurementConverterClient; +import org.rhq.core.domain.measurement.MeasurementSchedule; +import org.rhq.core.domain.measurement.MeasurementUnits; +import org.rhq.core.domain.measurement.util.MeasurementConversionException; + +import java.util.ArrayList; +import java.util.List; + +/** + * The methods in this class are ported from AlertDefUtil from portal-war and MeasurementFormatter from + * server-jar. + * + * @author Ian Springer + */ +public class AlertDefinitionUtility { + private static final String BASELINE_OPT_MEAN = "mean"; + private static final String BASELINE_OPT_MIN = "min"; + private static final String BASELINE_OPT_MAX = "max"; + + private static final String MEASUREMENT_BASELINE_MIN_TEXT = "Min Value"; + private static final String MEASUREMENT_BASELINE_MEAN_TEXT = "Baseline Value"; + private static final String MEASUREMENT_BASELINE_MAX_TEXT = "Max Value"; + + @SuppressWarnings("deprecation") + public static String formatAlertConditionForDisplay(AlertCondition condition) { + AlertConditionCategory category = condition.getCategory(); + + StringBuilder textValue = new StringBuilder(); + + // first format the LHS of the operator + if (category == AlertConditionCategory.CONTROL) { + try { + String operationName = condition.getName(); + /*Integer resourceTypeId = condition.getAlertDefinition().getResource().getResourceType().getId(); + OperationManagerLocal operationManager = LookupUtil.getOperationManager(); + OperationDefinition definition = operationManager.getOperationDefinitionByResourceTypeAndName( + resourceTypeId, operationName, false); + String operationDisplayName = definition.getDisplayName();*/ + textValue.append(operationName).append(' '); + } catch (Exception e) { + textValue.append(condition.getName()).append(' '); + } + } else if (category == AlertConditionCategory.RESOURCE_CONFIG) { + textValue.append("Resource Configuration").append(' '); + } else { + textValue.append(condition.getName()).append(' '); + } + + // next format the RHS + if (category == AlertConditionCategory.CONTROL) { + textValue.append(condition.getOption()); + } else if ((category == AlertConditionCategory.THRESHOLD) || (category == AlertConditionCategory.BASELINE)) { + textValue.append(condition.getComparator()); + textValue.append(' '); + + MeasurementSchedule schedule = null; + + MeasurementUnits units; + double value = condition.getThreshold(); + if (category == AlertConditionCategory.THRESHOLD) { + units = condition.getMeasurementDefinition().getUnits(); + } else // ( category == AlertConditionCategory.BASELINE ) + { + units = MeasurementUnits.PERCENTAGE; + } + + String formatted = MeasurementConverterClient.format(value, units, true); + textValue.append(formatted); + + if (category == AlertConditionCategory.BASELINE) { + textValue.append(" of "); + textValue.append(getBaselineText(condition.getOption(), schedule)); + } + } else if (category == AlertConditionCategory.RESOURCE_CONFIG || category == AlertConditionCategory.CHANGE + || category == AlertConditionCategory.TRAIT) { + textValue.append("Value Changed"); + } else if (category == AlertConditionCategory.EVENT) { + String msgKey = "alert.config.props.CB.EventSeverity"; + List<String> args = new ArrayList<String>(2); + + args.add(condition.getName()); + if ((condition.getOption() != null) && (condition.getOption().length() > 0)) { + msgKey += ".RegexMatch"; + args.add(condition.getOption()); + } + // TODO + textValue.append("TODO ").append(args); + } else if (category == AlertConditionCategory.AVAILABILITY) { + // TODO + textValue.append("Availability ").append(condition.getOption()); + } else { + // do nothing + } + + return textValue.toString(); + } + + public static String getAlertRecoveryInfo(Alert alert) { + String recoveryInfo; + AlertDefinition recoveryAlertDefinition = alert.getRecoveryAlertDefinition(); + if (recoveryAlertDefinition != null && recoveryAlertDefinition.getId() != 0) { + int resourceId = alert.getAlertDefinition().getResource().getId(); + recoveryInfo = "Triggered '<a href="/alerts/Config.do?mode=viewRoles&id=" + resourceId + "&ad=" + recoveryAlertDefinition.getId() + + "">" + recoveryAlertDefinition.getName() + "</a>' to be re-enabled."; + } else if (alert.getWillRecover()) { + recoveryInfo = "This alert caused its alert definition to be disabled."; + } else { + recoveryInfo = "N/A"; + } + return recoveryInfo; + } + + private static String getBaselineText(String baselineOption, MeasurementSchedule schedule) { + if ((null != schedule) && (null != schedule.getBaseline())) { + MeasurementBaseline baseline = schedule.getBaseline(); + + String lookupText = null; + Double value = null; + + if (baselineOption.equals(BASELINE_OPT_MIN)) { + lookupText = MEASUREMENT_BASELINE_MIN_TEXT; + value = baseline.getMin(); + } else if (baselineOption.equals(BASELINE_OPT_MEAN)) { + lookupText = MEASUREMENT_BASELINE_MEAN_TEXT; + value = baseline.getMean(); + } else if (baselineOption.equals(BASELINE_OPT_MAX)) { + lookupText = MEASUREMENT_BASELINE_MAX_TEXT; + value = baseline.getMax(); + } + + if (value != null) { + try { + String formatted = MeasurementConverterClient.scaleAndFormat(value, schedule, true); + return formatted + " (" + lookupText + ")"; + } catch (MeasurementConversionException mce) { + return lookupText; + } + } + /* + * will need a fall-through here because the value was null; this can happen when the user requests to view + * the formatted baseline before the first time it has been calculated + */ + } + + // here is the fall-through + if (BASELINE_OPT_MIN.equals(baselineOption)) { + return MEASUREMENT_BASELINE_MIN_TEXT; + } else if (BASELINE_OPT_MAX.equals(baselineOption)) { + return MEASUREMENT_BASELINE_MAX_TEXT; + } else { + return MEASUREMENT_BASELINE_MEAN_TEXT; + } + } + + private AlertDefinitionUtility() { + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java index dce235f..190b789 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertsView.java @@ -86,8 +86,10 @@ public class AlertsView extends SectionStack { public void onClick(ClickEvent clickEvent) { SC.confirm("Are you sure you want to delete " + listGrid.getSelection().length + " alerts?", new BooleanCallback() { - public void execute(Boolean aBoolean) { - + public void execute(Boolean confirmed) { + if (confirmed) { + deleteSelectedAlerts(dataSource, listGrid); + } } } ); @@ -136,4 +138,22 @@ public class AlertsView extends SectionStack {
} + + private void deleteSelectedAlerts(AlertDataSource dataSource, ListGrid listGrid) { + //listGrid.removeSelectedData(); + + /*DSRequest request = new DSRequest(); + request.setAttribute("data", listGrid.getSelection()); + DSResponse response = new DSResponse(); + dataSource.executeRemove(request, response);*/ + + dataSource.deleteAlerts(listGrid, this); + markForRedraw(); + } + + void reportSelectedAlertsDeleted(ListGrid listGrid) { + listGrid.removeSelectedData(); + System.out.println("Alerts deleted successfully."); + listGrid.markForRedraw(); + } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java index 66cffe3..cf19e2d 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertGWTService.java @@ -37,4 +37,6 @@ public interface AlertGWTService extends RemoteService { * @return all alerts that match the specified criteria */ PageList<Alert> findAlertsByCriteria(AlertCriteria criteria); + + void deleteAlerts(int resourceId, Integer[] alertIds); } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java index 9d65377..618fefe 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java @@ -74,7 +74,7 @@ public class ResourceDatasource extends RPCDataSource { }
- public void executeFetch(final String requestId, final DSRequest request, final DSResponse response) { + public void executeFetch(final DSRequest request, final DSResponse response) { final long start = System.currentTimeMillis();
ResourceCriteria criteria = new ResourceCriteria(); @@ -86,7 +86,7 @@ public class ResourceDatasource extends RPCDataSource { Window.alert("Failed to load " + caught.getMessage()); System.err.println("Failed to fetch Resource Data"); response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(requestId, response); + processResponse(request.getRequestId(), response); }
public void onSuccess(PageList<Resource> result) { @@ -110,7 +110,7 @@ public class ResourceDatasource extends RPCDataSource {
response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set - processResponse(requestId, response); + processResponse(request.getRequestId(), response); } }); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java index 4c23252..b053c71 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java @@ -34,7 +34,7 @@ import ca.nanometrics.gflot.client.options.PlotOptions; import ca.nanometrics.gflot.client.options.PointsSeriesOptions; import ca.nanometrics.gflot.client.options.TickFormatter;
-import org.rhq.core.domain.measurement.MeasurementConverter; +import org.rhq.core.domain.measurement.MeasurementConverterClient; import org.rhq.core.domain.measurement.MeasurementDefinition; import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
@@ -53,7 +53,6 @@ import java.util.List; */ public class SmallGraphView extends VLayout {
- private static final String INSTRUCTIONS = "Point your mouse to a data point on the chart";
private static final String[] MONTH_NAMES = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"}; @@ -166,7 +165,7 @@ public class SmallGraphView extends VLayout { private String getHover(PlotItem item) { if (definition != null) { com.google.gwt.i18n.client.DateTimeFormat df = DateTimeFormat.getMediumDateTimeFormat(); - return definition.getDisplayName() + ": " + MeasurementConverter.format(item.getDataPoint().getY(),definition.getUnits(), true) + return definition.getDisplayName() + ": " + MeasurementConverterClient.format(item.getDataPoint().getY(),definition.getUnits(), true) + "<br/>" + df.format(new Date((long) item.getDataPoint().getX())); } else { return "x: " + item.getDataPoint().getX() + ", y: " + item.getDataPoint().getY(); @@ -182,7 +181,7 @@ public class SmallGraphView extends VLayout {
plotOptions.setYAxisOptions(new AxisOptions().setTicks(5).setTickFormatter(new TickFormatter() { public String formatTickValue(double v, Axis axis) { - return MeasurementConverter.format(v, definition.getUnits(), true); + return MeasurementConverterClient.format(v, definition.getUnits(), true); } }));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java index b1a8012..ef00853 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.gui.coregui.client.util;
+import org.rhq.core.domain.util.OrderingField; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageOrdering;
@@ -27,6 +28,8 @@ import com.smartgwt.client.data.DataSource; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol;
+import java.util.List; + /** * @author Greg Hinkle */ @@ -48,33 +51,24 @@ public abstract class RPCDataSource extends DataSource {
@Override protected Object transformRequest(DSRequest request) { - String requestId = request.getRequestId(); - DSResponse response = new DSResponse(); - response.setAttribute("clientContext", request.getAttributeAsObject("clientContext")); - // Asume success - response.setStatus(0); switch (request.getOperationType()) { - case ADD: - //executeAdd(lstRec, true); - break; case FETCH: - executeFetch(requestId, request, response); - break; - case REMOVE: - //executeRemove(lstRec); + DSResponse response = createResponse(request); + executeFetch(request, response); break; + case ADD: case UPDATE: - //executeAdd(lstRec, false); + case REMOVE: + super.transformRequest(request); break; - default: + super.transformRequest(request); break; }
return request.getData(); }
- /** * Returns a prepopulated PageControl based on the provided DSRequest. This will set sort fields, * pagination, but *not* filter fields. @@ -88,7 +82,14 @@ public abstract class RPCDataSource extends DataSource {
// Initialize sorting. String sortBy = request.getAttribute("sortBy"); - if (sortBy != null) { + if (sortBy == null) { + List<OrderingField> orderingFields = getDefaultOrderingFields(alias); + if (orderingFields != null) { + for (OrderingField orderingField : orderingFields) { + pageControl.addDefaultOrderingField(orderingField.getField(), orderingField.getOrdering()); + } + } + } else { String[] sorts = sortBy.split(","); for (String sort : sorts) { PageOrdering ordering = (sort.startsWith("-")) ? PageOrdering.DESC : PageOrdering.ASC; @@ -101,6 +102,31 @@ public abstract class RPCDataSource extends DataSource { return pageControl; }
- public abstract void executeFetch(final String requestId, final DSRequest request, final DSResponse response); + protected List<OrderingField> getDefaultOrderingFields(String alias) { + return null; + } + + protected abstract void executeFetch(final DSRequest request, final DSResponse response);
+ /** + * Executed on <code>REMOVE</code> operation. <code>processResponse (requestId, response)</code> + * should be called when operation completes (either successful or failure). + * + * @param request <code>DSRequest</code> being processed. <code>request.getData ()</code> + * contains record should be removed. + * @param response <code>DSResponse</code>. <code>setData (list)</code> should be called on + * successful execution of this method. Array should contain single element representing + * removed row. <code>setStatus (<0)</code> should be called on failure. + */ + protected void executeRemove (final DSRequest request, final DSResponse response) { + throw new UnsupportedOperationException("This dataSource does not support removal."); + } + + private DSResponse createResponse(DSRequest request) { + DSResponse response = new DSResponse(); + response.setAttribute("clientContext", request.getAttributeAsObject("clientContext")); + // Assume success as the default. + response.setStatus(0); + return response; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java index 36538f8..b88385e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java @@ -33,7 +33,11 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert private AlertManagerLocal alertManager = LookupUtil.getAlertManager();
public PageList<Alert> findAlertsByCriteria(AlertCriteria criteria) { - return SerialUtility.prepare(alertManager.findAlertsByCriteria(getSessionSubject(), criteria), + return SerialUtility.prepare(this.alertManager.findAlertsByCriteria(getSessionSubject(), criteria), "AlertService.findAlertsByCriteria"); } + + public void deleteAlerts(int resourceId, Integer[] alertIds) { + this.alertManager.deleteAlerts(getSessionSubject(), resourceId, alertIds); + } } \ No newline at end of file
rhq-commits@lists.fedorahosted.org