[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 18 +++++++---
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml | 2 -
2 files changed, 14 insertions(+), 6 deletions(-)
New commits:
commit 8ffce671fa4d1977b2850a0ae3462969274a701c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Sep 15 12:04:43 2010 -0400
make CoreGUI.html a welcome page, so http://localhost:7080/coregui/ works
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index a86b217..6e5d56b 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -1,10 +1,12 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- version="2.5">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <display-name>RHQ GUI</display-name>
+
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI RoleGWTService</servlet-name>
@@ -214,4 +216,10 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI ClusterGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/ClusterGWTService</url-pattern>
</servlet-mapping>
+
+
+ <welcome-file-list>
+ <welcome-file>CoreGUI.html</welcome-file>
+ </welcome-file-list>
+
</web-app>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
index ed22bc6..2cdedb1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
- <display-name>RHQ</display-name>
+ <display-name>RHQ Legacy GUI</display-name>
<!--=== Seam ===-->
13 years, 9 months
[rhq] 4 commits - etc/eclipse-tools modules/enterprise
by Jay Shaughnessy
etc/eclipse-tools/maven/RHQ | 11 +
modules/enterprise/gui/coregui/pom.xml | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 14 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java | 92 ++++------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 10 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java | 45 +---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java | 23 +-
8 files changed, 108 insertions(+), 98 deletions(-)
New commits:
commit cc727ab9928ec5463171ff4eac8f5d69315198da
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 15 11:33:23 2010 -0400
A few more locatorId hooks in the TopMenu Search bar
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 34d1621..403456c 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
@@ -232,7 +232,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
// menuPane.setZIndex(400000);
// layout.addMember(menuPane);
- MenuBarView menuBarView = new MenuBarView();
+ MenuBarView menuBarView = new MenuBarView("TopMenu");
menuBarView.setWidth("100%");
// WidgetCanvas menuCanvas = new WidgetCanvas(menuBarView);
// menuCanvas.setTop(0);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java
index c98c16d..da5b92e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/DropDownMenuBarView.java
@@ -28,7 +28,6 @@ import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuBar;
import com.smartgwt.client.widgets.menu.MenuItem;
@@ -37,23 +36,23 @@ import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.AboutModalWindow;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
*/
-public class DropDownMenuBarView extends VLayout {
+public class DropDownMenuBarView extends LocatableVLayout {
private AboutModalWindow aboutModalWindow;
- public DropDownMenuBarView() {
- super(5);
+ public DropDownMenuBarView(String locatorId) {
+ super(locatorId, 5);
+
setHeight(50);
setWidth100();
-
}
-
protected void onDraw3() {
super.onDraw();
@@ -62,10 +61,9 @@ public class DropDownMenuBarView extends VLayout {
HLayout topBar = new HLayout();
topBar.setHeight(28);
topBar.setStyleName("topMenuBar");
-// url("./images/cssButton/button_stretch.png") repeat-x scroll 0 0 #DDDDDD
-// topBar.setBackgroundImage("[SKIN]/cssButton/button_stretch.png");
-// topBar.setBackgroundRepeat(BkgndRepeat.REPEAT_X);
-
+ // url("./images/cssButton/button_stretch.png") repeat-x scroll 0 0 #DDDDDD
+ // topBar.setBackgroundImage("[SKIN]/cssButton/button_stretch.png");
+ // topBar.setBackgroundRepeat(BkgndRepeat.REPEAT_X);
Img logo = new Img("header/rhq_logo_28px.png", 80, 28);
logo.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
@@ -74,36 +72,36 @@ public class DropDownMenuBarView extends VLayout {
}
});
-
topBar.addMember(logo);
-
// Create a menu bar
final MenuBar menu = new MenuBar();
menu.setHeight(28);
-
-
Menu subsystemsMenu = new Menu();
subsystemsMenu.setTitle("Subsystems");
- subsystemsMenu.addItem(new EMenuItem("Configuration Changes", LinkManager.getSubsystemConfigurationLink(), "subsystems/configure/Configure_16.png"));//, new LinkCommand("#config"));
- subsystemsMenu.addItem(new EMenuItem("Suspect Metrics", LinkManager.getSubsystemSuspectMetricsLink(), "subsystems/monitor/Monitor_failed_16.png"));//, new LinkCommand("#config"));
- subsystemsMenu.addItem(new EMenuItem("Operations", LinkManager.getSubsystemOperationHistoryLink(), "subsystems/control/Operation_16.png"));//, new LinkCommand("#config"));
- subsystemsMenu.addItem(new EMenuItem("Alerts", LinkManager.getSubsystemAlertHistoryLink(), "subsystems/alert/Alert_HIGH_16.png"));//, new LinkCommand("#config"));
- subsystemsMenu.addItem(new EMenuItem("Alert Definitions", LinkManager.getSubsystemAlertDefsLink(), "subsystems/alert/Alerts_16.png"));//, new LinkCommand("#config"));
-
+ subsystemsMenu.addItem(new EMenuItem("Configuration Changes", LinkManager.getSubsystemConfigurationLink(),
+ "subsystems/configure/Configure_16.png"));//, new LinkCommand("#config"));
+ subsystemsMenu.addItem(new EMenuItem("Suspect Metrics", LinkManager.getSubsystemSuspectMetricsLink(),
+ "subsystems/monitor/Monitor_failed_16.png"));//, new LinkCommand("#config"));
+ subsystemsMenu.addItem(new EMenuItem("Operations", LinkManager.getSubsystemOperationHistoryLink(),
+ "subsystems/control/Operation_16.png"));//, new LinkCommand("#config"));
+ subsystemsMenu.addItem(new EMenuItem("Alerts", LinkManager.getSubsystemAlertHistoryLink(),
+ "subsystems/alert/Alert_HIGH_16.png"));//, new LinkCommand("#config"));
+ subsystemsMenu.addItem(new EMenuItem("Alert Definitions", LinkManager.getSubsystemAlertDefsLink(),
+ "subsystems/alert/Alerts_16.png"));//, new LinkCommand("#config"));
final Menu overviewMenu = new Menu();
overviewMenu.setTitle("Overview");
overviewMenu.setStyleName("SimpleMenuBarButton");
overviewMenu.setBorder("none");
- com.smartgwt.client.widgets.menu.MenuItem subsystemsSubMenuItem = new com.smartgwt.client.widgets.menu.MenuItem("Subsystems");
+ com.smartgwt.client.widgets.menu.MenuItem subsystemsSubMenuItem = new com.smartgwt.client.widgets.menu.MenuItem(
+ "Subsystems");
subsystemsSubMenuItem.setSubmenu(subsystemsMenu);
overviewMenu.addItem(subsystemsSubMenuItem);
- overviewMenu.addItem(new EMenuItem("AutoDiscovery Queue",LinkManager.getAutodiscoveryQueueLink()));//,new LinkCommand("#cofng"));
- overviewMenu.addItem(new EMenuItem("Dashboard",LinkManager.getDashboardLink()));//,new LinkCommand("#cofng"));
-
+ overviewMenu.addItem(new EMenuItem("AutoDiscovery Queue", LinkManager.getAutodiscoveryQueueLink()));//,new LinkCommand("#cofng"));
+ overviewMenu.addItem(new EMenuItem("Dashboard", LinkManager.getDashboardLink()));//,new LinkCommand("#cofng"));
Menu resourcesMenu = new Menu();
resourcesMenu.setTitle("Resources");
@@ -111,7 +109,8 @@ public class DropDownMenuBarView extends VLayout {
resourcesMenu.setBorder("none");
resourcesMenu.setStyleName("menuBarMenuButton");
resourcesMenu.addItem(new EMenuItem("All Resources", LinkManager.getHubAllResourcesLink()));//, new LinkCommand("#fsdf"));
- resourcesMenu.addItem(new EMenuItem("Platforms", LinkManager.getHubPlatformsLink(),"types/Platform_up_16.png"));//, new LinkCommand("#fsdf"));
+ resourcesMenu
+ .addItem(new EMenuItem("Platforms", LinkManager.getHubPlatformsLink(), "types/Platform_up_16.png"));//, new LinkCommand("#fsdf"));
resourcesMenu.addItem(new EMenuItem("Servers", LinkManager.getHubServerssLink(), "types/Server_up_16.png"));//, new LinkCommand("#fsdf"));
resourcesMenu.addItem(new EMenuItem("Services", LinkManager.getHubServicesLink(), "types/Service_up_16.png"));//, new LinkCommand("#fsdf"));
resourcesMenu.addItem(new MenuItemSeparator());
@@ -136,52 +135,46 @@ public class DropDownMenuBarView extends VLayout {
groupsMenu.addItem(new EMenuItem("New Group", LinkManager.getHubNewGroupLink())); //, new LinkCommand("#sf"));
groupsMenu.addItem(new EMenuItem("New Group Definition", LinkManager.getHubNewGroupDefLink())); //, new LinkCommand("#sf"));
groupsMenu.addItem(new MenuItemSeparator());
-// groupsMenu.addItem(new MenuItem("Favorites")); //, new LinkCommand("#sf"));
-
+ // groupsMenu.addItem(new MenuItem("Favorites")); //, new LinkCommand("#sf"));
Menu securityMenu = new Menu();
securityMenu.setTitle("Security");
- securityMenu.addItem(new EMenuItem("Users",LinkManager.getAdminUsersLink()));
- securityMenu.addItem(new EMenuItem("Roles",LinkManager.getAdminRolesLink()));
+ securityMenu.addItem(new EMenuItem("Users", LinkManager.getAdminUsersLink()));
+ securityMenu.addItem(new EMenuItem("Roles", LinkManager.getAdminRolesLink()));
MenuItem securitySubMenuItem = new MenuItem("Security");
securitySubMenuItem.setSubmenu(securityMenu);
-
Menu sysConfigMenu = new Menu();
sysConfigMenu.setTitle("System Configuration");
- sysConfigMenu.addItem(new EMenuItem("Settings",LinkManager.getAdminSysConfigLink()));
- sysConfigMenu.addItem(new EMenuItem("Plugins",LinkManager.getAdminPluginsLink()));
- sysConfigMenu.addItem(new EMenuItem("Templates",LinkManager.getAdminTemplatesLink()));
+ sysConfigMenu.addItem(new EMenuItem("Settings", LinkManager.getAdminSysConfigLink()));
+ sysConfigMenu.addItem(new EMenuItem("Plugins", LinkManager.getAdminPluginsLink()));
+ sysConfigMenu.addItem(new EMenuItem("Templates", LinkManager.getAdminTemplatesLink()));
MenuItem sysConfigSubMenuItem = new MenuItem("System Configuration");
sysConfigSubMenuItem.setSubmenu(sysConfigMenu);
-
Menu contentMenu = new Menu();
contentMenu.setTitle("Content");
- contentMenu.addItem(new EMenuItem("Bundles","#Bundles"));
- contentMenu.addItem(new EMenuItem("Content Providers",LinkManager.getAdminContentProvidersLink()));
- contentMenu.addItem(new EMenuItem("Content Repositories",LinkManager.getAdminContentReposLink()));
+ contentMenu.addItem(new EMenuItem("Bundles", "#Bundles"));
+ contentMenu.addItem(new EMenuItem("Content Providers", LinkManager.getAdminContentProvidersLink()));
+ contentMenu.addItem(new EMenuItem("Content Repositories", LinkManager.getAdminContentReposLink()));
MenuItem contentSubMenuItem = new MenuItem("Content");
contentSubMenuItem.setSubmenu(contentMenu);
-
Menu haMenu = new Menu();
haMenu.setTitle("High Availability");
- haMenu.addItem(new EMenuItem("Servers",LinkManager.getHAServersLink()));
- haMenu.addItem(new EMenuItem("Agents",LinkManager.getHAAgentsLink()));
- haMenu.addItem(new EMenuItem("Affinity Groups",LinkManager.getHAAffinityGroupsLink()));
- haMenu.addItem(new EMenuItem("Partition Events",LinkManager.getHAEventsLink()));
+ haMenu.addItem(new EMenuItem("Servers", LinkManager.getHAServersLink()));
+ haMenu.addItem(new EMenuItem("Agents", LinkManager.getHAAgentsLink()));
+ haMenu.addItem(new EMenuItem("Affinity Groups", LinkManager.getHAAffinityGroupsLink()));
+ haMenu.addItem(new EMenuItem("Partition Events", LinkManager.getHAEventsLink()));
MenuItem haSubMentItem = new MenuItem("High Availability");
haSubMentItem.setSubmenu(haMenu);
-
Menu reportsMenu = new Menu();
reportsMenu.setTitle("Reports");
reportsMenu.addItem(new EMenuItem("Resource Version Inventory Report", LinkManager.getReportsInventoryLink()));
MenuItem reportsSubMenuItem = new MenuItem("Reports");
reportsSubMenuItem.setSubmenu(reportsMenu);
-
Menu adminMenu = new Menu();
adminMenu.setTitle("Administration");
adminMenu.addItem(securitySubMenuItem);
@@ -192,29 +185,22 @@ public class DropDownMenuBarView extends VLayout {
adminMenu.addItem(new EMenuItem("Downloads", LinkManager.getAdminDownloadsLink()));
adminMenu.addItem(new EMenuItem("License", LinkManager.getAdminLicenseLink()));
-
-
-
-
Menu helpMenu = new Menu();
helpMenu.setStyleName("menuBarMenuButton");
helpMenu.setTitle("Help");
helpMenu.addItem(new EMenuItem("Online Documentation", "http://www.rhq-project.org")); //, new LinkCommand("#sdfs"));
helpMenu.addItem(new EMenuItem("Open a support case", "http://www.rhq-project.org")); //, new LinkCommand("#sdfs"));
-// helpMenu.addItem(new MenuItem("About")); //, new LinkCommand("#sdfs"));
+ // helpMenu.addItem(new MenuItem("About")); //, new LinkCommand("#sdfs"));
menu.setMenus(overviewMenu, resourcesMenu, groupsMenu, adminMenu, helpMenu);
-
topBar.addMember(menu);
-
addMember(topBar);
- addMember(new SearchBarPane());
+ addMember(new SearchBarPane(this.extendLocatorId("Search")));
}
-
public static class EMenuItem extends com.smartgwt.client.widgets.menu.MenuItem {
String link;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index dc5503f..cd1b7d9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -25,16 +25,16 @@ import com.google.gwt.user.client.ui.Hyperlink;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
-import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.enterprise.gui.coregui.client.components.AboutModalWindow;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
*/
-public class MenuBarView extends VLayout {
+public class MenuBarView extends LocatableVLayout {
private AboutModalWindow aboutModalWindow;
@@ -44,6 +44,10 @@ public class MenuBarView extends VLayout {
private HTMLFlow linksPane;
+ public MenuBarView(String locatorId) {
+ super(locatorId);
+ }
+
protected void onDraw() {
super.onDraw();
@@ -119,7 +123,7 @@ public class MenuBarView extends VLayout {
topStrip.addMember(links);
*/
addMember(topStrip);
- addMember(new SearchBarPane());
+ addMember(new SearchBarPane(this.extendLocatorId("Search")));
markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
index 523dc41..81abe79 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
@@ -18,12 +18,15 @@
*/
package org.rhq.enterprise.gui.coregui.client.menu;
-import com.google.gwt.core.client.GWT;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+
import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.ui.TextBox;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.types.FormLayoutType;
-import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.TextMatchStyle;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -36,35 +39,22 @@ import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuButton;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.MenuItemSeparator;
-
-import java.util.LinkedHashMap;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
-
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
* @author Greg Hinkle
*/
-public class SearchBarPane extends HLayout {
+public class SearchBarPane extends LocatableHLayout {
+
+ public SearchBarPane(String locatorId) {
+ super(locatorId);
- public SearchBarPane() {
- super();
setWidth100();
setHeight(28);
}
@@ -73,7 +63,7 @@ public class SearchBarPane extends HLayout {
protected void onDraw() {
super.onDraw();
- final DynamicForm form = new DynamicForm();
+ final DynamicForm form = new LocatableDynamicForm(this.getLocatorId());
form.setNumCols(6);
form.setColWidths("120", "140", "400");
@@ -103,7 +93,6 @@ public class SearchBarPane extends HLayout {
addMember(form);
}
-
private ComboBoxItem getResourceComboBox() {
final ComboBoxItem comboBox = new ComboBoxItem("query", "Query");
@@ -122,7 +111,8 @@ public class SearchBarPane extends HLayout {
ListGridField availabilityField = new ListGridField(AVAILABILITY.propertyName(), AVAILABILITY.title(), 55);
availabilityField.setAlign(Alignment.CENTER);
- comboBox.setPickListFields(nameField, descriptionField, typeNameField, pluginNameField, categoryField, availabilityField);
+ comboBox.setPickListFields(nameField, descriptionField, typeNameField, pluginNameField, categoryField,
+ availabilityField);
comboBox.setValueField("id");
comboBox.setDisplayField("name");
@@ -150,19 +140,16 @@ public class SearchBarPane extends HLayout {
return comboBox;
}
-
private ComboBoxItem getGroupComboBox() {
ComboBoxItem comboBox = new ComboBoxItem("query", "Query");
comboBox.setWidth(400);
comboBox.setShowTitle(false);
-
comboBox.setOptionDataSource(new ResourceGroupsDataSource());
ListGridField nameField = new ListGridField("name");
ListGridField descriptionField = new ListGridField("description");
comboBox.setPickListFields(nameField, descriptionField);
-
comboBox.setValueField("id");
comboBox.setDisplayField("name");
comboBox.setPickListWidth(600);
commit 10e628a4d743cb0cfaa9bbd9c156c3e996570acf
Merge: af0ed91... 8acb1fb...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 15 09:20:13 2010 -0400
Merge branch 'master' into master-jay
commit af0ed9107e4e39ffd14ce345a166ccb466e690a7
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 15 09:16:50 2010 -0400
Added selenium hooks to MessageCenter
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index 39364d8..7b6d850 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -46,7 +46,8 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* @author Greg Hinkle
@@ -66,7 +67,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
super.onDraw();
CoreGUI.getMessageCenter().addMessageListener(this);
- final Menu recentEventsMenu = new Menu();
+ final Menu recentEventsMenu = new LocatableMenu(this.extendLocatorId("Messages"));
IMenuButton recentEventsButton = new LocatableIMenuButton(extendLocatorId("RecentEvents"), "Messages",
recentEventsMenu);
@@ -99,7 +100,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
}
});
- VLayout vl = new LocatableVLayout(extendLocatorId("Alignment"));
+ VLayout vl = new VLayout();
vl.setAutoWidth();
vl.setAlign(Alignment.LEFT);
vl.setAlign(VerticalAlignment.CENTER);
@@ -136,7 +137,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
form.setItems(title, severity, date, detail, okButton);
- final Window window = new Window();
+ final Window window = new LocatableWindow(this.extendLocatorId("Message"));
window.setTitle(message.title);
window.setWidth(600);
window.setHeight(400);
commit 354316f55b57cef67a424b58acfb475ff95ea27f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 15 09:16:30 2010 -0400
Added support for enabling or disabling our selenium locatorIds via
the coreGui url. We now look for url param:
enableLocators=true|false
If true we enable the use of our explicit locatorIds to be used as
selenium hooks. If false, or omitted, we run with default Ids and will
not be selenium-ready.
To support this from the maven command line and our eclipse external tools
config you can now specify the 'coreGuiParams' property. I've added a new
eclipse ext tools config called 'Run GWT DevMode-JPDA-Params' that
specifies -D$coreGuiParams=?enableLocators=true.
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA-Params.launch b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA-Params.launch
new file mode 100644
index 0000000..9791adc
--- /dev/null
+++ b/etc/eclipse-tools/maven/RHQ Maven Build - Run GWT DevMode-JPDA-Params.launch
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+<stringAttribute key="bad_container_name" value="\rhq\etc\eclipse-tools\maven"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true gwt:debug -DcoreGuiParams=?enableLocators=true"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/enterprise/gui/coregui}"/>
+</launchConfiguration>
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 2d92aba..fd24857 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -235,7 +235,7 @@
<inplace>false</inplace>
<!-- <logLevel>INFO' -bindAddress 0.0.0.0 -logLevel 'INFO</logLevel> -->
<logLevel>INFO</logLevel>
- <runTarget>http://localhost:7080/coregui/CoreGUI.html</runTarget>
+ <runTarget>http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}</runTarget>
<extraJvmArgs>${gwt-plugin.extraJvmArgs}</extraJvmArgs>
<localWorkers>${gwt-plugin.localWorkers}</localWorkers>
<draftCompile>true</draftCompile>
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 77cc196..34d1621 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
@@ -31,6 +31,7 @@ import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.core.KeyIdentifier;
@@ -60,6 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
@@ -103,11 +105,17 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static ProductInfo productInfo;
public void onModuleLoad() {
- if (GWT.getHostPageBaseURL().indexOf("/coregui/") == -1) {
+ String hostPageBaseURL = GWT.getHostPageBaseURL();
+ if (hostPageBaseURL.indexOf("/coregui/") == -1) {
System.out.println("Suppressing load of CoreGUI module");
return; // suppress loading this module if not using the new GWT app
}
+ String enableLocators = Location.getParameter("enableLocators");
+ if ((null != enableLocators) && Boolean.parseBoolean(enableLocators)) {
+ SeleniumUtility.setUseDefaultIds(false);
+ }
+
coreGUI = this;
if (!GWT.isScript()) {
@@ -358,7 +366,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
String currentViewPath = History.getToken();
if (currentViewPath.equals(viewPath)) {
// We're already there - just refresh the view.
- refresh();
+ refresh();
} else {
if (viewPath.matches("(Resource|ResourceGroup)/[^/]*")) {
// e.g. "Resource/10001"
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
index e4b60bc..223d0d6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
@@ -17,11 +17,15 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
*/
public class SeleniumUtility {
- private static final boolean USE_DEFAULT_IDS = true;
-
/** A default id that is not ecommended as it will clash with any other element set to the default */
public static final String DEFAULT_ID = "DefaultID";
+ /**
+ * When true ignore any explicit locatorId assignment and use the standard
+ * ids generated by smartgwt.
+ */
+ private static boolean useDefaultIds = true;
+
/**
* A utility for assigning an ID to a smartgwt widget. Any current ID will be overwritten. The algorithm is:
* <pre>
@@ -30,7 +34,7 @@ public class SeleniumUtility {
* @return the updated widget
*/
static public <T extends BaseWidget> T setID(final T widget, String locatorId) {
- if (USE_DEFAULT_IDS) {
+ if (useDefaultIds) {
return widget;
}
@@ -84,7 +88,7 @@ public class SeleniumUtility {
* @return the updated uiObject
*/
static public <T extends UIObject> T setHtmlId(final T uiObject, String unsafeId) {
- if (USE_DEFAULT_IDS) {
+ if (useDefaultIds) {
return uiObject;
}
@@ -143,7 +147,7 @@ public class SeleniumUtility {
}
static public boolean isUseDefaultIds() {
- return USE_DEFAULT_IDS;
+ return useDefaultIds;
}
/**
@@ -157,4 +161,13 @@ public class SeleniumUtility {
currentMember.destroy();
}
}
+
+ public static boolean getUseDefaultIds() {
+ return SeleniumUtility.useDefaultIds;
+ }
+
+ public static void setUseDefaultIds(boolean useDefaultIds) {
+ SeleniumUtility.useDefaultIds = useDefaultIds;
+ }
+
}
13 years, 9 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit 8acb1fb31579eeeaf3283af315183383eae53f01
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 15 08:05:25 2010 -0400
use locatable window to facilitate selenium testing
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 7b85eae..6a3c6f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -43,6 +43,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* @author John Mazzitelli
@@ -92,7 +93,8 @@ public class ConditionsEditor extends LocatableVLayout {
table.addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() {
@Override
public void executeAction(ListGridRecord[] selection) {
- final Window winModal = new Window();
+ final Window winModal = new LocatableWindow(ConditionsEditor.this
+ .extendLocatorId("newConditionEditorWindow"));
winModal.setTitle("Add Condition");
winModal.setOverflow(Overflow.VISIBLE);
winModal.setShowMinimizeButton(false);
13 years, 9 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 6efe82d30d878ec3eb3e9eb6947adbe7b0cfd932
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 15 07:58:48 2010 -0400
opps... don't use bit op, need AND logical op
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index bd20b0a..fceb893 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -88,7 +88,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
this.okFunction = okFunc;
this.resourceType = rtype;
- this.supportsEvents = (rtype.getEventDefinitions() != null & rtype.getEventDefinitions().size() > 0);
+ this.supportsEvents = (rtype.getEventDefinitions() != null && rtype.getEventDefinitions().size() > 0);
Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions();
if (metricDefinitions != null && metricDefinitions.size() > 0) {
13 years, 9 months
[rhq] 2 commits - modules/enterprise modules/plugins
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java | 2
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java | 36 ++++++----
3 files changed, 25 insertions(+), 15 deletions(-)
New commits:
commit 0807155b735ae33c21b69df4758d7f031d4a28a0
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 14 20:11:07 2010 -0400
fix potential cast exception when sp[ecified metric collection interval is larger than Integer.MAX
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java
index 9b68f39..c00175a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java
@@ -87,7 +87,7 @@ public abstract class AbstractMeasurementScheduleListView extends Table {
return "";
}
- long milliseconds = (Integer) value;
+ long milliseconds = ((Number) value).longValue();
if (milliseconds == 0) {
return "0";
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
index 78fe1d3..bef5806 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
@@ -37,7 +37,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
/**
- * Widget for updating the collection intervals on the selected metrics. It displays two form fields for
+ * Widget for updating the collection intervals for the selected metrics. It displays two form fields for
* entering the interval and the interval's units (seconds, minutes, or hours), as well as a Set button
* for submitting the update.
*
commit 2a60df38568690f9b2b6a555e212c3a6934ea011
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 14 20:08:22 2010 -0400
add support for lofs and tmpfs filesystems on Solaris (https://bugzilla.redhat.com/show_bug.cgi?id=553034)
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java
index b7960c2..a12d556 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.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,7 +22,7 @@
*/
package org.rhq.plugins.platform;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -38,14 +38,16 @@ import org.rhq.core.system.SystemInfo;
/**
* @author Greg Hinkle
+ * @author Ian Springer
*/
+@SuppressWarnings({"UnusedDeclaration"})
public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent<PlatformComponent> {
private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PlatformComponent> discoveryContext)
throws Exception {
- Set<DiscoveredResourceDetails> results = new HashSet<DiscoveredResourceDetails>();
+ Set<DiscoveredResourceDetails> results = new LinkedHashSet<DiscoveredResourceDetails>();
SystemInfo sysInfo = discoveryContext.getSystemInformation();
if (!sysInfo.isNative()) {
@@ -54,22 +56,30 @@ public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent<
return results;
}
- String hostname = discoveryContext.getSystemInformation().getHostname();
-
- for (FileSystemInfo fs : sysInfo.getFileSystems()) {
- int fsType = fs.getFileSystem().getType();
- if (fsType != FileSystem.TYPE_LOCAL_DISK && fsType != FileSystem.TYPE_NETWORK) {
- continue;
+ for (FileSystemInfo fsInfo : sysInfo.getFileSystems()) {
+ FileSystem fs = fsInfo.getFileSystem();
+ int fsType = fs.getType();
+ // We only support local, network (nfs), lofs, or tmpfs filesystems - skip any other types.
+ switch (fsType) {
+ case FileSystem.TYPE_LOCAL_DISK:
+ case FileSystem.TYPE_NETWORK:
+ break;
+ default:
+ if (!(fs.getDevName().equals("lofs") ||
+ fs.getDevName().equals("tmpfs"))) {
+ continue;
+ }
}
+
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
try {
- String key = fs.getMountPoint();
+ String key = fsInfo.getMountPoint();
DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
- key, key, null, fs.getFileSystem().getDevName() + ": "
- + fs.getFileSystem().getDirName(), pluginConfig, null);
+ key, key, null, fsInfo.getFileSystem().getDevName() + ": "
+ + fsInfo.getFileSystem().getDirName(), pluginConfig, null);
results.add(details);
} catch (Exception e) {
- log.error("File system discovery failed: " + e + ", skipping.");
+ log.error("File system discovery failed for [" + fsInfo + "]: " + e);
}
}
return results;
13 years, 9 months
[rhq] 6 commits - modules/core
by Joseph Marques
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java | 12 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java | 56 +++---
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java | 54 ++----
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java | 16 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java | 10 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java | 9 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java | 14 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java | 13 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java | 48 ++---
modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java | 10 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java | 9 -
modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java | 1
modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java | 51 ++----
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java | 52 +++---
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java | 74 ++++----
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java | 58 +++---
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java | 59 +++----
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java | 53 ++----
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java | 7
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java | 1
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java | 23 +-
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java | 11 -
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java | 10 -
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java | 12 -
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java | 83 ----------
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java | 12 +
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java | 7
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java | 22 +-
modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java | 18 --
modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java | 21 +-
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java | 11 -
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java | 20 +-
modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java | 7
71 files changed, 399 insertions(+), 597 deletions(-)
New commits:
commit 497f3d6b13ef46643d68a09bcd46adac121e1b3f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 13:06:17 2010 -0400
remove unused private inner class
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
index 1925c37..583fe36 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
@@ -57,14 +57,8 @@ public class ResourceGroupComposite implements Serializable {
@XmlTransient
private ResourcePermission resourcePermission;
- private class GroupDefinitionMember extends ResourceGroup {
- public void setGroupCategory(GroupCategory category) {
- super.setGroupCategory(category);
- }
- }
-
//def no args constructor for JAXB
- private ResourceGroupComposite() {
+ public ResourceGroupComposite() {
}
public ResourceGroupComposite(Long explicitCount, Double explicitAvailability, Long implicitCount,
commit ad54a80ad2a1737a960111f226f97f92b984c561
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 13:05:59 2010 -0400
add serialVersionUID to all objects in core/domain missing it
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java
index 7e2c87d..b3ac785 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/group/AbstractGroupConfigurationUpdate.java
@@ -45,6 +45,9 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONFIG_GROUP_UPDATE_ID_SEQ")
@Table(name = "RHQ_CONFIG_GROUP_UPDATE")
public abstract class AbstractGroupConfigurationUpdate extends AbstractConfigurationUpdate implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
@GeneratedValue(generator = "SEQ", strategy = GenerationType.AUTO)
@Id
private int id;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java
index 2165b34..5b4aca1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java
@@ -35,6 +35,8 @@ import org.rhq.core.domain.content.PackageDetailsKey;
*/
public class ResourcePackageDetails extends PackageDetails {
+ private static final long serialVersionUID = 1L;
+
/**
* Values the plugin should use when installing this package.
*/
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java
index 0ff464a..6ef2ce6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TaggedCriteria.java
@@ -27,23 +27,27 @@ import org.rhq.core.domain.tagging.Tag;
/**
* @author Greg Hinkle
*/
+@SuppressWarnings("unused")
public abstract class TaggedCriteria extends Criteria {
+ private static final long serialVersionUID = 1L;
+
private Tag filterTag;
private boolean fetchTags;
-
protected TaggedCriteria() {
String entityName = getPersistentClass().getName();
- entityName = entityName.substring(entityName.lastIndexOf(".")+1);
-
- filterOverrides.put("tag", "id IN (SELECT taggedEntity.id FROM " + entityName + " taggedEntity JOIN taggedEntity.tags tag \n " +
- " WHERE \n" +
- " (tag.namespace LIKE :tagNamespace OR :tagNamespace IS NULL ) AND \n" + // first '?' will get ordinal 1
- " (tag.semantic LIKE :tagSemantic OR :tagSemantic IS NULL ) AND \n" + // second '?' will get ordinal 2
- " (tag.name LIKE :tagName OR :tagName IS NULL ) )"); // third '?' will get ordinal 3
+ entityName = entityName.substring(entityName.lastIndexOf(".") + 1);
+
+ filterOverrides.put("tag", "" //
+ + "id IN ( SELECT taggedEntity.id \n" //
+ + " FROM " + entityName + " taggedEntity \n" //
+ + " JOIN taggedEntity.tags tag \n " //
+ + " WHERE (tag.namespace LIKE :tagNamespace OR :tagNamespace IS NULL ) \n" // first '?' will get ordinal 1
+ + " AND (tag.semantic LIKE :tagSemantic OR :tagSemantic IS NULL ) \n" // second '?' will get ordinal 2
+ + " AND (tag.name LIKE :tagName OR :tagName IS NULL ) )"); // third '?' will get ordinal 3
}
public void addFilterTagNamespace(String filterTagNamespace) {
@@ -71,12 +75,10 @@ public abstract class TaggedCriteria extends Criteria {
this.filterTag = tag;
}
-
public boolean isTagFiltered() {
return this.filterTag != null;
}
-
public void fetchTags(boolean fetchTags) {
this.fetchTags = fetchTags;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java b/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java
index 6e99c4b..95e920d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/Dashboard.java
@@ -24,7 +24,6 @@ package org.rhq.core.domain.dashboard;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -64,6 +63,8 @@ import org.rhq.core.domain.configuration.PropertySimple;
@XmlRootElement
public class Dashboard implements Serializable {
+ private static final long serialVersionUID = 1L;
+
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "RHQ_DASHBOARD_ID_SEQ")
@Id
@@ -72,36 +73,27 @@ public class Dashboard implements Serializable {
@Column(name = "NAME", nullable = false)
private String name;
-
@Column(name = "SHARED", nullable = false)
private boolean shared = false;
-
@JoinColumn(name = "CONFIGURATION_ID", referencedColumnName = "ID")
@OneToOne(cascade = { CascadeType.ALL })
private Configuration configuration = new Configuration();
-
-
@JoinColumn(name = "SUBJECT_ID", nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
private Subject owner;
-
@OneToMany(mappedBy = "dashboard", fetch = FetchType.EAGER)
- @Cascade( { org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
+ @Cascade({ org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE,
+ org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
private Set<DashboardPortlet> portlets = new HashSet<DashboardPortlet>();
-
-
-
public static final String CFG_COLUMNS = "columns";
public static final String CFG_WIDTHS = "widths";
public static final String CFG_BACKGROUND = "background";
public static final String CFG_REFRESH_RATE = "refresh";
-
-
public int getId() {
return id;
}
@@ -180,8 +172,6 @@ public class Dashboard implements Serializable {
return columnPortlets;
}
-
-
public boolean removePortlet(DashboardPortlet storedPortlet) {
return portlets.remove(storedPortlet);
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java b/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java
index 38b455a..5562dbe 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/dashboard/DashboardPortlet.java
@@ -51,6 +51,7 @@ import org.rhq.core.domain.configuration.Configuration;
@XmlRootElement
public class DashboardPortlet implements Serializable {
+ private static final long serialVersionUID = 1L;
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "RHQ_DASHBOARD_PORTLET_ID_SEQ")
@@ -80,7 +81,6 @@ public class DashboardPortlet implements Serializable {
@JoinColumn(name = "DASHBOARD_ID", nullable = false)
private Dashboard dashboard;
-
public DashboardPortlet() {
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java
index 9552e31..e18df58 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationLastCompletedComposite.java
@@ -25,6 +25,9 @@ package org.rhq.core.domain.operation.composite;
import org.rhq.core.domain.operation.OperationRequestStatus;
public class GroupOperationLastCompletedComposite extends OperationLastCompletedComposite {
+
+ private static final long serialVersionUID = 1L;
+
private final int groupId;
private final String groupName;
private final String groupResourceTypeName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java
index ee0f103..b5fba55 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java
@@ -30,6 +30,9 @@ import org.rhq.core.domain.operation.ScheduleJobId;
* @author John Mazzitelli
*/
public class GroupOperationScheduleComposite extends OperationScheduleComposite {
+
+ private static final long serialVersionUID = 1L;
+
private final int groupId;
private final String groupName;
private final String groupResourceTypeName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
index 5add81b..0b8bfbd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
@@ -25,6 +25,9 @@ package org.rhq.core.domain.operation.composite;
import org.rhq.core.domain.operation.OperationRequestStatus;
public class ResourceOperationLastCompletedComposite extends OperationLastCompletedComposite {
+
+ private static final long serialVersionUID = 1L;
+
private int resourceId;
private String resourceName;
private String resourceTypeName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
index 4185035..a0996a7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
@@ -25,6 +25,9 @@ package org.rhq.core.domain.operation.composite;
import org.rhq.core.domain.operation.ScheduleJobId;
public class ResourceOperationScheduleComposite extends OperationScheduleComposite {
+
+ private static final long serialVersionUID = 1L;
+
private int resourceId;
private String resourceName;
private String resourceTypeName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java
index 0d568d4..1e2af92 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/CreateResourceHistory.java
@@ -68,7 +68,9 @@ import org.rhq.core.domain.content.InstalledPackage;
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CREATE_RES_HIST_ID_SEQ")
@Table(name = "RHQ_CREATE_RES_HIST")
public class CreateResourceHistory implements Serializable {
+
// Constants --------------------------------------------
+ private static final long serialVersionUID = 1L;
public static final String QUERY_FIND_WITH_STATUS = "CreateResourceHistory.findWithStatus";
public static final String QUERY_FIND_BY_PARENT_RESOURCE_ID = "CreateResourceHistory.findByParentResourceId";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java
index decafe2..375c79d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/InventorySummary.java
@@ -30,6 +30,9 @@ import java.io.Serializable;
* @author Ian Springer
*/
public class InventorySummary implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
private int platformCount;
private int serverCount;
private int serviceCount;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java
index b31fb5b..2770b70 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceAvailabilitySummary.java
@@ -30,6 +30,8 @@ import org.rhq.core.domain.measurement.AvailabilityType;
*/
public class ResourceAvailabilitySummary implements Serializable {
+ private static final long serialVersionUID = 1L;
+
long upTime;
long downTime;
int failures;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java
index bf2c7ca..c3fef6c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceIdFlyWeight.java
@@ -26,6 +26,8 @@ import org.rhq.core.domain.resource.Resource;
public class ResourceIdFlyWeight extends Resource {
+ private static final long serialVersionUID = 1L;
+
public ResourceIdFlyWeight(int id, String uuid) {
super(id);
setUuid(uuid);
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java
index 5878192..5c0f0e7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceInstallCount.java
@@ -18,15 +18,17 @@
*/
package org.rhq.core.domain.resource.composite;
-import org.rhq.core.domain.resource.ResourceCategory;
-
import java.io.Serializable;
+import org.rhq.core.domain.resource.ResourceCategory;
+
/**
* @author Greg Hinkle
*/
public class ResourceInstallCount implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private long count;
private String typeName;
private String typePlugin;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java
index f57608d..5b7a9a6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ClusterKey.java
@@ -22,7 +22,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-
/**
* A ClusterKey represents an AutoCluster of resources in a Cluster Hierarchy. Given the key it is
* possible to determine specific membership of the AutoCluster at any time. It represents the Cluster
@@ -47,7 +46,6 @@ public class ClusterKey implements Serializable {
private static final long serialVersionUID = 1L;
-
static final String DELIM = ":";
static final String DELIM_NODE = "::";
@@ -57,7 +55,6 @@ public class ClusterKey implements Serializable {
private String key = null;
private String namedKey = null;
-
public ClusterKey() {
}
@@ -80,12 +77,10 @@ public class ClusterKey implements Serializable {
this.clusterGroupId = parentKey.getClusterGroupId();
this.hierarchy = new ArrayList<ClusterKey.Node>(rootClusterNodes); //.size() + 1);
-// Collections.copy(this.hierarchy, rootClusterNodes);
+ // Collections.copy(this.hierarchy, rootClusterNodes);
this.hierarchy.add(new ClusterKey.Node(childResourceTypeId, childResourceKey));
}
-
-
public int getClusterGroupId() {
return clusterGroupId;
}
@@ -146,7 +141,6 @@ public class ClusterKey implements Serializable {
return getKey();
}
-
public static ClusterKey valueOf(String clusterKey) {
ClusterKey result = null;
@@ -182,15 +176,17 @@ public class ClusterKey implements Serializable {
return nodes.get(nodes.size() - 1).getResourceTypeId();
}
-
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ClusterKey)) return false;
+ if (this == o)
+ return true;
+ if (!(o instanceof ClusterKey))
+ return false;
ClusterKey that = (ClusterKey) o;
- if (!getKey().equals(that.getKey())) return false;
+ if (!getKey().equals(that.getKey()))
+ return false;
return true;
}
@@ -237,8 +233,9 @@ public class ClusterKey implements Serializable {
}
private String encode(String info) {
- return info.replace(":","%3a");
+ return info.replace(":", "%3a");
}
+
private String decode(String code) {
return code.replace("%3a", ":");
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java
index a156804..5e2e207 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterFlyweight.java
@@ -25,13 +25,13 @@ package org.rhq.core.domain.resource.group.composite;
import java.io.Serializable;
import java.util.List;
-import org.rhq.core.domain.resource.group.ClusterKey;
-
/**
* @author Greg Hinkle
*/
public class ClusterFlyweight implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private int groupId;
private ClusterKeyFlyweight clusterKey;
@@ -89,11 +89,4 @@ public class ClusterFlyweight implements Serializable {
return children;
}
-
-
-
-
-
-
-
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java
index e546614..7ed08db 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ClusterKeyFlyweight.java
@@ -29,6 +29,8 @@ import java.io.Serializable;
*/
public class ClusterKeyFlyweight implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private int resourceTypeId;
private String resourceKey;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java
index 1804daa..57084e2 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java
@@ -29,17 +29,25 @@ import org.rhq.core.domain.tagging.Tag;
*/
public class TagReportComposite extends Tag {
+ private static final long serialVersionUID = 1L;
+
private Tag tag;
- private long total, resourceCount, resourceGroupCount, bundleCount, bundleVersionCount, bundleDeploymentCount, bundleDestinationCount;
+ private long total;
+ private long resourceCount;
+ private long resourceGroupCount;
+ private long bundleCount;
+ private long bundleVersionCount;
+ private long bundleDeploymentCount;
+ private long bundleDestinationCount;
public TagReportComposite() {
}
- public TagReportComposite(int id, String namespace, String semantic, String name,
- long total,
- long resourceCount, long resourceGroupCount, long bundleCount, long bundleVersionCount, long bundleDeploymentCount, long bundleDestinationCount) {
- tag = new Tag(namespace, semantic, name);
- tag.setId(id);
+ public TagReportComposite(int id, String namespace, String semantic, String name, long total, long resourceCount,
+ long resourceGroupCount, long bundleCount, long bundleVersionCount, long bundleDeploymentCount,
+ long bundleDestinationCount) {
+ this.tag = new Tag(namespace, semantic, name);
+ this.tag.setId(id);
this.total = total;
this.resourceCount = resourceCount;
this.resourceGroupCount = resourceGroupCount;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java
index cd6874f..b26aead 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java
@@ -7,6 +7,9 @@ package org.rhq.core.domain.util;
* @author Ian Springer
*/
public class UnlimitedPageControl extends PageControl {
+
+ private static final long serialVersionUID = 1L;
+
public UnlimitedPageControl() {
this(new OrderingField[0]);
}
@@ -22,7 +25,8 @@ public class UnlimitedPageControl extends PageControl {
@Override
public void setPageSize(int pageSize) {
- throw new UnsupportedOperationException("page size cannot be changed from " + SIZE_UNLIMITED + " for an UnlimitedPageControl.");
+ throw new UnsupportedOperationException("page size cannot be changed from " + SIZE_UNLIMITED
+ + " for an UnlimitedPageControl.");
}
@Override
@@ -30,5 +34,4 @@ public class UnlimitedPageControl extends PageControl {
getOrderingFields().clear();
}
-
}
commit 583812edd609d72048b452ef01df9bf1de65e20e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 13:00:21 2010 -0400
remove unused deprecated methods
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java
index 03dd41b..3237c49 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java
@@ -49,7 +49,11 @@ public class RoleCriteria extends Criteria {
private PageOrdering sortName;
public RoleCriteria() {
- filterOverrides.put("subjectId", "id in (select sr.id from Role sr JOIN sr.subjects s where s.id = :id)");
+ filterOverrides.put("subjectId", "" //
+ + "id IN ( SELECT innerRole.id " //
+ + " FROM Role innerRole " //
+ + " JOIN innerRole.subjects innerSubject " //
+ + " WHERE innerSubject.id = ? )");
}
@Override
@@ -106,81 +110,4 @@ public class RoleCriteria extends Criteria {
public boolean isSecurityManagerRequired() {
return (this.fetchSubjects || this.fetchResourceGroups);
}
-
- /**
- * @Deprecated use addFilterId
- */
- @Deprecated
- public void setFilterId(Integer filterId) {
- this.filterId = filterId;
- }
-
- /**
- * @Deprecated use addFilterName
- */
- @Deprecated
- public void setFilterName(String filterName) {
- this.filterName = filterName;
- }
-
- /**
- * @Deprecated use addFilterDescription
- */
- @Deprecated
- public void setFilterDescription(String filterDescription) {
- this.filterDescription = filterDescription;
- }
-
- @Deprecated
- public Integer getFilterId() {
- return this.filterId;
- }
-
- @Deprecated
- public boolean getFetchSubjects() {
- return this.fetchSubjects;
- }
-
- /**
- * Requires MANAGE_SECURITY
- * @param fetchSubjects
- * @Deprecated use fetchSubjects
- */
- @Deprecated
- public void setFetchSubjects(boolean fetchSubjects) {
- this.fetchSubjects = fetchSubjects;
- }
-
- /**
- * @Deprecated use fetchResourceGroups
- */
- @Deprecated
- public void setFetchResourceGroups(boolean fetchResourceGroups) {
- this.fetchResourceGroups = fetchResourceGroups;
- }
-
- /**
- * @Deprecated use fetchPermissions
- */
- @Deprecated
- public void setFetchPermissions(boolean fetchPermissions) {
- this.fetchPermissions = fetchPermissions;
- }
-
- /**
- * @Deprecated use fetchRoleNotifications
- */
- @Deprecated
- public void setFetchRoleNotifications(boolean fetchRoleNotifications) {
- this.fetchRoleNotifications = fetchRoleNotifications;
- }
-
- /**
- * @Deprecated use addSortName
- */
- @Deprecated
- public void setSortName(PageOrdering sortName) {
- addSortField("name");
- this.sortName = sortName;
- }
}
commit 1f6af685b55276fb7568abd334300de9b15ada32
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 12:59:52 2010 -0400
add the ability to filter SubjectCriteria by roleId
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
index e6e1780..4e9418c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
@@ -45,6 +45,7 @@ public class SubjectCriteria extends Criteria {
private String filterPhoneNumber;
private String filterDepartment;
private Boolean filterFactive;
+ private Integer filterRoleId;
private boolean fetchConfiguration;
private boolean fetchRoles;
@@ -58,6 +59,11 @@ public class SubjectCriteria extends Criteria {
private PageOrdering sortDepartment;
public SubjectCriteria() {
+ filterOverrides.put("roleId", "" //
+ + "id IN ( SELECT innerSubject.id " //
+ + " FROM Subject innerSubject " //
+ + " JOIN innerSubject.roles innerRole " //
+ + " WHERE innerRole.id = ? )");
}
@Override
@@ -101,6 +107,10 @@ public class SubjectCriteria extends Criteria {
this.filterFactive = filterFactive;
}
+ public void addFilterRoleId(Integer filterRoleId) {
+ this.filterRoleId = filterRoleId;
+ }
+
public void fetchConfiguration(boolean fetchConfiguration) {
this.fetchConfiguration = fetchConfiguration;
}
commit e92400fbdfb51149eb3444580c80d3113a13a0f6
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 12:59:35 2010 -0400
get use of generics for getPersisttentClass method on Criteria classes
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 a605adf..9470937 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
@@ -29,8 +29,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.Alert;
+import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -100,7 +100,7 @@ public class AlertCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<Alert> getPersistentClass() {
return Alert.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index 298a6e5..5c84c62 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -71,7 +71,7 @@ public class AlertDefinitionCriteria extends Criteria {
}
@Override
- public Class<?> getPersistentClass() {
+ public Class<AlertDefinition> getPersistentClass() {
return AlertDefinition.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java
index e52333f..35c9367 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleCriteria.java
@@ -71,7 +71,7 @@ public class BundleCriteria extends TaggedCriteria {
}
@Override
- public Class<?> getPersistentClass() {
+ public Class<Bundle> getPersistentClass() {
return Bundle.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
index 66d85c2..9e613c6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
@@ -60,7 +60,7 @@ public class BundleDeploymentCriteria extends TaggedCriteria {
}
@Override
- public Class<?> getPersistentClass() {
+ public Class<BundleDeployment> getPersistentClass() {
return BundleDeployment.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java
index 62a42f8..dcd99d8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDestinationCriteria.java
@@ -23,7 +23,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleDestination;
@@ -45,22 +44,19 @@ public class BundleDestinationCriteria extends TaggedCriteria {
private String filterDeployDir;
private Integer filterGroupId; // needs override
-
private boolean fetchBundle;
private boolean fetchDeployments;
private boolean fetchGroup;
public BundleDestinationCriteria() {
-
filterOverrides.put("bundleId", "bundle.id = ?");
filterOverrides.put("bundleVersionId", "deployments.bundleVersion.id = ?");
filterOverrides.put("status", "deployment.status like ?");
filterOverrides.put("groupId", "group.id = ?");
-
}
@Override
- public Class<?> getPersistentClass() {
+ public Class<BundleDestination> getPersistentClass() {
return BundleDestination.class;
}
@@ -84,12 +80,10 @@ public class BundleDestinationCriteria extends TaggedCriteria {
this.filterDescription = filterDescription;
}
-
public void addFilterBundleVersionId(Integer filterBundleVersionId) {
this.filterBundleVersionId = filterBundleVersionId;
}
-
public void addFilterGroupId(Integer filterGroupId) {
this.filterGroupId = filterGroupId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java
index 130b2b6..26f2b3e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleFileCriteria.java
@@ -42,8 +42,6 @@ public class BundleFileCriteria extends Criteria {
private boolean fetchPackageVersion;
public BundleFileCriteria() {
- super();
-
filterOverrides.put("bundleVersionId", "bundleVersion.id = ?");
filterOverrides.put("packageVersionId", "packageVersion.id = ?");
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
index 4e38e46..98f77c1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleResourceDeploymentCriteria.java
@@ -53,7 +53,7 @@ public class BundleResourceDeploymentCriteria extends Criteria {
}
@Override
- public Class<?> getPersistentClass() {
+ public Class<BundleResourceDeployment> getPersistentClass() {
return BundleResourceDeployment.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java
index c4240b4..bf8b885 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleVersionCriteria.java
@@ -52,7 +52,7 @@ public class BundleVersionCriteria extends TaggedCriteria {
}
@Override
- public Class<?> getPersistentClass() {
+ public Class<BundleVersion> getPersistentClass() {
return BundleVersion.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java
index 8156d9a..8d0116e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/CallTimeDataCriteria.java
@@ -59,7 +59,7 @@ public class CallTimeDataCriteria extends Criteria {
private PageOrdering sortCount; // requires overrides
@Override
- public Class<?> getPersistentClass() {
+ public Class<CallTimeDataValue> getPersistentClass() {
return CallTimeDataValue.class;
}
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 d4e3fcb..4ad0376 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
@@ -64,7 +64,6 @@ public abstract class Criteria implements Serializable {
private String searchExpression;
public Criteria() {
-
this.filterOverrides = new HashMap<String, String>();
this.sortOverrides = new HashMap<String, String>();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
index f4db72d..9aa52fd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
@@ -83,7 +83,7 @@ public class EventCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<Event> getPersistentClass() {
return Event.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java
index e3fb715..1e5c91a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/GroupOperationHistoryCriteria.java
@@ -44,7 +44,7 @@ public class GroupOperationHistoryCriteria extends OperationHistoryCriteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<GroupOperationHistory> getPersistentClass() {
return GroupOperationHistory.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java
index 34fb9f9..bf9ba40 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java
@@ -3,8 +3,8 @@ package org.rhq.core.domain.criteria;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import org.rhq.core.domain.util.PageOrdering;
import org.rhq.core.domain.content.InstalledPackage;
+import org.rhq.core.domain.util.PageOrdering;
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("unused")
@@ -33,7 +33,7 @@ public class InstalledPackageCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<InstalledPackage> getPersistentClass() {
return InstalledPackage.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java
index 2f13722..10cdcea 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java
@@ -22,12 +22,12 @@
*/
package org.rhq.core.domain.criteria;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.util.PageOrdering;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.util.PageOrdering;
+
/**
* RHQ {@link Criteria} object for filtered, sortable queries of {@link MeasurementDataTrait trait} data sets.
*
@@ -85,7 +85,7 @@ public class MeasurementDataTraitCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<MeasurementDataTrait> getPersistentClass() {
return MeasurementDataTrait.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java
index 2ce0f65..779e4c5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java
@@ -28,9 +28,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.DisplayType;
import org.rhq.core.domain.measurement.MeasurementCategory;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.measurement.NumericType;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -74,7 +74,7 @@ public class MeasurementDefinitionCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<MeasurementDefinition> getPersistentClass() {
return MeasurementDefinition.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java
index a4c8a09..3a2b130 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java
@@ -100,7 +100,7 @@ public class MeasurementScheduleCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<MeasurementSchedule> getPersistentClass() {
return MeasurementSchedule.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java
index d66d118..854a561 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java
@@ -28,8 +28,8 @@ import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import org.rhq.core.domain.util.PageOrdering;
import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.util.PageOrdering;
/**
* @author Joseph Marques
@@ -72,7 +72,7 @@ public class OperationDefinitionCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<OperationDefinition> getPersistentClass() {
return OperationDefinition.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java
index f54de21..5f879ea 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java
@@ -26,9 +26,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import org.rhq.core.domain.operation.JobId;
-import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.OperationHistory;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -58,30 +57,26 @@ public abstract class OperationHistoryCriteria extends Criteria {
private PageOrdering sortOperationName; // requires override
public OperationHistoryCriteria() {
- init();
- }
-
- @Override
- public Class getPersistentClass() {
- return ResourceOperationHistory.class;
- }
-
- private void init() {
filterOverrides.put("operationDefinitionId", "operationDefinition.id = ?");
filterOverrides.put("operationName", "operationDefinition.name like ?");
filterOverrides.put("startTime", "startedTime >= ?");
filterOverrides.put("endTime", "modifiedTime <= ?");
filterOverrides.put("resourceIds", "id IN " //
- + " ( SELECT roh.id " //
- + " FROM ResourceOperationHistory roh " //
- + " WHERE roh.resource.id IN ( ? ) ) ");
+ + " ( SELECT roh.id " //
+ + " FROM ResourceOperationHistory roh " //
+ + " WHERE roh.resource.id IN ( ? ) ) ");
sortOverrides.put("startTime", "startedTime");
sortOverrides.put("endTime", "modifiedTime");
sortOverrides.put("operationName", "operationDefinition.name");
}
+ @Override
+ public Class<? extends OperationHistory> getPersistentClass() {
+ return OperationHistory.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java
index 3e304b6..592cea1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java
@@ -51,7 +51,7 @@ public class PackageVersionCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<PackageVersion> getPersistentClass() {
return PackageVersion.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
index 42e2ec8..60d23da 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
@@ -56,14 +56,15 @@ public class RepoCriteria extends Criteria {
public RepoCriteria() {
filterOverrides.put("resourceIds", "resourceRepos.resource.id IN ( ? )");
- filterOverrides.put("contentSourceIds",
- "id IN (SELECT innerRepo FROM Repo innerRepo " +
- "JOIN innerRepo.repoContentSources rcs " +
- "WHERE rcs.contentSource.id IN ( ? ))");
+ filterOverrides.put("contentSourceIds", "" //
+ + "id IN ( SELECT innerRepo " //
+ + " FROM Repo innerRepo " //
+ + " JOIN innerRepo.repoContentSources rcs " //
+ + " WHERE rcs.contentSource.id IN ( ? ))");
}
@Override
- public Class getPersistentClass() {
+ public Class<Repo> getPersistentClass() {
return Repo.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
index 3ccab5d..adf2cbd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
@@ -84,7 +84,7 @@ public class ResourceConfigurationUpdateCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<ResourceConfigurationUpdate> getPersistentClass() {
return ResourceConfigurationUpdate.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index a332b77..1eae4a3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -125,8 +125,7 @@ public class ResourceCriteria extends TaggedCriteria {
+ " FROM Resource ires " //
+ " JOIN ires.implicitGroups implicitGroup " //
+ " WHERE implicitGroup.id IN ( ? ) )");
- filterOverrides.put("rootResourceId",
- "agent.id = (SELECT r2.agent.id FROM Resource r2 where r2.id = ?)");
+ filterOverrides.put("rootResourceId", "agent.id = (SELECT r2.agent.id FROM Resource r2 where r2.id = ?)");
sortOverrides.put("resourceTypeName", "resourceType.name");
sortOverrides.put("resourceCategory", "resourceType.category");
@@ -137,7 +136,7 @@ public class ResourceCriteria extends TaggedCriteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<Resource> getPersistentClass() {
return Resource.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
index 7544422..1a54f0f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
@@ -115,7 +115,7 @@ public class ResourceGroupCriteria extends TaggedCriteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<ResourceGroup> getPersistentClass() {
return ResourceGroup.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java
index 96925fb..356dabc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupDefinitionCriteria.java
@@ -22,12 +22,12 @@
*/
package org.rhq.core.domain.criteria;
-import org.rhq.core.domain.resource.group.GroupDefinition;
-import org.rhq.core.domain.util.PageOrdering;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import org.rhq.core.domain.resource.group.GroupDefinition;
+import org.rhq.core.domain.util.PageOrdering;
+
/**
* @author Greg Hinkle
*/
@@ -36,7 +36,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
public class ResourceGroupDefinitionCriteria extends Criteria {
private static final long serialVersionUID = 1L;
-
private Integer filterId;
private String filterName;
private String filterDescription;
@@ -50,13 +49,12 @@ public class ResourceGroupDefinitionCriteria extends Criteria {
private PageOrdering sortRecursive;
private PageOrdering sortExpression;
-
public ResourceGroupDefinitionCriteria() {
}
@Override
- public Class getPersistentClass() {
+ public Class<GroupDefinition> getPersistentClass() {
return GroupDefinition.class;
}
@@ -80,12 +78,10 @@ public class ResourceGroupDefinitionCriteria extends Criteria {
this.filterExpression = filterExpression;
}
-
public void fetchManagedResourceGroups(boolean fetchManagedResourceGroups) {
this.fetchManagedResourceGroups = fetchManagedResourceGroups;
}
-
public void addSortName(PageOrdering sortName) {
addSortField("name");
this.sortName = sortName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java
index e1ab4c4..8e58e69 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceOperationHistoryCriteria.java
@@ -22,8 +22,6 @@
*/
package org.rhq.core.domain.criteria;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-
import java.util.Arrays;
import java.util.List;
@@ -31,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+
/**
* @author Joseph Marques
*/
@@ -49,7 +49,7 @@ public class ResourceOperationHistoryCriteria extends OperationHistoryCriteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<ResourceOperationHistory> getPersistentClass() {
return ResourceOperationHistory.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
index ba5f05e..93ba523 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
@@ -83,7 +83,7 @@ public class ResourceTypeCriteria extends Criteria {
}
@Override
- public Class<?> getPersistentClass() {
+ public Class<ResourceType> getPersistentClass() {
return ResourceType.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
index a810df1..634dc15 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SavedSearchCriteria.java
@@ -65,7 +65,7 @@ public class SavedSearchCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<SavedSearch> getPersistentClass() {
return SavedSearch.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
index 7c39c50..e6e1780 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
@@ -61,7 +61,7 @@ public class SubjectCriteria extends Criteria {
}
@Override
- public Class getPersistentClass() {
+ public Class<Subject> getPersistentClass() {
return Subject.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java
index 2c93450..3e60bd0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/TagCriteria.java
@@ -46,13 +46,11 @@ public class TagCriteria extends Criteria {
private PageOrdering sortSemantic;
private PageOrdering sortName;
-
@Override
- public Class<?> getPersistentClass() {
+ public Class<Tag> getPersistentClass() {
return Tag.class;
}
-
public void addFilterNamespace(String filterNamespace) {
this.filterNamespace = filterNamespace;
}
@@ -65,7 +63,6 @@ public class TagCriteria extends Criteria {
this.filterName = filterName;
}
-
public void addSortNamespace(PageOrdering sortNamespace) {
addSortField("namespace");
this.sortNamespace = sortNamespace;
@@ -81,6 +78,4 @@ public class TagCriteria extends Criteria {
this.sortName = sortName;
}
-
-
}
commit d139f3b79e62d87253e2ff846c1bde0a5b47afa7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 12:57:02 2010 -0400
cosmetic
* remove sections headers, e.g. constants/attributes/constructor/public
* remove unused imports
* reorder import statements
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
index 26291fb..e50214b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
@@ -19,7 +19,7 @@ import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = Advisory.QUERY_FIND_ALL, query = "SELECT adv FROM Advisory adv"),
@NamedQuery(name = Advisory.QUERY_FIND_BY_ADV, query = "SELECT adv " + " FROM Advisory adv "
+ " WHERE adv.advisory = :advisory "),
@@ -44,12 +44,12 @@ import javax.persistence.Table;
public class Advisory implements Serializable {
private static final long serialVersionUID = 1L;
+
public static final String QUERY_FIND_ALL = "Advisory.findAll";
public static final String QUERY_FIND_BY_ADV = "Advisory.findByAdv";
public static final String QUERY_DELETE_BY_ADV_ID = "Advisory.deleteByAdvId";
public static final String QUERY_FIND_COMPOSITE_BY_ID = "Advisory.queryFindCompositeByAdvId";
public static final String QUERY_FIND_BY_ADV_ID = "Advisory.queryFindByAdvId";
- // Attributes --------------------------------------------
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@@ -101,8 +101,6 @@ public class Advisory implements Serializable {
@OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Set<AdvisoryBuglist> advisorybugs;
- // Constructor ----------------------------------------
-
public Advisory() {
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java
index 40c2c36..f47ec44 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Architecture.java
@@ -43,15 +43,13 @@ import org.rhq.core.domain.resource.Resource;
* @author Jason Dobies
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = Architecture.QUERY_FIND_BY_NAME, query = "SELECT arch FROM Architecture arch WHERE arch.name = :name"),
@NamedQuery(name = Architecture.QUERY_FIND_ALL, query = "SELECT arch FROM Architecture arch"),
- @NamedQuery(name = Architecture.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT arch.name, arch.name FROM Architecture arch")
-})
+ @NamedQuery(name = Architecture.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT arch.name, arch.name FROM Architecture arch") })
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_ARCHITECTURE_ID_SEQ")
@Table(name = "RHQ_ARCHITECTURE")
public class Architecture implements Serializable {
- // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
@@ -60,8 +58,6 @@ public class Architecture implements Serializable {
public static final String QUERY_DYNAMIC_CONFIG_VALUES = "Architecture.dynamicConfigValues";
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -70,8 +66,6 @@ public class Architecture implements Serializable {
@Column(name = "NAME", nullable = false)
private String name;
- // Constructor ----------------------------------------
-
public Architecture() {
// for JPA use
}
@@ -80,8 +74,6 @@ public class Architecture implements Serializable {
setName(name);
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java
index 72b0011..696796c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/CVE.java
@@ -40,7 +40,7 @@ import javax.persistence.Table;
*/
@Entity
-@NamedQueries( { @NamedQuery(name = CVE.DELETE_BY_CVE_ID, query = "DELETE CVE cve WHERE cve.id = :cveId"),
+@NamedQueries({ @NamedQuery(name = CVE.DELETE_BY_CVE_ID, query = "DELETE CVE cve WHERE cve.id = :cveId"),
@NamedQuery(name = CVE.FIND_BY_CVE_ID, query = "SELECT cve FROM CVE as cve WHERE cve.id = :cveId") })
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CVE_ID_SEQ")
@Table(name = "RHQ_CVE")
@@ -50,8 +50,6 @@ public class CVE implements Serializable {
public static final String FIND_BY_CVE_ID = "CVE.findByCVEId";
public static final String DELETE_BY_CVE_ID = "CVE.deleteByCVEId";
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -60,8 +58,6 @@ public class CVE implements Serializable {
@Column(name = "NAME", nullable = false)
private String name;
- // Constructor ----------------------------------------
-
public CVE() {
// for JPA use
}
@@ -70,8 +66,6 @@ public class CVE implements Serializable {
this.name = name;
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java
index 5d64d9c..de5bbe1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestStatus.java
@@ -1,25 +1,25 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content;
/**
@@ -33,20 +33,20 @@ public enum ContentRequestStatus {
* state are subject to cleanup if they have been in this state for an extended period of time without a reply
* from the agent.
*/
- IN_PROGRESS("In Progress"),
+ IN_PROGRESS("In Progress"), //
/**
* Indicates the result has been returned from the agent and the plugin was able to execute the actions
* described by the request.
*/
- SUCCESS("Success"),
+ SUCCESS("Success"), //
/**
* Indicates the agent has responded to this request and indicated a failure occurred in either the agent,
* plugin container, or plugin itself. An error message will be provided in the request to further describe
* the failure.
*/
- FAILURE("Failure"),
+ FAILURE("Failure"), //
/**
* Indicates the request was successfully sent to the agent, however a response was not received in a timely manner.
@@ -55,18 +55,12 @@ public enum ContentRequestStatus {
*/
TIMED_OUT("Timed Out");
- // Attributes --------------------------------------------
-
private String displayText;
- // Constructors --------------------------------------------
-
ContentRequestStatus(String displayText) {
this.displayText = displayText; // not very I18N'ish :)
}
- // Object Overridden Methods --------------------------------------------
-
@Override
public String toString() {
return displayText;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java
index e7d50a3..dc8b1e1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentRequestType.java
@@ -1,25 +1,25 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content;
/**
@@ -31,33 +31,27 @@ public enum ContentRequestType {
/**
* Request is to create/deploy new {@link Package}s to a resource.
*/
- DEPLOY("Deploy"),
+ DEPLOY("Deploy"), //
/**
* Request is to delete {@link Package}s from a resource.
*/
- DELETE("Delete"),
+ DELETE("Delete"), //
/**
* Request is to retrieve the content of {@link Package}s.
*/
GET_BITS("Retrieve Package Bits");
- // Attributes --------------------------------------------
-
/**
* Used by the user interface when rendering instances of this enumeration.
*/
private String displayName;
- // Constructors --------------------------------------------
-
ContentRequestType(String displayName) {
this.displayName = displayName;
}
- // Object Overridden Methods --------------------------------------------
-
@Override
public String toString() {
return displayName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java
index 101b61c..9569910 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentServiceRequest.java
@@ -22,8 +22,6 @@
*/
package org.rhq.core.domain.content;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
@@ -58,7 +56,7 @@ import org.rhq.core.domain.resource.Resource;
* @author Jason Dobies
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = ContentServiceRequest.QUERY_FIND_WITH_STATUS, query = "SELECT csr FROM ContentServiceRequest AS csr WHERE csr.status = :status"),
@NamedQuery(name = ContentServiceRequest.QUERY_FIND_BY_RESOURCE_WITH_STATUS, query = "SELECT csr FROM ContentServiceRequest AS csr WHERE csr.resource.id = :resourceId AND csr.status = :status"),
@NamedQuery(name = ContentServiceRequest.QUERY_FIND_BY_RESOURCE_WITH_NOT_STATUS, query = "SELECT csr FROM ContentServiceRequest AS csr WHERE csr.resource.id = :resourceId AND csr.status <> :status"),
@@ -71,7 +69,6 @@ import org.rhq.core.domain.resource.Resource;
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONTENT_REQ_ID_SEQ")
@Table(name = "RHQ_CONTENT_REQ")
public class ContentServiceRequest implements Serializable {
- // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
@@ -82,8 +79,6 @@ public class ContentServiceRequest implements Serializable {
public static final String QUERY_FIND_BY_ID = "ContentServiceRequest.findById";
public static final String QUERY_DELETE_BY_RESOURCES = "ContentServiceRequest.deleteByResources";
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(generator = "SEQ", strategy = GenerationType.AUTO)
@Id
@@ -119,8 +114,6 @@ public class ContentServiceRequest implements Serializable {
@OneToMany(mappedBy = "contentServiceRequest", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
private Set<InstalledPackageHistory> installedPackageHistory;
- // Constructors --------------------------------------------
-
public ContentServiceRequest() {
}
@@ -130,8 +123,6 @@ public class ContentServiceRequest implements Serializable {
this.contentRequestType = contentRequestType;
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
@@ -234,7 +225,6 @@ public class ContentServiceRequest implements Serializable {
this.installedPackageHistory = installedPackageHistory;
}
-
/**
* The duration of the configuration update request which simply is the difference between the
* {@link #getCreatedTime()} and the {@link #getLastModifiedTime()}. If the request hasn't completed yet, this will
@@ -253,15 +243,11 @@ public class ContentServiceRequest implements Serializable {
return end - start;
}
- // Package --------------------------------------------
-
@PreUpdate
void onUpdate() {
this.mtime = System.currentTimeMillis();
}
- // Object Overridden --------------------------------------------
-
@Override
public int hashCode() {
final int PRIME = 31;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java
index 511da1a..00877bd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java
@@ -59,7 +59,7 @@ import org.rhq.core.domain.configuration.Configuration;
* @author Jason Dobies
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = ContentSource.QUERY_FIND_ALL, query = "SELECT cs FROM ContentSource cs "),
@NamedQuery(name = ContentSource.QUERY_FIND_ALL_WITH_CONFIG, query = "SELECT cs FROM ContentSource cs LEFT JOIN FETCH cs.configuration"),
@NamedQuery(name = ContentSource.QUERY_FIND_BY_NAME_AND_TYPENAME, query = "SELECT cs " + " FROM ContentSource cs "
@@ -86,12 +86,8 @@ public class ContentSource implements Serializable {
public static final String QUERY_FIND_BY_REPO_ID = "ContentSource.findByRepoId";
public static final String QUERY_FIND_AVAILABLE_BY_REPO_ID = "ContentSource.findAvailableByRepoId";
- // Constants --------------------------------------------
-
private static final long serialVersionUID = 1L;
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -138,8 +134,6 @@ public class ContentSource implements Serializable {
@OneToMany(mappedBy = "contentSource", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private Set<RepoContentSource> repoContentSources;
- // Constructor asdf
-
public ContentSource() {
// for JPA use
}
@@ -149,8 +143,6 @@ public class ContentSource implements Serializable {
this.contentSourceType = contentSourceType;
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java
index a2d6142..5a046ab 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java
@@ -54,7 +54,7 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
* @author Jason Dobies
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = ContentSourceType.QUERY_FIND_ALL, query = "SELECT cst " + " FROM ContentSourceType cst "
+ " LEFT JOIN FETCH cst.contentSourceConfigurationDefinition d " + " LEFT JOIN FETCH d.templates "),
@NamedQuery(name = ContentSourceType.QUERY_FIND_BY_NAME_WITH_CONFIG_DEF, query = "SELECT cst "
@@ -65,7 +65,6 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONTENT_SOURCE_TYPE_ID_SEQ")
@Table(name = "RHQ_CONTENT_SOURCE_TYPE")
public class ContentSourceType implements Serializable {
- // Constants --------------------------------------------
public static final String QUERY_FIND_ALL = "ContentSourceType.findAll";
public static final String QUERY_FIND_BY_NAME_WITH_CONFIG_DEF = "ContentSourceType.findByNameWithConfigDef";
@@ -73,8 +72,6 @@ public class ContentSourceType implements Serializable {
private static final long serialVersionUID = 1L;
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -113,8 +110,6 @@ public class ContentSourceType implements Serializable {
@OneToMany(mappedBy = "contentSourceType", fetch = FetchType.LAZY)
private Set<ContentSource> contentSources;
- // Constructor ----------------------------------------
-
public ContentSourceType() {
// for JPA use
}
@@ -124,8 +119,6 @@ public class ContentSourceType implements Serializable {
this.contentSourceApiClass = "undefined"; // TODO: I think we want this @Transient
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
index 5ae9acd..5d32c49 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
@@ -22,8 +22,8 @@
*/
package org.rhq.core.domain.content;
-import org.hibernate.annotations.NamedQueries;
-import org.hibernate.annotations.NamedQuery;
+import java.io.Serializable;
+import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -40,15 +40,15 @@ import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
-import java.io.Serializable;
-import java.util.Set;
+import org.hibernate.annotations.NamedQueries;
+import org.hibernate.annotations.NamedQuery;
/**
*
* @author Pradeep Kilambi
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = Distribution.QUERY_FIND_ALL, query = "SELECT dt FROM Distribution dt"),
@NamedQuery(name = Distribution.QUERY_FIND_PATH_BY_DIST_TYPE, query = "SELECT dt " + " FROM Distribution dt "
+ " WHERE dt.label = :label AND dt.distributionType.name = :typeName "),
@@ -66,8 +66,6 @@ public class Distribution implements Serializable {
public static final String QUERY_FIND_PATH_BY_DIST_TYPE = "Distribution.findPathByDistType";
public static final String QUERY_DELETE_BY_DIST_ID = "Distribution.deleteByDistId";
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -95,8 +93,6 @@ public class Distribution implements Serializable {
@OneToMany(mappedBy = "distribution", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<DistributionFile> distributionFiles;
- // Constructor ----------------------------------------
-
public Set<DistributionFile> getDistributionFiles() {
return distributionFiles;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
index 1bf02b8..40a4a26 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
@@ -46,7 +46,7 @@ import javax.xml.bind.annotation.XmlTransient;
*/
@Entity
//(a)IdClass(DistributionFilePK.class)
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = DistributionFile.SELECT_BY_DIST_ID, query = "SELECT df from DistributionFile df WHERE df.distribution.id = :distId"),
@NamedQuery(name = DistributionFile.DELETE_BY_DIST_ID, query = "DELETE DistributionFile df WHERE df.distribution.id = :distId") })
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DISTRIBUTION_FILE_ID_SEQ")
@@ -62,7 +62,6 @@ public class DistributionFile {
* @IdClass and ignore these here, even though the mappings should be here and no mappings should be needed in the
* @IdClass.
*/
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -99,8 +98,6 @@ public class DistributionFile {
this.distribution = pk.getDistribution();
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
index 81adc75..135266c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
@@ -29,10 +29,10 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
/**
* Defines a type of (@link Distribution)
@@ -44,8 +44,7 @@ import javax.persistence.NamedQuery;
@Entity
@NamedQueries({
@NamedQuery(name = DistributionType.QUERY_FIND_BY_NAME, query = "SELECT dt FROM DistributionType dt WHERE dt.name = :name"),
- @NamedQuery(name = DistributionType.QUERY_DELETE_BY_NAME, query = "DELETE FROM DistributionType dt where dt.name = :name")
-})
+ @NamedQuery(name = DistributionType.QUERY_DELETE_BY_NAME, query = "DELETE FROM DistributionType dt where dt.name = :name") })
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DISTRIBUTION_TYPE_ID_SEQ")
@Table(name = "RHQ_DISTRIBUTION_TYPE")
public class DistributionType implements Serializable {
@@ -55,8 +54,6 @@ public class DistributionType implements Serializable {
public static final String QUERY_FIND_BY_NAME = "DistributionType.findByName";
public static final String QUERY_DELETE_BY_NAME = "DistributionType.deleteByName";
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -68,8 +65,6 @@ public class DistributionType implements Serializable {
@Column(name = "DESCRIPTION", nullable = true)
private String description;
- // Constructor ----------------------------------------
-
public DistributionType() {
// for JPA use
}
@@ -78,8 +73,6 @@ public class DistributionType implements Serializable {
this.name = name;
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java
index 3fda3cc..1b79ffb 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DownloadMode.java
@@ -1,25 +1,25 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content;
/**
@@ -31,12 +31,12 @@ public enum DownloadMode {
* is a simple pass-through, where all requests pull down content
* directly from the remote repository.
*/
- NEVER,
+ NEVER, //
/**
* The package bits will be stored in the database.
*/
- DATABASE,
+ DATABASE, //
/**
* The package bits will be stored in the file system.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java
index b7550f4..2bfc04f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackage.java
@@ -46,7 +46,7 @@ import org.rhq.core.domain.resource.Resource;
* @author Jason Dobies
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = InstalledPackage.QUERY_FIND_BY_SET_OF_IDS, query = "SELECT ip FROM InstalledPackage AS ip WHERE ip.id IN ( :packageIds )"),
@NamedQuery(name = InstalledPackage.QUERY_FIND_BY_SET_OF_PACKAGE_VER_IDS, query = "SELECT ip FROM InstalledPackage AS ip WHERE ip.packageVersion.id IN ( :packageIds )"),
@NamedQuery(name = InstalledPackage.QUERY_FIND_BY_RESOURCE_ID, query = "SELECT ip FROM InstalledPackage AS ip WHERE ip.resource.id = :resourceId"),
@@ -89,8 +89,6 @@ public class InstalledPackage implements Serializable {
public static final String QUERY_FIND_INSTALLED_PACKAGE_HISTORY = "InstalledPackage.findInstalledPackageHistory";
public static final String QUERY_DELETE_BY_RESOURCES = "InstalledPackage.deleteByResources";
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -111,14 +109,10 @@ public class InstalledPackage implements Serializable {
@ManyToOne
private Subject user;
- // Constructor ----------------------------------------
-
public InstalledPackage() {
// needed for JPA
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
@@ -171,8 +165,6 @@ public class InstalledPackage implements Serializable {
this.user = user;
}
- // Object Overridden Methods --------------------------------------------
-
@Override
public String toString() {
return "InstalledPackage[resource=" + resource.getName() + ",packageVersion=" + packageVersion.getDisplayName()
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java
index 35ba747..9b21fe2 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/InstalledPackageHistory.java
@@ -22,8 +22,6 @@
*/
package org.rhq.core.domain.content;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
import java.io.Serializable;
import java.util.List;
@@ -56,7 +54,7 @@ import org.rhq.core.domain.resource.Resource;
* @author Jason Dobies
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = InstalledPackageHistory.QUERY_FIND_CONFIG_BY_PACKAGE_VERSION_AND_REQ, query = "SELECT dcv FROM InstalledPackageHistory iph JOIN iph.deploymentConfigurationValues dcv "
+ "WHERE iph.packageVersion = :packageVersion "
+ "AND iph.contentServiceRequest = :contentServiceRequest "
@@ -77,7 +75,6 @@ import org.rhq.core.domain.resource.Resource;
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_INSTALLED_PKG_HIST_ID_SEQ")
@Table(name = "RHQ_INSTALLED_PKG_HIST")
public class InstalledPackageHistory implements Serializable {
- // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
@@ -89,8 +86,6 @@ public class InstalledPackageHistory implements Serializable {
public static final String QUERY_FIND_BY_ID = "InstalledPackageHistory.findById";
public static final String QUERY_DELETE_BY_RESOURCES = "InstalledPackageHistory.deleteByResources";
- // Attributes --------------------------------------------
-
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
@Id
@@ -144,8 +139,6 @@ public class InstalledPackageHistory implements Serializable {
@ManyToOne
private ContentServiceRequest contentServiceRequest;
- // Public --------------------------------------------
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
index db349f3..772b6d7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
@@ -30,7 +30,6 @@ import java.util.Set;
import org.rhq.core.domain.content.Advisory;
import org.rhq.core.domain.content.AdvisoryBuglist;
-import org.rhq.core.domain.content.AdvisoryCVE;
import org.rhq.core.domain.content.AdvisoryPackage;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.util.StringUtils;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java
index 95a193e..76e886e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/PackageListItemComposite.java
@@ -1,25 +1,25 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content.composite;
import java.io.Serializable;
@@ -30,7 +30,8 @@ import java.io.Serializable;
* @author Jason Dobies
*/
public class PackageListItemComposite implements Serializable {
- // Attributes --------------------------------------------
+
+ private static final long serialVersionUID = 1L;
private final int id;
private final String packageName;
@@ -38,8 +39,6 @@ public class PackageListItemComposite implements Serializable {
private final String version;
private final Long timestamp;
- // Constructors --------------------------------------------
-
public PackageListItemComposite(int id, String packageName, String packageTypeName, String version) {
this.id = id;
this.packageName = packageName;
@@ -56,8 +55,6 @@ public class PackageListItemComposite implements Serializable {
this.timestamp = timestamp;
}
- // Public --------------------------------------------
-
public int getId() {
return id;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java
index 1c7c416..982da7a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ContentResponseResult.java
@@ -1,26 +1,26 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.domain.content.transfer;
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content.transfer;
/**
* Describes the result of a content operation executed on a plugin.
@@ -28,10 +28,8 @@
* @author Jason Dobies
*/
public enum ContentResponseResult {
- SUCCESS("Success"),
-
- FAILURE("Failed"),
-
+ SUCCESS("Success"), //
+ FAILURE("Failed"), //
NOT_PERFORMED("Not Performed");
private String displayName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java
index 096a0b3..61e9339 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployIndividualPackageResponse.java
@@ -1,49 +1,45 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.domain.content.transfer;
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content.transfer;
import java.io.Serializable;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
+
import org.rhq.core.domain.content.PackageDetailsKey;
-import org.rhq.core.domain.content.transfer.ContentResponseResult;
-import org.rhq.core.domain.content.transfer.DeployPackageStep;
-
- /**
- * Contains the data necessary to describe the result of deploying a single package. The overall result of the package
- * installation and any error message (if there is one) will convey whether or not the package was successfully
- * installed. Additionally, if installation steps were determined for this package, they and their respective
- * success/failure flags, will be contained in this object as well.
- *
- * @author Jason Dobies
- */
+
+/**
+* Contains the data necessary to describe the result of deploying a single package. The overall result of the package
+* installation and any error message (if there is one) will convey whether or not the package was successfully
+* installed. Additionally, if installation steps were determined for this package, they and their respective
+* success/failure flags, will be contained in this object as well.
+*
+* @author Jason Dobies
+*/
public class DeployIndividualPackageResponse implements Serializable {
- // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
- // Attributes --------------------------------------------
-
private PackageDetailsKey key;
private ContentResponseResult result;
@@ -51,8 +47,6 @@ public class DeployIndividualPackageResponse implements Serializable {
private List<DeployPackageStep> deploymentSteps;
- // Constructors --------------------------------------------
-
public DeployIndividualPackageResponse(PackageDetailsKey key) {
this.key = key;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java
index fd5d9ba..57c62d1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackageStep.java
@@ -1,25 +1,25 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content.transfer;
import java.io.Serializable;
@@ -31,12 +31,9 @@ import java.io.Serializable;
* @author Jason Dobies
*/
public class DeployPackageStep implements Serializable {
- // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
- // Attributes --------------------------------------------
-
/**
* Unique identifier for this step within the context of the overall package installation steps for a particular
* package.
@@ -58,8 +55,6 @@ public class DeployPackageStep implements Serializable {
*/
private String stepErrorMessage;
- // Public --------------------------------------------
-
public DeployPackageStep(String stepKey, String description) {
if (stepKey == null)
throw new IllegalArgumentException("stepKey cannot be null");
@@ -79,12 +74,15 @@ public class DeployPackageStep implements Serializable {
}
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
DeployPackageStep that = (DeployPackageStep) o;
- if (!stepKey.equals(that.stepKey)) return false;
+ if (!stepKey.equals(that.stepKey))
+ return false;
return true;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java
index 83f2957..40c1988 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/DeployPackagesResponse.java
@@ -1,31 +1,27 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.domain.content.transfer;
-
-import org.rhq.core.domain.content.transfer.ContentResponseResult;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content.transfer;
+
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -34,12 +30,9 @@ import java.util.Set;
* @author Jason Dobies
*/
public class DeployPackagesResponse implements Serializable {
- // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
- // Attributes --------------------------------------------
-
private int requestId;
private ContentResponseResult overallRequestResult;
@@ -47,8 +40,6 @@ public class DeployPackagesResponse implements Serializable {
private Set<DeployIndividualPackageResponse> packageResponses = new HashSet<DeployIndividualPackageResponse>();
- // Constructors --------------------------------------------
-
public DeployPackagesResponse() {
}
@@ -97,5 +88,5 @@ public class DeployPackagesResponse implements Serializable {
packageResponses.add(response);
}
-
+
}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java
index 35eb273..dd3848d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/RemovePackagesResponse.java
@@ -1,28 +1,26 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.domain.content.transfer;
-
-import org.rhq.core.domain.content.transfer.ContentResponseResult;
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.content.transfer;
import java.io.Serializable;
import java.util.HashSet;
@@ -32,12 +30,9 @@ import java.util.Set;
* @author Jason Dobies
*/
public class RemovePackagesResponse implements Serializable {
- // Constants --------------------------------------------
private static final long serialVersionUID = 1L;
- // Attributes --------------------------------------------
-
private int requestId;
private ContentResponseResult overallRequestResult;
@@ -45,8 +40,6 @@ public class RemovePackagesResponse implements Serializable {
private Set<RemoveIndividualPackageResponse> packageResponses = new HashSet<RemoveIndividualPackageResponse>();
- // Constructors --------------------------------------------
-
public RemovePackagesResponse() {
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java
index c1440cc..2165b34 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/ResourcePackageDetails.java
@@ -34,7 +34,6 @@ import org.rhq.core.domain.content.PackageDetailsKey;
* @author Jason Dobies
*/
public class ResourcePackageDetails extends PackageDetails {
- // Attributes --------------------------------------------
/**
* Values the plugin should use when installing this package.
@@ -43,14 +42,10 @@ public class ResourcePackageDetails extends PackageDetails {
private long installationTimestamp;
- // Constructors --------------------------------------------
-
public ResourcePackageDetails(PackageDetailsKey key) {
super(key);
}
- // Public --------------------------------------------
-
public Configuration getDeploymentTimeConfiguration() {
return deploymentTimeConfiguration;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
index af4f3b9..3ccab5d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
@@ -88,8 +88,6 @@ public class ResourceConfigurationUpdateCriteria extends Criteria {
return ResourceConfigurationUpdate.class;
}
- // filters
-
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
@@ -122,9 +120,6 @@ public class ResourceConfigurationUpdateCriteria extends Criteria {
this.filterResourceGroupIds = Arrays.asList(filterResourceGroupIds);
}
-
- // Fetches
-
public void fetchResource(boolean fetchResource) {
this.fetchResource = fetchResource;
}
@@ -137,9 +132,6 @@ public class ResourceConfigurationUpdateCriteria extends Criteria {
this.fetchConfiguration = configuration;
}
-
- // Sorts
-
public void addSortCtime(PageOrdering sortCtime) {
addSortField(SORT_FIELD_CTIME);
this.sortCtime = sortCtime;
13 years, 9 months
[rhq] Branch 'code-smell' - 78 commits - .classpath etc/cli-scripts modules/core modules/enterprise pom.xml
by lkrejci
.classpath | 2
etc/cli-scripts/measurement_utils.js | 134 ++
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 18
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java | 49
modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java | 34
modules/core/domain/src/main/java/org/rhq/core/domain/common/EntityContext.java | 186 +++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java | 51
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java | 12
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java | 25
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java | 47
modules/enterprise/gui/coregui/pom.xml | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java | 103 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 55 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/DemoCanvas.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 67 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java | 51
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java | 277 ++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java | 100 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java | 126 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java | 151 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 93 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java | 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 172 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 527 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnumSelectItem.java | 81 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java | 185 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java | 53 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 410 +++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 66 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 53 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 119 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java | 170 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java | 136 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 326 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 178 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java | 31
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java | 87 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListView.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 198 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java | 147 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java | 141 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 178 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 240 +---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java | 43
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java | 57 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java | 37
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java | 67 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 29
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 261 +---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java | 182 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 71 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDatasource.java | 134 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDetailsView.java | 99 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventHistoryView.java | 79 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDetailView.java | 44
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java | 61 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 55 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 53 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 132 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 46
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/HighlightingDatasourceTextField.java | 47
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java | 117 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 41
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java | 69 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java | 190 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/effects/ColoringUtility.java | 92 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java | 27
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java | 46
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java | 47
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 17
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 5
modules/enterprise/gui/coregui/src/main/webapp/images/types/GroupDefinition_16.png |binary
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java | 15
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java | 2
modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 89 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/common/EntityContext.java | 140 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java | 58 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java | 24
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 63 -
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java | 2
modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy | 2
modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy | 3
pom.xml | 171 +--
195 files changed, 5853 insertions(+), 2822 deletions(-)
New commits:
commit 077dd3d75a5782dd4c775b47a64e80b0cfd38311
Merge: 8970684... e5fac0a...
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 14 18:08:59 2010 +0200
Merge branch 'master' into code-smell
commit e5fac0a1484e1c2404bfb815d98228c707afca01
Merge: 76eb27f... b02e602...
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 14 11:29:37 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 76eb27f1cdefa7028df485ed5ec1fa54f3018cb7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 14 11:23:22 2010 -0400
fix a bunch of bugs in the resource tree plus start cleaning up / refactoring the tree code
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index 916bcc7..9355e30 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -665,7 +665,7 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_FIND_BY_ID_WITH_INSTALLED_PACKAGES, query = "SELECT r FROM Resource AS r LEFT JOIN r.installedPackages ip WHERE r.id = :id"),
@NamedQuery(name = Resource.QUERY_FIND_BY_ID_WITH_INSTALLED_PACKAGE_HIST, query = "SELECT r FROM Resource AS r LEFT JOIN r.installedPackageHistory ip WHERE r.id = :id"),
@NamedQuery(name = Resource.QUERY_FIND_PLATFORM_BY_AGENT, query = "SELECT res FROM Resource res WHERE res.resourceType.category = :category AND res.agent = :agent"),
- @NamedQuery(name = Resource.QUERY_FIND_PAREBT_ID, query = "SELECT res.parentResource.id FROM Resource AS res WHERE res.id = :id"),
+ @NamedQuery(name = Resource.QUERY_FIND_PARENT_ID, query = "SELECT res.parentResource.id FROM Resource AS res WHERE res.id = :id"),
@NamedQuery(name = Resource.QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE, query = ""
+ "SELECT DISTINCT r FROM Resource r "
+ "WHERE r.parentResource.id is null "
@@ -679,7 +679,7 @@ import org.rhq.core.domain.util.Summary;
+ " OR EXISTS (SELECT rr FROM Resource rr WHERE rr.id = :resourceId AND rr.parentResource.parentResource.parentResource.parentResource.parentResource = r) "
+ " OR EXISTS (SELECT rr FROM Resource rr WHERE rr.id = :resourceId AND rr.parentResource.parentResource.parentResource.parentResource.parentResource.parentResource = r) "
+ " )"), //
- @NamedQuery(name = Resource.QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME, query = "" //
+ @NamedQuery(name = Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME, query = "" //
+ "SELECT r.id " //
+ " FROM Resource r " //
+ " WHERE ( r.resourceType.id = :resourceTypeId OR :resourceTypeId IS NULL ) " //
@@ -692,7 +692,7 @@ import org.rhq.core.domain.util.Summary;
+ " OR r.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.parentResource.parentResource.id = :resourceId) "
+ " OR r.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.parentResource.parentResource.parentResource.id = :resourceId) "
+ " ) "),
- @NamedQuery(name = Resource.QUERY_FIND_DESCENDENTS, query = "" //
+ @NamedQuery(name = Resource.QUERY_FIND_DESCENDANTS, query = "" //
+ "SELECT r.id " //
+ " FROM Resource r " //
+ " WHERE r.id = :resourceId " //
@@ -846,12 +846,12 @@ public class Resource implements Comparable<Resource>, Serializable {
public static final String QUERY_FIND_PLATFORM_BY_AGENT = "Resource.findPlatformByAgent";
- public static final String QUERY_FIND_PAREBT_ID = "Resource.findParentId";
+ public static final String QUERY_FIND_PARENT_ID = "Resource.findParentId";
public static final String QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE = "Resource.findRootPlatformOfResource";
- public static final String QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME = "Resource.findDescendentsByTypeAndName";
- public static final String QUERY_FIND_DESCENDENTS = "Resource.findDescendents";
+ public static final String QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME = "Resource.findDescendantsByTypeAndName";
+ public static final String QUERY_FIND_DESCENDANTS = "Resource.findDescendants";
public static final String QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK = "Resource.markResourcesForAsyncDeletionQuick";
public static final String QUERY_FIND_RESOURCES_MARKED_FOR_ASYNC_DELETION = "Resource.findResourcesMarkedForAsyncDeletion";
@@ -913,7 +913,7 @@ public class Resource implements Comparable<Resource>, Serializable {
@JoinColumn(name = "RESOURCE_TYPE_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne
- // TODO GH: It would be prefferable for this to be lazy, but will need cleanup throughout the app (fetch = FetchType.LAZY)
+ // TODO GH: It would be preferable for this to be lazy, but will need cleanup throughout the app (fetch = FetchType.LAZY)
@Summary(index = 4)
private ResourceType resourceType;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java
index 80e92f6..14fd30f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java
@@ -256,9 +256,9 @@ public class ResourceSubCategory implements Comparable<ResourceSubCategory>, Ser
}
/**
- * Returns this subcategory's parent subcategory, or null if this subcateogry has no parent.
+ * Returns this subcategory's parent subcategory, or null if this subcategory has no parent.
*
- * @return this subcategory's parent subcategory, or null if this subcateogry has no parent
+ * @return this subcategory's parent subcategory, or null if this subcategory has no parent
*/
public ResourceSubCategory getParentSubCategory() {
return parentSubCategory;
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 2d92aba..6ef33a5 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -130,7 +130,7 @@
<artifactId>quartz</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
<scope>provided</scope>
- <!-- by JBossAS itself, which the container build has packaged with 1.6.5 -->
+ <!-- by JBossAS itself, which the container buildNodes has packaged with 1.6.5 -->
</dependency>
<!-- needed for referenced domain entities that use Hibernate annotations (due to JDK5 bug) -->
@@ -288,9 +288,9 @@
<configuration>
<tasks>
<taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
- <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
+ <i18n outputdir="${project.buildNodes.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
<classpath refid="maven.runtime.classpath" />
- <classfileset dir="${project.build.outputDirectory}">
+ <classfileset dir="${project.buildNodes.outputDirectory}">
<include name="**/*I18NResourceKeys.class" />
</classfileset>
</i18n>
@@ -305,7 +305,7 @@
<phase>process-classes</phase>
<configuration>
<tasks>
- <copy todir="${project.build.outputDirectory}">
+ <copy todir="${project.buildNodes.outputDirectory}">
<fileset dir="src/main/webapp-filtered/WEB-INF/classes">
<include name="ApplicationResources.properties" />
</fileset>
@@ -352,7 +352,7 @@
<tasks>
<!--
<property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" />
- <echo>*** Copying updated files from target/${project.build.finalName}/WEB-INF/classes to ${classes.dir}...</echo>
+ <echo>*** Copying updated files from target/${project.buildNodes.finalName}/WEB-INF/classes to ${classes.dir}...</echo>
<copy todir="${classes.dir}" verbose="${rhq.verbose}">
<fileset dir="war/WEB-INF/classes" />
</copy>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
index 7498ad2..b332c3a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
@@ -103,7 +103,7 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
private void buildForm() {
if (!formBuilt) {
- // TODO build components
+ // TODO buildNodes components
// TODO setFields(components);
formBuilt = true;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index 2ad86d4..db9aeaa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -103,7 +103,7 @@ public class NotificationsAlertDefinitionForm extends LocatableDynamicForm imple
private void buildForm() {
if (!formBuilt) {
- // TODO build components
+ // TODO buildNodes components
// TODO setFields(components);
formBuilt = true;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
index b0ddff7..a3bd629 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
@@ -32,7 +32,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
public abstract class AbstractBundleCreateWizard extends AbstractWizard {
- // the things we build up in the wizard
+ // the things we buildNodes up in the wizard
private String recipe;
private BundleVersion bundleVersion;
private HashMap<String, Boolean> allBundleFilesStatus; // bundle file names with their upload status (true=they were uploaded)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
index a0728af..eef6af5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
@@ -30,7 +30,7 @@ import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
*/
public abstract class AbstractBundleDeployWizard extends AbstractWizard {
- // the things we build up in the wizard
+ // the things we buildNodes up in the wizard
private Integer bundleId;
private BundleDestination destination;
private boolean isNewDestination = false;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java
index cf69400..c393657 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java
@@ -28,7 +28,7 @@ import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
*/
public abstract class AbstractBundleRevertWizard extends AbstractWizard {
- // the things we build up in the wizard
+ // the things we buildNodes up in the wizard
private BundleDestination destination;
private String deploymentDescription;
private BundleDeployment deployment;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
new file mode 100644
index 0000000..c0752a1
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -0,0 +1,53 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.tree;
+
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+/**
+ * @author Ian Springer
+ */
+public class EnhancedTreeNode extends TreeNode {
+ private static final String ID_FIELD = "id";
+ private static final String PARENT_ID_FIELD = "parentId";
+
+ public String getID() {
+ return getAttribute(ID_FIELD);
+ }
+
+ public String getParentID() {
+ return getAttribute(PARENT_ID_FIELD);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ String className = this.getClass().getName();
+ String simpleClassName = className.substring(className.lastIndexOf(".") + 1);
+ buffer.append(simpleClassName).append("[");
+ String id = getID();
+ buffer.append("id=").append(id);
+ String parentId = getParentID();
+ buffer.append(", parentId=").append(parentId);
+ String name = getName();
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
index 939c519..bccf8c5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
@@ -165,7 +165,7 @@ public class NewResourceTreeDataSource extends DataSource {
EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
-// response.setData(build(result));
+// response.setData(buildNodes(result));
processResponse(requestId, response);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index fe4fdc2..9d7f395 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -44,15 +45,17 @@ import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
- * This doesn't extend RPCDataSource because it is tree oriented and
- * behaves different from normal list data sources in some places.
+ * This doesn't extend RPCDataSource because it is tree-oriented and behaves differently than normal list data sources
+ * in some places.
*
* @author Greg Hinkle
+ * @author Ian Springer
*/
public class ResourceTreeDatasource extends DataSource {
private List<Resource> initialData;
@@ -98,7 +101,7 @@ public class ResourceTreeDatasource extends DataSource {
String requestId = request.getRequestId();
DSResponse response = new DSResponse();
response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
- // Asume success
+ // Assume success
response.setStatus(0);
switch (request.getOperationType()) {
case ADD:
@@ -168,7 +171,8 @@ public class ResourceTreeDatasource extends DataSource {
ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
- response.setData(build(result));
+ TreeNode[] treeNodes = buildNodes(result);
+ response.setData(treeNodes);
processResponse(requestId, response);
response.setStatus(DSResponse.STATUS_SUCCESS);
}
@@ -181,7 +185,7 @@ public class ResourceTreeDatasource extends DataSource {
* @param resources
* @return
*/
- public static TreeNode[] build(List<Resource> resources) {
+ public static TreeNode[] buildNodes(List<Resource> resources) {
ResourceTreeNode[] records = new ResourceTreeNode[resources.size()];
for (int x = 0; x < resources.size(); x++) {
Resource res = resources.get(x);
@@ -189,52 +193,54 @@ public class ResourceTreeDatasource extends DataSource {
records[x] = record;
}
- return introduceTypeFolders(records);
+ return introduceTypeAndCategoryNodes(records);
}
- private static TreeNode[] introduceTypeFolders(ResourceTreeNode[] nodes) {
- ArrayList<TreeNode> built = new ArrayList<TreeNode>();
- HashMap<ResourceSubCategory, CategoryTreeNode> categories = new HashMap<ResourceSubCategory, CategoryTreeNode>();
- HashMap<ResourceType, TypeTreeNode> types = new HashMap<ResourceType, TypeTreeNode>();
+ private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[] nodes) {
+ List<TreeNode> updatedNodes = new ArrayList<TreeNode>();
+ Map<Integer, CategoryTreeNode> categories = new HashMap<Integer, CategoryTreeNode>();
+ Map<ResourceType, TypeTreeNode> types = new HashMap<ResourceType, TypeTreeNode>();
for (ResourceTreeNode node : nodes) {
- built.add(node);
-
- if (!types.containsKey(node.getResourceType())
- && node.getResourceType().getCategory() != ResourceCategory.PLATFORM) {
-
- String parentResourceId = String.valueOf(node.getResource().getParentResource().getId());
-
- CategoryTreeNode categoryNode = null;
-
- if (node.getResourceType().getSubCategory() != null) {
- ResourceSubCategory category = node.getResourceType().getSubCategory();
- if (category.getName() != null) {
- categoryNode = categories.get(category);
-
- if (categoryNode == null) {
- categoryNode = new CategoryTreeNode(parentResourceId, category);
-
- categories.put(category, categoryNode);
- built.add(categoryNode);
+ updatedNodes.add(node);
+
+ ResourceType type = node.getResourceType();
+ if (type.getCategory() != ResourceCategory.PLATFORM) {
+ if (!types.containsKey(type)) {
+
+ String parentResourceId = String.valueOf(node.getResource().getParentResource().getId());
+
+ CategoryTreeNode categoryNode = null;
+ if (type.getSubCategory() != null) {
+ ResourceSubCategory category = type.getSubCategory();
+ if (category.getName() != null) {
+ categoryNode = categories.get(category.getId());
+ if (categoryNode == null) {
+ // TODO (ips): Handle connecting child subcat nodes to their parent subcats.
+ /*ResourceSubCategory parentCategory = category.getParentSubCategory();
+ while (parentCategory != null) {
+ Resource parentType = parentCategory.findParentResourceType();
+ if (parentCategory.findTaggedResourceTypes().isEmpty()) {
+ CategoryTreeNode parentCategoryNode =
+ new CategoryTreeNode(parentResourceId, parentCategory);
+ }
+ }*/
+ categoryNode = new CategoryTreeNode(parentResourceId, category);
+ categories.put(category.getId(), categoryNode);
+ updatedNodes.add(categoryNode);
+ }
}
}
- }
- String parentId = null;
- if (categoryNode != null) {
- parentId = categoryNode.getAttribute("id");
- } else {
- parentId = parentResourceId;
+ String parentId = (categoryNode != null) ? categoryNode.getID() : parentResourceId;
+ TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId, type);
+ updatedNodes.add(typeNode);
+ types.put(type, typeNode);
}
-
- TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId, node.getResourceType().getName());
- built.add(typeNode);
- types.put(node.getResourceType(), typeNode);
}
}
- return built.toArray(new TreeNode[built.size()]);
+ return updatedNodes.toArray(new TreeNode[updatedNodes.size()]);
}
private static boolean sameTypes(ResourceTreeNode[] nodes) {
@@ -247,78 +253,87 @@ public class ResourceTreeDatasource extends DataSource {
return true;
}
- public static class CategoryTreeNode extends TreeNode {
- public CategoryTreeNode(String parentId, ResourceSubCategory category) {
- setID(parentId + "__" + category.getName());
- setParentID(parentId);
- setName(category.getDisplayName());
+ public static class CategoryTreeNode extends EnhancedTreeNode {
+ public CategoryTreeNode(String parentResourceId, ResourceSubCategory category) {
+ String id = parentResourceId + "__" + fixId(category.getName());
+ setID(id);
+ setAttribute("id", id);
- setAttribute("id", parentId + "__" + category.getName());
- setAttribute("parentId", parentId);
- setAttribute("name", category.getDisplayName());
- }
+ setParentID(parentResourceId);
+ setAttribute("parentId", parentResourceId);
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("CategoryTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
+ setName(category.getDisplayName());
+ setAttribute("name", category.getDisplayName());
}
}
- public static class TypeTreeNode extends TreeNode {
- private TypeTreeNode(String parentId, String parentResourceId, String type) {
- setID(parentId + "_" + type);
- setParentID(parentId);
+ public static class TypeTreeNode extends EnhancedTreeNode {
+ private TypeTreeNode(String parentId, String parentResourceId, ResourceType type) {
+ String id = parentResourceId + "_" + type.getId();
+ setID(id);
+ setAttribute("id", id);
- setAttribute("id", parentResourceId + "_" + type);
+ if (parentId == null) {
+ try {
+ throw new IllegalStateException("**************** WARNING: parent ID is null for type " + type);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ setParentID(parentId);
setAttribute("parentId", parentId);
+
// setAttribute("parentKey", parentId);
- setAttribute("name", type);
+
+ String name = type.getName();
+ setName(name);
+ setAttribute("name", name);
+ }
+
+ @Override
+ public void setParentID(String parentID) {
+ if (parentID == null) {
+ try {
+ throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName());
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ super.setParentID(parentID);
}
@Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("TypeTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
+ public void setAttribute(String property, String value) {
+ if (property.equals("parentId") && value == null) {
+ try {
+ throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName());
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ super.setAttribute(property, value);
}
}
- public static class ResourceTreeNode extends TreeNode {
+ public static class ResourceTreeNode extends EnhancedTreeNode {
private Resource resource;
private ResourceTreeNode(Resource resource) {
this.resource = resource;
String id = String.valueOf(resource.getId());
- String parentId = resource.getParentResource() == null ? null
- : (resource.getParentResource().getId() + "_" + resource.getResourceType().getName());
-
- // System.out.println(id + " / " + parentId);
-
setID(id);
- setParentID(parentId);
-
setAttribute("id", id);
+
+ String parentId = (resource.getParentResource() != null) ?
+ (resource.getParentResource().getId() + "_" + resource.getResourceType().getId()) : null;
+ setParentID(parentId);
setAttribute("parentId", parentId);
+ // System.out.println(id + " / " + parentId);
// setAttribute("parentKey", resource.getParentResource() == null ? 0 : (resource.getParentResource().getId() + resource.getResourceType().getName()));
+ setName(resource.getName());
setAttribute("name", resource.getName());
setAttribute("description", resource.getDescription());
ResourceAvailability currentAvail = resource.getCurrentAvailability();
@@ -335,30 +350,12 @@ public class ResourceTreeDatasource extends DataSource {
return resource;
}
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
public ResourceType getResourceType() {
return resource.getResourceType();
}
+ }
- public String getParentId() {
- return getAttribute("parentId");
- }
-
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("ResourceTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
- }
+ private static String fixId(String id) {
+ return id.replace(' ', '_');
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 57ba8f2..02afc80 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -35,6 +35,7 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionEvent;
import com.smartgwt.client.widgets.menu.Menu;
@@ -129,11 +130,12 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (!selectionEvent.isRightButtonDown() && selectionEvent.getState()) {
- if (treeGrid.getSelectedRecord() instanceof ResourceTreeDatasource.ResourceTreeNode) {
- ResourceTreeDatasource.ResourceTreeNode node = (ResourceTreeDatasource.ResourceTreeNode) treeGrid
- .getSelectedRecord();
- //System.out.println("Resource selected in tree: " + node.getResource());
- String viewPath = "Resource/" + node.getResource().getId();
+ ListGridRecord selectedNode = treeGrid.getSelectedRecord();
+ System.out.println("Node selected in tree: " + selectedNode);
+ if (selectedNode instanceof ResourceTreeDatasource.ResourceTreeNode) {
+ ResourceTreeDatasource.ResourceTreeNode resourceNode =
+ (ResourceTreeDatasource.ResourceTreeNode) selectedNode;
+ String viewPath = "Resource/" + resourceNode.getResource().getId();
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
@@ -162,14 +164,14 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
if (!initialSelect) {
- updateBreadcrumb();
+ updateBreadcrumbs();
}
}
});
}
- private void updateBreadcrumb() {
+ private void updateBreadcrumbs() {
TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId));
// System.out.println("Trying to preopen: " + selectedNode);
if (selectedNode != null) {
@@ -177,10 +179,6 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.getTree().openFolders(parents);
treeGrid.getTree().openFolder(selectedNode);
- for (TreeNode p : parents) {
- // System.out.println("open? " + treeGrid.getTree().isOpen(p) + " node: " + p.getName());
- }
-
treeGrid.selectRecord(selectedNode);
initialSelect = true;
treeGrid.markForRedraw();
@@ -466,20 +464,9 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.selectRecord(node);
}
- updateBreadcrumb();
- /*
- TODO DELETEME
- // Update breadcrumbs
- viewId.getBreadcrumbs().clear();
- for (int i = parents.length - 1; i >= 0; i--) {
- TreeNode n = parents[i];
- adjustBreadcrumb(n, viewId);
- }
- adjustBreadcrumb(node, viewId);
-
- CoreGUI.refreshBreadCrumbTrail();
- */
+ TreeUtility.printTree(treeGrid.getTree());
+ updateBreadcrumbs();
} else {
// This is for cases where we have to load the tree fresh including down to the currently visible node
@@ -505,7 +492,7 @@ public class ResourceTreeView extends LocatableVLayout {
ResourceTreeDatasource dataSource = new ResourceTreeDatasource(result);
treeGrid.setDataSource(dataSource);
- // GH: couldn't get initial data to mix with the datasource... so i put the inital data in
+ // GH: couldn't get initial data to mix with the datasource... so i put the initial data in
// the first datasource request
// treeGrid.setInitialData(selectedLineage);
@@ -514,7 +501,7 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() {
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
System.out.println("Here!!!!!");
- updateBreadcrumb();
+ updateBreadcrumbs();
}
});
@@ -532,7 +519,7 @@ public class ResourceTreeView extends LocatableVLayout {
System.out.println("open? " + treeGrid.getTree().isOpen(p) + " node: " + p.getName());
}
- updateBreadcrumb();
+ updateBreadcrumbs();
treeGrid.selectRecord(selectedNode);
initialSelect = true;
@@ -552,7 +539,7 @@ public class ResourceTreeView extends LocatableVLayout {
TreeUtility.printTree(treeGrid.getTree());
- treeGrid.getTree().linkNodes(ResourceTreeDatasource.build(result));
+ treeGrid.getTree().linkNodes(ResourceTreeDatasource.buildNodes(result));
TreeNode selectedNode = treeGrid.getTree().findById(
String.valueOf(selectedResourceId));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
index 7e96af8..e9f773d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
@@ -80,7 +80,7 @@ public class ResourceSelector extends AbstractSelector<Resource> {
// TODO: Currently ignore the typeSelectItem widget because we already know the type.
// Alternatively, we could display it disabled but we'd want the type name to be displayed as the
// value. To get this to display the type name I think we need to pre-fetch the type tree here. We could
- // potentially optimize typeSelectItem.setValue(requireType.getId()) to build a tree that includes only
+ // potentially optimize typeSelectItem.setValue(requireType.getId()) to buildNodes a tree that includes only
// this single type.
//typeSelectItem.setValue(requireType.getId());
//typeSelectItem.setDisabled(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
index f8ebe39..550413c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
@@ -23,6 +23,8 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -41,8 +43,8 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
*/
public class ResourceTypeRepository {
- private HashMap<Integer, ResourceType> typeCache = new HashMap<Integer, ResourceType>();
- private HashMap<Integer, EnumSet<MetadataType>> typeCacheLevel = new HashMap<Integer, EnumSet<MetadataType>>();
+ private Map<Integer, ResourceType> typeCache = new HashMap<Integer, ResourceType>();
+ private Map<Integer, EnumSet<MetadataType>> typeCacheLevel = new HashMap<Integer, EnumSet<MetadataType>>();
private static ResourceTypeGWTServiceAsync resourceTypeService = GWTServiceLookup.getResourceTypeGWTService();
@@ -78,7 +80,8 @@ public class ResourceTypeRepository {
loadResourceTypes(resources, null, callback);
}
- public void loadResourceTypes(final List<Resource> resources, final EnumSet<MetadataType> metadataTypes, final ResourceTypeLoadedCallback callback) {
+ public void loadResourceTypes(final List<Resource> resources, final EnumSet<MetadataType> metadataTypes,
+ final ResourceTypeLoadedCallback callback) {
if (resources.size() == 0) {
callback.onResourceTypeLoaded(resources);
return;
@@ -86,7 +89,7 @@ public class ResourceTypeRepository {
long start = System.currentTimeMillis();
- HashSet<Integer> types = new HashSet<Integer>();
+ Set<Integer> types = new HashSet<Integer>();
for (Resource res : resources) {
types.add(res.getResourceType().getId());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
index 8199c50..360fd86 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
@@ -1,9 +1,30 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.enterprise.gui.coregui.client.util;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
+import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
/**
+ * A collection of utility methods for working with SmartGWT {@link Tree}s.
+ *
* @author Ian Springer
*/
public class TreeUtility {
@@ -15,15 +36,34 @@ public class TreeUtility {
private static void printTreeNode(Tree tree, TreeNode node) {
int level = tree.getLevel(node);
for (int i = 0; i < level; i++) {
- System.out.print(' ');
+ System.out.print(" ");
}
- System.out.println("* " + node);
+ System.out.println("* " + toString(node));
TreeNode[] childNodes = tree.getChildren(node);
for (TreeNode childNode : childNodes) {
printTreeNode(tree, childNode);
}
}
+ private static String toString(TreeNode node) {
+ if (node instanceof EnhancedTreeNode) {
+ return node.toString();
+ } else {
+ StringBuilder buffer = new StringBuilder();
+ String className = node.getClass().getName();
+ String simpleClassName = className.substring(className.lastIndexOf(".") + 1);
+ buffer.append(simpleClassName).append("[");
+ String id = node.getAttribute("id");
+ buffer.append("id=").append(id);
+ String parentId = node.getAttribute("parentId");
+ buffer.append(", parentId=").append(parentId);
+ String name = node.getName();
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
+ }
+
private TreeUtility() {
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 6bb2d7d..25b19b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -174,7 +174,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
public List<Resource> getResourceLineageAndSiblings(int resourceId) {
return SerialUtility.prepare(resourceManager.getResourceLineageAndSiblings(resourceId),
- "ResourceService.getResourceLineage");
+ "ResourceService.getResourceLineageAndSiblings");
}
public Resource getPlatformForResource(int resourceId) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index e228f15..ce68440 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -290,7 +290,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// set agent references null
// foobar the resourceKeys
// update the inventory status to UNINVENTORY
- Query toBeDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDENTS);
+ Query toBeDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS);
toBeDeletedQuery.setParameter("resourceId", resourceId);
List<Integer> toBeDeletedResourceIds = toBeDeletedQuery.getResultList();
@@ -358,7 +358,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
@SuppressWarnings("unchecked")
public List<Integer> getResourceDescendantsByTypeAndName(Subject user, int resourceId, Integer resourceTypeId,
String name) {
- Query descendantQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME);
+ Query descendantQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME);
descendantQuery.setParameter("resourceId", resourceId);
descendantQuery.setParameter("resourceTypeId", resourceTypeId);
name = QueryUtility.formatSearchParameter(name);
@@ -655,7 +655,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
@Nullable
private Integer getParentResourceId(int resourceId) {
- Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_PAREBT_ID);
+ Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_PARENT_ID);
query.setParameter("id", resourceId);
try {
@@ -701,11 +701,27 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public List<Resource> getResourceLineageAndSiblings(int resourceId) {
List<Resource> resourceLineage = getResourceLineage(resourceId);
- LinkedList<Resource> result = new LinkedList<Resource>();
+ List<Resource> result = new LinkedList<Resource>();
- result.add(resourceLineage.get(0));
+ Resource platform = resourceLineage.get(0);
+ result.add(platform);
for (Resource resource : resourceLineage) {
- result.addAll(resource.getChildResources());
+ if (resource.getParentResource() != null) {
+ // This ensures Hibernate actually fetches the parent Resource.
+ resource.getParentResource().getId();
+ }
+ Set<Resource> childResources = resource.getChildResources();
+ result.addAll(childResources);
+ for (Resource childResource : childResources) {
+ // This ensures Hibernate actually fetches the parent Resource.
+ childResource.getParentResource().getId();
+ Set<Resource> grandchildResources = childResource.getChildResources();
+ result.addAll(grandchildResources);
+ for (Resource grandchildResource : grandchildResources) {
+ // This ensures Hibernate actually fetches the parent Resource.
+ grandchildResource.getParentResource().getId();
+ }
+ }
}
return result;
commit b02e60272034d5f1785dd87b9e38046a31784c1f
Merge: bf9bb7b... fc50175...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Sep 14 10:52:46 2010 -0400
Merge branch 'master' into master-jay
commit bf9bb7bed3e3b697789ec1b953e68e966cf9488f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Sep 14 10:50:48 2010 -0400
More Adminisration Section Work
- First working version of role management (still
needs work to get it looking better)
- Tweaks to User management
- Selenium hooks worked into roles
- Add margin to TableSection to get BackButton some
buffer space.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java
index 74b9c34..3ec8b14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java
@@ -18,8 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin.roles;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Set;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -30,65 +31,58 @@ import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.HeaderItem;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Set;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
*/
public class PermissionEditorView extends CanvasItem {
-
private Set<Permission> selectedPermissions = EnumSet.noneOf(Permission.class);
- private DynamicForm parentForm;
-
private DynamicForm form;
-
- public PermissionEditorView(String name, String title) {
+ public PermissionEditorView(String locatorId, String name, String title) {
super(name, title);
- setCanvas(new SimpleCollapsiblePanel("Permissions", buildForm()));
+ setCanvas(buildForm(locatorId));
}
+ public Canvas buildForm(String locatorId) {
+ this.form = new LocatableDynamicForm(locatorId);
+ this.form.setNumCols(4);
+ this.form.setColWidths("20%", "20%", "20%", "40%");
- public Canvas buildForm() {
- System.out.println("Building permissions canvas");
-
-// Object o = getAttributeAsObject(getFieldName());
-
- this.form = new DynamicForm();
ArrayList<FormItem> items = new ArrayList<FormItem>();
-
- HeaderItem h1 = new HeaderItem("globalPermissions","Global Permissions");
+ HeaderItem h1 = new HeaderItem("globalPermissions", "Global Permissions");
h1.setValue("Global Permissions");
items.add(h1);
for (Permission p : Permission.values()) {
if (p.getTarget() == Permission.Target.GLOBAL) {
- items.add(new CheckboxItem(p.name(),p.name()));
+ CheckboxItem cb = new CheckboxItem(p.name(), p.name());
+ cb.setShowTitle(false);
+ items.add(cb);
}
}
- HeaderItem h2 = new HeaderItem("resourcePermissions","Resource Permissions");
+ HeaderItem h2 = new HeaderItem("resourcePermissions", "Resource Permissions");
h2.setValue("Resource Permissions");
items.add(h2);
for (Permission p : Permission.values()) {
if (p.getTarget() == Permission.Target.RESOURCE) {
- items.add(new CheckboxItem(p.name(),p.name()));
+ CheckboxItem cb = new CheckboxItem(p.name(), p.name());
+ cb.setShowTitle(false);
+ items.add(cb);
}
}
form.setItems(items.toArray(new FormItem[items.size()]));
-
return form;
}
-
public void setPermissions(Set<Permission> permissions) {
this.selectedPermissions = permissions;
for (Permission p : Permission.values()) {
@@ -98,7 +92,7 @@ public class PermissionEditorView extends CanvasItem {
form.addItemChangedHandler(new ItemChangedHandler() {
public void onItemChanged(ItemChangedEvent itemChangedEvent) {
for (Permission p : Permission.values()) {
- if ((Boolean)form.getValue(p.name())) {
+ if ((Boolean) form.getValue(p.name())) {
selectedPermissions.add(p);
} else {
selectedPermissions.remove(p);
@@ -116,11 +110,6 @@ public class PermissionEditorView extends CanvasItem {
@Override
public Object getValue() {
- System.out.println("Finding Value");
return super.getValue();
}
-
- public void setParentForm(DynamicForm parentForm) {
- this.parentForm = parentForm;
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
index ad9c982..7a81733 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
@@ -18,57 +18,57 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin.roles;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DSOperationType;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
-import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.ResetItem;
-import com.smartgwt.client.widgets.form.fields.SubmitItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
-import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
-import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceGroupSelector;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
*/
-public class RoleEditView extends LocatableVLayout {
+public class RoleEditView extends LocatableVLayout implements BookmarkableView {
- private Role roleBeingEdited;
+ private Role role;
- private Label message = new Label("Select a role to edit...");
+ private Label message = new Label("Loading...");
private VLayout editCanvas;
- private HeaderLabel editLabel;
private DynamicForm form;
+
private PermissionEditorView permissionEditorItem;
private CanvasItem groupSelectorItem;
@@ -77,187 +77,210 @@ public class RoleEditView extends LocatableVLayout {
private CanvasItem subjectSelectorItem;
private RoleSubjectSelector subjectSelector;
- private Window editorWindow;
+ private RolesDataSource dataSource;
public RoleEditView(String locatorId) {
super(locatorId);
- setPadding(10);
- setOverflow(Overflow.AUTO);
-
- addMember(message);
-
- addMember(buildRoleForm());
-
- editCanvas.hide();
- }
-
- private Canvas buildRoleForm() {
- this.editCanvas = new VLayout();
- this.editCanvas.setWidth100();
- this.editCanvas.setHeight100();
+ this.dataSource = RolesDataSource.getInstance();
- editLabel = new HeaderLabel("Create User");
- // TODO create header css style and set
+ this.setPadding(10);
+ setOverflow(Overflow.AUTO);
- editCanvas.addMember(editLabel);
+ buildRoleEditor();
+ this.editCanvas.hide();
- form = new LocatableDynamicForm(extendLocatorId("RoleForm"));
- form.setWidth100();
+ this.addMember(message);
+ this.addMember(editCanvas);
+ }
- form.setDataSource(RolesDataSource.getInstance());
+ private Canvas buildRoleEditor() {
+ form = new LocatableDynamicForm(extendLocatorId(this.getLocatorId()));
- TextItem idItem = new TextItem("id", "Id");
+ form.setHiliteRequiredFields(true);
+ form.setRequiredTitleSuffix("* :");
- TextItem nameItem = new TextItem("name", "Name");
+ form.setDataSource(this.dataSource);
+ form.setUseAllDataSourceFields(true);
- permissionEditorItem = new PermissionEditorView("permissionEditor", "Permissions");
+ permissionEditorItem = new PermissionEditorView(this.getLocatorId(), "permissionsEditor", "Permissions");
permissionEditorItem.setShowTitle(false);
permissionEditorItem.setColSpan(2);
groupSelectorItem = new CanvasItem("groupSelectionCanvas", "Assigned Resource Groups");
- groupSelectorItem.setCanvas(new Label("loading...")); //new RoleResourceGroupSelector(null));
groupSelectorItem.setTitleOrientation(TitleOrientation.TOP);
groupSelectorItem.setColSpan(2);
subjectSelectorItem = new CanvasItem("subjectSelectionCanvas", "Assigned Subjects");
- subjectSelectorItem.setCanvas(new Label("loading...")); //new RoleSubjectSelector(null));
subjectSelectorItem.setTitleOrientation(TitleOrientation.TOP);
subjectSelectorItem.setColSpan(2);
- SubmitItem saveButton = new SubmitItem("save", "Save");
-
- saveButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- save();
- System.out.println("Save is done");
+ IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
+ saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ if (form.validate()) {
+ save();
+ }
}
});
- form.addSubmitValuesHandler(new SubmitValuesHandler() {
- public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
- Object o = submitValuesEvent.getValues();
- System.out.println("O: " + o);
+ IButton resetButton = new LocatableIButton(this.extendLocatorId("Reset"), "Reset");
+ resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ form.reset();
}
});
- form.setItems(idItem, nameItem, permissionEditorItem, groupSelectorItem, subjectSelectorItem, saveButton,
- new ResetItem("reset", "Reset"));
-
- editCanvas.addMember(form);
-
- return editCanvas;
- }
-
- public void editRecord(Record record) {
- this.roleBeingEdited = (Role) record.getAttributeAsObject("entity");
- message.hide();
- editCanvas.show();
- try {
- editLabel.setContents("Editing Role " + record.getAttribute("name"));
- form.editRecord(record);
- permissionEditorItem.setParentForm(form);
- permissionEditorItem.setPermissions((Set<Permission>) record.getAttributeAsObject("permissions"));
-
- groupSelector = new RoleResourceGroupSelector("RoleEditor-Groups", (Collection<ResourceGroup>) record
- .getAttributeAsObject("resourceGroups"));
- groupSelectorItem.setCanvas(groupSelector);
-
- subjectSelector = new RoleSubjectSelector("RoleEditor-Subjects", (Collection<Subject>) record
- .getAttributeAsObject("subjects"));
- subjectSelectorItem.setCanvas(subjectSelector);
-
- } catch (Throwable t) {
- t.printStackTrace();
- }
- // markForRedraw();
- }
+ IButton cancelButton = new LocatableIButton(this.extendLocatorId("Cancel"), "Cancel");
+ cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ History.back();
+ }
+ });
- public void editNone() {
- message.show();
- editCanvas.hide();
+ HLayout buttonLayout = new HLayout(10);
+ buttonLayout.setAlign(Alignment.CENTER);
+ buttonLayout.addMember(saveButton);
+ buttonLayout.addMember(resetButton);
+ buttonLayout.addMember(cancelButton);
- // markForRedraw();
- }
+ form.setItems(permissionEditorItem, groupSelectorItem, subjectSelectorItem);
- public void editNew() {
- ListGridRecord r = RolesDataSource.getInstance().copyValues(new Role());
- editRecord(r);
- form.setSaveOperationType(DSOperationType.ADD);
-
- editLabel.setContents("Create Role");
+ this.editCanvas = new VLayout();
- editorWindow = new Window();
- editorWindow.setTitle("Create Role");
- editorWindow.setWidth(800);
- editorWindow.setHeight(800);
- editorWindow.setIsModal(true);
- editorWindow.setShowModalMask(true);
- editorWindow.setCanDragResize(true);
- editorWindow.centerInPage();
- editorWindow.addItem(this);
- editorWindow.show();
+ editCanvas.addMember(form);
+ editCanvas.addMember(buttonLayout);
+ return editCanvas;
}
public void save() {
+ final HashSet<Integer> groupSelection = this.groupSelector.getSelection();
+ final HashSet<Integer> userSelection = this.subjectSelector.getSelection();
- System.out.println("Saving role");
+ // The form.saveData() call triggers either RolesDataSource.executeAdd() to create the new Role,
+ // or executeUpdate() if saving changes to an existing Role. On success we need to perform the
+ // subsequent user or group assignment, so set this callback on completion.
form.saveData(new DSCallback() {
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
- HashSet<Integer> selection = groupSelector.getSelection();
- int[] groupIds = new int[selection.size()];
+
+ int roleId = Integer.parseInt(new ListGridRecord(dsRequest.getData()).getAttribute("id"));
+
+ int[] groupIds = new int[groupSelection.size()];
int i = 0;
- for (Integer id : selection) {
+ for (Integer id : groupSelection) {
groupIds[i++] = id;
}
- int roleId;
- if (roleBeingEdited != null && roleBeingEdited.getId() != null) {
- roleId = roleBeingEdited.getId();
- } else {
- // new role
- roleId = Integer.parseInt(new ListGridRecord(dsRequest.getData()).getAttribute("id"));
- }
-
GWTServiceLookup.getRoleService().setAssignedResourceGroups(roleId, groupIds,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to update role's assigned groups", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to save role group assignments.", caught);
}
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
- new Message("Updated assigned groups", Message.Severity.Info));
+ new Message("Succesfully saved role group assignments.", Message.Severity.Info));
}
});
- HashSet<Integer> selectedSubjects = subjectSelector.getSelection();
- int[] subjectIds = new int[selectedSubjects.size()];
+ int[] subjectIds = new int[userSelection.size()];
i = 0;
- for (Integer id : selectedSubjects) {
+ for (Integer id : userSelection) {
subjectIds[i++] = id;
}
GWTServiceLookup.getRoleService().setAssignedSubjects(roleId, subjectIds, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to update role's assigned subjects", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to save role user assignments.", caught);
+ History.back();
}
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
- new Message("Updated role assigned subjects", Message.Severity.Info));
+ new Message("Succesfully saved role user assignments.", Message.Severity.Info));
+ History.back();
}
});
-
- if (editorWindow != null) {
- editorWindow.destroy();
- }
}
});
}
- public DynamicForm getForm() {
- return form;
+ @SuppressWarnings("unchecked")
+ public void editRecord(Record record) {
+ this.groupSelector = new RoleResourceGroupSelector(this.extendLocatorId("Groups"), (Set<ResourceGroup>) record
+ .getAttributeAsObject("resourceGroups"));
+ this.subjectSelector = new RoleSubjectSelector(this.extendLocatorId("Subjects"), (Set<Subject>) record
+ .getAttributeAsObject("subjects"));
+
+ this.groupSelectorItem.setCanvas(this.groupSelector);
+ this.subjectSelectorItem.setCanvas(this.subjectSelector);
+
+ Set<Permission> permissions = (Set<Permission>) record.getAttributeAsObject("permissions");
+ this.permissionEditorItem.setPermissions(permissions);
+
+ try {
+ form.editRecord(record);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ message.hide();
+ editCanvas.show();
+ form.setSaveOperationType(DSOperationType.UPDATE);
+ }
+
+ private void editNewInternal() {
+ role = new Role();
+ ListGridRecord r = dataSource.copyValues(role);
+ editRecord(r);
+
+ // This tells form.saveData() to call RolesDataSource.executeAdd() on the new Role's ListGridRecord
+ form.setSaveOperationType(DSOperationType.ADD);
+ }
+
+ public static void editNew(String locatorId) {
+ RoleEditView editView = new RoleEditView(locatorId);
+ editView.editNewInternal();
+ }
+
+ private void editRole(int roleId, final ViewId current) {
+
+ final int id = Integer.valueOf(current.getBreadcrumbs().get(0).getName());
+
+ if (id > 0) {
+ RoleCriteria criteria = new RoleCriteria();
+ criteria.addFilterId(id);
+ criteria.fetchPermissions(true);
+ criteria.fetchResourceGroups(true);
+ criteria.fetchSubjects(true);
+
+ GWTServiceLookup.getRoleService().findRolesByCriteria(criteria, new AsyncCallback<PageList<Role>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load role for editing", caught);
+ }
+
+ @Override
+ public void onSuccess(PageList<Role> result) {
+ Role role = result.get(0);
+ Record record = new RolesDataSource().copyValues(role);
+ editRecord(record);
+
+ current.getBreadcrumbs().get(0).setDisplayName("Editing: " + role.getName());
+ CoreGUI.refreshBreadCrumbTrail();
+ }
+ });
+ } else {
+ editNewInternal();
+ current.getBreadcrumbs().get(0).setDisplayName("New Role");
+ CoreGUI.refreshBreadCrumbTrail();
+ }
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ int roleId = viewPath.getCurrentAsInt();
+
+ editRole(roleId, viewPath.getCurrent());
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java
deleted file mode 100644
index 59ebf1c..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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 as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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 for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.admin.roles;
-
-import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
-
-import com.smartgwt.client.types.DragDataAction;
-import com.smartgwt.client.types.DragTrackerMode;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.TransferImgButton;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VStack;
-
-/**
- * @author Greg Hinkle
- */
-public class RoleGroupsEditorItem extends CanvasItem {
-
- private PageList<ResourceGroup> assignedGroups;
-
- private ListGrid assignedGroupGrid;
- private ListGrid availableGroupGrid;
-
- public RoleGroupsEditorItem(String name, String title) {
- super(name, title);
- setCanvas(new SimpleCollapsiblePanel("Assigned Groups", buildForm()));
- }
-
- private Canvas buildForm() {
-
- HLayout layout = new HLayout(10);
-
- availableGroupGrid = new ListGrid();
- availableGroupGrid.setHeight(350);
- availableGroupGrid.setCanDragRecordsOut(true);
- availableGroupGrid.setDragTrackerMode(DragTrackerMode.RECORD);
- availableGroupGrid.setDragDataAction(DragDataAction.MOVE);
- availableGroupGrid.setDataSource(ResourceGroupsDataSource.getInstance());
- availableGroupGrid.setAutoFetchData(true);
- availableGroupGrid.setFields(new ListGridField("id",50), new ListGridField("name"));
-
- layout.addMember(availableGroupGrid);
-
- VStack moveButtonStack = new VStack(10);
- moveButtonStack.setWidth(50);
-
- TransferImgButton addButton = new TransferImgButton(TransferImgButton.RIGHT);
- TransferImgButton removeButton = new TransferImgButton(TransferImgButton.LEFT);
- TransferImgButton addAllButton = new TransferImgButton(TransferImgButton.RIGHT_ALL);
- TransferImgButton removeAllButton = new TransferImgButton(TransferImgButton.LEFT_ALL);
-
- moveButtonStack.addMember(addButton);
- moveButtonStack.addMember(removeButton);
- moveButtonStack.addMember(addAllButton);
- moveButtonStack.addMember(removeAllButton);
-
- layout.addMember(moveButtonStack);
-
- assignedGroupGrid = new ListGrid();
- assignedGroupGrid.setHeight(350);
- assignedGroupGrid.setCanDragRecordsOut(true);
- assignedGroupGrid.setCanAcceptDroppedRecords(true);
- assignedGroupGrid.setDataSource(ResourceGroupsDataSource.getInstance());
- assignedGroupGrid.setFields(new ListGridField("id", 50), new ListGridField("name"));
-
- layout.addMember(assignedGroupGrid);
-
-
- return layout;
- }
-
- public void setGroups(PageList<ResourceGroup> assignedGroups) {
- this.assignedGroups = assignedGroups;
-
- assignedGroupGrid.setData(ResourceGroupsDataSource.getInstance().buildRecords(assignedGroups));
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java
index 12f5fde..8190d3f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java
@@ -35,8 +35,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.Resour
*/
public class RoleResourceGroupSelector extends ResourceGroupSelector {
- public RoleResourceGroupSelector(String id, Collection<ResourceGroup> groups) {
- super(id);
+ public RoleResourceGroupSelector(String locatorId, Collection<ResourceGroup> groups) {
+ super(locatorId);
if (groups != null) {
ListGridRecord[] data = (new ResourceGroupsDataSource()).buildRecords(groups);
setAssigned(data);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
index 42e4b2f..8cbf180 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
@@ -47,18 +47,18 @@ public class RoleSubjectSelector extends AbstractSelector<Subject> {
}
@Override
- protected DynamicForm getAvailableFilterForm() {
- return null; // TODO: Implement this method.
+ protected RPCDataSource<Subject> getDataSource() {
+ return new SelectedSubjectsDataSource();
}
@Override
- protected RPCDataSource<Subject> getDataSource() {
- return new SelectedSubjectsDataSource();
+ protected DynamicForm getAvailableFilterForm() {
+ return null; // No Filters Currently
}
@Override
protected Criteria getLatestCriteria(DynamicForm availableFilterForm) {
- return null; // TODO: Implement this method.
+ return null; // No Filters Currently
}
public class SelectedSubjectsDataSource extends UsersDataSource {
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 5ddbde2..3b9aafb 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
@@ -64,12 +64,11 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
public RolesDataSource() {
-
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
- DataSourceTextField nameField = new DataSourceTextField("name", "Name");
+ DataSourceTextField nameField = new DataSourceTextField("name", "Name", 100, true);
setFields(idDataField, nameField);
}
@@ -97,9 +96,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
public void onSuccess(PageList<Role> result) {
-
- System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start));
-
response.setData(buildRecords(result));
response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
processResponse(request.getRequestId(), response);
@@ -118,7 +114,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
Map<String, String> errors = new HashMap<String, String>();
errors.put("name", "A role with name already exists.");
response.setErrors(errors);
- // CoreGUI.getErrorHandler().handleError("Failed to create role",caught);
response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR);
processResponse(request.getRequestId(), response);
}
@@ -137,7 +132,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
@Override
protected void executeUpdate(final DSRequest request, final DSResponse response) {
final ListGridRecord record = getEditedRecord(request);
- System.out.println("Updating record: " + record);
Role updatedRole = copyValues(record);
roleService.updateRole(updatedRole, new AsyncCallback<Role>() {
public void onFailure(Throwable caught) {
@@ -147,7 +141,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
public void onSuccess(Role result) {
CoreGUI.getMessageCenter().notify(
new Message("Role [" + result.getName() + "] updated", Message.Severity.Info));
- System.out.println("Role Updated");
response.setData(new Record[] { copyValues(result) });
processResponse(request.getRequestId(), response);
}
@@ -168,7 +161,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
new Message("Role [" + newRole.getName() + "] removed", Message.Severity.Info));
- System.out.println("Role deleted");
response.setData(new Record[] { rec });
processResponse(request.getRequestId(), response);
}
@@ -176,12 +168,12 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
+ @SuppressWarnings("unchecked")
public Role copyValues(ListGridRecord from) {
Role to = new Role();
to.setId(from.getAttributeAsInt("id"));
to.setName(from.getAttributeAsString("name"));
- // to.setDate (from.getAttributeAsDate ("date"));
- // from.getAttributeAsIntArray("resourceGroups");
+
to.setResourceGroups((Set<ResourceGroup>) from.getAttributeAsObject("resourceGroups"));
to.setPermissions((Set<Permission>) from.getAttributeAsObject("permissions"));
to.setSubjects((Set<Subject>) from.getAttributeAsObject("subjects"));
@@ -192,6 +184,7 @@ public class RolesDataSource extends RPCDataSource<Role> {
ListGridRecord to = new ListGridRecord();
to.setAttribute("id", from.getId());
to.setAttribute("name", from.getName());
+
to.setAttribute("resourceGroups", from.getResourceGroups());
to.setAttribute("permissions", from.getPermissions());
to.setAttribute("subjects", from.getSubjects());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
index 55d5bb7..a9ea8b3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
@@ -22,7 +22,6 @@ import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
@@ -52,26 +51,15 @@ public class RolesView extends TableSection implements BookmarkableView {
addTableAction(extendLocatorId("New"), "New", new TableAction() {
public void executeAction(ListGridRecord[] selection) {
- createRole();
+ newDetails();
}
});
}
- public void createRole() {
- RoleEditView editView = new RoleEditView(extendLocatorId("Edit"));
-
- editView.editNew();
- }
-
@Override
public Canvas getDetailsView(int id) {
RoleEditView editor = new RoleEditView(extendLocatorId("Detail"));
return editor;
}
-
- public void renderView(ViewPath viewPath) {
-
- System.out.println("Display role list");
- }
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java
deleted file mode 100644
index 38f0e7a..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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 as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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 for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.admin.users;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Role;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesDataSource;
-import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
-
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.DSOperationType;
-import com.smartgwt.client.types.DragDataAction;
-import com.smartgwt.client.types.DragTrackerMode;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.TransferImgButton;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VStack;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Greg Hinkle
- */
-public class SubjectRolesEditorItem extends CanvasItem {
-
- private Set<Role> assignedRoles;
- private Subject subject;
-
- private ListGrid assignedRoleGrid;
- private ListGrid availableRoleGrid;
-
- public SubjectRolesEditorItem(String name, String title) {
- super(name, title);
- setShowTitle(false);
- setColSpan(2);
-// setWidth("90%");
- setCanvas(new SimpleCollapsiblePanel("Assigned Roles", buildForm()));
- }
-
- private Canvas buildForm() {
-
- HLayout layout = new HLayout(10);
-
- availableRoleGrid = new ListGrid();
- availableRoleGrid.setHeight(250);
- availableRoleGrid.setCanDragRecordsOut(true);
- availableRoleGrid.setDragTrackerMode(DragTrackerMode.RECORD);
- availableRoleGrid.setDragDataAction(DragDataAction.MOVE);
- availableRoleGrid.setDataSource(RolesDataSource.getInstance());
- availableRoleGrid.setAutoFetchData(true);
- availableRoleGrid.setFields(new ListGridField("id", 50), new ListGridField("name"));
-
- layout.addMember(availableRoleGrid);
-
- VStack moveButtonStack = new VStack(10);
- moveButtonStack.setWidth(50);
-
- TransferImgButton addButton = new TransferImgButton(TransferImgButton.RIGHT);
- TransferImgButton removeButton = new TransferImgButton(TransferImgButton.LEFT);
- TransferImgButton addAllButton = new TransferImgButton(TransferImgButton.RIGHT_ALL);
- TransferImgButton removeAllButton = new TransferImgButton(TransferImgButton.LEFT_ALL);
-
- moveButtonStack.addMember(addButton);
- moveButtonStack.addMember(removeButton);
- moveButtonStack.addMember(addAllButton);
- moveButtonStack.addMember(removeAllButton);
-
- layout.addMember(moveButtonStack);
-
- assignedRoleGrid = new ListGrid();
- assignedRoleGrid.setHeight(250);
- assignedRoleGrid.setCanDragRecordsOut(true);
- assignedRoleGrid.setCanAcceptDroppedRecords(true);
-// assignedRoleGrid.setDataSource(RolesDataSource.getInstance());
- assignedRoleGrid.setFields(new ListGridField("id", 50), new ListGridField("name"));
-
- layout.addMember(assignedRoleGrid);
-
-
- return layout;
- }
-
- public void setRoles(Set<Role> assignedRoles) {
- this.assignedRoles = assignedRoles;
-
- assignedRoleGrid.setData(RolesDataSource.getInstance().buildRecords(assignedRoles));
- }
-
- public Set<Role> getRoles() {
- return this.assignedRoles;
- }
-
- public Subject getSubject() {
- return subject;
- }
-
- public void setSubject(Subject subject) {
- this.subject = subject;
- if (subject != null) {
- assignedRoleGrid.setCriteria(new Criteria("subjectId", String.valueOf(subject.getId())));
- }
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index bd13da7..279fa33 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -29,13 +29,13 @@ import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DSOperationType;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.SectionItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.HLayout;
@@ -60,19 +60,16 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class UserEditView extends LocatableVLayout implements BookmarkableView {
- private Label message = new Label("Select a user to edit...");
-
- // private SubjectRolesEditorItem subjectRolesEditorItem ;
+ private Label message = new Label("Loading...");
private VLayout editCanvas;
private DynamicForm form;
- CanvasItem roleSelectionItem;
-
private UsersDataSource dataSource;
private Subject subject;
+ private CanvasItem roleSelectionItem;
private SubjectRoleSelector roleSelector;
public UserEditView(String locatorId) {
@@ -80,15 +77,13 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
dataSource = UsersDataSource.getInstance();
- setWidth100();
- setHeight100();
+ setOverflow(Overflow.AUTO);
buildSubjectEditor();
editCanvas.hide();
addMember(message);
addMember(editCanvas);
-
}
private Canvas buildSubjectEditor() {
@@ -98,12 +93,10 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
form.setHiliteRequiredFields(true);
form.setRequiredTitleSuffix("* :");
- SectionItem userEditSection = new SectionItem("userEditSection", "Edit User");
-
- form.setUseAllDataSourceFields(true);
form.setDataSource(dataSource);
+ form.setUseAllDataSourceFields(true);
- this.roleSelectionItem = new CanvasItem("selectRoles", "Select Roles");
+ this.roleSelectionItem = new CanvasItem("selectRoles", "Assigned Roles");
this.roleSelectionItem.setTitleOrientation(TitleOrientation.TOP);
this.roleSelectionItem.setColSpan(2);
@@ -152,8 +145,10 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
public void save() {
final HashSet<Integer> roles = roleSelector.getSelection();
- // The form.saveData() call triggers UsersDataSource.executeAdd() to create the new Subject. On
- // successful create we need to perform the role assignment, so set this callback on completion.
+
+ // The form.saveData() call triggers either UsersDataSource.executeAdd() to create the new Subject,
+ // or executeUpdate() if saving changes to an existing Subject. On success we need to perform the
+ // subsequent role assignment, so set this callback on completion.
form.saveData(new DSCallback() {
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
@@ -168,21 +163,21 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
GWTServiceLookup.getRoleService().setAssignedSubjectRoles(subjectId, roleIds,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to set subject role assignments.", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to save user role assignments.", caught);
History.back();
}
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
- new Message("Succesfully saved new user roles.", Message.Severity.Info));
+ new Message("Succesfully saved user role assignments.", Message.Severity.Info));
History.back();
}
});
-
}
});
}
+ @SuppressWarnings("unchecked")
public void editRecord(Record record) {
roleSelector = new SubjectRoleSelector(this.extendLocatorId("Roles"), (Set<Role>) record
.getAttributeAsObject("roles"));
@@ -200,13 +195,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
markForRedraw();
}
- public void editNone() {
- message.show();
- editCanvas.hide();
- markForRedraw();
- }
-
- public void editNewInternal() {
+ private void editNewInternal() {
subject = new Subject();
ListGridRecord r = dataSource.copyValues(subject);
editRecord(r);
@@ -247,6 +236,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
CoreGUI.refreshBreadCrumbTrail();
}
});
+
} else {
editNewInternal();
current.getBreadcrumbs().get(0).setDisplayName("New User");
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 809edec..470b144 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
@@ -97,11 +97,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
- DataSourceField roles = new DataSourceField();
- roles.setForeignKey("Roles.id");
- roles.setName("roles");
- roles.setMultiple(true);
-
setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress,
department);
}
@@ -121,16 +116,7 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
public void onSuccess(PageList<Subject> result) {
- System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start));
-
- ListGridRecord[] records = new ListGridRecord[result.size()];
- for (int x = 0; x < result.size(); x++) {
- Subject subject = result.get(x);
-
- records[x] = copyValues(subject);
- }
-
- response.setData(records);
+ response.setData(buildRecords(result));
response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
processResponse(request.getRequestId(), response);
}
@@ -177,7 +163,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
@Override
protected void executeUpdate(final DSRequest request, final DSResponse response) {
final ListGridRecord record = getEditedRecord(request);
- System.out.println("Updating record: " + record);
final Subject updatedSubject = copyValues(record);
subjectService.updateSubject(updatedSubject, new AsyncCallback<Subject>() {
public void onFailure(Throwable caught) {
@@ -202,7 +187,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
});
} else {
- System.out.println("Subject Updated");
CoreGUI.getMessageCenter().notify(
new Message("User [" + result.getName() + "] updated", Message.Severity.Info));
response.setData(new Record[] { copyValues(result) });
@@ -233,6 +217,7 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
+ @SuppressWarnings("unchecked")
public Subject copyValues(ListGridRecord from) {
Subject to = new Subject();
to.setId(from.getAttributeAsInt("id"));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index 72e2aa7..e1de74d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -32,7 +32,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
public class UsersView extends TableSection {
public UsersView(String locatorId) {
- super(locatorId, "Users View");
+ super(locatorId, "Users");
final UsersDataSource datasource = UsersDataSource.getInstance();
@@ -43,8 +43,6 @@ public class UsersView extends TableSection {
protected void configureTable() {
final ListGrid grid = getListGrid();
- grid.getField("id").setWidth(20);
- grid.getField("name").setWidth(100);
grid.hideField("password");
grid.hideField("passwordVerify");
@@ -64,6 +62,7 @@ public class UsersView extends TableSection {
public Canvas getDetailsView(int id) {
final UserEditView userEditor = new UserEditView(extendLocatorId("Detail"));
+
return userEditor;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java
index cb09a01..ed9163d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java
@@ -26,24 +26,23 @@ import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;
/**
+ * TODO: Not Quite Working. For some reason the icon is not clickable.
+ *
* @author Greg Hinkle
*/
public class SimpleCollapsiblePanel extends VLayout {
-
private Canvas content;
private String title;
private boolean expanded = true;
-
public SimpleCollapsiblePanel(String title, Canvas content) {
this.content = content;
this.title = title;
setWidth100();
}
-
@Override
protected void onInit() {
super.onInit();
@@ -51,12 +50,11 @@ public class SimpleCollapsiblePanel extends VLayout {
final Button button = new Button(title);
button.setShowRollOver(false);
button.setActionType(SelectionType.RADIO);
- button.setBorder(null);
+ //button.setBorder(null);
button.setAutoFit(true);
-
button.setIcon("[skin]/images/SectionHeader/opener_opened.png");
- button.setBaseStyle("SimpleButton");
+ //button.setBaseStyle("SimpleButton");
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
@@ -74,7 +72,6 @@ public class SimpleCollapsiblePanel extends VLayout {
}
});
-
addMember(button);
addMember(content);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index 1617a2d..1c8774f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -129,6 +129,9 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
@Override
public void run() {
if (latestCriteria != null) {
+ // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
+ availableGrid.invalidateCache();
+
Criteria c = latestCriteria;
latestCriteria = null;
availableGrid.fetchData(c);
@@ -144,12 +147,12 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
moveButtonStack.setAlign(VerticalAlignment.CENTER);
moveButtonStack.setWidth(40);
- addButton = new LocatableTransferImgButton(TransferImgButton.RIGHT);
+ addButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.RIGHT);
addButton.setDisabled(true);
- removeButton = new LocatableTransferImgButton(TransferImgButton.LEFT);
+ removeButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.LEFT);
removeButton.setDisabled(true);
- addAllButton = new LocatableTransferImgButton(TransferImgButton.RIGHT_ALL);
- removeAllButton = new LocatableTransferImgButton(TransferImgButton.LEFT_ALL);
+ addAllButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.RIGHT_ALL);
+ removeAllButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.LEFT_ALL);
removeAllButton.setDisabled(true);
moveButtonStack.addMember(addButton);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index 9bd3a6a..a1303a1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -79,8 +79,9 @@ public abstract class TableSection extends Table implements BookmarkableView {
super.onInit();
detailsHolder = new VLayout();
- detailsHolder.setWidth100();
- detailsHolder.setHeight100();
+ //detailsHolder.setWidth100();
+ //detailsHolder.setHeight100();
+ detailsHolder.setMargin(5);
detailsHolder.hide();
addMember(detailsHolder);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index 9de2407..00e9389 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -42,8 +42,6 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*/
public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
- private String query;
-
private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
private static ResourceGroupsDataSource INSTANCE;
@@ -85,14 +83,12 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
groupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load groups", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to fetch groups data", caught);
response.setStatus(RPCResponse.STATUS_FAILURE);
processResponse(request.getRequestId(), response);
}
public void onSuccess(PageList<ResourceGroup> result) {
- System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start));
-
response.setData(buildRecords(result));
response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
processResponse(request.getRequestId(), response);
@@ -104,7 +100,10 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.setPageControl(getPageControl(request));
- criteria.addFilterName(query);
+
+ if (request.getCriteria().getValues().get("name") != null) {
+ criteria.addFilterName((String) request.getCriteria().getValues().get("name"));
+ }
if (request.getCriteria().getValues().get("category") != null) {
criteria.addFilterGroupCategory(GroupCategory.valueOf(((String) request.getCriteria().getValues().get(
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
index f2f15dc..c983dee 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -21,29 +21,33 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection;
import java.util.Collection;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
*/
public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
- public ResourceGroupSelector(String id) {
- super(id);
+ public ResourceGroupSelector(String locatorId) {
+ super(locatorId);
}
protected DynamicForm getAvailableFilterForm() {
- DynamicForm availableFilterForm = new DynamicForm();
- availableFilterForm.setNumCols(5);
+ DynamicForm availableFilterForm = new LocatableDynamicForm(this.getLocatorId());
+ availableFilterForm.setWidth100();
+ availableFilterForm.setNumCols(4);
final TextItem search = new TextItem("search", "Search");
@@ -61,7 +65,7 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
// TODO: Until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed, avoid AdvancedCriteria and always
// use server-side fetch and simple criteria. When fixed, use the commented version below. Also see
- // ResourceGroupDataSource.
+ // AbstractSelector and ResourceGroupDataSource.
protected Criteria getLatestCriteria(DynamicForm availableFilterForm) {
String search = (String) availableFilterForm.getValue("search");
String category = (String) availableFilterForm.getValue("groupCategory");
@@ -104,5 +108,15 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
}
return records;
}
+
+ @Override
+ protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) {
+ ResourceGroupCriteria result = super.getFetchCriteria(request);
+ if (null != result) {
+ result.setStrict(false);
+ }
+ return result;
+ }
+
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
index e255096..efbd818 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
@@ -7,28 +7,22 @@ import com.smartgwt.client.widgets.TransferImgButton;
*
* @author Jay Shaughnessy
*/
-public class LocatableTransferImgButton extends TransferImgButton {
+public class LocatableTransferImgButton extends TransferImgButton implements Locatable {
- /**
- * <pre>
- * ID Format: "simpleClassname-imgName"
- * </pre>
- * @param img not null.
- */
- public LocatableTransferImgButton(TransferImg img) {
- this(getSuffix(img), img);
- }
+ private String locatorId;
/**
* <pre>
- * ID Format: "simpleClassname_locatorId"
+ * ID Format: "simpleClassname_locatorId_imgName"
* </pre>
* @param locatorId not null.
* @param img not null or empty.
*/
public LocatableTransferImgButton(String locatorId, TransferImg img) {
super(img);
- SeleniumUtility.setID(this, locatorId);
+ this.locatorId = locatorId;
+ this.locatorId = extendLocatorId(getSuffix(img));
+ SeleniumUtility.setID(this, this.locatorId);
}
static private String getSuffix(TransferImg img) {
@@ -54,4 +48,12 @@ public class LocatableTransferImgButton extends TransferImgButton {
return img.toString();
}
+ public String getLocatorId() {
+ return locatorId;
+ }
+
+ public String extendLocatorId(String extension) {
+ return this.locatorId + "_" + extension;
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
index 7770cba..aeac399 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
@@ -66,6 +66,9 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
private EntityManager entityManager;
@EJB
+ private RoleManagerLocal roleManager; // self-referencing
+
+ @EJB
private SubjectManagerLocal subjectManager;
@EJB
@@ -262,7 +265,6 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
return;
}
-
@RequiredPermission(Permission.MANAGE_SECURITY)
public void setAssignedSubjectRoles(Subject subject, int subjectId, int[] roleIds) {
@@ -280,23 +282,21 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
for (Integer id : newRoles) {
newRoleIds[i++] = id;
}
- addRolesToSubject(subject, subjectId, newRoleIds);
+ roleManager.addRolesToSubject(subject, subjectId, newRoleIds);
}
- List<Integer> extraMembers = new ArrayList<Integer>(currentRoles); // members needing removal
- extraMembers.removeAll(ArrayUtils.wrapInList(roleIds));
- if (extraMembers.size() > 0) {
- int[] extraMemberIds = new int[extraMembers.size()];
+ List<Integer> removedRoles = new ArrayList<Integer>(currentRoles); // members needing removal
+ removedRoles.removeAll(ArrayUtils.wrapInList(roleIds));
+ if (removedRoles.size() > 0) {
+ int[] removedRoleIds = new int[removedRoles.size()];
int i = 0;
- for (Integer id : extraMembers) {
- extraMemberIds[i++] = id;
+ for (Integer id : removedRoles) {
+ removedRoleIds[i++] = id;
}
- removeRolesFromSubject(subject, subjectId, extraMemberIds);
+ roleManager.removeRolesFromSubject(subject, subjectId, removedRoleIds);
}
}
-
-
/**
* @see org.rhq.enterprise.server.authz.RoleManagerLocal#getRoleById(Integer)
*/
@@ -491,32 +491,32 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
public void setAssignedResourceGroups(Subject subject, int roleId, int[] groupIds) {
Role role = getRole(subject, roleId);
- List<Integer> currentMembers = new ArrayList<Integer>();
+ List<Integer> currentGroups = new ArrayList<Integer>();
for (ResourceGroup group : role.getResourceGroups()) {
- currentMembers.add(group.getId());
+ currentGroups.add(group.getId());
}
- List<Integer> newMembers = ArrayUtils.wrapInList(groupIds); // members needing addition
- newMembers.removeAll(currentMembers);
- if (newMembers.size() > 0) {
- int[] newMemberInts = new int[newMembers.size()];
+ List<Integer> newGroups = ArrayUtils.wrapInList(groupIds); // members needing addition
+ newGroups.removeAll(currentGroups);
+ if (newGroups.size() > 0) {
+ int[] newGroupIds = new int[newGroups.size()];
int i = 0;
- for (Integer id : newMembers) {
- newMemberInts[i++] = id;
+ for (Integer id : newGroups) {
+ newGroupIds[i++] = id;
}
- addResourceGroupsToRole(subject, roleId, newMemberInts);
+ roleManager.addResourceGroupsToRole(subject, roleId, newGroupIds);
}
- List<Integer> extraMembers = new ArrayList<Integer>(currentMembers); // members needing removal
- extraMembers.removeAll(ArrayUtils.wrapInList(groupIds));
- if (extraMembers.size() > 0) {
- int[] removeMemberInts = new int[extraMembers.size()];
+ List<Integer> removedGroups = new ArrayList<Integer>(currentGroups); // members needing removal
+ removedGroups.removeAll(ArrayUtils.wrapInList(groupIds));
+ if (removedGroups.size() > 0) {
+ int[] removedGroupIds = new int[removedGroups.size()];
int i = 0;
- for (Integer id : extraMembers) {
- removeMemberInts[i++] = id;
+ for (Integer id : removedGroups) {
+ removedGroupIds[i++] = id;
}
- removeResourceGroupsFromRole(subject, roleId, removeMemberInts);
+ roleManager.removeResourceGroupsFromRole(subject, roleId, removedGroupIds);
}
}
@@ -564,32 +564,33 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
@RequiredPermission(Permission.MANAGE_SECURITY)
public void setAssignedSubjects(Subject subject, int roleId, int[] subjectIds) {
+
Role role = getRole(subject, roleId);
- List<Integer> currentMembers = new ArrayList<Integer>();
- for (ResourceGroup group : role.getResourceGroups()) {
- currentMembers.add(group.getId());
+ List<Integer> currentSubjects = new ArrayList<Integer>();
+ for (Subject currentSubject : role.getSubjects()) {
+ currentSubjects.add(currentSubject.getId());
}
- List<Integer> newMembers = ArrayUtils.wrapInList(subjectIds); // members needing addition
- newMembers.removeAll(currentMembers);
- if (newMembers.size() > 0) {
- int[] newMemberIds = new int[newMembers.size()];
+ List<Integer> newSubjects = ArrayUtils.wrapInList(subjectIds); // members needing addition
+ newSubjects.removeAll(currentSubjects);
+ if (newSubjects.size() > 0) {
+ int[] newSubjectIds = new int[newSubjects.size()];
int i = 0;
- for (Integer id : newMembers) {
- newMemberIds[i++] = id;
+ for (Integer id : newSubjects) {
+ newSubjectIds[i++] = id;
}
- addSubjectsToRole(subject, roleId, newMemberIds);
+ roleManager.addSubjectsToRole(subject, roleId, newSubjectIds);
}
- List<Integer> extraMembers = new ArrayList<Integer>(currentMembers); // members needing removal
- extraMembers.removeAll(ArrayUtils.wrapInList(subjectIds));
- if (extraMembers.size() > 0) {
- int[] removeMemberIds = new int[extraMembers.size()];
+ List<Integer> removedSubjects = new ArrayList<Integer>(currentSubjects); // members needing removal
+ removedSubjects.removeAll(ArrayUtils.wrapInList(subjectIds));
+ if (removedSubjects.size() > 0) {
+ int[] removedSubjectIds = new int[removedSubjects.size()];
int i = 0;
- for (Integer id : extraMembers) {
- removeMemberIds[i++] = id;
+ for (Integer id : removedSubjects) {
+ removedSubjectIds[i++] = id;
}
- removeSubjectsFromRole(subject, roleId, removeMemberIds);
+ roleManager.removeSubjectsFromRole(subject, roleId, removedSubjectIds);
}
}
commit fc50175d9159e90c52b8839283d7baba4323336e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Sep 13 20:46:27 2010 -0400
enable server side operations portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index ce381ce..54647a1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -64,14 +64,15 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
private static final String TITLE = KEY;
private static String recentOperations = "Recent Operations";
private static String scheduledOperations = "Scheduled Operations";
- private boolean operationsRangeLastEnabled = false;
- private boolean operationsRangeNextEnabled = false;
- private int operationsRangeScheduled = -1;
- private int operationsRangeCompleted = -1;
+ public static String RANGE_DISABLED_MESSAGE = "(Results currently disabled. Change settings to enable results.)";
+ //TODO: change this to use the Smart GWT default value.
+ public static String RANGE_DISABLED_MESSAGE_DEFAULT = "No items to show.";
//ListGrids for operations
private LocatableListGrid recentOperationsGrid = null;
private LocatableListGrid scheduledOperationsGrid = null;
private DashboardPortlet storedPortlet = null;
+ private RecentOperationsDataSource dataSourceCompleted;
+ private ScheduledOperationsDataSource dataSourceScheduled;
public static String unlimited = "unlimited";
public static String defaultValue = unlimited;
public static boolean defaultEnabled = true;
@@ -83,17 +84,18 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
public OperationsPortlet(String locatorId) {
super(locatorId);
+ this.dataSourceCompleted = new RecentOperationsDataSource(this);
+ this.dataSourceScheduled = new ScheduledOperationsDataSource(this);
}
@Override
protected void onInit() {
super.onInit();
-
//set title for larger container
setTitle(TITLE);
this.recentOperationsGrid = new LocatableListGrid(recentOperations);
- recentOperationsGrid.setDataSource(new RecentOperationsDataSource());
+ recentOperationsGrid.setDataSource(getDataSourceCompleted());
recentOperationsGrid.setAutoFetchData(true);
recentOperationsGrid.setTitle(recentOperations);
recentOperationsGrid.setWidth100();
@@ -111,7 +113,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
// Add the list table as the top half of the view.
this.scheduledOperationsGrid = new LocatableListGrid(scheduledOperations);
- scheduledOperationsGrid.setDataSource(new ScheduledOperationsDataSource());
+ scheduledOperationsGrid.setDataSource(getDataSourceScheduled());
scheduledOperationsGrid.setAutoFetchData(true);
scheduledOperationsGrid.setTitle(scheduledOperations);
scheduledOperationsGrid.setWidth100();
@@ -140,42 +142,44 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
//retrieve and translate to int
String retrieved = property.getStringValue();
if (retrieved.equals(unlimited)) {
- setOperationsRangeCompleted(-1);
+ getDataSourceCompleted().setOperationsRangeCompleted(-1);
} else {
- setOperationsRangeCompleted(Integer.parseInt(retrieved));
+ getDataSourceCompleted().setOperationsRangeCompleted(Integer.parseInt(retrieved));
}
} else {//create setting
storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue));
- setOperationsRangeCompleted(-1);
+ getDataSourceCompleted().setOperationsRangeCompleted(-1);
}
+
property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED);
if ((property != null) && (property.getStringValue() != null)) {
//retrieve and translate to int
String retrieved = property.getStringValue();
if (retrieved.equals(unlimited)) {
- setOperationsRangeScheduled(-1);
+ getDataSourceScheduled().setOperationsRangeScheduled(-1);
} else {
- setOperationsRangeScheduled(Integer.parseInt(retrieved));
+ getDataSourceScheduled().setOperationsRangeScheduled(Integer.parseInt(retrieved));
}
} else {//create setting
storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
- setOperationsRangeScheduled(-1);
+ getDataSourceScheduled().setOperationsRangeScheduled(-1);
}
//Checkbox settings property
property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
if ((property != null) && (property.getBooleanValue() != null)) {
- setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
+ getDataSourceScheduled().setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
} else {//create setting
storedPortlet.getConfiguration()
.put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, defaultEnabled));
- setOperationsRangeScheduleEnabled(defaultEnabled);
+ getDataSourceScheduled().setOperationsRangeScheduleEnabled(defaultEnabled);
}
property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED);
if ((property != null) && (property.getBooleanValue() != null)) {
- setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
+ getDataSourceCompleted().setOperationsRangeCompleteEnabled(property.getBooleanValue().booleanValue());
} else {//create setting
storedPortlet.getConfiguration()
.put(new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, defaultEnabled));
+ getDataSourceCompleted().setOperationsRangeCompleteEnabled(defaultEnabled);
}
}
@@ -359,38 +363,6 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
}
}
- public boolean isOperationsRangeCompletedEnabled() {
- return operationsRangeLastEnabled;
- }
-
- public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) {
- this.operationsRangeLastEnabled = operationsRangeLastEnabled;
- }
-
- public boolean isOperationsRangeScheduleEnabled() {
- return operationsRangeNextEnabled;
- }
-
- public void setOperationsRangeScheduleEnabled(boolean operationsRangeNextEnabled) {
- this.operationsRangeNextEnabled = operationsRangeNextEnabled;
- }
-
- public int getOperationsRangeScheduled() {
- return operationsRangeScheduled;
- }
-
- public void setOperationsRangeScheduled(int operationsRangeScheduled) {
- this.operationsRangeScheduled = operationsRangeScheduled;
- }
-
- public int getOperationsRangeCompleted() {
- return operationsRangeCompleted;
- }
-
- public void setOperationsRangeCompleted(int operationsRangeCompleted) {
- this.operationsRangeCompleted = operationsRangeCompleted;
- }
-
/** Custom refresh operation as we cannot directly extend Table because it only
* contains one ListGrid while the OperationsPortlet displays two tables.
*/
@@ -424,4 +396,19 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
return definition;
}
+ public RecentOperationsDataSource getDataSourceCompleted() {
+ return this.dataSourceCompleted;
+ }
+
+ public ScheduledOperationsDataSource getDataSourceScheduled() {
+ return this.dataSourceScheduled;
+ }
+
+ public LocatableListGrid getCompletedOperationsGrid() {
+ return this.recentOperationsGrid;
+ }
+
+ public LocatableListGrid getScheduledOperationsGrid() {
+ return this.scheduledOperationsGrid;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
index 72f2fb9..b74efea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
@@ -24,7 +24,6 @@ import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
@@ -44,10 +43,9 @@ public interface OperationGWTService extends RemoteService {
PageList<GroupOperationHistory> findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria);
- List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(
- ResourceCriteria criteria);
+ List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(int pageSize);
- List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(ResourceCriteria criteria);
+ List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize);
void scheduleResourceOperation(int resourceId, String operationName, Configuration parameters,
ExecutionSchedule schedule, String description, int timeout) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index e53708c..2c02f25 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -31,11 +31,12 @@ import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -52,10 +53,18 @@ public class RecentOperationsDataSource extends
public static final String operation = "operation";
public static final String time = "time";
public static final String status = "status";
+ private Portlet portlet;
+
+ //config attributes
+ private boolean operationsRangeLastEnabled = false;
+ private int operationsRangeCompleted = -1;
+ private boolean dataRangeDisabled = true;
+ public static String RANGE_DISABLED_MESSAGE = "(Results currently disabled. Change settings to enable results.)";
/** Build list of fields for the datasource and then adds them to it.
*/
- public RecentOperationsDataSource() {
+ public RecentOperationsDataSource(Portlet portlet) {
+ this.portlet = portlet;
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
@@ -100,9 +109,30 @@ public class RecentOperationsDataSource extends
* @param response outgoing response
*/
public void executeFetch(final DSRequest request, final DSResponse response) {
+ int pageSize = -1;
+ //retrieve current portlet display settings
+ if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) {
+ OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet;
+ //populate criteria with portlet preferences defined.
+ if (operationsPortlet != null) {
+ if (isOperationsRangeCompletedEnabled()) {
+ pageSize = getOperationsRangeCompleted();
+ operationsPortlet.getCompletedOperationsGrid().setEmptyMessage(
+ OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
+ } else {//show the component, return no results and indicate that you've disabled this display
+ pageSize = 0;
+ operationsPortlet.getCompletedOperationsGrid().setEmptyMessage(
+ OperationsPortlet.RANGE_DISABLED_MESSAGE);
+ response.setData(null);
+ response.setTotalRows(0);
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
+ return;
+ }
+ }
+ }
- ResourceCriteria c = new ResourceCriteria();
- GWTServiceLookup.getOperationService().findRecentCompletedOperations(c,
+ GWTServiceLookup.getOperationService().findRecentCompletedOperations(pageSize,
new AsyncCallback<List<DisambiguationReport<ResourceOperationLastCompletedComposite>>>() {
public void onFailure(Throwable throwable) {
@@ -204,4 +234,21 @@ public class RecentOperationsDataSource extends
return record;
}
+
+ public boolean isOperationsRangeCompletedEnabled() {
+ return operationsRangeLastEnabled;
+ }
+
+ public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) {
+ this.operationsRangeLastEnabled = operationsRangeLastEnabled;
+ }
+
+ public int getOperationsRangeCompleted() {
+ return operationsRangeCompleted;
+ }
+
+ public void setOperationsRangeCompleted(int operationsRangeCompleted) {
+ this.operationsRangeCompleted = operationsRangeCompleted;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index 4f58644..ebb1185 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -30,10 +30,11 @@ import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -49,10 +50,15 @@ public class ScheduledOperationsDataSource extends
public static final String location = "location";
public static final String operation = "operation";
public static final String time = "time";
+ //config settings
+ private boolean operationsRangeNextEnabled = false;
+ private int operationsRangeScheduled = -1;
+ private Portlet portlet;
/** Build list of fields for the datasource and then adds them to it.
*/
- public ScheduledOperationsDataSource() {
+ public ScheduledOperationsDataSource(Portlet portlet) {
+ this.portlet = portlet;
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
@@ -96,8 +102,30 @@ public class ScheduledOperationsDataSource extends
*/
public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria c = new ResourceCriteria();
- GWTServiceLookup.getOperationService().findScheduledOperations(c,
+ int pageSize = -1;
+ //retrieve current portlet display settings
+ if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) {
+ OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet;
+ //populate criteria with portlet preferences defined.
+ if (operationsPortlet != null) {
+ if (isOperationsRangeScheduleEnabled()) {
+ pageSize = getOperationsRangeScheduled();
+ operationsPortlet.getScheduledOperationsGrid().setEmptyMessage(
+ OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
+ } else {//show the component, return no results and indicate that you've disabled this display
+ pageSize = 0;
+ operationsPortlet.getScheduledOperationsGrid().setEmptyMessage(
+ OperationsPortlet.RANGE_DISABLED_MESSAGE);
+ response.setData(null);
+ response.setTotalRows(0);
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
+ return;
+ }
+ }
+ }
+
+ GWTServiceLookup.getOperationService().findScheduledOperations(pageSize,
new AsyncCallback<List<DisambiguationReport<ResourceOperationScheduleComposite>>>() {
public void onFailure(Throwable throwable) {
@@ -172,4 +200,21 @@ public class ScheduledOperationsDataSource extends
return record;
}
+
+ public boolean isOperationsRangeScheduleEnabled() {
+ return operationsRangeNextEnabled;
+ }
+
+ public void setOperationsRangeScheduleEnabled(boolean operationsRangeNextEnabled) {
+ this.operationsRangeNextEnabled = operationsRangeNextEnabled;
+ }
+
+ public int getOperationsRangeScheduled() {
+ return operationsRangeScheduled;
+ }
+
+ public void setOperationsRangeScheduled(int operationsRangeScheduled) {
+ this.operationsRangeScheduled = operationsRangeScheduled;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index e44c086..a7f72ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -24,7 +24,6 @@ import org.quartz.CronTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
@@ -88,9 +87,9 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
*
*/
public List<DisambiguationReport<ResourceOperationLastCompletedComposite>> findRecentCompletedOperations(
- ResourceCriteria criteria) {
+ int pageSize) {
- PageControl pageControl = new PageControl(0, -1);
+ PageControl pageControl = new PageControl(0, pageSize);
PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = operationManager
.findRecentlyCompletedResourceOperations(getSessionSubject(), null, pageControl);
@@ -105,10 +104,9 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
/** Find scheduled operations, disambiguate them and return that list.
*
*/
- public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(
- ResourceCriteria criteria) {
+ public List<DisambiguationReport<ResourceOperationScheduleComposite>> findScheduledOperations(int pageSize) {
- PageControl pageControl = new PageControl(0, -1);
+ PageControl pageControl = new PageControl(0, pageSize);
PageList<ResourceOperationScheduleComposite> scheduledResourceOps = operationManager
.findCurrentlyScheduledResourceOperations(getSessionSubject(), pageControl);
commit b9b50704a663d86eb0f961aa45c09cc2cc40063a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 17:23:27 2010 -0400
abstract out the save method since different SLSBs need to be called depending on the type of alert def (resource, group, or template)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 657fd5c..ce834da 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -119,14 +119,14 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
AlertDefinition alertDef = getAlertDefinitionDataSource().copyValues(record);
SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
- .extendLocatorId(alertDef.getName()), getResourceType(), alertDef);
+ .extendLocatorId(alertDef.getName()), this, alertDef);
return singleAlertDefinitionView;
}
@Override
public SingleAlertDefinitionView getDetailsView(int id) {
final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
- .extendLocatorId("singleAlertDefinitionView"), getResourceType());
+ .extendLocatorId("singleAlertDefinitionView"), this);
if (id == 0) {
// create an empty one with all defaults
@@ -176,4 +176,6 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
protected abstract void enableButtonPressed(ListGridRecord[] selection);
protected abstract void disableButtonPressed(ListGridRecord[] selection);
+
+ protected abstract void commitAlertDefinition(AlertDefinition alertDefinition);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index ec67b08..0c7cdff 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -106,4 +107,11 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
SC.say(str);
}
+
+ @Override
+ protected void commitAlertDefinition(AlertDefinition alertDefinition) {
+ // TODO call into server SLSB to store alert def
+ // GroupAlertDefinitionManagerLocal groupAlertDefinitionManager = LookupUtil.getGroupAlertDefinitionManager();
+ // groupAlertDefinitionManager.updateGroupAlertDefinitions(subject, alertDef, true);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 83a8629..da46f44 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -101,4 +102,12 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
SC.say(str);
}
+
+ @Override
+ protected void commitAlertDefinition(AlertDefinition alertDefinition) {
+ System.out.println("=======================================>" + alertDefinition);
+ // TODO call into server SLSB to store alert def
+ // AlertDefinitionManagerLocal alertDefinitionManager = LookupUtil.getAlertDefinitionManager();
+ // alertDefinitionManager.updateAlertDefinition(subject, alertDef.getId(), alertDef, true);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 7cf6356..bc7a8b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -30,8 +30,6 @@ import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
@@ -54,11 +52,12 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
private Button saveButton;
private Button cancelButton;
- public SingleAlertDefinitionView(String locatorId, ResourceType resourceType) {
- this(locatorId, resourceType, null);
+ public SingleAlertDefinitionView(String locatorId, AbstractAlertDefinitionsView alertDefView) {
+ this(locatorId, alertDefView, null);
}
- public SingleAlertDefinitionView(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) {
+ public SingleAlertDefinitionView(String locatorId, final AbstractAlertDefinitionsView alertDefView,
+ AlertDefinition alertDefinition) {
super(locatorId);
this.alertDefinition = alertDefinition;
@@ -71,7 +70,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
generalPropertiesTab.setPane(generalProperties);
Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), "Conditions");
- conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), resourceType, alertDefinition);
+ conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), alertDefView.getResourceType(),
+ alertDefinition);
conditionsTab.setPane(conditions);
Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"), "Notifications");
@@ -117,8 +117,9 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
setAlertDefinition(getAlertDefinition()); // loads data into static fields
makeViewOnly();
- // TODO getAlertDefinition() should now have the new user data - commit it to DB
- CoreGUI.refresh();
+ alertDefView.commitAlertDefinition(getAlertDefinition());
+
+ alertDefView.refresh();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index d5a5e14..3ef3dfe 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
/**
@@ -105,4 +106,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
SC.say(str);
}
+
+ @Override
+ protected void commitAlertDefinition(AlertDefinition alertDefinition) {
+ // TODO call into server SLSB to store alert def
+ // AlertTemplateManagerLocal alertTemplateManager = LookupUtil.getAlertTemplateManager();
+ // alertTemplateManager.updateAlertTemplate(subject, alertDef, true);
+ }
}
commit f1599977fb315f35391f8b8c54babc40c5b062ea
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 17:08:19 2010 -0400
builds the conditions object and sets the new condition in the alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 78261a3..7b85eae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -111,7 +111,13 @@ public class ConditionsEditor extends LocatableVLayout {
});
NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"),
- conditions, ConditionsEditor.this.resourceType, winModal);
+ conditions, ConditionsEditor.this.resourceType, new Runnable() {
+ @Override
+ public void run() {
+ winModal.markForDestroy();
+ table.refresh();
+ }
+ });
winModal.addItem(newConditionEditor);
winModal.show();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 7922824..bd20b0a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,13 +24,11 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.FormItemIfFunction;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
@@ -46,10 +44,12 @@ import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -57,42 +57,49 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
+ private static final String AVAILABILITY_ITEMNAME = "availability";
+ private static final String THRESHOLD_METRIC_ITEMNAME = "thresholdMetric";
+ private static final String THRESHOLD_COMPARATOR_ITEMNAME = "thresholdComparator";
+ private static final String THRESHOLD_ABSVALUE_ITEMNAME = "metricAbsoluteValue";
+ private static final String BASELINE_METRIC_ITEMNAME = "baselineMetric";
+ private static final String BASELINE_COMPARATOR_ITEMNAME = "baselineComparator";
+ private static final String BASELINE_PERCENTAGE_ITEMNAME = "baselinePercentage";
+ private static final String BASELINE_SELECTION_ITEMNAME = "baselineSelection";
+ private static final String CHANGE_METRIC_ITEMNAME = "changeMetric";
+ private static final String TRAIT_METRIC_ITEMNAME = "trait";
+ private static final String OPERATION_NAME_ITEMNAME = "operation";
+ private static final String OPERATION_RESULTS_ITEMNAME = "operationResults";
+ private static final String EVENT_SEVERITY_ITEMNAME = "eventSeverity";
+ private static final String EVENT_REGEX_ITEMNAME = "eventRegex";
+
private SelectItem conditionTypeSelectItem;
private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
- private Collection<String> metrics;
- private Collection<String> traits;
- private Collection<String> operations;
- private boolean supportsEvents;
- private Window parentWindow; // where this form is located; after form is OK'ed, this window will be destroyed
+ private boolean supportsMetrics = false;
+ private boolean supportsTraits = false;
+ private boolean supportsOperations = false;
+ private boolean supportsEvents = false;
+ private Runnable okFunction; // this is called after the OK button is pressed and a new condition is saved
+ private ResourceType resourceType;
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Window parent) {
+ public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Runnable okFunc) {
super(locatorId);
this.conditions = conditions;
- this.parentWindow = parent;
+ this.okFunction = okFunc;
+ this.resourceType = rtype;
this.supportsEvents = (rtype.getEventDefinitions() != null & rtype.getEventDefinitions().size() > 0);
Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions();
- Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions();
- if (metricDefinitions == null || metricDefinitions.size() == 0) {
- this.metrics = null;
- this.traits = null;
- } else {
+ if (metricDefinitions != null && metricDefinitions.size() > 0) {
for (MeasurementDefinition measurementDefinition : metricDefinitions) {
switch (measurementDefinition.getDataType()) {
case MEASUREMENT: {
- if (this.metrics == null) {
- this.metrics = new ArrayList<String>();
- }
- this.metrics.add(measurementDefinition.getDisplayName());
+ this.supportsMetrics = true;
break;
}
case TRAIT: {
- if (this.traits == null) {
- this.traits = new ArrayList<String>();
- }
- this.traits.add(measurementDefinition.getDisplayName());
+ this.supportsTraits = true;
break;
}
default: {
@@ -102,13 +109,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
}
- if (operationDefinitions == null || operationDefinitions.size() == 0) {
- this.operations = null;
- } else {
- this.operations = new ArrayList<String>(operationDefinitions.size());
- for (OperationDefinition operationDefinition : operationDefinitions) {
- this.operations.add(operationDefinition.getDisplayName());
- }
+ Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions();
+ if (operationDefinitions != null && operationDefinitions.size() > 0) {
+ this.supportsOperations = true;
}
}
@@ -121,15 +124,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type");
LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7);
condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability Change");
- if (metrics != null) {
+ if (supportsMetrics) {
condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
}
- if (traits != null) {
+ if (supportsTraits) {
condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
}
- if (operations != null) {
+ if (supportsOperations) {
condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution");
}
if (supportsEvents) {
@@ -152,8 +155,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
@Override
public void onClick(ClickEvent event) {
if (validate(false)) {
- // TODO
- NewConditionEditor.this.parentWindow.markForDestroy();
+ saveNewCondition();
+ okFunction.run();
}
}
});
@@ -162,15 +165,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(conditionTypeSelectItem);
formItems.add(spacer);
formItems.addAll(buildAvailabilityChangeFormItems());
- if (metrics != null) {
+ if (supportsMetrics) {
formItems.addAll(buildMetricThresholdFormItems());
formItems.addAll(buildMetricBaselineFormItems());
formItems.addAll(buildMetricChangeFormItems());
}
- if (traits != null) {
+ if (supportsTraits) {
formItems.addAll(buildTraitChangeFormItems());
}
- if (operations != null) {
+ if (supportsOperations) {
formItems.addAll(buildOperationFormItems());
}
if (supportsEvents) {
@@ -181,6 +184,90 @@ public class NewConditionEditor extends LocatableDynamicForm {
setFields(formItems.toArray(new FormItem[formItems.size()]));
};
+ private void saveNewCondition() {
+ AlertConditionCategory category;
+ category = AlertConditionCategory.valueOf(conditionTypeSelectItem.getValue().toString());
+
+ AlertCondition newCondition = new AlertCondition();
+ newCondition.setCategory(category);
+
+ switch (category) {
+ case AVAILABILITY: {
+ newCondition.setName(null);
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(AVAILABILITY_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ case THRESHOLD: {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
+ newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case BASELINE: {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(BASELINE_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setThreshold(Double.valueOf(getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)) / 100.0);
+ newCondition.setComparator(getValueAsString(BASELINE_COMPARATOR_ITEMNAME));
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case CHANGE: {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case TRAIT: {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(TRAIT_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ break;
+ }
+
+ case CONTROL: {
+ newCondition.setName(getValueAsString(OPERATION_NAME_ITEMNAME));
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(OPERATION_RESULTS_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ case EVENT: {
+ newCondition.setName(getValueAsString(EVENT_SEVERITY_ITEMNAME));
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(getValueAsString(EVENT_REGEX_ITEMNAME));
+ newCondition.setMeasurementDefinition(null);
+ break;
+ }
+
+ default: {
+ CoreGUI.getErrorHandler().handleError("Invalid alert category selected: " + category); // should never happen
+ break;
+ }
+ }
+
+ this.conditions.add(newCondition);
+ }
+
private ArrayList<FormItem> buildMetricThresholdFormItems() {
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
@@ -190,10 +277,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr, ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("thresholdMetric", ifFunc));
- formItems.add(buildComparatorDropDownMenu("thresholdComparator", ifFunc));
-
- TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value");
+ formItems.add(buildMetricDropDownMenu(THRESHOLD_METRIC_ITEMNAME, ifFunc));
+ formItems.add(buildComparatorDropDownMenu(THRESHOLD_COMPARATOR_ITEMNAME, ifFunc));
+ TextItem absoluteValue = new TextItem(THRESHOLD_ABSVALUE_ITEMNAME, "Metric Value");
absoluteValue.setWrapTitle(false);
absoluteValue.setRequired(true);
absoluteValue
@@ -214,10 +300,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("baselineHelp", helpStr, ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("baselineMetric", ifFunc));
- formItems.add(buildComparatorDropDownMenu("baselineComparator", ifFunc));
+ formItems.add(buildMetricDropDownMenu(BASELINE_METRIC_ITEMNAME, ifFunc));
+ formItems.add(buildComparatorDropDownMenu(BASELINE_COMPARATOR_ITEMNAME, ifFunc));
- TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage");
+ TextItem baselinePercentage = new TextItem(BASELINE_PERCENTAGE_ITEMNAME, "Baseline Percentage");
baselinePercentage.setWrapTitle(false);
baselinePercentage.setRequired(true);
baselinePercentage
@@ -225,13 +311,13 @@ public class NewConditionEditor extends LocatableDynamicForm {
baselinePercentage.setShowIfCondition(ifFunc);
formItems.add(baselinePercentage);
- SelectItem baselineSelection = new SelectItem("baselineSelection", "Baseline");
+ SelectItem baselineSelection = new SelectItem(BASELINE_SELECTION_ITEMNAME, "Baseline");
LinkedHashMap<String, String> baselines = new LinkedHashMap<String, String>(3);
- baselines.put("min", "Minimum"); // title should have the current value of the min baseline
- baselines.put("avg", "Baseline"); // title should have the current value of the avg baseline
- baselines.put("max", "Maximum"); // title should have the current value of the max baseline
+ baselines.put("min", "Minimum"); // TODO can we have the current value of the min baseline
+ baselines.put("mean", "Average"); // TODO can we have the current value of the avg baseline
+ baselines.put("max", "Maximum"); // TODO can we have the current value of the max baseline
baselineSelection.setValueMap(baselines);
- baselineSelection.setDefaultValue("avg");
+ baselineSelection.setDefaultValue("mean");
baselineSelection.setWrapTitle(false);
baselineSelection.setWidth("*");
baselineSelection.setRedrawOnChange(true);
@@ -250,7 +336,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp", helpStr, ifFunc);
formItems.add(helpItem);
- formItems.add(buildMetricDropDownMenu("changeMetric", ifFunc));
+ formItems.add(buildMetricDropDownMenu(CHANGE_METRIC_ITEMNAME, ifFunc));
return formItems;
}
@@ -265,11 +351,13 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(helpItem);
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>();
- for (String traitName : this.traits) {
- traitsMap.put(traitName, traitName);
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (def.getDataType() == DataType.TRAIT) {
+ traitsMap.put(def.getName(), def.getDisplayName());
+ }
}
- SelectItem traitSelection = new SelectItem("trait", "Trait");
+ SelectItem traitSelection = new SelectItem(TRAIT_METRIC_ITEMNAME, "Trait");
traitSelection.setValueMap(traitsMap);
traitSelection.setDefaultValue(traitsMap.keySet().iterator().next()); // just use the first one
traitSelection.setWidth("*");
@@ -289,7 +377,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("availabilityHelp", helpStr, ifFunc);
formItems.add(helpItem);
- SelectItem selection = new SelectItem("availability", "Availability");
+ SelectItem selection = new SelectItem(AVAILABILITY_ITEMNAME, "Availability");
LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2);
avails.put(AvailabilityType.UP.name(), "Goes UP");
avails.put(AvailabilityType.DOWN.name(), "Goes DOWN");
@@ -311,11 +399,11 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(helpItem);
LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>();
- for (String opName : this.operations) {
- ops.put(opName, opName);
+ for (OperationDefinition opDef : this.resourceType.getOperationDefinitions()) {
+ ops.put(opDef.getName(), opDef.getDisplayName());
}
- SelectItem opSelection = new SelectItem("operation", "Operation");
+ SelectItem opSelection = new SelectItem(OPERATION_NAME_ITEMNAME, "Operation");
opSelection.setValueMap(ops);
opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one
opSelection.setWidth("*");
@@ -323,7 +411,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
opSelection.setShowIfCondition(ifFunc);
formItems.add(opSelection);
- SelectItem opResultsSelection = new SelectItem("operationResults", "Operation Status");
+ SelectItem opResultsSelection = new SelectItem(OPERATION_RESULTS_ITEMNAME, "Operation Status");
LinkedHashMap<String, String> operationStatuses = new LinkedHashMap<String, String>(4);
operationStatuses.put(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.INPROGRESS.name());
operationStatuses.put(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.SUCCESS.name());
@@ -347,7 +435,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("eventHelp", helpStr, ifFunc);
formItems.add(helpItem);
- SelectItem eventSeveritySelection = new SelectItem("eventSeverity", "Event Severity");
+ SelectItem eventSeveritySelection = new SelectItem(EVENT_SEVERITY_ITEMNAME, "Event Severity");
LinkedHashMap<String, String> severities = new LinkedHashMap<String, String>(5);
severities.put(EventSeverity.DEBUG.name(), EventSeverity.DEBUG.name());
severities.put(EventSeverity.INFO.name(), EventSeverity.INFO.name());
@@ -360,7 +448,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
eventSeveritySelection.setShowIfCondition(ifFunc);
formItems.add(eventSeveritySelection);
- TextItem eventRegex = new TextItem("eventRegex", "Regular Expression");
+ TextItem eventRegex = new TextItem(EVENT_REGEX_ITEMNAME, "Regular Expression");
eventRegex.setRequired(false);
eventRegex
.setTooltip("If specified, this is a regular expression that must match a collected event message in order to trigger the condition.");
@@ -374,8 +462,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
- for (String metricName : this.metrics) {
- metricsMap.put(metricName, metricName);
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (def.getDataType() == DataType.MEASUREMENT) {
+ metricsMap.put(def.getName(), def.getDisplayName());
+ }
}
SelectItem metricSelection = new SelectItem(itemName, "Metric");
@@ -413,6 +503,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
return help;
}
+ private MeasurementDefinition getMeasurementDefinition(String metricName) {
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (metricName.equals(def.getName())) {
+ return def;
+ }
+ }
+ CoreGUI.getErrorHandler().handleError("Should have found metric definition - something is wrong");
+ return null;
+ }
+
private class ShowIfCategoryFunction implements FormItemIfFunction {
private final AlertConditionCategory category;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 8269a8d..7cf6356 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -31,6 +31,7 @@ import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
@@ -117,6 +118,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
makeViewOnly();
// TODO getAlertDefinition() should now have the new user data - commit it to DB
+ CoreGUI.refresh();
}
});
commit d0a76a4f3628d280bd861237869933dc126e235b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 15:23:41 2010 -0400
add javadoc omments to AlertCondition so its clear what the different fields should be based on the different category semantics
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
index b54d58e..3218d9d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
@@ -47,7 +47,9 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationRequestStatus;
/**
* An alert condition (e.g. ActiveThreads > 100) as configured in an alert definition.
@@ -366,6 +368,13 @@ public class AlertCondition implements Serializable {
this.category = category;
}
+ /**
+ * Identifies the measurement definition of the metric that is to be compared when determining
+ * if the condition is true. This is null if the condition category is not a metric-related one
+ * (metric related categories are THRESHOLD, TRAIT, BASELINE and CHANGE; others are not).
+ *
+ * @return measurement definition or null
+ */
public MeasurementDefinition getMeasurementDefinition() {
return this.measurementDefinition;
}
@@ -374,6 +383,19 @@ public class AlertCondition implements Serializable {
this.measurementDefinition = measurementDefinition;
}
+ /**
+ * The name of the condition whose semantics are different based on this condition's category:
+ *
+ * AVAILABILITY: n/a (null)
+ * THRESHOLD: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
+ * BASELINE: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
+ * CHANGE: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
+ * TRAIT: the name of the trait (TODO: today its the display name, very bad for i18n purposes)
+ * CONTROL: the name of the operation (not its display name)
+ * EVENT: the level of event to compare with (DEBUG, INFO, WARN, ERROR, FATAL)
+ *
+ * @return additional information about the condition
+ */
public String getName() {
return this.name;
}
@@ -382,6 +404,14 @@ public class AlertCondition implements Serializable {
this.name = name;
}
+ /**
+ * One of these comparators: "<", ">" or "=".
+ * This will be null if the condition does not compare values. Only THRESHOLD
+ * and BASELINE condition categories use comparators; other types of conditions
+ * will return <code>null</code>.
+ *
+ * @return comparator string
+ */
public String getComparator() {
return this.comparator;
}
@@ -390,6 +420,13 @@ public class AlertCondition implements Serializable {
this.comparator = comparator;
}
+ /**
+ * Returns the threshold to compare a measurement value to see if the condition is true.
+ * This is only valid for conditions of category THRESHOLD and BASELINE. All other
+ * condition types will return <code>null</code>.
+ *
+ * @return threshold value or null
+ */
public Double getThreshold() {
return this.threshold;
}
@@ -398,6 +435,18 @@ public class AlertCondition implements Serializable {
this.threshold = threshold;
}
+ /**
+ * The option string is optional and its semantics differ based on the category of this condition:
+ * AVAILABILITY: the {@link AvailabilityType} to trigger off of (DOWN or UP)
+ * THRESHOLD: n/a
+ * BASELINE: one of "min", "max" or "mean" - indicates what the threshold is compared to (min/max/avg baseline value)
+ * CHANGE: n/a
+ * TRAIT: n/a
+ * CONTROL: the {@link OperationRequestStatus} name (SUCCESS, FAILURE, etc).
+ * EVENT: the regular expression of the message to match (which may be empty string if not specified)
+ *
+ * @return additional information about the condition
+ */
public String getOption() {
return this.option;
}
commit 4752d410687ff02f7c04e3f62a552f3f7e55bb06
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 13 14:17:48 2010 -0400
get new condition editor to show metrics, operations, etc
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 23bc0cc..657fd5c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -29,6 +29,7 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.BooleanExpression;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
@@ -118,14 +119,14 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
AlertDefinition alertDef = getAlertDefinitionDataSource().copyValues(record);
SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
- .extendLocatorId(alertDef.getName()), alertDef);
+ .extendLocatorId(alertDef.getName()), getResourceType(), alertDef);
return singleAlertDefinitionView;
}
@Override
public SingleAlertDefinitionView getDetailsView(int id) {
final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
- .extendLocatorId("Empty"));
+ .extendLocatorId("singleAlertDefinitionView"), getResourceType());
if (id == 0) {
// create an empty one with all defaults
@@ -160,6 +161,8 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
return singleAlertDefinitionView;
}
+ protected abstract ResourceType getResourceType();
+
protected abstract Criteria getCriteria();
protected abstract AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
index e1cb68f..182173a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.BooleanExpression;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -40,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class ConditionsAlertDefinitionForm extends LocatableVLayout implements EditAlertDefinitionForm {
+ private final ResourceType resourceType;
private AlertDefinition alertDefinition;
private SelectItem conditionExpression;
@@ -49,12 +51,13 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
private boolean formBuilt = false;
- public ConditionsAlertDefinitionForm(String locatorId) {
- this(locatorId, null);
+ public ConditionsAlertDefinitionForm(String locatorId, ResourceType resourceType) {
+ this(locatorId, resourceType, null);
}
- public ConditionsAlertDefinitionForm(String locatorId, AlertDefinition alertDefinition) {
+ public ConditionsAlertDefinitionForm(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) {
super(locatorId);
+ this.resourceType = resourceType;
this.alertDefinition = alertDefinition;
}
@@ -146,7 +149,7 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
conditionExpressionForm.setFields(conditionExpression, conditionExpressionStatic);
- conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), null);
+ conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), resourceType, null);
setMembers(conditionExpressionForm, conditionsEditor);
formBuilt = true;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 1742ec0..78261a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -29,12 +29,14 @@ import java.util.Set;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
@@ -47,11 +49,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class ConditionsEditor extends LocatableVLayout {
+ private ResourceType resourceType;
private HashSet<AlertCondition> conditions;
private Table table;
- public ConditionsEditor(String locatorId, HashSet<AlertCondition> conditions) {
+ public ConditionsEditor(String locatorId, ResourceType resourceType, HashSet<AlertCondition> conditions) {
super(locatorId);
+ this.resourceType = resourceType;
setConditions(conditions);
}
@@ -90,20 +94,24 @@ public class ConditionsEditor extends LocatableVLayout {
public void executeAction(ListGridRecord[] selection) {
final Window winModal = new Window();
winModal.setTitle("Add Condition");
+ winModal.setOverflow(Overflow.VISIBLE);
winModal.setShowMinimizeButton(false);
winModal.setIsModal(true);
winModal.setShowModalMask(true);
winModal.setAutoSize(true);
winModal.setAutoCenter(true);
+ //winModal.setShowResizer(true);
+ //winModal.setCanDragResize(true);
winModal.centerInPage();
winModal.addCloseClickHandler(new CloseClickHandler() {
@Override
public void onCloseClick(CloseClientEvent event) {
- winModal.destroy();
+ winModal.markForDestroy();
}
});
+
NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"),
- conditions);
+ conditions, ConditionsEditor.this.resourceType, winModal);
winModal.addItem(newConditionEditor);
winModal.show();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index c0b37ca..ec67b08 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
/**
@@ -44,6 +45,11 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ protected ResourceType getResourceType() {
+ return group.getResourceType();
+ }
+
+ @Override
protected Criteria getCriteria() {
Criteria criteria = new Criteria();
criteria.addCriteria(CRITERIA_GROUP_ID, group.getId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index c6c59c1..7922824 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,11 +24,13 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.Set;
import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.FormItemIfFunction;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
@@ -44,7 +46,10 @@ import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -52,12 +57,59 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
- private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
private SelectItem conditionTypeSelectItem;
+ private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
+ private Collection<String> metrics;
+ private Collection<String> traits;
+ private Collection<String> operations;
+ private boolean supportsEvents;
+ private Window parentWindow; // where this form is located; after form is OK'ed, this window will be destroyed
+
+ public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions, ResourceType rtype, Window parent) {
- public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions) {
super(locatorId);
this.conditions = conditions;
+ this.parentWindow = parent;
+
+ this.supportsEvents = (rtype.getEventDefinitions() != null & rtype.getEventDefinitions().size() > 0);
+
+ Set<MeasurementDefinition> metricDefinitions = rtype.getMetricDefinitions();
+ Set<OperationDefinition> operationDefinitions = rtype.getOperationDefinitions();
+ if (metricDefinitions == null || metricDefinitions.size() == 0) {
+ this.metrics = null;
+ this.traits = null;
+ } else {
+ for (MeasurementDefinition measurementDefinition : metricDefinitions) {
+ switch (measurementDefinition.getDataType()) {
+ case MEASUREMENT: {
+ if (this.metrics == null) {
+ this.metrics = new ArrayList<String>();
+ }
+ this.metrics.add(measurementDefinition.getDisplayName());
+ break;
+ }
+ case TRAIT: {
+ if (this.traits == null) {
+ this.traits = new ArrayList<String>();
+ }
+ this.traits.add(measurementDefinition.getDisplayName());
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ }
+ }
+
+ if (operationDefinitions == null || operationDefinitions.size() == 0) {
+ this.operations = null;
+ } else {
+ this.operations = new ArrayList<String>(operationDefinitions.size());
+ for (OperationDefinition operationDefinition : operationDefinitions) {
+ this.operations.add(operationDefinition.getDisplayName());
+ }
+ }
}
@Override
@@ -68,15 +120,23 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type");
LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7);
- condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
- condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
- condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
- condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability Change");
- condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution");
- condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection");
+ if (metrics != null) {
+ condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
+ condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
+ condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
+ }
+ if (traits != null) {
+ condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
+ }
+ if (operations != null) {
+ condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution");
+ }
+ if (supportsEvents) {
+ condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection");
+ }
conditionTypeSelectItem.setValueMap(condTypes);
- conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.THRESHOLD.name());
+ conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.AVAILABILITY.name());
conditionTypeSelectItem.setWrapTitle(false);
conditionTypeSelectItem.setRedrawOnChange(true);
conditionTypeSelectItem.setWidth("*");
@@ -91,21 +151,31 @@ public class NewConditionEditor extends LocatableDynamicForm {
ok.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- // TODO
- SC.say("Not yet implemented");
+ if (validate(false)) {
+ // TODO
+ NewConditionEditor.this.parentWindow.markForDestroy();
+ }
}
});
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
formItems.add(conditionTypeSelectItem);
formItems.add(spacer);
- formItems.addAll(buildMetricThresholdFormItems());
- formItems.addAll(buildMetricBaselineFormItems());
- formItems.addAll(buildMetricChangeFormItems());
- formItems.addAll(buildTraitChangeFormItems());
formItems.addAll(buildAvailabilityChangeFormItems());
- formItems.addAll(buildOperationFormItems());
- formItems.addAll(buildEventFormItems());
+ if (metrics != null) {
+ formItems.addAll(buildMetricThresholdFormItems());
+ formItems.addAll(buildMetricBaselineFormItems());
+ formItems.addAll(buildMetricChangeFormItems());
+ }
+ if (traits != null) {
+ formItems.addAll(buildTraitChangeFormItems());
+ }
+ if (operations != null) {
+ formItems.addAll(buildOperationFormItems());
+ }
+ if (supportsEvents) {
+ formItems.addAll(buildEventFormItems());
+ }
formItems.add(ok);
setFields(formItems.toArray(new FormItem[formItems.size()]));
@@ -126,6 +196,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value");
absoluteValue.setWrapTitle(false);
absoluteValue.setRequired(true);
+ absoluteValue
+ .setTooltip("The threshold value of the metric that will trigger the condition when compared using the selected comparator.");
absoluteValue.setShowIfCondition(ifFunc);
formItems.add(absoluteValue);
@@ -148,6 +220,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage");
baselinePercentage.setWrapTitle(false);
baselinePercentage.setRequired(true);
+ baselinePercentage
+ .setTooltip("A collected metric value will trigger this condition when compared to this percentage of the selected baseline value using the selected comparator");
baselinePercentage.setShowIfCondition(ifFunc);
formItems.add(baselinePercentage);
@@ -158,8 +232,9 @@ public class NewConditionEditor extends LocatableDynamicForm {
baselines.put("max", "Maximum"); // title should have the current value of the max baseline
baselineSelection.setValueMap(baselines);
baselineSelection.setDefaultValue("avg");
- baselineSelection.setWidth("*");
baselineSelection.setWrapTitle(false);
+ baselineSelection.setWidth("*");
+ baselineSelection.setRedrawOnChange(true);
baselineSelection.setShowIfCondition(ifFunc);
formItems.add(baselineSelection);
@@ -189,14 +264,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
StaticTextItem helpItem = buildHelpTextItem("traitHelp", helpStr, ifFunc);
formItems.add(helpItem);
- LinkedHashMap<String, String> traits = new LinkedHashMap<String, String>();
- // TODO
- traits.put("dummy trait", "Dummy Trait Name");
+ LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>();
+ for (String traitName : this.traits) {
+ traitsMap.put(traitName, traitName);
+ }
SelectItem traitSelection = new SelectItem("trait", "Trait");
- traitSelection.setValueMap(traits);
- traitSelection.setDefaultValue(traits.keySet().iterator().next()); // just use the first one
+ traitSelection.setValueMap(traitsMap);
+ traitSelection.setDefaultValue(traitsMap.keySet().iterator().next()); // just use the first one
traitSelection.setWidth("*");
+ traitSelection.setRedrawOnChange(true);
traitSelection.setShowIfCondition(ifFunc);
formItems.add(traitSelection);
@@ -234,12 +311,15 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.add(helpItem);
LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>();
- // TODO
- ops.put("dummy op", "Dummy Op Name");
+ for (String opName : this.operations) {
+ ops.put(opName, opName);
+ }
SelectItem opSelection = new SelectItem("operation", "Operation");
opSelection.setValueMap(ops);
opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one
+ opSelection.setWidth("*");
+ opSelection.setRedrawOnChange(true);
opSelection.setShowIfCondition(ifFunc);
formItems.add(opSelection);
@@ -251,7 +331,6 @@ public class NewConditionEditor extends LocatableDynamicForm {
operationStatuses.put(OperationRequestStatus.CANCELED.name(), OperationRequestStatus.CANCELED.name());
opResultsSelection.setValueMap(operationStatuses);
opResultsSelection.setDefaultValue(OperationRequestStatus.FAILURE.name());
- opResultsSelection.setWidth("*");
opResultsSelection.setWrapTitle(false);
opResultsSelection.setShowIfCondition(ifFunc);
formItems.add(opResultsSelection);
@@ -283,6 +362,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
TextItem eventRegex = new TextItem("eventRegex", "Regular Expression");
eventRegex.setRequired(false);
+ eventRegex
+ .setTooltip("If specified, this is a regular expression that must match a collected event message in order to trigger the condition.");
eventRegex.setWrapTitle(false);
eventRegex.setShowIfCondition(ifFunc);
formItems.add(eventRegex);
@@ -292,13 +373,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
- LinkedHashMap<String, String> metrics = new LinkedHashMap<String, String>();
- metrics.put("dummy metric", "Dummy Metric Name");
+ LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
+ for (String metricName : this.metrics) {
+ metricsMap.put(metricName, metricName);
+ }
SelectItem metricSelection = new SelectItem(itemName, "Metric");
- metricSelection.setValueMap(metrics);
- metricSelection.setDefaultValue(metrics.keySet().iterator().next()); // just use the first one
+ metricSelection.setValueMap(metricsMap);
+ metricSelection.setDefaultValue(metricsMap.keySet().iterator().next()); // just use the first one
metricSelection.setWidth("*");
+ metricSelection.setRedrawOnChange(true);
metricSelection.setShowIfCondition(ifFunc);
return metricSelection;
}
@@ -313,6 +397,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
SelectItem comparatorSelection = new SelectItem(itemName, "Comparator");
comparatorSelection.setValueMap(comparators);
comparatorSelection.setDefaultValue("<");
+ comparatorSelection.setTooltip("How a collected metric value should be compared to the given threshold value");
comparatorSelection.setShowIfCondition(ifFunc);
return comparatorSelection;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 7cf7226..83a8629 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -28,6 +28,7 @@ import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
/**
* @author John Mazzitelli
@@ -44,6 +45,11 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ protected ResourceType getResourceType() {
+ return resource.getResourceType();
+ }
+
+ @Override
protected Criteria getCriteria() {
Criteria criteria = new Criteria();
criteria.addCriteria(CRITERIA_RESOURCE_ID, resource.getId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index d06e422..8269a8d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
@@ -41,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class SingleAlertDefinitionView extends LocatableVLayout {
private AlertDefinition alertDefinition;
+
private GeneralPropertiesAlertDefinitionForm generalProperties;
private ConditionsAlertDefinitionForm conditions;
private NotificationsAlertDefinitionForm notifications;
@@ -51,11 +53,11 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
private Button saveButton;
private Button cancelButton;
- public SingleAlertDefinitionView(String locatorId) {
- this(locatorId, null);
+ public SingleAlertDefinitionView(String locatorId, ResourceType resourceType) {
+ this(locatorId, resourceType, null);
}
- public SingleAlertDefinitionView(String locatorId, AlertDefinition alertDefinition) {
+ public SingleAlertDefinitionView(String locatorId, ResourceType resourceType, AlertDefinition alertDefinition) {
super(locatorId);
this.alertDefinition = alertDefinition;
@@ -68,7 +70,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
generalPropertiesTab.setPane(generalProperties);
Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), "Conditions");
- conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), alertDefinition);
+ conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), resourceType, alertDefinition);
conditionsTab.setPane(conditions);
Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"), "Notifications");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index d2f44f6..d5a5e14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -44,6 +44,11 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ protected ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ @Override
protected Criteria getCriteria() {
Criteria criteria = new Criteria();
criteria.addCriteria(CRITERIA_RESOURCE_TYPE_ID, resourceType.getId());
commit 8d1ef83e3075616b615c385f2174c7228ddde9d6
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Sep 13 12:24:48 2010 -0400
moved Table attrs back to private, enabled RecentlyAdded server side
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 0d4e6d6..5196c71 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -77,12 +77,12 @@ public class Table extends LocatableHLayout {
private TableFilter filterForm;
private ListGrid listGrid;
private ToolStrip footer;
- protected Label tableInfo;
+ private Label tableInfo;
private List<String> headerIcons = new ArrayList<String>();
private boolean showHeader = true;
- protected boolean showFooter = true;
+ private boolean showFooter = true;
private boolean showFooterRefresh = true;
private String tableTitle;
@@ -249,7 +249,7 @@ public class Table extends LocatableHLayout {
// Now give subclasses a chance to configure the table
configureTable();
- tableInfo = new Label("Total: " + listGrid.getTotalRows());
+ setTableInfo(new Label("Total: " + listGrid.getTotalRows()));
// NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since
// super.onDraw() is what actually adds the fields to the ListGrid (based on what fields are defined in
@@ -260,7 +260,7 @@ public class Table extends LocatableHLayout {
}
}
- tableInfo.setWrap(false);
+ getTableInfo().setWrap(false);
if (showHeader) {
@@ -543,8 +543,8 @@ public class Table extends LocatableHLayout {
((TableWidget) extraWidget).refresh(this.listGrid);
}
}
- if (this.tableInfo != null) {
- this.tableInfo.setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)");
+ if (getTableInfo() != null) {
+ getTableInfo().setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)");
}
}
}
@@ -659,4 +659,12 @@ public class Table extends LocatableHLayout {
public void setShowFooterRefresh(boolean showFooterRefresh) {
this.showFooterRefresh = showFooterRefresh;
}
+
+ public Label getTableInfo() {
+ return tableInfo;
+ }
+
+ public void setTableInfo(Label tableInfo) {
+ this.tableInfo = tableInfo;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
index fb1db39..17b4074 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
@@ -23,6 +23,10 @@
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -32,28 +36,28 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.core.domain.criteria.ResourceCriteria;
+
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
public class RecentlyAddedResourceDS extends DataSource {
+ private Portlet portlet;
+ private int maximumRecentlyAddedToDisplay;
+ private int maximumRecentlyAddedWithinHours;
+ private long oldestDate = -1;
-
- public RecentlyAddedResourceDS() {
+ public RecentlyAddedResourceDS(Portlet recentlyAddedPortlet) {
+ this.portlet = recentlyAddedPortlet;
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
-
DataSourceTextField idField = new DataSourceTextField("id", "ID");
idField.setPrimaryKey(true);
@@ -75,11 +79,11 @@ public class RecentlyAddedResourceDS extends DataSource {
// Asume success
response.setStatus(0);
switch (request.getOperationType()) {
- case FETCH:
- executeFetch(request, response);
- break;
- default:
- break;
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
}
return request.getData();
@@ -87,21 +91,43 @@ public class RecentlyAddedResourceDS extends DataSource {
public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria c = new ResourceCriteria();
+ long ctime = -1;
+ int maxItems = -1;
+ //retrieve current portlet display settings
+ if ((this.portlet != null) && (this.portlet instanceof RecentlyAddedView)) {
+ RecentlyAddedView recentAdditionsPortlet = (RecentlyAddedView) this.portlet;
+ if (recentAdditionsPortlet != null) {
+ if (getMaximumRecentlyAddedToDisplay() > 0) {
+ maxItems = getMaximumRecentlyAddedToDisplay();
+ }
- String p = request.getCriteria().getAttribute("parentId");
+ //define the time window
+ if (getMaximumRecentlyAddedWithinHours() > 0) {
+ ctime = System.currentTimeMillis()
+ - (getMaximumRecentlyAddedWithinHours() * MeasurementUtility.HOURS);
+ setOldestDate(ctime);
+ }
- if (p == null) {
- c.addFilterResourceCategory(ResourceCategory.PLATFORM);
- c.fetchChildResources(true);
- } else {
- c.addFilterParentResourceId(Integer.parseInt(p));
+ }
}
+ // TODO: spinder: revisit this later. ResourceCriteria mechanism does not work. Not sure if it's better?
+ // ResourceCriteria c = new ResourceCriteria();
+ //
+ // String p = request.getCriteria().getAttribute("parentId");
+ //
+ // if (p == null) {
+ // c.addFilterResourceCategory(ResourceCategory.PLATFORM);
+ // c.fetchChildResources(true);
+ // } else {
+ // c.addFilterParentResourceId(Integer.parseInt(p));
+ // }
+
// TODO GH: Enhance resourceCriteria query to support itime based filtering for
// "Recently imported" resources
- GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100,
+ // GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100,
+ GWTServiceLookup.getResourceService().findRecentlyAddedResources(ctime, maxItems,
new AsyncCallback<List<RecentlyAddedResourceComposite>>() {
public void onFailure(Throwable throwable) {
CoreGUI.getErrorHandler().handleError("Failed to load recently added resources", throwable);
@@ -120,38 +146,38 @@ public class RecentlyAddedResourceDS extends DataSource {
processResponse(request.getRequestId(), response);
}
});
-//
-// GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() {
-// public void onFailure(Throwable caught) {
-// CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught);
-// response.setStatus(DSResponse.STATUS_FAILURE);
-// processResponse(request.getRequestId(), response);
-// }
-//
-// public void onSuccess(PageList<Resource> result) {
-// PageList<Resource> all = new PageList<Resource>();
-//
-// for (Resource root : result) {
-// all.add(root);
-// if (root.getChildResources() != null)
-// all.addAll(root.getChildResources());
-// }
-//
-//
-// response.setData(buildNodes(all));
-// response.setTotalRows(all.getTotalSize());
-// processResponse(request.getRequestId(), response);
-// }
-// });
+ //
+ // GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() {
+ // public void onFailure(Throwable caught) {
+ // CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught);
+ // response.setStatus(DSResponse.STATUS_FAILURE);
+ // processResponse(request.getRequestId(), response);
+ // }
+ //
+ // public void onSuccess(PageList<Resource> result) {
+ // PageList<Resource> all = new PageList<Resource>();
+ //
+ // for (Resource root : result) {
+ // all.add(root);
+ // if (root.getChildResources() != null)
+ // all.addAll(root.getChildResources());
+ // }
+ //
+ //
+ // response.setData(buildNodes(all));
+ // response.setTotalRows(all.getTotalSize());
+ // processResponse(request.getRequestId(), response);
+ // }
+ // });
}
-// private TreeNode[] buildNodes(PageList<Resource> list) {
-// TreeNode[] treeNodes = new TreeNode[list.size()];
-// for (int i = 0; i < list.size(); ++i) {
-// treeNodes[i] = new ResourceTreeNode(list.get(i));
-// }
-// return treeNodes;
-// }
+ // private TreeNode[] buildNodes(PageList<Resource> list) {
+ // TreeNode[] treeNodes = new TreeNode[list.size()];
+ // for (int i = 0; i < list.size(); ++i) {
+ // treeNodes[i] = new ResourceTreeNode(list.get(i));
+ // }
+ // return treeNodes;
+ // }
private TreeNode[] buildNodes(List<RecentlyAddedResourceComposite> list) {
TreeNode[] treeNodes = new TreeNode[list.size()];
@@ -169,8 +195,7 @@ public class RecentlyAddedResourceDS extends DataSource {
Date dateAdded = new Date(recentlyAdded.getCtime());
String id = String.valueOf(recentlyAdded.getId());
- String parentId = recentlyAdded.getParentId() == 0 ? null
- : String.valueOf((recentlyAdded.getParentId()));
+ String parentId = recentlyAdded.getParentId() == 0 ? null : String.valueOf((recentlyAdded.getParentId()));
setID(id);
setParentID(parentId);
@@ -191,8 +216,8 @@ public class RecentlyAddedResourceDS extends DataSource {
this.resource = resource;
String id = String.valueOf(resource.getId());
- String parentId = resource.getParentResource() == null ? null
- : String.valueOf((resource.getParentResource().getId()));
+ String parentId = resource.getParentResource() == null ? null : String.valueOf((resource
+ .getParentResource().getId()));
setID(id);
setParentID(parentId);
@@ -201,10 +226,10 @@ public class RecentlyAddedResourceDS extends DataSource {
setAttribute("parentId", parentId);
setAttribute("name", resource.getName());
setAttribute("timestamp", "");//String.valueOf(resource.getItime())); // Seems to be null
- setAttribute("currentAvailability",
- resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP
- ? "/images/icons/availability_green_16.png"
- : "/images/icons/availability_red_16.png");
+ setAttribute(
+ "currentAvailability",
+ resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP ? "/images/icons/availability_green_16.png"
+ : "/images/icons/availability_red_16.png");
}
public Resource getResource() {
@@ -223,4 +248,29 @@ public class RecentlyAddedResourceDS extends DataSource {
return getAttribute("parentId");
}
}
+
+ public int getMaximumRecentlyAddedToDisplay() {
+ return maximumRecentlyAddedToDisplay;
+ }
+
+ public void setMaximumRecentlyAddedToDisplay(int maximumRecentlyAddedToDisplay) {
+ this.maximumRecentlyAddedToDisplay = maximumRecentlyAddedToDisplay;
+ }
+
+ public int getMaximumRecentlyAddedWithinHours() {
+ return maximumRecentlyAddedWithinHours;
+ }
+
+ public void setMaximumRecentlyAddedWithinHours(int maximumRecentlyAddedWithinHours) {
+ this.maximumRecentlyAddedWithinHours = maximumRecentlyAddedWithinHours;
+ }
+
+ public long getOldestDate() {
+ return oldestDate;
+ }
+
+ public void setOldestDate(long oldestDate) {
+ this.oldestDate = oldestDate;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
index c856151..31bcf9d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
@@ -49,27 +49,25 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
private boolean simple = true;
private DashboardPortlet storedPortlet;
+ private RecentlyAddedResourceDS dataSource;
+ private TreeGrid treeGrid = null;
public static final String unlimited = "unlimited";
public static final String defaultValue = unlimited;
private static final String RECENTLY_ADDED_SHOW_MAX = "recently-added-show-amount";
-
private static final String RECENTLY_ADDED_SHOW_HRS = "recently-added-time-range";
public RecentlyAddedView(String locatorId) {
super(locatorId);
+ //insert the datasource
+ this.dataSource = new RecentlyAddedResourceDS(this);
}
- private TreeGrid treeGrid = null;
-
- private int maximumRecentlyAddedToDisplay;
- private int maximumRecentlyAddedWithinHours;
-
@Override
protected void onInit() {
super.onInit();
treeGrid = new TreeGrid();
- treeGrid.setDataSource(new RecentlyAddedResourceDS());
+ treeGrid.setDataSource(getDataSource());
treeGrid.setAutoFetchData(true);
treeGrid.setTitle("Recently Added Resources");
treeGrid.setResizeFieldsInRealTime(true);
@@ -83,7 +81,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
}
});
- ListGridField timestampField = new ListGridField("timestamp", "Date//Time");
+ ListGridField timestampField = new ListGridField("timestamp", "Date/Time");
treeGrid.setFields(resourceNameField, timestampField);
@@ -100,20 +98,24 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX) != null) {
//retrieve and translate to int
String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX).getStringValue();
- if (retrieved.equals(unlimited)) {
- maximumRecentlyAddedToDisplay = -1;
- } else {
- maximumRecentlyAddedToDisplay = Integer.parseInt(retrieved);
+ if (getDataSource() != null) {//check for initialization of datasource unavailability
+ if (retrieved.equals(unlimited)) {
+ getDataSource().setMaximumRecentlyAddedToDisplay(-1);
+ } else {
+ getDataSource().setMaximumRecentlyAddedToDisplay(Integer.parseInt(retrieved));
+ }
}
} else {//create setting
storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_MAX, defaultValue));
}
if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS) != null) {
String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS).getStringValue();
- if (retrieved.equals(unlimited)) {
- setMaximumRecentlyAddedWithinHours(-1);
- } else {
- setMaximumRecentlyAddedWithinHours(Integer.parseInt(retrieved));
+ if (getDataSource() != null) {//check for initialization of datasource unavailability
+ if (retrieved.equals(unlimited)) {
+ getDataSource().setMaximumRecentlyAddedWithinHours(-1);
+ } else {
+ getDataSource().setMaximumRecentlyAddedWithinHours(Integer.parseInt(retrieved));
+ }
}
} else {
storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue));
@@ -130,7 +132,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
//-------------combobox for number of recently added resources to display on the dashboard
final SelectItem maximumRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_MAX);
maximumRecentlyAddedComboBox.setTitle("Show");
- maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved resources on dashboard.</b></nobr>");
+ maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved platforms on dashboard.</b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumRecentlyAddedComboBox.setType("selection");
//define acceptable values for display amount
@@ -216,19 +218,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
this.treeGrid.markForRedraw();
}
- public int getMaximumRecentlyAddedToDisplay() {
- return maximumRecentlyAddedToDisplay;
- }
-
- public void setMaximumRecentlyAddedToDisplay(int maximumRecentlyAddedToDisplay) {
- this.maximumRecentlyAddedToDisplay = maximumRecentlyAddedToDisplay;
- }
-
- public int getMaximumRecentlyAddedWithinHours() {
- return maximumRecentlyAddedWithinHours;
- }
-
- public void setMaximumRecentlyAddedWithinHours(int maximumRecentlyAddedWithinHours) {
- this.maximumRecentlyAddedWithinHours = maximumRecentlyAddedWithinHours;
+ public RecentlyAddedResourceDS getDataSource() {
+ return dataSource;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 3faa954..2778c59 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -62,6 +62,9 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
public static final String KEY = "Has Alerts or Currently Unavailable";
private static final String TITLE = KEY;
private DashboardPortlet storedPortlet;
+ //reference to datasource
+ private ProblemResourcesDataSource dataSource;
+
//constants
public static final String unlimited = "unlimited";
public static final String defaultValue = unlimited;
@@ -97,9 +100,6 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
}
}
- //reference to datasource
- private ProblemResourcesDataSource dataSource;
-
@Override
public ProblemResourcesDataSource getDataSource() {
return (ProblemResourcesDataSource) super.getDataSource();
@@ -251,7 +251,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
}
protected void refreshTableInfo() {
- if (showFooter) {
+ if (isShowFooter()) {
long begin = 0;
List<Long> bounds = MeasurementUtility.calculateTimeFrame(getDataSource()
.getMaximumProblemResourcesWithinHours(), MeasurementUtility.UNIT_HOURS);
@@ -272,7 +272,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
}
}
//remove selected count as portlet is view only. Selection not used.
- this.tableInfo.setContents("Total: " + getListGrid().getTotalRows());
+ getTableInfo().setContents("Total: " + getListGrid().getTotalRows());
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 64fd5f8..e228f15 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -213,7 +213,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
if (!authorizationManager.hasResourcePermission(user, Permission.MODIFY_RESOURCE, resource.getId())) {
throw new PermissionException("You do not have permission to modify Resource with id " + resource.getId()
- + ".");
+ + ".");
}
/*if (getResourceByParentAndKey(user, resource.getParentResource(), resource.getResourceKey()) != null)
@@ -246,8 +246,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
@SuppressWarnings("unchecked")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public List<Integer> uninventoryResource(Subject user, int resourceId) {
-// Resource resource = resourceManager.getResourceTree(resourceId, true);
- Resource resource = entityManager.find(Resource.class,resourceId);
+ // Resource resource = resourceManager.getResourceTree(resourceId, true);
+ Resource resource = entityManager.find(Resource.class, resourceId);
if (resource == null) {
log.info("Delete resource not possible, as resource with id [" + resourceId + "] was not found");
return Collections.emptyList(); // Resource not found. TODO give a nice message to the user
@@ -313,10 +313,10 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION is an expensive recursive query
// But luckily we have already (through such a recursive query above) determined the doomed resources
-// Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION);
-// markDeletedQuery.setParameter("resourceId", resourceId);
-// markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED);
-// int resourcesDeleted = markDeletedQuery.executeUpdate();
+ // Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION);
+ // markDeletedQuery.setParameter("resourceId", resourceId);
+ // markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED);
+ // int resourcesDeleted = markDeletedQuery.executeUpdate();
i = 0;
int resourcesDeleted = 0;
@@ -326,11 +326,11 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
j = toBeDeletedResourceIds.size();
List<Integer> idsToDelete = toBeDeletedResourceIds.subList(i, j);
-
- Query markDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK);
+ Query markDeletedQuery = entityManager
+ .createNamedQuery(Resource.QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK);
markDeletedQuery.setParameter("resourceIds", idsToDelete);
markDeletedQuery.setParameter("status", InventoryStatus.UNINVENTORIED);
- resourcesDeleted+= markDeletedQuery.executeUpdate();
+ resourcesDeleted += markDeletedQuery.executeUpdate();
i = j;
}
@@ -1063,7 +1063,11 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
query.setParameter("oldestEpochTime", ctime);
- query.setMaxResults(maxItems); // this query is only used by the dashboard portlet, let's not blow it up
+ if ((maxItems > 100) || (maxItems < 0)) {//cap infininte(-1) and large requests to 100
+ query.setMaxResults(100); // this query is only used by the dashboard portlet, let's not blow it up
+ } else {
+ query.setMaxResults(maxItems);
+ }
return query.getResultList();
}
@@ -2093,14 +2097,14 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
Resource parent = resource.getParentResource();
ResourceComposite composite = new ResourceComposite(resource, parent, availType);
composite.setResourceFacets(typeManager.getResourceFacets(resource.getResourceType().getId()));
- Set<Permission> permissions = authorizationManager.getImplicitResourcePermissions(subject, resource.getId());
+ Set<Permission> permissions = authorizationManager
+ .getImplicitResourcePermissions(subject, resource.getId());
composite.setResourcePermission(new ResourcePermission(permissions));
// TODO: jmarques: Alter criteria projection to include permissions.
results.add(composite);
}
- return new PageList<ResourceComposite>(results, resources.getTotalSize(), resources
- .getPageControl());
+ return new PageList<ResourceComposite>(results, resources.getTotalSize(), resources.getPageControl());
}
@SuppressWarnings("unchecked")
@@ -2168,6 +2172,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public <T> List<DisambiguationReport<T>> disambiguate(List<T> results, IntExtractor<? super T> extractor,
DisambiguationUpdateStrategy updateStrategy) {
- return Disambiguator.disambiguate(results, updateStrategy, extractor, entityManager, typeManager.getDuplicateTypeNames());
+ return Disambiguator.disambiguate(results, updateStrategy, extractor, entityManager, typeManager
+ .getDuplicateTypeNames());
}
}
commit e3467c9c4e144cf4f1859fdce25711b6239c2783
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Sep 13 09:00:28 2010 -0400
enable server side for autodiscovery and some cleanup.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index e66f091..8159d23 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -35,6 +35,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.AutodiscoveryQueueDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -54,6 +55,15 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
super(locatorId, true);
}
+ @Override
+ protected void onInit() {
+ super.onInit();
+ //initialize the datasource to include Portlet instance
+ if (getTreeGrid() != null) {
+ getTreeGrid().setDataSource(new AutodiscoveryQueueDataSource(this));
+ }
+ }
+
/** Implement configure action.
*/
@Override
@@ -63,9 +73,9 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
//retrieve and translate to int
String retrieved = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
if (retrieved.equals(unlimited)) {
- maximumPlatformsToDisplay = -1;
+ setMaximumPlatformsToDisplay(-1);
} else {
- maximumPlatformsToDisplay = Integer.parseInt(retrieved);
+ setMaximumPlatformsToDisplay(Integer.parseInt(retrieved));
}
} else {//create setting
storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
@@ -153,4 +163,12 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
return new AutodiscoveryPortlet(locatorId);
}
}
+
+ public int getMaximumPlatformsToDisplay() {
+ return maximumPlatformsToDisplay;
+ }
+
+ public void setMaximumPlatformsToDisplay(int maximumPlatformsToDisplay) {
+ this.maximumPlatformsToDisplay = maximumPlatformsToDisplay;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
index 01a5ad3..63ed782 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
@@ -20,7 +20,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery;
import java.util.ArrayList;
import java.util.Date;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -40,6 +39,8 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
@@ -48,15 +49,20 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
*/
public class AutodiscoveryQueueDataSource extends DataSource {
-
+ private Portlet portlet = null;
+ private int unlimited = -1;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+ public AutodiscoveryQueueDataSource(Portlet portlet) {
+ this();
+ this.portlet = portlet;
+ }
+
public AutodiscoveryQueueDataSource() {
setClientOnly(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
-
DataSourceTextField idField = new DataSourceTextField("id", "ID");
idField.setPrimaryKey(true);
@@ -75,7 +81,8 @@ public class AutodiscoveryQueueDataSource extends DataSource {
DataSourceTextField statusField = new DataSourceTextField("status", "Inventory Status");
- setFields(idField, parentIdField, resourceNameField, resourceKeyField, resourceTypeField, descriptionField, statusField, timestampField);
+ setFields(idField, parentIdField, resourceNameField, resourceKeyField, resourceTypeField, descriptionField,
+ statusField, timestampField);
}
protected Object transformRequest(DSRequest request) {
@@ -84,17 +91,16 @@ public class AutodiscoveryQueueDataSource extends DataSource {
// Asume success
response.setStatus(0);
switch (request.getOperationType()) {
- case FETCH:
- executeFetch(request, response);
- break;
- default:
- break;
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
}
return request.getData();
}
-
protected void executeFetch(final DSRequest request, final DSResponse response) {
PageControl pc = getPageControl(request);
@@ -114,21 +120,18 @@ public class AutodiscoveryQueueDataSource extends DataSource {
statuses.add(InventoryStatus.NEW);
}
+ resourceService.getQueuedPlatformsAndServers(statuses, pc, new AsyncCallback<Map<Resource, List<Resource>>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load inventory discovery queue", caught);
+ }
- resourceService.getQueuedPlatformsAndServers(statuses, pc,
- new AsyncCallback<Map<Resource, List<Resource>>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load inventory discovery queue", caught);
- }
-
- public void onSuccess(Map<Resource, List<Resource>> result) {
- response.setData(buildNodes(result));
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(Map<Resource, List<Resource>> result) {
+ response.setData(buildNodes(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
-
private TreeNode[] buildNodes(Map<Resource, List<Resource>> result) {
ArrayList<ResourceTreeNode> nodes = new ArrayList<ResourceTreeNode>();
@@ -146,7 +149,6 @@ public class AutodiscoveryQueueDataSource extends DataSource {
return treeNodes;
}
-
/**
* Returns a prepopulated PageControl based on the provided DSRequest. This will set sort fields,
* pagination, but *not* filter fields.
@@ -157,10 +159,12 @@ public class AutodiscoveryQueueDataSource extends DataSource {
protected PageControl getPageControl(DSRequest request) {
// Initialize paging.
PageControl pageControl;
- if (request.getStartRow() == null || request.getEndRow() == null) {
- pageControl = new PageControl();
+ //retrieve portlet.configurationInformation
+ if ((this.portlet != null) || (this.portlet instanceof AutodiscoveryPortlet)) {//using default
+ AutodiscoveryPortlet settings = (AutodiscoveryPortlet) this.portlet;
+ pageControl = new PageControl(0, settings.getMaximumPlatformsToDisplay());
} else {
- pageControl = PageControl.getExplicitPageControl(request.getStartRow(), request.getEndRow() - request.getStartRow());
+ pageControl = new PageControl(0, unlimited);
}
// Initialize sorting.
@@ -177,7 +181,6 @@ public class AutodiscoveryQueueDataSource extends DataSource {
return pageControl;
}
-
public static class ResourceTreeNode extends TreeNode {
private Resource resource;
@@ -186,8 +189,8 @@ public class AutodiscoveryQueueDataSource extends DataSource {
this.resource = resource;
String id = String.valueOf(resource.getId());
- String parentId = resource.getParentResource() == null ? null
- : String.valueOf((resource.getParentResource().getId()));
+ String parentId = resource.getParentResource() == null ? null : String.valueOf((resource
+ .getParentResource().getId()));
setID(id);
setParentID(parentId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 2d81fe0..445d1cb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.SelectionAppearance;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.IButton;
@@ -57,6 +58,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
private boolean simple = false;
private TreeGrid treeGrid;
private ToolStrip footer;
+ private DataSource dataSource = null;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -107,7 +109,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
treeGrid.setHeight100();
- treeGrid.setDataSource(new AutodiscoveryQueueDataSource());
+ treeGrid.setDataSource(dataSource = new AutodiscoveryQueueDataSource());
treeGrid.setAutoFetchData(true);
treeGrid.setResizeFieldsInRealTime(true);
@@ -230,4 +232,12 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
this.treeGrid.invalidateCache();
this.treeGrid.markForRedraw();
}
+
+ public DataSource getDataSource() {
+ return dataSource;
+ }
+
+ public TreeGrid getTreeGrid() {
+ return treeGrid;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
index bc72530..1dd89ce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
@@ -1,5 +1,23 @@
package org.rhq.enterprise.gui.coregui.client.util;
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
import java.util.ArrayList;
import java.util.List;
commit 3bd640d779cbd010aa70fa13a81a54598ed78ada
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sun Sep 12 21:23:06 2010 -0400
add footer for portlet and port of measurement utility.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index f30ab10..0d4e6d6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -77,12 +77,13 @@ public class Table extends LocatableHLayout {
private TableFilter filterForm;
private ListGrid listGrid;
private ToolStrip footer;
- private Label tableInfo;
+ protected Label tableInfo;
private List<String> headerIcons = new ArrayList<String>();
private boolean showHeader = true;
- private boolean showFooter = true;
+ protected boolean showFooter = true;
+ private boolean showFooterRefresh = true;
private String tableTitle;
private Criteria criteria;
@@ -122,7 +123,7 @@ public class Table extends LocatableHLayout {
private List<TableActionInfo> tableActions = new ArrayList<TableActionInfo>();
private boolean tableActionDisableOverride = false;
- private List<Canvas> extraWidgets = new ArrayList<Canvas>();
+ protected List<Canvas> extraWidgets = new ArrayList<Canvas>();
public Table(String locatorId) {
this(locatorId, null, null, null, null, true);
@@ -314,13 +315,15 @@ public class Table extends LocatableHLayout {
footer.addMember(new LayoutSpacer());
- IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh");
- refreshButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- listGrid.invalidateCache();
- }
- });
- footer.addMember(refreshButton);
+ if (isShowFooterRefresh()) {
+ IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh");
+ refreshButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ listGrid.invalidateCache();
+ }
+ });
+ footer.addMember(refreshButton);
+ }
footer.addMember(tableInfo);
@@ -648,4 +651,12 @@ public class Table extends LocatableHLayout {
this.actionButton = actionButton;
}
}
+
+ public boolean isShowFooterRefresh() {
+ return showFooterRefresh;
+ }
+
+ public void setShowFooterRefresh(boolean showFooterRefresh) {
+ this.showFooterRefresh = showFooterRefresh;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 815afd7..3faa954 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -19,9 +19,14 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+//import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
@@ -34,11 +39,14 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
* A view that displays a paginated table of Resources with alerts,
@@ -48,13 +56,13 @@ import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource
*/
public class ProblemResourcesPortlet extends Table implements CustomSettingsPortlet {
+ //keys for smart gwt elements. should be unique
public static final String PROBLEM_RESOURCE_SHOW_HRS = "max-problems-query-span";
public static final String PROBLEM_RESOURCE_SHOW_MAX = "max-problems-shown";
public static final String KEY = "Has Alerts or Currently Unavailable";
private static final String TITLE = KEY;
- private int maximumProblemResourcesToDisplay = -1;
- private int maximumProblemResourcesWithinHours = -1;
private DashboardPortlet storedPortlet;
+ //constants
public static final String unlimited = "unlimited";
public static final String defaultValue = unlimited;
@@ -62,10 +70,13 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
super(locatorId, TITLE, true);
setShowHeader(false);
- setShowFooter(false);
+ setShowFooter(true);
+ //disable footer refresh
+ setShowFooterRefresh(false);
setOverflow(Overflow.HIDDEN);
+ //insert the datasource
this.dataSource = new ProblemResourcesDataSource(this);
setDataSource(this.dataSource);
@@ -82,16 +93,18 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
listGrid.setCellHeight(50);
//wrap to display disambiguation
listGrid.setWrapCells(true);
- listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%");
- listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%");
- listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%");
- listGrid.getField(ProblemResourcesDataSource.available).setWidth("10%");
+ addExtraWidget(new TimeRange(this.getLocatorId(), this));
}
}
//reference to datasource
private ProblemResourcesDataSource dataSource;
+ @Override
+ public ProblemResourcesDataSource getDataSource() {
+ return (ProblemResourcesDataSource) super.getDataSource();
+ }
+
/** Implement configure action.
*
*/
@@ -99,27 +112,39 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
this.storedPortlet = storedPortlet;
- if (storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_MAX) != null) {
+ int configuredValue = -1;
+
+ //determine configuration value for ProblemResourceShowMax
+ configuredValue = populateConfigurationValue(storedPortlet, PROBLEM_RESOURCE_SHOW_MAX, defaultValue);
+ getDataSource().setMaximumProblemResourcesToDisplay(configuredValue);
+
+ //determine configuration value for ProblemResourceShowHrs
+ configuredValue = populateConfigurationValue(storedPortlet, PROBLEM_RESOURCE_SHOW_HRS, defaultValue);
+ getDataSource().setMaximumProblemResourcesWithinHours(configuredValue);
+ }
+
+ /**Determine which configuration value to use given the property passed in.
+ *
+ * @param storedPortlet DashboardPortlet instance
+ * @param propertyKey Widget key
+ * @param defaultKeyValue default value to be used if property not yet set.
+ * @return int value of configuration, Ex. 1,5,10,unlimited where unlimited==-1.
+ */
+ private int populateConfigurationValue(DashboardPortlet storedPortlet, String propertyKey, String defaultKeyValue) {
+ int configuredValue;
+ if ((storedPortlet != null) && (storedPortlet.getConfiguration().getSimple(propertyKey) != null)) {
//retrieve and translate to int
- String retrieved = storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_MAX).getStringValue();
+ String retrieved = storedPortlet.getConfiguration().getSimple(propertyKey).getStringValue();
if (retrieved.equals(unlimited)) {
- maximumProblemResourcesToDisplay = -1;
+ configuredValue = -1;
} else {
- maximumProblemResourcesToDisplay = Integer.parseInt(retrieved);
+ configuredValue = Integer.parseInt(retrieved);
}
- } else {//create setting
- storedPortlet.getConfiguration().put(new PropertySimple(PROBLEM_RESOURCE_SHOW_MAX, defaultValue));
- }
- if (storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_HRS) != null) {
- String retrieved = storedPortlet.getConfiguration().getSimple(PROBLEM_RESOURCE_SHOW_HRS).getStringValue();
- if (retrieved.equals(unlimited)) {
- setMaximumProblemResourcesWithinHours(-1);
- } else {
- setMaximumProblemResourcesWithinHours(Integer.parseInt(retrieved));
- }
- } else {
- storedPortlet.getConfiguration().put(new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, defaultValue));
+ } else {//create setting if not already there.
+ storedPortlet.getConfiguration().put(new PropertySimple(propertyKey, defaultKeyValue));
+ configuredValue = -1;
}
+ return configuredValue;
}
@Override
@@ -198,6 +223,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
storedPortlet.getConfiguration().put(
new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, form.getValue(PROBLEM_RESOURCE_SHOW_HRS)));
}
+ refresh();
}
});
@@ -224,19 +250,62 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
return definition;
}
- public int getMaximumProblemResourcesToDisplay() {
- return maximumProblemResourcesToDisplay;
+ protected void refreshTableInfo() {
+ if (showFooter) {
+ long begin = 0;
+ List<Long> bounds = MeasurementUtility.calculateTimeFrame(getDataSource()
+ .getMaximumProblemResourcesWithinHours(), MeasurementUtility.UNIT_HOURS);
+ begin = bounds.get(0);
+ long end = bounds.get(1);
+
+ //if range spans greater than year then change formatter.
+ if ((end - begin) > MeasurementUtility.ONE_YEAR) {
+ timeRange = new String[] { MeasurementUtility.getDateTimeYearFormatter().format(new Date(begin)),
+ MeasurementUtility.getDateTimeYearFormatter().format(new Date(end)) };
+ } else {
+ timeRange = new String[] { MeasurementUtility.getDateTimeFormatter().format(new Date(begin)),
+ MeasurementUtility.getDateTimeFormatter().format(new Date(end)) };
+ }
+ for (Canvas extraWidget : extraWidgets) {
+ if (extraWidget instanceof TableWidget) {
+ ((TableWidget) extraWidget).refresh(getListGrid());
+ }
+ }
+ //remove selected count as portlet is view only. Selection not used.
+ this.tableInfo.setContents("Total: " + getListGrid().getTotalRows());
+ }
+ }
+
+ private String[] timeRange = null;
+
+ public String[] getTimeRange() {
+ return timeRange;
}
- public void setMaximumProblemResourcesToDisplay(int maxPerRow) {
- this.maximumProblemResourcesToDisplay = maxPerRow;
+}
+
+/**Construct table widget Label to display timerange settings used with latest datasource query.
+ *
+ * @author spinder
+ */
+class TimeRange extends LocatableHLayout implements TableWidget {
+ private Label label = new Label();
+ private ProblemResourcesPortlet portlet = null;
+
+ public TimeRange(String locatorId, ProblemResourcesPortlet problemResourcesPortlet) {
+ super(locatorId);
+ this.portlet = problemResourcesPortlet;
}
- public void setMaximumProblemResourcesWithinHours(int maximumProblemResourcesWithinHours) {
- this.maximumProblemResourcesWithinHours = maximumProblemResourcesWithinHours;
+ @Override
+ public void refresh(ListGrid listGrid) {
+ this.label.setWidth(400);
+ this.label.setContents("From " + portlet.getTimeRange()[0] + " to " + portlet.getTimeRange()[1]);
}
- public int getMaximumProblemResourcesWithinHours() {
- return maximumProblemResourcesWithinHours;
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ addMember(this.label);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 7597d13..38c316b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -52,6 +52,10 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
public static final String alerts = "alerts";
public static final String available = "available";
private Portlet portlet = null;
+ private long oldestDate = -1;
+ //configure elements
+ private int maximumProblemResourcesToDisplay = -1;
+ private int maximumProblemResourcesWithinHours = -1;
/** Build list of fields for the datasource and then adds them to it.
* @param problemResourcesPortlet
@@ -108,13 +112,13 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
ProblemResourcesPortlet problemPortlet = (ProblemResourcesPortlet) this.portlet;
//populate criteria with portlet preferences defined.
if (problemPortlet != null) {
- if (problemPortlet.getMaximumProblemResourcesToDisplay() > 0) {
- maxItems = problemPortlet.getMaximumProblemResourcesToDisplay();
+ if (getMaximumProblemResourcesToDisplay() > 0) {
+ maxItems = getMaximumProblemResourcesToDisplay();
}
//define the time window
- if (problemPortlet.getMaximumProblemResourcesWithinHours() > 0) {
- ctime = System.currentTimeMillis()
- - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000);
+ if (getMaximumProblemResourcesWithinHours() > 0) {
+ ctime = System.currentTimeMillis() - (getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000);
+ setOldestDate(ctime);
}
}
}
@@ -200,4 +204,28 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
public DisambiguationReport<ProblemResourceComposite> copyValues(ListGridRecord from) {
throw new UnsupportedOperationException("ProblemResource data is read only");
}
+
+ public long getOldestDate() {
+ return oldestDate;
+ }
+
+ public void setOldestDate(long oldestDate) {
+ this.oldestDate = oldestDate;
+ }
+
+ public int getMaximumProblemResourcesToDisplay() {
+ return maximumProblemResourcesToDisplay;
+ }
+
+ public void setMaximumProblemResourcesToDisplay(int maxPerRow) {
+ this.maximumProblemResourcesToDisplay = maxPerRow;
+ }
+
+ public void setMaximumProblemResourcesWithinHours(int maximumProblemResourcesWithinHours) {
+ this.maximumProblemResourcesWithinHours = maximumProblemResourcesWithinHours;
+ }
+
+ public int getMaximumProblemResourcesWithinHours() {
+ return maximumProblemResourcesWithinHours;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
new file mode 100644
index 0000000..bc72530
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementUtility.java
@@ -0,0 +1,99 @@
+package org.rhq.enterprise.gui.coregui.client.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+
+public class MeasurementUtility {
+
+ private static DateTimeFormat formatter = DateTimeFormat.getFormat("MMM d, hh:mm a");
+ private static DateTimeFormat formatterYear = DateTimeFormat.getFormat("MMM d, yyyy hh:mm a");
+
+ //Time constants
+ public static final int UNIT_COLLECTION_POINTS = 1;
+ public static final int UNIT_MINUTES = 2;
+ public static final int UNIT_HOURS = 3;
+ public static final int UNIT_DAYS = 4;
+ public static final int UNIT_WEEKS = 5;
+ /*
+ * show units in terms of milliseconds
+ */
+ public static final long MINUTES = 60000;
+ public static final long HOURS = 3600000;
+ public static final long DAYS = 86400000;
+ public static final long WEEKS = 604800000;
+
+ /**
+ * five minutes in millisecond increments
+ */
+ public static final long FIVE_MINUTES = 300000;
+ public static final long ONE_YEAR = WEEKS * 52;
+
+ /**
+ * Method calculateTimeFrame
+ * <p/>
+ * Returns a two element<code>List</code> of <code>Long</code> objects representing the begin and end times (in
+ * milliseconds since the epoch) of the timeframe. Returns null instead if the time unit is indicated as
+ * <code>UNIT_COLLECTION_POINTS</code>. Ported to GWT from MeasurementUtils(i:server side dep
+ * ii:old DateFormat doesn't play well with GWT).
+ *
+ * @param lastN the number of time units in the time frame
+ * @param unit the unit of time (as defined by <code>UNIT_*</code> constants
+ * @return List
+ */
+ public static List<Long> calculateTimeFrame(int lastN, int unit) {
+ List<Long> l = new ArrayList<Long>(0);
+ if (unit == UNIT_COLLECTION_POINTS) {
+ return null;
+ }
+
+ long now = System.currentTimeMillis();
+
+ long retrospective = lastN;
+
+ switch (unit) {
+ case UNIT_WEEKS:
+ retrospective *= WEEKS;
+ break;
+ case UNIT_MINUTES:
+ retrospective *= MINUTES;
+ break;
+ case UNIT_HOURS:
+ retrospective *= HOURS;
+ break;
+ case UNIT_DAYS:
+ retrospective *= DAYS;
+ break;
+ default:
+ retrospective = -1;
+ break;
+ }
+
+ if (retrospective < 0) {//translate unlimited hrs to 0 time.
+ retrospective = now;
+ }
+
+ l.add(now - retrospective);
+ l.add(now);
+
+ return l;
+ }
+
+ /**Utility to return shared DateTimeFormat("MMM d, hh:mm a");
+ *
+ * @return DateTimeFormat
+ */
+ public static DateTimeFormat getDateTimeFormatter() {
+ return formatter;
+ }
+
+ /**Utility to return shared DateTimeFormat("MMM d, yyyy hh:mm a");
+ *
+ * @return DateTimeFormat
+ */
+ public static DateTimeFormat getDateTimeYearFormatter() {
+ return formatterYear;
+ }
+
+}
commit 4b78144546207ab92eddf048699a3a46fbb1434b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Sat Sep 11 16:29:57 2010 -0400
extract superclass for resource and group detail view classes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
index 1302774..cba747e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
@@ -35,7 +35,7 @@ public class ViewId {
public ViewId(String path, Breadcrumb... breadcrumbs) {
this.path = path;
if ( breadcrumbs != null) {
- this.breadcrumbs = Arrays.asList(breadcrumbs);
+ this.breadcrumbs = Arrays.asList(breadcrumbs);
} else {
this.breadcrumbs = new ArrayList<Breadcrumb>();
}
@@ -57,6 +57,11 @@ public class ViewId {
}
@Override
+ public String toString() {
+ return this.path;
+ }
+
+ @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
new file mode 100644
index 0000000..bdd1981
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -0,0 +1,198 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.types.Side;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.layout.Layout;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
+import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+import java.util.List;
+
+/**
+ * @author Greg Hinkle
+ * @author Ian Springer
+ */
+public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends LocatableVLayout
+ implements BookmarkableView, TwoLevelTabSelectedHandler {
+ private String baseViewPath;
+ private TwoLevelTabSet tabSet;
+ private String tabName;
+ private String subTabName;
+ private U titleBar;
+
+ public AbstractTwoLevelTabSetView(String locatorId, String baseViewPath) {
+ super(locatorId);
+ this.baseViewPath = baseViewPath;
+
+ setWidth100();
+ setHeight100();
+
+ this.titleBar = createTitleBar();
+ addMember(this.titleBar);
+
+ this.tabSet = new TwoLevelTabSet(extendLocatorId("TabSet"));
+ this.tabSet.setTabBarPosition(Side.TOP);
+ this.tabSet.setWidth100();
+ this.tabSet.setHeight100();
+ this.tabSet.setEdgeMarginSize(0);
+ this.tabSet.setEdgeSize(0);
+
+ List<TwoLevelTab> tabsList = createTabs();
+ this.tabSet.setTabs(tabsList.toArray(new TwoLevelTab[tabsList.size()]));
+
+ this.tabSet.addTwoLevelTabSelectedHandler(this);
+
+ addMember(this.tabSet);
+ }
+
+ // ------------------ Abstract Methods --------------------
+ public abstract Integer getSelectedItemId();
+
+ protected abstract U createTitleBar();
+
+ protected abstract List<TwoLevelTab> createTabs();
+
+ protected abstract void loadSelectedItem(int itemId, ViewPath viewPath);
+
+ protected abstract void updateTabContent(T selectedItem);
+ // ---------------------------------------------------------
+
+ protected U getTitleBar() {
+ return this.titleBar;
+ }
+
+ public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
+ //CoreGUI.printWidgetTree();
+
+ if (getSelectedItemId() == null) {
+ // History.fireCurrentHistoryState();
+ } else {
+ // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
+ // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
+ String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
+ String path = this.baseViewPath + "/" + getSelectedItemId() + tabPath;
+
+ // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
+ // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
+ // current history item.
+ if (!History.getToken().equals(path)) {
+ History.newItem(path, true);
+ }
+ }
+ }
+
+ public void renderView(ViewPath viewPath) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ viewPath.next();
+
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.tabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.subTabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ } else {
+ this.subTabName = null;
+ }
+ } else {
+ this.tabName = null;
+ }
+
+ if (getSelectedItemId() == null || getSelectedItemId() != id) {
+ // A different Resource or first load - go get data.
+ loadSelectedItem(id, viewPath);
+ } else {
+ // Same Resource - just switch tabs.
+ selectTab(this.tabName, this.subTabName, viewPath);
+ }
+ }
+
+ /**
+ * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
+ *
+ * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
+ * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
+ * @param viewPath the view path, which may have additional view items to be rendered
+ */
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
+ try {
+ TwoLevelTab tab = (tabTitle != null) ? this.tabSet.getTabByTitle(tabTitle) :
+ this.tabSet.getDefaultTab();
+ if (tab == null || tab.getDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ tab = this.tabSet.getDefaultTab();
+ if (tab == null) {
+ throw new IllegalStateException("No default tab is defined.");
+ }
+ subtabTitle = null;
+ }
+ // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
+
+ SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
+ if (subtab == null || tab.getLayout().isDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ subtab = tab.getLayout().getDefaultSubTab();
+ }
+ tab.getLayout().selectSubTab(subtab);
+
+ // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
+ this.tabSet.selectTab(tab);
+
+ // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
+ Canvas subView = subtab.getCanvas();
+ if (subView instanceof BookmarkableView) {
+ ((BookmarkableView) subView).renderView(viewPath);
+ }
+
+ this.tabSet.markForRedraw();
+ } catch (Exception e) {
+ System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
+ }
+ }
+
+ public TwoLevelTabSet getTabSet() {
+ return tabSet;
+ }
+
+ public String getTabName() {
+ return tabName;
+ }
+
+ public String getSubTabName() {
+ return subTabName;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9d289ca..b51bc00 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -18,13 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
+import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.List;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Side;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.authz.Permission;
@@ -38,23 +37,19 @@ import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* Right panel of the group view.
@@ -62,13 +57,14 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class ResourceGroupDetailView extends LocatableVLayout implements BookmarkableView, TwoLevelTabSelectedHandler {
- private static final String DEFAULT_TAB_NAME = "Inventory";
+public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
+ private static final String BASE_VIEW_PATH = "ResourceGroup";
- private int groupId;
+ private Integer groupId;
private ResourceGroupComposite groupComposite;
private ResourcePermission permissions;
+ // tabs
private TwoLevelTab summaryTab;
private TwoLevelTab monitoringTab;
private TwoLevelTab inventoryTab;
@@ -77,8 +73,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
private TwoLevelTab configurationTab;
private TwoLevelTab eventsTab;
- private TwoLevelTabSet topTabSet;
-
+ // subtabs
private SubTab summaryOverview;
private SubTab summaryTimeline;
private SubTab monitorGraphs;
@@ -96,32 +91,30 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
private SubTab configHistory;
private SubTab eventHistory;
- private ResourceGroupTitleBar titleBar;
-
- private String tabName;
- private String subTabName;
-
public ResourceGroupDetailView(String locatorId) {
- super(locatorId);
+ super(locatorId, BASE_VIEW_PATH);
+ }
- setWidth100();
- setHeight100();
+ @Override
+ public Integer getSelectedItemId() {
+ return this.groupId;
+ }
- // The Tabs section
+ @Override
+ protected ResourceGroupTitleBar createTitleBar() {
+ return new ResourceGroupTitleBar(getLocatorId());
+ }
- topTabSet = new TwoLevelTabSet(getLocatorId());
- topTabSet.setTabBarPosition(Side.TOP);
- topTabSet.setWidth100();
- topTabSet.setHeight100();
- topTabSet.setEdgeMarginSize(0);
- topTabSet.setEdgeSize(0);
+ protected List<TwoLevelTab> createTabs() {
+ List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(topTabSet.extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png");
+ summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png");
summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null);
summaryTab.registerSubTabs(summaryOverview, summaryTimeline);
+ tabs.add(summaryTab);
- monitoringTab = new TwoLevelTab(topTabSet.extendLocatorId("Monitoring"), "Monitoring",
+ monitoringTab = new TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring",
"/images/icons/Monitor_grey_16.png");
monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"), "Graphs", null);
monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"), "Tables", null);
@@ -130,54 +123,49 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
monitorSched = new SubTab(monitoringTab.extendLocatorId("Schedules"), "Schedules", null);
monitorCallTime = new SubTab(monitoringTab.extendLocatorId("CallTime"), "Call Time", null);
monitoringTab.registerSubTabs(monitorGraphs, monitorTables, monitorTraits, monitorSched, monitorCallTime);
+ tabs.add(monitoringTab);
- inventoryTab = new TwoLevelTab(topTabSet.extendLocatorId("Inventory"), "Inventory",
+ inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory",
"/images/icons/Inventory_grey_16.png");
inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"), "Members", null);
inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null);
inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn);
+ tabs.add(inventoryTab);
- operationsTab = new TwoLevelTab(topTabSet.extendLocatorId("Operations"), "Operations",
+ operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
"/images/icons/Operation_grey_16.png");
this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), "History", null);
this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), "Scheduled", null);
operationsTab.registerSubTabs(this.opHistory, this.opSched);
+ tabs.add(operationsTab);
- alertsTab = new TwoLevelTab(topTabSet.extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
+ alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"), "History", null);
this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"), "Definitions", null);
alertsTab.registerSubTabs(alertHistory, alertDef);
+ tabs.add(alertsTab);
- configurationTab = new TwoLevelTab(topTabSet.extendLocatorId("Configuration"), "Configuration",
+ configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), "Configuration",
"/images/icons/Configure_grey_16.png");
this.configCurrent = new SubTab(configurationTab.extendLocatorId("Current"), "Current", null);
this.configHistory = new SubTab(configurationTab.extendLocatorId("History"), "History", null);
configurationTab.registerSubTabs(this.configCurrent, this.configHistory);
+ tabs.add(configurationTab);
- eventsTab = new TwoLevelTab(topTabSet.extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png");
+ eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png");
this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"), "History", null);
eventsTab.registerSubTabs(eventHistory);
+ tabs.add(eventsTab);
- topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab, alertsTab, configurationTab,
- eventsTab);
-
- topTabSet.addTwoLevelTabSelectedHandler(this);
-
- titleBar = new ResourceGroupTitleBar(getLocatorId());
- addMember(titleBar);
-
- addMember(topTabSet);
-
- // CoreGUI.addBreadCrumb(getPlace());
+ return tabs;
}
- public void updateDetailViews(ResourceGroupComposite groupComposite) {
-
+ protected void updateTabContent(ResourceGroupComposite groupComposite) {
this.groupComposite = groupComposite;
- this.titleBar.setGroup(groupComposite.getResourceGroup());
+ getTitleBar().setGroup(groupComposite.getResourceGroup());
- for (Tab top : this.topTabSet.getTabs()) {
+ for (Tab top : this.getTabSet().getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -218,7 +206,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
updateTabEnablement();
}
-
private void updateTabEnablement() {
GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory();
Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
@@ -235,74 +222,22 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups.
// TODO (ips): Break out mixed groups into a separate view.
- this.topTabSet.setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE);
- this.topTabSet.setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
+ getTabSet().setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE);
+ getTabSet().setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
// Operations tab is only enabled for compatible groups of a type that supports the Operations facet.
- this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
+ getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
// Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet
// and when the current user has the CONFIGURE_READ permission.
- this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION)
+ getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION)
&& this.permissions.isConfigureRead());
// Events tab is only enabled for compatible groups of a type that supports the Events facet.
- this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
- }
-
- public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- //CoreGUI.printWidgetTree();
-
- if (this.groupComposite == null) {
- // History.fireCurrentHistoryState();
- } else {
- String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
- String path = "ResourceGroup/" + this.groupComposite.getResourceGroup().getId() + tabPath;
-
- // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
- // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
- // current history item.
- if (!History.getToken().equals(path)) {
- //System.out.println("Firing History event [" + path + "]...");
- History.newItem(path, true);
- }
- }
+ getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
}
- public void renderView(ViewPath viewPath) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- int groupId = Integer.parseInt(viewPath.getCurrent().getPath());
- viewPath.next();
-
- if (!viewPath.isEnd()) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- this.tabName = viewPath.getCurrent().getPath();
- viewPath.next();
- if (!viewPath.isEnd()) {
- // e.g. #ResourceGroup/10010/Summary/Overview
- // ^ current path
- this.subTabName = viewPath.getCurrent().getPath();
- viewPath.next();
- } else {
- this.subTabName = null;
- }
- } else {
- this.tabName = null;
- }
-
- if (this.groupId != groupId) {
- // A different group or first load - go get data.
- loadSelectedGroup(groupId, viewPath);
- } else {
- // Same group - just switch tabs.
- selectTab(this.tabName, this.subTabName, viewPath);
- }
-
- }
-
- public void loadSelectedGroup(final int groupId, final ViewPath viewPath) {
+ protected void loadSelectedItem(final int groupId, final ViewPath viewPath) {
this.groupId = groupId;
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
@@ -348,8 +283,8 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
public void onSuccess(Set<Permission> result) {
ResourceGroupDetailView.this.permissions = new ResourcePermission(result);
- updateDetailViews(groupComposite);
- selectTab(tabName, subTabName, viewPath);
+ updateTabContent(groupComposite);
+ selectTab(getTabName(), getSubTabName(), viewPath);
}
});
}
@@ -357,48 +292,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
}
}
- /**
- * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
- *
- * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
- * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
- * @param viewPath the view path, which may have additional view items to be rendered
- */
- public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
- try {
- TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) :
- this.topTabSet.getDefaultTab();
- if (tab == null || tab.getDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- tab = this.topTabSet.getDefaultTab();
- subtabTitle = null;
- }
- // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
-
- SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
- if (subtab == null || tab.getLayout().isDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- subtab = tab.getLayout().getDefaultSubTab();
- }
- tab.getLayout().selectSubTab(subtab);
-
- // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
- this.topTabSet.selectTab(tab);
-
- // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
- Canvas subView = subtab.getCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
-
- this.topTabSet.markForRedraw();
- } catch (Exception e) {
- System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
- }
- }
-
private static boolean hasTraits(ResourceGroupComposite groupComposite) {
ResourceType type = groupComposite.getResourceGroup().getResourceType();
if (type != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 2451e4b..e4bb9fd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -18,13 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.List;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Side;
-import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.criteria.ResourceCriteria;
@@ -36,17 +35,14 @@ import org.rhq.core.domain.resource.ResourceTypeFacet;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.alert.definitions.ResourceAlertDefinitionsView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
-import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
@@ -61,7 +57,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.D
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.OverviewView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* Right panel of the Resource view.
@@ -69,12 +64,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class ResourceDetailView extends LocatableVLayout implements BookmarkableView, TwoLevelTabSelectedHandler {
- private int resourceId;
+public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceComposite, ResourceTitleBar> {
+ private static final String BASE_VIEW_PATH = "Resource";
- private ResourceComposite resourceComposite;
+ private Integer resourceId;
- private TwoLevelTabSet topTabSet;
+ private ResourceComposite resourceComposite;
private TwoLevelTab summaryTab;
private TwoLevelTab monitoringTab;
@@ -109,33 +104,22 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
private SubTab contentSubscrip;
private SubTab contentHistory;
- private ResourceTitleBar titleBar;
-
- private String tabName;
- private String subTabName;
-
public ResourceDetailView(String locatorId) {
- super(locatorId);
-
- setWidth100();
- setHeight100();
-
- // The Tabs section
+ super(locatorId, BASE_VIEW_PATH);
+ }
- topTabSet = new TwoLevelTabSet(extendLocatorId("TabSet"));
- topTabSet.setTabBarPosition(Side.TOP);
- topTabSet.setWidth100();
- topTabSet.setHeight100();
- topTabSet.setEdgeMarginSize(0);
- topTabSet.setEdgeSize(0);
+ protected List<TwoLevelTab> createTabs() {
+ List<TwoLevelTab> tabs = new ArrayList<TwoLevelTab>();
- summaryTab = new TwoLevelTab(topTabSet.extendLocatorId("Summary"), "Summary", "/images/icons/Service_up_16.png");
+ summaryTab = new TwoLevelTab(getTabSet().extendLocatorId("Summary"), "Summary",
+ "/images/icons/Service_up_16.png");
summaryOverview = new SubTab(summaryTab.extendLocatorId("Overview"), "Overview", null);
summaryDashboard = new SubTab(summaryTab.extendLocatorId("Dashboard"), "Dashboard", null);
summaryTimeline = new SubTab(summaryTab.extendLocatorId("Timeline"), "Timeline", null);
summaryTab.registerSubTabs(summaryOverview, summaryDashboard, summaryTimeline);
+ tabs.add(summaryTab);
- monitoringTab = new TwoLevelTab(topTabSet.extendLocatorId("Monitoring"), "Monitoring",
+ monitoringTab = new TwoLevelTab(getTabSet().extendLocatorId("Monitoring"), "Monitoring",
"/images/icons/Monitor_grey_16.png");
monitorGraphs = new SubTab(monitoringTab.extendLocatorId("Graphs"), "Graphs", null);
monitorTables = new SubTab(monitoringTab.extendLocatorId("Tables"), "Tables", null);
@@ -145,64 +129,64 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
monitorCallTime = new SubTab(monitoringTab.extendLocatorId("CallTime"), "Call Time", null);
monitoringTab.registerSubTabs(monitorGraphs, monitorTables, monitorTraits, monitorAvail, monitorSched,
monitorCallTime);
+ tabs.add(monitoringTab);
- inventoryTab = new TwoLevelTab(topTabSet.extendLocatorId("Inventory"), "Inventory",
+ inventoryTab = new TwoLevelTab(getTabSet().extendLocatorId("Inventory"), "Inventory",
"/images/icons/Inventory_grey_16.png");
inventoryChildren = new SubTab(inventoryTab.extendLocatorId("Children"), "Children", null);
inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null);
inventoryTab.registerSubTabs(this.inventoryChildren, this.inventoryConn);
+ tabs.add(inventoryTab);
- operationsTab = new TwoLevelTab(topTabSet.extendLocatorId("Operations"), "Operations",
+ operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
"/images/icons/Operation_grey_16.png");
this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), "History", null);
this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), "Scheduled", null);
operationsTab.registerSubTabs(this.opHistory, this.opSched);
+ tabs.add(operationsTab);
- alertsTab = new TwoLevelTab(topTabSet.extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
+ alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"), "History", null);
this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"), "Definitions", null);
this.alertDelete = new SubTab(alertsTab.extendLocatorId("DELETEME"), "DELETEME", null);
alertsTab.registerSubTabs(alertHistory, alertDef, alertDelete);
+ tabs.add(alertsTab);
- configurationTab = new TwoLevelTab(topTabSet.extendLocatorId("Configuration"), "Configuration",
+ configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), "Configuration",
"/images/icons/Configure_grey_16.png");
this.configCurrent = new SubTab(configurationTab.extendLocatorId("Current"), "Current", null);
this.configHistory = new SubTab(configurationTab.extendLocatorId("History"), "History", null);
configurationTab.registerSubTabs(this.configCurrent, this.configHistory);
+ tabs.add(configurationTab);
- eventsTab = new TwoLevelTab(topTabSet.extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png");
+ eventsTab = new TwoLevelTab(getTabSet().extendLocatorId("Events"), "Events", "/images/icons/Events_grey_16.png");
this.eventHistory = new SubTab(eventsTab.extendLocatorId("History"), "History", null);
eventsTab.registerSubTabs(eventHistory);
+ tabs.add(eventsTab);
- contentTab = new TwoLevelTab(topTabSet.extendLocatorId("Content"), "Content",
+ contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), "Content",
"/images/icons/Content_grey_16.png");
this.contentDeployed = new SubTab(contentTab.extendLocatorId("Deployed"), "Deployed", null);
this.contentNew = new SubTab(contentTab.extendLocatorId("New"), "New", null);
this.contentSubscrip = new SubTab(contentTab.extendLocatorId("Subscriptions"), "Subscriptions", null);
this.contentHistory = new SubTab(contentTab.extendLocatorId("History"), "History", null);
contentTab.registerSubTabs(contentDeployed, contentNew, contentSubscrip, contentHistory);
+ tabs.add(contentTab);
- topTabSet.setTabs(summaryTab, monitoringTab, inventoryTab, operationsTab, alertsTab, configurationTab,
- eventsTab, contentTab);
-
- topTabSet.addTwoLevelTabSelectedHandler(this);
-
- titleBar = new ResourceTitleBar(extendLocatorId("TitleBar"));
-
- addMember(titleBar);
- addMember(topTabSet);
-
- // CoreGUI.addBreadCrumb(getPlace());
+ return tabs;
}
- public void updateDetailViews(ResourceComposite resourceComposite) {
+ protected ResourceTitleBar createTitleBar() {
+ return new ResourceTitleBar(extendLocatorId("TitleBar"));
+ }
+ protected void updateTabContent(ResourceComposite resourceComposite) {
this.resourceComposite = resourceComposite;
final Resource resource = this.resourceComposite.getResource();
- this.titleBar.setResource(resource);
+ getTitleBar().setResource(resource);
- for (Tab top : this.topTabSet.getTabs()) {
+ for (Tab top : this.getTabSet().getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -276,66 +260,17 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
ResourceType type = this.resourceComposite.getResource().getResourceType();
inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
- this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
- this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead());
- this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
- this.topTabSet.setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT));
- }
-
- public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- //CoreGUI.printWidgetTree();
-
- if (this.resourceComposite == null) {
- // History.fireCurrentHistoryState();
- } else {
- // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
- // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
- String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
- String path = "Resource/" + resourceId + tabPath;
-
- // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
- // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
- // current history item.
- if (!History.getToken().equals(path)) {
- System.out.println("Firing History event [" + path + "]...");
- History.newItem(path, true);
- }
- }
+ getTabSet().setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
+ getTabSet().setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead());
+ getTabSet().setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
+ getTabSet().setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT));
}
- public void renderView(ViewPath viewPath) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- int resourceId = Integer.parseInt(viewPath.getCurrent().getPath());
- viewPath.next();
-
- if (!viewPath.isEnd()) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- this.tabName = viewPath.getCurrent().getPath();
- viewPath.next();
- if (!viewPath.isEnd()) {
- // e.g. #Resource/10010/Summary/Overview
- // ^ current path
- this.subTabName = viewPath.getCurrent().getPath();
- viewPath.next();
- } else {
- this.subTabName = null;
- }
- } else {
- this.tabName = null;
- }
-
- if (this.resourceId != resourceId) {
- // A different Resource or first load - go get data.
- loadSelectedResource(resourceId, viewPath);
- } else {
- // Same Resource - just switch tabs.
- selectTab(this.tabName, this.subTabName, viewPath);
- }
+ public Integer getSelectedItemId() {
+ return this.resourceId;
}
- public void loadSelectedResource(final int resourceId, final ViewPath viewPath) {
+ protected void loadSelectedItem(final int resourceId, final ViewPath viewPath) {
this.resourceId = resourceId;
ResourceCriteria criteria = new ResourceCriteria();
@@ -379,54 +314,12 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
public void onTypesLoaded(ResourceType type) {
resourceComposite.getResource().setResourceType(type);
ResourceDetailView.this.resourceComposite = resourceComposite;
- updateDetailViews(resourceComposite);
- selectTab(tabName, subTabName, viewPath);
+ updateTabContent(resourceComposite);
+ selectTab(getTabName(), getSubTabName(), viewPath);
}
});
}
- /**
- * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
- *
- * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
- * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
- * @param viewPath the view path, which may have additional view items to be rendered
- */
- public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
- try {
- TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) :
- this.topTabSet.getDefaultTab();
- if (tab == null || tab.getDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- tab = this.topTabSet.getDefaultTab();
- subtabTitle = null;
- }
- // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
-
- SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
- if (subtab == null || tab.getLayout().isDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- subtab = tab.getLayout().getDefaultSubTab();
- }
- tab.getLayout().selectSubTab(subtab);
-
- // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
- this.topTabSet.selectTab(tab);
-
- // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
- Canvas subView = subtab.getCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
-
- this.topTabSet.markForRedraw();
- } catch (Exception e) {
- System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
- }
- }
-
private static boolean hasTraits(ResourceComposite resourceComposite) {
ResourceType type = resourceComposite.getResource().getResourceType();
Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions();
commit f32625b5a47a803f36bc77351f8efa8344070381
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Sat Sep 11 01:25:22 2010 -0400
various fixes to tab/tree navigation/bookmarking; various refactoring of tab components; some refactoring of Resource and group detail views
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 12c624c..77cc196 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
@@ -132,11 +132,9 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
messages = GWT.create(Messages.class);
checkLoginStatus();
-
}
public static void checkLoginStatus() {
-
// String sessionIdString = com.google.gwt.user.client.Cookies.getCookie("RHQ_Sesssion");
// if (sessionIdString == null) {
@@ -255,9 +253,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) {
-
String event = URL.decodeComponent(stringValueChangeEvent.getValue());
- System.out.println("Handling history event: " + event);
+ //System.out.println("Handling history event: " + event);
currentPath = event;
currentViewPath = new ViewPath(event);
@@ -357,8 +354,24 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
contentCanvas.markForRedraw();
}
- public static void goTo(String path) {
- History.newItem(path);
+ public static void goToView(String viewPath) {
+ String currentViewPath = History.getToken();
+ if (currentViewPath.equals(viewPath)) {
+ // We're already there - just refresh the view.
+ refresh();
+ } else {
+ if (viewPath.matches("(Resource|ResourceGroup)/[^/]*")) {
+ // e.g. "Resource/10001"
+ if (!currentViewPath.startsWith(viewPath)) {
+ // The Resource that was selected is not the same Resource that was previously selected -
+ // grab the end portion of the previous history URL and append it to the new history URL,
+ // so the same tab is selected for the new Resource.
+ String suffix = currentViewPath.replaceFirst("^[^/]*/[^/]*", "");
+ viewPath += suffix;
+ }
+ }
+ History.newItem(viewPath);
+ }
}
public static void refreshBreadCrumbTrail() {
@@ -386,6 +399,10 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
});
}
+ public static void goToResourceOrGroupView(String newToken) {
+
+ }
+
private class RootCanvas extends VLayout implements BookmarkableView {
ViewId currentViewId;
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 aa9da49..935f351 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
@@ -78,7 +78,7 @@ public class DemoCanvas extends Canvas {
topTabSet.addTab(configTab);
topTabSet.addTab(treeTab);
//topTabSet.addTab(alertHistoryTab);
- //topTabSet.selectTab(alertHistoryTab);
+ //topTabSet.selectSubTabByTitle(alertHistoryTab);
final Menu configSelectMenu = new Menu();
configSelectMenu.addItem(new MenuItem("Agent"));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
index 7d022ce..1302774 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewId.java
@@ -28,12 +28,10 @@ import java.util.List;
*/
public class ViewId {
-
private String path;
private List<Breadcrumb> breadcrumbs;
-
public ViewId(String path, Breadcrumb... breadcrumbs) {
this.path = path;
if ( breadcrumbs != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java
index 445b0b7..d0e3c06 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ViewPath.java
@@ -19,13 +19,14 @@
package org.rhq.enterprise.gui.coregui.client;
import java.util.ArrayList;
+import java.util.List;
/**
* @author Greg Hinkle
*/
public class ViewPath {
- private ArrayList<ViewId> viewPath = new ArrayList<ViewId>();
+ private List<ViewId> viewPath = new ArrayList<ViewId>();
private int index = 0;
@@ -35,12 +36,12 @@ public class ViewPath {
}
public ViewPath(String pathString) {
- for (String pe : pathString.split("/")) {
- viewPath.add(new ViewId(pe));
+ for (String pathElement : pathString.split("/")) {
+ viewPath.add(new ViewId(pathElement));
}
}
- public ArrayList<ViewId> getViewPath() {
+ public List<ViewId> getViewPath() {
return viewPath;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index 7c69fa5..df0f4b5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -91,7 +91,7 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
grid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
- CoreGUI.goTo("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ CoreGUI.goToView("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
index 1db0e78..741d931 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
@@ -48,7 +48,6 @@ public class SubTabLayout extends LocatableVLayout {
private SubTab currentlyDisplayed;
private String currentlySelected;
- private int currentIndex;
public SubTabLayout(String locatorId) {
super(locatorId);
@@ -99,12 +98,9 @@ public class SubTabLayout extends LocatableVLayout {
// button.setStyleName("SubTabButton");
// button.setStylePrimaryName("SubTabButton");
- final Integer index = i++;
-
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
currentlySelected = locatorId;
- currentIndex = index;
fireSubTabSelection();
draw();
}
@@ -116,14 +112,14 @@ public class SubTabLayout extends LocatableVLayout {
}
// Initial settings
- selectTabByLocatorId(currentlySelected);
+ selectSubTabByLocatorId(currentlySelected);
}
@Override
protected void onDraw() {
super.onDraw();
- selectTabByLocatorId(currentlySelected);
+ selectSubTabByLocatorId(currentlySelected);
}
public void enableSubTab(String locatorId) {
@@ -171,17 +167,25 @@ public class SubTabLayout extends LocatableVLayout {
subtabs.put(locatorId, subTab);
}
- public int getCurrentIndex() {
- return currentIndex;
+ public SubTab getDefaultSubTab() {
+ // the default subtab is the first one in the set that is not disabled
+ for (SubTab subtab : this.subtabs.values()) {
+ if (!this.disabledSubTabs.contains(subtab.getLocatorId())) {
+ return subtab;
+ }
+ }
+ return null;
}
- public SubTab getDefaultSubTab() {
- return subtabs.values().iterator().next();
+ public boolean selectSubTab(SubTab subtab) {
+ if (subtab == null) {
+ throw new IllegalArgumentException("subtab is null.");
+ }
+ return selectSubTabByLocatorId(subtab.getLocatorId());
}
- public boolean selectTabByLocatorId(String locatorId) {
+ public boolean selectSubTabByLocatorId(String locatorId) {
boolean foundTab = false;
- int i = 0;
for (String subtabLocatorId : this.subtabs.keySet()) {
if (subtabLocatorId.equals(locatorId)) {
if (this.disabledSubTabs.contains(subtabLocatorId)) {
@@ -190,12 +194,10 @@ public class SubTabLayout extends LocatableVLayout {
CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + subtab.getTitle() + "'.");
} else {
this.currentlySelected = subtabLocatorId;
- this.currentIndex = i;
foundTab = true;
}
break;
}
- i++;
}
if (foundTab) {
@@ -205,30 +207,31 @@ public class SubTabLayout extends LocatableVLayout {
return foundTab;
}
- public boolean selectTab(String title) {
- boolean foundTab = false;
- int i = 0;
+ public SubTab getSubTabByTitle(String title) {
for (String subtabLocatorId : this.subtabs.keySet()) {
SubTab subtab = this.subtabs.get(subtabLocatorId);
if (subtab.getTitle().equals(title)) {
- if (this.disabledSubTabs.contains(subtab.getLocatorId())) {
- // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL.
- CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'.");
- } else {
- this.currentlySelected = subtab.getLocatorId();
- this.currentIndex = i;
- foundTab = true;
- }
- break;
+ return subtab;
}
- i++;
}
- if (foundTab) {
+ return null;
+ }
+
+ public boolean selectSubTabByTitle(String title) {
+ SubTab subtab = getSubTabByTitle(title);
+ if (subtab == null) {
+ return false;
+ } else {
+ if (this.disabledSubTabs.contains(subtab.getLocatorId())) {
+ // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL.
+ CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'.");
+ return false;
+ }
+ this.currentlySelected = subtab.getLocatorId();
refresh();
+ return true;
}
-
- return foundTab;
}
public SubTab getCurrentSubTab() {
@@ -246,7 +249,7 @@ public class SubTabLayout extends LocatableVLayout {
public void fireSubTabSelection() {
TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?", getCurrentSubTab().getTitle(), -1,
- currentIndex, getCurrentCanvas());
+ getCurrentCanvas());
hm.fireEvent(event);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
index 845128f..6258e9e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
@@ -52,6 +52,14 @@ public class TwoLevelTab extends LocatableTab {
}
}
+ public SubTab getSubTabByTitle(String title) {
+ return this.layout.getSubTabByTitle(title);
+ }
+
+ public SubTab getDefaultSubTab() {
+ return this.layout.getDefaultSubTab();
+ }
+
public SubTabLayout getLayout() {
return layout;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java
index 374c049..5f2b2ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSelectedEvent.java
@@ -18,10 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.components.tab;
-import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.tab.Tab;
/**
* @author Greg Hinkle
@@ -30,19 +28,17 @@ public class TwoLevelTabSelectedEvent extends GwtEvent<TwoLevelTabSelectedHandle
public static final GwtEvent.Type<TwoLevelTabSelectedHandler> TYPE = new Type<TwoLevelTabSelectedHandler>();
- String id;
- String subTabId;
+ private String id;
+ private String subTabId;
- int tabNum;
- int subTabNum;
+ private int tabNum;
- Canvas subTabPane;
+ private Canvas subTabPane;
- public TwoLevelTabSelectedEvent(String id, String subTabId, int tabNum, int subTabNum, Canvas subTabPane) {
+ public TwoLevelTabSelectedEvent(String id, String subTabId, int tabNum, Canvas subTabPane) {
this.id = id;
this.subTabId = subTabId;
this.tabNum = tabNum;
- this.subTabNum = subTabNum;
this.subTabPane = subTabPane;
}
@@ -70,14 +66,6 @@ public class TwoLevelTabSelectedEvent extends GwtEvent<TwoLevelTabSelectedHandle
this.tabNum = tabNum;
}
- public int getSubTabNum() {
- return subTabNum;
- }
-
- public void setSubTabNum(int subTabNum) {
- this.subTabNum = subTabNum;
- }
-
public Canvas getSubTabPane() {
return subTabPane;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
index a5c2611..d39efb7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
@@ -70,23 +70,30 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
}
public void onTabSelected(TabSelectedEvent tabSelectedEvent) {
- System.out.println("TwoLevelTabSet.onTabSelected(): " + tabSelectedEvent.getTab().getTitle());
TwoLevelTab tab = (TwoLevelTab) getSelectedTab();
TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(),
tab.getLayout().getCurrentSubTab().getTitle(), tabSelectedEvent.getTabNum(),
- tab.getLayout().getCurrentIndex(), tab.getLayout().getCurrentCanvas());
+ tab.getLayout().getCurrentCanvas());
m.fireEvent(event);
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
- System.out.println("TwoLevelTabSet.onTwoLevelTabSelected(): " + tabSelectedEvent.getId() + "/" +
- tabSelectedEvent.getSubTabId());
tabSelectedEvent.setTabNum(getSelectedTabNumber());
- Tab tab = getSelectedTab();
+ Tab tab = getSelectedTab();
tabSelectedEvent.setId(tab.getTitle());
m.fireEvent(tabSelectedEvent);
}
+ public TwoLevelTab getDefaultTab() {
+ TwoLevelTab[] tabs = getTabs();
+ for (TwoLevelTab tab : tabs) {
+ if (!tab.getDisabled()) {
+ return tab;
+ }
+ }
+ return null;
+ }
+
public TwoLevelTab getTabByTitle(String title) {
return (TwoLevelTab) super.getTabByTitle(title);
}
@@ -94,4 +101,12 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
public TwoLevelTab getTabByLocatorId(String locatorId) {
return (TwoLevelTab) super.getTabByLocatorId(locatorId);
}
+
+ public void setTabEnabled(TwoLevelTab tab, boolean enabled) {
+ if (enabled) {
+ enableTab(tab);
+ } else {
+ disableTab(tab);
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
index 0d04750..4f5374c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java
@@ -22,7 +22,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
@@ -70,7 +69,7 @@ public class FavoritesButton extends LocatableIMenuButton {
MenuItem item = new MenuItem(String.valueOf(resourceId));
item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- History.newItem("Resource/" + resourceId);
+ CoreGUI.goToView("Resource/" + resourceId);
}
});
items[i] = item;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 6bb216e..9d289ca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -177,7 +177,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
this.titleBar.setGroup(groupComposite.getResourceGroup());
- for (Tab top : topTabSet.getTabs()) {
+ for (Tab top : this.topTabSet.getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -185,7 +185,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
// summaryTab.updateSubTab("Overview", new DashboardView(resource));
// summaryTab.updateSubTab("Timeline", timelinePane);
this.summaryOverview.setCanvas(new OverviewView(this.groupComposite));
- summaryTab.updateSubTab(this.summaryOverview);
int groupId = this.groupComposite.getResourceGroup().getId();
@@ -194,126 +193,113 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
this.monitorTraits.setCanvas(new TraitsView(this.monitoringTab.extendLocatorId("TraitsView"), groupId));
this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId));
this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
- monitoringTab.updateSubTab(this.monitorGraphs);
- monitoringTab.updateSubTab(this.monitorTables);
- monitoringTab.updateSubTab(this.monitorSched);
- monitoringTab.updateSubTab(this.monitorCallTime);
this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId));
- inventoryTab.updateSubTab(this.inventoryMembers);
-
- // inventoryTab.updateSubTab("Connection Settings", new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
+ // TODO: Uncomment this once the group config component is done.
+ //this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId="
+ groupId));
this.opSched.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId="
+ groupId));
- operationsTab.updateSubTab(this.opHistory);
- operationsTab.updateSubTab(this.opSched);
this.alertHistory.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertHistory-plain.xhtml?groupId="
+ groupId));
this.alertDef.setCanvas(new FullHTMLPane("/rhq/group/alert/listGroupAlertDefinitions-plain.xhtml?groupId="
+ groupId));
- alertsTab.updateSubTab(this.alertHistory);
- alertsTab.updateSubTab(this.alertDef);
this.configCurrent.setCanvas(new FullHTMLPane("/rhq/group/configuration/viewCurrent-plain.xhtml?groupId="
+ groupId));
this.configHistory
.setCanvas(new FullHTMLPane("/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId));
- configurationTab.updateSubTab(this.configCurrent);
- configurationTab.updateSubTab(this.configHistory);
this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite));
- eventsTab.updateSubTab(this.eventHistory);
updateTabEnablement();
}
private void updateTabEnablement() {
-
GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory();
Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
// Summary and Inventory tabs are always enabled.
- topTabSet.enableTab(summaryTab);
- topTabSet.enableTab(inventoryTab);
+
+ // Only enable "Call Time" and "Traits" subtabs for groups that implement them.
+ this.monitoringTab.setSubTabEnabled(this.monitorTraits.getLocatorId(), hasTraits(this.groupComposite));
+ this.monitoringTab.setSubTabEnabled(this.monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
// Inventory>Connection Settings subtab is only enabled for compat groups that define conn props.
- inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE
+ this.inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups.
- if (groupCategory == GroupCategory.COMPATIBLE) {
- topTabSet.enableTab(monitoringTab);
- topTabSet.enableTab(alertsTab);
- } else {
- topTabSet.disableTab(monitoringTab);
- topTabSet.disableTab(alertsTab);
- }
+ // TODO (ips): Break out mixed groups into a separate view.
+ this.topTabSet.setTabEnabled(this.monitoringTab, groupCategory == GroupCategory.COMPATIBLE);
+ this.topTabSet.setTabEnabled(this.alertsTab, groupCategory == GroupCategory.COMPATIBLE);
// Operations tab is only enabled for compatible groups of a type that supports the Operations facet.
- if (facets.contains(ResourceTypeFacet.OPERATION)) {
- topTabSet.enableTab(operationsTab);
- } else {
- topTabSet.disableTab(operationsTab);
- }
+ this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
// Configuration tab is only enabled for compatible groups of a type that supports the Configuration facet
// and when the current user has the CONFIGURE_READ permission.
- if (facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()) {
- topTabSet.enableTab(configurationTab);
- } else {
- topTabSet.disableTab(configurationTab);
- }
+ this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION)
+ && this.permissions.isConfigureRead());
// Events tab is only enabled for compatible groups of a type that supports the Events facet.
- if (facets.contains(ResourceTypeFacet.EVENT)) {
- topTabSet.enableTab(eventsTab);
- } else {
- topTabSet.disableTab(eventsTab);
- }
-
- // only enable "Call Time" and "Traits" subtabs for groups that implement them.
- monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.groupComposite));
- monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
+ this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
+ //CoreGUI.printWidgetTree();
+
if (this.groupComposite == null) {
-// History.fireCurrentHistoryState();
+ // History.fireCurrentHistoryState();
} else {
- // Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
-// selectTab(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
String path = "ResourceGroup/" + this.groupComposite.getResourceGroup().getId() + tabPath;
- // But still add an item to the history, specifying false to tell it not to fire an event.
- History.newItem(path, true);
+ // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
+ // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
+ // current history item.
+ if (!History.getToken().equals(path)) {
+ //System.out.println("Firing History event [" + path + "]...");
+ History.newItem(path, true);
+ }
}
}
public void renderView(ViewPath viewPath) {
- // e.g. #ResourceGroup/10010/Inventory/Overview
+ // e.g. #ResourceGroup/10010/Summary/Overview
+ // ^ current path
int groupId = Integer.parseInt(viewPath.getCurrent().getPath());
-
- viewPath.next();
-
- tabName = (!viewPath.isEnd()) ? viewPath.getCurrent().getPath() : null; // e.g. "Inventory"
- subTabName = (viewPath.viewsLeft() >= 1) ? viewPath.getNext().getPath() : null; // e.g. "Overview"
-
- viewPath.next();
viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #ResourceGroup/10010/Summary/Overview
+ // ^ current path
+ this.tabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #ResourceGroup/10010/Summary/Overview
+ // ^ current path
+ this.subTabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ } else {
+ this.subTabName = null;
+ }
+ } else {
+ this.tabName = null;
+ }
if (this.groupId != groupId) {
+ // A different group or first load - go get data.
loadSelectedGroup(groupId, viewPath);
} else {
- // Same group just switching tabs
- selectTab(tabName, subTabName, viewPath);
+ // Same group - just switch tabs.
+ selectTab(this.tabName, this.subTabName, viewPath);
}
+
}
public void loadSelectedGroup(final int groupId, final ViewPath viewPath) {
@@ -337,7 +323,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
});
}
-
private void loadResourceType(final ResourceGroupComposite groupComposite, final ViewPath viewPath) {
final ResourceGroup group = this.groupComposite.getResourceGroup();
@@ -372,33 +357,48 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
}
}
+ /**
+ * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
+ *
+ * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
+ * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
+ * @param viewPath the view path, which may have additional view items to be rendered
+ */
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
+ try {
+ TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) :
+ this.topTabSet.getDefaultTab();
+ if (tab == null || tab.getDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ tab = this.topTabSet.getDefaultTab();
+ subtabTitle = null;
+ }
+ // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
- public void selectTab(String tabName, String subtabName, ViewPath viewPath) {
- if (tabName == null) {
- tabName = DEFAULT_TAB_NAME;
- }
- TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName);
- if (tab == null) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- tab = this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME);
- }
- this.topTabSet.selectTab(tab);
- if (subtabName != null) {
- if (!tab.getLayout().selectTab(subtabName)) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName);
+ SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
+ if (subtab == null || tab.getLayout().isDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
// TODO: Should we fire a history event here to redirect to a valid bookmark?
- return;
- } else {
- Canvas subView = tab.getLayout().getCurrentCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
+ subtab = tab.getLayout().getDefaultSubTab();
}
+ tab.getLayout().selectSubTab(subtab);
+
+ // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
+ this.topTabSet.selectTab(tab);
+
+ // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
+ Canvas subView = subtab.getCanvas();
+ if (subView instanceof BookmarkableView) {
+ ((BookmarkableView) subView).renderView(viewPath);
+ }
+
+ this.topTabSet.markForRedraw();
+ } catch (Exception e) {
+ System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
}
}
-
private static boolean hasTraits(ResourceGroupComposite groupComposite) {
ResourceType type = groupComposite.getResourceGroup().getResourceType();
if (type != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
index 7fe5361..a205584 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTopView.java
@@ -25,10 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import com.smartgwt.client.widgets.Canvas;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
@@ -37,17 +34,14 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
public class ResourceGroupTopView extends LocatableHLayout implements BookmarkableView {
private Canvas contentCanvas;
-
-
private ResourceGroupTreeView treeView;
private ResourceGroupDetailView detailView;
- private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
-
public ResourceGroupTopView(String locatorId) {
super(locatorId);
}
+
@Override
protected void onInit() {
super.onInit();
@@ -68,7 +62,6 @@ public class ResourceGroupTopView extends LocatableHLayout implements Bookmarkab
setContent(detailView);
}
-
public void setContent(Canvas newContent) {
if (contentCanvas.getChildren().length > 0)
@@ -77,16 +70,9 @@ public class ResourceGroupTopView extends LocatableHLayout implements Bookmarkab
contentCanvas.markForRedraw();
}
- public void renderView(ViewPath viewPath) {
- if (viewPath.isEnd()) {
- // default detail view
- viewPath.getViewPath().add(new ViewId("Inventory"));
- viewPath.getViewPath().add(new ViewId("Overview"));
- }
-
+ public void renderView(ViewPath viewPath) {
this.treeView.renderView(viewPath);
-
this.detailView.renderView(viewPath);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
index 28aee70..4be1f22 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
@@ -49,8 +49,8 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
groupIdField.setHidden(true);
fields.add(0, groupIdField);
- DataSourceTextField resourceNameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME,
- "Resource Name");
+ DataSourceTextField resourceNameField =
+ new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, "Member Resource");
fields.add(0, resourceNameField);
return fields;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index 731711e..c31881c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -111,7 +111,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
grid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
- CoreGUI.goTo("Inventory/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ CoreGUI.goToView("Inventory/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index fc67739..2451e4b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -264,7 +264,6 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
}
private void updateTabEnablement() {
-
ResourcePermission permissions = this.resourceComposite.getResourcePermission();
Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
@@ -277,29 +276,10 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
ResourceType type = this.resourceComposite.getResource().getResourceType();
inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
- if (facets.contains(ResourceTypeFacet.OPERATION)) {
- topTabSet.enableTab(operationsTab);
- } else {
- topTabSet.disableTab(operationsTab);
- }
-
- if (facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead()) {
- topTabSet.enableTab(configurationTab);
- } else {
- topTabSet.disableTab(configurationTab);
- }
-
- if (facets.contains(ResourceTypeFacet.EVENT)) {
- topTabSet.enableTab(eventsTab);
- } else {
- topTabSet.disableTab(eventsTab);
- }
-
- if (facets.contains(ResourceTypeFacet.CONTENT)) {
- topTabSet.enableTab(contentTab);
- } else {
- topTabSet.disableTab(contentTab);
- }
+ this.topTabSet.setTabEnabled(this.operationsTab, facets.contains(ResourceTypeFacet.OPERATION));
+ this.topTabSet.setTabEnabled(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION) && permissions.isConfigureRead());
+ this.topTabSet.setTabEnabled(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT));
+ this.topTabSet.setTabEnabled(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT));
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
@@ -309,7 +289,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
// History.fireCurrentHistoryState();
} else {
// Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
- // selectTab(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
+ // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
String path = "Resource/" + resourceId + tabPath;
@@ -324,26 +304,35 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
}
public void renderView(ViewPath viewPath) {
- // e.g. #Resource/10010/Inventory/Overview
- // ^ Current Path
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
int resourceId = Integer.parseInt(viewPath.getCurrent().getPath());
-
viewPath.next();
- tabName = (!viewPath.isEnd()) ? viewPath.getCurrent().getPath() : null; // e.g. "Inventory"
- subTabName = (viewPath.viewsLeft() >= 1) ? viewPath.getNext().getPath() : null; // e.g. "Overview"
-
- viewPath.next();
- viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.tabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ if (!viewPath.isEnd()) {
+ // e.g. #Resource/10010/Summary/Overview
+ // ^ current path
+ this.subTabName = viewPath.getCurrent().getPath();
+ viewPath.next();
+ } else {
+ this.subTabName = null;
+ }
+ } else {
+ this.tabName = null;
+ }
if (this.resourceId != resourceId) {
- // A different resource or first load, go get data
+ // A different Resource or first load - go get data.
loadSelectedResource(resourceId, viewPath);
} else {
- // same resource just switch tabs
- selectTab(tabName, subTabName, viewPath);
+ // Same Resource - just switch tabs.
+ selectTab(this.tabName, this.subTabName, viewPath);
}
-
}
public void loadSelectedResource(final int resourceId, final ViewPath viewPath) {
@@ -360,7 +349,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
new Message("Resource with id [" + resourceId + "] does not exist or is not accessible.",
Message.Severity.Warning));
- CoreGUI.goTo(InventoryView.VIEW_PATH);
+ CoreGUI.goToView(InventoryView.VIEW_PATH);
}
public void onSuccess(PageList<ResourceComposite> result) {
@@ -396,37 +385,45 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
});
}
- public void selectTab(String tabName, String subtabName, ViewPath viewPath) {
+ /**
+ * Select the tab/subtab with the specified titles (e.g. "Monitoring", "Graphs").
+ *
+ * @param tabTitle the title of the tab to select - if null, the default tab (the leftmost non-disabled one) will be selected
+ * @param subtabTitle the title of the subtab to select - if null, the default subtab (the leftmost non-disabled one) will be selected
+ * @param viewPath the view path, which may have additional view items to be rendered
+ */
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
try {
- TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName);
+ TwoLevelTab tab = (tabTitle != null) ? this.topTabSet.getTabByTitle(tabTitle) :
+ this.topTabSet.getDefaultTab();
if (tab == null || tab.getDisabled()) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName);
+ CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabTitle);
// TODO: Should we fire a history event here to redirect to a valid bookmark?
- Tab defaultTab = this.topTabSet.getTab(0);
- tab = (TwoLevelTab) defaultTab;
+ tab = this.topTabSet.getDefaultTab();
+ subtabTitle = null;
}
- SubTab subTab = null;
- if (subtabName != null) {
- if (!tab.getLayout().selectTab(subtabName)) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- SubTab defaultSubtab = tab.getLayout().getDefaultSubTab();
- tab.getLayout().selectTab(defaultSubtab.getTitle());
- }
- subTab = tab.getLayout().getCurrentSubTab();
+ // Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
+
+ SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
+ if (subtab == null || tab.getLayout().isDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ subtab = tab.getLayout().getDefaultSubTab();
}
+ tab.getLayout().selectSubTab(subtab);
+
+ // Now that the subtab has been selected, select the tab (this will cause a tab selected event to fire).
this.topTabSet.selectTab(tab);
- if (subTab != null) {
- tab.updateSubTab(subTab);
- Canvas subView = subTab.getCanvas();
- if (subView instanceof BookmarkableView) {
- ((BookmarkableView) subView).renderView(viewPath);
- }
+
+ // Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
+ Canvas subView = subtab.getCanvas();
+ if (subView instanceof BookmarkableView) {
+ ((BookmarkableView) subView).renderView(viewPath);
}
- tab.getLayout().markForRedraw();
+
this.topTabSet.markForRedraw();
} catch (Exception e) {
- System.err.println("Failed to select tab " + tabName + "/" + subtabName + ": " + e);
+ System.err.println("Failed to select tab " + tabTitle + "/" + subtabTitle + ": " + e);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
index 83c5352..7fae500 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTopView.java
@@ -62,14 +62,7 @@ public class ResourceTopView extends LocatableHLayout implements BookmarkableVie
}
public void renderView(ViewPath viewPath) {
- if (viewPath.isEnd()) {
- // default detail view
- viewPath.getViewPath().add(new ViewId("Summary"));
- viewPath.getViewPath().add(new ViewId("Overview"));
- }
-
this.treeView.renderView(viewPath);
-
this.detailView.renderView(viewPath);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 8566975..57ba8f2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -91,7 +91,7 @@ public class ResourceTreeView extends LocatableVLayout {
private ViewId currentViewId;
- private ArrayList<ResourceSelectListener> selectListeners = new ArrayList<ResourceSelectListener>();
+ private List<ResourceSelectListener> selectListeners = new ArrayList<ResourceSelectListener>();
private boolean initialSelect = false;
@@ -105,6 +105,7 @@ public class ResourceTreeView extends LocatableVLayout {
}
public void onInit() {
+ // TODO (ips): Are we intentionally avoiding calling super.onInit() here? If so, why?
}
private void buildTree() {
@@ -124,7 +125,6 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.setLeaveScrollbarGap(false);
contextMenu = new Menu();
- MenuItem item = new MenuItem("Expand node");
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
@@ -132,16 +132,11 @@ public class ResourceTreeView extends LocatableVLayout {
if (treeGrid.getSelectedRecord() instanceof ResourceTreeDatasource.ResourceTreeNode) {
ResourceTreeDatasource.ResourceTreeNode node = (ResourceTreeDatasource.ResourceTreeNode) treeGrid
.getSelectedRecord();
- System.out.println("Resource selected in tree: " + node.getResource());
-
- String newToken = "Resource/" + node.getResource().getId();
- String currentToken = History.getToken();
- if (!currentToken.startsWith(newToken)) {
-
- String ending = currentToken.replaceFirst("^[^\\/]*\\/[^\\/]*", "");
-
- History.newItem("Resource/" + node.getResource().getId() + ending);
-
+ //System.out.println("Resource selected in tree: " + node.getResource());
+ String viewPath = "Resource/" + node.getResource().getId();
+ String currentViewPath = History.getToken();
+ if (!currentViewPath.startsWith(viewPath)) {
+ CoreGUI.goToView(viewPath);
}
}
}
@@ -167,13 +162,13 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
if (!initialSelect) {
-
updateBreadcrumb();
}
}
});
}
+
private void updateBreadcrumb() {
TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId));
// System.out.println("Trying to preopen: " + selectedNode);
@@ -455,7 +450,7 @@ public class ResourceTreeView extends LocatableVLayout {
public void setSelectedResource(final int selectedResourceId) {
this.selectedResourceId = selectedResourceId;
- TreeNode node = null;
+ TreeNode node;
if (treeGrid != null && treeGrid.getTree() != null
&& (node = treeGrid.getTree().findById(String.valueOf(selectedResourceId))) != null) {
@@ -466,8 +461,10 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.getTree().openFolders(parents);
treeGrid.getTree().openFolder(node);
- treeGrid.deselectAllRecords();
- treeGrid.selectRecord(node);
+ if (!treeGrid.getSelectedRecord().equals(node)) {
+ treeGrid.deselectAllRecords();
+ treeGrid.selectRecord(node);
+ }
updateBreadcrumb();
/*
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index 9d56dc2..c507395 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -100,7 +100,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
grid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
- CoreGUI.goTo("Reports/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ CoreGUI.goToView("Reports/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
index 37f553d..10213f4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/RPCManager.java
@@ -21,20 +21,22 @@ package org.rhq.enterprise.gui.coregui.client.util.rpc;
import com.smartgwt.client.widgets.Img;
import java.util.HashSet;
+import java.util.Set;
/**
* @author Greg Hinkle
*/
public class RPCManager {
+ private static final RPCManager INSTANCE = new RPCManager();
- int nextCallId = 0;
+ private int nextCallId = 0;
- HashSet<MonitoringRequestCallback> inProgress = new HashSet<MonitoringRequestCallback>();
+ private Set<MonitoringRequestCallback> inProgress = new HashSet<MonitoringRequestCallback>();
- Img activityIndicator;
+ private Img activityIndicator;
- public RPCManager() {
+ private RPCManager() {
activityIndicator = new Img("/coregui/images/ajax-loader.gif", 16, 16);
activityIndicator.setZIndex(10000);
activityIndicator.setLeft(10);
@@ -43,6 +45,10 @@ public class RPCManager {
activityIndicator.draw();
}
+ public static RPCManager getInstance() {
+ return INSTANCE;
+ }
+
public int register(MonitoringRequestCallback callback) {
inProgress.add(callback);
refresh();
@@ -50,13 +56,13 @@ public class RPCManager {
}
public void failCall(MonitoringRequestCallback callback) {
- System.out.println("RPC [" + callback.getName() + "] failed in [" + callback.age() + "]");
+ //System.err.println("RPC [" + callback.getName() + "] failed in [" + callback.age() + "] ms.");
inProgress.remove(callback);
refresh();
}
public void succeedCall(MonitoringRequestCallback callback) {
- System.out.println("RPC [" + callback.getName() + "] succeeded in [" + callback.age() + "]");
+ //System.out.println("RPC [" + callback.getName() + "] succeeded in [" + callback.age() + "] ms.");
inProgress.remove(callback);
refresh();
}
@@ -76,17 +82,8 @@ public class RPCManager {
}
activityIndicator.setTooltip(buf.toString());
-
} else {
activityIndicator.hide();
}
}
-
-
- public static RPCManager INSTANCE = new RPCManager();
-
- public static RPCManager getInstance() {
- return INSTANCE;
- }
-
}
commit f121c0c17c6740c078e71a8d7da0ddda549c1392
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Sep 10 17:22:43 2010 -0400
continuing to build out the "new condition" dialog window for alert def/condition editor
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index e6ee5c0..23bc0cc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -137,6 +137,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
newAlertDef.setConditionExpression(BooleanExpression.ALL);
newAlertDef.setPriority(AlertPriority.MEDIUM);
newAlertDef.setWillRecover(false);
+ singleAlertDefinitionView.setAlertDefinition(newAlertDef);
singleAlertDefinitionView.makeEditable();
} else {
final AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
index d1f5de5..fe1e2e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
@@ -219,7 +219,7 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
priorities.put(AlertPriority.HIGH.name(), AlertPriority.HIGH.name());
priorities.put(AlertPriority.MEDIUM.name(), AlertPriority.MEDIUM.name());
priorities.put(AlertPriority.LOW.name(), AlertPriority.LOW.name());
- LinkedHashMap<String, String> priorityIcons = new LinkedHashMap<String, String>();
+ LinkedHashMap<String, String> priorityIcons = new LinkedHashMap<String, String>(3);
priorityIcons.put(AlertPriority.HIGH.name(), "/images/icons/Flag_red_16.png");
priorityIcons.put(AlertPriority.MEDIUM.name(), "/images/icons/Flag_yellow_16.png");
priorityIcons.put(AlertPriority.LOW.name(), "/images/icons/Flag_blue_16.png");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 9f39e6e..c6c59c1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -23,18 +23,28 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.FormItemIfFunction;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertConditionCategory;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -42,7 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
- private HashSet<AlertCondition> conditions;
+ private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
private SelectItem conditionTypeSelectItem;
public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions) {
@@ -54,6 +64,8 @@ public class NewConditionEditor extends LocatableDynamicForm {
protected void onInit() {
super.onInit();
+ setMargin(20);
+
conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type");
LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7);
condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
@@ -66,6 +78,12 @@ public class NewConditionEditor extends LocatableDynamicForm {
conditionTypeSelectItem.setValueMap(condTypes);
conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.THRESHOLD.name());
conditionTypeSelectItem.setWrapTitle(false);
+ conditionTypeSelectItem.setRedrawOnChange(true);
+ conditionTypeSelectItem.setWidth("*");
+
+ SpacerItem spacer = new SpacerItem();
+ spacer.setColSpan(2);
+ spacer.setHeight(5);
ButtonItem ok = new ButtonItem("buttonItem", "OK");
ok.setColSpan(2);
@@ -78,6 +96,247 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
});
- setFields(conditionTypeSelectItem, ok);
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+ formItems.add(conditionTypeSelectItem);
+ formItems.add(spacer);
+ formItems.addAll(buildMetricThresholdFormItems());
+ formItems.addAll(buildMetricBaselineFormItems());
+ formItems.addAll(buildMetricChangeFormItems());
+ formItems.addAll(buildTraitChangeFormItems());
+ formItems.addAll(buildAvailabilityChangeFormItems());
+ formItems.addAll(buildOperationFormItems());
+ formItems.addAll(buildEventFormItems());
+ formItems.add(ok);
+
+ setFields(formItems.toArray(new FormItem[formItems.size()]));
};
+
+ private ArrayList<FormItem> buildMetricThresholdFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.THRESHOLD);
+
+ String helpStr = "Specify the threshold value that, when violated, triggers the condition. The value you specify is an absolute value with an optional units specifier.";
+ StaticTextItem helpItem = buildHelpTextItem("thresholdHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildMetricDropDownMenu("thresholdMetric", ifFunc));
+ formItems.add(buildComparatorDropDownMenu("thresholdComparator", ifFunc));
+
+ TextItem absoluteValue = new TextItem("metricAbsoluteValue", "Metric Value");
+ absoluteValue.setWrapTitle(false);
+ absoluteValue.setRequired(true);
+
+ absoluteValue.setShowIfCondition(ifFunc);
+ formItems.add(absoluteValue);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildMetricBaselineFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.BASELINE);
+
+ String helpStr = "Specify the baseline value that must be violated to trigger the condition. The value you specify is a percentage of the given baseline value.";
+ StaticTextItem helpItem = buildHelpTextItem("baselineHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildMetricDropDownMenu("baselineMetric", ifFunc));
+ formItems.add(buildComparatorDropDownMenu("baselineComparator", ifFunc));
+
+ TextItem baselinePercentage = new TextItem("baselinePercentage", "Baseline Percentage");
+ baselinePercentage.setWrapTitle(false);
+ baselinePercentage.setRequired(true);
+ baselinePercentage.setShowIfCondition(ifFunc);
+ formItems.add(baselinePercentage);
+
+ SelectItem baselineSelection = new SelectItem("baselineSelection", "Baseline");
+ LinkedHashMap<String, String> baselines = new LinkedHashMap<String, String>(3);
+ baselines.put("min", "Minimum"); // title should have the current value of the min baseline
+ baselines.put("avg", "Baseline"); // title should have the current value of the avg baseline
+ baselines.put("max", "Maximum"); // title should have the current value of the max baseline
+ baselineSelection.setValueMap(baselines);
+ baselineSelection.setDefaultValue("avg");
+ baselineSelection.setWidth("*");
+ baselineSelection.setWrapTitle(false);
+ baselineSelection.setShowIfCondition(ifFunc);
+ formItems.add(baselineSelection);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildMetricChangeFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.CHANGE);
+
+ String helpStr = "Specify the metric whose value must change to trigger the condition.";
+ StaticTextItem helpItem = buildHelpTextItem("changeMetricHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildMetricDropDownMenu("changeMetric", ifFunc));
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildTraitChangeFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.TRAIT);
+
+ String helpStr = "Specify the trait whose value must change to trigger the condition.";
+ StaticTextItem helpItem = buildHelpTextItem("traitHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ LinkedHashMap<String, String> traits = new LinkedHashMap<String, String>();
+ // TODO
+ traits.put("dummy trait", "Dummy Trait Name");
+
+ SelectItem traitSelection = new SelectItem("trait", "Trait");
+ traitSelection.setValueMap(traits);
+ traitSelection.setDefaultValue(traits.keySet().iterator().next()); // just use the first one
+ traitSelection.setWidth("*");
+ traitSelection.setShowIfCondition(ifFunc);
+ formItems.add(traitSelection);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildAvailabilityChangeFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.AVAILABILITY);
+
+ String helpStr = "Specify the availability state change that will trigger the condition.";
+ StaticTextItem helpItem = buildHelpTextItem("availabilityHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ SelectItem selection = new SelectItem("availability", "Availability");
+ LinkedHashMap<String, String> avails = new LinkedHashMap<String, String>(2);
+ avails.put(AvailabilityType.UP.name(), "Goes UP");
+ avails.put(AvailabilityType.DOWN.name(), "Goes DOWN");
+ selection.setValueMap(avails);
+ selection.setDefaultValue(AvailabilityType.DOWN.name());
+ selection.setShowIfCondition(ifFunc);
+
+ formItems.add(selection);
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildOperationFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.CONTROL);
+
+ String helpStr = "Specify the result that must occur when the selected operation is executed in order to trigger the condition.";
+ StaticTextItem helpItem = buildHelpTextItem("operationHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ LinkedHashMap<String, String> ops = new LinkedHashMap<String, String>();
+ // TODO
+ ops.put("dummy op", "Dummy Op Name");
+
+ SelectItem opSelection = new SelectItem("operation", "Operation");
+ opSelection.setValueMap(ops);
+ opSelection.setDefaultValue(ops.keySet().iterator().next()); // just use the first one
+ opSelection.setShowIfCondition(ifFunc);
+ formItems.add(opSelection);
+
+ SelectItem opResultsSelection = new SelectItem("operationResults", "Operation Status");
+ LinkedHashMap<String, String> operationStatuses = new LinkedHashMap<String, String>(4);
+ operationStatuses.put(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.INPROGRESS.name());
+ operationStatuses.put(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.SUCCESS.name());
+ operationStatuses.put(OperationRequestStatus.FAILURE.name(), OperationRequestStatus.FAILURE.name());
+ operationStatuses.put(OperationRequestStatus.CANCELED.name(), OperationRequestStatus.CANCELED.name());
+ opResultsSelection.setValueMap(operationStatuses);
+ opResultsSelection.setDefaultValue(OperationRequestStatus.FAILURE.name());
+ opResultsSelection.setWidth("*");
+ opResultsSelection.setWrapTitle(false);
+ opResultsSelection.setShowIfCondition(ifFunc);
+ formItems.add(opResultsSelection);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildEventFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(AlertConditionCategory.EVENT);
+
+ String helpStr = "Specify the event severity that an event message must be reported with in order to trigger this condition. If you specify an optional regular expression, the event message must also match that regular expression in order for the condition to trigger.";
+ StaticTextItem helpItem = buildHelpTextItem("eventHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ SelectItem eventSeveritySelection = new SelectItem("eventSeverity", "Event Severity");
+ LinkedHashMap<String, String> severities = new LinkedHashMap<String, String>(5);
+ severities.put(EventSeverity.DEBUG.name(), EventSeverity.DEBUG.name());
+ severities.put(EventSeverity.INFO.name(), EventSeverity.INFO.name());
+ severities.put(EventSeverity.WARN.name(), EventSeverity.WARN.name());
+ severities.put(EventSeverity.ERROR.name(), EventSeverity.ERROR.name());
+ severities.put(EventSeverity.FATAL.name(), EventSeverity.FATAL.name());
+ eventSeveritySelection.setValueMap(severities);
+ eventSeveritySelection.setDefaultValue(EventSeverity.ERROR.name());
+ eventSeveritySelection.setWrapTitle(false);
+ eventSeveritySelection.setShowIfCondition(ifFunc);
+ formItems.add(eventSeveritySelection);
+
+ TextItem eventRegex = new TextItem("eventRegex", "Regular Expression");
+ eventRegex.setRequired(false);
+ eventRegex.setWrapTitle(false);
+ eventRegex.setShowIfCondition(ifFunc);
+ formItems.add(eventRegex);
+
+ return formItems;
+ }
+
+ private SelectItem buildMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
+
+ LinkedHashMap<String, String> metrics = new LinkedHashMap<String, String>();
+ metrics.put("dummy metric", "Dummy Metric Name");
+
+ SelectItem metricSelection = new SelectItem(itemName, "Metric");
+ metricSelection.setValueMap(metrics);
+ metricSelection.setDefaultValue(metrics.keySet().iterator().next()); // just use the first one
+ metricSelection.setWidth("*");
+ metricSelection.setShowIfCondition(ifFunc);
+ return metricSelection;
+ }
+
+ private SelectItem buildComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
+
+ LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>();
+ comparators.put("<", "< (Less than)");
+ comparators.put("=", "= (Equal to)");
+ comparators.put(">", "> (Greater than)");
+
+ SelectItem comparatorSelection = new SelectItem(itemName, "Comparator");
+ comparatorSelection.setValueMap(comparators);
+ comparatorSelection.setDefaultValue("<");
+ comparatorSelection.setShowIfCondition(ifFunc);
+ return comparatorSelection;
+ }
+
+ private StaticTextItem buildHelpTextItem(String itemName, String helpText, FormItemIfFunction ifFunc) {
+ StaticTextItem help = new StaticTextItem(itemName);
+ help.setShowTitle(false);
+ help.setColSpan(2);
+ help.setRowSpan(2);
+ help.setWrap(true);
+ help.setValue(helpText);
+ help.setShowIfCondition(ifFunc);
+ return help;
+ }
+
+ private class ShowIfCategoryFunction implements FormItemIfFunction {
+ private final AlertConditionCategory category;
+
+ public ShowIfCategoryFunction(AlertConditionCategory category) {
+ this.category = category;
+ }
+
+ public boolean execute(FormItem item, Object value, DynamicForm form) {
+ return category.name().equals(form.getValue("conditionType").toString());
+ }
+ }
}
commit ee8eb63dc16b3e4d9847c0d26705dee5008e2222
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Sep 9 18:30:01 2010 -0400
organize config labels.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index ad0895b..e66f091 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -88,7 +88,7 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
//horizontal display component
LocatableHLayout row = new LocatableHLayout("auto-discovery.configuration");
BlurbItem label = new BlurbItem("discovery-platform-count-label");
- label.setValue("Maximum Platforms to show");
+ label.setValue("Number of platforms to display");
//-------------combobox for number of platforms to display on the dashboard
final SelectItem maximumPlatformsComboBox = new SelectItem(AUTODISCOVERY_PLATFORM_MAX);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
index 655596b..c856151 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
@@ -129,7 +129,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
//-------------combobox for number of recently added resources to display on the dashboard
final SelectItem maximumRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_MAX);
- maximumRecentlyAddedComboBox.setTitle("Show maximum of");
+ maximumRecentlyAddedComboBox.setTitle("Show");
maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved resources on dashboard.</b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumRecentlyAddedComboBox.setType("selection");
@@ -154,7 +154,7 @@ public class RecentlyAddedView extends LocatableVLayout implements CustomSetting
//------------- Build second combobox for timeframe for problem resources search.
final SelectItem maximumTimeRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_HRS);
- maximumTimeRecentlyAddedComboBox.setTitle("For the last ");
+ maximumTimeRecentlyAddedComboBox.setTitle("Over ");
maximumTimeRecentlyAddedComboBox.setHint("<nobr><b> hours </b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumTimeRecentlyAddedComboBox.setType("selection");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 88df56f..815afd7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -136,8 +136,8 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
//-------------combobox for number of resource to display on the dashboard
final SelectItem maximumProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_MAX);
- maximumProblemResourcesComboBox.setTitle("Show maximum of");
- maximumProblemResourcesComboBox.setHint("<nobr><b> problem resources for display on dashboard.</b></nobr>");
+ maximumProblemResourcesComboBox.setTitle("Display");
+ maximumProblemResourcesComboBox.setHint("<nobr><b> problem resources on dashboard.</b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumProblemResourcesComboBox.setType("selection");
//define acceptable values for display amount
@@ -161,7 +161,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
//------------- Build second combobox for timeframe for problem resources search.
final SelectItem maximumTimeProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_HRS);
- maximumTimeProblemResourcesComboBox.setTitle("For the last ");
+ maximumTimeProblemResourcesComboBox.setTitle("Over ");
maximumTimeProblemResourcesComboBox.setHint("<nobr><b> hours </b></nobr>");
//spinder 9/3/10: the following is required workaround to disable editability of combobox.
maximumTimeProblemResourcesComboBox.setType("selection");
commit b07055b4f5bb90aa5d4d3c01541793fc5c23b3ef
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Sep 9 18:16:01 2010 -0400
enable server side problem resource config.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 81accf8..ce381ce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -74,7 +74,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
private DashboardPortlet storedPortlet = null;
public static String unlimited = "unlimited";
public static String defaultValue = unlimited;
- public static boolean defaultEnabled = false;
+ public static boolean defaultEnabled = true;
//default no-args constructor for serialization.
private OperationsPortlet() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index fefa85f..b282e41 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -50,7 +50,7 @@ public interface ResourceGWTService extends RemoteService {
List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems);
- List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(ResourceCriteria criteria);
+ List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems);
Resource getPlatformForResource(int resourceId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index d0835b8..7597d13 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -31,7 +31,6 @@ import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
@@ -102,26 +101,25 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
*/
public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria criteria = new ResourceCriteria();
+ long ctime = -1;
+ int maxItems = -1;
//retrieve current portlet display settings
if ((this.portlet != null) && (this.portlet instanceof ProblemResourcesPortlet)) {
ProblemResourcesPortlet problemPortlet = (ProblemResourcesPortlet) this.portlet;
//populate criteria with portlet preferences defined.
if (problemPortlet != null) {
if (problemPortlet.getMaximumProblemResourcesToDisplay() > 0) {
- criteria.setPaging(0, problemPortlet.getMaximumProblemResourcesToDisplay());
+ maxItems = problemPortlet.getMaximumProblemResourcesToDisplay();
}
//define the time window
if (problemPortlet.getMaximumProblemResourcesWithinHours() > 0) {
- criteria.addFilterStartItime(System.currentTimeMillis()
- - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000));
- criteria.addFilterEndItime(System.currentTimeMillis());
+ ctime = System.currentTimeMillis()
+ - (problemPortlet.getMaximumProblemResourcesWithinHours() * 60 * 60 * 1000);
}
}
- //problem resources within the time specified
}
- GWTServiceLookup.getResourceService().findProblemResources(criteria,
+ GWTServiceLookup.getResourceService().findProblemResources(ctime, maxItems,
new AsyncCallback<List<DisambiguationReport<ProblemResourceComposite>>>() {
public void onFailure(Throwable throwable) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index aca7778..6bb2d7d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -146,16 +146,14 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
/** Locate ProblemResourcesComposites and generate the disambiguation reports for them.
* Criteria passed in not currently used.
*/
- public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(ResourceCriteria criteria) {
+ public List<DisambiguationReport<ProblemResourceComposite>> findProblemResources(long ctime, int maxItems) {
List<ProblemResourceComposite> located = new ArrayList<ProblemResourceComposite>();
MeasurementProblemManagerLocal problemManager = LookupUtil.getMeasurementProblemManager();
ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
//retrieve list of discovered problem resources. Grab all, live scrolling data
- //TODO: modify MeasurementProblemManagerLocal to accept ResourceCriteria
- // located = problemManager.findProblemResources(getSessionSubject(), 0, new PageControl(0, -1));
- located = problemManager.findProblemResources(getSessionSubject(), 0, new PageControl(0, -1));
+ located = problemManager.findProblemResources(getSessionSubject(), ctime, new PageControl(0, maxItems));
//translate the returned problem resources to disambiguated links
List<DisambiguationReport<ProblemResourceComposite>> translated = resourceManager.disambiguate(located,
@@ -197,15 +195,6 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return platforms;
}
- // @Override
- // public List<ProblemResourceComposite> findProblemResources(long ctime, int maxItems) {
- // List<ProblemResourceComposite> problems =
- // resourceManager.findResourceCompositesByCriteria(getSessionSubject(), criteria)(
- // getSessionSubject(), ctime, maxItems);
- //
- // return problems;
- // }
-
public List<Integer> uninventoryResources(int[] resourceIds) {
return SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(), resourceIds),
"ResourceService.uninventoryResources");
commit e3421f51e395eda30bcb42e44658e37e26ad6800
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Sep 10 12:55:31 2010 -0400
show priority flag icons in alert def pages
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
index 7e56aec..8f8c5c3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
@@ -23,6 +23,7 @@ import java.util.Date;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.FieldType;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -70,7 +71,20 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
record.setAttribute(FIELD_MTIME, new Date(from.getMtime()));
record.setAttribute(FIELD_ENABLED, from.getEnabled());
record.setAttribute(FIELD_DELETED, from.getDeleted());
- record.setAttribute(FIELD_PRIORITY, from.getPriority().getDisplayName());
+ switch (from.getPriority()) {
+ case HIGH: {
+ record.setAttribute(FIELD_PRIORITY, "/images/icons/Flag_red_16.png");
+ break;
+ }
+ case MEDIUM: {
+ record.setAttribute(FIELD_PRIORITY, "/images/icons/Flag_yellow_16.png");
+ break;
+ }
+ case LOW: {
+ record.setAttribute(FIELD_PRIORITY, "/images/icons/Flag_blue_16.png");
+ break;
+ }
+ }
record.setAttribute(FIELD_OBJECT, from);
return record;
}
@@ -99,7 +113,7 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
enabledField.setType(FieldType.BOOLEAN);
addField(enabledField);
- DataSourceTextField priorityField = new DataSourceTextField(FIELD_PRIORITY, "Priority");
+ DataSourceImageField priorityField = new DataSourceImageField(FIELD_PRIORITY, "Priority");
addField(priorityField);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
index b3f07bd..d1f5de5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
@@ -97,7 +97,7 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
descriptionStatic.setValue(alertDef.getDescription());
prioritySelection.setValue(alertDef.getPriority().name());
- priorityStatic.setValue(alertDef.getPriority().getDisplayName());
+ priorityStatic.setValue(alertDef.getPriority().name());
enabledSelection.setValue(alertDef.getEnabled() ? "Yes" : "No");
enabledStatic.setValue(alertDef.getEnabled() ? "Yes" : "No");
@@ -216,12 +216,18 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
prioritySelection = new SelectItem("priority", "Priority");
LinkedHashMap<String, String> priorities = new LinkedHashMap<String, String>(3);
- priorities.put(AlertPriority.HIGH.name(), AlertPriority.HIGH.getDisplayName());
- priorities.put(AlertPriority.MEDIUM.name(), AlertPriority.MEDIUM.getDisplayName());
- priorities.put(AlertPriority.LOW.name(), AlertPriority.LOW.getDisplayName());
+ priorities.put(AlertPriority.HIGH.name(), AlertPriority.HIGH.name());
+ priorities.put(AlertPriority.MEDIUM.name(), AlertPriority.MEDIUM.name());
+ priorities.put(AlertPriority.LOW.name(), AlertPriority.LOW.name());
+ LinkedHashMap<String, String> priorityIcons = new LinkedHashMap<String, String>();
+ priorityIcons.put(AlertPriority.HIGH.name(), "/images/icons/Flag_red_16.png");
+ priorityIcons.put(AlertPriority.MEDIUM.name(), "/images/icons/Flag_yellow_16.png");
+ priorityIcons.put(AlertPriority.LOW.name(), "/images/icons/Flag_blue_16.png");
prioritySelection.setValueMap(priorities);
+ prioritySelection.setValueIcons(priorityIcons);
prioritySelection.setDefaultValue(AlertPriority.MEDIUM.name());
priorityStatic = new StaticTextItem("priorityStatic", "Priority");
+ priorityStatic.setValueIcons(priorityIcons);
enabledSelection = new RadioGroupItem("enabled", "Enabled");
enabledSelection.setValueMap("Yes", "No");
commit 2c01272635223d14b4019408aaeaab104022d1c0
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Sep 10 01:22:28 2010 -0400
upgrade GWT from 2.0.3 to 2.0.4 (make sure to do a mvn clean install of coregui after pulling down this commit!); include GWT version in About window
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 37e1993..2d92aba 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -23,8 +23,9 @@
<properties>
<!-- dependency versions -->
- <gwt.version>2.0.3</gwt.version>
-
+ <gwt.version>2.0.4</gwt.version>
+ <smartgwt.version>2.2</smartgwt.version>
+
<!-- If this is too much memory to allocate to your gwt:debug process then override this property in
in your settings.xml -->
<gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M</gwt-plugin.extraJvmArgs>
@@ -86,13 +87,13 @@
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
- <version>2.2</version>
+ <version>${smartgwt.version}</version>
</dependency>
<!--
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt-skins</artifactId>
- <version>2.1</version>
+ <version>${smartgwt.version}</version>
</dependency>
-->
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
index b714a33..2611435 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
@@ -45,7 +45,7 @@ public class AboutModalWindow extends Window {
public AboutModalWindow() {
setTitle(MESSAGES.about_title(PRODUCT_INFO.getFullName()));
setWidth(300);
- setHeight(290);
+ setHeight(300);
setOverflow(Overflow.VISIBLE);
setShowMinimizeButton(false);
setIsModal(true);
@@ -74,7 +74,9 @@ public class AboutModalWindow extends Window {
+ "</span><br/>\n" +
"<span class=\"DisplayLabel\">" + MESSAGES.about_buildNumber() + " " + PRODUCT_INFO.getBuildNumber()
+ "</span><p/>\n" +
- "<span class=\"DisplayLabel\">SmartGWT version: " + Version.getVersion() + " (built " + Version.getBuildDate() + ")"
+ "<span class=\"DisplayLabel\">GWT version: " + MESSAGES.gwt_version()
+ + "</span><br/>\n" +
+ "<span class=\"DisplayLabel\">SmartGWT version: " + Version.getVersion()
+ "</span><br/>\n" +
"<p><a href=\"http://jboss.org/\" title=\"JBoss " + MESSAGES.about_homepage() + "\">\n" +
" <img height=\"55\" alt=\"" + MESSAGES.about_jbossByRedHat() + "\" src=\"/images/jboss_logo.png\">\n" +
@@ -86,9 +88,11 @@ public class AboutModalWindow extends Window {
HLayout bottomPanel = new HLayout();
bottomPanel.setAlign(VerticalAlignment.BOTTOM);
contentPane.addMember(bottomPanel);
+
Canvas spacer = new Canvas();
spacer.setWidth("*");
bottomPanel.addMember(spacer);
+
Button closeButton = new Button(MESSAGES.button_close());
closeButton.setShowRollOver(true);
closeButton.setShowDown(true);
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 60fe75b..927f231 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -3,6 +3,11 @@
###########################
#
+# Build Info
+#
+gwt.version = ${gwt.version}
+
+#
# Standard Button Labels
#
button.ok = OK
commit e07ebd6a7670ca982b95363820f925531acc0963
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Sep 10 00:31:41 2010 -0400
various refactorings of tab code; start of utility method for dumping the widget tree to stdout
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
index 4b387eb..1db0e78 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
@@ -38,10 +38,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class SubTabLayout extends LocatableVLayout {
- private ToolStrip buttonBar;
+ /** maps subtab locator IDs to SubTabs */
private Map<String, SubTab> subtabs = new LinkedHashMap<String, SubTab>();
- private Map<String, Button> subTabButtons = new HashMap<String, Button>();
+ /** maps subtab locator IDs to subtab Buttons */
+ private Map<String, Button> subTabButtons = new LinkedHashMap<String, Button>();
+ /** locator IDs of subtabs that are disabled */
private Set<String> disabledSubTabs = new HashSet<String>();
private SubTab currentlyDisplayed;
@@ -62,7 +64,7 @@ public class SubTabLayout extends LocatableVLayout {
setMargin(0);
setPadding(0);
- buttonBar = new ToolStrip();
+ ToolStrip buttonBar = new ToolStrip();
buttonBar.setBackgroundColor("grey");
buttonBar.setWidth100();
buttonBar.setBorder(null);
@@ -77,7 +79,6 @@ public class SubTabLayout extends LocatableVLayout {
SubTab subTab = subtabs.get(locatorId);
if (currentlySelected == null) {
- // currentlyDisplayed = subTab;
currentlySelected = locatorId;
}
@@ -105,7 +106,7 @@ public class SubTabLayout extends LocatableVLayout {
currentlySelected = locatorId;
currentIndex = index;
fireSubTabSelection();
- draw(subtabs.get(locatorId));
+ draw();
}
});
@@ -151,35 +152,9 @@ public class SubTabLayout extends LocatableVLayout {
// }
String locatorId = subTab.getLocatorId();
- subtabs.put(locatorId, subTab);
- if (isDrawn() && locatorId.equals(currentlySelected)) {
- draw(subTab);
- }
- }
-
- private void draw(SubTab subTab) {
- if (currentlyDisplayed != null && currentlyDisplayed.getCanvas() != subTab.getCanvas()) {
- try {
- currentlyDisplayed.getCanvas().hide();
- } catch (Exception e) {
- // ignore this
- }
- }
-
- Canvas canvas = subTab.getCanvas();
- if (canvas != null) {
- if (hasMember(canvas)) {
- if (!canvas.isVisible()) {
- canvas.show();
- }
- } else {
- if (!canvas.isCreated()) {
- canvas.setOverflow(Overflow.SCROLL);
- }
- addMember(canvas);
- }
- markForRedraw();
- currentlyDisplayed = subTab;
+ this.subtabs.put(locatorId, subTab);
+ if (locatorId.equals(this.currentlySelected)) {
+ refresh();
}
}
@@ -200,37 +175,31 @@ public class SubTabLayout extends LocatableVLayout {
return currentIndex;
}
- public String getCurrentTitle() {
- return subtabs.get(currentlySelected).getTitle();
- }
-
public SubTab getDefaultSubTab() {
return subtabs.values().iterator().next();
}
public boolean selectTabByLocatorId(String locatorId) {
boolean foundTab = false;
- this.currentlySelected = locatorId;
int i = 0;
for (String subtabLocatorId : this.subtabs.keySet()) {
if (subtabLocatorId.equals(locatorId)) {
- SubTab subtab = this.subtabs.get(subtabLocatorId);
if (this.disabledSubTabs.contains(subtabLocatorId)) {
// Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL.
+ SubTab subtab = this.subtabs.get(subtabLocatorId);
CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + subtab.getTitle() + "'.");
- break;
+ } else {
+ this.currentlySelected = subtabLocatorId;
+ this.currentIndex = i;
+ foundTab = true;
}
- this.currentIndex = i;
- foundTab = true;
break;
}
i++;
}
- if (foundTab && isDrawn()) {
- Button button = (Button) this.buttonBar.getMember(this.currentIndex);
- button.select();
- draw(this.subtabs.get(locatorId));
+ if (foundTab) {
+ refresh();
}
return foundTab;
@@ -245,20 +214,18 @@ public class SubTabLayout extends LocatableVLayout {
if (this.disabledSubTabs.contains(subtab.getLocatorId())) {
// Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL.
CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'.");
- break;
+ } else {
+ this.currentlySelected = subtab.getLocatorId();
+ this.currentIndex = i;
+ foundTab = true;
}
- this.currentlySelected = subtab.getLocatorId();
- this.currentIndex = i;
- foundTab = true;
break;
}
i++;
}
- if (foundTab && isDrawn()) {
- Button button = (Button) buttonBar.getMember(currentIndex);
- button.select();
- draw(subtabs.get(currentlySelected));
+ if (foundTab) {
+ refresh();
}
return foundTab;
@@ -278,8 +245,8 @@ public class SubTabLayout extends LocatableVLayout {
}
public void fireSubTabSelection() {
- TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?", getCurrentTitle(), -1, currentIndex,
- getCurrentCanvas());
+ TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?", getCurrentSubTab().getTitle(), -1,
+ currentIndex, getCurrentCanvas());
hm.fireEvent(event);
}
@@ -297,4 +264,37 @@ public class SubTabLayout extends LocatableVLayout {
}
}
}
+
+ private void refresh() {
+ if (isDrawn()) {
+ Button button = this.subTabButtons.get(this.currentlySelected);
+ button.select();
+
+ SubTab currentSubtab = this.subtabs.get(this.currentlySelected);
+
+ if (this.currentlyDisplayed != null && this.currentlyDisplayed.getCanvas() != currentSubtab.getCanvas()) {
+ try {
+ this.currentlyDisplayed.getCanvas().hide();
+ } catch (Exception e) {
+ // ignore this
+ }
+ }
+
+ Canvas canvas = currentSubtab.getCanvas();
+ if (canvas != null) {
+ if (hasMember(canvas)) {
+ if (!canvas.isVisible()) {
+ canvas.show();
+ }
+ } else {
+ if (!canvas.isCreated()) {
+ canvas.setOverflow(Overflow.SCROLL);
+ }
+ addMember(canvas);
+ }
+ markForRedraw();
+ this.currentlyDisplayed = currentSubtab;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
index 7215baa..a5c2611 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
@@ -73,8 +73,8 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
System.out.println("TwoLevelTabSet.onTabSelected(): " + tabSelectedEvent.getTab().getTitle());
TwoLevelTab tab = (TwoLevelTab) getSelectedTab();
TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(),
- tab.getLayout().getCurrentTitle(), tabSelectedEvent.getTabNum(), tab.getLayout().getCurrentIndex(), tab
- .getLayout().getCurrentCanvas());
+ tab.getLayout().getCurrentSubTab().getTitle(), tabSelectedEvent.getTabNum(),
+ tab.getLayout().getCurrentIndex(), tab.getLayout().getCurrentCanvas());
m.fireEvent(event);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 7a2064f..6bb216e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -228,13 +228,11 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite));
eventsTab.updateSubTab(this.eventHistory);
- // topTabSet.setSelectedTab(selectedTab);
- completeTabUpdate();
-
+ updateTabEnablement();
}
- private void completeTabUpdate() {
+ private void updateTabEnablement() {
GroupCategory groupCategory = groupComposite.getResourceGroup().getGroupCategory();
Set<ResourceTypeFacet> facets = groupComposite.getResourceFacets().getFacets();
@@ -318,7 +316,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
}
}
- public void loadSelectedGroup(int groupId, final ViewPath viewPath) {
+ public void loadSelectedGroup(final int groupId, final ViewPath viewPath) {
this.groupId = groupId;
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
@@ -327,12 +325,11 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceGroupComposite>>() {
- @Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load group composite", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to load group composite for group with id "
+ + groupId, caught);
}
- @Override
public void onSuccess(PageList<ResourceGroupComposite> result) {
groupComposite = result.get(0);
loadResourceType(groupComposite, viewPath);
@@ -414,5 +411,4 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
}
return false;
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index dc2b363..fc67739 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -274,6 +274,8 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
+ ResourceType type = this.resourceComposite.getResource().getResourceType();
+ inventoryTab.setSubTabEnabled(inventoryChildren.getLocatorId(), !type.getChildResourceTypes().isEmpty());
if (facets.contains(ResourceTypeFacet.OPERATION)) {
topTabSet.enableTab(operationsTab);
@@ -377,7 +379,9 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
final Resource resource = resourceComposite.getResource();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
resource.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.content,
+ EnumSet.of(
+ ResourceTypeRepository.MetadataType.children,
+ ResourceTypeRepository.MetadataType.content,
ResourceTypeRepository.MetadataType.operations,
ResourceTypeRepository.MetadataType.measurements,
ResourceTypeRepository.MetadataType.events,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java
new file mode 100644
index 0000000..5790c70
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/WidgetUtility.java
@@ -0,0 +1,190 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.util;
+
+import com.google.gwt.user.client.ui.Widget;
+import com.smartgwt.client.widgets.BaseWidget;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.Layout;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Ian Springer
+ */
+public class WidgetUtility {
+ private WidgetUtility() {
+ }
+
+ public static void printWidgetTree(Widget widget) {
+ printWidgetTree(widget, 0);
+ }
+
+ private static void printWidgetTree(Widget widget, int level) {
+ try {
+ printWidget(widget, level);
+ } catch (Exception e) {
+ System.err.println("=====================================================================================");
+ System.err.println("Failed to print widget [" + widget + "]: " + e);
+ System.err.println("=====================================================================================");
+ }
+
+ // Recurse.
+ List<Widget> children;
+ try {
+ children = getChildren(widget);
+ } catch (Exception e) {
+ System.err.println("=====================================================================================");
+ System.err.println("Failed to get children of widget [" + widget + "]: " + e);
+ System.err.println("=====================================================================================");
+ return;
+ }
+
+ for (Widget child : children) {
+ printWidgetTree(child, level + 1);
+ }
+ }
+
+ private static void printWidget(Widget widget, int level) {
+ String simpleClassName;
+ try {
+ String className = widget.getClass().getName();
+ simpleClassName = className.substring(className.lastIndexOf(".") + 1);
+ } catch (Exception e) {
+ simpleClassName = "?";
+ }
+ String id;
+ try {
+ id = (widget.getElement() != null) ? widget.getElement().getId() : "?";
+ } catch (Exception e) {
+ id = "?";
+ }
+ String title;
+ try {
+ title = widget.getTitle();
+ } catch (Exception e) {
+ title = "?";
+ }
+
+ StringBuilder flags = new StringBuilder();
+
+ if (widget.isAttached()) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("attached");
+ }
+ if (widget.isVisible()) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("visible");
+ }
+
+ if (widget instanceof BaseWidget) {
+ BaseWidget baseWidget = (BaseWidget) widget;
+
+ if (baseWidget.isCreated()) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("created");
+ }
+ if (baseWidget.isConfigOnly()) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("configOnly");
+ }
+ }
+
+ if (widget instanceof Canvas) {
+ Canvas canvas = (Canvas) widget;
+
+ if (canvas.isDrawn()) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("drawn");
+ }
+ if (canvas.isDirty()) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("dirty");
+ }
+ if (canvas.isDisabled()) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("disabled");
+ }
+ }
+
+ if (widget instanceof HLayout) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("hlayout");
+ } else if (widget instanceof VLayout) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("vlayout");
+ } else if (widget instanceof Layout) {
+ if (flags.length() != 0) {
+ flags.append(", ");
+ }
+ flags.append("layout");
+ }
+
+ StringBuilder indent = new StringBuilder();
+ for (int i = 0; i < level; i++) {
+ indent.append(" ");
+ }
+
+ System.out.println(indent + simpleClassName + "[id=" + id + ", title=" + title + ", flags=[" + flags + "]]");
+ }
+
+ private static List<Widget> getChildren(Widget widget) {
+ List<Widget> children;
+ if (widget instanceof TabSet) {
+ TabSet tabSet = (TabSet) widget;
+ Tab[] tabs = tabSet.getTabs();
+ children = new ArrayList<Widget>();
+ for (Tab tab : tabs) {
+ children.add(tab.getPane());
+ }
+ } else if (widget instanceof Canvas) {
+ Canvas canvas = (Canvas) widget;
+ Canvas[] childrenArray = canvas.getChildren();
+ children = new ArrayList<Widget>();
+ children.addAll(Arrays.asList(childrenArray));
+ } else {
+ children = new ArrayList<Widget>();
+ }
+ return children;
+ }
+}
commit d00a7dd10a914fc0b1359e9e4da04a802629b941
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Sep 9 19:30:38 2010 -0400
fix various bugs in Resource tab navigation; fix bug that was causing Schedules subtabs to fail to render; start coding a debug utility for dumping the entire GWT widget tree to stdout; fix conditional rendering of certain subtabs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index f26acb7..aa2b040 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -41,7 +41,7 @@
<!-- <set-property name="user.agent" value="safari"/> -->
<!-- Firefox 3 -->
- <!--<set-property name="user.agent" value="gecko1_8"/>-->
+ <set-property name="user.agent" value="gecko1_8"/>
<entry-point class='org.rhq.enterprise.gui.coregui.client.CoreGUI'/>
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 9b35895..12c624c 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
@@ -57,6 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
+import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
@@ -321,6 +322,10 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
return userPreferences;
}
+ public static void printWidgetTree() {
+ WidgetUtility.printWidgetTree(coreGUI.rootCanvas);
+ }
+
public static void setSessionSubject(Subject subject) {
// TODO this breaks because of reattach rules, bizarrely even in queries. gonna switch out to non-subject include apis
// Create a minimized session object for validation on requests
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
index 7aa6dff..b714a33 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/AboutModalWindow.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.components;
+import com.smartgwt.client.Version;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Button;
@@ -44,7 +45,7 @@ public class AboutModalWindow extends Window {
public AboutModalWindow() {
setTitle(MESSAGES.about_title(PRODUCT_INFO.getFullName()));
setWidth(300);
- setHeight(255);
+ setHeight(290);
setOverflow(Overflow.VISIBLE);
setShowMinimizeButton(false);
setIsModal(true);
@@ -72,7 +73,9 @@ public class AboutModalWindow extends Window {
"<span class=\"DisplayLabel\">" + MESSAGES.about_version() + " " + PRODUCT_INFO.getVersion()
+ "</span><br/>\n" +
"<span class=\"DisplayLabel\">" + MESSAGES.about_buildNumber() + " " + PRODUCT_INFO.getBuildNumber()
- + "</span>\n" +
+ + "</span><p/>\n" +
+ "<span class=\"DisplayLabel\">SmartGWT version: " + Version.getVersion() + " (built " + Version.getBuildDate() + ")"
+ + "</span><br/>\n" +
"<p><a href=\"http://jboss.org/\" title=\"JBoss " + MESSAGES.about_homepage() + "\">\n" +
" <img height=\"55\" alt=\"" + MESSAGES.about_jbossByRedHat() + "\" src=\"/images/jboss_logo.png\">\n" +
"</a></p>\n" +
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java
index e6be4f8..1739a35 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTab.java
@@ -53,4 +53,8 @@ public class SubTab {
this.canvas = canvas;
}
+ @Override
+ public String toString() {
+ return "SubTab[title=" + this.title + ", locatorId=" + this.locatorId + "]";
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
index 512540e..4b387eb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
@@ -18,10 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.components.tab;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Set;
+import java.util.*;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.event.shared.HandlerRegistration;
@@ -33,6 +30,7 @@ import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -40,16 +38,15 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class SubTabLayout extends LocatableVLayout {
-
private ToolStrip buttonBar;
- private LinkedHashMap<String, SubTab> subtabs = new LinkedHashMap<String, SubTab>();
- private HashMap<String, Button> subTabButtons = new HashMap<String, Button>();
+ private Map<String, SubTab> subtabs = new LinkedHashMap<String, SubTab>();
+ private Map<String, Button> subTabButtons = new HashMap<String, Button>();
private Set<String> disabledSubTabs = new HashSet<String>();
- SubTab currentlyDisplayed;
- String currentlySelected;
- int currentIndex = 0;
+ private SubTab currentlyDisplayed;
+ private String currentlySelected;
+ private int currentIndex;
public SubTabLayout(String locatorId) {
super(locatorId);
@@ -128,10 +125,10 @@ public class SubTabLayout extends LocatableVLayout {
selectTabByLocatorId(currentlySelected);
}
- public void enableSubTab(String title) {
- disabledSubTabs.remove(title);
- if (subTabButtons.containsKey(title)) {
- subTabButtons.get(title).enable();
+ public void enableSubTab(String locatorId) {
+ disabledSubTabs.remove(locatorId);
+ if (subTabButtons.containsKey(locatorId)) {
+ subTabButtons.get(locatorId).enable();
markForRedraw();
}
}
@@ -172,14 +169,16 @@ public class SubTabLayout extends LocatableVLayout {
Canvas canvas = subTab.getCanvas();
if (canvas != null) {
if (hasMember(canvas)) {
- canvas.show();
+ if (!canvas.isVisible()) {
+ canvas.show();
+ }
} else {
if (!canvas.isCreated()) {
canvas.setOverflow(Overflow.SCROLL);
}
- addMember(canvas);
- markForRedraw();
+ addMember(canvas);
}
+ markForRedraw();
currentlyDisplayed = subTab;
}
}
@@ -205,22 +204,33 @@ public class SubTabLayout extends LocatableVLayout {
return subtabs.get(currentlySelected).getTitle();
}
+ public SubTab getDefaultSubTab() {
+ return subtabs.values().iterator().next();
+ }
+
public boolean selectTabByLocatorId(String locatorId) {
boolean foundTab = false;
- currentlySelected = locatorId;
+ this.currentlySelected = locatorId;
int i = 0;
- for (String sub : subtabs.keySet()) {
- if (sub.equals(locatorId)) {
- currentIndex = i;
+ for (String subtabLocatorId : this.subtabs.keySet()) {
+ if (subtabLocatorId.equals(locatorId)) {
+ SubTab subtab = this.subtabs.get(subtabLocatorId);
+ if (this.disabledSubTabs.contains(subtabLocatorId)) {
+ // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL.
+ CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + subtab.getTitle() + "'.");
+ break;
+ }
+ this.currentIndex = i;
foundTab = true;
break;
}
i++;
}
- if (isDrawn()) {
- ((Button) buttonBar.getMember(currentIndex)).select();
- draw(subtabs.get(locatorId));
+ if (foundTab && isDrawn()) {
+ Button button = (Button) this.buttonBar.getMember(this.currentIndex);
+ button.select();
+ draw(this.subtabs.get(locatorId));
}
return foundTab;
@@ -229,25 +239,35 @@ public class SubTabLayout extends LocatableVLayout {
public boolean selectTab(String title) {
boolean foundTab = false;
int i = 0;
- for (String sub : subtabs.keySet()) {
- SubTab subtab = subtabs.get(sub);
+ for (String subtabLocatorId : this.subtabs.keySet()) {
+ SubTab subtab = this.subtabs.get(subtabLocatorId);
if (subtab.getTitle().equals(title)) {
+ if (this.disabledSubTabs.contains(subtab.getLocatorId())) {
+ // Nice try - user tried to select a disabled tab, probably by going directly to a bookmark URL.
+ CoreGUI.getErrorHandler().handleError("Cannot select disabled subtab '" + title + "'.");
+ break;
+ }
this.currentlySelected = subtab.getLocatorId();
- currentIndex = i;
+ this.currentIndex = i;
foundTab = true;
break;
}
i++;
}
- if (isDrawn()) {
- ((Button) buttonBar.getMember(currentIndex)).select();
+ if (foundTab && isDrawn()) {
+ Button button = (Button) buttonBar.getMember(currentIndex);
+ button.select();
draw(subtabs.get(currentlySelected));
}
return foundTab;
}
+ public SubTab getCurrentSubTab() {
+ return this.subtabs.get(this.currentlySelected);
+ }
+
// ------- Event support -------
// Done with a separate handler manager from parent class on purpose (compatibility issue)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
index c78db8a..845128f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTab.java
@@ -26,7 +26,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
* @author Greg Hinkle
*/
public class TwoLevelTab extends LocatableTab {
-
private SubTabLayout layout;
public TwoLevelTab(String locatorId, String title, String icon) {
@@ -45,11 +44,11 @@ public class TwoLevelTab extends LocatableTab {
}
}
- public void setSubTabEnabled(String tab, boolean enabled) {
+ public void setSubTabEnabled(String locatorId, boolean enabled) {
if (enabled) {
- layout.enableSubTab(tab);
+ layout.enableSubTab(locatorId);
} else {
- layout.disableSubTab(tab);
+ layout.disableSubTab(locatorId);
}
}
@@ -62,4 +61,8 @@ public class TwoLevelTab extends LocatableTab {
return layout;
}
+ @Override
+ public String toString() {
+ return "TwoLevelTab[title=" + getTitle() + ", locatorId=" + getLocatorId() + "]";
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
index de4a27c..7215baa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/TwoLevelTabSet.java
@@ -27,6 +27,8 @@ import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
/**
+ * A tab set where each {@link TwoLevelTab tab} has one or more {@link SubTab subtab}s.
+ *
* @author Greg Hinkle
*/
public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandler, TwoLevelTabSelectedHandler {
@@ -37,16 +39,27 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
public void setTabs(TwoLevelTab... tabs) {
super.setTabs(tabs);
- for (TwoLevelTab tab : tabs) {
-
+ for (TwoLevelTab tab : tabs) {
tab.getLayout().addTwoLevelTabSelectedHandler(this);
-
updateTab(tab, tab.getPane());
}
addTabSelectedHandler(this);
}
+ public TwoLevelTab[] getTabs() {
+ Tab[] tabs = super.getTabs();
+ TwoLevelTab[] twoLevelTabs = new TwoLevelTab[tabs.length];
+ for (int i = 0, tabsLength = tabs.length; i < tabsLength; i++) {
+ Tab tab = tabs[i];
+ if (!(tab instanceof TwoLevelTab)) {
+ throw new IllegalStateException("TwoLevelTabSet contains a Tab that is not a TwoLevelTab.");
+ }
+ twoLevelTabs[i] = (TwoLevelTab) tab;
+ }
+ return twoLevelTabs;
+ }
+
// ------- Event support -------
// Done with a separate handler manager from parent class on purpose (compatibility issue)
@@ -57,9 +70,8 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
}
public void onTabSelected(TabSelectedEvent tabSelectedEvent) {
-
+ System.out.println("TwoLevelTabSet.onTabSelected(): " + tabSelectedEvent.getTab().getTitle());
TwoLevelTab tab = (TwoLevelTab) getSelectedTab();
-
TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent(tab.getTitle(),
tab.getLayout().getCurrentTitle(), tabSelectedEvent.getTabNum(), tab.getLayout().getCurrentIndex(), tab
.getLayout().getCurrentCanvas());
@@ -67,19 +79,19 @@ public class TwoLevelTabSet extends LocatableTabSet implements TabSelectedHandle
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
+ System.out.println("TwoLevelTabSet.onTwoLevelTabSelected(): " + tabSelectedEvent.getId() + "/" +
+ tabSelectedEvent.getSubTabId());
tabSelectedEvent.setTabNum(getSelectedTabNumber());
- tabSelectedEvent.setId(getSelectedTab().getTitle());
-
+ Tab tab = getSelectedTab();
+ tabSelectedEvent.setId(tab.getTitle());
m.fireEvent(tabSelectedEvent);
}
- public Tab getTabByTitle(String title) {
- Tab[] tabs = getTabs();
- for (Tab tab : tabs) {
- if (tab.getTitle().equals(title)) {
- return tab;
- }
- }
- return null;
+ public TwoLevelTab getTabByTitle(String title) {
+ return (TwoLevelTab) super.getTabByTitle(title);
+ }
+
+ public TwoLevelTab getTabByLocatorId(String locatorId) {
+ return (TwoLevelTab) super.getTabByLocatorId(locatorId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index abae48f..f30ab10 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -53,6 +53,7 @@ import com.smartgwt.client.widgets.layout.LayoutSpacer;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -208,136 +209,140 @@ public class Table extends LocatableHLayout {
@Override
protected void onDraw() {
- super.onDraw();
+ try {
+ super.onDraw();
- for (Canvas child : contents.getMembers()) {
- contents.removeChild(child);
- }
-
- // Title
- title = new HTMLFlow();
- setTableTitle(tableTitle);
-
- if (showHeader) {
- titleLayout = new HLayout();
- titleLayout.setAutoHeight();
- titleLayout.setAlign(VerticalAlignment.BOTTOM);
- }
+ for (Canvas child : contents.getMembers()) {
+ contents.removeChild(child);
+ }
- // Add components to the view
- if (showHeader) {
- contents.addMember(titleLayout, 0);
- }
+ // Title
+ title = new HTMLFlow();
+ setTableTitle(tableTitle);
- if (filterForm.hasContent()) {
- contents.addMember(filterForm);
- }
+ if (showHeader) {
+ titleLayout = new HLayout();
+ titleLayout.setAutoHeight();
+ titleLayout.setAlign(VerticalAlignment.BOTTOM);
+ }
- contents.addMember(listGrid);
+ // Add components to the view
+ if (showHeader) {
+ contents.addMember(titleLayout, 0);
+ }
- // Footer
- footer = new ToolStrip();
- footer.setPadding(5);
- footer.setWidth100();
- footer.setMembersMargin(15);
- contents.addMember(footer);
-
- // The ListGrid has been created and configured
- // Now give subclasses a chance to configure the table
- configureTable();
-
- tableInfo = new Label("Total: " + listGrid.getTotalRows());
-
- // NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since
- // super.onDraw() is what actually adds the fields to the ListGrid (based on what fields are defined in
- // the underlying datasource).
- if (this.excludedFieldNames != null) {
- for (String excludedFieldName : excludedFieldNames) {
- this.listGrid.hideField(excludedFieldName);
+ if (filterForm.hasContent()) {
+ contents.addMember(filterForm);
}
- }
- tableInfo.setWrap(false);
+ contents.addMember(listGrid);
- if (showHeader) {
+ // Footer
+ footer = new ToolStrip();
+ footer.setPadding(5);
+ footer.setWidth100();
+ footer.setMembersMargin(15);
+ contents.addMember(footer);
- for (String headerIcon : headerIcons) {
- Img img = new Img(headerIcon, 24, 24);
- img.setPadding(4);
- titleLayout.addMember(img);
- }
+ // The ListGrid has been created and configured
+ // Now give subclasses a chance to configure the table
+ configureTable();
- titleLayout.addMember(title);
+ tableInfo = new Label("Total: " + listGrid.getTotalRows());
- if (titleComponent != null) {
- titleLayout.addMember(new LayoutSpacer());
- titleLayout.addMember(titleComponent);
+ // NOTE: It is essential that we wait to hide any excluded fields until after super.onDraw() is called, since
+ // super.onDraw() is what actually adds the fields to the ListGrid (based on what fields are defined in
+ // the underlying datasource).
+ if (this.excludedFieldNames != null) {
+ for (String excludedFieldName : excludedFieldNames) {
+ this.listGrid.hideField(excludedFieldName);
+ }
}
- }
+ tableInfo.setWrap(false);
- if (showFooter) {
+ if (showHeader) {
- footer.removeMembers(footer.getMembers());
+ for (String headerIcon : headerIcons) {
+ Img img = new Img(headerIcon, 24, 24);
+ img.setPadding(4);
+ titleLayout.addMember(img);
+ }
- for (final TableActionInfo tableAction : tableActions) {
- IButton button = new LocatableIButton(tableAction.getLocatorId(), tableAction.getTitle());
- button.setDisabled(true);
- button.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- if (tableAction.confirmMessage != null) {
+ titleLayout.addMember(title);
- String message = tableAction.confirmMessage.replaceAll("\\#", String.valueOf(listGrid
- .getSelection().length));
+ if (titleComponent != null) {
+ titleLayout.addMember(new LayoutSpacer());
+ titleLayout.addMember(titleComponent);
+ }
- SC.ask(message, new BooleanCallback() {
- public void execute(Boolean confirmed) {
- if (confirmed) {
- tableAction.action.executeAction(listGrid.getSelection());
- }
- }
- });
- } else {
- tableAction.action.executeAction(listGrid.getSelection());
- }
- }
- });
- tableAction.actionButton = button;
- footer.addMember(button);
}
- for (Canvas extraWidgetCanvas : extraWidgets) {
- footer.addMember(extraWidgetCanvas);
- }
+ if (showFooter) {
- footer.addMember(new LayoutSpacer());
+ footer.removeMembers(footer.getMembers());
- IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh");
- refreshButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- listGrid.invalidateCache();
- }
- });
- footer.addMember(refreshButton);
+ for (final TableActionInfo tableAction : tableActions) {
+ IButton button = new LocatableIButton(tableAction.getLocatorId(), tableAction.getTitle());
+ button.setDisabled(true);
+ button.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ if (tableAction.confirmMessage != null) {
- footer.addMember(tableInfo);
+ String message = tableAction.confirmMessage.replaceAll("\\#", String.valueOf(listGrid
+ .getSelection().length));
- // Manages enable/disable buttons for the grid
- listGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- refreshTableInfo();
+ SC.ask(message, new BooleanCallback() {
+ public void execute(Boolean confirmed) {
+ if (confirmed) {
+ tableAction.action.executeAction(listGrid.getSelection());
+ }
+ }
+ });
+ } else {
+ tableAction.action.executeAction(listGrid.getSelection());
+ }
+ }
+ });
+ tableAction.actionButton = button;
+ footer.addMember(button);
}
- });
- listGrid.addDataArrivedHandler(new DataArrivedHandler() {
- public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
- refreshTableInfo();
- fieldSizes.clear();
+ for (Canvas extraWidgetCanvas : extraWidgets) {
+ footer.addMember(extraWidgetCanvas);
}
- });
- // ensure buttons are initially set correctly
- refreshTableInfo();
+ footer.addMember(new LayoutSpacer());
+
+ IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), "Refresh");
+ refreshButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ listGrid.invalidateCache();
+ }
+ });
+ footer.addMember(refreshButton);
+
+ footer.addMember(tableInfo);
+
+ // Manages enable/disable buttons for the grid
+ listGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ refreshTableInfo();
+ }
+ });
+
+ listGrid.addDataArrivedHandler(new DataArrivedHandler() {
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ refreshTableInfo();
+ fieldSizes.clear();
+ }
+ });
+
+ // Ensure buttons are initially set correctly.
+ refreshTableInfo();
+ }
+ } catch (Exception e) {
+ CoreGUI.getErrorHandler().handleError("Failed to draw Table [" + this + "].", e);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
index 1cf02e7..78fe1d3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
@@ -96,9 +96,13 @@ public class UpdateCollectionIntervalWidget extends LocatableHLayout implements
@Override
public void refresh(ListGrid listGrid) {
- int count = listGrid.getSelection().length;
- Long interval = getInterval();
- this.setButton.setDisabled(count == 0 || interval == null);
+ if (isDrawn()) {
+ int count = listGrid.getSelection().length;
+ Long interval = getInterval();
+ this.setButton.setDisabled(count == 0 || interval == null);
+ } else {
+ markForRedraw();
+ }
}
private Long getInterval() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 59997b4..7a2064f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -29,6 +29,8 @@ import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.ResourceTypeFacet;
import org.rhq.core.domain.resource.composite.ResourcePermission;
@@ -242,7 +244,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
topTabSet.enableTab(inventoryTab);
// Inventory>Connection Settings subtab is only enabled for compat groups that define conn props.
- inventoryTab.setSubTabEnabled("Connection Settings", groupCategory == GroupCategory.COMPATIBLE
+ inventoryTab.setSubTabEnabled(this.inventoryConn.getLocatorId(), groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
// Monitoring and Alerts tabs are always enabled for compatible groups and always disabled for mixed groups.
@@ -276,8 +278,9 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
topTabSet.disableTab(eventsTab);
}
- // only enable "Call Time" sub-tab for those that implement it
- monitoringTab.setSubTabEnabled("Call Time", facets.contains(ResourceTypeFacet.CALL_TIME));
+ // only enable "Call Time" and "Traits" subtabs for groups that implement them.
+ monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.groupComposite));
+ monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
@@ -300,7 +303,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
viewPath.next();
-
tabName = (!viewPath.isEnd()) ? viewPath.getCurrent().getPath() : null; // e.g. "Inventory"
subTabName = (viewPath.viewsLeft() >= 1) ? viewPath.getNext().getPath() : null; // e.g. "Overview"
@@ -319,7 +321,6 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
public void loadSelectedGroup(int groupId, final ViewPath viewPath) {
this.groupId = groupId;
-
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.addFilterId(groupId);
criteria.addFilterVisible(null);
@@ -349,7 +350,9 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
ResourceType groupType = group.getResourceType();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
groupType.getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations,
+ EnumSet.of(ResourceTypeRepository.MetadataType.content,
+ ResourceTypeRepository.MetadataType.operations,
+ ResourceTypeRepository.MetadataType.measurements,
ResourceTypeRepository.MetadataType.events,
ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
new ResourceTypeRepository.TypeLoadedCallback() {
@@ -377,16 +380,16 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
if (tabName == null) {
tabName = DEFAULT_TAB_NAME;
}
- TwoLevelTab tab = (TwoLevelTab) this.topTabSet.getTabByTitle(tabName);
+ TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName);
if (tab == null) {
CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName);
// TODO: Should we fire a history event here to redirect to a valid bookmark?
- tab = (TwoLevelTab) this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME);
+ tab = this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME);
}
this.topTabSet.selectTab(tab);
if (subtabName != null) {
if (!tab.getLayout().selectTab(subtabName)) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName);
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName);
// TODO: Should we fire a history event here to redirect to a valid bookmark?
return;
} else {
@@ -398,4 +401,18 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
}
}
+
+ private static boolean hasTraits(ResourceGroupComposite groupComposite) {
+ ResourceType type = groupComposite.getResourceGroup().getResourceType();
+ if (type != null) {
+ Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions();
+ for (MeasurementDefinition metricDef : metricDefs) {
+ if (metricDef.getDataType() == DataType.TRAIT) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java
index 51b48eb..76b7b76 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeDatasource.java
@@ -261,11 +261,24 @@ public class ResourceGroupTreeDatasource extends DataSource {
setAttribute("parentId", parentId);
setAttribute("name", category.getDisplayName());
}
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("CategoryTreeNode[");
+ String id = getAttribute("id");
+ buffer.append("id=").append(id);
+ String parentId = getAttribute("parentId");
+ buffer.append(", parentId=").append(parentId);
+ String name = getAttribute("name");
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
}
public static class TypeTreeNode extends TreeNode {
-
private TypeTreeNode(String parentId, String parentResourceId, String type) {
setID(parentId + "_" + type);
setParentID(parentId);
@@ -276,10 +289,22 @@ public class ResourceGroupTreeDatasource extends DataSource {
setAttribute("name", type);
}
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("TypeTreeNode[");
+ String id = getAttribute("id");
+ buffer.append("id=").append(id);
+ String parentId = getAttribute("parentId");
+ buffer.append(", parentId=").append(parentId);
+ String name = getAttribute("name");
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
}
public static class ResourceTreeNode extends TreeNode {
-
private Resource resource;
private ResourceTreeNode(Resource resource) {
@@ -325,5 +350,19 @@ public class ResourceGroupTreeDatasource extends DataSource {
public String getParentId() {
return getAttribute("parentId");
}
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("ResourceTreeNode[");
+ String id = getAttribute("id");
+ buffer.append("id=").append(id);
+ String parentId = getAttribute("parentId");
+ buffer.append(", parentId=").append(parentId);
+ String name = getAttribute("name");
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index e43ccef..dc2b363 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -28,6 +28,8 @@ import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.ResourceTypeFacet;
@@ -65,11 +67,9 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* Right panel of the Resource view.
*
* @author Greg Hinkle
+ * @author Ian Springer
*/
public class ResourceDetailView extends LocatableVLayout implements BookmarkableView, TwoLevelTabSelectedHandler {
-
- private static final String DEFAULT_TAB_NAME = "Summary";
-
private int resourceId;
private ResourceComposite resourceComposite;
@@ -202,7 +202,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
final Resource resource = this.resourceComposite.getResource();
this.titleBar.setResource(resource);
- for (Tab top : topTabSet.getTabs()) {
+ for (Tab top : this.topTabSet.getTabs()) {
((TwoLevelTab) top).getLayout().destroyViews();
}
@@ -210,9 +210,6 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
this.summaryDashboard.setCanvas(new DashboardView(this.resourceComposite));
this.summaryTimeline.setCanvas(new FullHTMLPane("/rhq/resource/summary/timeline-plain.xhtml?id="
+ resource.getId()));
- summaryTab.updateSubTab(this.summaryOverview);
- summaryTab.updateSubTab(this.summaryDashboard);
- summaryTab.updateSubTab(this.summaryTimeline);
this.monitorGraphs.setCanvas(new GraphListView(this.monitoringTab.extendLocatorId("GraphListView"), resource));
this.monitorTables.setCanvas(new FullHTMLPane("/rhq/common/monitor/tables-plain.xhtml?id=" + resource.getId()));
@@ -222,17 +219,9 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
this.monitorSched.setCanvas(new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resource.getId()));
this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id="
+ resource.getId()));
- monitoringTab.updateSubTab(this.monitorGraphs);
- monitoringTab.updateSubTab(this.monitorTables);
- monitoringTab.updateSubTab(this.monitorTraits);
- monitoringTab.updateSubTab(this.monitorAvail);
- monitoringTab.updateSubTab(this.monitorSched);
- monitoringTab.updateSubTab(this.monitorCallTime);
this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(resource.getId()));
this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource));
- inventoryTab.updateSubTab(this.inventoryChildren);
- inventoryTab.updateSubTab(this.inventoryConn);
// comment out GWT-based operation history until...
// 1) user can delete history if they possess the appropriate permissions
@@ -244,33 +233,24 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
resourceComposite));
this.opSched.setCanvas(new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id="
+ resource.getId()));
- operationsTab.updateSubTab(this.opHistory);
- operationsTab.updateSubTab(this.opSched);
// comment out GWT-based alert definitions/history views until...
// 1) new workflow is implement for alert definition creation, with particular attention to interaction model for alert notifications
// 2) user can delete/ack/purgeAll alerts if they possess the appropriate permissions
// 3) user can enable/disable/delete alert definitions if they possess the appropriate permissions
- // 4) user can search alert history by: date alert was fired, alert priority, or alert definition
- //alertsTab.updateSubTab("History", new ResourceAlertHistoryView(resource.getId()));
+ // 4) user can search alert history by: date alert was fired, alert priority, or alert definition
this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id="
+ resource.getId()));
this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("Def"), resource));
this.alertDelete.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id="
+ resource.getId()));
- alertsTab.updateSubTab(this.alertHistory);
- alertsTab.updateSubTab(this.alertDef);
- alertsTab.updateSubTab(this.alertDelete);
this.configCurrent
.setCanvas(new ResourceConfigurationEditView(this.extendLocatorId("ResourceConfig"), resource));
this.configHistory.setCanvas(ConfigurationHistoryView.getHistoryOf(configurationTab.extendLocatorId("Hist"),
resource.getId()));
- configurationTab.updateSubTab(this.configCurrent);
- configurationTab.updateSubTab(this.configHistory);
this.eventHistory.setCanvas(EventCompositeHistoryView.get(resourceComposite));
- eventsTab.updateSubTab(this.eventHistory);
this.contentDeployed
.setCanvas(new FullHTMLPane("/rhq/resource/content/view-plain.xhtml?id=" + resource.getId()));
@@ -279,26 +259,21 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
+ resource.getId()));
this.contentHistory.setCanvas(new FullHTMLPane("/rhq/resource/content/history-plain.xhtml?id="
+ resource.getId()));
- contentTab.updateSubTab(contentDeployed);
- contentTab.updateSubTab(contentNew);
- contentTab.updateSubTab(contentSubscrip);
- contentTab.updateSubTab(contentHistory);
-
- // topTabSet.setSelectedTab(selectedTab);
- completeTabUpdate();
+ updateTabEnablement();
}
- private void completeTabUpdate() {
+ private void updateTabEnablement() {
ResourcePermission permissions = this.resourceComposite.getResourcePermission();
Set<ResourceTypeFacet> facets = this.resourceComposite.getResourceFacets().getFacets();
// Summary, Monitoring, Inventory, and Alerts tabs are always enabled.
- monitoringTab.setSubTabEnabled("Call Time", facets.contains(ResourceTypeFacet.CALL_TIME));
+ monitoringTab.setSubTabEnabled(monitorTraits.getLocatorId(), hasTraits(this.resourceComposite));
+ monitoringTab.setSubTabEnabled(monitorCallTime.getLocatorId(), facets.contains(ResourceTypeFacet.CALL_TIME));
- inventoryTab.setSubTabEnabled("Connection Settings", facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
+ inventoryTab.setSubTabEnabled(inventoryConn.getLocatorId(), facets.contains(ResourceTypeFacet.PLUGIN_CONFIGURATION));
if (facets.contains(ResourceTypeFacet.OPERATION)) {
topTabSet.enableTab(operationsTab);
@@ -323,26 +298,26 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
} else {
topTabSet.disableTab(contentTab);
}
-
- if (topTabSet.getSelectedTab().getDisabled()) {
- topTabSet.selectTab(0);
- }
-
- topTabSet.markForRedraw();
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
+ //CoreGUI.printWidgetTree();
+
if (this.resourceComposite == null) {
// History.fireCurrentHistoryState();
} else {
// Switch tabs directly, rather than letting the history framework do it, to avoid redrawing the outer views.
// selectTab(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
-
String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
String path = "Resource/" + resourceId + tabPath;
- // But still add an item to the history, specifying false to tell it not to fire an event.
- History.newItem(path, true);
+ // If the tab that was selected is not already the current history item, the user clicked on the tab, rather
+ // than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
+ // current history item.
+ if (!History.getToken().equals(path)) {
+ System.out.println("Firing History event [" + path + "]...");
+ History.newItem(path, true);
+ }
}
}
@@ -402,7 +377,9 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
final Resource resource = resourceComposite.getResource();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
resource.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations,
+ EnumSet.of(ResourceTypeRepository.MetadataType.content,
+ ResourceTypeRepository.MetadataType.operations,
+ ResourceTypeRepository.MetadataType.measurements,
ResourceTypeRepository.MetadataType.events,
ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
new ResourceTypeRepository.TypeLoadedCallback() {
@@ -411,34 +388,52 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
ResourceDetailView.this.resourceComposite = resourceComposite;
updateDetailViews(resourceComposite);
selectTab(tabName, subTabName, viewPath);
-
}
});
}
public void selectTab(String tabName, String subtabName, ViewPath viewPath) {
- if (tabName == null) {
- tabName = DEFAULT_TAB_NAME;
- }
- TwoLevelTab tab = (TwoLevelTab) this.topTabSet.getTabByTitle(tabName);
- if (tab == null) {
- CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName);
- // TODO: Should we fire a history event here to redirect to a valid bookmark?
- tab = (TwoLevelTab) this.topTabSet.getTabByTitle(DEFAULT_TAB_NAME);
- }
- this.topTabSet.selectTab(tab);
- if (subtabName != null) {
- if (!tab.getLayout().selectTab(subtabName)) {
- CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName);
+ try {
+ TwoLevelTab tab = this.topTabSet.getTabByTitle(tabName);
+ if (tab == null || tab.getDisabled()) {
+ CoreGUI.getErrorHandler().handleError("Invalid tab name: " + tabName);
// TODO: Should we fire a history event here to redirect to a valid bookmark?
- return;
- } else {
- Canvas subView = tab.getLayout().getCurrentCanvas();
+ Tab defaultTab = this.topTabSet.getTab(0);
+ tab = (TwoLevelTab) defaultTab;
+ }
+ SubTab subTab = null;
+ if (subtabName != null) {
+ if (!tab.getLayout().selectTab(subtabName)) {
+ CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabName);
+ // TODO: Should we fire a history event here to redirect to a valid bookmark?
+ SubTab defaultSubtab = tab.getLayout().getDefaultSubTab();
+ tab.getLayout().selectTab(defaultSubtab.getTitle());
+ }
+ subTab = tab.getLayout().getCurrentSubTab();
+ }
+ this.topTabSet.selectTab(tab);
+ if (subTab != null) {
+ tab.updateSubTab(subTab);
+ Canvas subView = subTab.getCanvas();
if (subView instanceof BookmarkableView) {
((BookmarkableView) subView).renderView(viewPath);
}
}
+ tab.getLayout().markForRedraw();
+ this.topTabSet.markForRedraw();
+ } catch (Exception e) {
+ System.err.println("Failed to select tab " + tabName + "/" + subtabName + ": " + e);
}
}
+ private static boolean hasTraits(ResourceComposite resourceComposite) {
+ ResourceType type = resourceComposite.getResource().getResourceType();
+ Set<MeasurementDefinition> metricDefs = type.getMetricDefinitions();
+ for (MeasurementDefinition metricDef : metricDefs) {
+ if (metricDef.getDataType() == DataType.TRAIT) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index ecb4806..fe4fdc2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -55,10 +55,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* @author Greg Hinkle
*/
public class ResourceTreeDatasource extends DataSource {
-
- private boolean initialized = false;
- int rootId;
- List<Resource> initialData;
+ private List<Resource> initialData;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -69,8 +66,6 @@ public class ResourceTreeDatasource extends DataSource {
this.initialData = initialData;
- this.rootId = rootId;
-
DataSourceField idDataField = new DataSourceTextField("id", "ID");
idDataField.setPrimaryKey(true);
@@ -240,7 +235,6 @@ public class ResourceTreeDatasource extends DataSource {
}
return built.toArray(new TreeNode[built.size()]);
-
}
private static boolean sameTypes(ResourceTreeNode[] nodes) {
@@ -263,10 +257,23 @@ public class ResourceTreeDatasource extends DataSource {
setAttribute("parentId", parentId);
setAttribute("name", category.getDisplayName());
}
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("CategoryTreeNode[");
+ String id = getAttribute("id");
+ buffer.append("id=").append(id);
+ String parentId = getAttribute("parentId");
+ buffer.append(", parentId=").append(parentId);
+ String name = getAttribute("name");
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
}
public static class TypeTreeNode extends TreeNode {
-
private TypeTreeNode(String parentId, String parentResourceId, String type) {
setID(parentId + "_" + type);
setParentID(parentId);
@@ -277,10 +284,22 @@ public class ResourceTreeDatasource extends DataSource {
setAttribute("name", type);
}
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("TypeTreeNode[");
+ String id = getAttribute("id");
+ buffer.append("id=").append(id);
+ String parentId = getAttribute("parentId");
+ buffer.append(", parentId=").append(parentId);
+ String name = getAttribute("name");
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
}
public static class ResourceTreeNode extends TreeNode {
-
private Resource resource;
private ResourceTreeNode(Resource resource) {
@@ -327,5 +346,19 @@ public class ResourceTreeDatasource extends DataSource {
public String getParentId() {
return getAttribute("parentId");
}
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("ResourceTreeNode[");
+ String id = getAttribute("id");
+ buffer.append("id=").append(id);
+ String parentId = getAttribute("parentId");
+ buffer.append(", parentId=").append(parentId);
+ String name = getAttribute("name");
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index e73c7ef..8566975 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -73,6 +73,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectLi
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.factory.ResourceFactoryCreateWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.TreeUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -520,6 +521,8 @@ public class ResourceTreeView extends LocatableVLayout {
}
});
+ TreeUtility.printTree(treeGrid.getTree());
+
TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId));
// System.out.println("Trying to preopen: " + selectedNode);
if (selectedNode != null) {
@@ -550,6 +553,8 @@ public class ResourceTreeView extends LocatableVLayout {
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
+ TreeUtility.printTree(treeGrid.getTree());
+
treeGrid.getTree().linkNodes(ResourceTreeDatasource.build(result));
TreeNode selectedNode = treeGrid.getTree().findById(
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
new file mode 100644
index 0000000..8199c50
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
@@ -0,0 +1,29 @@
+package org.rhq.enterprise.gui.coregui.client.util;
+
+import com.smartgwt.client.widgets.tree.Tree;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+/**
+ * @author Ian Springer
+ */
+public class TreeUtility {
+ public static void printTree(Tree tree) {
+ TreeNode rootNode = tree.getRoot();
+ printTreeNode(tree, rootNode);
+ }
+
+ private static void printTreeNode(Tree tree, TreeNode node) {
+ int level = tree.getLevel(node);
+ for (int i = 0; i < level; i++) {
+ System.out.print(' ');
+ }
+ System.out.println("* " + node);
+ TreeNode[] childNodes = tree.getChildren(node);
+ for (TreeNode childNode : childNodes) {
+ printTreeNode(tree, childNode);
+ }
+ }
+
+ private TreeUtility() {
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
index 5b3e09e..8fb1e41 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
@@ -3,7 +3,7 @@ package org.rhq.enterprise.gui.coregui.client.util.selenium;
import com.smartgwt.client.widgets.layout.HLayout;
/**
- * Wrapper for com.smartgwt.client.widgets.layout.HLayout that sets the ID for use with selenium scLocators.
+ * Wrapper for a SmartGWT {@link HLayout} that sets the ID for use with Selenium scLocators.
*
* @author Jay Shaughnessy
*/
@@ -46,5 +46,4 @@ public class LocatableHLayout extends HLayout implements Locatable {
public String extendLocatorId(String extension) {
return this.locatorId + "_" + extension;
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java
index 4ba995c..0dda6bf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.util.selenium;
+import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
/**
@@ -41,10 +42,28 @@ public class LocatableTabSet extends TabSet {
SeleniumUtility.setID(this, locatorId);
}
+ public void setTabs(LocatableTab... tabs) {
+ super.setTabs(tabs);
+ }
+
+ public LocatableTab[] getTabs() {
+ Tab[] tabs = super.getTabs();
+ LocatableTab[] locatableTabs = new LocatableTab[tabs.length];
+ for (int i = 0, tabsLength = tabs.length; i < tabsLength; i++) {
+ Tab tab = tabs[i];
+ if (!(tab instanceof LocatableTab)) {
+ throw new IllegalStateException("LocatableTabSet contains a Tab that is not a LocatableTab.");
+ }
+ locatableTabs[i] = (LocatableTab) tab;
+ }
+ return locatableTabs;
+ }
+
/**
* Returns the locatorId. This can be useful for constructing more granular locatorIds. For example, if
* the widget contains sub-widgets. Note, this is the raw locatorId for the widget, to get the fully
- * formed ID, typically ofthe form "simpleClassname_locatorId" Call {@link getID()}.
+ * formed ID, typically of the form "simpleClassname_locatorId", call
+ * {@link com.smartgwt.client.widgets.Canvas#getID()}.
*
* @return the locatorId
*/
@@ -67,4 +86,23 @@ public class LocatableTabSet extends TabSet {
return this.locatorId + "_" + extension;
}
+ public LocatableTab getTabByTitle(String title) {
+ LocatableTab[] tabs = getTabs();
+ for (LocatableTab tab : tabs) {
+ if (tab.getTitle().equals(title)) {
+ return tab;
+ }
+ }
+ return null;
+ }
+
+ public LocatableTab getTabByLocatorId(String locatorId) {
+ LocatableTab[] tabs = getTabs();
+ for (LocatableTab tab : tabs) {
+ if (tab.getLocatorId().equals(locatorId)) {
+ return tab;
+ }
+ }
+ return null;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
index 0a9b00e..61991c4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
@@ -3,7 +3,7 @@ package org.rhq.enterprise.gui.coregui.client.util.selenium;
import com.smartgwt.client.widgets.layout.VLayout;
/**
- * Wrapper for com.smartgwt.client.widgets.layout.VLayout that sets the ID for use with selenium scLocators.
+ * Wrapper for a SmartGWT {@link VLayout} that sets the ID for use with Selenium scLocators.
*
* @author Jay Shaughnessy
*/
@@ -50,5 +50,4 @@ public class LocatableVLayout extends VLayout implements Locatable {
public void destroyMembers() {
SeleniumUtility.destroyMembers(this);
}
-
}
commit d5c7dd9fe06a82c944231ef63d102f48968585c9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 9 17:17:32 2010 -0400
more alert def conditions editor stuff - starting the "add new condition" dialog
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
index c4e1844..e1cb68f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -139,7 +139,11 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
condExprs.put(BooleanExpression.ANY.name(), BooleanExpression.ANY.toString());
conditionExpression.setValueMap(condExprs);
conditionExpression.setDefaultValue(BooleanExpression.ALL.name());
+ conditionExpression.setWrapTitle(false);
+
conditionExpressionStatic = new StaticTextItem("conditionExpressionStatic", "Fire alert when");
+ conditionExpressionStatic.setWrapTitle(false);
+
conditionExpressionForm.setFields(conditionExpression, conditionExpressionStatic);
conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), null);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index ecd93d0..1742ec0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -29,7 +29,9 @@ import java.util.Set;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition;
@@ -86,8 +88,24 @@ public class ConditionsEditor extends LocatableVLayout {
table.addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() {
@Override
public void executeAction(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- SC.say("Not implemented yet");
+ final Window winModal = new Window();
+ winModal.setTitle("Add Condition");
+ winModal.setShowMinimizeButton(false);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.destroy();
+ }
+ });
+ NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"),
+ conditions);
+ winModal.addItem(newConditionEditor);
+ winModal.show();
}
});
table.addTableAction(this.extendLocatorId("delete"), "Delete", SelectionEnablement.ANY, "Are you sure?",
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
new file mode 100644
index 0000000..9f39e6e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -0,0 +1,83 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.definitions;
+
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+
+import org.rhq.core.domain.alert.AlertCondition;
+import org.rhq.core.domain.alert.AlertConditionCategory;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * @author John Mazzitelli
+ */
+public class NewConditionEditor extends LocatableDynamicForm {
+
+ private HashSet<AlertCondition> conditions;
+ private SelectItem conditionTypeSelectItem;
+
+ public NewConditionEditor(String locatorId, HashSet<AlertCondition> conditions) {
+ super(locatorId);
+ this.conditions = conditions;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ conditionTypeSelectItem = new SelectItem("conditionType", "Condition Type");
+ LinkedHashMap<String, String> condTypes = new LinkedHashMap<String, String>(7);
+ condTypes.put(AlertConditionCategory.THRESHOLD.name(), "Measurement Absolute Value Threshold");
+ condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
+ condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
+ condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
+ condTypes.put(AlertConditionCategory.AVAILABILITY.name(), "Availability Change");
+ condTypes.put(AlertConditionCategory.CONTROL.name(), "Operation Execution");
+ condTypes.put(AlertConditionCategory.EVENT.name(), "Event Detection");
+ conditionTypeSelectItem.setValueMap(condTypes);
+ conditionTypeSelectItem.setDefaultValue(AlertConditionCategory.THRESHOLD.name());
+ conditionTypeSelectItem.setWrapTitle(false);
+
+ ButtonItem ok = new ButtonItem("buttonItem", "OK");
+ ok.setColSpan(2);
+ ok.setAlign(Alignment.CENTER);
+ ok.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ // TODO
+ SC.say("Not yet implemented");
+ }
+ });
+
+ setFields(conditionTypeSelectItem, ok);
+ };
+}
commit b10d84bf08e986ade3786ef53bcea64c94c11468
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 9 13:44:52 2010 -0400
more incremental coding for the conditions editor of alert def editor
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
index f19d967..c4e1844 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -23,24 +23,27 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.HashSet;
import java.util.LinkedHashMap;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.BooleanExpression;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author John Mazzitelli
*/
-public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implements EditAlertDefinitionForm {
+public class ConditionsAlertDefinitionForm extends LocatableVLayout implements EditAlertDefinitionForm {
private AlertDefinition alertDefinition;
private SelectItem conditionExpression;
+ private ConditionsEditor conditionsEditor;
private StaticTextItem conditionExpressionStatic;
@@ -81,6 +84,7 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen
clearFormValues();
} else {
conditionExpression.setValue(alertDef.getConditionExpression().name());
+ conditionsEditor.setConditions(alertDef.getConditions());
conditionExpressionStatic.setValue(alertDef.getConditionExpression().toString());
}
@@ -90,6 +94,7 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen
@Override
public void makeEditable() {
conditionExpression.show();
+ conditionsEditor.setEditable(true);
conditionExpressionStatic.hide();
markForRedraw();
@@ -98,6 +103,7 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen
@Override
public void makeViewOnly() {
conditionExpression.hide();
+ conditionsEditor.setEditable(false);
conditionExpressionStatic.show();
markForRedraw();
@@ -107,11 +113,15 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen
public void saveAlertDefinition() {
String condExpr = conditionExpression.getValue().toString();
alertDefinition.setConditionExpression(BooleanExpression.valueOf(condExpr));
+
+ HashSet<AlertCondition> conditions = conditionsEditor.getConditions();
+ alertDefinition.setConditions(conditions);
}
@Override
public void clearFormValues() {
conditionExpression.clearValue();
+ conditionsEditor.setConditions(null);
conditionExpressionStatic.clearValue();
@@ -121,6 +131,8 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen
private void buildForm() {
if (!formBuilt) {
+ LocatableDynamicForm conditionExpressionForm;
+ conditionExpressionForm = new LocatableDynamicForm(this.extendLocatorId("conditionExpressionForm"));
conditionExpression = new SelectItem("conditionExpression", "Fire alert when");
LinkedHashMap<String, String> condExprs = new LinkedHashMap<String, String>(2);
condExprs.put(BooleanExpression.ALL.name(), BooleanExpression.ALL.toString());
@@ -128,16 +140,11 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen
conditionExpression.setValueMap(condExprs);
conditionExpression.setDefaultValue(BooleanExpression.ALL.name());
conditionExpressionStatic = new StaticTextItem("conditionExpressionStatic", "Fire alert when");
+ conditionExpressionForm.setFields(conditionExpression, conditionExpressionStatic);
- ConditionsEditor conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), this);
-
- CanvasItem canvasItem = new CanvasItem("conditionsEditorCanvasItem");
- canvasItem.setCanvas(conditionsEditor);
- canvasItem.setShowTitle(false);
- canvasItem.setColSpan(2);
-
- setFields(conditionExpression, conditionExpressionStatic, canvasItem);
+ conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), null);
+ setMembers(conditionExpressionForm, conditionsEditor);
formBuilt = true;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index ddc3545..ecd93d0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -23,9 +23,13 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.HashSet;
+import java.util.Set;
+
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition;
@@ -41,12 +45,32 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class ConditionsEditor extends LocatableVLayout {
- private final ConditionsAlertDefinitionForm form;
+ private HashSet<AlertCondition> conditions;
private Table table;
- public ConditionsEditor(String locatorId, ConditionsAlertDefinitionForm form) {
+ public ConditionsEditor(String locatorId, HashSet<AlertCondition> conditions) {
super(locatorId);
- this.form = form;
+ setConditions(conditions);
+ }
+
+ /**
+ * Returns the conditions that this editor currently has in memory.
+ * This will never be <code>null</code>.
+ *
+ * @return conditions set that was possibly edited by the user
+ */
+ public HashSet<AlertCondition> getConditions() {
+ return conditions;
+ }
+
+ public void setConditions(Set<AlertCondition> set) {
+ conditions = new HashSet<AlertCondition>(); // make our own copy
+ if (set != null) {
+ conditions.addAll(set);
+ }
+ if (table != null) {
+ table.refresh();
+ }
}
@Override
@@ -55,19 +79,26 @@ public class ConditionsEditor extends LocatableVLayout {
table = new Table("conditionsTable");
table.setShowHeader(false);
- table.setDataSource(new ConditionDataSource());
+
+ final ConditionDataSource dataSource = new ConditionDataSource();
+ table.setDataSource(dataSource);
table.addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() {
@Override
public void executeAction(ListGridRecord[] selection) {
// TODO Auto-generated method stub
+ SC.say("Not implemented yet");
}
});
table.addTableAction(this.extendLocatorId("delete"), "Delete", SelectionEnablement.ANY, "Are you sure?",
new TableAction() {
@Override
public void executeAction(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
+ for (ListGridRecord record : selection) {
+ AlertCondition cond = dataSource.copyValues(record);
+ conditions.remove(cond);
+ }
+ table.refresh();
}
});
@@ -102,7 +133,7 @@ public class ConditionsEditor extends LocatableVLayout {
@Override
protected void executeFetch(DSRequest request, DSResponse response) {
- response.setData(buildRecords(ConditionsEditor.this.form.getAlertDefinition().getConditions()));
+ response.setData(buildRecords(conditions));
processResponse(request.getRequestId(), response);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 05e6c18..d06e422 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -121,6 +121,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
+ setAlertDefinition(getAlertDefinition()); // reverts data back to original
makeViewOnly();
}
});
commit 0074e60a201b6d8796f2cea440d4df3b32003c9a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 9 13:44:00 2010 -0400
avoid NPE. this can occur if calling the set-disable-override method before the table is drawn
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index d12a864..abae48f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -501,39 +501,43 @@ public class Table extends LocatableHLayout {
if (showFooter) {
int count = this.listGrid.getSelection().length;
for (TableActionInfo tableAction : tableActions) {
- boolean enabled;
- if (!this.tableActionDisableOverride) {
- switch (tableAction.enablement) {
- case ALWAYS:
- enabled = true;
- break;
- case NEVER:
+ if (tableAction.actionButton != null) { // if null, we haven't initialized our buttons yet, so skip this
+ boolean enabled;
+ if (!this.tableActionDisableOverride) {
+ switch (tableAction.enablement) {
+ case ALWAYS:
+ enabled = true;
+ break;
+ case NEVER:
+ enabled = false;
+ break;
+ case ANY:
+ enabled = (count >= 1);
+ break;
+ case SINGLE:
+ enabled = (count == 1);
+ break;
+ case MULTIPLE:
+ enabled = (count > 1);
+ break;
+ default:
+ throw new IllegalStateException("Unhandled SelectionEnablement: "
+ + tableAction.enablement.name());
+ }
+ } else {
enabled = false;
- break;
- case ANY:
- enabled = (count >= 1);
- break;
- case SINGLE:
- enabled = (count == 1);
- break;
- case MULTIPLE:
- enabled = (count > 1);
- break;
- default:
- throw new IllegalStateException("Unhandled SelectionEnablement: "
- + tableAction.enablement.name());
}
- } else {
- enabled = false;
+ tableAction.actionButton.setDisabled(!enabled);
}
- tableAction.actionButton.setDisabled(!enabled);
}
for (Canvas extraWidget : extraWidgets) {
if (extraWidget instanceof TableWidget) {
((TableWidget) extraWidget).refresh(this.listGrid);
}
}
- this.tableInfo.setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)");
+ if (this.tableInfo != null) {
+ this.tableInfo.setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)");
+ }
}
}
commit ede3762f4450a72eb47c9359b115ab5342f0d26d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 8 21:54:59 2010 -0400
keep default ids in place for just a little longer
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
index 21ef740..e4b60bc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
@@ -17,7 +17,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
*/
public class SeleniumUtility {
- private static final boolean USE_DEFAULT_IDS = false;
+ private static final boolean USE_DEFAULT_IDS = true;
/** A default id that is not ecommended as it will clash with any other element set to the default */
public static final String DEFAULT_ID = "DefaultID";
commit 3465dd5d19d96e5be1ff3569beec2b7b30e333e6
Merge: 5fc1c81... e292517...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 8 17:28:08 2010 -0400
Merge branch 'master' into master-jay
commit 5fc1c81999013914039d01d293a8dfc3eb6827fa
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 8 17:26:23 2010 -0400
A bunch of fixes to Admin/User mgmt.
- Fixes to Administration View setup/left nav/rendering
-- I believe this also fixes the issues with the "sticking" Admin
top menu and default content.
- Users list/new/delete should all be working
- removed password/verify from list view
- removed pop-up window for create in favor of straight master-detail
approach. This should be more consistent across the app, makes better
use of real-estate, and avoids an issue/possible bug with smartgwt
callbacks.
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 e0625a5..6856a55 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
@@ -257,7 +257,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
Canvas canvas;
if (breadcrumbName.equals("Administration")) {
- canvas = new AdministrationView("Administration");
+ canvas = new AdministrationView("Admin");
} else if (breadcrumbName.equals("Demo")) {
canvas = new DemoCanvas();
} else if (breadcrumbName.equals("Inventory")) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index 709d1cd..7c69fa5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -84,14 +84,15 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
treeGrids.put("Configuration", buildSystemConfigurationSection());
treeGrids.put("Cluster", buildManagementClusterSection());
treeGrids.put("Reports", buildReportsSection());
- treeGrids.put("Security", buildSecuritySection());
for (final String name : treeGrids.keySet()) {
TreeGrid grid = treeGrids.get(name);
grid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
- CoreGUI.goTo("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ if (selectionEvent.getState()) {
+ CoreGUI.goTo("Administration/" + name + "/" + selectionEvent.getRecord().getAttribute("name"));
+ }
}
});
@@ -199,8 +200,11 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
public void setContent(Canvas newContent) {
- if (contentCanvas.getChildren().length > 0)
- contentCanvas.getChildren()[0].destroy();
+ if (contentCanvas.getChildren().length > 0) {
+ for (Canvas child : contentCanvas.getChildren()) {
+ child.destroy();
+ }
+ }
contentCanvas.addChild(newContent);
contentCanvas.markForRedraw();
@@ -272,7 +276,14 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
}
}
- setContent(content);
+ // ignore clicks on subsection folder nodes
+ if (null != content) {
+ setContent(content);
+
+ if (content instanceof BookmarkableView) {
+ ((BookmarkableView) content).renderView(viewPath.next().next());
+ }
+ }
}
@@ -286,17 +297,12 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
} else {
renderContentView(viewPath);
}
- }
-
- // When looking at a detail view, always fire the event down
- if (!viewPath.isEnd()) {
-
- if (currentContent instanceof BookmarkableView) {
- ((BookmarkableView) currentContent).renderView(viewPath.next().next());
+ } else {
+ if (this.currentContent instanceof BookmarkableView) {
+ ((BookmarkableView) this.currentContent).renderView(viewPath.next().next());
}
}
-
}
private static String addQueryStringParam(String url, String param) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index 1a36bc7..bd13da7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.admin.users;
import java.util.HashSet;
import java.util.Set;
+import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
@@ -32,7 +33,6 @@ import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.SectionItem;
@@ -49,11 +49,9 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -67,7 +65,6 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
// private SubjectRolesEditorItem subjectRolesEditorItem ;
private VLayout editCanvas;
- private HeaderLabel editLabel;
private DynamicForm form;
CanvasItem roleSelectionItem;
@@ -76,7 +73,6 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
private Subject subject;
- private Window editorWindow;
private SubjectRoleSelector roleSelector;
public UserEditView(String locatorId) {
@@ -104,30 +100,12 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
SectionItem userEditSection = new SectionItem("userEditSection", "Edit User");
- // TextItem firstName = new TextItem("firstName", "First Name");
- //
- // TextItem lastName = new TextItem("lastName", "Last Name");
- //
- // TextItem email = new TextItem("email", "Email Address");
- //
- //
- // BooleanItem enabled = new BooleanItem();
- // enabled.setName("enabled");
- // enabled.setTitle("Enabled");
- //
- // TextItem username = new TextItem("username", "Username");
- //
- // TextItem phone = new TextItem("phone", "Phone");
-
- // form.setField//s(userEditSection);
-
form.setUseAllDataSourceFields(true);
form.setDataSource(dataSource);
this.roleSelectionItem = new CanvasItem("selectRoles", "Select Roles");
this.roleSelectionItem.setTitleOrientation(TitleOrientation.TOP);
this.roleSelectionItem.setColSpan(2);
- // roleSelectionItem.setCanvas(new SubjectRoleSelector(null));
TextItem departmentItem = new TextItem("department");
departmentItem.setRequired(false);
@@ -137,10 +115,6 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
if (form.validate()) {
save();
- if (editorWindow != null) {
- editorWindow.destroy();
- CoreGUI.refresh();
- }
}
}
});
@@ -155,15 +129,11 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
IButton cancelButton = new LocatableIButton(this.extendLocatorId("Cancel"), "Cancel");
cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
- if (editorWindow != null) {
- editorWindow.destroy();
- } else {
- form.reset();
- }
+ History.back();
}
});
- HLayout buttonLayout = new LocatableHLayout(this.extendLocatorId("Buttons"), 10);
+ HLayout buttonLayout = new HLayout(10);
buttonLayout.setAlign(Alignment.CENTER);
buttonLayout.addMember(saveButton);
buttonLayout.addMember(resetButton);
@@ -180,8 +150,10 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
}
- private void save() {
+ public void save() {
final HashSet<Integer> roles = roleSelector.getSelection();
+ // The form.saveData() call triggers UsersDataSource.executeAdd() to create the new Subject. On
+ // successful create we need to perform the role assignment, so set this callback on completion.
form.saveData(new DSCallback() {
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
@@ -197,11 +169,13 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to set subject role assignments.", caught);
+ History.back();
}
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
new Message("Succesfully saved new user roles.", Message.Severity.Info));
+ History.back();
}
});
@@ -210,9 +184,6 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
}
public void editRecord(Record record) {
-
- // form.getDataSource().getField("username").setCanEdit(true );
-
roleSelector = new SubjectRoleSelector(this.extendLocatorId("Roles"), (Set<Role>) record
.getAttributeAsObject("roles"));
roleSelectionItem.setCanvas(roleSelector);
@@ -239,50 +210,48 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
subject = new Subject();
ListGridRecord r = dataSource.copyValues(subject);
editRecord(r);
- // form.getDataSource().getField("username").setCanEdit(false);
- form.setSaveOperationType(DSOperationType.ADD);
-
- editorWindow = new Window();
- editorWindow.setTitle("Create User");
- editorWindow.setWidth(800);
- editorWindow.setHeight(800);
- editorWindow.setIsModal(true);
- editorWindow.setShowModalMask(true);
- editorWindow.setCanDragResize(true);
- editorWindow.centerInPage();
- editorWindow.addItem(this);
- editorWindow.show();
+ // This tells form.saveData() to call UsersDataSource.executeAdd() on the new Subject's ListGridRecord
+ form.setSaveOperationType(DSOperationType.ADD);
}
public static void editNew(String locatorId) {
UserEditView editView = new UserEditView(locatorId);
editView.editNewInternal();
-
}
private void editSubject(int subjectId, final ViewId current) {
- SubjectCriteria criteria = new SubjectCriteria();
- criteria.fetchRoles(true);
- criteria.fetchConfiguration(true);
+ final int id = Integer.valueOf(current.getBreadcrumbs().get(0).getName());
- GWTServiceLookup.getSubjectService().findSubjectsByCriteria(criteria, new AsyncCallback<PageList<Subject>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load subject for editing", caught);
- }
+ if (id > 0) {
+ SubjectCriteria criteria = new SubjectCriteria();
+ criteria.addFilterId(id);
+ criteria.fetchRoles(true);
+ criteria.fetchConfiguration(true);
- @Override
- public void onSuccess(PageList<Subject> result) {
- Subject subject = result.get(0);
- Record record = new UsersDataSource().copyValues(subject);
- editRecord(record);
+ GWTServiceLookup.getSubjectService().findSubjectsByCriteria(criteria,
+ new AsyncCallback<PageList<Subject>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load subject for editing", caught);
+ }
- current.getBreadcrumbs().get(0).setDisplayName("Editing: " + subject.getName());
- CoreGUI.refreshBreadCrumbTrail();
- }
- });
+ @Override
+ public void onSuccess(PageList<Subject> result) {
+ Subject subject = result.get(0);
+ Record record = new UsersDataSource().copyValues(subject);
+ editRecord(record);
+
+ current.getBreadcrumbs().get(0).setDisplayName("Editing: " + subject.getName());
+ CoreGUI.refreshBreadCrumbTrail();
+ }
+ });
+ } else {
+ editNewInternal();
+ current.getBreadcrumbs().get(0).setDisplayName("New User");
+ CoreGUI.refreshBreadCrumbTrail();
+ }
}
@Override
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 578d2b6..809edec 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
@@ -18,26 +18,15 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin.users;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.authz.Role;
-import org.rhq.core.domain.criteria.SubjectCriteria;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.FieldValueExtractor;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -48,9 +37,15 @@ import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.form.validator.MatchesFieldValidator;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.criteria.SubjectCriteria;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/**
* @author Greg Hinkle
@@ -61,7 +56,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
private SubjectGWTServiceAsync subjectService = GWTServiceLookup.getSubjectService();
-
public static UsersDataSource getInstance() {
if (INSTANCE == null) {
INSTANCE = new UsersDataSource();
@@ -69,9 +63,8 @@ public class UsersDataSource extends RPCDataSource<Subject> {
return INSTANCE;
}
+ public UsersDataSource() {
- public UsersDataSource() {
-
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
@@ -90,7 +83,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
passwordValdidator.setErrorMessage("Password must be at least six characters");
password.setValidators(passwordValdidator);
-
DataSourceTextField passwordVerify = new DataSourceTextField("passwordVerify", "Verify", 100, false);
passwordVerify.setType(FieldType.PASSWORD);
@@ -99,10 +91,9 @@ public class UsersDataSource extends RPCDataSource<Subject> {
passwordsEqualValidator.setErrorMessage("Passwords do not match");
passwordVerify.setValidators(passwordsEqualValidator);
-
DataSourceTextField emailAddress = new DataSourceTextField("emailAddress", "Email Address", 100, true);
- DataSourceTextField phone = new DataSourceTextField("phoneNumber", "Phone", 15, false);
+ DataSourceTextField phone = new DataSourceTextField("phoneNumber", "Phone", 15, false);
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
@@ -111,11 +102,10 @@ public class UsersDataSource extends RPCDataSource<Subject> {
roles.setName("roles");
roles.setMultiple(true);
-
- setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress, department);
+ setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress,
+ department);
}
-
public void executeFetch(final DSRequest request, final DSResponse response) {
final long start = System.currentTimeMillis();
@@ -141,13 +131,12 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
response.setData(records);
- response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
processResponse(request.getRequestId(), response);
}
});
}
-
@Override
protected void executeAdd(final DSRequest request, final DSResponse response) {
JavaScriptObject data = request.getData();
@@ -160,7 +149,7 @@ public class UsersDataSource extends RPCDataSource<Subject> {
Map<String, String> errors = new HashMap<String, String>();
errors.put("name", "A user with this name already exists.");
response.setErrors(errors);
-// CoreGUI.getErrorHandler().handleError("Failed to create role",caught);
+ // CoreGUI.getErrorHandler().handleError("Failed to create role",caught);
response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR);
processResponse(request.getRequestId(), response);
}
@@ -169,12 +158,14 @@ public class UsersDataSource extends RPCDataSource<Subject> {
String password = rec.getAttribute("password");
subjectService.createPrincipal(newSubject.getName(), password, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Subject created, but failed to create principal",caught);
+ CoreGUI.getErrorHandler()
+ .handleError("Subject created, but failed to create principal", caught);
}
public void onSuccess(Void nothing) {
- CoreGUI.getMessageCenter().notify(new Message("Created User [" + newSubject.getName() + "]", Message.Severity.Info));
- response.setData(new Record[]{copyValues(result)});
+ CoreGUI.getMessageCenter().notify(
+ new Message("Created User [" + newSubject.getName() + "]", Message.Severity.Info));
+ response.setData(new Record[] { copyValues(result) });
processResponse(request.getRequestId(), response);
}
});
@@ -203,16 +194,18 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
public void onSuccess(Void nothing) {
- CoreGUI.getMessageCenter().notify(new Message("User updated and password changed", Message.Severity.Info));
- response.setData(new Record[]{copyValues(result)});
+ CoreGUI.getMessageCenter().notify(
+ new Message("User updated and password changed", Message.Severity.Info));
+ response.setData(new Record[] { copyValues(result) });
processResponse(request.getRequestId(), response);
}
});
} else {
System.out.println("Subject Updated");
- CoreGUI.getMessageCenter().notify(new Message("User [" + result.getName() + "] updated", Message.Severity.Info));
- response.setData(new Record[]{copyValues(result)});
+ CoreGUI.getMessageCenter().notify(
+ new Message("User [" + result.getName() + "] updated", Message.Severity.Info));
+ response.setData(new Record[] { copyValues(result) });
processResponse(request.getRequestId(), response);
}
}
@@ -225,21 +218,21 @@ public class UsersDataSource extends RPCDataSource<Subject> {
final ListGridRecord rec = new ListGridRecord(data);
final Subject subjectToDelete = copyValues(rec);
- subjectService.deleteSubjects(new int[]{subjectToDelete.getId()}, new AsyncCallback<Void>() {
+ subjectService.deleteSubjects(new int[] { subjectToDelete.getId() }, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Failed to delete role", caught);
}
public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(new Message("User [" + subjectToDelete.getName() + "] removed", Message.Severity.Info));
- response.setData(new Record[]{rec});
+ CoreGUI.getMessageCenter().notify(
+ new Message("User [" + subjectToDelete.getName() + "] removed", Message.Severity.Info));
+ response.setData(new Record[] { rec });
processResponse(request.getRequestId(), response);
}
});
}
-
public Subject copyValues(ListGridRecord from) {
Subject to = new Subject();
to.setId(from.getAttributeAsInt("id"));
@@ -272,7 +265,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
return to;
}
-
private ListGridRecord getEditedRecord(DSRequest request) {
// Retrieving values before edit
JavaScriptObject oldValues = request.getAttributeAsJavaScriptObject("oldValues");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index aa0cf64..72e2aa7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.users;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
@@ -41,31 +42,28 @@ public class UsersView extends TableSection {
@Override
protected void configureTable() {
- getListGrid().getField("id").setWidth(55);
- getListGrid().getField("name").setWidth(100);
+ final ListGrid grid = getListGrid();
+ grid.getField("id").setWidth(20);
+ grid.getField("name").setWidth(100);
+ grid.hideField("password");
+ grid.hideField("passwordVerify");
addTableAction(extendLocatorId("Delete"), "Delete", Table.SelectionEnablement.ANY,
"Are you sure you want to delete # users?", new TableAction() {
public void executeAction(ListGridRecord[] selection) {
- getListGrid().removeSelectedData();
+ grid.removeSelectedData();
}
});
addTableAction(extendLocatorId("New"), "New", new TableAction() {
public void executeAction(ListGridRecord[] selection) {
- createUser();
+ newDetails();
}
});
}
- public void createUser() {
- UserEditView editView = new UserEditView(extendLocatorId("Edit"));
- editView.editNewInternal();
- }
-
public Canvas getDetailsView(int id) {
final UserEditView userEditor = new UserEditView(extendLocatorId("Detail"));
-
return userEditor;
}
}
commit fa6ab36ec6ff7be045d84e99e72860c3a97d40f3
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 8 17:19:16 2010 -0400
Add newDetails() to TableSection. This complements showDetails(id) and
should be called instead of showDetails(0) when wanting an empty form for
creating a new entity.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 126c672..7cf7226 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -63,7 +63,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
protected void newButtonPressed(ListGridRecord[] selection) {
- showDetails(0);
+ newDetails();
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index 01a19f3..44746c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -146,17 +146,35 @@ public abstract class TableSection extends Table implements BookmarkableView {
}
/**
- * Shows the details for an item has the given ID. Note that an empty
- * details view will be shown if the id passed in is 0.
+ * Shows empty details for a new item being created.
+ * This method is usually called when a user clicks a 'New' button.
+ *
+ * @see #showDetails(ListGridRecord)
+ */
+ public void newDetails() {
+ History.newItem(basePath + "/0");
+ }
+
+ /**
+ * Shows the details for an item has the given ID.
* This method is usually called when a user goes to the details
- * page via a bookmark or direct link.
+ * page via a bookmark, double-cick on a list view row, or direct link.
*
- * @param id the id of the row whose details are to be shown; pass in 0 to show empty details
+ * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
*
* @see #showDetails(ListGridRecord)
+ *
+ * @throws IllegalArgumentException if id <= 0.
*/
public void showDetails(int id) {
- History.newItem(basePath + "/" + id);
+ if (id > 0) {
+ History.newItem(basePath + "/" + id);
+ } else {
+ String msg = "Can not show detail for [" + this.getClass() + "]. Illegal 'id': " + id
+ + " Please report this bug";
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
}
/**
@@ -232,9 +250,8 @@ public abstract class TableSection extends Table implements BookmarkableView {
detailsHolder.animateHide(AnimationEffect.FADE, new AnimationCallback() {
@Override
public void execute(boolean b) {
- // TODO: Implement this method.
for (Canvas child : detailsHolder.getMembers()) {
- detailsHolder.removeMember(child);
+ child.destroy();
}
contents.animateShow(AnimationEffect.FADE);
commit bfc20948d695463b215f247339cf0c9568a151b9
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 8 17:16:33 2010 -0400
removed 'Preferences' from top menu. Currently this may not be needed at all,
but even if it is it wil likely be integrated into either user mgmt or
possibly even more fine-grained use, like specific to a group config
update.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
index 8e51dd9..dc5503f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/MenuBarView.java
@@ -89,7 +89,6 @@ public class MenuBarView extends VLayout {
// loggedInAs.setValign(VerticalAlignment.CENTER);
// helpLayout.addMember(loggedInAs);
topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Help", "Help")));
- topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Preferences", "Preferences")));
topStrip.addMember(SeleniumUtility.setHtmlId(new Hyperlink("Log Out", "LogOut")));
// helpLayout.setLayoutAlign(VerticalAlignment.CENTER);
// topStrip.addMember(helpLayout);
commit 818b8aa88257a97541c8f97f1a167aa7f99c319a
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Sep 8 17:15:00 2010 -0400
Selenium Work - It seems that in certain scenarios a DSCallback can't
locate an element with a '-' in the id attribute. The dash seems to be used
as a delimiter, this may be a bug in smartgwt. Anyway, changing all use of
'-' in locatorIds to '_'.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index ef0c74d..a8472b8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -455,7 +455,7 @@ public class ConfigurationEditor extends LocatableVLayout {
.getNonGroupedProperties() : definition.getPropertiesInGroup(group.getName())));
Collections.sort(definitions, new PropertyDefinitionComparator());
- DynamicForm form = buildPropertiesForm(locatorId + "-Props", definitions, configuration);
+ DynamicForm form = buildPropertiesForm(locatorId + "_Props", definitions, configuration);
section.addItem(form);
return section;
@@ -493,7 +493,7 @@ public class ConfigurationEditor extends LocatableVLayout {
propertyMap.put(property);
}
}
- addItems(locatorId + "-" + propertyDefinition.getName(), fields, propertyDefinition, property, odd);
+ addItems(locatorId + "_" + propertyDefinition.getName(), fields, propertyDefinition, property, odd);
odd = !odd;
}
@@ -635,7 +635,7 @@ public class ConfigurationEditor extends LocatableVLayout {
editField.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(RecordClickEvent recordClickEvent) {
System.out.println("You want to edit: " + recordClickEvent.getRecord());
- displayMapEditor(locatorId + "-MapEdit", summaryTable, recordClickEvent.getRecord(),
+ displayMapEditor(locatorId + "_MapEdit", summaryTable, recordClickEvent.getRecord(),
propertyDefinition, propertyList, (PropertyMap) recordClickEvent.getRecord().getAttributeAsObject(
"_RHQ_PROPERTY"));
}
@@ -684,7 +684,7 @@ public class ConfigurationEditor extends LocatableVLayout {
addRowButton.setIcon(Window.getImgURL("[SKIN]/actions/add.png"));
addRowButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- displayMapEditor(locatorId + "-MapEdit", summaryTable, null, propertyDefinition, propertyList, null);
+ displayMapEditor(locatorId + "_MapEdit", summaryTable, null, propertyDefinition, propertyList, null);
}
});
@@ -917,7 +917,7 @@ public class ConfigurationEditor extends LocatableVLayout {
LocatableVLayout layout = new LocatableVLayout(locatorId);
layout.setHeight100();
- DynamicForm childForm = buildPropertiesForm(locatorId + "-Child", definitions, finalMap);
+ DynamicForm childForm = buildPropertiesForm(locatorId + "_Child", definitions, finalMap);
childForm.setHeight100();
layout.addMember(childForm);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java
index 6c0481d..bd9d966 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java
@@ -5,7 +5,7 @@ public interface Locatable {
/**
* Returns the locatorId. This can be useful for constructing more granular locatorIds. For example, if
* the widget contains sub-widgets. Note, this is the raw locatorId for the widget, to get the fully
- * formed ID, typically ofthe form "simpleClassname-locatorId" Call {@link getID()}.
+ * formed ID, typically ofthe form "simpleClassname_locatorId" Call {@link getID()}.
*
* @return the locatorId
*/
@@ -15,7 +15,7 @@ public interface Locatable {
* Extends this widget's original locatorId with an extension. This can be useful for constructing more
* granular locatorIds. For example, if the widget contains sub-widgets.
* <pre>
- * ID Format: "getLocatorId()-extension"
+ * ID Format: "getLocatorId()_extension"
* </pre>
*
* @param extension not null or empty.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java
index a6dd2ca..5219934 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableButton.java
@@ -11,7 +11,7 @@ public class LocatableButton extends Button {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java
index b923b1c..39e4772 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDialog.java
@@ -13,7 +13,7 @@ public class LocatableDialog extends Dialog implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null.
*/
@@ -28,6 +28,6 @@ public class LocatableDialog extends Dialog implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java
index a29789c..1fb565c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableDynamicForm.java
@@ -13,7 +13,7 @@ public class LocatableDynamicForm extends DynamicForm implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -28,7 +28,7 @@ public class LocatableDynamicForm extends DynamicForm implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
index 25f8216..5b3e09e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHLayout.java
@@ -13,7 +13,7 @@ public class LocatableHLayout extends HLayout implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -24,7 +24,7 @@ public class LocatableHLayout extends HLayout implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
* @param membersMargin
@@ -44,7 +44,7 @@ public class LocatableHLayout extends HLayout implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java
index 653190c..a8e758e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHTMLPane.java
@@ -13,7 +13,7 @@ public class LocatableHTMLPane extends HTMLPane implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -28,7 +28,7 @@ public class LocatableHTMLPane extends HTMLPane implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java
index 83e2443..b30f134 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableHeaderControl.java
@@ -14,7 +14,7 @@ public class LocatableHeaderControl extends HeaderControl implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
* @param icon
@@ -26,7 +26,7 @@ public class LocatableHeaderControl extends HeaderControl implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
* @param icon
@@ -47,7 +47,7 @@ public class LocatableHeaderControl extends HeaderControl implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java
index 72ce93b..f265697 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java
@@ -11,7 +11,7 @@ public class LocatableIButton extends IButton {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java
index e3b2eae..7734c3b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIMenuButton.java
@@ -14,7 +14,7 @@ public class LocatableIMenuButton extends IMenuButton implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -25,7 +25,7 @@ public class LocatableIMenuButton extends IMenuButton implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -44,6 +44,6 @@ public class LocatableIMenuButton extends IMenuButton implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java
index 8317ff5..c0dc681 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableImg.java
@@ -11,7 +11,7 @@ public class LocatableImg extends Img {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null.
* @param img not null or empty.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java
index bd7ab1f..3b06238 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLabel.java
@@ -13,7 +13,7 @@ public class LocatableLabel extends Label implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -24,7 +24,7 @@ public class LocatableLabel extends Label implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -43,7 +43,7 @@ public class LocatableLabel extends Label implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
index e14a421..7a2e99b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableLayout.java
@@ -13,7 +13,7 @@ public class LocatableLayout extends Layout implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -28,7 +28,7 @@ public class LocatableLayout extends Layout implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java
index 458a97a..87ed4b7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java
@@ -13,7 +13,7 @@ public class LocatableListGrid extends ListGrid implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -28,6 +28,6 @@ public class LocatableListGrid extends ListGrid implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java
index 424f64d..827ba2a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableMenu.java
@@ -13,7 +13,7 @@ public class LocatableMenu extends Menu implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -32,7 +32,7 @@ public class LocatableMenu extends Menu implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java
index 33e2b9e..62fb4ac 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableSectionStack.java
@@ -13,7 +13,7 @@ public class LocatableSectionStack extends SectionStack implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -28,7 +28,7 @@ public class LocatableSectionStack extends SectionStack implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java
index 6b2b379..ba1435f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableStretchImgButton.java
@@ -11,7 +11,7 @@ public class LocatableStretchImgButton extends StretchImgButton {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null.
* @param img not null or empty.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java
index 9932a65..197a1be 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTab.java
@@ -31,7 +31,7 @@ public class LocatableTab extends Tab implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -64,7 +64,7 @@ public class LocatableTab extends Tab implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java
index e290758..4ba995c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTabSet.java
@@ -31,7 +31,7 @@ public class LocatableTabSet extends TabSet {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -44,7 +44,7 @@ public class LocatableTabSet extends TabSet {
/**
* Returns the locatorId. This can be useful for constructing more granular locatorIds. For example, if
* the widget contains sub-widgets. Note, this is the raw locatorId for the widget, to get the fully
- * formed ID, typically ofthe form "simpleClassname-locatorId" Call {@link getID()}.
+ * formed ID, typically ofthe form "simpleClassname_locatorId" Call {@link getID()}.
*
* @return the locatorId
*/
@@ -56,7 +56,7 @@ public class LocatableTabSet extends TabSet {
* Extends this widget's original locatorId with an extension. This can be useful for constructing more
* granular locatorIds. For example, if the widget contains sub-widgets.
* <pre>
- * ID Format: "getLocatorId()-extension"
+ * ID Format: "getLocatorId()_extension"
* </pre>
*
* @param extension not null or empty.
@@ -64,7 +64,7 @@ public class LocatableTabSet extends TabSet {
* @return the new, extended locatorId
*/
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java
index b93bfe8..c6308a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTileLayout.java
@@ -13,7 +13,7 @@ public class LocatableTileLayout extends TileLayout implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -28,7 +28,7 @@ public class LocatableTileLayout extends TileLayout implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java
index 7f1dfb7..fa24d45 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableToolStrip.java
@@ -13,7 +13,7 @@ public class LocatableToolStrip extends ToolStrip implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -28,7 +28,7 @@ public class LocatableToolStrip extends ToolStrip implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
index 58d11f7..e255096 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
@@ -21,7 +21,7 @@ public class LocatableTransferImgButton extends TransferImgButton {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null.
* @param img not null or empty.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java
index 39e4afa..c4d6a87 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTreeGrid.java
@@ -13,7 +13,7 @@ public class LocatableTreeGrid extends TreeGrid implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null.
*/
@@ -28,6 +28,6 @@ public class LocatableTreeGrid extends TreeGrid implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
index e396236..0a9b00e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
@@ -13,7 +13,7 @@ public class LocatableVLayout extends VLayout implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -24,7 +24,7 @@ public class LocatableVLayout extends VLayout implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
* @param membersMargin
@@ -44,7 +44,7 @@ public class LocatableVLayout extends VLayout implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
public void destroyMembers() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java
index 66792a2..90324df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWidgetCanvas.java
@@ -14,7 +14,7 @@ public class LocatableWidgetCanvas extends WidgetCanvas implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -33,7 +33,7 @@ public class LocatableWidgetCanvas extends WidgetCanvas implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java
index 87c6b22..56f34bd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableWindow.java
@@ -13,7 +13,7 @@ public class LocatableWindow extends Window implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
*/
@@ -32,7 +32,7 @@ public class LocatableWindow extends Window implements Locatable {
}
public String extendLocatorId(String extension) {
- return this.locatorId + "-" + extension;
+ return this.locatorId + "_" + extension;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
index 43678f0..21ef740 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/SeleniumUtility.java
@@ -17,7 +17,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
*/
public class SeleniumUtility {
- private static final boolean USE_DEFAULT_IDS = true;
+ private static final boolean USE_DEFAULT_IDS = false;
/** A default id that is not ecommended as it will clash with any other element set to the default */
public static final String DEFAULT_ID = "DefaultID";
@@ -25,7 +25,7 @@ public class SeleniumUtility {
/**
* A utility for assigning an ID to a smartgwt widget. Any current ID will be overwritten. The algorithm is:
* <pre>
- * ID Format: "simpleClassname-locatorId"
+ * ID Format: "simpleClassname_locatorId"
* </pre>
* @return the updated widget
*/
@@ -34,7 +34,7 @@ public class SeleniumUtility {
return widget;
}
- String unsafeId = getSimpleClassName(widget) + "-" + locatorId;
+ String unsafeId = getSimpleClassName(widget) + "_" + locatorId;
String safeId = SeleniumUtility.getSafeId(unsafeId, DEFAULT_ID);
Canvas canvasWithId = Canvas.getById(safeId);
if (null != canvasWithId) {
@@ -127,6 +127,7 @@ public class SeleniumUtility {
* <pre>
* - removes spaces
* - removes dots
+ * - converts '-' to '_'
* </pre>
* @param unsafeId The desired Id but with potential problems
* @param defaultId
@@ -137,7 +138,7 @@ public class SeleniumUtility {
return defaultId;
}
- String safeId = unsafeId.replace(" ", "").replace(".", "");
+ String safeId = unsafeId.replace(" ", "").replace(".", "").replace("-", "_");
return safeId;
}
commit e292517b3189ed60c6b38cdab023d6fec7dd9098
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 8 17:01:50 2010 -0400
initial start of the conditions tab for alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
index 201360b..f19d967 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.LinkedHashMap;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
@@ -128,7 +129,14 @@ public class ConditionsAlertDefinitionForm extends LocatableDynamicForm implemen
conditionExpression.setDefaultValue(BooleanExpression.ALL.name());
conditionExpressionStatic = new StaticTextItem("conditionExpressionStatic", "Fire alert when");
- setFields(conditionExpression, conditionExpressionStatic);
+ ConditionsEditor conditionsEditor = new ConditionsEditor(this.extendLocatorId("conditionsEditor"), this);
+
+ CanvasItem canvasItem = new CanvasItem("conditionsEditorCanvasItem");
+ canvasItem.setCanvas(conditionsEditor);
+ canvasItem.setShowTitle(false);
+ canvasItem.setColSpan(2);
+
+ setFields(conditionExpression, conditionExpressionStatic, canvasItem);
formBuilt = true;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
new file mode 100644
index 0000000..ddc3545
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -0,0 +1,109 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.definitions;
+
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.alert.AlertCondition;
+import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ConditionsEditor extends LocatableVLayout {
+
+ private final ConditionsAlertDefinitionForm form;
+ private Table table;
+
+ public ConditionsEditor(String locatorId, ConditionsAlertDefinitionForm form) {
+ super(locatorId);
+ this.form = form;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ table = new Table("conditionsTable");
+ table.setShowHeader(false);
+ table.setDataSource(new ConditionDataSource());
+
+ table.addTableAction(this.extendLocatorId("add"), "Add", SelectionEnablement.ALWAYS, null, new TableAction() {
+ @Override
+ public void executeAction(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ }
+ });
+ table.addTableAction(this.extendLocatorId("delete"), "Delete", SelectionEnablement.ANY, "Are you sure?",
+ new TableAction() {
+ @Override
+ public void executeAction(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ }
+ });
+
+ addMember(table);
+ }
+
+ public void setEditable(boolean editable) {
+ table.setTableActionDisableOverride(!editable);
+ }
+
+ private class ConditionDataSource extends RPCDataSource<AlertCondition> {
+ private static final String FIELD_OBJECT = "obj";
+ private static final String FIELD_CONDITION = "condition";
+
+ public ConditionDataSource() {
+ DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION, "Condition");
+ addField(conditionField);
+ }
+
+ @Override
+ public AlertCondition copyValues(ListGridRecord from) {
+ return (AlertCondition) from.getAttributeAsObject(FIELD_OBJECT);
+ }
+
+ @Override
+ public ListGridRecord copyValues(AlertCondition from) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(FIELD_CONDITION, AlertFormatUtility.formatAlertConditionForDisplay(from));
+ record.setAttribute(FIELD_OBJECT, from);
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(DSRequest request, DSResponse response) {
+ response.setData(buildRecords(ConditionsEditor.this.form.getAlertDefinition().getConditions()));
+ processResponse(request.getRequestId(), response);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index ac7b789..dc04a1e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -97,6 +97,8 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.fetchGroupAlertDefinition(true);
+ criteria.fetchConditions(true);
+ criteria.fetchAlertNotifications(true);
Criteria requestCriteria = request.getCriteria();
if (requestCriteria != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 90b448f..d12a864 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -120,6 +120,7 @@ public class Table extends LocatableHLayout {
;
private List<TableActionInfo> tableActions = new ArrayList<TableActionInfo>();
+ private boolean tableActionDisableOverride = false;
private List<Canvas> extraWidgets = new ArrayList<Canvas>();
public Table(String locatorId) {
@@ -476,29 +477,54 @@ public class Table extends LocatableHLayout {
this.headerIcons.add(headerIcon);
}
+ /**
+ * By default, all table actions have buttons that are enabled or
+ * disabled based on if and how many rows are selected. There are
+ * times when you don't want the user to be able to press table action
+ * buttons regardless of which rows are selected. This method let's
+ * you set this override-disable flag.
+ *
+ * @param disabled if true, all table action buttons will be disabled
+ * if false, table action buttons will be enabled based on their predefined
+ * selection enablement rule.
+ */
+ public void setTableActionDisableOverride(boolean disabled) {
+ this.tableActionDisableOverride = disabled;
+ refreshTableInfo();
+ }
+
+ public boolean getTableActionDisableOverride() {
+ return this.tableActionDisableOverride;
+ }
+
protected void refreshTableInfo() {
if (showFooter) {
int count = this.listGrid.getSelection().length;
for (TableActionInfo tableAction : tableActions) {
boolean enabled;
- switch (tableAction.enablement) {
- case ALWAYS:
- enabled = true;
- break;
- case NEVER:
+ if (!this.tableActionDisableOverride) {
+ switch (tableAction.enablement) {
+ case ALWAYS:
+ enabled = true;
+ break;
+ case NEVER:
+ enabled = false;
+ break;
+ case ANY:
+ enabled = (count >= 1);
+ break;
+ case SINGLE:
+ enabled = (count == 1);
+ break;
+ case MULTIPLE:
+ enabled = (count > 1);
+ break;
+ default:
+ throw new IllegalStateException("Unhandled SelectionEnablement: "
+ + tableAction.enablement.name());
+ }
+ } else {
enabled = false;
- break;
- case ANY:
- enabled = (count >= 1);
- break;
- case SINGLE:
- enabled = (count == 1);
- break;
- case MULTIPLE:
- enabled = (count > 1);
- break;
- default:
- throw new IllegalStateException("Unhandled SelectionEnablement: " + tableAction.enablement.name());
}
tableAction.actionButton.setDisabled(!enabled);
}
commit 116b730cb2cd65086374eccb0d74904abef053cb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 8 16:59:25 2010 -0400
fix NPE - make sure targetUnits is not null before checking to see if its family is RELATIVE
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java
index f78b62c..f084ec0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/core/domain/measurement/MeasurementConverterClient.java
@@ -1,47 +1,46 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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.domain.measurement;
-
- import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits;
- import org.rhq.core.domain.measurement.util.MeasurementConversionException;
-
- import com.google.gwt.i18n.client.NumberFormat;
-
- import java.util.HashSet;
- import java.util.Set;
-
- public class MeasurementConverterClient {
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.domain.measurement;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.gwt.i18n.client.NumberFormat;
+
+import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits;
+import org.rhq.core.domain.measurement.util.MeasurementConversionException;
+
+public class MeasurementConverterClient {
private static final int MAX_PRECISION_DIGITS = 4;
private static final String NULL_OR_NAN_FORMATTED_VALUE = "--no data available--";
-
private static NumberFormat getDefaultNumberFormat() {
NumberFormat nf = NumberFormat.getFormat("0.0");
return nf;
}
- public static Double scale(MeasurementNumericValueAndUnits origin, MeasurementUnits targetUnits)
+ public static Double scale(MeasurementNumericValueAndUnits origin, MeasurementUnits targetUnits)
throws MeasurementConversionException {
MeasurementUnits originUnits = origin.getUnits();
Double originValue = origin.getValue();
@@ -201,7 +200,7 @@
}
public static String format(Double value, MeasurementUnits targetUnits, boolean bestFit,
- Integer minimumFractionDigits, Integer maximumFractionDigits) {
+ Integer minimumFractionDigits, Integer maximumFractionDigits) {
if (value == null || Double.isNaN(value)) {
return NULL_OR_NAN_FORMATTED_VALUE;
}
@@ -213,15 +212,13 @@
}
// apply relative scale at presentation time
- if (MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) {
+ if (targetUnits != null && MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) {
value = MeasurementUnits.scaleUp(value, targetUnits);
}
- NumberFormat numberFormat =
- NumberFormat.getFormat(
- getFormat(
- minimumFractionDigits != null ? minimumFractionDigits : 1,
- maximumFractionDigits != null ? maximumFractionDigits : 1));
+ NumberFormat numberFormat = NumberFormat.getFormat(getFormat(
+ minimumFractionDigits != null ? minimumFractionDigits : 1,
+ maximumFractionDigits != null ? maximumFractionDigits : 1));
String formatted = numberFormat.format(value);
@@ -273,7 +270,7 @@
if (MeasurementUnits.Family.RELATIVE == units.getFamily()) {
return new MeasurementNumericValueAndUnits(origin, units);
}
-
+
if (MeasurementUnits.Family.TEMPERATURE == units.getFamily()) {
return new MeasurementNumericValueAndUnits(origin, units);
}
@@ -347,14 +344,14 @@
return currentValueAndUnits;
}
- public static String getFormat(int minDigits, int maxDigits) {
- StringBuilder buf = new StringBuilder("0.");
- for (int i = 0; i < minDigits;i++) {
- buf.append("0");
- }
- for (int i = 0; i < (maxDigits-minDigits);i++) {
- buf.append("#");
- }
- return buf.toString();
- }
+ public static String getFormat(int minDigits, int maxDigits) {
+ StringBuilder buf = new StringBuilder("0.");
+ for (int i = 0; i < minDigits; i++) {
+ buf.append("0");
+ }
+ for (int i = 0; i < (maxDigits - minDigits); i++) {
+ buf.append("#");
+ }
+ return buf.toString();
+ }
}
commit bcf70dce12b481f4f0876a9d87eb3f7781df9497
Merge: ce3f841... 256cc0e...
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Sep 8 13:38:17 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 256cc0e5624dcb2c1c656057924590126e37e5ff
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Sep 8 17:27:50 2010 -0400
refresh/config for portlets i)auto discovery ii)recently added.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index 0356212..ad0895b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -18,29 +18,58 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue;
+import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.BlurbItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
* @author Greg Hinkle
*/
-public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements Portlet {
+public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements CustomSettingsPortlet {
public static final String KEY = "Discovery Queue";
+ private static final String AUTODISCOVERY_PLATFORM_MAX = "auto-discovery-platform-max";
+ private String unlimited = "unlimited";
+ private String defaultValue = unlimited;
+ private DashboardPortlet storedPortlet;
+ private int maximumPlatformsToDisplay = -1;
public AutodiscoveryPortlet(String locatorId) {
super(locatorId, true);
}
+ /** Implement configure action.
+ */
+ @Override
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
- // TODO: Implement this method.
+ this.storedPortlet = storedPortlet;
+ if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) != null) {
+ //retrieve and translate to int
+ String retrieved = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
+ if (retrieved.equals(unlimited)) {
+ maximumPlatformsToDisplay = -1;
+ } else {
+ maximumPlatformsToDisplay = Integer.parseInt(retrieved);
+ }
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
+ }
}
public Canvas getHelpCanvas() {
@@ -48,8 +77,73 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements P
+ "for monitoring and management or to ingnore them from further action.");
}
+ /** Build custom for to dispaly the Portlet Configuration settings.
+ *
+ */
public DynamicForm getCustomSettingsForm() {
- return null; // TODO: Implement this method.
+
+ final DynamicForm form = new DynamicForm();
+ form.setLayoutAlign(VerticalAlignment.CENTER);
+
+ //horizontal display component
+ LocatableHLayout row = new LocatableHLayout("auto-discovery.configuration");
+ BlurbItem label = new BlurbItem("discovery-platform-count-label");
+ label.setValue("Maximum Platforms to show");
+
+ //-------------combobox for number of platforms to display on the dashboard
+ final SelectItem maximumPlatformsComboBox = new SelectItem(AUTODISCOVERY_PLATFORM_MAX);
+ maximumPlatformsComboBox.setTitle("");
+ //spinder 9/3/10: the following is required workaround to disable editability of combobox.
+ maximumPlatformsComboBox.setType("selection");
+ //define acceptable values for display amount
+ String[] acceptableDisplayValues = { "1", "2", "5", "10", unlimited };
+ maximumPlatformsComboBox.setValueMap(acceptableDisplayValues);
+ //set width of dropdown display region
+ maximumPlatformsComboBox.setWidth(100);
+ maximumPlatformsComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(AUTODISCOVERY_PLATFORM_MAX, selectedItem);
+ }
+ });
+
+ //wrap field item in dynamicform for addition as a field item
+ DynamicForm item = new DynamicForm();
+ item.setFields(label);
+
+ row.addMember(item);
+ DynamicForm item2 = new DynamicForm();
+ item2.setFields(maximumPlatformsComboBox);
+ row.addMember(item2);
+
+ //default selected value to 'unlimited'(live lists) and check both combobox settings here.
+ String selectedValue = defaultValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX) != null) {
+ selectedValue = storedPortlet.getConfiguration().getSimple(AUTODISCOVERY_PLATFORM_MAX).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, defaultValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ maximumPlatformsComboBox.setDefaultValue(selectedValue);
+
+ form.addChild(row);
+
+ //submit handler
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ if (form.getValue(AUTODISCOVERY_PLATFORM_MAX) != null) {
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(AUTODISCOVERY_PLATFORM_MAX, form.getValue(AUTODISCOVERY_PLATFORM_MAX)));
+ }
+ }
+ });
+
+ return form;
}
public static final class Factory implements PortletViewFactory {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
index 3a551eb..655596b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedView.java
@@ -26,32 +26,49 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.tree.TreeGrid;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-public class RecentlyAddedView extends LocatableVLayout implements Portlet {
+public class RecentlyAddedView extends LocatableVLayout implements CustomSettingsPortlet {
public static final String KEY = "Recently Added Portlet";
private boolean simple = true;
+ private DashboardPortlet storedPortlet;
+ public static final String unlimited = "unlimited";
+ public static final String defaultValue = unlimited;
+
+ private static final String RECENTLY_ADDED_SHOW_MAX = "recently-added-show-amount";
+
+ private static final String RECENTLY_ADDED_SHOW_HRS = "recently-added-time-range";
public RecentlyAddedView(String locatorId) {
super(locatorId);
}
+ private TreeGrid treeGrid = null;
+
+ private int maximumRecentlyAddedToDisplay;
+ private int maximumRecentlyAddedWithinHours;
+
@Override
protected void onInit() {
super.onInit();
- TreeGrid treeGrid = new TreeGrid();
+ treeGrid = new TreeGrid();
treeGrid.setDataSource(new RecentlyAddedResourceDS());
treeGrid.setAutoFetchData(true);
treeGrid.setTitle("Recently Added Resources");
@@ -79,7 +96,28 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet {
}
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
-
+ this.storedPortlet = storedPortlet;
+ if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX) != null) {
+ //retrieve and translate to int
+ String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX).getStringValue();
+ if (retrieved.equals(unlimited)) {
+ maximumRecentlyAddedToDisplay = -1;
+ } else {
+ maximumRecentlyAddedToDisplay = Integer.parseInt(retrieved);
+ }
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_MAX, defaultValue));
+ }
+ if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS) != null) {
+ String retrieved = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS).getStringValue();
+ if (retrieved.equals(unlimited)) {
+ setMaximumRecentlyAddedWithinHours(-1);
+ } else {
+ setMaximumRecentlyAddedWithinHours(Integer.parseInt(retrieved));
+ }
+ } else {
+ storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue));
+ }
}
public Canvas getHelpCanvas() {
@@ -87,7 +125,76 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet {
}
public DynamicForm getCustomSettingsForm() {
- return null;
+ final DynamicForm form = new DynamicForm();
+
+ //-------------combobox for number of recently added resources to display on the dashboard
+ final SelectItem maximumRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_MAX);
+ maximumRecentlyAddedComboBox.setTitle("Show maximum of");
+ maximumRecentlyAddedComboBox.setHint("<nobr><b> recently approved resources on dashboard.</b></nobr>");
+ //spinder 9/3/10: the following is required workaround to disable editability of combobox.
+ maximumRecentlyAddedComboBox.setType("selection");
+ //define acceptable values for display amount
+ String[] acceptableDisplayValues = { "5", "10", "15", "20", "30", unlimited };
+ maximumRecentlyAddedComboBox.setValueMap(acceptableDisplayValues);
+ //set width of dropdown display region
+ maximumRecentlyAddedComboBox.setWidth(100);
+
+ //default selected value to 'unlimited'(live lists) and check both combobox settings here.
+ String selectedValue = defaultValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX) != null) {
+ selectedValue = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_MAX).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_MAX, defaultValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ maximumRecentlyAddedComboBox.setDefaultValue(selectedValue);
+
+ //------------- Build second combobox for timeframe for problem resources search.
+ final SelectItem maximumTimeRecentlyAddedComboBox = new SelectItem(RECENTLY_ADDED_SHOW_HRS);
+ maximumTimeRecentlyAddedComboBox.setTitle("For the last ");
+ maximumTimeRecentlyAddedComboBox.setHint("<nobr><b> hours </b></nobr>");
+ //spinder 9/3/10: the following is required workaround to disable editability of combobox.
+ maximumTimeRecentlyAddedComboBox.setType("selection");
+ //define acceptable values for display amount
+ String[] acceptableTimeValues = { "1", "4", "8", "24", "48", unlimited };
+ maximumTimeRecentlyAddedComboBox.setValueMap(acceptableTimeValues);
+ maximumTimeRecentlyAddedComboBox.setWidth(100);
+
+ //set to default
+ selectedValue = defaultValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS) != null) {
+ selectedValue = storedPortlet.getConfiguration().getSimple(RECENTLY_ADDED_SHOW_HRS).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(new PropertySimple(RECENTLY_ADDED_SHOW_HRS, defaultValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ maximumTimeRecentlyAddedComboBox.setDefaultValue(selectedValue);
+
+ //insert fields
+ form.setFields(maximumRecentlyAddedComboBox, maximumTimeRecentlyAddedComboBox);
+
+ //submit handler
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ if (form.getValue(RECENTLY_ADDED_SHOW_MAX) != null) {
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(RECENTLY_ADDED_SHOW_MAX, form.getValue(RECENTLY_ADDED_SHOW_MAX)));
+ }
+ if (form.getValue(RECENTLY_ADDED_SHOW_HRS) != null) {
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(RECENTLY_ADDED_SHOW_HRS, form.getValue(RECENTLY_ADDED_SHOW_HRS)));
+ }
+ }
+ });
+
+ return form;
}
public static final class Factory implements PortletViewFactory {
@@ -97,4 +204,31 @@ public class RecentlyAddedView extends LocatableVLayout implements Portlet {
return new RecentlyAddedView(locatorId);
}
}
+
+ /** Custom refresh operation as we cannot directly extend Table because it
+ * contains a TreeGrid which is not a Table.
+ */
+ @Override
+ public void redraw() {
+ super.redraw();
+ //now reload the table data
+ this.treeGrid.invalidateCache();
+ this.treeGrid.markForRedraw();
+ }
+
+ public int getMaximumRecentlyAddedToDisplay() {
+ return maximumRecentlyAddedToDisplay;
+ }
+
+ public void setMaximumRecentlyAddedToDisplay(int maximumRecentlyAddedToDisplay) {
+ this.maximumRecentlyAddedToDisplay = maximumRecentlyAddedToDisplay;
+ }
+
+ public int getMaximumRecentlyAddedWithinHours() {
+ return maximumRecentlyAddedWithinHours;
+ }
+
+ public void setMaximumRecentlyAddedWithinHours(int maximumRecentlyAddedWithinHours) {
+ this.maximumRecentlyAddedWithinHours = maximumRecentlyAddedWithinHours;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 57472d3..88df56f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -82,7 +82,6 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
listGrid.setCellHeight(50);
//wrap to display disambiguation
listGrid.setWrapCells(true);
- // System.out.println("@@@@:"+listGrid.getField(ProblemResourcesDataSource.resource)+":W"+listGrid.getField(ProblemResourcesDataSource.resource).getWidth());
listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%");
listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%");
listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 54d175f..2d81fe0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -219,4 +219,15 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
}
return selected.toArray(new Integer[selected.size()]);
}
+
+ /** Custom refresh operation as we cannot directly extend Table because it
+ * contains a TreeGrid which is not a Table.
+ */
+ @Override
+ public void redraw() {
+ super.redraw();
+ //now reload the table data
+ this.treeGrid.invalidateCache();
+ this.treeGrid.markForRedraw();
+ }
}
commit c6fa4276a970f11ad543bdd83d714c3c2cc8c5bb
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Sep 8 09:23:39 2010 -0400
i)OperationsPortlet config/refresh ii)editable combobox fix.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index b7eeef9..81accf8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -21,15 +21,29 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operatio
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import com.smartgwt.client.widgets.grid.HeaderSpan;
+import com.smartgwt.client.widgets.layout.VStack;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -38,12 +52,34 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*
* @author Simeon Pinder
*/
-public class OperationsPortlet extends LocatableVLayout implements Portlet {
+public class OperationsPortlet extends LocatableVLayout implements CustomSettingsPortlet {
+ //unique field/form identifiers
+ public static final String OPERATIONS_RANGE_COMPLETED_ENABLED = "operations-completed-enabled";
+ public static final String OPERATIONS_RANGE_SCHEDULED_ENABLED = "operations-scheduled-enabled";
+ public static final String OPERATIONS_RANGE_COMPLETED = "operations-range-completed";
+ public static final String OPERATIONS_RANGE_SCHEDULED = "operations-range-scheduled";
+ //portlet key
public static final String KEY = "Operations";
private static final String TITLE = KEY;
private static String recentOperations = "Recent Operations";
private static String scheduledOperations = "Scheduled Operations";
+ private boolean operationsRangeLastEnabled = false;
+ private boolean operationsRangeNextEnabled = false;
+ private int operationsRangeScheduled = -1;
+ private int operationsRangeCompleted = -1;
+ //ListGrids for operations
+ private LocatableListGrid recentOperationsGrid = null;
+ private LocatableListGrid scheduledOperationsGrid = null;
+ private DashboardPortlet storedPortlet = null;
+ public static String unlimited = "unlimited";
+ public static String defaultValue = unlimited;
+ public static boolean defaultEnabled = false;
+
+ //default no-args constructor for serialization.
+ private OperationsPortlet() {
+ super("(unitialized)");
+ }
public OperationsPortlet(String locatorId) {
super(locatorId);
@@ -56,13 +92,16 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
//set title for larger container
setTitle(TITLE);
- // Add the list table as the top half of the view.
- LocatableListGrid recentOperationsGrid = new LocatableListGrid(recentOperations);
+ this.recentOperationsGrid = new LocatableListGrid(recentOperations);
recentOperationsGrid.setDataSource(new RecentOperationsDataSource());
recentOperationsGrid.setAutoFetchData(true);
- String[] allRows = new String[] { RecentOperationsDataSource.location, RecentOperationsDataSource.operation,
- RecentOperationsDataSource.resource, RecentOperationsDataSource.status, RecentOperationsDataSource.time };
- recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, allRows));
+ recentOperationsGrid.setTitle(recentOperations);
+ recentOperationsGrid.setWidth100();
+ //defining header span
+ String[] completedRows = new String[] { RecentOperationsDataSource.location,
+ RecentOperationsDataSource.operation, RecentOperationsDataSource.resource,
+ RecentOperationsDataSource.status, RecentOperationsDataSource.time };
+ recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, completedRows));
recentOperationsGrid.setHeaderSpanHeight(new Integer(20));
recentOperationsGrid.setHeaderHeight(40);
recentOperationsGrid.setResizeFieldsInRealTime(true);
@@ -71,13 +110,15 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
addMember(recentOperationsGrid);
// Add the list table as the top half of the view.
- LocatableListGrid scheduledOperationsGrid = new LocatableListGrid(scheduledOperations);
+ this.scheduledOperationsGrid = new LocatableListGrid(scheduledOperations);
scheduledOperationsGrid.setDataSource(new ScheduledOperationsDataSource());
scheduledOperationsGrid.setAutoFetchData(true);
- String[] allRows2 = new String[] { ScheduledOperationsDataSource.location,
+ scheduledOperationsGrid.setTitle(scheduledOperations);
+ scheduledOperationsGrid.setWidth100();
+ String[] scheduledRows = new String[] { ScheduledOperationsDataSource.location,
ScheduledOperationsDataSource.operation, ScheduledOperationsDataSource.resource,
ScheduledOperationsDataSource.time };
- scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, allRows2));
+ scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, scheduledRows));
scheduledOperationsGrid.setHeaderSpanHeight(new Integer(20));
scheduledOperationsGrid.setHeaderHeight(40);
@@ -92,8 +133,50 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
@Override
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
- // TODO implement this.
-
+ this.storedPortlet = storedPortlet;
+ //Operation range property - retrieve existing value
+ PropertySimple property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ if (retrieved.equals(unlimited)) {
+ setOperationsRangeCompleted(-1);
+ } else {
+ setOperationsRangeCompleted(Integer.parseInt(retrieved));
+ }
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue));
+ setOperationsRangeCompleted(-1);
+ }
+ property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ if (retrieved.equals(unlimited)) {
+ setOperationsRangeScheduled(-1);
+ } else {
+ setOperationsRangeScheduled(Integer.parseInt(retrieved));
+ }
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
+ setOperationsRangeScheduled(-1);
+ }
+ //Checkbox settings property
+ property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ if ((property != null) && (property.getBooleanValue() != null)) {
+ setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
+ } else {//create setting
+ storedPortlet.getConfiguration()
+ .put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, defaultEnabled));
+ setOperationsRangeScheduleEnabled(defaultEnabled);
+ }
+ property = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED);
+ if ((property != null) && (property.getBooleanValue() != null)) {
+ setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
+ } else {//create setting
+ storedPortlet.getConfiguration()
+ .put(new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, defaultEnabled));
+ }
}
@Override
@@ -101,8 +184,171 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
return new HTMLFlow("This portlet displays both operations that have occurred and are scheduled to occur.");
}
+ /** Constructs the dynamic form instance using 1 column and multiple row layouts.
+ */
public DynamicForm getCustomSettingsForm() {
- return null;
+
+ //root dynamic form instance
+ final DynamicForm form = new DynamicForm();
+
+ //vertical layout
+ VStack column = new VStack();
+
+ //label
+ Label operationRange = new Label("Operation Range");
+ column.addMember(operationRange);
+
+ //horizontal layout
+ LocatableHLayout row = new LocatableHLayout("enable.completed.operations");
+
+ //checkbox indicating whether to apply completed operations grouping settings
+ final CheckboxItem enableCompletedOperationsGrouping = new CheckboxItem();
+ enableCompletedOperationsGrouping.setName(OPERATIONS_RANGE_COMPLETED_ENABLED);
+ enableCompletedOperationsGrouping.setTitle(" show Last ");
+ //add change listener
+ enableCompletedOperationsGrouping.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(OPERATIONS_RANGE_COMPLETED_ENABLED, selectedItem);
+ }
+ });
+ //retrieve previous value otherwise initialize to true(live unlimited list)
+ PropertySimple retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED);
+ if (retrieved != null) {
+ enableCompletedOperationsGrouping.setValue(retrieved.getBooleanValue());
+ } else {//default
+ enableCompletedOperationsGrouping.setValue(true);
+ }
+
+ //wrap field item in dynamicform for addition as a field item
+ DynamicForm item = new DynamicForm();
+ item.setFields(enableCompletedOperationsGrouping);
+ row.addMember(item);
+
+ //-------------combobox for number of completed scheduled ops to display on the dashboard
+ final SelectItem maximumCompletedOperationsComboBox = new SelectItem(OPERATIONS_RANGE_COMPLETED);
+ maximumCompletedOperationsComboBox.setTitle("");
+ maximumCompletedOperationsComboBox.setHint("<nobr><b> completed operations.</b></nobr>");
+ //spinder: required to disable editability
+ maximumCompletedOperationsComboBox.setType("selection");
+ //define acceptable values for display amount
+ String[] acceptableDisplayValues = { "1", "5", "10", "15", unlimited };
+ maximumCompletedOperationsComboBox.setValueMap(acceptableDisplayValues);
+ //set width of dropdown display region
+ maximumCompletedOperationsComboBox.setWidth(100);
+ maximumCompletedOperationsComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(OPERATIONS_RANGE_COMPLETED, selectedItem);
+ }
+ });
+
+ //default selected value to 'unlimited'(live lists) and check both combobox settings here.
+ String selectedValue = defaultValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED) != null) {
+ selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ maximumCompletedOperationsComboBox.setDefaultValue(selectedValue);
+ DynamicForm item2 = new DynamicForm();
+ item2.setFields(maximumCompletedOperationsComboBox);
+ row.addMember(item2);
+
+ //horizontal layout
+ LocatableHLayout row2 = new LocatableHLayout("enable.scheduled.operations");
+
+ final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem();
+ enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ enableScheduledOperationsGrouping.setTitle(" show Next ");
+ enableScheduledOperationsGrouping.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(OPERATIONS_RANGE_SCHEDULED_ENABLED, selectedItem);
+ }
+ });
+
+ //wrap field item in dynamicform for addition
+ DynamicForm fieldWrapper = new DynamicForm();
+ fieldWrapper.setFields(enableScheduledOperationsGrouping);
+ row2.addMember(fieldWrapper);
+
+ //retrieve previous value otherwise initialize to true(live unlimited list)
+ retrieved = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ if (retrieved != null) {
+ enableScheduledOperationsGrouping.setValue(retrieved.getBooleanValue());
+ } else {
+ enableScheduledOperationsGrouping.setValue(true);
+ }
+
+ //------------- Build second combobox for timeframe for problem resources search.
+ final SelectItem maximumScheduledOperationsComboBox = new SelectItem(OPERATIONS_RANGE_SCHEDULED);
+ maximumScheduledOperationsComboBox.setTitle("");
+ maximumScheduledOperationsComboBox.setHint("<nobr><b> scheduled operations.</b></nobr>");
+ maximumScheduledOperationsComboBox.setType("selection");
+ maximumScheduledOperationsComboBox.setValueMap(acceptableDisplayValues);
+ maximumScheduledOperationsComboBox.setWidth(100);
+ maximumScheduledOperationsComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(OPERATIONS_RANGE_SCHEDULED, selectedItem);
+ }
+ });
+
+ //set to default
+ selectedValue = defaultValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED) != null) {
+ selectedValue = storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ maximumScheduledOperationsComboBox.setDefaultValue(selectedValue);
+ DynamicForm fieldWrapper2 = new DynamicForm();
+ fieldWrapper2.setFields(maximumScheduledOperationsComboBox);
+ row2.addMember(fieldWrapper2);
+ column.addMember(row);
+ column.addMember(row2);
+ form.addChild(column);
+
+ //submit handler
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ //no need to insert validation here as user not allowed to enter values
+ if (form.getValue(OPERATIONS_RANGE_SCHEDULED) != null) {//if new value supplied
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(OPERATIONS_RANGE_SCHEDULED, form.getValue(OPERATIONS_RANGE_SCHEDULED)));
+ }
+ if (form.getValue(OPERATIONS_RANGE_COMPLETED) != null) {//if new value supplied
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(OPERATIONS_RANGE_COMPLETED, form.getValue(OPERATIONS_RANGE_COMPLETED)));
+ }
+ if (form.getValue(OPERATIONS_RANGE_COMPLETED_ENABLED) != null) {//if new value supplied
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, form
+ .getValue(OPERATIONS_RANGE_COMPLETED_ENABLED)));
+ }
+ if (form.getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED) != null) {//if new value supplied
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, form
+ .getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED)));
+ }
+ }
+ });
+
+ return form;
}
public static final class Factory implements PortletViewFactory {
@@ -113,4 +359,69 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
}
}
+ public boolean isOperationsRangeCompletedEnabled() {
+ return operationsRangeLastEnabled;
+ }
+
+ public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) {
+ this.operationsRangeLastEnabled = operationsRangeLastEnabled;
+ }
+
+ public boolean isOperationsRangeScheduleEnabled() {
+ return operationsRangeNextEnabled;
+ }
+
+ public void setOperationsRangeScheduleEnabled(boolean operationsRangeNextEnabled) {
+ this.operationsRangeNextEnabled = operationsRangeNextEnabled;
+ }
+
+ public int getOperationsRangeScheduled() {
+ return operationsRangeScheduled;
+ }
+
+ public void setOperationsRangeScheduled(int operationsRangeScheduled) {
+ this.operationsRangeScheduled = operationsRangeScheduled;
+ }
+
+ public int getOperationsRangeCompleted() {
+ return operationsRangeCompleted;
+ }
+
+ public void setOperationsRangeCompleted(int operationsRangeCompleted) {
+ this.operationsRangeCompleted = operationsRangeCompleted;
+ }
+
+ /** Custom refresh operation as we cannot directly extend Table because it only
+ * contains one ListGrid while the OperationsPortlet displays two tables.
+ */
+ @Override
+ public void redraw() {
+ super.redraw();
+ //now reload the table data
+ this.recentOperationsGrid.invalidateCache();
+ this.recentOperationsGrid.markForRedraw();
+ this.scheduledOperationsGrid.invalidateCache();
+ this.scheduledOperationsGrid.markForRedraw();
+ }
+
+ public ConfigurationDefinition getConfigurationDefinition() {
+ ConfigurationDefinition definition = new ConfigurationDefinition("OperationsPortlet Configuration",
+ "The configuration settings for the Operations portlet.");
+
+ definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED,
+ "Maximum number of Completed operations to display.", true, PropertySimpleType.STRING));
+ definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED,
+ "Maximum number of Scheduled operations to display.", true, PropertySimpleType.STRING));
+ definition
+ .put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED_ENABLED,
+ "Whether to enable completed operations results grouping for dashboard.", true,
+ PropertySimpleType.BOOLEAN));
+ definition
+ .put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED,
+ "Whether to enable scheduled operations results grouping for dashboard.", true,
+ PropertySimpleType.BOOLEAN));
+
+ return definition;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index f87d80d..57472d3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -19,8 +19,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-import java.util.ArrayList;
-
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -84,6 +82,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
listGrid.setCellHeight(50);
//wrap to display disambiguation
listGrid.setWrapCells(true);
+ // System.out.println("@@@@:"+listGrid.getField(ProblemResourcesDataSource.resource)+":W"+listGrid.getField(ProblemResourcesDataSource.resource).getWidth());
listGrid.getField(ProblemResourcesDataSource.resource).setWidth("40%");
listGrid.getField(ProblemResourcesDataSource.location).setWidth("40%");
listGrid.getField(ProblemResourcesDataSource.alerts).setWidth("10%");
@@ -137,20 +136,14 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
final DynamicForm form = new DynamicForm();
//-------------combobox for number of resource to display on the dashboard
- // final ComboBoxItem maximumProblemResourcesComboBox = new ComboBoxItem(PROBLEM_RESOURCE_SHOW_MAX);
- //TODO: spinder(9/1/10) field is still editable. This looks like a bug.
final SelectItem maximumProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_MAX);
maximumProblemResourcesComboBox.setTitle("Show maximum of");
maximumProblemResourcesComboBox.setHint("<nobr><b> problem resources for display on dashboard.</b></nobr>");
- maximumProblemResourcesComboBox.setType("comboBox");
+ //spinder 9/3/10: the following is required workaround to disable editability of combobox.
+ maximumProblemResourcesComboBox.setType("selection");
//define acceptable values for display amount
String[] acceptableDisplayValues = { "5", "10", "15", "20", "30", unlimited };
maximumProblemResourcesComboBox.setValueMap(acceptableDisplayValues);
- //load the acceptable values for validity check later.
- final ArrayList<String> acceptableProblemResourceDisplayValues = new ArrayList<String>();
- for (String value : acceptableDisplayValues) {
- acceptableProblemResourceDisplayValues.add(value);
- }
//set width of dropdown display region
maximumProblemResourcesComboBox.setWidth(100);
@@ -171,14 +164,10 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
final SelectItem maximumTimeProblemResourcesComboBox = new SelectItem(PROBLEM_RESOURCE_SHOW_HRS);
maximumTimeProblemResourcesComboBox.setTitle("For the last ");
maximumTimeProblemResourcesComboBox.setHint("<nobr><b> hours </b></nobr>");
- maximumTimeProblemResourcesComboBox.setType("comboBox");
+ //spinder 9/3/10: the following is required workaround to disable editability of combobox.
+ maximumTimeProblemResourcesComboBox.setType("selection");
//define acceptable values for display amount
String[] acceptableTimeValues = { "1", "4", "8", "24", "48", unlimited };
- //load the acceptable values for validity check later.
- final ArrayList<String> acceptableTimeDisplayValues = new ArrayList<String>();
- for (String value : acceptableTimeValues) {
- acceptableTimeDisplayValues.add(value);
- }
maximumTimeProblemResourcesComboBox.setValueMap(acceptableTimeValues);
maximumTimeProblemResourcesComboBox.setWidth(100);
@@ -202,15 +191,11 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
form.addSubmitValuesHandler(new SubmitValuesHandler() {
@Override
public void onSubmitValues(SubmitValuesEvent event) {
- String maxItems = (String) form.getValue(PROBLEM_RESOURCE_SHOW_MAX);
- String timeFrame = (String) form.getValue(PROBLEM_RESOURCE_SHOW_HRS);
- //TODO: spinder 9/1/10: use smartgwt validation here?
- //shouldn't be necessary, but SelectItem remains editable for odd reason.
- if (acceptableProblemResourceDisplayValues.contains(maxItems.trim())) {
+ if (form.getValue(PROBLEM_RESOURCE_SHOW_MAX) != null) {
storedPortlet.getConfiguration().put(
new PropertySimple(PROBLEM_RESOURCE_SHOW_MAX, form.getValue(PROBLEM_RESOURCE_SHOW_MAX)));
}
- if (acceptableTimeDisplayValues.contains(timeFrame.trim())) {
+ if (form.getValue(PROBLEM_RESOURCE_SHOW_HRS) != null) {
storedPortlet.getConfiguration().put(
new PropertySimple(PROBLEM_RESOURCE_SHOW_HRS, form.getValue(PROBLEM_RESOURCE_SHOW_HRS)));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java
index 87ed4b7..28e6169 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableListGrid.java
@@ -13,7 +13,7 @@ public class LocatableListGrid extends ListGrid implements Locatable {
/**
* <pre>
- * ID Format: "simpleClassname_locatorId"
+ * ID Format: "scClassname-id"
* </pre>
* @param locatorId not null or empty.
*/
commit ce3f841a30ea1f4d56055c42e252acad575043bb
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Sep 8 13:36:49 2010 -0400
Initial commit for measurement_utils.js
Defines the class MeausrementModule which provides some properties and
methods for working with measurement schedules.
diff --git a/etc/cli-scripts/measurement_utils.js b/etc/cli-scripts/measurement_utils.js
new file mode 100644
index 0000000..261aa8e
--- /dev/null
+++ b/etc/cli-scripts/measurement_utils.js
@@ -0,0 +1,134 @@
+testUpdates = {
+ context: 'Resource',
+ id: 10033,
+ schedules: {
+ 'Late Collections': interval(15, minutes),
+ 'Failed Collections per Minute': interval(15, minutes),
+ 'Currently Schedule Measurements': 'enabled'
+ }
+}
+
+testGroupUpdates = {
+ context: 'Group',
+ id: 10031,
+ schedules: {
+ 'Used Swap Space': 'disabled',
+ 'Total Memory': interval(3, minutes)
+ }
+}
+
+/**
+ * MeasurementModule is a class that provides properties and methods for working with
+ * measurements.
+ */
+function MeasurementModule() {
+
+ /**
+ * Performs the actual updates, calling MeasurementScheduleManager.
+ *
+ * @param updates
+ * @param criteria
+ * @param enableSchedules
+ * @param disableSchedules
+ * @param updateSchedules
+ */
+ function doScheduleUpdates(updates, criteria, enableSchedules, disableSchedules, updateSchedules) {
+ criteria.fetchDefinition(true);
+ var schedules = MeasurementScheduleManager.findSchedulesByCriteria(criteria);
+
+ foreach(schedules, function (schedule) {
+ var measurementName = schedule.definition.displayName;
+
+ if (updates.schedules[measurementName]) {
+ switch (updates.schedules[measurementName]) {
+ case 'enabled':
+ MeasurementScheduleManager[enableSchedules](updates.id, [schedule.definition.id]);
+ break;
+ case 'disabled':
+ MeasurementScheduleManager[disableSchedules](updates.id,
+ [schedule.definition.id]);
+ break;
+ default:
+ var interval = updates.schedules[measurementName];
+ MeasurementScheduleManager[updateSchedules](updates.id,
+ [schedule.definition.id], interval);
+ }
+ }
+ });
+
+ }
+
+ /**
+ * Intended for use with the interval method.
+ */
+ this.time = {
+ seconds: 1000,
+ minutes: 60 * seconds,
+ hours: 60 * minutes
+ }
+
+ /**
+ * A helper method that calculates a shedule's interval in milliseconds
+ * @param num
+ * @param time
+ */
+ this.interval = function (num, time) {
+ return num * time;
+ }
+
+ /**
+ * Updates the metric schedule as specified in the updates object. The object is expected
+ * to contain three properties or keys. The first of these required keys is <context>.
+ * Accepted values are the strings 'Resource' or 'Group'.
+ *
+ * The next required key is <id>, and its values is expected to be an integer. The
+ * interpretation of its values is dependent on the value of <context>. When the value of
+ * <context> is 'Resource', then <id> is treated as a resource id. If the value of
+ * <context> is 'Group', then <id> is treated as a compatible group id.
+ *
+ * The third required key is <schedules>, and it a nested object that specifies the
+ * schedules to be updated. The keys of <schedules> are the measurement display names.
+ * Expected values are 'enabled', 'disabled', or an integer which specifies the
+ * collection interval in milliseconds.
+ *
+ * Here is an example to illustrate what the updates object should look like:
+ *
+ * resourceSchedulesUpdates = {
+ * context: 'Resource',
+ * id: 123,
+ * schedules: {
+ * 'Measurement A': 'enabled',
+ * 'Measurement B': 'disabled,
+ * 'Measurement C': interval(20, time.minutes)
+ * }
+ * }
+ *
+ * @param updates The updates to perform
+ */
+ this.updateSchedules = function (updates) {
+ if (!updates.id) {
+ throw '<id> is a required property';
+ }
+
+ if (!updates.schedules) {
+ throw '<schedules> is a required property';
+ }
+
+ if (updates.context == 'Resource') {
+ var criteria = MeasurementScheduleCriteria();
+ criteria.addFilterResourceId(updates.id);
+ doScheduleUpdates(updates, criteria, 'enableSchedulesForResource',
+ 'disableSchedulesForResource', 'updateSchedulesForResource');
+ }
+ else if (updates.context == 'Group') {
+ var criteria = MeasurementScheduleCriteria();
+ criteria.addFilterResourceGroupId(updates.id);
+ doScheduleUpdates(updates, criteria, 'enableSchedulesForCompatibleGroup',
+ 'disableSchedulesForCompatibleGroup', 'updateSchedulesForCompatibleGroup');
+ }
+ else {
+ throw "Unrecognized value for context: " + updates.context + " - expected either " +
+ "<Resource> or <Group>";
+ }
+ }
+}
commit ca5e991eef94926a016a43500eac107051ebde44
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Sep 7 16:52:03 2010 -0400
Putting build number generation plugins in profile to facilitate building in mead
We execute git during the build to generate some build properties, namely a
build number. The git executable however is not available in the mead build
environment. I have move the plugins involved with generating build properties
into a profile so that we can disable them during builds in mead.
diff --git a/pom.xml b/pom.xml
index 70c5254..497a520 100644
--- a/pom.xml
+++ b/pom.xml
@@ -604,85 +604,6 @@
</executions>
</plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>write-build-time-properties-file</id>
- <goals>
- <goal>run</goal>
- </goals>
- <phase>generate-sources</phase>
- <configuration>
- <tasks>
- <tstamp>
- <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US" timezone="GMT" />
- </tstamp>
- <mkdir dir="target" />
- <echo file="target/build-time.properties" level="error">buildTime = ${buildTime}</echo>
- </tasks>
- </configuration>
- </execution>
-
- <execution>
- <id>echo-build-properties</id>
- <phase>compile</phase>
- <inherited>false</inherited>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <echo level="debug">buildTime = ${buildTime}</echo>
- <echo level="debug">buildNumber = ${buildNumber}</echo>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-build-number-properties</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>git</executable>
- <arguments>
- <argument>log</argument>
- <argument>--pretty=format:buildNumber = %h</argument>
- <argument>-n1</argument>
- </arguments>
- <outputFile>${project.build.directory}/build-number.properties</outputFile>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>properties-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>read-build-properties</id>
- <phase>process-sources</phase>
- <goals>
- <goal>read-project-properties</goal>
- </goals>
- <configuration>
- <files>
- <file>${project.build.directory}/build-time.properties</file>
- <file>${project.build.directory}/build-number.properties</file>
- </files>
- </configuration>
- </execution>
- </executions>
- </plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
@@ -1083,6 +1004,98 @@
</build>
</profile>
+ <profile>
+ <id>build-properties</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>write-build-time-properties-file</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+ <tasks>
+ <tstamp>
+ <format property="buildTime" pattern="MM/dd/yy hh:mm aa z" locale="en,US"
+ timezone="GMT"/>
+ </tstamp>
+ <mkdir dir="target"/>
+ <echo file="target/build-time.properties" level="error">buildTime = ${buildTime}
+ </echo>
+ </tasks>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>echo-build-properties</id>
+ <phase>compile</phase>
+ <inherited>false</inherited>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <echo level="debug">buildTime = ${buildTime}</echo>
+ <echo level="debug">buildNumber = ${buildNumber}</echo>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-build-number-properties</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>git</executable>
+ <arguments>
+ <argument>log</argument>
+ <argument>--pretty=format:buildNumber = %h</argument>
+ <argument>-n1</argument>
+ </arguments>
+ <outputFile>${project.build.directory}/build-number.properties</outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>properties-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>read-build-properties</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>read-project-properties</goal>
+ </goals>
+ <configuration>
+ <files>
+ <file>${project.build.directory}/build-time.properties</file>
+ <file>${project.build.directory}/build-number.properties</file>
+ </files>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
</profiles>
commit 560767773837cf185c700cec5e4e3424e83d21fb
Merge: 06b4a2c... 05f3a00...
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Sep 7 16:50:28 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 05f3a00fae75d97d066559c7671dc4f0770a1dbd
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Sep 8 13:54:18 2010 -0400
bz 631895 - allow a user to enter --resourceId option to discovery prompt
command in order to perform a service scan. Like the rest of the options
of this command (exception being --ful) this new feature still will not
send up an inventory report to the RHQ Server - use --full for that.
This --resourceId is to assist developers while they are writing plugins
to test service scans or allows users to see what the next service scan
would detect. Since service scans are scheduled every 24 hours, this helps people
see if anything would result - if something is discovered using this command,
you can do a "discovery --full" to force a full discovery to be performed
and the inventory report sent up to the server.
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 7920df0..eb1df86 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
@@ -1832,7 +1832,7 @@ public interface AgentI18NResourceKeys {
String DISCOVERY = "PromptCommand.discovery";
@I18NMessage("discovery [--plugin=<plugin name>] [--resourceType=<type name>]\\n\\\n" //
- + "\\ [--verbose]\\n\\\n" //
+ + "\\ [--resourceId=<id>] [--verbose]\\n\\\n" //
+ "\\ discovery --full [--verbose]\\n\\\n" //
+ "\\ discovery --blacklist={list|clear}")
String DISCOVERY_SYNTAX = "PromptCommand.discovery.syntax";
@@ -1840,16 +1840,16 @@ public interface AgentI18NResourceKeys {
@I18NMessage("Asks a plugin to run a server scan discovery")
String DISCOVERY_HELP = "PromptCommand.discovery.help";
- @I18NMessage("Asks a plugin to run a discovery scan. This is a way to determine\\n\\\n"
- + "what servers a plugin can actually find. Note that this will run a server\\n\\\n"
- + "scan, not a service scan (i.e. it will not try to discover child services\\n\\\n"
- + "for parent servers already in inventory) unless you use --full. Also note\\n\\\n"
- + "that only --full will actually send an inventory report to the server.\\n\\\n"
+ @I18NMessage("Asks a plugin to run a discovery scan. This is a way to determine what\\n\\\n"
+ + "resources a plugin can actually find. Note that this will run a server scan\\n\\\n"
+ + "not a service scan (i.e. it will not try to discover child services for parent\\n\\\n"
+ + "servers already in inventory) unless you use --full or --resourceId. Also\\n\\\n"
+ + "note that only --full will actually send an inventory report to the server.\\n\\\n"
+ "The valid command line arguments are:\\n\\\n"
+ "\\ -f, --full : Runs a detailed discovery inside the plugin container.\\n\\\n"
+ "\\ This will update the actual agent inventory by sending\\n\\\n"
+ "\\ an inventory report to the server.\\n\\\n"
- + "\\ This ignores --plugin and --resourceType.\\n\\\n"
+ + "\\ This ignores --plugin, --resourceType and --resourceId.\\n\\\n"
+ "\\ -p, --plugin=<name> : The name of the plugin whose discovery will run.\\n\\\n"
+ "\\ If you do not specify a plugin, all plugins will\\n\\\n"
+ "\\ run their discovery.\\n\\\n"
@@ -1859,6 +1859,11 @@ public interface AgentI18NResourceKeys {
+ "\\ discovered (and if no plugin was specified,\\n\\\n"
+ "\\ then all resource types for all plugins will\\n\\\n"
+ "\\ be discovered).\\n\\\n"
+ + "\\ -i, --resourceId=<id> : specifies the specific resource ID whose\\n\\\n"
+ + "\\ services are to be discovered. If specified,\\n\\\n"
+ + "\\ a service scan is performed as opposed to a\\n\\\n"
+ + "\\ server scan and the --plugin/--resourceType\\n\\\n"
+ + "\\ options are ignored.\\n\\\n"
+ "\\ -v, --verbose : If doing a non-full discovery, this prints the plugin\\n\\\n"
+ "\\ configuration of each discovered resource. For --full\\n\\\n"
+ "\\ scans, this will dump all resources and errors found.\\n\\\n"
@@ -1877,6 +1882,12 @@ public interface AgentI18NResourceKeys {
@I18NMessage("Full discovery run in [{0}] ms")
String DISCOVERY_FULL_RUN = "PromptCommand.discovery.full-run";
+ @I18NMessage("Service discovery run for resource [{0}]")
+ String DISCOVERY_RESOURCE_SERVICES = "PromptCommand.discovery.resource-service-scan";
+
+ @I18NMessage("The given resource ID [{0}] does not match any resource in inventory.")
+ String DISCOVERY_RESOURCE_ID_INVALID = "PromptCommand.discovery.resource-id-invalid";
+
@I18NMessage("=== {0} Inventory Report ===\\n\\\n" //
+ "Start Time: {1,date,medium} {1,time,medium}\\n\\\n" //
+ "Finish Time: {2,date,medium} {2,time,medium}\\n\\\n" //
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java
index 3aea8ec..8736f05 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/DiscoveryPromptCommand.java
@@ -33,17 +33,19 @@ import java.util.Set;
import mazz.i18n.Msg;
import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.resource.ProcessScan;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.core.pc.inventory.ResourceContainer;
+import org.rhq.core.pc.inventory.RuntimeDiscoveryExecutor;
import org.rhq.core.pc.plugin.PluginComponentFactory;
import org.rhq.core.pc.util.DiscoveryComponentProxyFactory;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
@@ -58,6 +60,7 @@ import org.rhq.core.system.SystemInfoFactory;
import org.rhq.core.system.pquery.ProcessInfoQuery;
import org.rhq.core.util.exception.ExceptionPackage;
import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.enterprise.agent.AgentConfiguration;
import org.rhq.enterprise.agent.AgentMain;
import org.rhq.enterprise.agent.i18n.AgentI18NFactory;
import org.rhq.enterprise.agent.i18n.AgentI18NResourceKeys;
@@ -89,7 +92,7 @@ public class DiscoveryPromptCommand implements AgentPromptCommand {
System.arraycopy(args, 1, realArgs, 0, args.length - 1);
// use getAgentName because it is the name of the plugin container
- processCommand(agent.getConfiguration().getAgentName(), realArgs, out);
+ processCommand(agent, realArgs, out);
} else {
out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_PC_NOT_STARTED));
}
@@ -118,14 +121,18 @@ public class DiscoveryPromptCommand implements AgentPromptCommand {
return MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_DETAILED_HELP);
}
- private void processCommand(String pcName, String[] args, PrintWriter out) {
+ private void processCommand(AgentMain agent, String[] args, PrintWriter out) {
+ AgentConfiguration agentConfig = agent.getConfiguration();
+ String pcName = agentConfig.getAgentName();
String pluginName = null;
String resourceTypeName = null;
+ Integer resourceId = null;
boolean verbose = false;
boolean full = false;
- String sopts = "-p:r:fvb:";
+ String sopts = "-p:i:r:fvb:";
LongOpt[] lopts = { new LongOpt("plugin", LongOpt.REQUIRED_ARGUMENT, null, 'p'), //
+ new LongOpt("resourceId", LongOpt.REQUIRED_ARGUMENT, null, 'i'), //
new LongOpt("resourceType", LongOpt.REQUIRED_ARGUMENT, null, 'r'), //
new LongOpt("full", LongOpt.NO_ARGUMENT, null, 'f'), //
new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'), //
@@ -148,6 +155,11 @@ public class DiscoveryPromptCommand implements AgentPromptCommand {
break;
}
+ case 'i': {
+ resourceId = Integer.valueOf(getopt.getOptarg());
+ break;
+ }
+
case 'r': {
resourceTypeName = getopt.getOptarg();
break;
@@ -187,9 +199,10 @@ public class DiscoveryPromptCommand implements AgentPromptCommand {
}
if (full) {
- // do a full discovery - we ignore the -p and -r options and do everything
+ // do a full discovery - we ignore the -p and -r and -i options and do everything
InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager();
- HashSet<ResourceType> blacklist = inventoryManager.getDiscoveryComponentProxyFactory().getResourceTypeBlacklist();
+ HashSet<ResourceType> blacklist = inventoryManager.getDiscoveryComponentProxyFactory()
+ .getResourceTypeBlacklist();
if (!blacklist.isEmpty()) {
out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_BLACKLISTED_TYPES, blacklist));
}
@@ -201,10 +214,25 @@ public class DiscoveryPromptCommand implements AgentPromptCommand {
printInventoryReport(scan2, out, verbose);
} else {
try {
- discovery(pcName, out, pluginName, resourceTypeName, verbose);
+ if (resourceId == null) {
+ discovery(pcName, out, pluginName, resourceTypeName, verbose);
+ } else {
+ // specifying a resource ID implies we must ignore -r and -p (since type/plugin is determined by the resource)
+ InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+ ResourceContainer resourceContainer = im.getResourceContainer(resourceId);
+ if (resourceContainer != null) {
+ Resource resource = resourceContainer.getResource();
+ PluginContainerConfiguration pcc = agentConfig.getPluginContainerConfiguration();
+ RuntimeDiscoveryExecutor scanner = new RuntimeDiscoveryExecutor(im, pcc, resource);
+ InventoryReport report = scanner.call();
+ out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_RESOURCE_SERVICES, resource.getName()));
+ printInventoryReport(report, out, verbose);
+ } else {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_RESOURCE_ID_INVALID, resourceId));
+ }
+ }
} catch (Exception e) {
out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_ERROR, ThrowableUtil.getAllMessages(e)));
- return;
}
}
@@ -261,7 +289,8 @@ public class DiscoveryPromptCommand implements AgentPromptCommand {
}
InventoryManager inventoryManager = pc.getInventoryManager();
- HashSet<ResourceType> blacklist = inventoryManager.getDiscoveryComponentProxyFactory().getResourceTypeBlacklist();
+ HashSet<ResourceType> blacklist = inventoryManager.getDiscoveryComponentProxyFactory()
+ .getResourceTypeBlacklist();
Iterator<ResourceType> iterator = blacklist.iterator();
while (iterator.hasNext()) {
ResourceType type = iterator.next();
commit a572ff4732dfa48147cadfdba026742c05eba1a3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Sep 7 16:58:25 2010 -0400
we never updated ecllipse classpath to point to our current EMS version - this corrects that mistake
diff --git a/.classpath b/.classpath
index dc15df6..c13d973 100644
--- a/.classpath
+++ b/.classpath
@@ -202,7 +202,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/javax/faces/jsf-impl/1.2_14/jsf-impl-1.2_14.jar" sourcepath="/M2_REPO/javax/faces/jsf-impl/1.2_14/jsf-impl-1.2_14-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/sun/facelets/jsf-facelets/1.1.15.B1/jsf-facelets-1.1.15.B1.jar" sourcepath="/M2_REPO/com/sun/facelets/jsf-facelets/1.1.15.B1/jsf-facelets-1.1.15.B1-sources.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.2.14/org-mc4j-ems-1.2.14.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.2.13/org-mc4j-ems-1.2.13-sources.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.2.15.1/org-mc4j-ems-1.2.15.1.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.2.15.1/org-mc4j-ems-1.2.15.1-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5.jar" sourcepath="/M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/javax/mail/mail/1.4.2/mail-1.4.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar"/>
commit 8cc4a2da37215e02591d3a24d790f47c7593a9be
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Sep 7 18:34:44 2010 -0400
add more consistency to left-hand navigation element of the inventory browser
* new top-level nodes
** pull-up auto discovery node as top-level node within resource section
** pull-up group definitions node as top-level node within group section
** rename both to use a manager suffix, to be more consistent across sections
* collapse superfluous nodes into nodes that didn't do anything
** collapse "all reosurces" node into its "inventory" parent folder/node
** collapse "all groups" node into its "inventory" parent folder/node
** rename both "inventory" folders/nodes by prefixing with section/context
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index a3d0821..731711e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -47,6 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public class InventoryView extends LocatableHLayout implements BookmarkableView {
@@ -55,14 +56,15 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
private static final String SECTION_GROUPS = "Groups";
private static final String SECTION_RESOURCES = "Resources";
- private static final String SUBSECTION_INVENTORY = "Inventory";
+ private static final String SUBSECTION_RESOURCE_INVENTORY = "Resource Inventory";
+ private static final String SUBSECTION_GROUP_INVENTORY = "Group Inventory";
private static final String SUBSECTION_SAVED_SEARCHES = "Saved Searches";
- private static final String PAGE_ADQ = "Auto Discovery Queue";
+ private static final String PAGE_ADQ = "Discovery Manager";
private static final String PAGE_COMPATIBLE_GROUPS = "Compatible Groups";
private static final String PAGE_DOWN = "Down Servers";
private static final String PAGE_GROUPS = "All Groups";
- private static final String PAGE_GROUP_DEFINITIONS = "Group Definitions";
+ private static final String PAGE_GROUP_DEFINITIONS = "DynaGroup Manager";
private static final String PAGE_MIXED_GROUPS = "Mixed Groups";
private static final String PAGE_PLATFORMS = "Platforms";
private static final String PAGE_PROBLEM_GROUPS = "Problem Groups";
@@ -126,10 +128,13 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
}
private SectionStackSection buildResourcesSection() {
+
final SectionStackSection section = new SectionStackSection(SECTION_RESOURCES);
section.setExpanded(true);
- final TreeNode allResources = new TreeNode(PAGE_RESOURCES);
+ final TreeNode discoveryQueue = new TreeNode(PAGE_ADQ);
+ discoveryQueue.setIcon("global/Recent_16.png");
+
final TreeNode onlyPlatforms = new TreeNode(PAGE_PLATFORMS);
onlyPlatforms.setIcon("types/Platform_up_16.png");
@@ -139,11 +144,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
final TreeNode onlyServices = new TreeNode(PAGE_SERVICES);
onlyServices.setIcon("types/Service_up_16.png");
- final TreeNode discoveryQueue = new TreeNode("Auto Discovery Queue");
- discoveryQueue.setIcon("global/Recent_16.png");
-
- final TreeNode inventory = new TreeNode(SUBSECTION_INVENTORY, allResources, onlyPlatforms, onlyServers,
- onlyServices, discoveryQueue);
+ final TreeNode inventory = new TreeNode(SUBSECTION_RESOURCE_INVENTORY, onlyPlatforms, onlyServers, onlyServices);
final TreeNode downServers = new TreeNode(PAGE_DOWN);
downServers.setIcon("types/Server_down_16.png");
@@ -153,7 +154,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
TreeGrid treeGrid = new LocatableTreeGrid(SECTION_RESOURCES);
treeGrid.setShowHeader(false);
Tree tree = new Tree();
- tree.setRoot(new TreeNode(SECTION_RESOURCES, inventory, savedSearches));
+ tree.setRoot(new TreeNode(SECTION_RESOURCES, discoveryQueue, inventory, savedSearches));
treeGrid.setData(tree);
treeGrid.getTree().openAll();
@@ -168,15 +169,15 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
final SectionStackSection section = new SectionStackSection(SECTION_GROUPS);
section.setExpanded(true);
- final TreeNode allGroups = new TreeNode(PAGE_GROUPS);
+ final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS);
+ groupGroupDefinitions.setIcon("types/GroupDefinition_16.png");
+
final TreeNode onlyCompatible = new TreeNode(PAGE_COMPATIBLE_GROUPS);
onlyCompatible.setIcon("types/Cluster_up_16.png");
final TreeNode onlyMixed = new TreeNode(PAGE_MIXED_GROUPS);
onlyMixed.setIcon("types/Group_up_16.png");
- final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS);
- groupGroupDefinitions.setIcon("types/GroupDefinition_16.png");
- final TreeNode inventory = new TreeNode(SECTION_GROUPS, allGroups, onlyCompatible, onlyMixed,
- groupGroupDefinitions);
+
+ final TreeNode inventory = new TreeNode(SUBSECTION_GROUP_INVENTORY, onlyCompatible, onlyMixed);
final TreeNode problemGroups = new TreeNode(PAGE_PROBLEM_GROUPS);
final TreeNode savedSearches = new TreeNode(SUBSECTION_SAVED_SEARCHES, problemGroups);
@@ -184,7 +185,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
TreeGrid treeGrid = new LocatableTreeGrid(SECTION_GROUPS);
treeGrid.setShowHeader(false);
Tree tree = new Tree();
- tree.setRoot(new TreeNode(SECTION_GROUPS, inventory, savedSearches));
+ tree.setRoot(new TreeNode(SECTION_GROUPS, groupGroupDefinitions, inventory, savedSearches));
treeGrid.setData(tree);
treeGrid.getTree().openAll();
@@ -217,11 +218,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
Canvas content = null;
if (SECTION_RESOURCES.equals(section)) {
-
- if (PAGE_RESOURCES.equals(page)) {
- content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES,
- "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png");
- } else if (PAGE_PLATFORMS.equals(page)) {
+ if (PAGE_PLATFORMS.equals(page)) {
content = new ResourceSearchView(extendLocatorId("Platforms"), new Criteria(
ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS,
"types/Platform_up_24.png");
@@ -240,14 +237,13 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
AvailabilityType.DOWN.name());
criteria.addCriteria(ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name());
content = new ResourceSearchView(extendLocatorId("DownResources"), criteria, PAGE_DOWN);
+ } else { // selected the Inventory node itself
+ content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES,
+ "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png");
}
} else if (SECTION_GROUPS.equals(section)) {
-
- if (PAGE_GROUPS.equals(page)) {
- content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS,
- "types/Cluster_up_24.png", "types/Group_up_24.png");
- } else if (PAGE_COMPATIBLE_GROUPS.equals(page)) {
+ if (PAGE_COMPATIBLE_GROUPS.equals(page)) {
content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria("category",
"compatible"), PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_24.png");
} else if (PAGE_MIXED_GROUPS.equals(page)) {
@@ -260,6 +256,9 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
// new button on this page.
content = new ResourceGroupListView(extendLocatorId("DownGroups"),
new Criteria("availability", "down"), PAGE_PROBLEM_GROUPS);
+ } else { // selected the Inventory node itself
+ content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS,
+ "types/Cluster_up_24.png", "types/Group_up_24.png");
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 29673a6..54d175f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -82,7 +82,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
HTMLFlow title = new HTMLFlow();
title.setWidth100();
title.setHeight(35);
- title.setContents("Auto Discovery Queue");
+ title.setContents("Discovery Manager");
title.setPadding(4);
title.setStyleName("HeaderLabel");
titleLayout.addMember(title);
@@ -109,7 +109,6 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
treeGrid.setDataSource(new AutodiscoveryQueueDataSource());
treeGrid.setAutoFetchData(true);
- treeGrid.setTitle("Auto Discovery Queue");
treeGrid.setResizeFieldsInRealTime(true);
final TreeGridField name, key, type, description, status, ctime;
commit de9516869976390c3a0c8bcf3fcd0fce451bfb90
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 30 01:13:55 2010 -0400
primitive solution to time out the coregui user session prior to the http session
* upon login, refresh the count-down timer @ 29 minutes (http session is 30 mins)
* upon logout, destroy/cancel the count-down timer
* if the count-down timer expires, immitate a logout action
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 e0625a5..f153fea 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
@@ -30,6 +30,7 @@ import com.google.gwt.http.client.Response;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.core.KeyIdentifier;
@@ -69,6 +70,14 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static Subject sessionSubject;
+ private static Timer sessionTimer = new Timer() {
+ @Override
+ public void run() {
+ System.out.println("Session Timer Expired");
+ new LoginView(true).showLoginDialog(); // log user out, show login dialog
+ }
+ };
+
private static UserPreferences userPreferences;
private static ErrorHandler errorHandler = new ErrorHandler();
@@ -192,6 +201,16 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
}
+ public static void refreshSessionTimer() {
+ System.out.println("Refreshing Session Timer");
+ sessionTimer.schedule(29 * 60 * 1000); // 29 minutes from now, timeout before the http session timeout
+ }
+
+ public static void destroySessionTimer() {
+ System.out.println("Destroying Session Timer");
+ sessionTimer.cancel();
+ }
+
private void buildCoreUI() {
// If the core gui is already built (eg. from previous login, just refire event)
if (this.rootCanvas == null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 82d010d..6290eb7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -63,18 +63,22 @@ public class LoginView extends Canvas {
}
public LoginView(boolean logout) {
+ if (logout) {
+ CoreGUI.destroySessionTimer();
+ if (CoreGUI.getSessionSubject() != null) {
+ GWTServiceLookup.getSubjectService().logout(CoreGUI.getSessionSubject(), new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to logout", caught);
+ CoreGUI.checkLoginStatus();
+ }
- if (logout && CoreGUI.getSessionSubject() != null) {
- GWTServiceLookup.getSubjectService().logout(CoreGUI.getSessionSubject(), new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to logout", caught);
- CoreGUI.checkLoginStatus();
- }
-
- public void onSuccess(Void result) {
- CoreGUI.checkLoginStatus();
- }
- });
+ public void onSuccess(Void result) {
+ CoreGUI.checkLoginStatus();
+ }
+ });
+ }
+ } else {
+ CoreGUI.refreshSessionTimer();
}
}
commit 25c2c140c9cf11a801d08b49212d0e2eda3dc877
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 12:26:27 2010 -0400
add left-nav and table header icons for group definitions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
index 9e3f983..dc81946 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
@@ -32,9 +32,11 @@ import org.rhq.enterprise.gui.coregui.client.components.table.Table;
*/
public class GroupDefinitionListView extends Table {
- public GroupDefinitionListView(String locatorId) {
+ public GroupDefinitionListView(String locatorId, String headerIcon) {
super(locatorId, "Group Definitions");
+ setHeaderIcon(headerIcon);
+
final GroupDefinitionDataSource datasource = new GroupDefinitionDataSource();
setDataSource(datasource);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index ac717bf..a3d0821 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -174,6 +174,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
final TreeNode onlyMixed = new TreeNode(PAGE_MIXED_GROUPS);
onlyMixed.setIcon("types/Group_up_16.png");
final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS);
+ groupGroupDefinitions.setIcon("types/GroupDefinition_16.png");
final TreeNode inventory = new TreeNode(SECTION_GROUPS, allGroups, onlyCompatible, onlyMixed,
groupGroupDefinitions);
@@ -253,7 +254,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria("category", "mixed"),
PAGE_MIXED_GROUPS, "types/Group_up_24.png");
} else if (PAGE_GROUP_DEFINITIONS.equals(page)) {
- content = new GroupDefinitionListView(extendLocatorId("Definitions"));
+ content = new GroupDefinitionListView(extendLocatorId("Definitions"), "types/GroupDefinition_16.png");
} else if (PAGE_PROBLEM_GROUPS.equals(page)) {
//TODO - there is no underlying support for this criteria. Also, there should not be an active
// new button on this page.
commit c559a5bfc79a7232526a565b058151d0cd2edb66
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 11:47:35 2010 -0400
add group definition icon to coregui
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/types/GroupDefinition_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/types/GroupDefinition_16.png
new file mode 100644
index 0000000..20b0f01
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/types/GroupDefinition_16.png differ
commit 307c5f41f63a9f3ba7b79d4f5c99efed815c7b5b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 11:47:22 2010 -0400
set the node icons for compatible/mixed groups in the inventory view left-nav
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index c051000..ac717bf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -170,7 +170,9 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
final TreeNode allGroups = new TreeNode(PAGE_GROUPS);
final TreeNode onlyCompatible = new TreeNode(PAGE_COMPATIBLE_GROUPS);
+ onlyCompatible.setIcon("types/Cluster_up_16.png");
final TreeNode onlyMixed = new TreeNode(PAGE_MIXED_GROUPS);
+ onlyMixed.setIcon("types/Group_up_16.png");
final TreeNode groupGroupDefinitions = new TreeNode(PAGE_GROUP_DEFINITIONS);
final TreeNode inventory = new TreeNode(SECTION_GROUPS, allGroups, onlyCompatible, onlyMixed,
groupGroupDefinitions);
commit aaace38e92ecb818c9fe482dd2880ce33347cd62
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 11:42:05 2010 -0400
cosmetic, refactoring according to code conventions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 25c24bb..a77a9d9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -18,6 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
+
import java.util.ArrayList;
import java.util.List;
@@ -40,13 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.PLUGIN;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.TYPE;
-
/**
* @author Greg Hinkle
*/
@@ -99,10 +99,8 @@ public class ResourceSearchView extends Table {
// setTitleComponent(searchPanel);
setDataSource(datasource);
-
}
-
@Override
protected void configureTable() {
@@ -115,7 +113,8 @@ public class ResourceSearchView extends Table {
ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- return "<a href=\"" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")) + "\">" + o + "</a>";
+ return "<a href=\"" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")) + "\">" + o
+ + "</a>";
}
});
commit 47a25eff072edf9443a3587ab032e67a11b2f12f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 11:41:41 2010 -0400
add appropriate table header icons for inventory view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
index b1f70b7..38d409f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
@@ -51,10 +51,12 @@ public class ResourceGroupListView extends Table {
this(locatorId, null, title);
}
- public ResourceGroupListView(String locatorId, Criteria criteria, String title) {
+ public ResourceGroupListView(String locatorId, Criteria criteria, String title, String... headerIcons) {
super(locatorId, title, criteria);
- setHeaderIcon("types/Group_up_24.png");
+ for (String headerIcon : headerIcons) {
+ addHeaderIcon(headerIcon);
+ }
final ResourceGroupsDataSource datasource = ResourceGroupsDataSource.getInstance();
setDataSource(datasource);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index d4b0b63..c051000 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -216,16 +216,20 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
if (SECTION_RESOURCES.equals(section)) {
if (PAGE_RESOURCES.equals(page)) {
- content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES);
+ content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES,
+ "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png");
} else if (PAGE_PLATFORMS.equals(page)) {
content = new ResourceSearchView(extendLocatorId("Platforms"), new Criteria(
- ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS);
+ ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS,
+ "types/Platform_up_24.png");
} else if (PAGE_SERVERS.equals(page)) {
content = new ResourceSearchView(extendLocatorId("Servers"), new Criteria(
- ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()), PAGE_SERVERS);
+ ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()), PAGE_SERVERS,
+ "types/Server_up_24.png");
} else if (PAGE_SERVICES.equals(page)) {
content = new ResourceSearchView(extendLocatorId("Services"), new Criteria(
- ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVICE.name()), PAGE_SERVICES);
+ ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVICE.name()), PAGE_SERVICES,
+ "types/Service_up_24.png");
} else if (PAGE_ADQ.equals(page)) {
content = new ResourceAutodiscoveryView(this.extendLocatorId("ADQ"));
} else if (PAGE_DOWN.equals(page)) {
@@ -238,13 +242,14 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
} else if (SECTION_GROUPS.equals(section)) {
if (PAGE_GROUPS.equals(page)) {
- content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS);
+ content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS,
+ "types/Cluster_up_24.png", "types/Group_up_24.png");
} else if (PAGE_COMPATIBLE_GROUPS.equals(page)) {
content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria("category",
- "compatible"), PAGE_COMPATIBLE_GROUPS);
+ "compatible"), PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_24.png");
} else if (PAGE_MIXED_GROUPS.equals(page)) {
content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria("category", "mixed"),
- PAGE_MIXED_GROUPS);
+ PAGE_MIXED_GROUPS, "types/Group_up_24.png");
} else if (PAGE_GROUP_DEFINITIONS.equals(page)) {
content = new GroupDefinitionListView(extendLocatorId("Definitions"));
} else if (PAGE_PROBLEM_GROUPS.equals(page)) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 7a4b3be..25c24bb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -74,18 +74,20 @@ public class ResourceSearchView extends Table {
this(locatorId, criteria, DEFAULT_TITLE);
}
- public ResourceSearchView(String locatorId, Criteria criteria, String title) {
- this(locatorId, criteria, title, null, null);
+ public ResourceSearchView(String locatorId, Criteria criteria, String title, String... headerIcons) {
+ this(locatorId, criteria, title, null, null, headerIcons);
}
/**
* A Resource list filtered by a given criteria with the given title.
*/
public ResourceSearchView(String locatorId, Criteria criteria, String title, SortSpecifier[] sortSpecifier,
- String[] excludeFields) {
+ String[] excludeFields, String... headerIcons) {
super(locatorId, title, criteria, sortSpecifier, excludeFields);
- setHeaderIcon("types/Platform_up_24.png");
+ for (String headerIcon : headerIcons) {
+ addHeaderIcon(headerIcon);
+ }
// DynamicForm searchPanel = new DynamicForm();
// final TextItem searchBox = new TextItem("query", "Search Resources");
commit cbf929586870b5697931bf0019ca82f661654051
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 11:40:26 2010 -0400
enhance Table component to be able to display multiple title-prefix images
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index a18d6f8..90b448f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -78,7 +78,7 @@ public class Table extends LocatableHLayout {
private ToolStrip footer;
private Label tableInfo;
- private String headerIcon;
+ private List<String> headerIcons = new ArrayList<String>();
private boolean showHeader = true;
private boolean showFooter = true;
@@ -260,7 +260,7 @@ public class Table extends LocatableHLayout {
if (showHeader) {
- if (headerIcon != null) {
+ for (String headerIcon : headerIcons) {
Img img = new Img(headerIcon, 24, 24);
img.setPadding(4);
titleLayout.addMember(img);
@@ -465,12 +465,15 @@ public class Table extends LocatableHLayout {
this.extraWidgets.add(canvas);
}
- public String getHeaderIcon() {
- return headerIcon;
+ public void setHeaderIcon(String headerIcon) {
+ if (this.headerIcons.size() > 0) {
+ this.headerIcons.clear();
+ }
+ addHeaderIcon(headerIcon);
}
- public void setHeaderIcon(String headerIcon) {
- this.headerIcon = headerIcon;
+ public void addHeaderIcon(String headerIcon) {
+ this.headerIcons.add(headerIcon);
}
protected void refreshTableInfo() {
commit 4158471e033ff8a545b13dfa15cf9e96ee76a3b0
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 11:21:52 2010 -0400
fix table title for "all groups" list view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index 393bd45..d4b0b63 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -238,7 +238,7 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
} else if (SECTION_GROUPS.equals(section)) {
if (PAGE_GROUPS.equals(page)) {
- content = new ResourceGroupListView(extendLocatorId("AllGroups"));
+ content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, PAGE_GROUPS);
} else if (PAGE_COMPATIBLE_GROUPS.equals(page)) {
content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria("category",
"compatible"), PAGE_COMPATIBLE_GROUPS);
commit 66bd7d5d9ca050ba70b21810ec2ce45b041313e8
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 11:21:34 2010 -0400
all instantiations of ResourceGroupListView should set the datasource
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
index d5b2df6..b1f70b7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
@@ -54,6 +54,8 @@ public class ResourceGroupListView extends Table {
public ResourceGroupListView(String locatorId, Criteria criteria, String title) {
super(locatorId, title, criteria);
+ setHeaderIcon("types/Group_up_24.png");
+
final ResourceGroupsDataSource datasource = ResourceGroupsDataSource.getInstance();
setDataSource(datasource);
}
commit 24e1e33f51575f54cb217d96b163070378601cb5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 02:48:53 2010 -0400
update EventCompositeHistoryView to use latest infrastructure changes:
* merge EventCompositeHistoryTable impl into EventCompositeHistoryView
** delete obsolete the EventCompositeHistoryTable class
** change EventCompositeHistoryView to implement TableSection instead of Table
* update EventCompositeDetailsView to implement BookmarkableView
** appropriately update View class to instantiate Details view
* expose static factory create methods for resource/group contexts in View class
** remove Resource/Group views in favor of calling static factory create methods
* fix typo in displayName for severity column in EventCompositeDatasource
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
index c7df7f4..40dc105 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
@@ -63,7 +63,7 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
timestamp.setType(FieldType.DATETIME);
addField(timestamp);
- DataSourceTextField severity = new DataSourceTextField("severity", "Servity");
+ DataSourceTextField severity = new DataSourceTextField("severity", "Severity");
addField(severity);
DataSourceTextField details = new HighlightingDatasourceTextField("details", "Details");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
index 600ad2a..343947b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
@@ -22,47 +22,104 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.event;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.TitleOrientation;
-import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
+import org.rhq.core.domain.criteria.EventCriteria;
+import org.rhq.core.domain.event.composite.EventComposite;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
/**
* @author Joseph Marques
*/
-public class EventCompositeDetailsView extends VLayout {
+public class EventCompositeDetailsView extends VLayout implements BookmarkableView {
+
+ private int eventId;
+ private EventComposite composite;
- private ListGridRecord eventRecord;
+ private ViewId viewId;
+
+ public EventCompositeDetailsView(int eventId) {
+ this.eventId = eventId;
+ }
- public EventCompositeDetailsView(ListGridRecord eventRecord) {
- this.eventRecord = eventRecord;
+ public EventCompositeDetailsView(EventComposite composite) {
+ this.composite = composite;
}
@Override
- protected void onInit() {
- super.onInit();
+ protected void onDraw() {
+ super.onDraw();
+
+ for (Canvas child : getMembers()) {
+ child.destroy();
+ }
+
+ if (this.composite != null) {
+ show(composite);
+ } else {
+ show(eventId);
+ }
+ }
+
+ private void show(int eventId) {
+ EventCriteria criteria = new EventCriteria();
+ criteria.addFilterId(eventId);
+ GWTServiceLookup.getEventService().findEventCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<EventComposite>>() {
+ @Override
+ public void onSuccess(PageList<EventComposite> result) {
+ EventComposite composite = result.get(0);
+ show(composite);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failure loading event details", caught);
+ }
+ });
+ }
+
+ private void show(EventComposite composite) {
+ for (Canvas child : getMembers()) {
+ removeChild(child);
+ }
+
+ if (this.viewId != null) {
+ viewId.getBreadcrumbs().get(0).setDisplayName("Event Details");
+ CoreGUI.refreshBreadCrumbTrail();
+ }
+
+ this.composite = composite;
DynamicForm form = new DynamicForm();
form.setWidth100();
form.setHeight100();
StaticTextItem id = new StaticTextItem("id", "Id");
- id.setValue(eventRecord.getAttribute("id"));
+ id.setValue(composite.getEventId());
StaticTextItem severity = new StaticTextItem("severity", "Severity");
- severity.setValue(eventRecord.getAttribute("severity"));
+ severity.setValue(composite.getSeverity().name());
StaticTextItem source = new StaticTextItem("source", "Source");
- source.setValue(eventRecord.getAttribute("source"));
+ source.setValue(composite.getSourceLocation());
StaticTextItem timestamp = new StaticTextItem("timestamp", "Timestamp");
- timestamp.setValue(eventRecord.getAttribute("timestamp"));
+ timestamp.setValue(composite.getTimestamp());
TextAreaItem detail = new TextAreaItem("details", "Details");
- detail.setValue(eventRecord.getAttribute("details"));
+ detail.setValue(composite.getEventDetail());
detail.setTitleOrientation(TitleOrientation.TOP);
detail.setColSpan(2);
detail.setWidth("100%");
@@ -73,20 +130,12 @@ public class EventCompositeDetailsView extends VLayout {
addMember(form);
}
- public void displayInDialog() {
- Window window = new Window();
- window.setTitle("Event Details");
- window.setWidth(800);
- window.setHeight(800);
- window.setIsModal(true);
- window.setShowModalMask(true);
- window.setCanDragResize(true);
- window.centerInPage();
- window.addItem(this);
- window.setDismissOnEscape(true);
- window.setDismissOnOutsideClick(true);
- window.show();
- window.focus();
+ @Override
+ public void renderView(ViewPath viewPath) {
+ eventId = viewPath.getCurrentAsInt();
+ viewId = viewPath.getCurrent();
+
+ show(eventId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java
deleted file mode 100644
index e74a169..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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.inventory.common.event;
-
-import com.smartgwt.client.types.SortDirection;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent;
-import com.smartgwt.client.widgets.grid.events.CellDoubleClickHandler;
-
-import org.rhq.core.domain.common.EntityContext;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-
-/**
- * @author Joseph Marques
- */
-public class EventCompositeHistoryTable extends Table {
-
- public EventCompositeHistoryTable(String tableTitle, EntityContext context) {
- super(tableTitle);
-
- setDataSource(new EventCompositeDatasource(context));
-
- ListGrid grid = getListGrid();
-
- // getListGrid().getField("id").setWidth(60);
-
- grid.getField("timestamp").setWidth(125);
- grid.getField("timestamp").setSortDirection(SortDirection.DESCENDING);
-
- grid.getField("severity").setWidth(75);
- grid.getField("severity").setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o;
- }
- });
-
- grid.getField("source").setWidth(275);
- grid.getField("source").setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- String sourceLocation = (String) o;
- int length = sourceLocation.length();
- if (length > 40) {
- return "..." + sourceLocation.substring(length - 40); // the last 40 chars
- }
- return sourceLocation;
- }
- });
-
- setupTableInteractions();
-
- grid.sort(); // will sort by timestamp, whose default ordering is descending
- }
-
- private void setupTableInteractions() {
- getListGrid().addCellDoubleClickHandler(new CellDoubleClickHandler() {
- public void onCellDoubleClick(CellDoubleClickEvent cellDoubleClickEvent) {
- ListGridRecord record = cellDoubleClickEvent.getRecord();
- EventCompositeDetailsView detailsView = new EventCompositeDetailsView(record);
- detailsView.displayInDialog();
- }
- });
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 3de4d04..b9434f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -26,18 +26,22 @@ import java.util.ArrayList;
import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.MultipleAppearance;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.form.TableFilterForm;
+import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -45,114 +49,130 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
* @author Joseph Marques
*/
-public abstract class EventCompositeHistoryView extends VLayout {
+public class EventCompositeHistoryView extends TableSection {
- private EventCompositeHistoryTable eventCompositeHistoryTable;
- private EntityContext entityContext;
- private boolean permitted;
+ private static SortSpecifier DEFAULT_SORT_SPECIFIER = new SortSpecifier("timestamp", SortDirection.DESCENDING);
+ private EntityContext context;
+ private boolean hasWriteAccess;
- public EventCompositeHistoryView() {
- setWidth100();
- setHeight100();
- setMembersMargin(10);
+ public static EventCompositeHistoryView get(ResourceGroupComposite composite) {
+ String tableTitle = "Group Event History";
+ EntityContext context = EntityContext.forGroup(composite.getResourceGroup().getId());
+ boolean hasWriteAccess = composite.getResourcePermission().isEvent();
+ return new EventCompositeHistoryView(tableTitle, context, hasWriteAccess);
}
- @Override
- protected void onInit() {
- super.onInit();
+ public static EventCompositeHistoryView get(ResourceComposite composite) {
+ String tableTitle = "Resource Event History";
+ EntityContext context = EntityContext.forResource(composite.getResource().getId());
+ boolean hasWriteAccess = composite.getResourcePermission().isEvent();
+ return new EventCompositeHistoryView(tableTitle, context, hasWriteAccess);
+ }
- entityContext = getEntityContext();
- eventCompositeHistoryTable = new EventCompositeHistoryTable(getTableTitle(), entityContext);
- permitted = checkModifyPermission();
+ private EventCompositeHistoryView(String tableTitle, EntityContext context, boolean hasWriteAccess) {
+ super("EventCompositeHistoryTable", tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER });
+ this.context = context;
+ this.hasWriteAccess = hasWriteAccess;
- setupTableFilters();
- setupTableContents();
+ setDataSource(new EventCompositeDatasource(this.context));
}
- private void setupTableFilters() {
- TableFilterForm form = new TableFilterForm(eventCompositeHistoryTable);
-
+ @Override
+ protected void configureTableFilters() {
final TextItem sourceFilter = new TextItem("source", "Source Filter");
final TextItem detailsFilter = new TextItem("details", "Details Filter");
+ final EnumSelectItem severityFilter = new EnumSelectItem("severities", "Severity Filter", EventSeverity.class);
- final SelectItem severityMultiFilter = new SelectItem("severities", "Severity Filter");
- severityMultiFilter.setMultiple(true);
- severityMultiFilter.setMultipleAppearance(MultipleAppearance.PICKLIST);
- String[] severities = new String[EventSeverity.values().length];
- int i = 0;
- for (EventSeverity nextOption : EventSeverity.values()) {
- severities[i++] = nextOption.name();
- }
- severityMultiFilter.setValueMap(severities);
- severityMultiFilter.setValues(severities); // select them all by default
-
- form.setItems(sourceFilter, detailsFilter, severityMultiFilter);
- addMember(form);
+ setFilterFormItems(sourceFilter, detailsFilter, severityFilter);
}
- private void setupTableContents() {
- eventCompositeHistoryTable.addTableAction("deleteButton", "Delete", (permitted) ? SelectionEnablement.ANY
- : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() {
- public void executeAction(ListGridRecord[] selection) {
- deleteButtonPressed(selection);
+ @Override
+ protected void configureTable() {
+ ListGrid grid = getListGrid();
+
+ // getListGrid().getField("id").setWidth(60);
+
+ grid.getField("timestamp").setWidth(125);
+
+ grid.getField("severity").setWidth(75);
+ grid.getField("severity").setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o;
}
});
- eventCompositeHistoryTable.addTableAction("purgeAllButton", "Purge All",
- (permitted) ? SelectionEnablement.ALWAYS : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() {
- public void executeAction(ListGridRecord[] selection) {
- purgeButtonPressed();
+ grid.getField("source").setWidth(275);
+ grid.getField("source").setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String sourceLocation = (String) o;
+ int length = sourceLocation.length();
+ if (length > 40) {
+ return "..." + sourceLocation.substring(length - 40); // the last 40 chars
}
- });
+ return sourceLocation;
+ }
+ });
- addMember(eventCompositeHistoryTable);
+ setupTableInteractions();
}
- protected abstract String getTableTitle();
-
- protected abstract EntityContext getEntityContext();
+ private void setupTableInteractions() {
+ addTableAction("deleteButton", "Delete", hasWriteAccess ? SelectionEnablement.ANY : SelectionEnablement.NEVER,
+ "Are You Sure?", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ deleteButtonPressed(selection);
+ }
+ });
- protected abstract boolean checkModifyPermission();
+ addTableAction("purgeAllButton", "Purge All", hasWriteAccess ? SelectionEnablement.ALWAYS
+ : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ purgeButtonPressed();
+ }
+ });
+ }
private void deleteButtonPressed(ListGridRecord[] selection) {
List<Integer> eventIds = new ArrayList<Integer>();
for (ListGridRecord nextRecord : selection) {
eventIds.add(nextRecord.getAttributeAsInt("id"));
}
- GWTServiceLookup.getEventService().deleteEventsForContext(entityContext, eventIds,
- new AsyncCallback<Integer>() {
- @Override
- public void onSuccess(Integer result) {
- CoreGUI.getMessageCenter().notify(
- new Message("Successfully deleted " + result + " events for " + entityContext.toShortString(),
- Severity.Info));
- eventCompositeHistoryTable.refresh();
- }
+ GWTServiceLookup.getEventService().deleteEventsForContext(context, eventIds, new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Successfully deleted " + result + " events for " + context.toShortString(),
+ Severity.Info));
+ refresh();
+ }
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- "Failed to delete selected events for " + entityContext.toShortString(), caught);
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to delete selected events for " + context.toShortString(), caught);
+ }
+ });
}
private void purgeButtonPressed() {
- GWTServiceLookup.getEventService().purgeEventsForContext(entityContext, new AsyncCallback<Integer>() {
+ GWTServiceLookup.getEventService().purgeEventsForContext(context, new AsyncCallback<Integer>() {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new Message("Successfully purged " + result + " events for " + entityContext.toShortString(),
+ new Message("Successfully purged " + result + " events for " + context.toShortString(),
Severity.Info));
- eventCompositeHistoryTable.refresh();
+ refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to purge events for " + entityContext.toShortString(),
- caught);
+ CoreGUI.getErrorHandler().handleError("Failed to purge events for " + context.toShortString(), caught);
}
});
}
+ @Override
+ public Canvas getDetailsView(int eventId) {
+ return new EventCompositeDetailsView(eventId);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 966e4c6..59997b4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -46,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedE
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.event.GroupEventCompositeHistoryView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView;
@@ -223,7 +223,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
configurationTab.updateSubTab(this.configCurrent);
configurationTab.updateSubTab(this.configHistory);
- this.eventHistory.setCanvas(new GroupEventCompositeHistoryView(groupId));
+ this.eventHistory.setCanvas(EventCompositeHistoryView.get(groupComposite));
eventsTab.updateSubTab(this.eventHistory);
// topTabSet.setSelectedTab(selectedTab);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java
deleted file mode 100644
index 0b24878..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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.inventory.groups.detail.event;
-
-import org.rhq.core.domain.common.EntityContext;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
-
-/**
- * @author Joseph Marques
- */
-public class GroupEventCompositeHistoryView extends EventCompositeHistoryView {
-
- private int groupId;
-
- public GroupEventCompositeHistoryView(int groupId) {
- super();
- this.groupId = groupId;
- }
-
- @Override
- public String getTableTitle() {
- return "Group Event History";
- }
-
- @Override
- public EntityContext getEntityContext() {
- return EntityContext.forGroup(groupId);
- }
-
- @Override
- protected boolean checkModifyPermission() {
- return true; // does the user have Permission.MANAGE_EVENTS ?
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 82c362e..e43ccef 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -45,11 +45,11 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedE
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event.ResourceEventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView;
@@ -269,7 +269,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
configurationTab.updateSubTab(this.configCurrent);
configurationTab.updateSubTab(this.configHistory);
- this.eventHistory.setCanvas(new ResourceEventCompositeHistoryView(resource.getId()));
+ this.eventHistory.setCanvas(EventCompositeHistoryView.get(resourceComposite));
eventsTab.updateSubTab(this.eventHistory);
this.contentDeployed
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java
deleted file mode 100644
index d2fb5d8..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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.inventory.resource.detail.event;
-
-import org.rhq.core.domain.common.EntityContext;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
-
-/**
- * @author Joseph Marques
- */
-public class ResourceEventCompositeHistoryView extends EventCompositeHistoryView {
-
- private int resourceId;
-
- public ResourceEventCompositeHistoryView(int resourceId) {
- super();
- this.resourceId = resourceId;
- }
-
- @Override
- public String getTableTitle() {
- return "Resource Event History";
- }
-
- @Override
- public EntityContext getEntityContext() {
- return EntityContext.forResource(resourceId);
- }
-
- @Override
- protected boolean checkModifyPermission() {
- return true; // does the user have Permission.MANAGE_EVENTS ?
- }
-}
commit 739b97deab7144a1e4d659bbd649dc02f4c976ff
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 02:42:48 2010 -0400
infrastructure component enhancements:
* move TableFilterForm inside Table...rename to TableFilter
* add EnumSelectItem as convenience wrapper for creating multi-select form items
for enums, automatically constructing the value map
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnumSelectItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnumSelectItem.java
new file mode 100644
index 0000000..e1a09fe
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnumSelectItem.java
@@ -0,0 +1,81 @@
+/*
+ * 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.components.form;
+
+import java.util.EnumSet;
+import java.util.LinkedHashMap;
+import java.util.Set;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.smartgwt.client.types.MultipleAppearance;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+
+/**
+ * A convenients class for exposing an {@link Enum} as a multi-select form item.
+ *
+ * @author Joseph Marques
+ */
+public class EnumSelectItem extends SelectItem {
+
+ public EnumSelectItem(Class<? extends Enum<?>> e) {
+ super();
+ init(e);
+ }
+
+ public EnumSelectItem(JavaScriptObject jsObj, Class<? extends Enum<?>> e) {
+ super(jsObj);
+ init(e);
+ }
+
+ public EnumSelectItem(String name, Class<? extends Enum<?>> e) {
+ super(name);
+ init(e);
+ }
+
+ public EnumSelectItem(String name, String title, Class<? extends Enum<?>> e) {
+ super(name, title);
+ init(e);
+ }
+
+ public void init(Class<? extends Enum<?>> e) {
+ setMultiple(true);
+ setMultipleAppearance(MultipleAppearance.PICKLIST);
+
+ LinkedHashMap<String, String> valueMap = getEnumValueMap(e);
+ Set<String> keys = valueMap.keySet();
+
+ setValueMap(valueMap);
+ setValues(keys.toArray(new String[keys.size()])); // select them all by default
+ }
+
+ @SuppressWarnings("unchecked")
+ private LinkedHashMap<String, String> getEnumValueMap(Class<? extends Enum> e) {
+ LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
+ for (Object o : EnumSet.allOf(e)) {
+ Enum v = (Enum) o;
+ map.put(v.name(), v.toString());
+ }
+ return map;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java
deleted file mode 100644
index 8687ea5..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.components.form;
-
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
-import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
-
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-
-/**
- * A subclass of SmartGWT's DynamicForm widget that provides a more convenient interface for filtering a {@link Table}
- * of results.
- *
- * @author Joseph Marques
- */
-public class TableFilterForm extends DynamicForm implements KeyPressHandler, ChangedHandler {
-
- private Table table;
-
- public TableFilterForm(Table table) {
- super();
- setWidth100();
- this.table = table;
- this.table.setTableTitle(null);
- }
-
- @Override
- public void setItems(FormItem... items) {
- super.setItems(items);
- setupFormItems(items);
- }
-
- private void setupFormItems(FormItem... formItems) {
- for (FormItem nextFormItem : formItems) {
- nextFormItem.setWrapTitle(false);
- nextFormItem.setWidth(300); // wider than default
- if (nextFormItem instanceof TextItem) {
- nextFormItem.addKeyPressHandler(this);
- } else if (nextFormItem instanceof SelectItem) {
- nextFormItem.addChangedHandler(this);
- }
- }
- }
-
- private void fetchFilteredTableData() {
- table.refresh(getValuesAsCriteria());
- }
-
- public void onKeyPress(KeyPressEvent event) {
- if (event.getKeyName().equals("Enter") == false) {
- return;
- }
- fetchFilteredTableData();
- }
-
- public void onChanged(ChangedEvent event) {
- fetchFilteredTableData();
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index c26ccef..a18d6f8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -35,6 +35,14 @@ import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
+import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
@@ -65,6 +73,7 @@ public class Table extends LocatableHLayout {
private HLayout titleLayout;
private Canvas titleComponent;
+ private TableFilter filterForm;
private ListGrid listGrid;
private ToolStrip footer;
private Label tableInfo;
@@ -157,6 +166,9 @@ public class Table extends LocatableHLayout {
protected void onInit() {
super.onInit();
+ filterForm = new TableFilter(this);
+ configureTableFilters();
+
listGrid = new LocatableListGrid(getLocatorId());
listGrid.setAutoFetchData(autoFetchData);
@@ -216,6 +228,10 @@ public class Table extends LocatableHLayout {
contents.addMember(titleLayout, 0);
}
+ if (filterForm.hasContent()) {
+ contents.addMember(filterForm);
+ }
+
contents.addMember(listGrid);
// Footer
@@ -324,6 +340,18 @@ public class Table extends LocatableHLayout {
}
}
+ public void setFilterFormItems(FormItem... formItems) {
+ this.filterForm.setItems(formItems);
+ }
+
+ /**
+ * Overriding components can use this as a chance to add {@link FormItem}s which will filter
+ * the table that displays their data.
+ */
+ protected void configureTableFilters() {
+
+ }
+
/**
* Overriding components can use this as a chance to configure the list grid after it has been
* created but before it has been drawn to the DOM. This is also the proper place to add table
@@ -480,7 +508,63 @@ public class Table extends LocatableHLayout {
}
}
- // -------------- Inner utility class -------------
+ // -------------- Inner utility classes ------------- //
+
+ /**
+ * A subclass of SmartGWT's DynamicForm widget that provides a more convenient interface for filtering a {@link Table}
+ * of results.
+ *
+ * @author Joseph Marques
+ */
+ private static class TableFilter extends DynamicForm implements KeyPressHandler, ChangedHandler {
+
+ private Table table;
+
+ public TableFilter(Table table) {
+ super();
+ setWidth100();
+ this.table = table;
+ //this.table.setTableTitle(null);
+ }
+
+ @Override
+ public void setItems(FormItem... items) {
+ super.setItems(items);
+ setupFormItems(items);
+ }
+
+ private void setupFormItems(FormItem... formItems) {
+ for (FormItem nextFormItem : formItems) {
+ nextFormItem.setWrapTitle(false);
+ nextFormItem.setWidth(300); // wider than default
+ if (nextFormItem instanceof TextItem) {
+ nextFormItem.addKeyPressHandler(this);
+ } else if (nextFormItem instanceof SelectItem) {
+ nextFormItem.addChangedHandler(this);
+ }
+ }
+ }
+
+ private void fetchFilteredTableData() {
+ table.refresh(getValuesAsCriteria());
+ }
+
+ public void onKeyPress(KeyPressEvent event) {
+ if (event.getKeyName().equals("Enter") == false) {
+ return;
+ }
+ fetchFilteredTableData();
+ }
+
+ public void onChanged(ChangedEvent event) {
+ fetchFilteredTableData();
+ }
+
+ public boolean hasContent() {
+ return super.getFields().length != 0;
+ }
+
+ }
private static class TableActionInfo {
commit 96ecc5267928948c3c96123b5e05f715c7dcbbbf
Author: Joseph Marques <joseph(a)redhat.com>
Date: Fri Aug 27 02:36:46 2010 -0400
expose the new MANAGE_EVENTS permission to the ResourceComposite level
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index 40deb43..916bcc7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -568,6 +568,7 @@ import org.rhq.core.domain.util.Summary;
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 4), " // we want MODIFY_RESOURCE (4), not VIEW_RESOURCE (3)
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 10), " // we want CONTROL, 10
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 7), " // we want MANAGE_ALERTS, 7
+ + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 14), " // we want MANAGE_EVENTS, 14
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 13), " // we want CONFIGURE_READ, 13
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 11), " // we want CONFIGURE_WRITE, 11
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 9), " // we want MANAGE_CONTENT, 9
@@ -590,6 +591,7 @@ import org.rhq.core.domain.util.Summary;
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 4), " // we want MODIFY_RESOURCE (4), not VIEW_RESOURCE (3)
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 10), " // we want CONTROL, 10
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 7), " // we want MANAGE_ALERTS, 7
+ + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 14), " // we want MANAGE_EVENTS, 14
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 13), " // we want CONFIGURE_READ, 13
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 11), " // we want CONFIGURE_WRITE, 11
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 9), " // we want MANAGE_CONTENT, 9
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java
index 823a785..9f22d68 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java
@@ -74,22 +74,24 @@ public class ResourceComposite implements Serializable {
* Provides specified permissions - used for non-admin queries.
*/
public ResourceComposite(Resource resource, AvailabilityType availability, Number measure, Number inventory,
- Number control, Number alert, Number configureRead, Number configureWrite, Number content,
+ Number control, Number alert, Number event, Number configureRead, Number configureWrite, Number content,
Number createChildResources, Number deleteResources) {
this(resource, null, availability, new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0,
- control.intValue() > 0, alert.intValue() > 0, configureRead.intValue() > 0, configureWrite.intValue() > 0,
- content.intValue() > 0, createChildResources.intValue() > 0, deleteResources.intValue() > 0));
+ control.intValue() > 0, alert.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0,
+ configureWrite.intValue() > 0, content.intValue() > 0, createChildResources.intValue() > 0, deleteResources
+ .intValue() > 0));
}
/**
* Provides specified permissions - used for non-admin queries.
*/
public ResourceComposite(Resource resource, Resource parent, AvailabilityType availability, Number measure,
- Number inventory, Number control, Number alert, Number configureRead, Number configureWrite, Number content,
- Number createChildResources, Number deleteResources) {
+ Number inventory, Number control, Number alert, Number event, Number configureRead, Number configureWrite,
+ Number content, Number createChildResources, Number deleteResources) {
this(resource, parent, availability, new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0,
- control.intValue() > 0, alert.intValue() > 0, configureRead.intValue() > 0, configureWrite.intValue() > 0,
- content.intValue() > 0, createChildResources.intValue() > 0, deleteResources.intValue() > 0));
+ control.intValue() > 0, alert.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0,
+ configureWrite.intValue() > 0, content.intValue() > 0, createChildResources.intValue() > 0, deleteResources
+ .intValue() > 0));
}
/**
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java
index ee8e8a8..e75fa14 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java
@@ -43,6 +43,8 @@ public class ResourcePermission implements Serializable {
private boolean alert;
+ private boolean event;
+
private boolean configureRead;
private boolean configureWrite;
@@ -57,7 +59,7 @@ public class ResourcePermission implements Serializable {
* All permissions
*/
public ResourcePermission() {
- this(true, true, true, true, true, true, true, true, true);
+ this(true, true, true, true, true, true, true, true, true, true);
}
public ResourcePermission(//
@@ -65,6 +67,7 @@ public class ResourcePermission implements Serializable {
boolean inventory, //
boolean control, //
boolean alert, //
+ boolean event, //
boolean configureRead, //
boolean configureWrite, //
boolean content, //
@@ -74,6 +77,7 @@ public class ResourcePermission implements Serializable {
this.inventory = inventory;
this.control = control;
this.alert = alert;
+ this.event = event;
this.configureRead = configureRead;
this.configureWrite = configureWrite;
this.content = content;
@@ -86,6 +90,7 @@ public class ResourcePermission implements Serializable {
permissions.contains(Permission.MODIFY_RESOURCE),//
permissions.contains(Permission.CONTROL), //
permissions.contains(Permission.MANAGE_ALERTS), //
+ permissions.contains(Permission.MANAGE_EVENTS), //
permissions.contains(Permission.CONFIGURE_READ), //
permissions.contains(Permission.CONFIGURE_WRITE), //
permissions.contains(Permission.MANAGE_CONTENT), //
@@ -109,6 +114,10 @@ public class ResourcePermission implements Serializable {
return alert;
}
+ public boolean isEvent() {
+ return event;
+ }
+
public boolean isConfigureRead() {
return configureRead;
}
@@ -136,6 +145,7 @@ public class ResourcePermission implements Serializable {
"inventory: " + inventory + ", " + //
"control: " + control + ", " + //
"alert: " + alert + ", " + //
+ "event: " + event + ", " + //
"configure-read: " + configureRead + ", " + //
"configure-write: " + configureWrite + ", " + //
"content: " + content + ", " + //
commit db9494f4420d200904fe7a694e9a8acc8dd75f1f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Aug 25 16:42:28 2010 -0400
change JSP import to use new location of EntityContext
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp
index 0bad7a1..5b4320e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp
@@ -1,4 +1,5 @@
<%@ page import="org.rhq.core.domain.auth.Subject" %>
+<%@ page import="org.rhq.core.domain.common.EntityContext"%>
<%@ page import="org.rhq.core.domain.event.composite.EventComposite" %>
<%@ page import="org.rhq.core.domain.util.OrderingField" %>
<%@ page import="org.rhq.core.domain.util.PageControl" %>
@@ -14,7 +15,6 @@
<%@ page import="java.util.regex.Pattern"%>
<%@ page import="java.util.*"%>
<%@ page import="org.rhq.core.domain.event.EventSeverity"%>
-<%@ page import="org.rhq.enterprise.server.common.EntityContext"%>
<%@ page import="org.rhq.core.domain.util.PageOrdering"%>
<%@ page contentType="text/javascript" language="java" %>
commit 70795ef4e1a29f10e562f4f6b7f386e52127cd56
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Aug 25 11:25:29 2010 -0400
add locatorID for buttons to adhere to modified API for addTableAction
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index ea5cd03..3de4d04 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -91,19 +91,19 @@ public abstract class EventCompositeHistoryView extends VLayout {
}
private void setupTableContents() {
- eventCompositeHistoryTable.addTableAction("Delete", (permitted) ? SelectionEnablement.ANY
+ eventCompositeHistoryTable.addTableAction("deleteButton", "Delete", (permitted) ? SelectionEnablement.ANY
: SelectionEnablement.NEVER, "Are You Sure?", new TableAction() {
public void executeAction(ListGridRecord[] selection) {
deleteButtonPressed(selection);
}
});
- eventCompositeHistoryTable.addTableAction("Purge All", (permitted) ? SelectionEnablement.ALWAYS
- : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() {
- public void executeAction(ListGridRecord[] selection) {
- purgeButtonPressed();
- }
- });
+ eventCompositeHistoryTable.addTableAction("purgeAllButton", "Purge All",
+ (permitted) ? SelectionEnablement.ALWAYS : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ purgeButtonPressed();
+ }
+ });
addMember(eventCompositeHistoryTable);
}
commit d3db6bf1337204344e59a0938fc5e74d0419bc06
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Aug 25 09:47:29 2010 -0400
improve error message handling when failing to log into coregui
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index d534aca..82d010d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -58,7 +58,6 @@ public class LoginView extends Canvas {
private SubmitItem loginButton;
-
public LoginView() {
this(false);
}
@@ -97,7 +96,6 @@ public class LoginView extends Canvas {
HeaderItem header = new HeaderItem();
header.setValue("RHQ Login");
-
TextItem user = new TextItem("user", "User");
user.setRequired(true);
user.setAttribute("autoComplete", "native");
@@ -126,7 +124,6 @@ public class LoginView extends Canvas {
form.setFields(logo, header, user, password, loginButton);
-
window = new Window();
window.setTitle("RHQ Login");
window.setWidth(400);
@@ -158,38 +155,35 @@ public class LoginView extends Canvas {
}
loginButton.setDisabled(true);
- RequestBuilder b = new RequestBuilder(RequestBuilder.GET,
- "/j_security_check.do?j_username=" + user + "&j_password=" + password);
+
try {
+ RequestBuilder b = new RequestBuilder(RequestBuilder.GET, "/j_security_check.do?j_username=" + user
+ + "&j_password=" + password);
b.setCallback(new RequestCallback() {
public void onResponseReceived(Request request, Response response) {
- if (response.getStatusCode() == 200) {
- System.out.println("Portal-War logged in");
+ int statusCode = response.getStatusCode();
+ if (statusCode == 200) {
window.destroy();
loginShowing = false;
CoreGUI.checkLoginStatus();
} else {
- form.setFieldErrors("login", "The username or password provided does not match our records.", true);
- loginButton.setDisabled(false);
+ handleError(statusCode);
}
}
public void onError(Request request, Throwable exception) {
- System.out.println("Portal-War login failed");
- loginButton.setDisabled(false);
+ handleError(0);
}
});
b.send();
} catch (Exception e) {
- loginButton.setDisabled(false);
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ handleError(0);
} finally {
if (CoreGUI.detectIe6()) {
CoreGUI.unforceIe6Hacks();
}
}
-
/*
SubjectGWTServiceAsync subjectService = SubjectGWTServiceAsync.Util.getInstance();
@@ -205,16 +199,25 @@ public class LoginView extends Canvas {
CoreGUI.setSessionSubject(result);
*//* We can cache all metadata right here
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
(Integer[]) null, EnumSet.allOf(ResourceTypeRepository.MetadataType.class), new ResourceTypeRepository.TypesLoadedCallback() {
public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
System.out.println("Preloaded [" + types.size() + "] resource types");
buildCoreUI();
}
- });
- *//*
- }
- }); */
+ });
+ *//*
+ }
+ }); */
+
+ }
+ private void handleError(int statusCode) {
+ if (statusCode == 401) {
+ form.setFieldErrors("login", "The username or password provided does not match our records", true);
+ } else {
+ form.setFieldErrors("login", "The server could data source is unavailable", true);
+ }
+ loginButton.setDisabled(false);
}
}
commit ee01ad67f5fd45bed6589a48dea84129c5096617
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 22:18:17 2010 -0400
concrete implementation of event>history sub-tab for groups (mixed and compat)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index d8f83ab..966e4c6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -46,6 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedE
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedHandler;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.event.GroupEventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView;
@@ -198,6 +199,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId));
inventoryTab.updateSubTab(this.inventoryMembers);
+
// inventoryTab.updateSubTab("Connection Settings", new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId="
@@ -221,7 +223,7 @@ public class ResourceGroupDetailView extends LocatableVLayout implements Bookmar
configurationTab.updateSubTab(this.configCurrent);
configurationTab.updateSubTab(this.configHistory);
- this.eventHistory.setCanvas(new FullHTMLPane("/rhq/group/events/history-plain.xhtml?groupId=" + groupId));
+ this.eventHistory.setCanvas(new GroupEventCompositeHistoryView(groupId));
eventsTab.updateSubTab(this.eventHistory);
// topTabSet.setSelectedTab(selectedTab);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java
new file mode 100644
index 0000000..0b24878
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/event/GroupEventCompositeHistoryView.java
@@ -0,0 +1,54 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.inventory.groups.detail.event;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
+
+/**
+ * @author Joseph Marques
+ */
+public class GroupEventCompositeHistoryView extends EventCompositeHistoryView {
+
+ private int groupId;
+
+ public GroupEventCompositeHistoryView(int groupId) {
+ super();
+ this.groupId = groupId;
+ }
+
+ @Override
+ public String getTableTitle() {
+ return "Group Event History";
+ }
+
+ @Override
+ public EntityContext getEntityContext() {
+ return EntityContext.forGroup(groupId);
+ }
+
+ @Override
+ protected boolean checkModifyPermission() {
+ return true; // does the user have Permission.MANAGE_EVENTS ?
+ }
+}
commit c7596b299f47773f2dabc92a22b918b5d01c7f36
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 22:17:55 2010 -0400
concrete implementation of event>history sub-tab for resources
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index f0e1c3f..82c362e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.event.ResourceEventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.GraphListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView;
@@ -202,9 +203,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
this.titleBar.setResource(resource);
for (Tab top : topTabSet.getTabs()) {
-
((TwoLevelTab) top).getLayout().destroyViews();
-
}
this.summaryOverview.setCanvas(new OverviewView(this.resourceComposite));
@@ -239,10 +238,10 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
// 1) user can delete history if they possess the appropriate permissions
// 2) user can see both operation arguments and results in the history details pop-up
// 3) operation arguments/results become read-only configuration data in the history details pop-up
- // 4) user can navigate to the group operation that spawned this resource operation history, if appropriate
+ // 4) user can navigate to the group operation that spawned this resource operation history, if appropriate
+ // note: enabled operation execution/schedules from left-nav, if it doesn't already exist
this.opHistory.setCanvas(OperationHistoryView.getResourceHistoryView(operationsTab.extendLocatorId("History"),
resourceComposite));
- // note: enabled operation execution/schedules from left-nav, if it doesn't already exist
this.opSched.setCanvas(new FullHTMLPane("/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id="
+ resource.getId()));
operationsTab.updateSubTab(this.opHistory);
@@ -254,7 +253,6 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
// 3) user can enable/disable/delete alert definitions if they possess the appropriate permissions
// 4) user can search alert history by: date alert was fired, alert priority, or alert definition
//alertsTab.updateSubTab("History", new ResourceAlertHistoryView(resource.getId()));
-
this.alertHistory.setCanvas(new FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id="
+ resource.getId()));
this.alertDef.setCanvas(new ResourceAlertDefinitionsView(alertsTab.extendLocatorId("Def"), resource));
@@ -271,13 +269,7 @@ public class ResourceDetailView extends LocatableVLayout implements Bookmarkable
configurationTab.updateSubTab(this.configCurrent);
configurationTab.updateSubTab(this.configHistory);
- // comment out GWT-based view until...
- // 1) user can search event history by: metric display range, event source, event details, event severity
- // 2) user can delete events if they possess the appropriate permissions
- //eventsTab.updateSubTab("History", EventHistoryView.createResourceHistoryView(resource.getId()));
-
- this.eventHistory
- .setCanvas(new FullHTMLPane("/rhq/resource/events/history-plain.xhtml?id=" + resource.getId()));
+ this.eventHistory.setCanvas(new ResourceEventCompositeHistoryView(resource.getId()));
eventsTab.updateSubTab(this.eventHistory);
this.contentDeployed
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java
new file mode 100644
index 0000000..d2fb5d8
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/ResourceEventCompositeHistoryView.java
@@ -0,0 +1,54 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.inventory.resource.detail.event;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
+
+/**
+ * @author Joseph Marques
+ */
+public class ResourceEventCompositeHistoryView extends EventCompositeHistoryView {
+
+ private int resourceId;
+
+ public ResourceEventCompositeHistoryView(int resourceId) {
+ super();
+ this.resourceId = resourceId;
+ }
+
+ @Override
+ public String getTableTitle() {
+ return "Resource Event History";
+ }
+
+ @Override
+ public EntityContext getEntityContext() {
+ return EntityContext.forResource(resourceId);
+ }
+
+ @Override
+ protected boolean checkModifyPermission() {
+ return true; // does the user have Permission.MANAGE_EVENTS ?
+ }
+}
commit abd053238b39a75051638bb1923f8d68094b6c83
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 22:17:29 2010 -0400
reusable base classes for event>history views
* supports full feature parity with existing JSF views including
sorting, scrolling (pagination), and filtering, and table actions
* filtering support: event details, event source/location, event severity
* table actions support: delete selected events, purge all events for
the given context (resource, group, auto-group), double-click row item
displays modal panel with full details in a large text area input
* enhancement: will highlight in-line matches for event details filter
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
new file mode 100644
index 0000000..c7df7f4
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
@@ -0,0 +1,147 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.inventory.common.event;
+
+import java.util.Map;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.rpc.RPCResponse;
+import com.smartgwt.client.types.FieldType;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.EventCriteria;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.event.composite.EventComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.HighlightingDatasourceTextField;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Joseph Marques
+ */
+public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
+
+ private EntityContext entityContext;
+
+ public EventCompositeDatasource(EntityContext context) {
+ super();
+ this.entityContext = context;
+
+ // DataSourceField id = new DataSourceIntegerField("id", "Id");
+ // id.setPrimaryKey(true);
+ // addField(id);
+
+ DataSourceTextField timestamp = new DataSourceTextField("timestamp", "Timestamp");
+ timestamp.setType(FieldType.DATETIME);
+ addField(timestamp);
+
+ DataSourceTextField severity = new DataSourceTextField("severity", "Servity");
+ addField(severity);
+
+ DataSourceTextField details = new HighlightingDatasourceTextField("details", "Details");
+ addField(details);
+
+ DataSourceTextField sourceLocation = new DataSourceTextField("source", "Source Location");
+ addField(sourceLocation);
+ }
+
+ @Override
+ public EventComposite copyValues(ListGridRecord from) {
+ return null; // TODO: Implement this method.
+ }
+
+ @Override
+ public ListGridRecord copyValues(EventComposite from) {
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute("id", from.getEventId());
+ record.setAttribute("timestamp", from.getTimestamp());
+ record.setAttribute("details", from.getEventDetail());
+ record.setAttribute("severity", from.getSeverity().name());
+ record.setAttribute("source", from.getSourceLocation());
+
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ EventCriteria criteria = getFetchCriteria(request);
+
+ GWTServiceLookup.getEventService().findEventCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<EventComposite>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load event data", caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ }
+
+ public void onSuccess(PageList<EventComposite> result) {
+ ListGridRecord[] records = buildRecords(result);
+ highlightFilterMatches(request, records);
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ protected EventCriteria getFetchCriteria(final DSRequest request) {
+ EventCriteria criteria = new EventCriteria();
+
+ PageControl pageControl = getPageControl(request);
+ if (pageControl.getOrderingFields().isEmpty()) {
+ criteria.addSortTimestamp(PageOrdering.DESC); // default sort
+ } else {
+ criteria.setPageControl(pageControl);
+ }
+
+ // TODO: This call is broken in 2.2, http://code.google.com/p/smartgwt/issues/detail?id=490
+ // when using AdvancedCriteria
+ Map<String, Object> criteriaMap = request.getCriteria().getValues();
+
+ criteria.addFilterSourceName((String) criteriaMap.get("source"));
+ criteria.addFilterDetail((String) criteriaMap.get("details"));
+
+ if (criteriaMap.get("severities") != null) {
+ String[] severityStrings = criteriaMap.get("severities").toString().split(",");
+ EventSeverity[] severities = new EventSeverity[severityStrings.length];
+ int i = 0;
+ for (String nextSeverity : severityStrings) {
+ severities[i++] = EventSeverity.valueOf(nextSeverity);
+ }
+ criteria.addFilterSeverities(severities);
+ }
+
+ criteria.addFilterEntityContext(entityContext);
+
+ return criteria;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
new file mode 100644
index 0000000..600ad2a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
@@ -0,0 +1,92 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.inventory.common.event;
+
+import com.smartgwt.client.types.TitleOrientation;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+/**
+ * @author Joseph Marques
+ */
+public class EventCompositeDetailsView extends VLayout {
+
+ private ListGridRecord eventRecord;
+
+ public EventCompositeDetailsView(ListGridRecord eventRecord) {
+ this.eventRecord = eventRecord;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ DynamicForm form = new DynamicForm();
+ form.setWidth100();
+ form.setHeight100();
+
+ StaticTextItem id = new StaticTextItem("id", "Id");
+ id.setValue(eventRecord.getAttribute("id"));
+
+ StaticTextItem severity = new StaticTextItem("severity", "Severity");
+ severity.setValue(eventRecord.getAttribute("severity"));
+
+ StaticTextItem source = new StaticTextItem("source", "Source");
+ source.setValue(eventRecord.getAttribute("source"));
+
+ StaticTextItem timestamp = new StaticTextItem("timestamp", "Timestamp");
+ timestamp.setValue(eventRecord.getAttribute("timestamp"));
+
+ TextAreaItem detail = new TextAreaItem("details", "Details");
+ detail.setValue(eventRecord.getAttribute("details"));
+ detail.setTitleOrientation(TitleOrientation.TOP);
+ detail.setColSpan(2);
+ detail.setWidth("100%");
+ detail.setHeight("100%");
+
+ form.setItems(id, severity, source, timestamp, detail);
+
+ addMember(form);
+ }
+
+ public void displayInDialog() {
+ Window window = new Window();
+ window.setTitle("Event Details");
+ window.setWidth(800);
+ window.setHeight(800);
+ window.setIsModal(true);
+ window.setShowModalMask(true);
+ window.setCanDragResize(true);
+ window.centerInPage();
+ window.addItem(this);
+ window.setDismissOnEscape(true);
+ window.setDismissOnOutsideClick(true);
+ window.show();
+ window.focus();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java
new file mode 100644
index 0000000..e74a169
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryTable.java
@@ -0,0 +1,86 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.inventory.common.event;
+
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent;
+import com.smartgwt.client.widgets.grid.events.CellDoubleClickHandler;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+
+/**
+ * @author Joseph Marques
+ */
+public class EventCompositeHistoryTable extends Table {
+
+ public EventCompositeHistoryTable(String tableTitle, EntityContext context) {
+ super(tableTitle);
+
+ setDataSource(new EventCompositeDatasource(context));
+
+ ListGrid grid = getListGrid();
+
+ // getListGrid().getField("id").setWidth(60);
+
+ grid.getField("timestamp").setWidth(125);
+ grid.getField("timestamp").setSortDirection(SortDirection.DESCENDING);
+
+ grid.getField("severity").setWidth(75);
+ grid.getField("severity").setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o;
+ }
+ });
+
+ grid.getField("source").setWidth(275);
+ grid.getField("source").setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String sourceLocation = (String) o;
+ int length = sourceLocation.length();
+ if (length > 40) {
+ return "..." + sourceLocation.substring(length - 40); // the last 40 chars
+ }
+ return sourceLocation;
+ }
+ });
+
+ setupTableInteractions();
+
+ grid.sort(); // will sort by timestamp, whose default ordering is descending
+ }
+
+ private void setupTableInteractions() {
+ getListGrid().addCellDoubleClickHandler(new CellDoubleClickHandler() {
+ public void onCellDoubleClick(CellDoubleClickEvent cellDoubleClickEvent) {
+ ListGridRecord record = cellDoubleClickEvent.getRecord();
+ EventCompositeDetailsView detailsView = new EventCompositeDetailsView(record);
+ detailsView.displayInDialog();
+ }
+ });
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
new file mode 100644
index 0000000..ea5cd03
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -0,0 +1,158 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.inventory.common.event;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.MultipleAppearance;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.TableFilterForm;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
+
+/**
+ * @author Joseph Marques
+ */
+public abstract class EventCompositeHistoryView extends VLayout {
+
+ private EventCompositeHistoryTable eventCompositeHistoryTable;
+ private EntityContext entityContext;
+ private boolean permitted;
+
+ public EventCompositeHistoryView() {
+ setWidth100();
+ setHeight100();
+ setMembersMargin(10);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ entityContext = getEntityContext();
+ eventCompositeHistoryTable = new EventCompositeHistoryTable(getTableTitle(), entityContext);
+ permitted = checkModifyPermission();
+
+ setupTableFilters();
+ setupTableContents();
+ }
+
+ private void setupTableFilters() {
+ TableFilterForm form = new TableFilterForm(eventCompositeHistoryTable);
+
+ final TextItem sourceFilter = new TextItem("source", "Source Filter");
+ final TextItem detailsFilter = new TextItem("details", "Details Filter");
+
+ final SelectItem severityMultiFilter = new SelectItem("severities", "Severity Filter");
+ severityMultiFilter.setMultiple(true);
+ severityMultiFilter.setMultipleAppearance(MultipleAppearance.PICKLIST);
+ String[] severities = new String[EventSeverity.values().length];
+ int i = 0;
+ for (EventSeverity nextOption : EventSeverity.values()) {
+ severities[i++] = nextOption.name();
+ }
+ severityMultiFilter.setValueMap(severities);
+ severityMultiFilter.setValues(severities); // select them all by default
+
+ form.setItems(sourceFilter, detailsFilter, severityMultiFilter);
+ addMember(form);
+ }
+
+ private void setupTableContents() {
+ eventCompositeHistoryTable.addTableAction("Delete", (permitted) ? SelectionEnablement.ANY
+ : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ deleteButtonPressed(selection);
+ }
+ });
+
+ eventCompositeHistoryTable.addTableAction("Purge All", (permitted) ? SelectionEnablement.ALWAYS
+ : SelectionEnablement.NEVER, "Are You Sure?", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ purgeButtonPressed();
+ }
+ });
+
+ addMember(eventCompositeHistoryTable);
+ }
+
+ protected abstract String getTableTitle();
+
+ protected abstract EntityContext getEntityContext();
+
+ protected abstract boolean checkModifyPermission();
+
+ private void deleteButtonPressed(ListGridRecord[] selection) {
+ List<Integer> eventIds = new ArrayList<Integer>();
+ for (ListGridRecord nextRecord : selection) {
+ eventIds.add(nextRecord.getAttributeAsInt("id"));
+ }
+ GWTServiceLookup.getEventService().deleteEventsForContext(entityContext, eventIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Successfully deleted " + result + " events for " + entityContext.toShortString(),
+ Severity.Info));
+ eventCompositeHistoryTable.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ "Failed to delete selected events for " + entityContext.toShortString(), caught);
+ }
+ });
+ }
+
+ private void purgeButtonPressed() {
+ GWTServiceLookup.getEventService().purgeEventsForContext(entityContext, new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Successfully purged " + result + " events for " + entityContext.toShortString(),
+ Severity.Info));
+ eventCompositeHistoryTable.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to purge events for " + entityContext.toShortString(),
+ caught);
+ }
+ });
+ }
+
+}
commit 81cb060f2bae643bf13f6f8cf1a65a6cace1723e
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 22:12:41 2010 -0400
reformat, cosmetic
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
index 15c25b0..5846d8d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
@@ -22,8 +22,11 @@
*/
package org.rhq.enterprise.gui.coregui.client.gwt;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.RemoteService;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSeverity;
@@ -36,29 +39,18 @@ import org.rhq.core.domain.util.PageList;
*/
public interface EventGWTService extends RemoteService {
+ EventSeverity[] getSeverityBuckets(int resourceId, long begin, long end, int numBuckets);
+
+ EventSeverity[] getSeverityBucketsForAutoGroup(int parentResourceId, int resourceTypeId, long begin, long end,
+ int numBuckets);
- EventSeverity[] getSeverityBuckets(
- int resourceId,
- long begin,
- long end,
- int numBuckets);
+ EventSeverity[] getSeverityBucketsForCompGroup(int resourceGroupId, long begin, long end, int numBuckets);
PageList<Event> findEventsByCriteria(EventCriteria criteria);
- EventSeverity[] getSeverityBucketsForAutoGroup(
- int parentResourceId,
- int resourceTypeId,
- long begin,
- long end,
- int numBuckets);
PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria);
- EventSeverity[] getSeverityBucketsForCompGroup(
int deleteEventsForContext(EntityContext context, List<Integer> eventIds);
- int resourceGroupId,
- long begin,
- long end,
- int numBuckets);
int purgeEventsForContext(EntityContext context);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
index f61b617..665f370 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
@@ -41,31 +41,29 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements EventGWTService {
- private EventManagerLocal eventManager = LookupUtil.getEventManager();
+ private static final long serialVersionUID = 1L;
+ private EventManagerLocal eventManager = LookupUtil.getEventManager();
public EventSeverity[] getSeverityBuckets(int resourceId, long begin, long end, int numBuckets) {
- return SerialUtility.prepare(
- eventManager.getSeverityBuckets(getSessionSubject(), resourceId, begin, end, numBuckets),
- "EventService.getSeverityBuckets");
+ return SerialUtility.prepare(eventManager.getSeverityBuckets(getSessionSubject(), resourceId, begin, end,
+ numBuckets), "EventService.getSeverityBuckets");
}
- public EventSeverity[] getSeverityBucketsForAutoGroup(int parentResourceId, int resourceTypeId, long begin, long end, int numBuckets) {
- return SerialUtility.prepare(
- eventManager.getSeverityBucketsForAutoGroup(getSessionSubject(), parentResourceId, resourceTypeId, begin, end, numBuckets),
- "EventService.getSeverityBucketsForAutoGroup");
+ public EventSeverity[] getSeverityBucketsForAutoGroup(int parentResourceId, int resourceTypeId, long begin,
+ long end, int numBuckets) {
+ return SerialUtility.prepare(eventManager.getSeverityBucketsForAutoGroup(getSessionSubject(), parentResourceId,
+ resourceTypeId, begin, end, numBuckets), "EventService.getSeverityBucketsForAutoGroup");
}
public EventSeverity[] getSeverityBucketsForCompGroup(int resourceGroupId, long begin, long end, int numBuckets) {
- return SerialUtility.prepare(
- eventManager.getSeverityBucketsForCompGroup(getSessionSubject(), resourceGroupId, begin, end, numBuckets),
- "EventService.getSeverityBucketsForCompGroup");
- }
+ return SerialUtility.prepare(eventManager.getSeverityBucketsForCompGroup(getSessionSubject(), resourceGroupId,
+ begin, end, numBuckets), "EventService.getSeverityBucketsForCompGroup");
+ }
public PageList<Event> findEventsByCriteria(EventCriteria criteria) {
- return SerialUtility.prepare(
- eventManager.findEventsByCriteria(getSessionSubject(), criteria),
- "EventService.findEventsByCriteria");
+ return SerialUtility.prepare(eventManager.findEventsByCriteria(getSessionSubject(), criteria),
+ "EventService.findEventsByCriteria");
}
public PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria) {
commit efaa7ce2368c536aa685a8120ab39a64b280332c
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 22:12:23 2010 -0400
add delete/purge methods to EventGWTService** classes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
index 1b8c87f..15c25b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
@@ -43,6 +43,7 @@ public interface EventGWTService extends RemoteService {
long end,
int numBuckets);
+ PageList<Event> findEventsByCriteria(EventCriteria criteria);
EventSeverity[] getSeverityBucketsForAutoGroup(
int parentResourceId,
int resourceTypeId,
@@ -53,10 +54,11 @@ public interface EventGWTService extends RemoteService {
PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria);
EventSeverity[] getSeverityBucketsForCompGroup(
+ int deleteEventsForContext(EntityContext context, List<Integer> eventIds);
int resourceGroupId,
long begin,
long end,
int numBuckets);
- PageList<Event> findEventsByCriteria(EventCriteria criteria);
+ int purgeEventsForContext(EntityContext context);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
index 957d9c2..f61b617 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
@@ -22,6 +22,9 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import java.util.List;
+
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSeverity;
@@ -69,4 +72,13 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
return SerialUtility.prepare(eventManager.findEventCompositesByCriteria(getSessionSubject(), criteria),
"EventService.findEventsByCriteria");
}
+
+ public int deleteEventsForContext(EntityContext context, List<Integer> eventIds) {
+ return eventManager.deleteEventsForContext(getSessionSubject(), context, eventIds);
+ }
+
+ public int purgeEventsForContext(EntityContext context) {
+ return eventManager.purgeEventsForContext(getSessionSubject(), context);
+ }
+
}
commit 93768d38ede3cd73b35cecac8be0ee26853b7cc5
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 22:11:21 2010 -0400
update EventGWTService** classes to retrieve EventComposite data by Criteria
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
index 04b967b..1b8c87f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/EventGWTService.java
@@ -27,10 +27,12 @@ import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageList;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public interface EventGWTService extends RemoteService {
@@ -48,6 +50,7 @@ public interface EventGWTService extends RemoteService {
long end,
int numBuckets);
+ PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria);
EventSeverity[] getSeverityBucketsForCompGroup(
int resourceGroupId,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
index cdfd2cb..957d9c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.EventGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
@@ -33,6 +34,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements EventGWTService {
@@ -62,4 +64,9 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
eventManager.findEventsByCriteria(getSessionSubject(), criteria),
"EventService.findEventsByCriteria");
}
+
+ public PageList<EventComposite> findEventCompositesByCriteria(EventCriteria criteria) {
+ return SerialUtility.prepare(eventManager.findEventCompositesByCriteria(getSessionSubject(), criteria),
+ "EventService.findEventsByCriteria");
+ }
}
commit fb0e601f0f7cfaf52d057dbcdb39f2eb6a6923dd
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 22:06:50 2010 -0400
remove existing GWT-based Event views
* these will be replaced by EventComposite views to reduce DB roundtrips
as well as payload between (UI) client and (web) server
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDatasource.java
deleted file mode 100644
index 41e7971..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDatasource.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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.inventory.resource.detail.event;
-
-import java.util.Date;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.types.FieldType;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.EventCriteria;
-import org.rhq.core.domain.event.Event;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * @author Greg Hinkle
- */
-public class EventDatasource extends RPCDataSource<Event> {
-
-
- public EventDatasource() {
- super();
-
-// DataSourceField id = new DataSourceIntegerField("id", "Id");
-// id.setPrimaryKey(true);
-// addField(id);
-
- DataSourceTextField detail = new DataSourceTextField("detail", "Detail");
- addField(detail);
-
-// DataSourceTextField detailExcerpt = new DataSourceTextField("detailExcerpt", "Detail Excerpt");
-// addField(detailExcerpt);
-
- DataSourceTextField severity = new DataSourceTextField("severity", "Servity");
- addField(severity);
-
-// DataSourceTextField source = new DataSourceTextField("source", "Source");
-// addField(source);
-
- DataSourceTextField sourceLocation = new DataSourceTextField("sourceLocation", "Source Location");
- addField(sourceLocation);
-
-// DataSourceTextField type = new DataSourceTextField("type", "Type");
-// addField(type);
-
- DataSourceTextField timestamp = new DataSourceTextField("timestamp", "Timestamp");
- timestamp.setType(FieldType.DATETIME);
- addField(timestamp);
-
-
- }
-
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- EventCriteria criteria = new EventCriteria();
- criteria.addSortSeverity(PageOrdering.DESC);
-
- criteria.setPageControl(getPageControl(request));
- criteria.fetchSource(true);
-
- if (request.getCriteria().getValues().get("resourceId") != null) {
- criteria.addFilterResourceId(request.getCriteria().getAttributeAsInt("resourceId"));
- }
-
- GWTServiceLookup.getEventService().findEventsByCriteria(criteria,
- new AsyncCallback<PageList<Event>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load event data", caught);
- }
-
- public void onSuccess(PageList<Event> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
-
- }
-
- @Override
- public Event copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
- }
-
- @Override
- public ListGridRecord copyValues(Event from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute("id", from.getId());
- record.setAttribute("detail", from.getDetail());
- record.setAttribute("detailExcerpt", from.getDetailExcerpt());
- record.setAttribute("severity", from.getSeverity().name());
- record.setAttribute("source", from.getSource());
- record.setAttribute("sourceLocation", from.getSource().getLocation());
- record.setAttribute("type", from.getType());
- record.setAttribute("timestamp", new Date(from.getTimestamp()));
-
- return record;
- }
-
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDetailsView.java
deleted file mode 100644
index 13ab506..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventDetailsView.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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.inventory.resource.detail.event;
-
-import com.smartgwt.client.types.TitleOrientation;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.TextAreaItem;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-/**
- * @author Greg Hinkle
- */
-public class EventDetailsView extends VLayout {
-
-
- private ListGridRecord eventRecord;
-
-
- public EventDetailsView(ListGridRecord eventRecord) {
- this.eventRecord = eventRecord;
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
-
- DynamicForm form = new DynamicForm();
- form.setWidth100();
- form.setHeight100();
-
- StaticTextItem id = new StaticTextItem("id","Id");
- id.setValue(eventRecord.getAttribute("id"));
-
- StaticTextItem severity = new StaticTextItem("severity","Severity");
- severity.setValue(eventRecord.getAttribute("severity"));
-
- StaticTextItem source = new StaticTextItem("sourceLocation","Source");
- source.setValue(eventRecord.getAttribute("sourceLocation"));
-
- StaticTextItem timestamp = new StaticTextItem("timestamp","Timestamp");
- timestamp.setValue(eventRecord.getAttribute("timestamp"));
-
- TextAreaItem detail = new TextAreaItem("detail", "Detail");
- detail.setTitleOrientation(TitleOrientation.TOP);
- detail.setColSpan(2);
- detail.setWidth("100%");
- detail.setHeight("100%");
- detail.setValue(eventRecord.getAttribute("detail"));
-
-
- form.setItems(id,severity,source,timestamp,detail);
-
-
-
- addMember(form);
-
- }
-
- public void displayInDialog() {
- Window window = new Window();
- window.setTitle("Event Details");
- window.setWidth(800);
- window.setHeight(800);
- window.setIsModal(true);
- window.setShowModalMask(true);
- window.setCanDragResize(true);
- window.centerInPage();
- window.addItem(this);
- window.setDismissOnEscape(true);
- window.setDismissOnOutsideClick(true);
- window.show();
- window.focus();
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventHistoryView.java
deleted file mode 100644
index a1e45ce..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/event/EventHistoryView.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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.inventory.resource.detail.event;
-
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.grid.events.CellDoubleClickEvent;
-import com.smartgwt.client.widgets.grid.events.CellDoubleClickHandler;
-
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
-
-/**
- * @author Greg Hinkle
- */
-public class EventHistoryView extends Table {
-
- public EventHistoryView(String locatorId, Criteria criteria) {
- super(locatorId, "Event History", criteria);
-
- setDataSource(new EventDatasource());
-
- // getListGrid().getField("id").setWidth(60);
- getListGrid().getField("severity").setWidth(120);
- getListGrid().getField("severity").setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o;
- }
- });
-
- getListGrid().addCellDoubleClickHandler(new CellDoubleClickHandler() {
- public void onCellDoubleClick(CellDoubleClickEvent cellDoubleClickEvent) {
- // TODO: Implement this method.
- showEventDetails(cellDoubleClickEvent.getRecord());
- }
- });
-
- addTableAction(extendLocatorId("Detail"), "Details", SelectionEnablement.SINGLE, null, new TableAction() {
- public void executeAction(ListGridRecord[] selection) {
- showEventDetails(selection[0]);
- }
- });
-
- getListGrid().getField("sourceLocation").setWidth(200);
- getListGrid().getField("timestamp").setWidth(160);
- }
-
- public static void showEventDetails(ListGridRecord record) {
- new EventDetailsView(record).displayInDialog();
- }
-
- public static EventHistoryView createResourceHistoryView(String locatorId, int resourceId) {
- Criteria criteria = new Criteria();
- criteria.addCriteria("resourceId", resourceId);
- return new EventHistoryView(locatorId, criteria);
- }
-}
commit 6a432844fff9298ab8f61bb934875e1d7fc6267c
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 22:04:53 2010 -0400
improvements to some GWT infrastructure components
TableFilterForm
* represents a DynamicForm containing fields that filter the results of
an associated Tabular display
* will automatically setup onKeyPress event handler for TextItem fields
* will automatically setup onChanged event handler for SelectItem fields
HighlightingDatasourceTextField
* to be used when constructing an RPCDataSource definition
* usage: 'new DatasourceTextField' with 'new HighlightingDatasourceTextField'
* end-result is that the pattern entered in the FormItem of the same name will
cause the column of the same name in the associated Table to highlight matching
results in-line
RPCDataSource (improvements)
* corresponding handling code for the HighlightingDatasourceTextField
* contains the logic for (under-the-covers) adding new DatasourceTextFields for
the columns which will show the highlighted results
ColoringUtility
* contains the code for performing the actual highlighting logic, which
involves injecting <span> tags with background-color style attributes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java
new file mode 100644
index 0000000..8687ea5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/TableFilterForm.java
@@ -0,0 +1,86 @@
+/*
+ * 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.components.form;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
+import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
+
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+
+/**
+ * A subclass of SmartGWT's DynamicForm widget that provides a more convenient interface for filtering a {@link Table}
+ * of results.
+ *
+ * @author Joseph Marques
+ */
+public class TableFilterForm extends DynamicForm implements KeyPressHandler, ChangedHandler {
+
+ private Table table;
+
+ public TableFilterForm(Table table) {
+ super();
+ setWidth100();
+ this.table = table;
+ this.table.setTableTitle(null);
+ }
+
+ @Override
+ public void setItems(FormItem... items) {
+ super.setItems(items);
+ setupFormItems(items);
+ }
+
+ private void setupFormItems(FormItem... formItems) {
+ for (FormItem nextFormItem : formItems) {
+ nextFormItem.setWrapTitle(false);
+ nextFormItem.setWidth(300); // wider than default
+ if (nextFormItem instanceof TextItem) {
+ nextFormItem.addKeyPressHandler(this);
+ } else if (nextFormItem instanceof SelectItem) {
+ nextFormItem.addChangedHandler(this);
+ }
+ }
+ }
+
+ private void fetchFilteredTableData() {
+ table.refresh(getValuesAsCriteria());
+ }
+
+ public void onKeyPress(KeyPressEvent event) {
+ if (event.getKeyName().equals("Enter") == false) {
+ return;
+ }
+ fetchFilteredTableData();
+ }
+
+ public void onChanged(ChangedEvent event) {
+ fetchFilteredTableData();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/HighlightingDatasourceTextField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/HighlightingDatasourceTextField.java
new file mode 100644
index 0000000..7eb6a62
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/HighlightingDatasourceTextField.java
@@ -0,0 +1,47 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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.util;
+
+import com.smartgwt.client.data.fields.DataSourceTextField;
+
+/**
+ * @author Joseph Marques
+ */
+public class HighlightingDatasourceTextField extends DataSourceTextField {
+
+ public HighlightingDatasourceTextField(String name, String title, int length, boolean required) {
+ super(name, title, length, required);
+ }
+
+ public HighlightingDatasourceTextField(String name, String title, int length) {
+ super(name, title, length);
+ }
+
+ public HighlightingDatasourceTextField(String name, String title) {
+ super(name, title);
+ }
+
+ public HighlightingDatasourceTextField(String name) {
+ super(name);
+ }
+}
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 950d28c..cb2768f 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,13 +18,16 @@
*/
package org.rhq.enterprise.gui.coregui.client.util;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -32,6 +35,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.effects.ColoringUtility;
/**
* Base GWT-RPC oriented DataSource class.
@@ -41,6 +45,8 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
*/
public abstract class RPCDataSource<T> extends DataSource {
+ private List<String> hightlightingFieldNames = new ArrayList<String>();
+
public RPCDataSource() {
this(null);
}
@@ -51,6 +57,8 @@ public abstract class RPCDataSource<T> extends DataSource {
setID(name);
}
setClientOnly(false);
+ setAutoCacheAllData(false);
+ setCacheAllData(false);
setDataProtocol(DSProtocol.CLIENTCUSTOM);
setDataFormat(DSDataFormat.CUSTOM);
}
@@ -128,6 +136,37 @@ public abstract class RPCDataSource<T> extends DataSource {
return records;
}
+ @Override
+ public void addField(DataSourceField field) throws IllegalStateException {
+ super.addField(field);
+ if ((field instanceof HighlightingDatasourceTextField) == false) {
+ return;
+ }
+ field.setHidden(true);
+
+ hightlightingFieldNames.add(field.getName());
+
+ String name = field.getName() + "-highlight";
+ String title = field.getTitle();
+ DataSourceTextField fieldToDisplayHighlighting = new DataSourceTextField(name, title);
+ super.addField(fieldToDisplayHighlighting);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void highlightFilterMatches(final DSRequest request, final ListGridRecord[] records) {
+ Map<String, Object> criteriaMap = request.getCriteria().getValues();
+
+ for (String filterName : hightlightingFieldNames) {
+ String filterValue = (String) criteriaMap.get(filterName);
+ for (ListGridRecord nextRecord : records) {
+ String originalData = nextRecord.getAttribute(filterName);
+ String decoratedData = (filterValue != null) ? ColoringUtility.highlight(originalData, filterValue)
+ : originalData;
+ nextRecord.setAttribute(filterName + "-highlight", decoratedData);
+ }
+ }
+ }
+
/**
* Extensions should implement this method to retrieve data. Paging solutions should use
* {@link #getPageControl(com.smartgwt.client.data.DSRequest)}. All implementations should call processResponse()
@@ -182,7 +221,7 @@ public abstract class RPCDataSource<T> extends DataSource {
*/
public void addFields(List<DataSourceField> fields) {
for (DataSourceField field : fields) {
- addField(field);
+ addField(field);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/effects/ColoringUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/effects/ColoringUtility.java
new file mode 100644
index 0000000..265ef0f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/effects/ColoringUtility.java
@@ -0,0 +1,92 @@
+package org.rhq.enterprise.gui.coregui.client.util.effects;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ColoringUtility {
+ public static String highlight(String data, String filter) {
+ return highlight(data, filter, "yellow");
+ }
+
+ public static String highlight(String data, String filter, String color) {
+ String lowerData = data.toLowerCase();
+ String lowerFilter = filter.toLowerCase();
+
+ List<Integer> matchingIndices = new ArrayList<Integer>();
+
+ int startFrom = -1;
+ while ((startFrom = lowerData.indexOf(lowerFilter, startFrom + 1)) != -1) {
+ matchingIndices.add(startFrom);
+ }
+
+ String style = "background-color: " + color;
+ for (int i = matchingIndices.size() - 1; i >= 0; i--) {
+ Integer nextMatchingIndex = matchingIndices.get(i);
+ data = decorate(data, style, nextMatchingIndex, nextMatchingIndex + filter.length());
+ }
+
+ return data;
+ }
+
+ private static String decorate(String data, String style, int startIndex, int endIndex) {
+ if (startIndex == -1 || (startIndex == endIndex)) {
+ return data; // no match or zero-width match
+ }
+
+ String[] words = data.split("<br/>");
+ int counter = 0;
+ int wordIndex = 0;
+ int letterIndex = 0;
+
+ StringBuilder results = new StringBuilder();
+ while (counter < startIndex) {
+ if (wordIndex == words.length) {
+ break;
+ }
+
+ if (letterIndex < words[wordIndex].length()) { // more letters left in the current word?
+ results.append(words[wordIndex].charAt(letterIndex)); // append the next char of the current word
+ letterIndex++; // move to the next char in the current word
+ counter++; // only move counter forward when we've added non-BR chars to the results
+ } else { // next word
+ results.append("<br/>"); // put the break point back in between words
+ letterIndex = 0; // point to the first char
+ wordIndex++; // of the next word
+ }
+ }
+
+ // we're at start index, wrap all words and word fragments in the specified style up to endIndex
+ results.append("<span style=\"" + style + "\">"); // seed action
+ while (counter < endIndex) {
+ if (wordIndex == words.length) {
+ break;
+ }
+
+ if (letterIndex < words[wordIndex].length()) { // more letters left in the current word?
+ results.append(words[wordIndex].charAt(letterIndex)); // append the next char of the current word
+ letterIndex++; // move to the next char in the current word
+ counter++; // only move counter forward when we've added non-BR chars to the results
+ } else { // next word
+ results.append("</span>"); // close the previous word, we don't highlight breaks
+ results.append("<br/>"); // put the break point back in between words
+ letterIndex = 0; // point to the first char
+ wordIndex++; // of the next word
+ results.append("<span style=\"" + style + "\">"); // prepare for next word
+ }
+ }
+ results.append("</span>"); // end last dangling span
+
+ // append the rest of the current word fragment, if any
+ if (wordIndex != words.length) {
+ results.append(words[wordIndex].substring(letterIndex));
+ }
+
+ // append the rest of the words
+ while (++wordIndex < words.length) {
+ results.append("<br/>"); // put the break point back in between words
+ results.append(words[wordIndex]);
+ }
+
+ return results.toString();
+ }
+}
commit 4e5f974a6562f178339f47f90f95065e956b7635
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 21:57:00 2010 -0400
add ability to filter EventCriteria by EntityContext object
* this is a convenience method wrapper that will automatically set other filters appropriate based on context
** if resource context, will add resourceId filter
** if group context, will add groupId filter
** if auto-group context, will add parentResourceId/resourceTypeId filters
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
index bdbccbc..f4db72d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
@@ -29,6 +29,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.util.PageOrdering;
@@ -107,11 +108,22 @@ public class EventCriteria extends Criteria {
}
public void addFilterSeverities(EventSeverity... filterSeverities) {
- if (filterSeverities != null) {
+ if (filterSeverities != null && filterSeverities.length > 0) {
this.filterSeverities = Arrays.asList(filterSeverities);
}
}
+ public void addFilterEntityContext(EntityContext filterEntityContext) {
+ if (filterEntityContext.getCategory() == EntityContext.Category.Resource) {
+ addFilterResourceId(filterEntityContext.getResourceId());
+ } else if (filterEntityContext.getCategory() == EntityContext.Category.ResourceGroup) {
+ addFilterResourceGroupId(filterEntityContext.getGroupId());
+ } else if (filterEntityContext.getCategory() == EntityContext.Category.AutoGroup) {
+ addFilterAutoGroupParentResourceId(filterEntityContext.getParentResourceId());
+ addFilterAutoGroupResourceTypeId(filterEntityContext.getResourceTypeId());
+ }
+ }
+
public void addFilterResourceId(Integer filterResourceId) {
this.filterResourceId = filterResourceId;
}
commit 1cb73bc8d121d5e66795d86e794dccc0c7fce415
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 21:55:19 2010 -0400
fix bug - filtering by sourceName on EventCriteria
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
index f7dbb6a..bdbccbc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
@@ -59,7 +59,7 @@ public class EventCriteria extends Criteria {
private PageOrdering sortSeverity;
public EventCriteria() {
- filterOverrides.put("sourceName", "source.eventDefinition.name like ?");
+ filterOverrides.put("sourceName", "source.location like ?");
filterOverrides.put("startTime", "timestamp >= ?");
filterOverrides.put("endTime", "timestamp <= ?");
filterOverrides.put("resourceId", "source.resourceId = ?");
commit 4daa5f3a45c61581e45254aae3dad8f09df4f5d6
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 21:54:41 2010 -0400
parameterized delete/purge routines in EventManagerBean using EntityContext; add missing permission
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
index 09221d3..31b283b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
@@ -49,6 +49,7 @@ import org.rhq.core.db.OracleDatabaseType;
import org.rhq.core.db.PostgresqlDatabaseType;
import org.rhq.core.db.SQLServerDatabaseType;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.event.Event;
@@ -260,10 +261,29 @@ public class EventManagerBean implements EventManagerLocal, EventManagerRemote {
}
}
- public int deleteEvents(Subject subject, List<Integer> eventIds) {
+ public int deleteEventsForContext(Subject subject, EntityContext context, List<Integer> eventIds) {
if (eventIds == null || eventIds.size() == 0) {
return 0; // nothing to delete, thus 0 were deleted
}
+
+ if (context.category == EntityContext.Category.Resource) {
+ if (authorizationManager.hasResourcePermission(subject, Permission.MANAGE_EVENTS, context.resourceId) == false) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permissions to delete events for resource[id=" + context.resourceId + "]");
+ }
+ } else if (context.category == EntityContext.Category.ResourceGroup) {
+ if (authorizationManager.hasGroupPermission(subject, Permission.MANAGE_EVENTS, context.groupId) == false) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permissions to delete events for resourceGroup[id=" + context.groupId + "]");
+ }
+ } else if (context.category == EntityContext.Category.AutoGroup) {
+ if (authorizationManager.canViewAutoGroup(subject, context.parentResourceId, context.resourceTypeId) == false) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permission to view event history for autoGroup[parentResourceId="
+ + context.parentResourceId + ", resourceTypeId=" + context.resourceTypeId + "]");
+ }
+ }
+
Query q = entityManager.createNamedQuery(Event.DELETE_BY_EVENT_IDS);
q.setParameter("eventIds", eventIds);
int deletedCount = q.executeUpdate();
@@ -271,18 +291,32 @@ public class EventManagerBean implements EventManagerLocal, EventManagerRemote {
return deletedCount;
}
- public int deleteAllEventsForResource(Subject subject, int resourceId) {
- Query q = entityManager.createNamedQuery(Event.DELETE_ALL_BY_RESOURCE);
- q.setParameter("resourceId", resourceId);
- int deletedCount = q.executeUpdate();
+ public int purgeEventsForContext(Subject subject, EntityContext context) {
- return deletedCount;
- }
+ if (context.category == EntityContext.Category.Resource) {
+ if (authorizationManager.hasResourcePermission(subject, Permission.MANAGE_EVENTS, context.resourceId) == false) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permissions to purge events for resource[id=" + context.resourceId + "]");
+ }
+ } else if (context.category == EntityContext.Category.ResourceGroup) {
+ if (authorizationManager.hasGroupPermission(subject, Permission.MANAGE_EVENTS, context.groupId) == false) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permissions to purge events for resourceGroup[id=" + context.groupId + "]");
+ }
+ } else {
+ throw new IllegalArgumentException(context.getUnknownContextMessage());
+ }
- public int deleteAllEventsForCompatibleGroup(Subject subject, int groupId) {
- Query q = entityManager.createNamedQuery(Event.DELETE_ALL_BY_RESOURCE_GROUP);
- q.setParameter("groupId", groupId);
- int deletedCount = q.executeUpdate();
+ Query purgeQuery = null;
+ if (context.category == EntityContext.Category.Resource) {
+ purgeQuery = entityManager.createNamedQuery(Event.DELETE_ALL_BY_RESOURCE);
+ purgeQuery.setParameter("resourceId", context.resourceId);
+ } else if (context.category == EntityContext.Category.ResourceGroup) {
+ purgeQuery = entityManager.createNamedQuery(Event.DELETE_ALL_BY_RESOURCE_GROUP);
+ purgeQuery.setParameter("groupId", context.groupId);
+ }
+
+ int deletedCount = purgeQuery.executeUpdate();
return deletedCount;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java
index ac91817..03a4b21 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java
@@ -85,11 +85,9 @@ public interface EventManagerLocal {
void deleteEventSourcesForDefinition(EventDefinition def);
- int deleteEvents(Subject subject, List<Integer> eventIds);
+ int deleteEventsForContext(Subject subject, EntityContext context, List<Integer> eventIds);
- int deleteAllEventsForResource(Subject subject, int resourceId);
-
- int deleteAllEventsForCompatibleGroup(Subject subject, int groupId);
+ int purgeEventsForContext(Subject subject, EntityContext context);
PageList<EventComposite> findEventComposites(Subject subject, EntityContext context, long begin, long end,
EventSeverity[] severities, String source, String detail, PageControl pc);
commit 04725bce53b14e43ca5a9d9077a414907bee63ed
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 21:54:15 2010 -0400
add MANAGE_EVENTS permission to dbsetup routine for new installations
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml
index 76e0eb7..8a92b54 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-data.xml
@@ -57,6 +57,7 @@
<data ROLE_ID="1" OPERATION="9"/> <!-- Permission.MANAGE_CONTENT -->
<data ROLE_ID="1" OPERATION="10"/> <!-- Permission.CONTROL -->
<data ROLE_ID="1" OPERATION="11"/> <!-- Permission.CONFIGURE -->
+ <data ROLE_ID="1" OPERATION="14"/> <!-- Permission.MANAGE_EVENTS -->
<!-- give all-resources-role all permissions (resource perms is mainly just to show on view-role page) -->
<data ROLE_ID="2" OPERATION="1"/> <!-- Permission.MANAGE_INVENTORY -->
@@ -71,6 +72,7 @@
<data ROLE_ID="2" OPERATION="9"/> <!-- Permission.MANAGE_CONTENT -->
<data ROLE_ID="2" OPERATION="10"/> <!-- Permission.CONTROL -->
<data ROLE_ID="2" OPERATION="11"/> <!-- Permission.CONFIGURE -->
+ <data ROLE_ID="2" OPERATION="14"/> <!-- Permission.MANAGE_EVENTS -->
</table>
</dbsetup>
commit b0cb569f309d257c65ce1ffb12bd4913ad7dc368
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 21:53:39 2010 -0400
add numeric label after each enum, for ease of reference
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
index 3b8c5fd..5ab76b6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
@@ -39,74 +39,74 @@ public enum Permission {
/**
* can C/U/D users and roles (viewing is implied for everyone)
*/
- MANAGE_SECURITY(Target.GLOBAL),
+ MANAGE_SECURITY(Target.GLOBAL), // 0
/**
* can C/R/U/D all resources, groups and can import auto-discovered resources
*/
- MANAGE_INVENTORY(Target.GLOBAL),
+ MANAGE_INVENTORY(Target.GLOBAL), // 1
/**
* can modify the JON Server configuration and perform any server-related functionality
*/
- MANAGE_SETTINGS(Target.GLOBAL),
+ MANAGE_SETTINGS(Target.GLOBAL), // 2
/* ========= Resource Permissions ========= */
/**
* can view this resource's config, metrics, and alerts
*/
- VIEW_RESOURCE(Target.RESOURCE),
+ VIEW_RESOURCE(Target.RESOURCE), // 3
/**
* can modify resource name, description, and plugin config (e.g. set principal/credentials jboss-as plugin uses to access the managed JBossAS instance)
*/
- MODIFY_RESOURCE(Target.RESOURCE),
+ MODIFY_RESOURCE(Target.RESOURCE), // 4
/**
* can delete this resource (which also implies deleting all its descendant resources)
*/
- DELETE_RESOURCE(Target.RESOURCE),
+ DELETE_RESOURCE(Target.RESOURCE), // 5
/**
* can manually create new child servers or services
*/
- CREATE_CHILD_RESOURCES(Target.RESOURCE),
+ CREATE_CHILD_RESOURCES(Target.RESOURCE), // 6
/**
* can C/U/D alert definitions (this implies {@link #VIEW_RESOURCE}, {@link #MANAGE_MEASUREMENTS}, {@link #CONTROL})
*/
- MANAGE_ALERTS(Target.RESOURCE),
+ MANAGE_ALERTS(Target.RESOURCE), // 7
/**
* can C/U/D metric schedules (this implies {@link #VIEW_RESOURCE})
*/
- MANAGE_MEASUREMENTS(Target.RESOURCE),
+ MANAGE_MEASUREMENTS(Target.RESOURCE), // 8
/**
* can C/U/D content (package bits, software updates, etc) (this implies {@link #VIEW_RESOURCE})
*/
- MANAGE_CONTENT(Target.RESOURCE),
+ MANAGE_CONTENT(Target.RESOURCE), // 9
/**
* can invoke operations that only change the "running" state of the resource (e.g. start/stop)
*/
- CONTROL(Target.RESOURCE),
+ CONTROL(Target.RESOURCE), // 10
/**
* can C/U/D resource config (e.g. reconfiguring JBoss to listen for jnp on port 1199);
* having this permission implies having @link {@link #CONFIGURE_READ}
*/
- CONFIGURE_WRITE(Target.RESOURCE),
+ CONFIGURE_WRITE(Target.RESOURCE), // 11
/* ========== New Bundle Global Permission ========== */
- MANAGE_BUNDLE(Target.GLOBAL),
+ MANAGE_BUNDLE(Target.GLOBAL), // 12
/**
* can read resource configu, but can not necessarily C/U/D unless @link {@link #CONFIGURE_WRITE} is also possessed
*/
- CONFIGURE_READ(Target.RESOURCE);
+ CONFIGURE_READ(Target.RESOURCE), // 13
/**
* can C/U/D events (this implies {@link #VIEW_RESOURCE})
commit f92f62432bf397854e8ef276dbc29b2011c29935
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 21:53:23 2010 -0400
add missing MANAGE_EVENTS permission, previous event delete/purge was guarded by view resource permission
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 81498dc..1f4adef 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.93.3</db.schema.version>
+ <db.schema.version>2.94</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 07b448b..f32e5e3 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3192,6 +3192,24 @@
<schema-alterColumn table="RHQ_PARTITION_EVENT" column="SUBJECT_NAME" columnType="VARCHAR2" precision="100" />
</schemaSpec>
+ <schemaSpec version="2.94">
+ <!-- give the 'SUPER USER' and 'ALL RESOURCES' roles permission to delete/purge events (this permission
+ previously did not exist, and event deletion/purging could be performed by any user with authz to
+ view the resource/group in question).
+
+ a user with MANAGE_SECURITY must explicitly grant this permission to other roles after upgrade-->
+ <schema-directSQL>
+ <statement desc="Inserting MANAGE_EVENTS permission for 'Super User' role">
+ INSERT INTO RHQ_PERMISSION (ROLE_ID, OPERATION)
+ VALUES (1, 14)
+ </statement>
+ <statement desc="Inserting MANAGE_EVENTS permission for 'All Resources' role">
+ INSERT INTO RHQ_PERMISSION (ROLE_ID, OPERATION)
+ VALUES (2, 14)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
index e20d15b..3b8c5fd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
@@ -109,6 +109,12 @@ public enum Permission {
CONFIGURE_READ(Target.RESOURCE);
/**
+ * can C/U/D events (this implies {@link #VIEW_RESOURCE})
+ * in the future, will also C/U/D event definitions
+ */
+ MANAGE_EVENTS(Target.RESOURCE); // 14
+
+ /**
* The target that a permission applies to.
*/
public enum Target {
commit 2f206ea7d5438596b956de476e883fcc9b723a9d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 21:02:07 2010 -0400
sorting fix
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml
index 21bbc81..2db2852 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/events/history-plain.xhtml
@@ -97,7 +97,7 @@
<rich:column style="white-space: nowrap;">
<f:facet name="header">
- <onc:sortableColumnHeader sort="ev.severity">
+ <onc:sortableColumnHeader sort="severity">
<h:outputText styleClass="headerText" value="Severity" />
</onc:sortableColumnHeader>
</f:facet>
@@ -113,7 +113,7 @@
<rich:column rendered="#{EventHistoryUIBean.context.resourceId == -1}">
<f:facet name="header">
- <onc:sortableColumnHeader sort="res.name">
+ <onc:sortableColumnHeader sort="resource.name">
<h:outputText styleClass="headerText" value="Resource" />
</onc:sortableColumnHeader>
</f:facet>
@@ -122,7 +122,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="evs.location">
+ <onc:sortableColumnHeader sort="source.location">
<h:outputText styleClass="headerText" value="Source" />
</onc:sortableColumnHeader>
</f:facet>
@@ -144,7 +144,7 @@
<rich:column>
<f:facet name="header">
- <onc:sortableColumnHeader sort="ev.timestamp">
+ <onc:sortableColumnHeader sort="timestamp">
<h:outputText styleClass="headerText" value="Time occurred" />
</onc:sortableColumnHeader>
</f:facet>
commit 3ef6b07c0db492dac1b50853a7338be2e78ab5dd
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Aug 23 21:01:23 2010 -0400
move EntityContext from server/jar to core/domain, so it can be GWT-consumed
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/common/EntityContext.java b/modules/core/domain/src/main/java/org/rhq/core/domain/common/EntityContext.java
new file mode 100644
index 0000000..493c4d6
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/common/EntityContext.java
@@ -0,0 +1,186 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.core.domain.common;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Category is assigned with the following preference assuming multiple categories can be satisfied with the available context information:
+ * <pre>
+ * ResourceGroup
+ * AutoGroup
+ * ResourceTemplate
+ * Resource
+ * <pre>
+ *
+ * @author Joseph Marques
+ */
+public class EntityContext implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public enum Category {
+ Resource, //
+ ResourceTemplate, //
+ ResourceGroup, //
+ AutoGroup;
+ }
+
+ // can't make these fields final because need public no-arg ctor for GWT-compile
+ public Category category;
+ public int resourceId;
+ public int groupId;
+ public int parentResourceId;
+ public int resourceTypeId;
+
+ public EntityContext() {
+ }
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public int getGroupId() {
+ return groupId;
+ }
+
+ public int getParentResourceId() {
+ return parentResourceId;
+ }
+
+ public int getResourceTypeId() {
+ return resourceTypeId;
+ }
+
+ public EntityContext(Integer resourceId, Integer groupId, Integer parentResourceId, Integer resourceTypeId) {
+ int rId = (resourceId != null && resourceId > 0) ? resourceId : -1;
+ int gId = (groupId != null && groupId > 0) ? groupId : -1;
+ int prId = (parentResourceId != null && parentResourceId > 0) ? parentResourceId : -1;
+ int rtId = (resourceTypeId != null && resourceTypeId > 0) ? resourceTypeId : -1;
+
+ this.resourceId = rId;
+ this.groupId = gId;
+ this.parentResourceId = prId;
+ this.resourceTypeId = rtId;
+
+ if (this.groupId > 0) {
+ category = Category.ResourceGroup;
+ } else if (this.resourceTypeId > 0) {
+ if (this.parentResourceId > 0) {
+ category = Category.AutoGroup;
+ } else {
+ category = Category.ResourceTemplate;
+ }
+ } else if (this.resourceId > 0) {
+ category = Category.Resource;
+ } else {
+ throw new IllegalArgumentException(getUnknownContextMessage());
+ }
+ }
+
+ public static EntityContext forResource(int resourceId) {
+ return new EntityContext(resourceId, null, null, null);
+ }
+
+ public static EntityContext forGroup(int groupId) {
+ return new EntityContext(null, groupId, null, null);
+ }
+
+ public static EntityContext forAutoGroup(int parentResourceId, int resourceTypeId) {
+ return new EntityContext(null, null, parentResourceId, resourceTypeId);
+ }
+
+ public static EntityContext forTemplate(int resourceTypeId) {
+ return new EntityContext(null, null, null, resourceTypeId);
+ }
+
+ public static EntityContext fromCriteriaMap(Map<String, Object> criteriaMap) {
+ return new EntityContext(//
+ Integer.valueOf((String) criteriaMap.get("resourceId")), //
+ Integer.valueOf((String) criteriaMap.get("groupId")), //
+ Integer.valueOf((String) criteriaMap.get("parentResourceId")), //
+ Integer.valueOf((String) criteriaMap.get("resourceTypeId")));
+ }
+
+ public Map<String, String> toCriteriaMap() {
+ Map<String, String> criteriaMap = new HashMap<String, String>();
+
+ switch (category) {
+ case Resource:
+ criteriaMap.put("resourceId", String.valueOf(resourceId));
+ break;
+ case ResourceGroup:
+ criteriaMap.put("groupId", String.valueOf(groupId));
+ break;
+ case AutoGroup:
+ criteriaMap.put("parentResourceId", String.valueOf(parentResourceId));
+ criteriaMap.put("resourceTypeId", String.valueOf(resourceTypeId));
+ break;
+ case ResourceTemplate:
+ criteriaMap.put("resourceTypeId", String.valueOf(resourceTypeId));
+ break;
+ }
+
+ return criteriaMap;
+ }
+
+ public String getLegacyKey() {
+ switch (category) {
+ case Resource:
+ return String.valueOf(resourceId);
+ case ResourceGroup:
+ return "cg=" + String.valueOf(groupId);
+ case AutoGroup:
+ return "ag=" + String.valueOf(parentResourceId) + ":" + String.valueOf(resourceTypeId);
+ default:
+ throw new IllegalArgumentException(getUnknownContextMessage());
+ }
+ }
+
+ public String getUnknownContextMessage() {
+ return "Unsupported EntityContext '" + this + "'";
+ }
+
+ @Override
+ public String toString() {
+ return "EntityContext[category=" + category + ",resourceId=" + resourceId + "," + "groupId=" + groupId + ","
+ + "parent=" + parentResourceId + "," + "type=" + resourceTypeId + "]";
+ }
+
+ public String toShortString() {
+ switch (category) {
+ case Resource:
+ return "resource[id=" + resourceId + "]";
+ case ResourceGroup:
+ return "resourceGroup[groupId=" + resourceId + "]";
+ case AutoGroup:
+ return "autoGroup[parent=" + parentResourceId + ",type=" + resourceTypeId + "]";
+ case ResourceTemplate:
+ return "template[type=" + resourceTypeId + "]";
+ default:
+ return toString();
+ }
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java
index a68baca..9760900 100755
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/servlet/HighLowChartServlet.java
@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.MeasurementUnits;
@@ -40,7 +41,6 @@ import org.rhq.enterprise.gui.legacy.DefaultConstants;
import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java
index e9f24fa..ad57e8b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/tag/FunctionTagLibrary.java
@@ -41,6 +41,7 @@ import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -58,7 +59,6 @@ import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.util.WebUtility;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.uibean.MetricDisplaySummary;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSender;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java
index 8b033d7..3b2f373 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/event/EventHistoryUIBean.java
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageControl;
@@ -42,7 +43,6 @@ import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.event.EventException;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
@@ -152,7 +152,8 @@ public class EventHistoryUIBean extends PagedDataTableUIBean {
Integer[] eventIds = StringUtility.getIntegerArray(selectedEvents);
try {
- int numDeleted = eventManager.deleteEvents(getSubject(), Arrays.asList(eventIds));
+ int numDeleted = eventManager.deleteEventsForContext(getSubject(), context, Arrays.asList(eventIds));
+
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted " + numDeleted + " events.");
} catch (Exception e) {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Failed to delete selected events.", e);
@@ -163,15 +164,7 @@ public class EventHistoryUIBean extends PagedDataTableUIBean {
public String purgeAllEvents() {
try {
- int numDeleted = 0;
-
- if (context.category == EntityContext.Category.Resource) {
- numDeleted = eventManager.deleteAllEventsForResource(getSubject(), context.resourceId);
- } else if (context.category == EntityContext.Category.ResourceGroup) {
- numDeleted = eventManager.deleteAllEventsForCompatibleGroup(getSubject(), context.groupId);
- } else {
- log.error(context.getUnknownContextMessage());
- }
+ int numDeleted = eventManager.purgeEventsForContext(getSubject(), context);
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted " + numDeleted + " events");
} catch (Exception e) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java
index 243f7eb..9a02867 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/autogroup/AutoGroupUIBean.java
@@ -22,12 +22,12 @@ import java.util.List;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.util.WebUtility;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
index 9109345..8403297 100755
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventDetailsAction.java
@@ -33,6 +33,7 @@ import org.apache.struts.util.MessageResources;
import org.rhq.core.clientapi.util.StringUtil;
import org.rhq.core.clientapi.util.TimeUtil;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageControl;
@@ -46,7 +47,6 @@ import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.legacy.action.BaseAction;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java
index 45f17ba..fb41aee 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/events/EventsFormPrepareAction.java
@@ -31,6 +31,7 @@ import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageControl;
@@ -40,7 +41,6 @@ import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.legacy.action.resource.common.monitor.visibility.MetricsControlFormPrepareAction;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java
index a69fe6f..18183ac 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/config/ConfigMetricsFormPrepareAction.java
@@ -33,6 +33,7 @@ import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.actions.TilesAction;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
import org.rhq.core.domain.resource.Resource;
@@ -42,7 +43,6 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java
index aa8d207..df37899 100755
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/IndicatorChartsAction.java
@@ -36,6 +36,7 @@ import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.KeyConstants;
import org.rhq.enterprise.gui.legacy.ParamConstants;
@@ -46,7 +47,6 @@ import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.gui.util.MetricsDisplayMode;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
import org.rhq.enterprise.server.measurement.MeasurementViewException;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java
index 1e02793..4cfb664 100755
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/visibility/TimelineAction.java
@@ -29,6 +29,7 @@ import org.apache.struts.action.ActionMapping;
import org.apache.struts.tiles.actions.TilesAction;
import org.rhq.core.clientapi.util.TimeUtil;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.DefaultConstants;
@@ -37,7 +38,6 @@ import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.legacy.beans.TimelineBean;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java
index c93c137..6a1177c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/calltime/CallTimeUIBean.java
@@ -5,6 +5,7 @@ import javax.faces.model.DataModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -15,7 +16,6 @@ import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.CallTimeDataManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java
index d2c9434..3958d5d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/AvailabilityUIBean.java
@@ -8,12 +8,12 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.util.units.UnitNumber;
import org.rhq.core.clientapi.util.units.UnitsConstants;
import org.rhq.core.clientapi.util.units.UnitsFormat;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.enterprise.gui.legacy.DefaultConstants;
import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal;
import org.rhq.enterprise.server.measurement.AvailabilityPoint;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java
index 6b5776f..5f9fb22 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/EventsTimelineUIBean.java
@@ -4,13 +4,13 @@ import java.util.ArrayList;
import java.util.List;
import org.rhq.core.clientapi.util.TimeUtil;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.enterprise.gui.legacy.DefaultConstants;
import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.legacy.beans.TimelineBean;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java
index 5dbddac..572cc88 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/graphs/IndicatorChartsUIBean.java
@@ -18,6 +18,7 @@ import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.legacy.AttrConstants;
import org.rhq.enterprise.gui.legacy.KeyConstants;
@@ -33,7 +34,6 @@ import org.rhq.enterprise.gui.util.WebUtility;
import org.rhq.enterprise.server.auth.SessionNotFoundException;
import org.rhq.enterprise.server.auth.SessionTimeoutException;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
import org.rhq.enterprise.server.measurement.MeasurementViewException;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java
index 162f23d..39004f0 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/autogroup/ListAutoGroupMeasurementScheduleUIBean.java
@@ -3,6 +3,7 @@ package org.rhq.enterprise.gui.measurement.schedule.autogroup;
import javax.faces.application.FacesMessage;
import javax.faces.model.DataModel;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -12,7 +13,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
import org.rhq.enterprise.gui.common.time.DurationComponent;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java
index 267bb07..3c2cf04 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/group/ListResourceGroupMeasurementScheduleUIBean.java
@@ -3,6 +3,7 @@ package org.rhq.enterprise.gui.measurement.schedule.group;
import javax.faces.application.FacesMessage;
import javax.faces.model.DataModel;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -12,7 +13,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
import org.rhq.enterprise.gui.common.time.DurationComponent;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java
index 1a07f05..2dda70b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/schedule/resource/ListResourceMeasurementScheduleUIBean.java
@@ -3,6 +3,7 @@ package org.rhq.enterprise.gui.measurement.schedule.resource;
import javax.faces.application.FacesMessage;
import javax.faces.model.DataModel;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -12,7 +13,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
import org.rhq.enterprise.gui.common.time.DurationComponent;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java
index 64d695f..0b46dc1 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/tables/MetricsTableUIBean.java
@@ -26,6 +26,7 @@ import javax.faces.context.FacesContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementSchedule;
@@ -36,7 +37,6 @@ import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.legacy.util.MonitorUtils;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementChartsManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementPreferences;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java
index c60c2fd..072d052 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/util/WebUtility.java
@@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
@@ -36,7 +37,6 @@ import org.rhq.enterprise.gui.legacy.ParamConstants;
import org.rhq.enterprise.gui.legacy.WebUser;
import org.rhq.enterprise.gui.legacy.exception.ParameterNotFoundException;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
-import org.rhq.enterprise.server.common.EntityContext;
/**
* Utilities for the web tier. Named such so as not to clash with
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/common/EntityContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/common/EntityContext.java
deleted file mode 100644
index 0330286..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/common/EntityContext.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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 as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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 for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.server.common;
-
-/**
- * Category is assigned with the following preference assuming multiple categories can be satisfied with the available context information:
- * <pre>
- * ResourceGroup
- * AutoGroup
- * ResourceTemplate
- * Resource
- * <pre>
- *
- * @author Joseph Marques
- */
-public class EntityContext {
-
- public enum Category {
- Resource, //
- ResourceTemplate, //
- ResourceGroup, //
- AutoGroup;
- }
-
- public final Category category;
- public final int resourceId;
- public final int groupId;
- public final int parentResourceId;
- public final int resourceTypeId;
-
- public Category getCategory() {
- return category;
- }
-
- public int getResourceId() {
- return resourceId;
- }
-
- public int getGroupId() {
- return groupId;
- }
-
- public int getParentResourceId() {
- return parentResourceId;
- }
-
- public int getResourceTypeId() {
- return resourceTypeId;
- }
-
- public EntityContext(Integer resourceId, Integer groupId, Integer parentResourceId, Integer resourceTypeId) {
- int rId = (resourceId != null && resourceId > 0) ? resourceId : -1;
- int gId = (groupId != null && groupId > 0) ? groupId : -1;
- int prId = (parentResourceId != null && parentResourceId > 0) ? parentResourceId : -1;
- int rtId = (resourceTypeId != null && resourceTypeId > 0) ? resourceTypeId : -1;
-
- this.resourceId = rId;
- this.groupId = gId;
- this.parentResourceId = prId;
- this.resourceTypeId = rtId;
-
- if (this.groupId > 0) {
- category = Category.ResourceGroup;
- } else if (this.resourceTypeId > 0) {
- if (this.parentResourceId > 0) {
- category = Category.AutoGroup;
- } else {
- category = Category.ResourceTemplate;
- }
- } else if (this.resourceId > 0) {
- category = Category.Resource;
- } else {
- throw new IllegalArgumentException(getUnknownContextMessage());
- }
- }
-
- public static EntityContext forResource(int resourceId) {
- return new EntityContext(resourceId, null, null, null);
- }
-
- public static EntityContext forGroup(int groupId) {
- return new EntityContext(null, groupId, null, null);
- }
-
- public static EntityContext forAutoGroup(int parentResourceId, int resourceTypeId) {
- return new EntityContext(null, null, parentResourceId, resourceTypeId);
- }
-
- public String getLegacyKey() {
- switch (category) {
- case Resource:
- return String.valueOf(resourceId);
- case ResourceGroup:
- return "cg=" + String.valueOf(groupId);
- case AutoGroup:
- return "ag=" + String.valueOf(parentResourceId) + ":" + String.valueOf(resourceTypeId);
- default:
- throw new IllegalArgumentException(getUnknownContextMessage());
- }
- }
-
- public String getUnknownContextMessage() {
- return "Unsupported " + EntityContext.class.getSimpleName() + " '" + this + "'";
- }
-
- @Override
- public String toString() {
- return EntityContext.class.getSimpleName() + "[category=" + category + ",resourceId=" + resourceId + ","
- + "groupId=" + groupId + "," + "parent=" + parentResourceId + "," + "type=" + resourceTypeId + "]";
- }
-
- public String toShortString() {
- switch (category) {
- case Resource:
- return "resource[id=" + resourceId + "]";
- case ResourceGroup:
- return "resourceGroup[groupId=" + resourceId + "]";
- case AutoGroup:
- return "autoGroup[parent=" + parentResourceId + ",type=" + resourceTypeId + "]";
- default:
- return toString();
- }
- }
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
index 443625f..09221d3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
@@ -49,6 +49,7 @@ import org.rhq.core.db.OracleDatabaseType;
import org.rhq.core.db.PostgresqlDatabaseType;
import org.rhq.core.db.SQLServerDatabaseType;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventDefinition;
@@ -63,7 +64,6 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java
index 97d63bc..ac91817 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerLocal.java
@@ -28,6 +28,7 @@ import java.util.Set;
import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventDefinition;
@@ -36,7 +37,6 @@ import org.rhq.core.domain.event.EventSource;
import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.server.common.EntityContext;
/**
* Interface for the Event Manager
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
index 7b90d5f..0f75686 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
@@ -40,6 +40,7 @@ import org.apache.commons.logging.LogFactory;
import org.jboss.annotation.ejb.TransactionTimeout;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -57,7 +58,6 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor;
import org.rhq.enterprise.server.resource.ResourceAvailabilityManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
index 65bf0e3..d052d88 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
@@ -49,6 +49,7 @@ import org.rhq.core.db.Postgresql83DatabaseType;
import org.rhq.core.db.PostgresqlDatabaseType;
import org.rhq.core.db.SQLServerDatabaseType;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.CallTimeDataCriteria;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.calltime.CallTimeData;
@@ -64,7 +65,6 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java
index 6c0180b..cf95f77 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerLocal.java
@@ -25,11 +25,11 @@ import java.util.Set;
import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.calltime.CallTimeData;
import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.server.common.EntityContext;
/**
* The manager for call-time metric data.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java
index 15b5267..59f76dc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementChartsManagerBean.java
@@ -37,6 +37,7 @@ import org.apache.commons.logging.LogFactory;
import org.jboss.annotation.IgnoreDependency;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.DisplayType;
@@ -53,7 +54,6 @@ import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.common.PerformanceMonitorInterceptor;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricRangePreferences;
import org.rhq.enterprise.server.measurement.uibean.MetricDisplayConstants;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
index 3a5f53b..c65cc8c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
@@ -55,6 +55,7 @@ import org.rhq.core.db.DatabaseType;
import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.db.Postgresql83DatabaseType;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.DisplayType;
@@ -83,7 +84,6 @@ import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.jaxb.adapter.MeasurementDataNumericHighLowCompositeAdapter;
import org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor;
@@ -833,16 +833,16 @@ public class MeasurementDataManagerBean implements MeasurementDataManagerLocal,
Map<String, Object> filterFields = generator.getFilterFields(criteria);
if (!this.authorizationManager.isInventoryManager(subject)) {
if (filterFields.get(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID) != null) {
- generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.GROUP,
- subject.getId());
+ generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.GROUP, subject
+ .getId());
} else {
generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.RESOURCE,
- subject.getId());
+ subject.getId());
}
}
CriteriaQueryRunner<MeasurementDataTrait> queryRunner = new CriteriaQueryRunner(criteria, generator,
- this.entityManager);
+ this.entityManager);
PageList<MeasurementDataTrait> results = queryRunner.execute();
// Fetch the metric definition for each schedule, so the results include the trait names.
@@ -857,7 +857,7 @@ public class MeasurementDataManagerBean implements MeasurementDataManagerLocal,
result.getSchedule().getResource().getName();
}
}
-
+
return results;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java
index 7e4d87c..5090d47 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerLocal.java
@@ -26,8 +26,8 @@ import java.util.Set;
import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
-import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.measurement.DisplayType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -40,7 +40,6 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.uibean.MetricDisplaySummary;
/**
@@ -161,7 +160,7 @@ public interface MeasurementDataManagerLocal {
* @return the traits that match the specified {@link MeasurementDataTraitCriteria criteria}; never null
*/
PageList<MeasurementDataTrait> findTraitsByCriteria(Subject subject, MeasurementDataTraitCriteria criteria);
-
+
/**
* Get live metrics for a given MeasurementSchedule
*
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index bebf8a4..1e0b353 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -52,6 +52,7 @@ import org.rhq.core.db.PostgresqlDatabaseType;
import org.rhq.core.db.SQLServerDatabaseType;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.DataType;
@@ -80,7 +81,6 @@ import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.authz.RequiredPermissions;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.common.PerformanceMonitorInterceptor;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java
index 1ef3012..5a6f6ad 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerLocal.java
@@ -24,6 +24,7 @@ import java.util.Set;
import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.DisplayType;
@@ -35,7 +36,6 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.agentclient.AgentClient;
-import org.rhq.enterprise.server.common.EntityContext;
/**
* A manager for {@link MeasurementSchedule}s.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java
index d8f0074..c7611cb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerBean.java
@@ -23,7 +23,7 @@ import java.util.List;
import javax.ejb.Stateless;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.enterprise.server.common.EntityContext;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricViewData;
import org.rhq.enterprise.server.measurement.MeasurementPreferences.MetricViewsPreferences;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java
index f6ce639..473269e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementViewManagerLocal.java
@@ -23,7 +23,7 @@ import java.util.List;
import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.enterprise.server.common.EntityContext;
+import org.rhq.core.domain.common.EntityContext;
/**
* @author Joseph Marques
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java
index 42ce980..9968592 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/uibean/MetricDisplaySummary.java
@@ -20,8 +20,8 @@ package org.rhq.enterprise.server.measurement.uibean;
import java.util.Date;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.enterprise.server.common.EntityContext;
public class MetricDisplaySummary extends BaseMetricDisplay implements java.io.Serializable {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java
index cae22fd..0e37e3d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/util/MeasurementDataManagerUtility.java
@@ -37,12 +37,12 @@ import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementDataPK;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.measurement.MeasurementAggregate;
import org.rhq.enterprise.server.measurement.MeasurementNotFoundException;
import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java
index 8323299..dc708f5 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/event/test/EventManagerTest.java
@@ -32,6 +32,7 @@ import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventDefinition;
import org.rhq.core.domain.event.EventSeverity;
@@ -41,7 +42,6 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
index 6f6ec38..3145682 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
@@ -51,6 +51,7 @@ import org.rhq.core.domain.alert.BooleanExpression;
import org.rhq.core.domain.alert.notification.AlertNotificationLog;
import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventDefinition;
import org.rhq.core.domain.event.EventSeverity;
@@ -74,7 +75,6 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.exception.ThrowableUtil;
-import org.rhq.enterprise.server.common.EntityContext;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.CallTimeDataManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
commit 672f7c1867cb3ef6937b678da9e601e504c15fea
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Sat Sep 4 01:21:08 2010 -0400
finish Traits subtabs
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java
index 2fd4dcf..2f13722 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDataTraitCriteria.java
@@ -29,7 +29,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
/**
- * RHQ {@link Criteria} object for filtered, sortable queries of {@link MeasurementDataTrait} data sets.
+ * RHQ {@link Criteria} object for filtered, sortable queries of {@link MeasurementDataTrait trait} data sets.
*
* @author Ian Springer
*/
@@ -38,28 +38,31 @@ import javax.xml.bind.annotation.XmlAccessorType;
public class MeasurementDataTraitCriteria extends Criteria {
private static final long serialVersionUID = 1L;
- // sort fields
+ // sort field names
public static final String SORT_FIELD_SCHEDULE_ID = "scheduleId";
public static final String SORT_FIELD_TIMESTAMP = "timestamp";
- public static final String SORT_FIELD_NAME = "name";
+ public static final String SORT_FIELD_DISPLAY_NAME = "displayName";
public static final String SORT_FIELD_VALUE = "value";
+ public static final String SORT_FIELD_RESOURCE_NAME = "resourceName";
- // filter fields
+ // filter field names
public static final String FILTER_FIELD_SCHEDULE_ID = "scheduleId";
public static final String FILTER_FIELD_RESOURCE_ID = "resourceId";
public static final String FILTER_FIELD_GROUP_ID = "groupId";
+ public static final String FILTER_FIELD_DEFINITION_ID = "definitionId";
public static final String FILTER_FIELD_MAX_TIMESTAMP = "maxTimestamp";
private Integer filterScheduleId; // requires overrides
private Integer filterResourceId; // requires overrides
private Integer filterGroupId; // requires overrides
- private Boolean filterMaxTimestamp; // requires overrides
+ private Integer filterDefinitionId; // requires overrides
+ private Integer filterMaxTimestamp; // requires overrides
private boolean fetchSchedule;
- private PageOrdering sortScheduleId; // requires overrides
private PageOrdering sortTimestamp; // requires overrides
- private PageOrdering sortName; // requires overrides
+ private PageOrdering sortDisplayName; // requires overrides
+ private PageOrdering sortResourceName; // requires overrides
public MeasurementDataTraitCriteria() {
filterOverrides.put(FILTER_FIELD_SCHEDULE_ID, "id.scheduleId = ?");
@@ -69,14 +72,16 @@ public class MeasurementDataTraitCriteria extends Criteria {
+ " FROM Resource res " //
+ " JOIN res.implicitGroups ig " //
+ " WHERE ig.id = ? )");
+ filterOverrides.put(FILTER_FIELD_DEFINITION_ID, "schedule.definition.id = ?");
filterOverrides.put(FILTER_FIELD_MAX_TIMESTAMP, "id.timestamp = " //
+ "( SELECT MAX(mdt.id.timestamp) "
+ " FROM MeasurementDataTrait mdt "
- + " WHERE mdt.id.scheduleId = id.scheduleId )");
-
- sortOverrides.put(SORT_FIELD_SCHEDULE_ID, "id.scheduleId");
+ + " WHERE mdt.id.scheduleId = " + getAlias() + ".id.scheduleId ) "
+ + " AND 1 = ?");
+
sortOverrides.put(SORT_FIELD_TIMESTAMP, "id.timestamp");
- sortOverrides.put(SORT_FIELD_NAME, "schedule.definition.displayName");
+ sortOverrides.put(SORT_FIELD_DISPLAY_NAME, "schedule.definition.displayName");
+ sortOverrides.put(SORT_FIELD_RESOURCE_NAME, "schedule.resource.name");
}
@Override
@@ -102,17 +107,16 @@ public class MeasurementDataTraitCriteria extends Criteria {
this.filterGroupId = filterGroupId;
}
- public void addFilterMaxTimestamp(Boolean filterMaxTimestamp) {
- this.filterMaxTimestamp = filterMaxTimestamp;
+ public void addFilterDefinitionId(Integer filterDefinitionId) {
+ this.filterDefinitionId = filterDefinitionId;
}
- public void fetchSchedule(boolean fetchSchedule) {
- this.fetchSchedule = fetchSchedule;
+ public void addFilterMaxTimestamp() {
+ this.filterMaxTimestamp = 1;
}
- public void addSortScheduleId(PageOrdering sortScheduleId) {
- addSortField(SORT_FIELD_SCHEDULE_ID);
- this.sortScheduleId = sortScheduleId;
+ public void fetchSchedule(boolean fetchSchedule) {
+ this.fetchSchedule = fetchSchedule;
}
public void addSortTimestamp(PageOrdering sortTimestamp) {
@@ -121,7 +125,12 @@ public class MeasurementDataTraitCriteria extends Criteria {
}
public void addSortName(PageOrdering sortName) {
- addSortField(SORT_FIELD_NAME);
- this.sortName = sortName;
+ addSortField(SORT_FIELD_DISPLAY_NAME);
+ this.sortDisplayName = sortName;
+ }
+
+ public void addSortResourceName(PageOrdering sortResourceName) {
+ addSortField(SORT_FIELD_RESOURCE_NAME);
+ this.sortResourceName = sortResourceName;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
index 6c579ce..512540e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tab/SubTabLayout.java
@@ -259,7 +259,7 @@ public class SubTabLayout extends LocatableVLayout {
public void fireSubTabSelection() {
TwoLevelTabSelectedEvent event = new TwoLevelTabSelectedEvent("?", getCurrentTitle(), -1, currentIndex,
- currentlyDisplayed.getCanvas());
+ getCurrentCanvas());
hm.fireEvent(event);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 1b5a6cf..c26ccef 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -171,13 +171,16 @@ public class Table extends LocatableHLayout {
listGrid.setAutoFitData(Autofit.HORIZONTAL);
listGrid.setAlternateRecordStyles(true);
listGrid.setResizeFieldsInRealTime(false);
+
// By default, SmartGWT will disable any rows that have a record named "enabled" with a value of false - setting
// these fields to a bogus field name will disable this behavior. Note, setting them to null does *not* disable
// the behavior.
listGrid.setRecordEnabledProperty("foobar");
- //listGrid.setRecordCanSelectProperty("foobar");
listGrid.setRecordEditProperty("foobar");
+ // TODO: Uncomment the below line once we've upgraded to SmartGWT 2.3.
+ //listGrid.setRecordCanSelectProperty("foobar");
+
if (dataSource != null) {
listGrid.setDataSource(dataSource);
}
@@ -206,7 +209,6 @@ public class Table extends LocatableHLayout {
titleLayout = new HLayout();
titleLayout.setAutoHeight();
titleLayout.setAlign(VerticalAlignment.BOTTOM);
-
}
// Add components to the view
@@ -224,7 +226,7 @@ public class Table extends LocatableHLayout {
contents.addMember(footer);
// The ListGrid has been created and configured
- // Now give extensions a chance to configure the table
+ // Now give subclasses a chance to configure the table
configureTable();
tableInfo = new Label("Total: " + listGrid.getTotalRows());
@@ -331,6 +333,17 @@ public class Table extends LocatableHLayout {
}
+ public String getTitle() {
+ return this.tableTitle;
+ }
+
+ public void setTitle(String title) {
+ this.tableTitle = title;
+ if (this.title != null) {
+ setTableTitle(title);
+ }
+ }
+
/**
* Returns the encompassing canvas that contains all content for this table component.
* This content includes the list grid, the buttons, etc.
@@ -432,7 +445,7 @@ public class Table extends LocatableHLayout {
this.headerIcon = headerIcon;
}
- private void refreshTableInfo() {
+ protected void refreshTableInfo() {
if (showFooter) {
int count = this.listGrid.getSelection().length;
for (TableActionInfo tableAction : tableActions) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index 01a19f3..3442fe1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -109,14 +109,12 @@ public abstract class TableSection extends Table implements BookmarkableView {
* @param record the record whose details are to be shown
*/
public void showDetails(ListGridRecord record) {
- Integer id = record.getAttributeAsInt("id");
- if (id != null) {
- showDetails(id.intValue());
- } else {
- String msg = "table [" + this.getClass() + "] is missing 'id' attrib! please report this bug";
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalArgumentException(msg);
+ if (record == null) {
+ throw new IllegalArgumentException("'record' parameter is null.");
}
+
+ Integer id = getId(record);
+ showDetails(id);
}
/**
@@ -131,18 +129,18 @@ public abstract class TableSection extends Table implements BookmarkableView {
* @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
*/
public Canvas getDetailsView(ListGridRecord record) {
- if (record == null) {
- return getDetailsView(0);
- }
+ Integer id = getId(record);
+ return getDetailsView(id);
+ }
- Integer id = record.getAttributeAsInt("id");
- if (id != null) {
- return getDetailsView(id.intValue());
- } else {
- String msg = "table [" + this.getClass() + "] is missing 'id' attrib. please report this bug";
+ protected Integer getId(ListGridRecord record) {
+ Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
+ if (id == null) {
+ String msg = "Table [" + this.getClass() + "] record is missing 'id' attribute - please report this bug.";
CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalArgumentException(msg);
+ throw new IllegalStateException(msg);
}
+ return id;
}
/**
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
index d529087..a21e4f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java
@@ -55,14 +55,16 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
protected List<DataSourceField> createFields() {
List<DataSourceField> fields = new ArrayList<DataSourceField>();
- // Note: The fields
+ DataSourceTextField primaryKeyField = new DataSourceTextField("primaryKey", "Primary Key");
+ primaryKeyField.setPrimaryKey(true);
+ primaryKeyField.setHidden(true);
+ fields.add(primaryKeyField);
- DataSourceIntegerField idField = new DataSourceIntegerField(MeasurementDataTraitCriteria.SORT_FIELD_SCHEDULE_ID,
- "Id");
+ DataSourceIntegerField idField = new DataSourceIntegerField("id", "Definition Id");
idField.setHidden(true);
fields.add(idField);
- DataSourceTextField nameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_NAME,
+ DataSourceTextField nameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME,
"Trait");
fields.add(nameField);
@@ -118,6 +120,11 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
} else if (fieldName.equals(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID)) {
Integer groupId = (Integer) values.get(fieldName);
criteria.addFilterGroupId(groupId);
+ } else if (fieldName.equals(MeasurementDataTraitCriteria.FILTER_FIELD_DEFINITION_ID)) {
+ Integer definitionId = (Integer) values.get(fieldName);
+ criteria.addFilterDefinitionId(definitionId);
+ } else if (fieldName.equals(MeasurementDataTraitCriteria.FILTER_FIELD_MAX_TIMESTAMP)) {
+ criteria.addFilterMaxTimestamp();
}
}
}
@@ -135,12 +142,11 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
public ListGridRecord copyValues(MeasurementDataTrait from) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_SCHEDULE_ID, from.getScheduleId());
+ record.setAttribute("primaryKey", from.getScheduleId() + ":" + from.getTimestamp());
+ record.setAttribute("id", from.getSchedule().getDefinition().getId()); // used for detail view
record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP, from.getTimestamp());
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_NAME, from.getSchedule().getDefinition().getDisplayName());
+ record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, from.getSchedule().getDefinition().getDisplayName());
record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_VALUE, from.getValue());
-
- // TODO: resourceId and resourceGroupId (in subclasses)
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java
new file mode 100644
index 0000000..3df0310
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListDetailView.java
@@ -0,0 +1,87 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+
+/**
+ * A view that displays a non-paginated table of {@link org.rhq.core.domain.measurement.MeasurementDataTrait trait}s,
+ * along with the ability to sort those traits.
+ *
+ * @author Ian Springer
+ */
+public abstract class AbstractMeasurementDataTraitListDetailView extends Table {
+ private static final String[] EXCLUDED_FIELD_NAMES = new String[] {
+ MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME
+ };
+
+ private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[] {
+ //new SortSpecifier(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, SortDirection.ASCENDING)
+ };
+
+ public AbstractMeasurementDataTraitListDetailView(String locatorId, String title,
+ AbstractMeasurementDataTraitDataSource dataSource, Criteria criteria) {
+ super(locatorId, title, criteria, SORT_SPECIFIERS, EXCLUDED_FIELD_NAMES);
+ setDataSource(dataSource);
+ }
+
+ @Override
+ public AbstractMeasurementDataTraitDataSource getDataSource() {
+ return (AbstractMeasurementDataTraitDataSource) super.getDataSource();
+ }
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ ListGrid listGrid = getListGrid();
+ listGrid.setSelectionType(SelectionStyle.NONE);
+
+ // Set widths and cell formatters on the fields.
+ ListGridField timestampField = listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP);
+ timestampField.setWidth("20%");
+ timestampField.setCellFormatter(new TimestampCellFormatter());
+
+ listGrid.addDataArrivedHandler(new DataArrivedHandler() {
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ initTitle();
+ }
+ });
+ }
+
+ private void initTitle() {
+ if (getTitle() == null) {
+ // Now that the table data has been loaded, set the title to include the trait name.
+ ListGridRecord record = getListGrid().getRecord(0);
+ String displayName = record.getAttributeAsString(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME);
+ String title = "Value History for Trait '" + displayName + "'";
+ setTitle(title);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListView.java
index c6c5bc9..6468f5c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitListView.java
@@ -26,7 +26,7 @@ import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
/**
@@ -35,13 +35,18 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellForma
*
* @author Ian Springer
*/
-public abstract class AbstractMeasurementDataTraitListView extends Table {
- private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[] { new SortSpecifier(
- MeasurementDataTraitCriteria.SORT_FIELD_NAME, SortDirection.ASCENDING) };
+public abstract class AbstractMeasurementDataTraitListView extends TableSection {
+ private static final String TITLE = "Traits";
+ private static final String[] EXCLUDED_FIELD_NAMES = new String[0];
- public AbstractMeasurementDataTraitListView(String locatorId, String title,
- AbstractMeasurementDataTraitDataSource dataSource, Criteria criteria, String[] excludedFieldNames) {
- super(locatorId, title, criteria, SORT_SPECIFIERS, excludedFieldNames);
+ private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[] {
+ new SortSpecifier(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME, SortDirection.ASCENDING)
+ //,new SortSpecifier(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP, SortDirection.DESCENDING)
+ };
+
+ public AbstractMeasurementDataTraitListView(String locatorId,
+ AbstractMeasurementDataTraitDataSource dataSource, Criteria criteria) {
+ super(locatorId, TITLE, criteria, SORT_SPECIFIERS, EXCLUDED_FIELD_NAMES);
setDataSource(dataSource);
}
@@ -50,7 +55,6 @@ public abstract class AbstractMeasurementDataTraitListView extends Table {
return (AbstractMeasurementDataTraitDataSource) super.getDataSource();
}
-
@Override
protected void configureTable() {
super.configureTable();
@@ -59,8 +63,7 @@ public abstract class AbstractMeasurementDataTraitListView extends Table {
listGrid.setSelectionType(SelectionStyle.SINGLE);
// Set widths and cell formatters on the fields.
- listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_NAME).setWidth("20%");
- listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_VALUE).setWidth("60%");
+ listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME).setWidth("20%");
ListGridField timestampField = listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_TIMESTAMP);
timestampField.setWidth("20%");
timestampField.setCellFormatter(new TimestampCellFormatter());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
index a9abcaf..28aee70 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
@@ -42,17 +43,28 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
@Override
protected List<DataSourceField> createFields() {
List<DataSourceField> fields = super.createFields();
- DataSourceField groupIdField = new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID,
- "Group Id");
+
+ DataSourceIntegerField groupIdField =
+ new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, "Group Id");
groupIdField.setHidden(true);
- fields.add(groupIdField);
+ fields.add(0, groupIdField);
+
+ DataSourceTextField resourceNameField = new DataSourceTextField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME,
+ "Resource Name");
+ fields.add(0, resourceNameField);
+
return fields;
}
@Override
public ListGridRecord copyValues(MeasurementDataTrait from) {
ListGridRecord record = super.copyValues(from);
+
record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, this.groupId);
+
+ record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME,
+ from.getSchedule().getResource().getName());
+
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java
new file mode 100644
index 0000000..46ed7ad
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java
@@ -0,0 +1,57 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitListDetailView;
+
+/**
+ * The detail view for the group Monitoring>Traits subtab.
+ *
+ * @author Ian Springer
+ */
+public class TraitsDetailView extends AbstractMeasurementDataTraitListDetailView {
+ public TraitsDetailView(String locatorId, int groupId, int definitionId) {
+ super(locatorId, null, new TraitsDataSource(groupId), createCriteria(groupId, definitionId));
+ }
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ ListGrid listGrid = getListGrid();
+
+ // TODO (ips): Disambiguate Resource name.
+ ListGridField resourceNameField = listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME);
+ resourceNameField.setWidth("20%");
+ resourceNameField.setCanGroupBy(true);
+ }
+
+ private static Criteria createCriteria(int groupId, int definitionId) {
+ Criteria criteria = new Criteria();
+
+ criteria.addCriteria(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, groupId);
+ criteria.addCriteria(MeasurementDataTraitCriteria.FILTER_FIELD_DEFINITION_ID, definitionId);
+
+ return criteria;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
index 269420c..d35c6e7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
@@ -19,10 +19,13 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.GroupStartOpen;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits.TraitsDataSource;
/**
* The group Monitoring>Traits subtab.
@@ -30,20 +33,40 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitorin
* @author Ian Springer
*/
public class TraitsView extends AbstractMeasurementDataTraitListView {
+ private int groupId;
- private static final String TITLE = "Traits";
+ public TraitsView(String locatorId, int groupId) {
+ super(locatorId, new TraitsDataSource(groupId), createCriteria(groupId));
+ this.groupId = groupId;
+ }
- private static final String[] EXCLUDED_FIELD_NAMES = new String[] { MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID };
+ @Override
+ protected void configureTable() {
+ super.configureTable();
- public TraitsView(String locatorId, int groupId) {
- super(locatorId, TITLE, new TraitsDataSource(groupId), createCriteria(groupId), EXCLUDED_FIELD_NAMES);
- // TODO (ips): add column for Resource name
- // TODO (ips): group rows by trait
+ ListGrid listGrid = getListGrid();
+
+ listGrid.setShowAllRecords(true);
+ listGrid.setGroupStartOpen(GroupStartOpen.ALL);
+ listGrid.groupBy(MeasurementDataTraitCriteria.SORT_FIELD_DISPLAY_NAME);
+
+ // TODO (ips): Disambiguate Resource name.
+ ListGridField resourceNameField = listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME);
+ resourceNameField.setWidth("20%");
+ resourceNameField.setCanGroupBy(true);
+ }
+
+ @Override
+ public Canvas getDetailsView(int definitionId) {
+ return new TraitsDetailView(extendLocatorId("Detail"), this.groupId, definitionId);
}
private static Criteria createCriteria(int groupId) {
Criteria criteria = new Criteria();
+
criteria.addCriteria(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, groupId);
+ criteria.addCriteria(MeasurementDataTraitCriteria.FILTER_FIELD_MAX_TIMESTAMP, true);
+
return criteria;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
index 77cb4bb..c569260 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDataSource.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits;
+import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -33,26 +34,24 @@ import java.util.List;
* @author Ian Springer
*/
public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
- private int resourceId;
-
- public TraitsDataSource(int resourceId) {
- this.resourceId = resourceId;
- }
-
@Override
protected List<DataSourceField> createFields() {
List<DataSourceField> fields = super.createFields();
- DataSourceField resourceIdField = new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID,
- "Resource Id");
+
+ DataSourceIntegerField resourceIdField =
+ new DataSourceIntegerField(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, "Resource Id");
resourceIdField.setHidden(true);
- fields.add(resourceIdField);
+ fields.add(0, resourceIdField);
+
return fields;
}
@Override
public ListGridRecord copyValues(MeasurementDataTrait from) {
ListGridRecord record = super.copyValues(from);
- record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, this.resourceId);
+
+ record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, from.getSchedule().getResource().getId());
+
return record;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDetailView.java
new file mode 100644
index 0000000..da87700
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsDetailView.java
@@ -0,0 +1,44 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits;
+
+import com.smartgwt.client.data.Criteria;
+import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitListDetailView;
+
+/**
+ * The detail view for the Resource Monitoring>Traits subtab.
+ *
+ * @author Ian Springer
+ */
+public class TraitsDetailView extends AbstractMeasurementDataTraitListDetailView {
+ public TraitsDetailView(String locatorId, int resourceId, int definitionId) {
+ super(locatorId, null, new TraitsDataSource(), createCriteria(resourceId, definitionId)
+ );
+ }
+
+ private static Criteria createCriteria(int resourceId, int definitionId) {
+ Criteria criteria = new Criteria();
+
+ criteria.addCriteria(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, resourceId);
+ criteria.addCriteria(MeasurementDataTraitCriteria.FILTER_FIELD_DEFINITION_ID, definitionId);
+
+ return criteria;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
index 8a9c9c7..0d3b161 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitori
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitListView;
@@ -29,18 +30,24 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasuremen
* @author Ian Springer
*/
public class TraitsView extends AbstractMeasurementDataTraitListView {
-
- private static final String TITLE = "Traits";
-
- private static final String[] EXCLUDED_FIELD_NAMES = new String[] { MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID };
+ private int resourceId;
public TraitsView(String locatorId, int resourceId) {
- super(locatorId, TITLE, new TraitsDataSource(resourceId), createCriteria(resourceId), EXCLUDED_FIELD_NAMES);
+ super(locatorId, new TraitsDataSource(), createCriteria(resourceId));
+ this.resourceId = resourceId;
+ }
+
+ @Override
+ public Canvas getDetailsView(int definitionId) {
+ return new TraitsDetailView(extendLocatorId("Detail"), this.resourceId, definitionId);
}
private static Criteria createCriteria(int resourceId) {
Criteria criteria = new Criteria();
+
criteria.addCriteria(MeasurementDataTraitCriteria.FILTER_FIELD_RESOURCE_ID, resourceId);
+ criteria.addCriteria(MeasurementDataTraitCriteria.FILTER_FIELD_MAX_TIMESTAMP, true);
+
return criteria;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
index 3fece05..3a5f53b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
@@ -845,9 +845,17 @@ public class MeasurementDataManagerBean implements MeasurementDataManagerLocal,
this.entityManager);
PageList<MeasurementDataTrait> results = queryRunner.execute();
- // Fetch the definitions, so the results include the trait names.
+ // Fetch the metric definition for each schedule, so the results include the trait names.
for (MeasurementDataTrait result : results) {
- result.getSchedule().getDefinition();
+ result.getSchedule().getDefinition().getName();
+ }
+
+ // If the query is filtered by group id, also fetch the Resource for each schedule, so the results include the
+ // Resource names.
+ if (filterFields.get(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID) != null) {
+ for (MeasurementDataTrait result : results) {
+ result.getSchedule().getResource().getName();
+ }
}
return results;
commit 3f2b2d7ab890f050e65e90508f95866a29278558
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Sep 3 08:59:37 2010 -0400
Remove use of GWT.create() from some portlets. This uses the no-arg
constructor under the covers. We want to use constructors with explicit
locatorIds.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index fe33c31..0356212 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -56,7 +56,6 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements P
public static PortletViewFactory INSTANCE = new Factory();
public final Portlet getInstance(String locatorId) {
- //return GWT.create(AutodiscoveryPortlet.class);
return new AutodiscoveryPortlet(locatorId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 5119bf1..b7eeef9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -19,7 +19,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operatio
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-import com.google.gwt.core.client.GWT;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -46,12 +45,6 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
private static String recentOperations = "Recent Operations";
private static String scheduledOperations = "Scheduled Operations";
- //default no-args constructor for serialization.
- //TODO: spinder 9/2/10 revisit why we need to do this?
- private OperationsPortlet() {
- super("(unitialized)");
- }
-
public OperationsPortlet(String locatorId) {
super(locatorId);
}
@@ -115,14 +108,9 @@ public class OperationsPortlet extends LocatableVLayout implements Portlet {
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
- public final Portlet getInstance() {
- return GWT.create(OperationsPortlet.class);
- }
-
public final Portlet getInstance(String locatorId) {
return new OperationsPortlet(locatorId);
}
-
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 9838932..f87d80d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems
import java.util.ArrayList;
-import com.google.gwt.core.client.GWT;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
@@ -61,10 +60,6 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
public static final String unlimited = "unlimited";
public static final String defaultValue = unlimited;
- private ProblemResourcesPortlet() {
- super("(uninitialized)");
- }
-
public ProblemResourcesPortlet(String locatorId) {
super(locatorId, TITLE, true);
@@ -228,11 +223,7 @@ public class ProblemResourcesPortlet extends Table implements CustomSettingsPort
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
- public final Portlet getInstance() {
- return GWT.create(ProblemResourcesPortlet.class);
- }
-
- public Portlet getInstance(String locatorId) {
+ public final Portlet getInstance(String locatorId) {
return new ProblemResourcesPortlet(locatorId);
}
}
commit 13344f52f5e36ca340b4f246a3368c25120a66c6
Merge: 6cd1302... 0ba7c59...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Sep 2 10:32:47 2010 -0400
Merge branch 'master' into master-jay
commit 6cd13026c279f154b4d38b10674987e5fb57a246
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Sep 2 10:30:58 2010 -0400
Selenium Work - Administration Section work
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
index 146303a..2a7db09 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
@@ -38,8 +38,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*/
public class SubjectRoleSelector extends AbstractSelector<Role> {
- public SubjectRoleSelector(String id, Collection<Role> roles) {
- super(id);
+ public SubjectRoleSelector(String locatorId, Collection<Role> roles) {
+ super(locatorId);
if (roles != null) {
ListGridRecord[] data = (new RolesDataSource()).buildRecords(roles);
setAssigned(data);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index 5aefeec..1a36bc7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -52,6 +52,9 @@ import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -93,7 +96,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
}
private Canvas buildSubjectEditor() {
- form = new DynamicForm();
+ form = new LocatableDynamicForm(this.getLocatorId());
form.setWidth100();
form.setHiliteRequiredFields(true);
@@ -129,7 +132,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
TextItem departmentItem = new TextItem("department");
departmentItem.setRequired(false);
- IButton saveButton = new IButton("Save");
+ IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
if (form.validate()) {
@@ -142,14 +145,14 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
}
});
- IButton resetButton = new IButton("Reset");
+ IButton resetButton = new LocatableIButton(this.extendLocatorId("Reset"), "Reset");
resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
form.reset();
}
});
- IButton cancelButton = new IButton("Cancel");
+ IButton cancelButton = new LocatableIButton(this.extendLocatorId("Cancel"), "Cancel");
cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
if (editorWindow != null) {
@@ -160,7 +163,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
}
});
- HLayout buttonLayout = new HLayout(10);
+ HLayout buttonLayout = new LocatableHLayout(this.extendLocatorId("Buttons"), 10);
buttonLayout.setAlign(Alignment.CENTER);
buttonLayout.addMember(saveButton);
buttonLayout.addMember(resetButton);
@@ -210,7 +213,8 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
// form.getDataSource().getField("username").setCanEdit(true );
- roleSelector = new SubjectRoleSelector("UserEditor-Roles", (Set<Role>) record.getAttributeAsObject("roles"));
+ roleSelector = new SubjectRoleSelector(this.extendLocatorId("Roles"), (Set<Role>) record
+ .getAttributeAsObject("roles"));
roleSelectionItem.setCanvas(roleSelector);
try {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index 3d09ed8..9d56dc2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -41,18 +41,15 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.admin.agent.install.RemoteAgentInstallView;
-import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
-import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
-import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
import org.rhq.enterprise.gui.coregui.client.report.measurement.MeasurementOOBView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
* @author Greg Hinkle
@@ -61,6 +58,9 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
public static final String VIEW_PATH = "Reports";
+ private static final String SECTION_INVENTORY = "Inventory";
+ private static final String SECTION_REPORTS = "Reports";
+
private ViewId currentSectionViewId;
private ViewId currentPageViewId;
@@ -85,16 +85,14 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
contentCanvas.setWidth("*");
contentCanvas.setHeight100();
- sectionStack = new SectionStack();
+ sectionStack = new LocatableSectionStack(this.getLocatorId());
sectionStack.setShowResizeBar(true);
sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
sectionStack.setWidth(250);
sectionStack.setHeight100();
- treeGrids.put("Inventory", buildInventorySection());
- // treeGrids.put("Configuration", buildSystemConfigurationSection());
- // treeGrids.put("Cluster", buildManagementClusterSection());
- treeGrids.put("Reports", buildReportsSection());
+ treeGrids.put(SECTION_INVENTORY, buildInventorySection());
+ treeGrids.put(SECTION_REPORTS, buildReportsSection());
for (final String name : treeGrids.keySet()) {
TreeGrid grid = treeGrids.get(name);
@@ -128,7 +126,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
private TreeGrid buildInventorySection() {
- final TreeGrid inventoryTreeGrid = new TreeGrid();
+ final TreeGrid inventoryTreeGrid = new LocatableTreeGrid(SECTION_INVENTORY);
inventoryTreeGrid.setLeaveScrollbarGap(false);
inventoryTreeGrid.setShowHeader(false);
@@ -154,65 +152,24 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
final TreeNode platforms = new TreeNode("Platforms");
platforms.setIcon("types/Platform_up_16.png");
- tree.setRoot(new TreeNode("inventory", tagCloud, suspectMetrics, recentConfigurationChanges, recentOperations,
- recentAlerts, alertDefinitions, platforms));
+ tree.setRoot(new TreeNode(SECTION_INVENTORY, tagCloud, suspectMetrics, recentConfigurationChanges,
+ recentOperations, recentAlerts, alertDefinitions, platforms));
inventoryTreeGrid.setData(tree);
return inventoryTreeGrid;
}
- private TreeGrid buildManagementClusterSection() {
-
- final TreeGrid mgmtClusterTreeGrid = new TreeGrid();
- mgmtClusterTreeGrid.setLeaveScrollbarGap(false);
- mgmtClusterTreeGrid.setShowHeader(false);
-
- Tree tree = new Tree();
- final TreeNode manageServersNode = new TreeNode("Servers");
- final TreeNode manageAgentsNode = new TreeNode("Agents");
- final TreeNode manageAffinityGroupsNode = new TreeNode("Affinity Groups");
- final TreeNode managePartitionEventsNode = new TreeNode("Partition Events");
-
- tree.setRoot(new TreeNode("clustering", manageServersNode, manageAgentsNode, manageAffinityGroupsNode,
- managePartitionEventsNode));
-
- mgmtClusterTreeGrid.setData(tree);
-
- return mgmtClusterTreeGrid;
- }
-
- private TreeGrid buildSystemConfigurationSection() {
-
- final TreeGrid systemConfigTreeGrid = new TreeGrid();
- systemConfigTreeGrid.setLeaveScrollbarGap(false);
- systemConfigTreeGrid.setShowHeader(false);
-
- Tree tree = new Tree();
- final TreeNode manageSettings = new TreeNode("System Settings");
- final TreeNode manageTemplates = new TreeNode("Templates");
- final TreeNode manageDownloads = new TreeNode("Downloads");
- final TreeNode manageLicense = new TreeNode("License");
- final TreeNode managePlugins = new TreeNode("Plugins");
-
- tree.setRoot(new TreeNode("System Configuration", manageSettings, manageTemplates, manageDownloads,
- manageLicense, managePlugins));
-
- systemConfigTreeGrid.setData(tree);
-
- return systemConfigTreeGrid;
- }
-
private TreeGrid buildReportsSection() {
- final TreeGrid reportsTreeGrid = new TreeGrid();
+ final TreeGrid reportsTreeGrid = new LocatableTreeGrid(SECTION_REPORTS);
reportsTreeGrid.setLeaveScrollbarGap(false);
reportsTreeGrid.setShowHeader(false);
Tree tree = new Tree();
final TreeNode inventorySummaryNode = new TreeNode("Inventory Summary");
- TreeNode reportsNode = new TreeNode("Reports", inventorySummaryNode);
+ TreeNode reportsNode = new TreeNode(SECTION_REPORTS, inventorySummaryNode);
tree.setRoot(reportsNode);
reportsTreeGrid.setData(tree);
@@ -244,7 +201,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
page = URL.decode(page);
Canvas content = null;
- if ("Inventory".equals(section)) {
+ if (SECTION_INVENTORY.equals(section)) {
if ("Tag Cloud".equals(page)) {
content = new TaggedView(this.extendLocatorId("TagCloud"));
@@ -262,49 +219,12 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
content = new PlatformPortletView(this.extendLocatorId("Platforms"));
}
- } else if ("Security".equals(section)) {
-
- if ("Manage Users".equals(page)) {
- content = new UsersView(this.extendLocatorId("Users"));
- } else if ("Manage Roles".equals(page)) {
- content = new RolesView(this.extendLocatorId("Roles"));
- } else if ("Auto Discovery Queue".equals(page)) {
- content = new ResourceAutodiscoveryView(this.extendLocatorId("ADQ"));
- } else if ("Remote Agent Install".equals(page)) {
- content = new RemoteAgentInstallView(this.extendLocatorId("RemoteAgentInstall"));
- }
- } else if ("Configuration".equals(section)) {
-
- String url = null;
- if ("System Settings".equals(page)) {
- url = "/admin/config/Config.do?mode=edit";
- } else if ("Templates".equals(page)) {
- url = "/admin/config/EditDefaults.do?mode=monitor&viewMode=all";
- } else if ("Downloads".equals(page)) {
- url = "/rhq/admin/downloads-body.xhtml";
- } else if ("License".equals(page)) {
- url = "/admin/license/LicenseAdmin.do?mode=view";
- } else if ("Plugins".equals(page)) {
- url = "/rhq/admin/plugin/plugin-list.xhtml";
+ } else if (SECTION_REPORTS.equals(section)) {
+ if ("Inventory Summary".equals(page)) {
+ // TODO
+ content = null;
}
- url = addQueryStringParam(url, "nomenu=true");
- content = new FullHTMLPane(url);
-
- } else if ("Cluster".equals(section)) {
- String url = null;
- if ("Servers".equals(page)) {
- url = "/rhq/ha/listServers.xhtml";
- } else if ("Agents".equals(page)) {
- url = "/rhq/ha/listAgents.xhtml";
- } else if ("Affinity Groups".equals(page)) {
- url = "/rhq/ha/listAffinityGroups.xhtml";
- } else if ("Partition Events".equals(page)) {
- url = "/rhq/ha/listPartitionEvents.xhtml";
- }
- url = addQueryStringParam(url, "nomenu=true");
- content = new FullHTMLPane(url);
}
-
for (String name : treeGrids.keySet()) {
TreeGrid treeGrid = treeGrids.get(name);
@@ -318,12 +238,13 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
}
}
- setContent(content);
+ if (null != content) {
+ setContent(content);
- if (content instanceof BookmarkableView) {
- ((BookmarkableView) content).renderView(viewPath.next().next());
+ if (content instanceof BookmarkableView) {
+ ((BookmarkableView) content).renderView(viewPath.next().next());
+ }
}
-
}
public void renderView(ViewPath viewPath) {
@@ -345,9 +266,4 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
}
}
-
- private static String addQueryStringParam(String url, String param) {
- char separatorChar = (url.indexOf('?') == -1) ? '?' : '&';
- return url + separatorChar + param;
- }
}
\ No newline at end of file
commit 06b4a2c0fff9f975b213bc99b6f4e8efc37f3de5
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Aug 24 13:54:35 2010 -0400
Updating ScriptRunner to add lib directories to script classpath
diff --git a/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy b/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy
index 1c366d7..deb5001 100644
--- a/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy
+++ b/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ClasspathInitializer.groovy
@@ -1,7 +1,5 @@
package org.rhq.enterprise.server.plugins.groovy
-import org.codehaus.groovy.control.CompilerConfiguration
-
class ClasspathInitializer {
def initClasspath(String paths, String libDirs, scriptClassLoader) {
diff --git a/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy b/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy
index 6c9c44d..d5b1af0 100644
--- a/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy
+++ b/modules/enterprise/server/plugins/groovy-script/src/main/groovy/org/rhq/enterprise/server/plugins/groovy/ScriptRunner.groovy
@@ -53,11 +53,12 @@ class ScriptRunner implements ServerPluginComponent, ControlFacet {
def scriptName = parameters.getSimpleValue("script", null)
def paths = parameters.getSimpleValue("classpath", '')
+ def libDirs = parameters.getSimpleValue("libDirs", '')
log.debug("Preparing to execute script, $scriptName")
def scriptClassLoader = new GroovyClassLoader(Thread.currentThread().contextClassLoader, compilerConfig)
- new ClasspathInitializer().initClasspath(paths, null, scriptClassLoader)
+ new ClasspathInitializer().initClasspath(paths, libDirs, scriptClassLoader)
def scriptRoots = new URL[1]
scriptRoots[0] = new File(scriptName).toURI().toURL()
13 years, 9 months
[rhq] 2 commits - modules/core modules/enterprise
by ips
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 14
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java | 4
modules/enterprise/gui/coregui/pom.xml | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 53 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java | 211 ++++------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 43 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java | 44 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 28 +
17 files changed, 265 insertions(+), 169 deletions(-)
New commits:
commit e5fac0a1484e1c2404bfb815d98228c707afca01
Merge: 76eb27f... b02e602...
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 14 11:29:37 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 76eb27f1cdefa7028df485ed5ec1fa54f3018cb7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Sep 14 11:23:22 2010 -0400
fix a bunch of bugs in the resource tree plus start cleaning up / refactoring the tree code
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index 916bcc7..9355e30 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -665,7 +665,7 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_FIND_BY_ID_WITH_INSTALLED_PACKAGES, query = "SELECT r FROM Resource AS r LEFT JOIN r.installedPackages ip WHERE r.id = :id"),
@NamedQuery(name = Resource.QUERY_FIND_BY_ID_WITH_INSTALLED_PACKAGE_HIST, query = "SELECT r FROM Resource AS r LEFT JOIN r.installedPackageHistory ip WHERE r.id = :id"),
@NamedQuery(name = Resource.QUERY_FIND_PLATFORM_BY_AGENT, query = "SELECT res FROM Resource res WHERE res.resourceType.category = :category AND res.agent = :agent"),
- @NamedQuery(name = Resource.QUERY_FIND_PAREBT_ID, query = "SELECT res.parentResource.id FROM Resource AS res WHERE res.id = :id"),
+ @NamedQuery(name = Resource.QUERY_FIND_PARENT_ID, query = "SELECT res.parentResource.id FROM Resource AS res WHERE res.id = :id"),
@NamedQuery(name = Resource.QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE, query = ""
+ "SELECT DISTINCT r FROM Resource r "
+ "WHERE r.parentResource.id is null "
@@ -679,7 +679,7 @@ import org.rhq.core.domain.util.Summary;
+ " OR EXISTS (SELECT rr FROM Resource rr WHERE rr.id = :resourceId AND rr.parentResource.parentResource.parentResource.parentResource.parentResource = r) "
+ " OR EXISTS (SELECT rr FROM Resource rr WHERE rr.id = :resourceId AND rr.parentResource.parentResource.parentResource.parentResource.parentResource.parentResource = r) "
+ " )"), //
- @NamedQuery(name = Resource.QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME, query = "" //
+ @NamedQuery(name = Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME, query = "" //
+ "SELECT r.id " //
+ " FROM Resource r " //
+ " WHERE ( r.resourceType.id = :resourceTypeId OR :resourceTypeId IS NULL ) " //
@@ -692,7 +692,7 @@ import org.rhq.core.domain.util.Summary;
+ " OR r.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.parentResource.parentResource.id = :resourceId) "
+ " OR r.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.parentResource.parentResource.parentResource.id = :resourceId) "
+ " ) "),
- @NamedQuery(name = Resource.QUERY_FIND_DESCENDENTS, query = "" //
+ @NamedQuery(name = Resource.QUERY_FIND_DESCENDANTS, query = "" //
+ "SELECT r.id " //
+ " FROM Resource r " //
+ " WHERE r.id = :resourceId " //
@@ -846,12 +846,12 @@ public class Resource implements Comparable<Resource>, Serializable {
public static final String QUERY_FIND_PLATFORM_BY_AGENT = "Resource.findPlatformByAgent";
- public static final String QUERY_FIND_PAREBT_ID = "Resource.findParentId";
+ public static final String QUERY_FIND_PARENT_ID = "Resource.findParentId";
public static final String QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE = "Resource.findRootPlatformOfResource";
- public static final String QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME = "Resource.findDescendentsByTypeAndName";
- public static final String QUERY_FIND_DESCENDENTS = "Resource.findDescendents";
+ public static final String QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME = "Resource.findDescendantsByTypeAndName";
+ public static final String QUERY_FIND_DESCENDANTS = "Resource.findDescendants";
public static final String QUERY_MARK_RESOURCES_FOR_ASYNC_DELETION_QUICK = "Resource.markResourcesForAsyncDeletionQuick";
public static final String QUERY_FIND_RESOURCES_MARKED_FOR_ASYNC_DELETION = "Resource.findResourcesMarkedForAsyncDeletion";
@@ -913,7 +913,7 @@ public class Resource implements Comparable<Resource>, Serializable {
@JoinColumn(name = "RESOURCE_TYPE_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne
- // TODO GH: It would be prefferable for this to be lazy, but will need cleanup throughout the app (fetch = FetchType.LAZY)
+ // TODO GH: It would be preferable for this to be lazy, but will need cleanup throughout the app (fetch = FetchType.LAZY)
@Summary(index = 4)
private ResourceType resourceType;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java
index 80e92f6..14fd30f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceSubCategory.java
@@ -256,9 +256,9 @@ public class ResourceSubCategory implements Comparable<ResourceSubCategory>, Ser
}
/**
- * Returns this subcategory's parent subcategory, or null if this subcateogry has no parent.
+ * Returns this subcategory's parent subcategory, or null if this subcategory has no parent.
*
- * @return this subcategory's parent subcategory, or null if this subcateogry has no parent
+ * @return this subcategory's parent subcategory, or null if this subcategory has no parent
*/
public ResourceSubCategory getParentSubCategory() {
return parentSubCategory;
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 2d92aba..6ef33a5 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -130,7 +130,7 @@
<artifactId>quartz</artifactId>
<!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
<scope>provided</scope>
- <!-- by JBossAS itself, which the container build has packaged with 1.6.5 -->
+ <!-- by JBossAS itself, which the container buildNodes has packaged with 1.6.5 -->
</dependency>
<!-- needed for referenced domain entities that use Hibernate annotations (due to JDK5 bug) -->
@@ -288,9 +288,9 @@
<configuration>
<tasks>
<taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
- <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
+ <i18n outputdir="${project.buildNodes.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
<classpath refid="maven.runtime.classpath" />
- <classfileset dir="${project.build.outputDirectory}">
+ <classfileset dir="${project.buildNodes.outputDirectory}">
<include name="**/*I18NResourceKeys.class" />
</classfileset>
</i18n>
@@ -305,7 +305,7 @@
<phase>process-classes</phase>
<configuration>
<tasks>
- <copy todir="${project.build.outputDirectory}">
+ <copy todir="${project.buildNodes.outputDirectory}">
<fileset dir="src/main/webapp-filtered/WEB-INF/classes">
<include name="ApplicationResources.properties" />
</fileset>
@@ -352,7 +352,7 @@
<tasks>
<!--
<property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" />
- <echo>*** Copying updated files from target/${project.build.finalName}/WEB-INF/classes to ${classes.dir}...</echo>
+ <echo>*** Copying updated files from target/${project.buildNodes.finalName}/WEB-INF/classes to ${classes.dir}...</echo>
<copy todir="${classes.dir}" verbose="${rhq.verbose}">
<fileset dir="war/WEB-INF/classes" />
</copy>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
index 7498ad2..b332c3a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
@@ -103,7 +103,7 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
private void buildForm() {
if (!formBuilt) {
- // TODO build components
+ // TODO buildNodes components
// TODO setFields(components);
formBuilt = true;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index 2ad86d4..db9aeaa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -103,7 +103,7 @@ public class NotificationsAlertDefinitionForm extends LocatableDynamicForm imple
private void buildForm() {
if (!formBuilt) {
- // TODO build components
+ // TODO buildNodes components
// TODO setFields(components);
formBuilt = true;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
index b0ddff7..a3bd629 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/AbstractBundleCreateWizard.java
@@ -32,7 +32,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
public abstract class AbstractBundleCreateWizard extends AbstractWizard {
- // the things we build up in the wizard
+ // the things we buildNodes up in the wizard
private String recipe;
private BundleVersion bundleVersion;
private HashMap<String, Boolean> allBundleFilesStatus; // bundle file names with their upload status (true=they were uploaded)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
index a0728af..eef6af5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/AbstractBundleDeployWizard.java
@@ -30,7 +30,7 @@ import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
*/
public abstract class AbstractBundleDeployWizard extends AbstractWizard {
- // the things we build up in the wizard
+ // the things we buildNodes up in the wizard
private Integer bundleId;
private BundleDestination destination;
private boolean isNewDestination = false;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java
index cf69400..c393657 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/AbstractBundleRevertWizard.java
@@ -28,7 +28,7 @@ import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
*/
public abstract class AbstractBundleRevertWizard extends AbstractWizard {
- // the things we build up in the wizard
+ // the things we buildNodes up in the wizard
private BundleDestination destination;
private String deploymentDescription;
private BundleDeployment deployment;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
new file mode 100644
index 0000000..c0752a1
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -0,0 +1,53 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.tree;
+
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+/**
+ * @author Ian Springer
+ */
+public class EnhancedTreeNode extends TreeNode {
+ private static final String ID_FIELD = "id";
+ private static final String PARENT_ID_FIELD = "parentId";
+
+ public String getID() {
+ return getAttribute(ID_FIELD);
+ }
+
+ public String getParentID() {
+ return getAttribute(PARENT_ID_FIELD);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ String className = this.getClass().getName();
+ String simpleClassName = className.substring(className.lastIndexOf(".") + 1);
+ buffer.append(simpleClassName).append("[");
+ String id = getID();
+ buffer.append("id=").append(id);
+ String parentId = getParentID();
+ buffer.append(", parentId=").append(parentId);
+ String name = getName();
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
index 939c519..bccf8c5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeDataSource.java
@@ -165,7 +165,7 @@ public class NewResourceTreeDataSource extends DataSource {
EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children, ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
-// response.setData(build(result));
+// response.setData(buildNodes(result));
processResponse(requestId, response);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index fe4fdc2..9d7f395 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -44,15 +45,17 @@ import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
- * This doesn't extend RPCDataSource because it is tree oriented and
- * behaves different from normal list data sources in some places.
+ * This doesn't extend RPCDataSource because it is tree-oriented and behaves differently than normal list data sources
+ * in some places.
*
* @author Greg Hinkle
+ * @author Ian Springer
*/
public class ResourceTreeDatasource extends DataSource {
private List<Resource> initialData;
@@ -98,7 +101,7 @@ public class ResourceTreeDatasource extends DataSource {
String requestId = request.getRequestId();
DSResponse response = new DSResponse();
response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
- // Asume success
+ // Assume success
response.setStatus(0);
switch (request.getOperationType()) {
case ADD:
@@ -168,7 +171,8 @@ public class ResourceTreeDatasource extends DataSource {
ResourceTypeRepository.MetadataType.subCategory),
new ResourceTypeRepository.ResourceTypeLoadedCallback() {
public void onResourceTypeLoaded(List<Resource> result) {
- response.setData(build(result));
+ TreeNode[] treeNodes = buildNodes(result);
+ response.setData(treeNodes);
processResponse(requestId, response);
response.setStatus(DSResponse.STATUS_SUCCESS);
}
@@ -181,7 +185,7 @@ public class ResourceTreeDatasource extends DataSource {
* @param resources
* @return
*/
- public static TreeNode[] build(List<Resource> resources) {
+ public static TreeNode[] buildNodes(List<Resource> resources) {
ResourceTreeNode[] records = new ResourceTreeNode[resources.size()];
for (int x = 0; x < resources.size(); x++) {
Resource res = resources.get(x);
@@ -189,52 +193,54 @@ public class ResourceTreeDatasource extends DataSource {
records[x] = record;
}
- return introduceTypeFolders(records);
+ return introduceTypeAndCategoryNodes(records);
}
- private static TreeNode[] introduceTypeFolders(ResourceTreeNode[] nodes) {
- ArrayList<TreeNode> built = new ArrayList<TreeNode>();
- HashMap<ResourceSubCategory, CategoryTreeNode> categories = new HashMap<ResourceSubCategory, CategoryTreeNode>();
- HashMap<ResourceType, TypeTreeNode> types = new HashMap<ResourceType, TypeTreeNode>();
+ private static TreeNode[] introduceTypeAndCategoryNodes(ResourceTreeNode[] nodes) {
+ List<TreeNode> updatedNodes = new ArrayList<TreeNode>();
+ Map<Integer, CategoryTreeNode> categories = new HashMap<Integer, CategoryTreeNode>();
+ Map<ResourceType, TypeTreeNode> types = new HashMap<ResourceType, TypeTreeNode>();
for (ResourceTreeNode node : nodes) {
- built.add(node);
-
- if (!types.containsKey(node.getResourceType())
- && node.getResourceType().getCategory() != ResourceCategory.PLATFORM) {
-
- String parentResourceId = String.valueOf(node.getResource().getParentResource().getId());
-
- CategoryTreeNode categoryNode = null;
-
- if (node.getResourceType().getSubCategory() != null) {
- ResourceSubCategory category = node.getResourceType().getSubCategory();
- if (category.getName() != null) {
- categoryNode = categories.get(category);
-
- if (categoryNode == null) {
- categoryNode = new CategoryTreeNode(parentResourceId, category);
-
- categories.put(category, categoryNode);
- built.add(categoryNode);
+ updatedNodes.add(node);
+
+ ResourceType type = node.getResourceType();
+ if (type.getCategory() != ResourceCategory.PLATFORM) {
+ if (!types.containsKey(type)) {
+
+ String parentResourceId = String.valueOf(node.getResource().getParentResource().getId());
+
+ CategoryTreeNode categoryNode = null;
+ if (type.getSubCategory() != null) {
+ ResourceSubCategory category = type.getSubCategory();
+ if (category.getName() != null) {
+ categoryNode = categories.get(category.getId());
+ if (categoryNode == null) {
+ // TODO (ips): Handle connecting child subcat nodes to their parent subcats.
+ /*ResourceSubCategory parentCategory = category.getParentSubCategory();
+ while (parentCategory != null) {
+ Resource parentType = parentCategory.findParentResourceType();
+ if (parentCategory.findTaggedResourceTypes().isEmpty()) {
+ CategoryTreeNode parentCategoryNode =
+ new CategoryTreeNode(parentResourceId, parentCategory);
+ }
+ }*/
+ categoryNode = new CategoryTreeNode(parentResourceId, category);
+ categories.put(category.getId(), categoryNode);
+ updatedNodes.add(categoryNode);
+ }
}
}
- }
- String parentId = null;
- if (categoryNode != null) {
- parentId = categoryNode.getAttribute("id");
- } else {
- parentId = parentResourceId;
+ String parentId = (categoryNode != null) ? categoryNode.getID() : parentResourceId;
+ TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId, type);
+ updatedNodes.add(typeNode);
+ types.put(type, typeNode);
}
-
- TypeTreeNode typeNode = new TypeTreeNode(parentId, parentResourceId, node.getResourceType().getName());
- built.add(typeNode);
- types.put(node.getResourceType(), typeNode);
}
}
- return built.toArray(new TreeNode[built.size()]);
+ return updatedNodes.toArray(new TreeNode[updatedNodes.size()]);
}
private static boolean sameTypes(ResourceTreeNode[] nodes) {
@@ -247,78 +253,87 @@ public class ResourceTreeDatasource extends DataSource {
return true;
}
- public static class CategoryTreeNode extends TreeNode {
- public CategoryTreeNode(String parentId, ResourceSubCategory category) {
- setID(parentId + "__" + category.getName());
- setParentID(parentId);
- setName(category.getDisplayName());
+ public static class CategoryTreeNode extends EnhancedTreeNode {
+ public CategoryTreeNode(String parentResourceId, ResourceSubCategory category) {
+ String id = parentResourceId + "__" + fixId(category.getName());
+ setID(id);
+ setAttribute("id", id);
- setAttribute("id", parentId + "__" + category.getName());
- setAttribute("parentId", parentId);
- setAttribute("name", category.getDisplayName());
- }
+ setParentID(parentResourceId);
+ setAttribute("parentId", parentResourceId);
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("CategoryTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
+ setName(category.getDisplayName());
+ setAttribute("name", category.getDisplayName());
}
}
- public static class TypeTreeNode extends TreeNode {
- private TypeTreeNode(String parentId, String parentResourceId, String type) {
- setID(parentId + "_" + type);
- setParentID(parentId);
+ public static class TypeTreeNode extends EnhancedTreeNode {
+ private TypeTreeNode(String parentId, String parentResourceId, ResourceType type) {
+ String id = parentResourceId + "_" + type.getId();
+ setID(id);
+ setAttribute("id", id);
- setAttribute("id", parentResourceId + "_" + type);
+ if (parentId == null) {
+ try {
+ throw new IllegalStateException("**************** WARNING: parent ID is null for type " + type);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ setParentID(parentId);
setAttribute("parentId", parentId);
+
// setAttribute("parentKey", parentId);
- setAttribute("name", type);
+
+ String name = type.getName();
+ setName(name);
+ setAttribute("name", name);
+ }
+
+ @Override
+ public void setParentID(String parentID) {
+ if (parentID == null) {
+ try {
+ throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName());
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ super.setParentID(parentID);
}
@Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("TypeTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
+ public void setAttribute(String property, String value) {
+ if (property.equals("parentId") && value == null) {
+ try {
+ throw new IllegalStateException("**************** WARNING: setting parent ID to null for type " + getName());
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ super.setAttribute(property, value);
}
}
- public static class ResourceTreeNode extends TreeNode {
+ public static class ResourceTreeNode extends EnhancedTreeNode {
private Resource resource;
private ResourceTreeNode(Resource resource) {
this.resource = resource;
String id = String.valueOf(resource.getId());
- String parentId = resource.getParentResource() == null ? null
- : (resource.getParentResource().getId() + "_" + resource.getResourceType().getName());
-
- // System.out.println(id + " / " + parentId);
-
setID(id);
- setParentID(parentId);
-
setAttribute("id", id);
+
+ String parentId = (resource.getParentResource() != null) ?
+ (resource.getParentResource().getId() + "_" + resource.getResourceType().getId()) : null;
+ setParentID(parentId);
setAttribute("parentId", parentId);
+ // System.out.println(id + " / " + parentId);
// setAttribute("parentKey", resource.getParentResource() == null ? 0 : (resource.getParentResource().getId() + resource.getResourceType().getName()));
+ setName(resource.getName());
setAttribute("name", resource.getName());
setAttribute("description", resource.getDescription());
ResourceAvailability currentAvail = resource.getCurrentAvailability();
@@ -335,30 +350,12 @@ public class ResourceTreeDatasource extends DataSource {
return resource;
}
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
public ResourceType getResourceType() {
return resource.getResourceType();
}
+ }
- public String getParentId() {
- return getAttribute("parentId");
- }
-
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append("ResourceTreeNode[");
- String id = getAttribute("id");
- buffer.append("id=").append(id);
- String parentId = getAttribute("parentId");
- buffer.append(", parentId=").append(parentId);
- String name = getAttribute("name");
- buffer.append(", name=").append(name);
- buffer.append("]");
- return buffer.toString();
- }
+ private static String fixId(String id) {
+ return id.replace(' ', '_');
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 57ba8f2..02afc80 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -35,6 +35,7 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionEvent;
import com.smartgwt.client.widgets.menu.Menu;
@@ -129,11 +130,12 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (!selectionEvent.isRightButtonDown() && selectionEvent.getState()) {
- if (treeGrid.getSelectedRecord() instanceof ResourceTreeDatasource.ResourceTreeNode) {
- ResourceTreeDatasource.ResourceTreeNode node = (ResourceTreeDatasource.ResourceTreeNode) treeGrid
- .getSelectedRecord();
- //System.out.println("Resource selected in tree: " + node.getResource());
- String viewPath = "Resource/" + node.getResource().getId();
+ ListGridRecord selectedNode = treeGrid.getSelectedRecord();
+ System.out.println("Node selected in tree: " + selectedNode);
+ if (selectedNode instanceof ResourceTreeDatasource.ResourceTreeNode) {
+ ResourceTreeDatasource.ResourceTreeNode resourceNode =
+ (ResourceTreeDatasource.ResourceTreeNode) selectedNode;
+ String viewPath = "Resource/" + resourceNode.getResource().getId();
String currentViewPath = History.getToken();
if (!currentViewPath.startsWith(viewPath)) {
CoreGUI.goToView(viewPath);
@@ -162,14 +164,14 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
if (!initialSelect) {
- updateBreadcrumb();
+ updateBreadcrumbs();
}
}
});
}
- private void updateBreadcrumb() {
+ private void updateBreadcrumbs() {
TreeNode selectedNode = treeGrid.getTree().findById(String.valueOf(selectedResourceId));
// System.out.println("Trying to preopen: " + selectedNode);
if (selectedNode != null) {
@@ -177,10 +179,6 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.getTree().openFolders(parents);
treeGrid.getTree().openFolder(selectedNode);
- for (TreeNode p : parents) {
- // System.out.println("open? " + treeGrid.getTree().isOpen(p) + " node: " + p.getName());
- }
-
treeGrid.selectRecord(selectedNode);
initialSelect = true;
treeGrid.markForRedraw();
@@ -466,20 +464,9 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.selectRecord(node);
}
- updateBreadcrumb();
- /*
- TODO DELETEME
- // Update breadcrumbs
- viewId.getBreadcrumbs().clear();
- for (int i = parents.length - 1; i >= 0; i--) {
- TreeNode n = parents[i];
- adjustBreadcrumb(n, viewId);
- }
- adjustBreadcrumb(node, viewId);
-
- CoreGUI.refreshBreadCrumbTrail();
- */
+ TreeUtility.printTree(treeGrid.getTree());
+ updateBreadcrumbs();
} else {
// This is for cases where we have to load the tree fresh including down to the currently visible node
@@ -505,7 +492,7 @@ public class ResourceTreeView extends LocatableVLayout {
ResourceTreeDatasource dataSource = new ResourceTreeDatasource(result);
treeGrid.setDataSource(dataSource);
- // GH: couldn't get initial data to mix with the datasource... so i put the inital data in
+ // GH: couldn't get initial data to mix with the datasource... so i put the initial data in
// the first datasource request
// treeGrid.setInitialData(selectedLineage);
@@ -514,7 +501,7 @@ public class ResourceTreeView extends LocatableVLayout {
treeGrid.fetchData(treeGrid.getCriteria(), new DSCallback() {
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
System.out.println("Here!!!!!");
- updateBreadcrumb();
+ updateBreadcrumbs();
}
});
@@ -532,7 +519,7 @@ public class ResourceTreeView extends LocatableVLayout {
System.out.println("open? " + treeGrid.getTree().isOpen(p) + " node: " + p.getName());
}
- updateBreadcrumb();
+ updateBreadcrumbs();
treeGrid.selectRecord(selectedNode);
initialSelect = true;
@@ -552,7 +539,7 @@ public class ResourceTreeView extends LocatableVLayout {
TreeUtility.printTree(treeGrid.getTree());
- treeGrid.getTree().linkNodes(ResourceTreeDatasource.build(result));
+ treeGrid.getTree().linkNodes(ResourceTreeDatasource.buildNodes(result));
TreeNode selectedNode = treeGrid.getTree().findById(
String.valueOf(selectedResourceId));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
index 7e96af8..e9f773d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
@@ -80,7 +80,7 @@ public class ResourceSelector extends AbstractSelector<Resource> {
// TODO: Currently ignore the typeSelectItem widget because we already know the type.
// Alternatively, we could display it disabled but we'd want the type name to be displayed as the
// value. To get this to display the type name I think we need to pre-fetch the type tree here. We could
- // potentially optimize typeSelectItem.setValue(requireType.getId()) to build a tree that includes only
+ // potentially optimize typeSelectItem.setValue(requireType.getId()) to buildNodes a tree that includes only
// this single type.
//typeSelectItem.setValue(requireType.getId());
//typeSelectItem.setDisabled(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
index f8ebe39..550413c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/type/ResourceTypeRepository.java
@@ -23,6 +23,8 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -41,8 +43,8 @@ import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
*/
public class ResourceTypeRepository {
- private HashMap<Integer, ResourceType> typeCache = new HashMap<Integer, ResourceType>();
- private HashMap<Integer, EnumSet<MetadataType>> typeCacheLevel = new HashMap<Integer, EnumSet<MetadataType>>();
+ private Map<Integer, ResourceType> typeCache = new HashMap<Integer, ResourceType>();
+ private Map<Integer, EnumSet<MetadataType>> typeCacheLevel = new HashMap<Integer, EnumSet<MetadataType>>();
private static ResourceTypeGWTServiceAsync resourceTypeService = GWTServiceLookup.getResourceTypeGWTService();
@@ -78,7 +80,8 @@ public class ResourceTypeRepository {
loadResourceTypes(resources, null, callback);
}
- public void loadResourceTypes(final List<Resource> resources, final EnumSet<MetadataType> metadataTypes, final ResourceTypeLoadedCallback callback) {
+ public void loadResourceTypes(final List<Resource> resources, final EnumSet<MetadataType> metadataTypes,
+ final ResourceTypeLoadedCallback callback) {
if (resources.size() == 0) {
callback.onResourceTypeLoaded(resources);
return;
@@ -86,7 +89,7 @@ public class ResourceTypeRepository {
long start = System.currentTimeMillis();
- HashSet<Integer> types = new HashSet<Integer>();
+ Set<Integer> types = new HashSet<Integer>();
for (Resource res : resources) {
types.add(res.getResourceType().getId());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
index 8199c50..360fd86 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/TreeUtility.java
@@ -1,9 +1,30 @@
+/*
+ * 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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.enterprise.gui.coregui.client.util;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
+import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
/**
+ * A collection of utility methods for working with SmartGWT {@link Tree}s.
+ *
* @author Ian Springer
*/
public class TreeUtility {
@@ -15,15 +36,34 @@ public class TreeUtility {
private static void printTreeNode(Tree tree, TreeNode node) {
int level = tree.getLevel(node);
for (int i = 0; i < level; i++) {
- System.out.print(' ');
+ System.out.print(" ");
}
- System.out.println("* " + node);
+ System.out.println("* " + toString(node));
TreeNode[] childNodes = tree.getChildren(node);
for (TreeNode childNode : childNodes) {
printTreeNode(tree, childNode);
}
}
+ private static String toString(TreeNode node) {
+ if (node instanceof EnhancedTreeNode) {
+ return node.toString();
+ } else {
+ StringBuilder buffer = new StringBuilder();
+ String className = node.getClass().getName();
+ String simpleClassName = className.substring(className.lastIndexOf(".") + 1);
+ buffer.append(simpleClassName).append("[");
+ String id = node.getAttribute("id");
+ buffer.append("id=").append(id);
+ String parentId = node.getAttribute("parentId");
+ buffer.append(", parentId=").append(parentId);
+ String name = node.getName();
+ buffer.append(", name=").append(name);
+ buffer.append("]");
+ return buffer.toString();
+ }
+ }
+
private TreeUtility() {
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 6bb2d7d..25b19b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -174,7 +174,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
public List<Resource> getResourceLineageAndSiblings(int resourceId) {
return SerialUtility.prepare(resourceManager.getResourceLineageAndSiblings(resourceId),
- "ResourceService.getResourceLineage");
+ "ResourceService.getResourceLineageAndSiblings");
}
public Resource getPlatformForResource(int resourceId) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index e228f15..ce68440 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -290,7 +290,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// set agent references null
// foobar the resourceKeys
// update the inventory status to UNINVENTORY
- Query toBeDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDENTS);
+ Query toBeDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS);
toBeDeletedQuery.setParameter("resourceId", resourceId);
List<Integer> toBeDeletedResourceIds = toBeDeletedQuery.getResultList();
@@ -358,7 +358,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
@SuppressWarnings("unchecked")
public List<Integer> getResourceDescendantsByTypeAndName(Subject user, int resourceId, Integer resourceTypeId,
String name) {
- Query descendantQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDENTS_BY_TYPE_AND_NAME);
+ Query descendantQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME);
descendantQuery.setParameter("resourceId", resourceId);
descendantQuery.setParameter("resourceTypeId", resourceTypeId);
name = QueryUtility.formatSearchParameter(name);
@@ -655,7 +655,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
@Nullable
private Integer getParentResourceId(int resourceId) {
- Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_PAREBT_ID);
+ Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_PARENT_ID);
query.setParameter("id", resourceId);
try {
@@ -701,11 +701,27 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public List<Resource> getResourceLineageAndSiblings(int resourceId) {
List<Resource> resourceLineage = getResourceLineage(resourceId);
- LinkedList<Resource> result = new LinkedList<Resource>();
+ List<Resource> result = new LinkedList<Resource>();
- result.add(resourceLineage.get(0));
+ Resource platform = resourceLineage.get(0);
+ result.add(platform);
for (Resource resource : resourceLineage) {
- result.addAll(resource.getChildResources());
+ if (resource.getParentResource() != null) {
+ // This ensures Hibernate actually fetches the parent Resource.
+ resource.getParentResource().getId();
+ }
+ Set<Resource> childResources = resource.getChildResources();
+ result.addAll(childResources);
+ for (Resource childResource : childResources) {
+ // This ensures Hibernate actually fetches the parent Resource.
+ childResource.getParentResource().getId();
+ Set<Resource> grandchildResources = childResource.getChildResources();
+ result.addAll(grandchildResources);
+ for (Resource grandchildResource : grandchildResources) {
+ // This ensures Hibernate actually fetches the parent Resource.
+ grandchildResource.getParentResource().getId();
+ }
+ }
}
return result;
13 years, 9 months
[rhq] 2 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java | 51 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java | 277 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java | 100 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java | 126 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java | 40 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java | 26
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 89 +--
18 files changed, 298 insertions(+), 540 deletions(-)
New commits:
commit b02e60272034d5f1785dd87b9e38046a31784c1f
Merge: bf9bb7b... fc50175...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Sep 14 10:52:46 2010 -0400
Merge branch 'master' into master-jay
commit bf9bb7bed3e3b697789ec1b953e68e966cf9488f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Sep 14 10:50:48 2010 -0400
More Adminisration Section Work
- First working version of role management (still
needs work to get it looking better)
- Tweaks to User management
- Selenium hooks worked into roles
- Add margin to TableSection to get BackButton some
buffer space.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java
index 74b9c34..3ec8b14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionEditorView.java
@@ -18,8 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin.roles;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Set;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -30,65 +31,58 @@ import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.HeaderItem;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Set;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
*/
public class PermissionEditorView extends CanvasItem {
-
private Set<Permission> selectedPermissions = EnumSet.noneOf(Permission.class);
- private DynamicForm parentForm;
-
private DynamicForm form;
-
- public PermissionEditorView(String name, String title) {
+ public PermissionEditorView(String locatorId, String name, String title) {
super(name, title);
- setCanvas(new SimpleCollapsiblePanel("Permissions", buildForm()));
+ setCanvas(buildForm(locatorId));
}
+ public Canvas buildForm(String locatorId) {
+ this.form = new LocatableDynamicForm(locatorId);
+ this.form.setNumCols(4);
+ this.form.setColWidths("20%", "20%", "20%", "40%");
- public Canvas buildForm() {
- System.out.println("Building permissions canvas");
-
-// Object o = getAttributeAsObject(getFieldName());
-
- this.form = new DynamicForm();
ArrayList<FormItem> items = new ArrayList<FormItem>();
-
- HeaderItem h1 = new HeaderItem("globalPermissions","Global Permissions");
+ HeaderItem h1 = new HeaderItem("globalPermissions", "Global Permissions");
h1.setValue("Global Permissions");
items.add(h1);
for (Permission p : Permission.values()) {
if (p.getTarget() == Permission.Target.GLOBAL) {
- items.add(new CheckboxItem(p.name(),p.name()));
+ CheckboxItem cb = new CheckboxItem(p.name(), p.name());
+ cb.setShowTitle(false);
+ items.add(cb);
}
}
- HeaderItem h2 = new HeaderItem("resourcePermissions","Resource Permissions");
+ HeaderItem h2 = new HeaderItem("resourcePermissions", "Resource Permissions");
h2.setValue("Resource Permissions");
items.add(h2);
for (Permission p : Permission.values()) {
if (p.getTarget() == Permission.Target.RESOURCE) {
- items.add(new CheckboxItem(p.name(),p.name()));
+ CheckboxItem cb = new CheckboxItem(p.name(), p.name());
+ cb.setShowTitle(false);
+ items.add(cb);
}
}
form.setItems(items.toArray(new FormItem[items.size()]));
-
return form;
}
-
public void setPermissions(Set<Permission> permissions) {
this.selectedPermissions = permissions;
for (Permission p : Permission.values()) {
@@ -98,7 +92,7 @@ public class PermissionEditorView extends CanvasItem {
form.addItemChangedHandler(new ItemChangedHandler() {
public void onItemChanged(ItemChangedEvent itemChangedEvent) {
for (Permission p : Permission.values()) {
- if ((Boolean)form.getValue(p.name())) {
+ if ((Boolean) form.getValue(p.name())) {
selectedPermissions.add(p);
} else {
selectedPermissions.remove(p);
@@ -116,11 +110,6 @@ public class PermissionEditorView extends CanvasItem {
@Override
public Object getValue() {
- System.out.println("Finding Value");
return super.getValue();
}
-
- public void setParentForm(DynamicForm parentForm) {
- this.parentForm = parentForm;
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
index ad9c982..7a81733 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
@@ -18,57 +18,57 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin.roles;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DSOperationType;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
-import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.ResetItem;
-import com.smartgwt.client.widgets.form.fields.SubmitItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
-import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
-import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceGroupSelector;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
*/
-public class RoleEditView extends LocatableVLayout {
+public class RoleEditView extends LocatableVLayout implements BookmarkableView {
- private Role roleBeingEdited;
+ private Role role;
- private Label message = new Label("Select a role to edit...");
+ private Label message = new Label("Loading...");
private VLayout editCanvas;
- private HeaderLabel editLabel;
private DynamicForm form;
+
private PermissionEditorView permissionEditorItem;
private CanvasItem groupSelectorItem;
@@ -77,187 +77,210 @@ public class RoleEditView extends LocatableVLayout {
private CanvasItem subjectSelectorItem;
private RoleSubjectSelector subjectSelector;
- private Window editorWindow;
+ private RolesDataSource dataSource;
public RoleEditView(String locatorId) {
super(locatorId);
- setPadding(10);
- setOverflow(Overflow.AUTO);
-
- addMember(message);
-
- addMember(buildRoleForm());
-
- editCanvas.hide();
- }
-
- private Canvas buildRoleForm() {
- this.editCanvas = new VLayout();
- this.editCanvas.setWidth100();
- this.editCanvas.setHeight100();
+ this.dataSource = RolesDataSource.getInstance();
- editLabel = new HeaderLabel("Create User");
- // TODO create header css style and set
+ this.setPadding(10);
+ setOverflow(Overflow.AUTO);
- editCanvas.addMember(editLabel);
+ buildRoleEditor();
+ this.editCanvas.hide();
- form = new LocatableDynamicForm(extendLocatorId("RoleForm"));
- form.setWidth100();
+ this.addMember(message);
+ this.addMember(editCanvas);
+ }
- form.setDataSource(RolesDataSource.getInstance());
+ private Canvas buildRoleEditor() {
+ form = new LocatableDynamicForm(extendLocatorId(this.getLocatorId()));
- TextItem idItem = new TextItem("id", "Id");
+ form.setHiliteRequiredFields(true);
+ form.setRequiredTitleSuffix("* :");
- TextItem nameItem = new TextItem("name", "Name");
+ form.setDataSource(this.dataSource);
+ form.setUseAllDataSourceFields(true);
- permissionEditorItem = new PermissionEditorView("permissionEditor", "Permissions");
+ permissionEditorItem = new PermissionEditorView(this.getLocatorId(), "permissionsEditor", "Permissions");
permissionEditorItem.setShowTitle(false);
permissionEditorItem.setColSpan(2);
groupSelectorItem = new CanvasItem("groupSelectionCanvas", "Assigned Resource Groups");
- groupSelectorItem.setCanvas(new Label("loading...")); //new RoleResourceGroupSelector(null));
groupSelectorItem.setTitleOrientation(TitleOrientation.TOP);
groupSelectorItem.setColSpan(2);
subjectSelectorItem = new CanvasItem("subjectSelectionCanvas", "Assigned Subjects");
- subjectSelectorItem.setCanvas(new Label("loading...")); //new RoleSubjectSelector(null));
subjectSelectorItem.setTitleOrientation(TitleOrientation.TOP);
subjectSelectorItem.setColSpan(2);
- SubmitItem saveButton = new SubmitItem("save", "Save");
-
- saveButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- save();
- System.out.println("Save is done");
+ IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
+ saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ if (form.validate()) {
+ save();
+ }
}
});
- form.addSubmitValuesHandler(new SubmitValuesHandler() {
- public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
- Object o = submitValuesEvent.getValues();
- System.out.println("O: " + o);
+ IButton resetButton = new LocatableIButton(this.extendLocatorId("Reset"), "Reset");
+ resetButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ form.reset();
}
});
- form.setItems(idItem, nameItem, permissionEditorItem, groupSelectorItem, subjectSelectorItem, saveButton,
- new ResetItem("reset", "Reset"));
-
- editCanvas.addMember(form);
-
- return editCanvas;
- }
-
- public void editRecord(Record record) {
- this.roleBeingEdited = (Role) record.getAttributeAsObject("entity");
- message.hide();
- editCanvas.show();
- try {
- editLabel.setContents("Editing Role " + record.getAttribute("name"));
- form.editRecord(record);
- permissionEditorItem.setParentForm(form);
- permissionEditorItem.setPermissions((Set<Permission>) record.getAttributeAsObject("permissions"));
-
- groupSelector = new RoleResourceGroupSelector("RoleEditor-Groups", (Collection<ResourceGroup>) record
- .getAttributeAsObject("resourceGroups"));
- groupSelectorItem.setCanvas(groupSelector);
-
- subjectSelector = new RoleSubjectSelector("RoleEditor-Subjects", (Collection<Subject>) record
- .getAttributeAsObject("subjects"));
- subjectSelectorItem.setCanvas(subjectSelector);
-
- } catch (Throwable t) {
- t.printStackTrace();
- }
- // markForRedraw();
- }
+ IButton cancelButton = new LocatableIButton(this.extendLocatorId("Cancel"), "Cancel");
+ cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(com.smartgwt.client.widgets.events.ClickEvent clickEvent) {
+ History.back();
+ }
+ });
- public void editNone() {
- message.show();
- editCanvas.hide();
+ HLayout buttonLayout = new HLayout(10);
+ buttonLayout.setAlign(Alignment.CENTER);
+ buttonLayout.addMember(saveButton);
+ buttonLayout.addMember(resetButton);
+ buttonLayout.addMember(cancelButton);
- // markForRedraw();
- }
+ form.setItems(permissionEditorItem, groupSelectorItem, subjectSelectorItem);
- public void editNew() {
- ListGridRecord r = RolesDataSource.getInstance().copyValues(new Role());
- editRecord(r);
- form.setSaveOperationType(DSOperationType.ADD);
-
- editLabel.setContents("Create Role");
+ this.editCanvas = new VLayout();
- editorWindow = new Window();
- editorWindow.setTitle("Create Role");
- editorWindow.setWidth(800);
- editorWindow.setHeight(800);
- editorWindow.setIsModal(true);
- editorWindow.setShowModalMask(true);
- editorWindow.setCanDragResize(true);
- editorWindow.centerInPage();
- editorWindow.addItem(this);
- editorWindow.show();
+ editCanvas.addMember(form);
+ editCanvas.addMember(buttonLayout);
+ return editCanvas;
}
public void save() {
+ final HashSet<Integer> groupSelection = this.groupSelector.getSelection();
+ final HashSet<Integer> userSelection = this.subjectSelector.getSelection();
- System.out.println("Saving role");
+ // The form.saveData() call triggers either RolesDataSource.executeAdd() to create the new Role,
+ // or executeUpdate() if saving changes to an existing Role. On success we need to perform the
+ // subsequent user or group assignment, so set this callback on completion.
form.saveData(new DSCallback() {
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
- HashSet<Integer> selection = groupSelector.getSelection();
- int[] groupIds = new int[selection.size()];
+
+ int roleId = Integer.parseInt(new ListGridRecord(dsRequest.getData()).getAttribute("id"));
+
+ int[] groupIds = new int[groupSelection.size()];
int i = 0;
- for (Integer id : selection) {
+ for (Integer id : groupSelection) {
groupIds[i++] = id;
}
- int roleId;
- if (roleBeingEdited != null && roleBeingEdited.getId() != null) {
- roleId = roleBeingEdited.getId();
- } else {
- // new role
- roleId = Integer.parseInt(new ListGridRecord(dsRequest.getData()).getAttribute("id"));
- }
-
GWTServiceLookup.getRoleService().setAssignedResourceGroups(roleId, groupIds,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to update role's assigned groups", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to save role group assignments.", caught);
}
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
- new Message("Updated assigned groups", Message.Severity.Info));
+ new Message("Succesfully saved role group assignments.", Message.Severity.Info));
}
});
- HashSet<Integer> selectedSubjects = subjectSelector.getSelection();
- int[] subjectIds = new int[selectedSubjects.size()];
+ int[] subjectIds = new int[userSelection.size()];
i = 0;
- for (Integer id : selectedSubjects) {
+ for (Integer id : userSelection) {
subjectIds[i++] = id;
}
GWTServiceLookup.getRoleService().setAssignedSubjects(roleId, subjectIds, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to update role's assigned subjects", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to save role user assignments.", caught);
+ History.back();
}
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
- new Message("Updated role assigned subjects", Message.Severity.Info));
+ new Message("Succesfully saved role user assignments.", Message.Severity.Info));
+ History.back();
}
});
-
- if (editorWindow != null) {
- editorWindow.destroy();
- }
}
});
}
- public DynamicForm getForm() {
- return form;
+ @SuppressWarnings("unchecked")
+ public void editRecord(Record record) {
+ this.groupSelector = new RoleResourceGroupSelector(this.extendLocatorId("Groups"), (Set<ResourceGroup>) record
+ .getAttributeAsObject("resourceGroups"));
+ this.subjectSelector = new RoleSubjectSelector(this.extendLocatorId("Subjects"), (Set<Subject>) record
+ .getAttributeAsObject("subjects"));
+
+ this.groupSelectorItem.setCanvas(this.groupSelector);
+ this.subjectSelectorItem.setCanvas(this.subjectSelector);
+
+ Set<Permission> permissions = (Set<Permission>) record.getAttributeAsObject("permissions");
+ this.permissionEditorItem.setPermissions(permissions);
+
+ try {
+ form.editRecord(record);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ message.hide();
+ editCanvas.show();
+ form.setSaveOperationType(DSOperationType.UPDATE);
+ }
+
+ private void editNewInternal() {
+ role = new Role();
+ ListGridRecord r = dataSource.copyValues(role);
+ editRecord(r);
+
+ // This tells form.saveData() to call RolesDataSource.executeAdd() on the new Role's ListGridRecord
+ form.setSaveOperationType(DSOperationType.ADD);
+ }
+
+ public static void editNew(String locatorId) {
+ RoleEditView editView = new RoleEditView(locatorId);
+ editView.editNewInternal();
+ }
+
+ private void editRole(int roleId, final ViewId current) {
+
+ final int id = Integer.valueOf(current.getBreadcrumbs().get(0).getName());
+
+ if (id > 0) {
+ RoleCriteria criteria = new RoleCriteria();
+ criteria.addFilterId(id);
+ criteria.fetchPermissions(true);
+ criteria.fetchResourceGroups(true);
+ criteria.fetchSubjects(true);
+
+ GWTServiceLookup.getRoleService().findRolesByCriteria(criteria, new AsyncCallback<PageList<Role>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load role for editing", caught);
+ }
+
+ @Override
+ public void onSuccess(PageList<Role> result) {
+ Role role = result.get(0);
+ Record record = new RolesDataSource().copyValues(role);
+ editRecord(record);
+
+ current.getBreadcrumbs().get(0).setDisplayName("Editing: " + role.getName());
+ CoreGUI.refreshBreadCrumbTrail();
+ }
+ });
+ } else {
+ editNewInternal();
+ current.getBreadcrumbs().get(0).setDisplayName("New Role");
+ CoreGUI.refreshBreadCrumbTrail();
+ }
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ int roleId = viewPath.getCurrentAsInt();
+
+ editRole(roleId, viewPath.getCurrent());
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java
deleted file mode 100644
index 59ebf1c..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleGroupsEditorItem.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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 as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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 for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.admin.roles;
-
-import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
-
-import com.smartgwt.client.types.DragDataAction;
-import com.smartgwt.client.types.DragTrackerMode;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.TransferImgButton;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VStack;
-
-/**
- * @author Greg Hinkle
- */
-public class RoleGroupsEditorItem extends CanvasItem {
-
- private PageList<ResourceGroup> assignedGroups;
-
- private ListGrid assignedGroupGrid;
- private ListGrid availableGroupGrid;
-
- public RoleGroupsEditorItem(String name, String title) {
- super(name, title);
- setCanvas(new SimpleCollapsiblePanel("Assigned Groups", buildForm()));
- }
-
- private Canvas buildForm() {
-
- HLayout layout = new HLayout(10);
-
- availableGroupGrid = new ListGrid();
- availableGroupGrid.setHeight(350);
- availableGroupGrid.setCanDragRecordsOut(true);
- availableGroupGrid.setDragTrackerMode(DragTrackerMode.RECORD);
- availableGroupGrid.setDragDataAction(DragDataAction.MOVE);
- availableGroupGrid.setDataSource(ResourceGroupsDataSource.getInstance());
- availableGroupGrid.setAutoFetchData(true);
- availableGroupGrid.setFields(new ListGridField("id",50), new ListGridField("name"));
-
- layout.addMember(availableGroupGrid);
-
- VStack moveButtonStack = new VStack(10);
- moveButtonStack.setWidth(50);
-
- TransferImgButton addButton = new TransferImgButton(TransferImgButton.RIGHT);
- TransferImgButton removeButton = new TransferImgButton(TransferImgButton.LEFT);
- TransferImgButton addAllButton = new TransferImgButton(TransferImgButton.RIGHT_ALL);
- TransferImgButton removeAllButton = new TransferImgButton(TransferImgButton.LEFT_ALL);
-
- moveButtonStack.addMember(addButton);
- moveButtonStack.addMember(removeButton);
- moveButtonStack.addMember(addAllButton);
- moveButtonStack.addMember(removeAllButton);
-
- layout.addMember(moveButtonStack);
-
- assignedGroupGrid = new ListGrid();
- assignedGroupGrid.setHeight(350);
- assignedGroupGrid.setCanDragRecordsOut(true);
- assignedGroupGrid.setCanAcceptDroppedRecords(true);
- assignedGroupGrid.setDataSource(ResourceGroupsDataSource.getInstance());
- assignedGroupGrid.setFields(new ListGridField("id", 50), new ListGridField("name"));
-
- layout.addMember(assignedGroupGrid);
-
-
- return layout;
- }
-
- public void setGroups(PageList<ResourceGroup> assignedGroups) {
- this.assignedGroups = assignedGroups;
-
- assignedGroupGrid.setData(ResourceGroupsDataSource.getInstance().buildRecords(assignedGroups));
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java
index 12f5fde..8190d3f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleResourceGroupSelector.java
@@ -35,8 +35,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.Resour
*/
public class RoleResourceGroupSelector extends ResourceGroupSelector {
- public RoleResourceGroupSelector(String id, Collection<ResourceGroup> groups) {
- super(id);
+ public RoleResourceGroupSelector(String locatorId, Collection<ResourceGroup> groups) {
+ super(locatorId);
if (groups != null) {
ListGridRecord[] data = (new ResourceGroupsDataSource()).buildRecords(groups);
setAssigned(data);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
index 42e4b2f..8cbf180 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
@@ -47,18 +47,18 @@ public class RoleSubjectSelector extends AbstractSelector<Subject> {
}
@Override
- protected DynamicForm getAvailableFilterForm() {
- return null; // TODO: Implement this method.
+ protected RPCDataSource<Subject> getDataSource() {
+ return new SelectedSubjectsDataSource();
}
@Override
- protected RPCDataSource<Subject> getDataSource() {
- return new SelectedSubjectsDataSource();
+ protected DynamicForm getAvailableFilterForm() {
+ return null; // No Filters Currently
}
@Override
protected Criteria getLatestCriteria(DynamicForm availableFilterForm) {
- return null; // TODO: Implement this method.
+ return null; // No Filters Currently
}
public class SelectedSubjectsDataSource extends UsersDataSource {
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 5ddbde2..3b9aafb 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
@@ -64,12 +64,11 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
public RolesDataSource() {
-
DataSourceField idDataField = new DataSourceIntegerField("id", "ID");
idDataField.setPrimaryKey(true);
idDataField.setCanEdit(false);
- DataSourceTextField nameField = new DataSourceTextField("name", "Name");
+ DataSourceTextField nameField = new DataSourceTextField("name", "Name", 100, true);
setFields(idDataField, nameField);
}
@@ -97,9 +96,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
public void onSuccess(PageList<Role> result) {
-
- System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start));
-
response.setData(buildRecords(result));
response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
processResponse(request.getRequestId(), response);
@@ -118,7 +114,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
Map<String, String> errors = new HashMap<String, String>();
errors.put("name", "A role with name already exists.");
response.setErrors(errors);
- // CoreGUI.getErrorHandler().handleError("Failed to create role",caught);
response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR);
processResponse(request.getRequestId(), response);
}
@@ -137,7 +132,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
@Override
protected void executeUpdate(final DSRequest request, final DSResponse response) {
final ListGridRecord record = getEditedRecord(request);
- System.out.println("Updating record: " + record);
Role updatedRole = copyValues(record);
roleService.updateRole(updatedRole, new AsyncCallback<Role>() {
public void onFailure(Throwable caught) {
@@ -147,7 +141,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
public void onSuccess(Role result) {
CoreGUI.getMessageCenter().notify(
new Message("Role [" + result.getName() + "] updated", Message.Severity.Info));
- System.out.println("Role Updated");
response.setData(new Record[] { copyValues(result) });
processResponse(request.getRequestId(), response);
}
@@ -168,7 +161,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
new Message("Role [" + newRole.getName() + "] removed", Message.Severity.Info));
- System.out.println("Role deleted");
response.setData(new Record[] { rec });
processResponse(request.getRequestId(), response);
}
@@ -176,12 +168,12 @@ public class RolesDataSource extends RPCDataSource<Role> {
}
+ @SuppressWarnings("unchecked")
public Role copyValues(ListGridRecord from) {
Role to = new Role();
to.setId(from.getAttributeAsInt("id"));
to.setName(from.getAttributeAsString("name"));
- // to.setDate (from.getAttributeAsDate ("date"));
- // from.getAttributeAsIntArray("resourceGroups");
+
to.setResourceGroups((Set<ResourceGroup>) from.getAttributeAsObject("resourceGroups"));
to.setPermissions((Set<Permission>) from.getAttributeAsObject("permissions"));
to.setSubjects((Set<Subject>) from.getAttributeAsObject("subjects"));
@@ -192,6 +184,7 @@ public class RolesDataSource extends RPCDataSource<Role> {
ListGridRecord to = new ListGridRecord();
to.setAttribute("id", from.getId());
to.setAttribute("name", from.getName());
+
to.setAttribute("resourceGroups", from.getResourceGroups());
to.setAttribute("permissions", from.getPermissions());
to.setAttribute("subjects", from.getSubjects());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
index 55d5bb7..a9ea8b3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
@@ -22,7 +22,6 @@ import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
@@ -52,26 +51,15 @@ public class RolesView extends TableSection implements BookmarkableView {
addTableAction(extendLocatorId("New"), "New", new TableAction() {
public void executeAction(ListGridRecord[] selection) {
- createRole();
+ newDetails();
}
});
}
- public void createRole() {
- RoleEditView editView = new RoleEditView(extendLocatorId("Edit"));
-
- editView.editNew();
- }
-
@Override
public Canvas getDetailsView(int id) {
RoleEditView editor = new RoleEditView(extendLocatorId("Detail"));
return editor;
}
-
- public void renderView(ViewPath viewPath) {
-
- System.out.println("Display role list");
- }
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java
deleted file mode 100644
index 38f0e7a..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRolesEditorItem.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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 as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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 for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.admin.users;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Role;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesDataSource;
-import org.rhq.enterprise.gui.coregui.client.components.SimpleCollapsiblePanel;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
-
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.DSOperationType;
-import com.smartgwt.client.types.DragDataAction;
-import com.smartgwt.client.types.DragTrackerMode;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.TransferImgButton;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VStack;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Greg Hinkle
- */
-public class SubjectRolesEditorItem extends CanvasItem {
-
- private Set<Role> assignedRoles;
- private Subject subject;
-
- private ListGrid assignedRoleGrid;
- private ListGrid availableRoleGrid;
-
- public SubjectRolesEditorItem(String name, String title) {
- super(name, title);
- setShowTitle(false);
- setColSpan(2);
-// setWidth("90%");
- setCanvas(new SimpleCollapsiblePanel("Assigned Roles", buildForm()));
- }
-
- private Canvas buildForm() {
-
- HLayout layout = new HLayout(10);
-
- availableRoleGrid = new ListGrid();
- availableRoleGrid.setHeight(250);
- availableRoleGrid.setCanDragRecordsOut(true);
- availableRoleGrid.setDragTrackerMode(DragTrackerMode.RECORD);
- availableRoleGrid.setDragDataAction(DragDataAction.MOVE);
- availableRoleGrid.setDataSource(RolesDataSource.getInstance());
- availableRoleGrid.setAutoFetchData(true);
- availableRoleGrid.setFields(new ListGridField("id", 50), new ListGridField("name"));
-
- layout.addMember(availableRoleGrid);
-
- VStack moveButtonStack = new VStack(10);
- moveButtonStack.setWidth(50);
-
- TransferImgButton addButton = new TransferImgButton(TransferImgButton.RIGHT);
- TransferImgButton removeButton = new TransferImgButton(TransferImgButton.LEFT);
- TransferImgButton addAllButton = new TransferImgButton(TransferImgButton.RIGHT_ALL);
- TransferImgButton removeAllButton = new TransferImgButton(TransferImgButton.LEFT_ALL);
-
- moveButtonStack.addMember(addButton);
- moveButtonStack.addMember(removeButton);
- moveButtonStack.addMember(addAllButton);
- moveButtonStack.addMember(removeAllButton);
-
- layout.addMember(moveButtonStack);
-
- assignedRoleGrid = new ListGrid();
- assignedRoleGrid.setHeight(250);
- assignedRoleGrid.setCanDragRecordsOut(true);
- assignedRoleGrid.setCanAcceptDroppedRecords(true);
-// assignedRoleGrid.setDataSource(RolesDataSource.getInstance());
- assignedRoleGrid.setFields(new ListGridField("id", 50), new ListGridField("name"));
-
- layout.addMember(assignedRoleGrid);
-
-
- return layout;
- }
-
- public void setRoles(Set<Role> assignedRoles) {
- this.assignedRoles = assignedRoles;
-
- assignedRoleGrid.setData(RolesDataSource.getInstance().buildRecords(assignedRoles));
- }
-
- public Set<Role> getRoles() {
- return this.assignedRoles;
- }
-
- public Subject getSubject() {
- return subject;
- }
-
- public void setSubject(Subject subject) {
- this.subject = subject;
- if (subject != null) {
- assignedRoleGrid.setCriteria(new Criteria("subjectId", String.valueOf(subject.getId())));
- }
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
index bd13da7..279fa33 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UserEditView.java
@@ -29,13 +29,13 @@ import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DSOperationType;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.SectionItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.HLayout;
@@ -60,19 +60,16 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class UserEditView extends LocatableVLayout implements BookmarkableView {
- private Label message = new Label("Select a user to edit...");
-
- // private SubjectRolesEditorItem subjectRolesEditorItem ;
+ private Label message = new Label("Loading...");
private VLayout editCanvas;
private DynamicForm form;
- CanvasItem roleSelectionItem;
-
private UsersDataSource dataSource;
private Subject subject;
+ private CanvasItem roleSelectionItem;
private SubjectRoleSelector roleSelector;
public UserEditView(String locatorId) {
@@ -80,15 +77,13 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
dataSource = UsersDataSource.getInstance();
- setWidth100();
- setHeight100();
+ setOverflow(Overflow.AUTO);
buildSubjectEditor();
editCanvas.hide();
addMember(message);
addMember(editCanvas);
-
}
private Canvas buildSubjectEditor() {
@@ -98,12 +93,10 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
form.setHiliteRequiredFields(true);
form.setRequiredTitleSuffix("* :");
- SectionItem userEditSection = new SectionItem("userEditSection", "Edit User");
-
- form.setUseAllDataSourceFields(true);
form.setDataSource(dataSource);
+ form.setUseAllDataSourceFields(true);
- this.roleSelectionItem = new CanvasItem("selectRoles", "Select Roles");
+ this.roleSelectionItem = new CanvasItem("selectRoles", "Assigned Roles");
this.roleSelectionItem.setTitleOrientation(TitleOrientation.TOP);
this.roleSelectionItem.setColSpan(2);
@@ -152,8 +145,10 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
public void save() {
final HashSet<Integer> roles = roleSelector.getSelection();
- // The form.saveData() call triggers UsersDataSource.executeAdd() to create the new Subject. On
- // successful create we need to perform the role assignment, so set this callback on completion.
+
+ // The form.saveData() call triggers either UsersDataSource.executeAdd() to create the new Subject,
+ // or executeUpdate() if saving changes to an existing Subject. On success we need to perform the
+ // subsequent role assignment, so set this callback on completion.
form.saveData(new DSCallback() {
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
@@ -168,21 +163,21 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
GWTServiceLookup.getRoleService().setAssignedSubjectRoles(subjectId, roleIds,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to set subject role assignments.", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to save user role assignments.", caught);
History.back();
}
public void onSuccess(Void result) {
CoreGUI.getMessageCenter().notify(
- new Message("Succesfully saved new user roles.", Message.Severity.Info));
+ new Message("Succesfully saved user role assignments.", Message.Severity.Info));
History.back();
}
});
-
}
});
}
+ @SuppressWarnings("unchecked")
public void editRecord(Record record) {
roleSelector = new SubjectRoleSelector(this.extendLocatorId("Roles"), (Set<Role>) record
.getAttributeAsObject("roles"));
@@ -200,13 +195,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
markForRedraw();
}
- public void editNone() {
- message.show();
- editCanvas.hide();
- markForRedraw();
- }
-
- public void editNewInternal() {
+ private void editNewInternal() {
subject = new Subject();
ListGridRecord r = dataSource.copyValues(subject);
editRecord(r);
@@ -247,6 +236,7 @@ public class UserEditView extends LocatableVLayout implements BookmarkableView {
CoreGUI.refreshBreadCrumbTrail();
}
});
+
} else {
editNewInternal();
current.getBreadcrumbs().get(0).setDisplayName("New User");
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 809edec..470b144 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
@@ -97,11 +97,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
DataSourceTextField department = new DataSourceTextField("department", "Department", 100, false);
- DataSourceField roles = new DataSourceField();
- roles.setForeignKey("Roles.id");
- roles.setName("roles");
- roles.setMultiple(true);
-
setFields(idDataField, usernameField, firstName, lastName, password, passwordVerify, phone, emailAddress,
department);
}
@@ -121,16 +116,7 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
public void onSuccess(PageList<Subject> result) {
- System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start));
-
- ListGridRecord[] records = new ListGridRecord[result.size()];
- for (int x = 0; x < result.size(); x++) {
- Subject subject = result.get(x);
-
- records[x] = copyValues(subject);
- }
-
- response.setData(records);
+ response.setData(buildRecords(result));
response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
processResponse(request.getRequestId(), response);
}
@@ -177,7 +163,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
@Override
protected void executeUpdate(final DSRequest request, final DSResponse response) {
final ListGridRecord record = getEditedRecord(request);
- System.out.println("Updating record: " + record);
final Subject updatedSubject = copyValues(record);
subjectService.updateSubject(updatedSubject, new AsyncCallback<Subject>() {
public void onFailure(Throwable caught) {
@@ -202,7 +187,6 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
});
} else {
- System.out.println("Subject Updated");
CoreGUI.getMessageCenter().notify(
new Message("User [" + result.getName() + "] updated", Message.Severity.Info));
response.setData(new Record[] { copyValues(result) });
@@ -233,6 +217,7 @@ public class UsersDataSource extends RPCDataSource<Subject> {
}
+ @SuppressWarnings("unchecked")
public Subject copyValues(ListGridRecord from) {
Subject to = new Subject();
to.setId(from.getAttributeAsInt("id"));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index 72e2aa7..e1de74d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -32,7 +32,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
public class UsersView extends TableSection {
public UsersView(String locatorId) {
- super(locatorId, "Users View");
+ super(locatorId, "Users");
final UsersDataSource datasource = UsersDataSource.getInstance();
@@ -43,8 +43,6 @@ public class UsersView extends TableSection {
protected void configureTable() {
final ListGrid grid = getListGrid();
- grid.getField("id").setWidth(20);
- grid.getField("name").setWidth(100);
grid.hideField("password");
grid.hideField("passwordVerify");
@@ -64,6 +62,7 @@ public class UsersView extends TableSection {
public Canvas getDetailsView(int id) {
final UserEditView userEditor = new UserEditView(extendLocatorId("Detail"));
+
return userEditor;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java
index cb09a01..ed9163d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/SimpleCollapsiblePanel.java
@@ -26,24 +26,23 @@ import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;
/**
+ * TODO: Not Quite Working. For some reason the icon is not clickable.
+ *
* @author Greg Hinkle
*/
public class SimpleCollapsiblePanel extends VLayout {
-
private Canvas content;
private String title;
private boolean expanded = true;
-
public SimpleCollapsiblePanel(String title, Canvas content) {
this.content = content;
this.title = title;
setWidth100();
}
-
@Override
protected void onInit() {
super.onInit();
@@ -51,12 +50,11 @@ public class SimpleCollapsiblePanel extends VLayout {
final Button button = new Button(title);
button.setShowRollOver(false);
button.setActionType(SelectionType.RADIO);
- button.setBorder(null);
+ //button.setBorder(null);
button.setAutoFit(true);
-
button.setIcon("[skin]/images/SectionHeader/opener_opened.png");
- button.setBaseStyle("SimpleButton");
+ //button.setBaseStyle("SimpleButton");
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
@@ -74,7 +72,6 @@ public class SimpleCollapsiblePanel extends VLayout {
}
});
-
addMember(button);
addMember(content);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index 1617a2d..1c8774f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -129,6 +129,9 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
@Override
public void run() {
if (latestCriteria != null) {
+ // TODO until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed always go to the server for data
+ availableGrid.invalidateCache();
+
Criteria c = latestCriteria;
latestCriteria = null;
availableGrid.fetchData(c);
@@ -144,12 +147,12 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
moveButtonStack.setAlign(VerticalAlignment.CENTER);
moveButtonStack.setWidth(40);
- addButton = new LocatableTransferImgButton(TransferImgButton.RIGHT);
+ addButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.RIGHT);
addButton.setDisabled(true);
- removeButton = new LocatableTransferImgButton(TransferImgButton.LEFT);
+ removeButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.LEFT);
removeButton.setDisabled(true);
- addAllButton = new LocatableTransferImgButton(TransferImgButton.RIGHT_ALL);
- removeAllButton = new LocatableTransferImgButton(TransferImgButton.LEFT_ALL);
+ addAllButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.RIGHT_ALL);
+ removeAllButton = new LocatableTransferImgButton(this.getLocatorId(), TransferImgButton.LEFT_ALL);
removeAllButton.setDisabled(true);
moveButtonStack.addMember(addButton);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index 9bd3a6a..a1303a1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -79,8 +79,9 @@ public abstract class TableSection extends Table implements BookmarkableView {
super.onInit();
detailsHolder = new VLayout();
- detailsHolder.setWidth100();
- detailsHolder.setHeight100();
+ //detailsHolder.setWidth100();
+ //detailsHolder.setHeight100();
+ detailsHolder.setMargin(5);
detailsHolder.hide();
addMember(detailsHolder);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index 9de2407..00e9389 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -42,8 +42,6 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*/
public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
- private String query;
-
private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
private static ResourceGroupsDataSource INSTANCE;
@@ -85,14 +83,12 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
groupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load groups", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to fetch groups data", caught);
response.setStatus(RPCResponse.STATUS_FAILURE);
processResponse(request.getRequestId(), response);
}
public void onSuccess(PageList<ResourceGroup> result) {
- System.out.println("Data retrieved in: " + (System.currentTimeMillis() - start));
-
response.setData(buildRecords(result));
response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
processResponse(request.getRequestId(), response);
@@ -104,7 +100,10 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.setPageControl(getPageControl(request));
- criteria.addFilterName(query);
+
+ if (request.getCriteria().getValues().get("name") != null) {
+ criteria.addFilterName((String) request.getCriteria().getValues().get("name"));
+ }
if (request.getCriteria().getValues().get("category") != null) {
criteria.addFilterGroupCategory(GroupCategory.valueOf(((String) request.getCriteria().getValues().get(
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
index f2f15dc..c983dee 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -21,29 +21,33 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection;
import java.util.Collection;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
*/
public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
- public ResourceGroupSelector(String id) {
- super(id);
+ public ResourceGroupSelector(String locatorId) {
+ super(locatorId);
}
protected DynamicForm getAvailableFilterForm() {
- DynamicForm availableFilterForm = new DynamicForm();
- availableFilterForm.setNumCols(5);
+ DynamicForm availableFilterForm = new LocatableDynamicForm(this.getLocatorId());
+ availableFilterForm.setWidth100();
+ availableFilterForm.setNumCols(4);
final TextItem search = new TextItem("search", "Search");
@@ -61,7 +65,7 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
// TODO: Until http://code.google.com/p/smartgwt/issues/detail?id=490 is fixed, avoid AdvancedCriteria and always
// use server-side fetch and simple criteria. When fixed, use the commented version below. Also see
- // ResourceGroupDataSource.
+ // AbstractSelector and ResourceGroupDataSource.
protected Criteria getLatestCriteria(DynamicForm availableFilterForm) {
String search = (String) availableFilterForm.getValue("search");
String category = (String) availableFilterForm.getValue("groupCategory");
@@ -104,5 +108,15 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
}
return records;
}
+
+ @Override
+ protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) {
+ ResourceGroupCriteria result = super.getFetchCriteria(request);
+ if (null != result) {
+ result.setStrict(false);
+ }
+ return result;
+ }
+
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
index e255096..efbd818 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableTransferImgButton.java
@@ -7,28 +7,22 @@ import com.smartgwt.client.widgets.TransferImgButton;
*
* @author Jay Shaughnessy
*/
-public class LocatableTransferImgButton extends TransferImgButton {
+public class LocatableTransferImgButton extends TransferImgButton implements Locatable {
- /**
- * <pre>
- * ID Format: "simpleClassname-imgName"
- * </pre>
- * @param img not null.
- */
- public LocatableTransferImgButton(TransferImg img) {
- this(getSuffix(img), img);
- }
+ private String locatorId;
/**
* <pre>
- * ID Format: "simpleClassname_locatorId"
+ * ID Format: "simpleClassname_locatorId_imgName"
* </pre>
* @param locatorId not null.
* @param img not null or empty.
*/
public LocatableTransferImgButton(String locatorId, TransferImg img) {
super(img);
- SeleniumUtility.setID(this, locatorId);
+ this.locatorId = locatorId;
+ this.locatorId = extendLocatorId(getSuffix(img));
+ SeleniumUtility.setID(this, this.locatorId);
}
static private String getSuffix(TransferImg img) {
@@ -54,4 +48,12 @@ public class LocatableTransferImgButton extends TransferImgButton {
return img.toString();
}
+ public String getLocatorId() {
+ return locatorId;
+ }
+
+ public String extendLocatorId(String extension) {
+ return this.locatorId + "_" + extension;
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
index 7770cba..aeac399 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java
@@ -66,6 +66,9 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
private EntityManager entityManager;
@EJB
+ private RoleManagerLocal roleManager; // self-referencing
+
+ @EJB
private SubjectManagerLocal subjectManager;
@EJB
@@ -262,7 +265,6 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
return;
}
-
@RequiredPermission(Permission.MANAGE_SECURITY)
public void setAssignedSubjectRoles(Subject subject, int subjectId, int[] roleIds) {
@@ -280,23 +282,21 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
for (Integer id : newRoles) {
newRoleIds[i++] = id;
}
- addRolesToSubject(subject, subjectId, newRoleIds);
+ roleManager.addRolesToSubject(subject, subjectId, newRoleIds);
}
- List<Integer> extraMembers = new ArrayList<Integer>(currentRoles); // members needing removal
- extraMembers.removeAll(ArrayUtils.wrapInList(roleIds));
- if (extraMembers.size() > 0) {
- int[] extraMemberIds = new int[extraMembers.size()];
+ List<Integer> removedRoles = new ArrayList<Integer>(currentRoles); // members needing removal
+ removedRoles.removeAll(ArrayUtils.wrapInList(roleIds));
+ if (removedRoles.size() > 0) {
+ int[] removedRoleIds = new int[removedRoles.size()];
int i = 0;
- for (Integer id : extraMembers) {
- extraMemberIds[i++] = id;
+ for (Integer id : removedRoles) {
+ removedRoleIds[i++] = id;
}
- removeRolesFromSubject(subject, subjectId, extraMemberIds);
+ roleManager.removeRolesFromSubject(subject, subjectId, removedRoleIds);
}
}
-
-
/**
* @see org.rhq.enterprise.server.authz.RoleManagerLocal#getRoleById(Integer)
*/
@@ -491,32 +491,32 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
public void setAssignedResourceGroups(Subject subject, int roleId, int[] groupIds) {
Role role = getRole(subject, roleId);
- List<Integer> currentMembers = new ArrayList<Integer>();
+ List<Integer> currentGroups = new ArrayList<Integer>();
for (ResourceGroup group : role.getResourceGroups()) {
- currentMembers.add(group.getId());
+ currentGroups.add(group.getId());
}
- List<Integer> newMembers = ArrayUtils.wrapInList(groupIds); // members needing addition
- newMembers.removeAll(currentMembers);
- if (newMembers.size() > 0) {
- int[] newMemberInts = new int[newMembers.size()];
+ List<Integer> newGroups = ArrayUtils.wrapInList(groupIds); // members needing addition
+ newGroups.removeAll(currentGroups);
+ if (newGroups.size() > 0) {
+ int[] newGroupIds = new int[newGroups.size()];
int i = 0;
- for (Integer id : newMembers) {
- newMemberInts[i++] = id;
+ for (Integer id : newGroups) {
+ newGroupIds[i++] = id;
}
- addResourceGroupsToRole(subject, roleId, newMemberInts);
+ roleManager.addResourceGroupsToRole(subject, roleId, newGroupIds);
}
- List<Integer> extraMembers = new ArrayList<Integer>(currentMembers); // members needing removal
- extraMembers.removeAll(ArrayUtils.wrapInList(groupIds));
- if (extraMembers.size() > 0) {
- int[] removeMemberInts = new int[extraMembers.size()];
+ List<Integer> removedGroups = new ArrayList<Integer>(currentGroups); // members needing removal
+ removedGroups.removeAll(ArrayUtils.wrapInList(groupIds));
+ if (removedGroups.size() > 0) {
+ int[] removedGroupIds = new int[removedGroups.size()];
int i = 0;
- for (Integer id : extraMembers) {
- removeMemberInts[i++] = id;
+ for (Integer id : removedGroups) {
+ removedGroupIds[i++] = id;
}
- removeResourceGroupsFromRole(subject, roleId, removeMemberInts);
+ roleManager.removeResourceGroupsFromRole(subject, roleId, removedGroupIds);
}
}
@@ -564,32 +564,33 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote {
@RequiredPermission(Permission.MANAGE_SECURITY)
public void setAssignedSubjects(Subject subject, int roleId, int[] subjectIds) {
+
Role role = getRole(subject, roleId);
- List<Integer> currentMembers = new ArrayList<Integer>();
- for (ResourceGroup group : role.getResourceGroups()) {
- currentMembers.add(group.getId());
+ List<Integer> currentSubjects = new ArrayList<Integer>();
+ for (Subject currentSubject : role.getSubjects()) {
+ currentSubjects.add(currentSubject.getId());
}
- List<Integer> newMembers = ArrayUtils.wrapInList(subjectIds); // members needing addition
- newMembers.removeAll(currentMembers);
- if (newMembers.size() > 0) {
- int[] newMemberIds = new int[newMembers.size()];
+ List<Integer> newSubjects = ArrayUtils.wrapInList(subjectIds); // members needing addition
+ newSubjects.removeAll(currentSubjects);
+ if (newSubjects.size() > 0) {
+ int[] newSubjectIds = new int[newSubjects.size()];
int i = 0;
- for (Integer id : newMembers) {
- newMemberIds[i++] = id;
+ for (Integer id : newSubjects) {
+ newSubjectIds[i++] = id;
}
- addSubjectsToRole(subject, roleId, newMemberIds);
+ roleManager.addSubjectsToRole(subject, roleId, newSubjectIds);
}
- List<Integer> extraMembers = new ArrayList<Integer>(currentMembers); // members needing removal
- extraMembers.removeAll(ArrayUtils.wrapInList(subjectIds));
- if (extraMembers.size() > 0) {
- int[] removeMemberIds = new int[extraMembers.size()];
+ List<Integer> removedSubjects = new ArrayList<Integer>(currentSubjects); // members needing removal
+ removedSubjects.removeAll(ArrayUtils.wrapInList(subjectIds));
+ if (removedSubjects.size() > 0) {
+ int[] removedSubjectIds = new int[removedSubjects.size()];
int i = 0;
- for (Integer id : extraMembers) {
- removeMemberIds[i++] = id;
+ for (Integer id : removedSubjects) {
+ removedSubjectIds[i++] = id;
}
- removeSubjectsFromRole(subject, roleId, removeMemberIds);
+ roleManager.removeSubjectsFromRole(subject, roleId, removedSubjectIds);
}
}
13 years, 9 months
[rhq] Branch 'perftest' - 9 commits - modules/cli-tests modules/enterprise modules/helpers modules/plugins modules/test-utils pom.xml
by lkrejci
modules/cli-tests/pom.xml | 3
modules/enterprise/remoting/cli/pom.xml | 3
modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml | 2
modules/enterprise/remoting/webservices/pom.xml | 1
modules/enterprise/server/jar/pom.xml | 6
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java | 222 ----------
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 7
modules/enterprise/server/jar/src/test/resources/AvailabilityInsertPurgeTest-testOne-data.xml.zip |binary
modules/helpers/perftest-support/data.sh | 3
modules/helpers/perftest-support/pom.xml | 7
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java | 11
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/FileFormat.java | 139 ++++++
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Importer.java | 10
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Main.java | 29 +
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Settings.java | 41 -
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java | 39 +
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/ExportConfiguration.java | 9
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Relationship.java | 4
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipFilter.java | 47 --
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipTableIterator.java | 4
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java | 11
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/FileInputStreamProvider.java | 44 +
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/SystemInProvider.java | 36 +
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/XmlInput.java | 1
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/ZipInputStreamProviderDecorator.java | 49 ++
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/ZippedCsvInput.java | 123 +++++
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Annotations.java | 15
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ColumnValues.java | 7
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ConfigurableDependencyInclusionResolver.java | 34 +
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyInclusionResolver.java | 4
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyType.java | 6
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EagerMappingInclusionResolver.java | 7
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Edge.java | 17
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EntityDependencyGraph.java | 46 +-
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/JPAUtil.java | 75 ++-
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Node.java | 175 +++++--
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/mapping/ColumnValuesTableMap.java | 17
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java | 11
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java | 4
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/ZippedCsvOutput.java | 118 +++++
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/ZippedXmlOutput.java | 50 ++
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/ConnectionProviderMethod.java | 36 -
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java | 27 -
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java | 23 -
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseStateStorage.java | 13
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/JdbcConnectionProviderMethod.java | 39 +
modules/helpers/perftest-support/src/main/resources/log4j.properties | 5
modules/helpers/pom.xml | 2
modules/plugins/augeas/pom.xml | 3
modules/test-utils/pom.xml | 3
pom.xml | 5
51 files changed, 1111 insertions(+), 482 deletions(-)
New commits:
commit abd46ec003fe12dea0a60bd39463e1091493199c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 14 17:02:53 2010 +0200
Adding log4j configuration to the data export/import tool.
diff --git a/modules/helpers/perftest-support/src/main/resources/log4j.properties b/modules/helpers/perftest-support/src/main/resources/log4j.properties
new file mode 100644
index 0000000..d384e4b
--- /dev/null
+++ b/modules/helpers/perftest-support/src/main/resources/log4j.properties
@@ -0,0 +1,5 @@
+log4j.rootCategory=INFO, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c] %m%n
commit b99a2e31fd204f94e1d8f576e28cf0a600e9d38b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 14 16:55:19 2010 +0200
Reimplementing the (still largely unimplemented) AvailabilityInsertPurgeTest to use the perftest-support infrastructure.
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 04d3557..335b76c 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -401,6 +401,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>perftest-support</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
index a289960..2335887 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
@@ -18,49 +18,26 @@
*/
package org.rhq.enterprise.server.performance.test;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import au.com.bytecode.opencsv.CSVReader;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.plugin.Plugin;
-import org.rhq.core.domain.resource.Agent;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.test.AbstractEJB3PerformanceTest;
-
+import org.rhq.helpers.perftest.support.testng.JdbcConnectionProviderMethod;
+import org.rhq.helpers.perftest.support.testng.DatabaseSetupInterceptor;
+import org.rhq.helpers.perftest.support.testng.DatabaseState;
+import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/**
* Performance test the availabilities subsystem
*
* @author Heiko W. Rupp
+ * @author Lukas Krejci
*/
@Test(groups = "PERF")
+@Listeners({ DatabaseSetupInterceptor.class })
+@JdbcConnectionProviderMethod("getConnection") //defined in AbstractEJB3Test
public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
- private final Log log = LogFactory.getLog(AvailabilityInsertPurgeTest.class);
-
- /*
- * we need to replace the ids in the csv files with the ids that we get back from the
- * databse in relations. So store them as pair <csv-id,new entity-id>
- */
- private Map<Integer,Integer> agentsTranslationTable = new HashMap<Integer,Integer>();
- private Map<Integer,Integer> pluginsTranslationTable = new HashMap<Integer,Integer>();
- private Map<Integer,Integer> resourceTypeTranslationTable = new HashMap<Integer,Integer>();
-
- private Map<Integer,Integer> childParentTypeMap = new HashMap<Integer, Integer>();
-
+ @DatabaseState(url = "AvailabilityInsertPurgeTest-testOne-data.xml.zip")
public void testOne() throws Exception {
- setup();
startTiming();
Thread.sleep(1234);
@@ -70,187 +47,4 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
commitTimings();
}
-
- private void setup() {
- setupAgents();
- setupPlugins();
- setupResourceTypes();
- // TODO set up resources
-
- }
-
- private void setupAgents() {
- String descriptorFile = "perftest/agents.csv";
- URL descriptorUrl = this.getClass().getClassLoader().getResource(descriptorFile);
- FileReader fr = null;
- try {
- String fileName = descriptorUrl.getFile();
- fr = new FileReader(fileName);
- } catch (FileNotFoundException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- return;
- }
- try {
- CSVReader reader = new CSVReader(fr,',','"',1); // Skip 1st line, use " as quote char and , as separator
-
- List<String[]> lines = reader.readAll();
- System.out.println("# of lines: " + lines.size());
- for (String[] line : lines) {
- if (line[0].startsWith("#"))
- continue; // comment
-
- int originalId = Integer.parseInt(line[0]);
- Agent agent = new Agent(line[1],line[2],Integer.parseInt(line[3]),line[5],line[4]);// TODO more information?
- getEntityManager().persist(agent);
- int id = agent.getId();
-
- agentsTranslationTable.put(originalId,id);
-
-
- }
- }
- catch (IOException ioe) {
- ioe.printStackTrace();
- }
- finally {
- try {
- fr.close();
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- }
- }
-
- }
-
- private void setupPlugins() {
- String descriptorFile = "perftest/plugins.csv";
- URL descriptorUrl = this.getClass().getClassLoader().getResource(descriptorFile);
- FileReader fr = null;
- try {
- String fileName = descriptorUrl.getFile();
- fr = new FileReader(fileName);
- } catch (FileNotFoundException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- return;
- }
- try {
- CSVReader reader = new CSVReader(fr,',','"',1);
-
- List<String[]> lines = reader.readAll();
- System.out.println("# of lines: " + lines.size());
- for (String[] line : lines) {
- if (line[0].startsWith("#"))
- continue; // comment
-
- int originalId = Integer.parseInt(line[0]);
- Plugin plugin = new Plugin(line[1],line[5],line[6]);
- plugin.setDisplayName(line[2]);
- plugin.setVersion(line[3]);
- plugin.setAmpsVersion(line[4]);
- getEntityManager().persist(plugin);
-
- int id = plugin.getId();
- pluginsTranslationTable.put(originalId,id);
- }
- }
- catch (IOException ioe) {
- ioe.printStackTrace();
- }
- finally {
- try {
- fr.close();
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- }
- }
-
- }
- private void setupResourceTypes() {
-
-
- // first pull in the parentResourceTypes.csv file to get a mapping for them.
- String descriptorFile = "perftest/parentResourceTypes.csv";
- URL descriptorUrl = this.getClass().getClassLoader().getResource(descriptorFile);
- FileReader fr = null;
- try {
- String fileName = descriptorUrl.getFile();
- fr = new FileReader(fileName);
- } catch (FileNotFoundException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- return;
- }
- try {
- CSVReader reader = new CSVReader(fr,',','"',1);
- List<String[]> lines = reader.readAll();
- System.out.println("# of lines: " + lines.size());
- for (String[] line: lines) {
- Integer typeId = Integer.parseInt(line[0]);
- Integer parentTypeId = Integer.parseInt(line[1]);
- childParentTypeMap.put(typeId,parentTypeId);
- }
- }
- catch (IOException ioe) {
- ioe.printStackTrace();
- }
- finally {
- try {
- fr.close();
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- }
- }
-
- // now the ResourceTypes themselves
-
- descriptorFile = "perftest/resourceTypes.csv";
- descriptorUrl = this.getClass().getClassLoader().getResource(descriptorFile);
- fr = null;
- try {
- String fileName = descriptorUrl.getFile();
- fr = new FileReader(fileName);
- } catch (FileNotFoundException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- return;
- }
- try {
- CSVReader reader = new CSVReader(fr,',','"',1);
-
- List<String[]> lines = reader.readAll();
- System.out.println("# of lines: " + lines.size());
- for (String[] line : lines) {
- if (line[0].startsWith("#"))
- continue; // comment
-
- int originalId = Integer.parseInt(line[0]);
- ResourceType parentType = findResourceType(originalId);
- ResourceCategory category = ResourceCategory.valueOf(line[2]);
- ResourceType rt = new ResourceType(line[1],line[3],category,parentType);
- getEntityManager().persist(rt);
-
- int id = rt.getId();
- resourceTypeTranslationTable.put(originalId,id);
- }
- }
- catch (IOException ioe) {
- ioe.printStackTrace();
- }
- finally {
- try {
- fr.close();
- } catch (IOException e) {
- e.printStackTrace(); // TODO: Customise this generated block
- }
- }
-
- }
-
- private ResourceType findResourceType(int originalId) {
-
- if (childParentTypeMap.containsKey(originalId)) {
- int id = childParentTypeMap.get(originalId);
- int translatedId = resourceTypeTranslationTable.get(id);
- ResourceType parentType = getEntityManager().find(ResourceType.class,translatedId);
- }
- return null;
- }
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index 3425ebb..4d5859d 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.test;
import java.sql.Connection;
+import java.sql.SQLException;
import java.util.Hashtable;
import java.util.Properties;
@@ -138,7 +139,7 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
public static void startTest() {
if (DatabaseTypeFactory.getDefaultDatabaseType() == null) {
try {
- Connection conn = LookupUtil.getDataSource().getConnection();
+ Connection conn = getConnection();
DatabaseTypeFactory.setDefaultDatabaseType(DatabaseTypeFactory.getDatabaseType(conn));
} catch (Exception e) {
System.err.println("!!! WARNING !!! cannot set default database type, some tests may fail");
@@ -149,6 +150,10 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
start = stats.getQueryExecutionCount();
}
+ public static Connection getConnection() throws SQLException {
+ return LookupUtil.getDataSource().getConnection();
+ }
+
@AfterMethod
public static void endTest() {
//System.out.println("Connections used: " + (stats.getQueryExecutionCount() - start));
diff --git a/modules/enterprise/server/jar/src/test/resources/AvailabilityInsertPurgeTest-testOne-data.xml.zip b/modules/enterprise/server/jar/src/test/resources/AvailabilityInsertPurgeTest-testOne-data.xml.zip
new file mode 100644
index 0000000..811c952
Binary files /dev/null and b/modules/enterprise/server/jar/src/test/resources/AvailabilityInsertPurgeTest-testOne-data.xml.zip differ
commit d03ff13faf2283af81b7f97b85524fc58e467e96
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 14 16:52:27 2010 +0200
Reshuffling, renaming and reorganizing stuff so it's slightly more logical.
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/FileFormat.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/FileFormat.java
index a0c6d1c..60f7736 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/FileFormat.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/FileFormat.java
@@ -19,11 +19,146 @@
package org.rhq.helpers.perftest.support;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.rhq.helpers.perftest.support.input.CsvInput;
+import org.rhq.helpers.perftest.support.input.FileInputStreamProvider;
+import org.rhq.helpers.perftest.support.input.InputStreamProvider;
+import org.rhq.helpers.perftest.support.input.SystemInProvider;
+import org.rhq.helpers.perftest.support.input.XmlInput;
+import org.rhq.helpers.perftest.support.input.ZipInputStreamProviderDecorator;
+import org.rhq.helpers.perftest.support.input.ZippedCsvInput;
+import org.rhq.helpers.perftest.support.output.CsvOutput;
+import org.rhq.helpers.perftest.support.output.XmlOutput;
+import org.rhq.helpers.perftest.support.output.ZippedCsvOutput;
+import org.rhq.helpers.perftest.support.output.ZippedXmlOutput;
+
/**
* Represents a file format to export/import database data to/from.
*
* @author Lukas Krejci
*/
public enum FileFormat {
- XML, CSV
-}
\ No newline at end of file
+
+ /**
+ * XML file format. The input/output specification is understood to be a path to an input/output file.
+ */
+ XML {
+ public Input getInput(String inputSpec) throws IOException {
+ InputStreamProvider isp = inputSpec == null ? new SystemInProvider() : new FileInputStreamProvider(
+ new File(inputSpec));
+ return new XmlInput(isp, inputSpec != null);
+ }
+
+ public Input getInput(InputStreamProvider provider) throws IOException {
+ return new XmlInput(provider, true);
+ }
+
+ public Output getOutput(String outputSpec) throws IOException {
+ OutputStream stream = outputSpec == null ? System.out : new FileOutputStream(outputSpec);
+
+ return new XmlOutput(stream, outputSpec != null);
+ }
+ },
+
+ /**
+ * CSV file format. The input/output specification is understood to be a path to a pre-existing
+ * directory that should contain the input/output files.
+ */
+ CSV {
+ public Input getInput(String inputSpec) throws IOException {
+ File directory = new File(inputSpec);
+
+ return new CsvInput(directory);
+ }
+
+ public Input getInput(InputStreamProvider provider) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Output getOutput(String outputSpec) throws IOException {
+ File directory = new File(outputSpec);
+ return new CsvOutput(directory);
+ }
+ },
+
+ /**
+ * Zipped XML format. The input/output specification is understood to be a path to a zip file
+ * containing the xml file.
+ */
+ ZIPPED_XML {
+ public Input getInput(String inputSpec) throws IOException {
+ InputStreamProvider isp = inputSpec == null ? new SystemInProvider() : new FileInputStreamProvider(
+ new File(inputSpec));
+ return new XmlInput(new ZipInputStreamProviderDecorator(isp, true), inputSpec != null);
+ }
+
+ public Input getInput(InputStreamProvider provider) {
+ return new XmlInput(new ZipInputStreamProviderDecorator(provider, true), true);
+ }
+
+ public Output getOutput(String outputSpec) throws IOException {
+ OutputStream stream = outputSpec == null ? System.out : new FileOutputStream(outputSpec);
+ return new ZippedXmlOutput(stream, outputSpec != null);
+ }
+ },
+
+ /**
+ * Zipped CSV format. The input/output specification is understood to be a path to a zip file
+ * containing the compressed directory with the CSV files.
+ */
+ ZIPPED_CSV {
+ public Input getInput(String inputSpec) throws IOException {
+ File file = new File(inputSpec);
+
+ return new ZippedCsvInput(new ZipInputStreamProviderDecorator(new FileInputStreamProvider(file), false));
+ }
+
+ public Input getInput(InputStreamProvider provider) throws IOException {
+ if (provider instanceof ZipInputStreamProviderDecorator) {
+ return new ZippedCsvInput((ZipInputStreamProviderDecorator)provider);
+ } else {
+ return new ZippedCsvInput(new ZipInputStreamProviderDecorator(provider, false));
+ }
+ }
+
+ public Output getOutput(String outputSpec) throws IOException {
+ File file = new File(outputSpec);
+ return new ZippedCsvOutput(file);
+ }
+ };
+
+ /**
+ * Returns an {@link Input} instance based on the input specification.
+ * The format of the input specification is file format dependent.
+ *
+ * @param inputSpec the "location" of the input
+ * @return an {@link Input} instance able to process the inputSpec
+ */
+ public abstract Input getInput(String inputSpec) throws IOException;
+
+ /**
+ * Returns an {@link Input} instance initialized with the specified
+ * {@link InputStreamProvider}. This enables more "low-level" usage than
+ * the {@link #getInput(String)} method which assumes that the inputSpec can
+ * specify the input location without any other contextual information.
+ *
+ * @param provider
+ * @return
+ * @throws IOException
+ * @throws UnsupportedOperationException if this file format doesn't support this type of initialization.
+ */
+ public abstract Input getInput(InputStreamProvider provider) throws IOException;
+
+ /**
+ * Returns an {@link Output} instance based on the output specification.
+ * The format of the output specification is file format dependent.
+ *
+ * @param outputSpec the "location" of the output
+ * @return an {@link Output} instance able to process the outputSpec
+ */
+ public abstract Output getOutput(String outputSpec) throws IOException;
+}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Settings.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Settings.java
index 6d031b4..51f7079 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Settings.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Settings.java
@@ -19,19 +19,7 @@
package org.rhq.helpers.perftest.support;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.rhq.helpers.perftest.support.input.CsvInput;
-import org.rhq.helpers.perftest.support.input.InputStreamProvider;
-import org.rhq.helpers.perftest.support.input.XmlInput;
-import org.rhq.helpers.perftest.support.output.CsvOutput;
-import org.rhq.helpers.perftest.support.output.XmlOutput;
/**
*
@@ -62,11 +50,11 @@ public class Settings {
* to which the CSV files corresponding to database tables will be written.
*
* @param fileFormat one of the values specified in {@link FileFormat} (case-insensitive)
+ * @param zipped true if the output should be ZIP compressed
* @param outputSpec format dependent specifier of output location
* @return an output object
- * @throws FileNotFoundException
*/
- public static Output getOutputObject(String fileFormat, final String outputSpec) throws FileNotFoundException {
+ public static Output getOutputObject(String fileFormat, final String outputSpec) throws IOException {
FileFormat format = fileFormat == null ? FileFormat.XML : Enum.valueOf(FileFormat.class,
fileFormat.toUpperCase());
@@ -74,16 +62,8 @@ public class Settings {
if (format == null) {
throw new IllegalArgumentException("Unknown file format specified: " + fileFormat);
}
-
- switch (format) {
- case XML:
- OutputStream stream = outputSpec == null ? System.out : new FileOutputStream(new File(outputSpec));
- return new XmlOutput(stream, stream != System.out);
- case CSV:
- return new CsvOutput(new File(outputSpec));
- default:
- throw new IllegalStateException("FileFormat defined, but don't know how to create it: " + format);
- }
+
+ return format.getOutput(outputSpec);
}
/**
@@ -101,17 +81,6 @@ public class Settings {
throw new IllegalArgumentException("Unknown file format specified: " + fileFormat);
}
- switch (format) {
- case XML:
- return new XmlInput(new InputStreamProvider() {
- public InputStream createInputStream() throws FileNotFoundException {
- return inputSpec == null ? System.in : new FileInputStream(new File(inputSpec));
- }
- }, inputSpec != null);
- case CSV:
- return new CsvInput(new File(inputSpec));
- default:
- throw new IllegalStateException("FileFormat defined, but don't know how to create it: " + format);
- }
+ return format.getInput(inputSpec);
}
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java
index be3b083..a1d522d 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java
@@ -40,6 +40,14 @@ public class CsvInput implements Input {
this.directory = directory;
}
+ protected File getDirectory() {
+ return directory;
+ }
+
+ protected CsvProducer getCsvProducer() {
+ return producer;
+ }
+
public IDataSetProducer getProducer() throws Exception {
if (producer == null) {
if (!directory.isDirectory()) {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/FileInputStreamProvider.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/FileInputStreamProvider.java
new file mode 100644
index 0000000..cc83692
--- /dev/null
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/FileInputStreamProvider.java
@@ -0,0 +1,44 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.helpers.perftest.support.input;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An {@link InputStreamProvider} implementation returning a {@link FileInputStream}.
+ *
+ * @author Lukas Krejci
+ */
+public class FileInputStreamProvider implements InputStreamProvider {
+
+ private File file;
+
+ public FileInputStreamProvider(File file) {
+ this.file = file;
+ }
+
+ public InputStream createInputStream() throws IOException {
+ return new FileInputStream(file);
+ }
+
+}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/SystemInProvider.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/SystemInProvider.java
new file mode 100644
index 0000000..a6c2f85
--- /dev/null
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/SystemInProvider.java
@@ -0,0 +1,36 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.helpers.perftest.support.input;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * {@link InputStreamProvider} implementation that returns {@link System#in}.
+ *
+ * @author Lukas Krejci
+ */
+public class SystemInProvider implements InputStreamProvider {
+
+ public InputStream createInputStream() throws IOException {
+ return System.in;
+ }
+
+}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/ZipInputStreamProviderDecorator.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/ZipInputStreamProviderDecorator.java
new file mode 100644
index 0000000..bae9f64
--- /dev/null
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/ZipInputStreamProviderDecorator.java
@@ -0,0 +1,49 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.helpers.perftest.support.input;
+
+import java.io.IOException;
+import java.util.zip.ZipInputStream;
+
+/**
+ * This is a wrapper around another {@link InputStreamProvider} that returns
+ * a {@link ZipInputStream} wrapped around the stream provided by the decorated provider.
+ *
+ * @author Lukas Krejci
+ */
+public class ZipInputStreamProviderDecorator implements InputStreamProvider {
+
+ private InputStreamProvider inner;
+ private boolean openEntry;
+
+ public ZipInputStreamProviderDecorator(InputStreamProvider inner, boolean openEntry) {
+ this.inner = inner;
+ this.openEntry = openEntry;
+ }
+
+ public ZipInputStream createInputStream() throws IOException {
+ ZipInputStream stream = new ZipInputStream(inner.createInputStream());
+ if (openEntry) {
+ stream.getNextEntry();
+ }
+ return stream;
+ }
+
+}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/ZippedCsvInput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/ZippedCsvInput.java
new file mode 100644
index 0000000..0537e37
--- /dev/null
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/ZippedCsvInput.java
@@ -0,0 +1,123 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.helpers.perftest.support.input;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.dbunit.dataset.stream.IDataSetProducer;
+
+/**
+ * Represents a zipped CSV input.
+ *
+ * @author Lukas Krejci
+ */
+public class ZippedCsvInput extends CsvInput {
+
+ private ZipInputStreamProviderDecorator sourceFile;
+
+ /**
+ *
+ * @param zipFileProvider a provider that creates a stream to read the zip file.
+ * @throws IOException
+ */
+ public ZippedCsvInput(ZipInputStreamProviderDecorator zipFileProvider) throws IOException {
+ super(createTempDirectory());
+ sourceFile = zipFileProvider;
+ }
+
+ @Override
+ public void close() throws IOException {
+ super.close();
+ delete(getDirectory());
+ }
+
+ @Override
+ public IDataSetProducer getProducer() throws Exception {
+ if (getCsvProducer() == null) {
+ unzip(sourceFile.createInputStream(), getDirectory());
+ }
+ return super.getProducer();
+ }
+
+ private static File createTempDirectory() throws IOException {
+ File tmpFile = File.createTempFile("perftest-support-csv-output", null);
+ tmpFile.delete();
+ tmpFile.mkdir();
+
+ return tmpFile;
+ }
+
+ private static void unzip(ZipInputStream zipFile, File target) throws RuntimeException, IOException {
+ ZipEntry entry = null;
+ while((entry = zipFile.getNextEntry()) != null) {
+ File f = new File(target, entry.getName());
+
+ if (entry.isDirectory()) {
+ f.mkdirs();
+ } else {
+ String parentDirectory = f.getParent();
+ File parentDirectoryFile = new File(parentDirectory);
+ parentDirectoryFile.mkdirs();
+
+ BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(f));
+ try {
+ copy(zipFile, outputStream);
+ } finally {
+ outputStream.close();
+ }
+ }
+ }
+ }
+
+ private static void delete(File f) {
+ if (f.isDirectory()) {
+ for (File child : f.listFiles()) {
+ delete(child);
+ }
+ f.delete();
+ } else {
+ f.delete();
+ }
+ }
+
+ private static void copy(InputStream input, OutputStream output) throws IOException {
+ long numBytesCopied = 0;
+ int bufferSize = 32768;
+
+ input = new BufferedInputStream(input, bufferSize);
+
+ byte[] buffer = new byte[bufferSize];
+
+ for (int bytesRead = input.read(buffer); bytesRead != -1; bytesRead = input.read(buffer)) {
+ output.write(buffer, 0, bytesRead);
+ numBytesCopied += bytesRead;
+ }
+
+ output.flush();
+ }
+}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java
index 6230ffc..407992b 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java
@@ -40,6 +40,10 @@ public class CsvOutput implements Output {
this.directory = directory;
}
+ protected File getDirectory() {
+ return directory;
+ }
+
public IDataSetConsumer getConsumer() throws Exception {
if (consumer == null) {
consumer = new CsvDataSetWriter(directory);
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java
index 2ec8de0..247cf67 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java
@@ -27,7 +27,7 @@ import org.dbunit.dataset.xml.FlatXmlWriter;
import org.rhq.helpers.perftest.support.Output;
/**
- * Implements the {@link Output} interface to ouput the database data into an XML file using
+ * Implements the {@link Output} interface to output the database data into an XML file using
* {@link FlatXmlWriter}.
*
* @author Lukas Krejci
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/ZippedCsvOutput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/ZippedCsvOutput.java
new file mode 100644
index 0000000..dc5043d
--- /dev/null
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/ZippedCsvOutput.java
@@ -0,0 +1,118 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.helpers.perftest.support.output;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Represents a CSV output compressed to a zip file.
+ *
+ * @author Lukas Krejci
+ */
+public class ZippedCsvOutput extends CsvOutput {
+
+ private File targetFile;
+
+ /**
+ * @param file the target zip file
+ * @throws IOException
+ */
+ public ZippedCsvOutput(File file) throws IOException {
+ super(createTempDirectory());
+ targetFile = file;
+ }
+
+ public void close() throws IOException {
+ super.close();
+ ZipOutputStream stream = null;
+ try {
+ stream = new ZipOutputStream(new FileOutputStream(targetFile));
+ zipFileOrDir(super.getDirectory(), stream);
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ delete(super.getDirectory());
+ }
+ }
+
+ private static File createTempDirectory() throws IOException {
+ File tmpFile = File.createTempFile("perftest-support-csv-output", null);
+ tmpFile.delete();
+ tmpFile.mkdir();
+
+ return tmpFile;
+ }
+
+ private static void zipFileOrDir(File f, ZipOutputStream zipFile) throws IOException {
+ if (f.isDirectory()) {
+ for (File child : f.listFiles()) {
+ zipFileOrDir(child, zipFile);
+ }
+ } else {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(f);
+ ZipEntry zipEntry = new ZipEntry(f.getPath());
+ zipFile.putNextEntry(zipEntry);
+ copy(fis, zipFile);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ }
+ }
+
+ private static void copy(InputStream input, OutputStream output) throws IOException {
+ long numBytesCopied = 0;
+ int bufferSize = 32768;
+
+ input = new BufferedInputStream(input, bufferSize);
+
+ byte[] buffer = new byte[bufferSize];
+
+ for (int bytesRead = input.read(buffer); bytesRead != -1; bytesRead = input.read(buffer)) {
+ output.write(buffer, 0, bytesRead);
+ numBytesCopied += bytesRead;
+ }
+
+ output.flush();
+ }
+
+ private static void delete(File f) {
+ if (f.isDirectory()) {
+ for (File child : f.listFiles()) {
+ delete(child);
+ }
+ f.delete();
+ } else {
+ f.delete();
+ }
+ }
+}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/ZippedXmlOutput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/ZippedXmlOutput.java
new file mode 100644
index 0000000..c9ada08
--- /dev/null
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/ZippedXmlOutput.java
@@ -0,0 +1,50 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.helpers.perftest.support.output;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Represents a zipped XML output.
+ *
+ * @author Lukas Krejci
+ */
+public class ZippedXmlOutput extends XmlOutput {
+
+ /**
+ *
+ * @param stream the stream to write the data to.
+ * @param doClose
+ * @throws IOException
+ */
+ public ZippedXmlOutput(OutputStream stream, boolean doClose) throws IOException {
+ super(getNewZipStream(stream), doClose);
+ }
+
+ private static ZipOutputStream getNewZipStream(OutputStream stream) throws IOException {
+ ZipOutputStream zipStream = new ZipOutputStream(stream);
+ zipStream.putNextEntry(new ZipEntry("data"));
+
+ return zipStream;
+ }
+}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/ConnectionProviderMethod.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/ConnectionProviderMethod.java
deleted file mode 100644
index f453598..0000000
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/ConnectionProviderMethod.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-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 as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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 for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.helpers.perftest.support.testng;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.sql.Connection;
-
-/**
- * Specifies the method on the annotated class that can provide JDBC connections to the caller.
- * The method must accept no arguments and return a {@link Connection} instance.
- *
- * @author Lukas Krejci
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-public @interface ConnectionProviderMethod {
-
- String value();
-}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
index 2f8ff3f..605caf6 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
@@ -29,7 +29,10 @@ import java.sql.Connection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.helpers.perftest.support.FileFormat;
import org.rhq.helpers.perftest.support.Importer;
+import org.rhq.helpers.perftest.support.Input;
+import org.rhq.helpers.perftest.support.input.FileInputStreamProvider;
import org.rhq.helpers.perftest.support.input.InputStreamProvider;
import org.rhq.helpers.perftest.support.input.XmlInput;
import org.testng.IInvokedMethod;
@@ -60,11 +63,13 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
Method connectionProviderMethod = getConnectionProviderMethod(method, state);
try {
- InputStreamProvider dataInput = getDataInput(state.url(), state.storage(), method);
+ InputStreamProvider streamProvider = getInputStreamProvider(state.url(), state.storage(), method);
Object classInstance = method.getTestMethod().getInstances()[0];
Connection connection = (Connection) connectionProviderMethod.invoke(classInstance, (Object[]) null);
- XmlInput input = new XmlInput(dataInput, true);
+ FileFormat format = state.format();
+
+ Input input = format.getInput(streamProvider);
try {
Importer.run(connection, input);
@@ -90,7 +95,7 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
String methodName = state.connectionProviderMethod();
Class<?> declaringClass = method.getTestMethod().getMethod().getDeclaringClass();
if (methodName == null || methodName.trim().isEmpty()) {
- ConnectionProviderMethod methodAnnotation = declaringClass.getAnnotation(ConnectionProviderMethod.class);
+ JdbcConnectionProviderMethod methodAnnotation = declaringClass.getAnnotation(JdbcConnectionProviderMethod.class);
if (methodAnnotation == null) {
throw new IllegalStateException(
"Neither 'connectionProviderMethod' attribute of the @DatabaseState annotation nor @ConnectionProviderMethod annotation could be found. Cannot initialize the database state without being able to get a connection.");
@@ -109,7 +114,7 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
}
- private static InputStreamProvider getDataInput(final String url, DatabaseStateStorage storage, final IInvokedMethod method)
+ private static InputStreamProvider getInputStreamProvider(final String url, DatabaseStateStorage storage, final IInvokedMethod method)
throws FileNotFoundException {
switch (storage) {
case CLASSLOADER:
@@ -120,11 +125,7 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
}
};
case FILESYSTEM:
- return new InputStreamProvider() {
- public InputStream createInputStream() throws IOException {
- return new FileInputStream(new File(url));
- }
- };
+ return new FileInputStreamProvider(new File(url));
default:
return null;
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
index aaa216b..af9e94c 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
@@ -24,6 +24,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.rhq.helpers.perftest.support.FileFormat;
+
/**
* An annotation to associate a test method with a required state of the database.
*
@@ -44,8 +46,13 @@ public @interface DatabaseState {
DatabaseStateStorage storage() default DatabaseStateStorage.CLASSLOADER;
/**
+ * The format of the export file (defaults to zipped xml).
+ */
+ FileFormat format() default FileFormat.ZIPPED_XML;
+
+ /**
* The name of the method to provide a JDBC connection object.
- * If the method is not specified, the value of the {@link ConnectionProviderMethod} annotation
+ * If the method is not specified, the value of the {@link JdbcConnectionProviderMethod} annotation
* is used.
*/
String connectionProviderMethod() default "";
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/JdbcConnectionProviderMethod.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/JdbcConnectionProviderMethod.java
new file mode 100644
index 0000000..8f04045
--- /dev/null
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/JdbcConnectionProviderMethod.java
@@ -0,0 +1,39 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-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 as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.helpers.perftest.support.testng;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.sql.Connection;
+
+/**
+ * Specifies the method on the annotated class that can provide JDBC connections to the caller.
+ * The method must accept no arguments and return a {@link Connection} instance.
+ *
+ * @author Lukas Krejci
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.TYPE)
+public @interface JdbcConnectionProviderMethod {
+
+ String value();
+}
commit 4c3bb35d30b46f969b1a05cbcea887fbef17b306
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 14 16:48:03 2010 +0200
Added a bit of usage blurb and validation to the data export/import tool Main class.
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Main.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Main.java
index 1e7d03d..bdd815c 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Main.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Main.java
@@ -24,6 +24,7 @@ import gnu.getopt.LongOpt;
import java.io.FileReader;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Properties;
@@ -58,7 +59,7 @@ public class Main {
longOptions[8] = new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null, 'f');
longOptions[9] = new LongOpt("format", LongOpt.REQUIRED_ARGUMENT, null, 'o');
- Getopt options = new Getopt("datagen", args, "eihr:u:p:d:c:f:o:", longOptions);
+ Getopt options = new Getopt("data", args, "eihr:u:p:d:c:f:o:", longOptions);
String url = null;
String user = null;
@@ -118,7 +119,9 @@ public class Main {
putNotNull(settings, "password", password);
putNotNull(settings, "driverClass", driverClass);
- validate(settings);
+ if (!validate(settings)) {
+ System.exit(1);
+ }
ExportConfiguration config = null;
@@ -172,14 +175,30 @@ public class Main {
}
}
- private static void validate(Properties settings) {
- //TODO implement
+ private static boolean validate(Properties settings) {
+ boolean ok = true;
+
+ if (!settings.containsKey("url")) {
+ System.err.println("The url of the database to connect to is missing.");
+ ok = false;
+ }
+
+ return ok;
}
private static void usage() {
System.out.println("Usage:");
- //TODO implement
+ System.out.println("data(.sh|.bat) (--export|--import) [<other-options>] [entity-names...]");
+ System.out.println();
+ System.out.println("--url : the JDBC URL to the database");
+ System.out.println("--username : the database username");
+ System.out.println("--password : the database password");
+ System.out.println("--driver-class : the full name of the JDBC driver class");
+ System.out.println("--config-file : The configuration file specifying what entities to export");
+ System.out.println("--file : the file to export the data to or to import the data from (defaults to standard output or input respectively)");
+ System.out.println("--format : one of " + Arrays.asList(FileFormat.values()));
+ System.out.println("--help : this info");
System.exit(0);
}
commit 26031f85f7e3c55f2084e1d337525f44b973ca24
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 14 16:47:13 2010 +0200
Adding a Linux specific script to start the data exporter/importer.
diff --git a/modules/helpers/perftest-support/data.sh b/modules/helpers/perftest-support/data.sh
new file mode 100755
index 0000000..e7cccdf
--- /dev/null
+++ b/modules/helpers/perftest-support/data.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+java -cp 'target/dependency/*':target/perftest-support-4.0.0-SNAPSHOT.jar org.rhq.helpers.perftest.support.Main $@
diff --git a/modules/helpers/perftest-support/pom.xml b/modules/helpers/perftest-support/pom.xml
index 82094ff..2dbe9c9 100644
--- a/modules/helpers/perftest-support/pom.xml
+++ b/modules/helpers/perftest-support/pom.xml
@@ -68,7 +68,6 @@
<configuration>
<archive>
<manifest>
- <addClasspath>true</addClasspath>
<mainClass>org.rhq.helpers.perftest.support.Main</mainClass>
</manifest>
</archive>
commit 7edb6c1e0012f517dc3dc60203ff151ad59f39d8
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Sep 14 16:45:28 2010 +0200
Upping the TestNG version to 5.13.1 so that we can use the @Listeners annotation.
Made the TestNG version consistent throughout the codebase.
diff --git a/modules/cli-tests/pom.xml b/modules/cli-tests/pom.xml
index 6eed8b4..34fd6c1 100644
--- a/modules/cli-tests/pom.xml
+++ b/modules/cli-tests/pom.xml
@@ -30,8 +30,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.8</version>
- <classifier>jdk15</classifier>
+ <version>${testng.version}</version>
</dependency>
<dependency>
diff --git a/modules/enterprise/remoting/cli/pom.xml b/modules/enterprise/remoting/cli/pom.xml
index 6bf2f26..cf0c24a 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -63,9 +63,8 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.9</version>
+ <version>${testng.version}</version>
<!-- Yes, this is actually meant to be compile, and not test, scoped. -->
- <classifier>jdk15</classifier>
</dependency>
<dependency>
diff --git a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
index 142e87b..b80f900 100644
--- a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
@@ -63,7 +63,7 @@
<copy file="${settings.localRepository}/javax/persistence/persistence-api/${persistence-api.version}/persistence-api-${persistence-api.version}.jar" tofile="${lib.home}/persistence-api-${persistence-api.version}.jar" verbose="true" />
<copy file="${basedir}/target/${project.artifactId}-${project.version}.jar" tofile="${lib.home}/${project.artifactId}-${project.version}.jar" verbose="true" />
<copy file="${settings.localRepository}/net/sf/opencsv/opencsv/${opencsv.version}/opencsv-${opencsv.version}.jar" tofile="${lib.home}/opencsv-${opencsv.version}.jar" verbose="true" />
- <copy file="${settings.localRepository}/org/testng/testng/${testng.version}/testng-${testng.version}-jdk15.jar" tofile="${lib.home}/testng-${testng.version}-jdk15.jar" verbose="true" />
+ <copy file="${settings.localRepository}/org/testng/testng/${testng.version}/testng-${testng.version}.jar" tofile="${lib.home}/testng-${testng.version}.jar" verbose="true" />
</target>
</project>
diff --git a/modules/enterprise/remoting/webservices/pom.xml b/modules/enterprise/remoting/webservices/pom.xml
index 71e2f93..e85d0d4 100644
--- a/modules/enterprise/remoting/webservices/pom.xml
+++ b/modules/enterprise/remoting/webservices/pom.xml
@@ -76,7 +76,6 @@
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
- <classifier>jdk15</classifier>
</dependency>
</dependencies>
diff --git a/modules/helpers/perftest-support/pom.xml b/modules/helpers/perftest-support/pom.xml
index a9e3322..82094ff 100644
--- a/modules/helpers/perftest-support/pom.xml
+++ b/modules/helpers/perftest-support/pom.xml
@@ -34,9 +34,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.9</version> <!-- replace with ${testng.version} once it's correctly integrated in the build -->
- <!-- <version>${testng.version}</version> -->
- <classifier>jdk15</classifier>
+ <version>${testng.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/modules/plugins/augeas/pom.xml b/modules/plugins/augeas/pom.xml
index cc1edd1..f8dd571 100644
--- a/modules/plugins/augeas/pom.xml
+++ b/modules/plugins/augeas/pom.xml
@@ -44,8 +44,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.9</version>
- <classifier>jdk15</classifier>
+ <version>${testng.version}</version>
</dependency>
<dependency>
diff --git a/modules/test-utils/pom.xml b/modules/test-utils/pom.xml
index 5f96131..54d18cc 100644
--- a/modules/test-utils/pom.xml
+++ b/modules/test-utils/pom.xml
@@ -13,9 +13,8 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.9</version>
+ <version>${testng.version}</version>
<scope>compile</scope>
- <classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
diff --git a/pom.xml b/pom.xml
index 7888b45..b236c13 100644
--- a/pom.xml
+++ b/pom.xml
@@ -96,7 +96,7 @@
<jna.version>3.2.5</jna.version>
<twitter4j.version>2.1.2</twitter4j.version>
<commons-codec.version>1.4</commons-codec.version>
- <testng.version>5.9</testng.version>
+ <testng.version>5.13.1</testng.version>
<!--
defaults for datasource used by integration tests -
@@ -445,9 +445,8 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.9</version>
+ <version>${testng.version}</version>
<scope>test</scope>
- <classifier>jdk15</classifier>
</dependency>
<!-- for the Nullable/NotNull annotations -->
commit a2971dc30a123ff7032ca72faf4aea0b7c7dc0e4
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Sep 13 13:42:56 2010 +0200
Fix the generation of the export configuration from a pre-existing entity dependency graph.
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/ExportConfiguration.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/ExportConfiguration.java
index 1e72333..580ca0d 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/ExportConfiguration.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/ExportConfiguration.java
@@ -151,7 +151,10 @@ public class ExportConfiguration {
for (Edge edge : node.getEdges()) {
if (edge.getFrom() == node) {
- edges.add(fromRealEdge(node, edge, realToSerialized));
+ Relationship r = fromRealEdge(node, edge, realToSerialized);
+ if (r != null) {
+ edges.add(r);
+ }
}
}
@@ -179,10 +182,14 @@ public class ExportConfiguration {
if (currentNode.equals(edge.getFrom())) {
if (edge.getFromField() != null) {
ret.setField(edge.getFromField().getName());
+ } else {
+ return null;
}
} else {
if (edge.getToField() != null) {
ret.setField(edge.getToField().getName());
+ } else {
+ return null;
}
}
return ret;
commit b7444a022e29931e19834e7b23229652f99e12ee
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Sep 13 13:26:02 2010 +0200
Include the perftest-support module in the parent module and call it a proper name.
diff --git a/modules/helpers/perftest-support/pom.xml b/modules/helpers/perftest-support/pom.xml
index 5f29ea8..a9e3322 100644
--- a/modules/helpers/perftest-support/pom.xml
+++ b/modules/helpers/perftest-support/pom.xml
@@ -6,7 +6,7 @@
<version>4.0.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq.helpers</groupId>
- <artifactId>data-gen</artifactId>
+ <artifactId>perftest-support</artifactId>
<version>4.0.0-SNAPSHOT</version>
<name>Performance Testing Support</name>
<description>To support performance testing, this is a basic tool to support extracting and later reimporting of data from/to a database.</description>
diff --git a/modules/helpers/pom.xml b/modules/helpers/pom.xml
index a26b7f2..4108570 100644
--- a/modules/helpers/pom.xml
+++ b/modules/helpers/pom.xml
@@ -38,7 +38,7 @@
<module>pluginGen</module>
<module>pluginAnnotations</module>
<module>bundleGen</module>
- <module>perftest-data-gen</module>
+ <module>perftest-support</module>
</modules>
commit b4e37380333980fdbc472c369d0ce7d70155de73
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Sep 13 13:25:31 2010 +0200
Javadoc and formatting for perftest-support.
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java
index e435284..45df4ac 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java
@@ -45,7 +45,8 @@ import org.rhq.helpers.perftest.support.jpa.ConfigurableDependencyInclusionResol
import org.rhq.helpers.perftest.support.jpa.mapping.MappingTranslator;
/**
- *
+ * A utility class to run an export.
+ *
* @author Lukas Krejci
*/
public class Exporter {
@@ -54,6 +55,14 @@ public class Exporter {
}
+ /**
+ * Runs the export using given export configuration and supplies the data to the provided
+ * consumer (which should convert it to some kind of output).
+ *
+ * @param config
+ * @param consumer
+ * @throws Exception
+ */
public static void run(ExportConfiguration config, IDataSetConsumer consumer) throws Exception {
IDatabaseConnection connection = DbUnitUtil.getConnection(config.getSettings());
try {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Importer.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Importer.java
index 42c5206..00724fe 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Importer.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Importer.java
@@ -30,7 +30,8 @@ import org.dbunit.operation.DatabaseOperation;
import org.rhq.helpers.perftest.support.dbunit.DbUnitUtil;
/**
- *
+ * Utility method to import the data previously produced by the {@link Exporter}.
+ *
* @author Lukas Krejci
*/
public class Importer {
@@ -39,6 +40,13 @@ public class Importer {
}
+ /**
+ * Imports the data from the input into a database using the provided JDBC connection.
+ *
+ * @param jdbcConnection
+ * @param input
+ * @throws Exception
+ */
public static void run(Connection jdbcConnection, Input input) throws Exception {
run(new DatabaseConnection(jdbcConnection), input);
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java
index 2bc92a0..cc2ef96 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java
@@ -30,7 +30,8 @@ import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
/**
- *
+ * Represents an entity in the dependency graph.
+ *
* @author Lukas Krejci
*/
@XmlRootElement
@@ -40,24 +41,30 @@ public class Entity {
@XmlID
@XmlAttribute
private String name;
-
+
@XmlAttribute
private Boolean includeAllFields;
-
+
@XmlElement(name = "rel")
private Set<Relationship> relationships = new HashSet<Relationship>();
-
+
@XmlElement(name = "filter")
private String filter;
-
+
+ /**
+ * @return the relationships defined on this entity.
+ */
public Set<Relationship> getRelationships() {
return relationships;
}
-
+
public void setRelationships(Set<Relationship> relationships) {
this.relationships = relationships;
}
-
+
+ /**
+ * @return the name of this entity
+ */
public String getName() {
return name;
}
@@ -67,10 +74,11 @@ public class Entity {
}
/**
- * @return the allDependents
+ * @return true if all fields on this entity are considered as included
+ * (as opposed to explicitly defined in the {@link #getRelationships()}).
*/
public boolean isIncludeAllFields() {
- return includeAllFields == null ? false :includeAllFields;
+ return includeAllFields == null ? false : includeAllFields;
}
/**
@@ -81,29 +89,28 @@ public class Entity {
}
/**
- * @return the filter
+ * @return the SQL statement that returns the primary keys to be considered.
*/
public String getFilter() {
return filter;
}
-
+
/**
* @param filter the filter to set
*/
public void setFilter(String filter) {
this.filter = filter;
}
-
+
public int hashCode() {
return name.hashCode();
}
-
+
public boolean equals(Object other) {
if (!(other instanceof Entity)) {
return false;
}
-
- return name.equals(((Entity)other).name);
+
+ return name.equals(((Entity) other).name);
}
}
-
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Relationship.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Relationship.java
index 9f0d99b..b9554c0 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Relationship.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Relationship.java
@@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
/**
- *
+ * Represents a relationship between two {@link Entity entities}.
* @author Lukas Krejci
*/
@XmlRootElement(name = "rel")
@@ -36,7 +36,7 @@ public class Relationship {
private String field;
/**
- * @return the fromField
+ * @return the name of the field on the owning {@link Entity} that represents the relationship.
*/
public String getField() {
return field;
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipFilter.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipFilter.java
index 3ee2e57..0d6bf9a 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipFilter.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipFilter.java
@@ -19,30 +19,22 @@
package org.rhq.helpers.perftest.support.dbunit;
-import java.io.StringReader;
-import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-
-import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.DatabaseSequenceFilter;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.DataSetException;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.ITableIterator;
-import org.rhq.helpers.perftest.support.config.ExportConfiguration;
+import org.dbunit.dataset.filter.ITableFilter;
import org.rhq.helpers.perftest.support.jpa.ColumnValues;
-import org.rhq.helpers.perftest.support.jpa.ConfigurableDependencyInclusionResolver;
import org.rhq.helpers.perftest.support.jpa.DependencyInclusionResolver;
import org.rhq.helpers.perftest.support.jpa.DependencyType;
import org.rhq.helpers.perftest.support.jpa.Edge;
@@ -53,7 +45,15 @@ import org.rhq.helpers.perftest.support.jpa.mapping.EntityTranslation;
import org.rhq.helpers.perftest.support.jpa.mapping.RelationshipTranslation;
/**
- *
+ * This is an implementation of {@link ITableFilter} interface acts as a proxy
+ * between the {@link EntityDependencyGraph} and the dbUnit.
+ * <p>
+ * This filter is able to produce a table iterator that traverses the tables in the
+ * correct order so that foreign key constraints are obeyed during insertion of data.
+ * <p>
+ * It is also able to filter the data from the tables corresponding to the entities by only
+ * allowing entities (and the underlying table rows) of certain primary key values to be included.
+ *
* @author Lukas Krejci
*/
public class EntityRelationshipFilter extends DatabaseSequenceFilter {
@@ -72,6 +72,7 @@ public class EntityRelationshipFilter extends DatabaseSequenceFilter {
RESOLUTION_IN_CONSTRUCTOR.set(null);
}
+ @Override
public ITableIterator iterator(IDataSet dataSet, boolean reversed) throws DataSetException {
return new EntityRelationshipTableIterator(super.iterator(dataSet, reversed), resolvedPks);
}
@@ -453,30 +454,4 @@ public class EntityRelationshipFilter extends DatabaseSequenceFilter {
return ret;
}
-
- public static void main(String[] args) throws Exception {
- HashMap<Class<?>, Set<ColumnValues>> allowed = new HashMap<Class<?>, Set<ColumnValues>>();
- allowed.put(Class.forName("org.rhq.core.domain.resource.Resource"), ColumnValues.setOf(10001));
-
- Class.forName("org.postgresql.Driver");
- DatabaseConnection con = new DatabaseConnection(DriverManager.getConnection(
- "jdbc:postgresql://127.0.0.1:5432/rhqdev", "rhqadmin", "rhqadmin"));
-
-// EntityRelationshipFilter f = new EntityRelationshipFilter(con, allowed, new EagerMappingInclusionResolver());
-// System.out.println(f.edg);
-//
-// f.iterator(con.createDataSet(), false);
-
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
- + "<graph packagePrefix=\"org.rhq.core.domain\">\n"
- + " <entity name=\"resource.Resource\" includeAllDependents=\"true\" />\n" + "</graph>";
-
- JAXBContext c = ExportConfiguration.getJAXBContext();
- Unmarshaller um = c.createUnmarshaller();
- ExportConfiguration edg = (ExportConfiguration) um.unmarshal(new StringReader(xml));
-
- EntityRelationshipFilter f2 = new EntityRelationshipFilter(con, allowed,
- new ConfigurableDependencyInclusionResolver(edg));
- f2.iterator(con.createDataSet(), false);
- }
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipTableIterator.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipTableIterator.java
index 52433fa..b8f7d20 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipTableIterator.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/dbunit/EntityRelationshipTableIterator.java
@@ -20,7 +20,6 @@
package org.rhq.helpers.perftest.support.dbunit;
import java.util.ArrayList;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -33,7 +32,8 @@ import org.rhq.helpers.perftest.support.jpa.ColumnValues;
import org.rhq.helpers.perftest.support.jpa.mapping.ColumnValuesTableMap;
/**
- *
+ * This is a table iterator able to filter out rows with disallowed primary key values.
+ *
* @author Lukas Krejci
*/
public class EntityRelationshipTableIterator implements ITableIterator {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java
index fbf1c85..be3b083 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/CsvInput.java
@@ -27,7 +27,8 @@ import org.dbunit.dataset.stream.IDataSetProducer;
import org.rhq.helpers.perftest.support.Input;
/**
- *
+ * Implements the {@link Input} interface for the set of CSV files using the {@link CsvProducer}.
+ *
* @author Lukas Krejci
*/
public class CsvInput implements Input {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/XmlInput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/XmlInput.java
index a5367c3..992a80a 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/XmlInput.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/input/XmlInput.java
@@ -28,6 +28,7 @@ import org.rhq.helpers.perftest.support.Input;
import org.xml.sax.InputSource;
/**
+ * Implements the {@link Input} interface for the XML files using the {@link FlatXmlProducer}.
*
* @author Lukas Krejci
*/
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Annotations.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Annotations.java
index c23b86a..b191a85 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Annotations.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Annotations.java
@@ -23,7 +23,9 @@ import java.util.HashMap;
import java.util.Map;
/**
- *
+ * A minimal extension of {@link HashMap} with {@link Class} keys and Object values.
+ * Provides only a convenience {@link #get(Class)} method.
+ *
* @author Lukas Krejci
*/
public class Annotations extends HashMap<Class<?>, Object> {
@@ -46,8 +48,17 @@ public class Annotations extends HashMap<Class<?>, Object> {
super(m);
}
+ /**
+ * Returns the annotation of given class (if present in this map) cast
+ * to the class. This is a convenience method for the users of this class
+ * so that they don't have to cast the annotation object themselves.
+ *
+ * @param <T>
+ * @param annotationClass
+ * @return
+ */
public <T> T get(Class<T> annotationClass) {
- Object annotation = get((Object)annotationClass);
+ Object annotation = get((Object) annotationClass);
return annotationClass.cast(annotation);
}
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ColumnValues.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ColumnValues.java
index 0207f1e..beef0f5 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ColumnValues.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ColumnValues.java
@@ -28,12 +28,17 @@ import java.util.Map;
import java.util.Set;
/**
- * Represents a (composite) primary key of a table.
+ * Represents a number of columns along with their values.
*
* @author Lukas Krejci
*/
public class ColumnValues implements Iterable<ColumnValues.Column>, Cloneable {
+ /**
+ * Presents a single column-value pair.
+ *
+ * @author Lukas Krejci
+ */
public static class Column {
private String name;
private Object value;
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ConfigurableDependencyInclusionResolver.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ConfigurableDependencyInclusionResolver.java
index ea1181e..9d2341b 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ConfigurableDependencyInclusionResolver.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/ConfigurableDependencyInclusionResolver.java
@@ -26,17 +26,47 @@ import org.rhq.helpers.perftest.support.config.ExportConfiguration;
import org.rhq.helpers.perftest.support.config.Relationship;
/**
- *
+ * An implementation of {@link DependencyInclusionResolver} interface that can be configured
+ * to include/exclude relationships by being provided a dependency graph in the form of {@link ExportConfiguration} instance.
+ *
* @author Lukas Krejci
*/
public class ConfigurableDependencyInclusionResolver implements DependencyInclusionResolver {
private ExportConfiguration edg;
+ /**
+ * @param edg the dependency graph of allowed entities and relations among them.
+ */
public ConfigurableDependencyInclusionResolver(ExportConfiguration edg) {
this.edg = edg;
}
+ /**
+ * An edge (relationship) is considered valid based on the dependency graph provided in this instance's
+ * constructor.
+ * These are the naming conventions used in the rules below:
+ * <ul>
+ * <li>Source Entity is an {@link Entity} in the {@link ExportConfiguration configuration} that corresponds
+ * to the "from node" {@link Edge#getFrom()} of the provided edge of the full dependency graph.
+ * <li>Target Entity is the {@link Entity} corresponding to the {@link Edge#getTo()}.
+ * <li>Source relationship is the {@link Relationship} defined on the source entity that corresponds to the {@link Edge#getFromField()} (i.e. has the same name).
+ * <li>Target relationship is the {@link Relationship} on the target entity corresponding to the {@link Edge#getToField()}.
+ * </ul>
+ *
+ * <p>
+ * An edge is considered valid if at least one of the following conditions is true:
+ * <ul>
+ * <li>The configuration specifies to include all explicit dependent entities and the edge has a non-null {@link Edge#getFromField() from field} (i.e. the dependency is explicitly defined).
+ * <li>The source entity specifies to include all fields ({@link Entity#isIncludeAllFields()}).
+ * <li>The target entity specifies to include all fields ({@link Entity#isIncludeAllFields()}).
+ * <li>The source relationship is defined.
+ * <li>The target relationship is defined.
+ * </ul>
+ *
+ * @param edge the edge from the full entity dependency graph to check the validity of.
+ * @return true if valid (i.e. to be included in the output), false otherwise.
+ */
public boolean isValid(Edge edge) {
Entity from = edg.getEntity(edge.getFrom().getEntity());
Entity to = edg.getEntity(edge.getTo().getEntity());
@@ -74,7 +104,7 @@ public class ConfigurableDependencyInclusionResolver implements DependencyInclus
if (field == null) {
return false;
}
-
+
for (Relationship relationship : entity.getRelationships()) {
String fieldName = relationship.getField();
if (field.getName().equals(fieldName)) {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyInclusionResolver.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyInclusionResolver.java
index 7ef906b..ccb73f7 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyInclusionResolver.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyInclusionResolver.java
@@ -32,5 +32,9 @@ import org.rhq.helpers.perftest.support.dbunit.EntityRelationshipFilter;
*/
public interface DependencyInclusionResolver {
+ /**
+ * @param edge
+ * @return true if the edge should be traversed, false otherwise
+ */
boolean isValid(Edge edge);
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyType.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyType.java
index fc2e6bb..05a22a3 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyType.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/DependencyType.java
@@ -25,6 +25,12 @@ import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
+/**
+ * Names the possible JPA dependency types. {@link OneToMany} and {@link ManyToOne} are considered
+ * the same as they represent the opposite sides of a single relationship.
+ *
+ * @author Lukas Krejci
+ */
public enum DependencyType {
ONE_TO_ONE {
public Class<? extends Annotation> annotationType() {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EagerMappingInclusionResolver.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EagerMappingInclusionResolver.java
index f126ef5..51de596 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EagerMappingInclusionResolver.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EagerMappingInclusionResolver.java
@@ -27,7 +27,12 @@ import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
/**
- *
+ * A {@link DependencyInclusionResolver} implementation that consideres an edge valid
+ * if the JPA defines the fetch type as {@link FetchType#EAGER}.
+ * <p>
+ * Note that this is just an example implementation of the interface with no practical use because
+ * of the lack of flexibility of this simple rule.
+ *
* @author Lukas Krejci
*/
public class EagerMappingInclusionResolver implements DependencyInclusionResolver {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Edge.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Edge.java
index 598ac1b..3f13ee1 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Edge.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Edge.java
@@ -23,6 +23,11 @@ import java.lang.reflect.Field;
import org.rhq.helpers.perftest.support.jpa.mapping.RelationshipTranslation;
+/**
+ * Represents an edge in the {@link EntityDependencyGraph}.
+ *
+ * @author Lukas Krejci
+ */
public class Edge {
private Node from;
@@ -46,28 +51,28 @@ public class Edge {
}
/**
- * @return the from
+ * @return the node this edge comes from.
*/
public Node getFrom() {
return from;
}
/**
- * @return the to
+ * @return the node this edge goes to.
*/
public Node getTo() {
return to;
}
/**
- * @return the fromField
+ * @return the field on the "from node"'s class that this edge represents.
*/
public Field getFromField() {
return fromField;
}
/**
- * @return the toField
+ * @return the field on the "to node"'s class that this edge represents.
*/
public Field getToField() {
return toField;
@@ -80,6 +85,10 @@ public class Edge {
return dependencyType;
}
+ /**
+ * The translation of this edge to the terms of SQL table and column names.
+ * @return
+ */
public RelationshipTranslation getTranslation() {
return translation;
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EntityDependencyGraph.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EntityDependencyGraph.java
index 390c2db..73eef94 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EntityDependencyGraph.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/EntityDependencyGraph.java
@@ -44,7 +44,11 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.helpers.perftest.support.jpa.mapping.MappingTranslator;
/**
- *
+ * Produces a graph of {@link Node}s linked to each other by {@link Edge}s.
+ * Each {@link Node} corresponds to a single JPA entity and each {@link Edge} between them
+ * corresponds to a single relationship between the JPA entities (i.e. one of {@link OneToOne},
+ * {@link OneToMany}, {@link ManyToOne} or {@link ManyToMany}).
+ *
* @author Lukas Krejci
*/
public class EntityDependencyGraph {
@@ -54,6 +58,14 @@ public class EntityDependencyGraph {
Map<Node, Node> nodes = new HashMap<Node, Node>();
private MappingTranslator mappingTranslator = new MappingTranslator();
+ /**
+ * Adds a single entity to the dependency graph and analyzes it. This will cause
+ * all the dependent and depending entities to be included in the graph as well.
+ *
+ * @param entity
+ * @return the {@link Node} instance corresponding to the provided entity class or null
+ * if the class doesn't represent a JPA entity.
+ */
public Node addEntity(Class<?> entity) {
Node n = new Node(entity);
n = analyze(n);
@@ -63,10 +75,22 @@ public class EntityDependencyGraph {
return n;
}
+ /**
+ * A convenience method to add a number of entities to the graph at once.
+ *
+ * @param entities
+ * @return the set of nodes corresponding to the provided entities.
+ */
public Set<Node> addEntities(Class<?>... entities) {
return addEntities(Arrays.asList(entities));
}
+ /**
+ * A convenience method to add a number of entities to the graph at once.
+ *
+ * @param entities
+ * @return the set of nodes corresponding to the provided entities.
+ */
public Set<Node> addEntities(Collection<Class<?>> entities) {
Set<Node> ret = new HashSet<Node>();
for (Class<?> e : entities) {
@@ -78,14 +102,24 @@ public class EntityDependencyGraph {
return ret;
}
+ /**
+ * @return all the nodes in the dependency graph
+ */
public Set<Node> getAllNodes() {
return nodes.keySet();
}
+ /**
+ * @param entityClass the class of an entity
+ * @return the node from the dependency graph corresponding to the given class or null if such node is not present.
+ */
public Node getNode(Class<?> entityClass) {
return nodes.get(new Node(entityClass));
}
+ /**
+ * @return all the nodes from the dependency graph with no parents (i.e. with no edges leading to them).
+ */
public Set<Node> getRootNodes() {
Set<Node> ret = new HashSet<Node>();
@@ -97,6 +131,9 @@ public class EntityDependencyGraph {
return ret;
}
+ /**
+ * @return all the nodes from the dependency graph with no children (i.e. no edges leading from them).
+ */
public Set<Node> getLeafNodes() {
Set<Node> ret = new HashSet<Node>();
@@ -335,11 +372,4 @@ public class EntityDependencyGraph {
return (Class<?>) typeParameter;
}
}
-
- public static void main(String[] args) throws Exception {
- EntityDependencyGraph g = new EntityDependencyGraph();
- //g.addEntity(Class.forName("org.rhq.core.domain.configuration.Configuration"));
- g.addEntity(Class.forName("org.rhq.core.domain.resource.Resource"));
- System.out.println(g);
- }
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/JPAUtil.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/JPAUtil.java
index dcd4ab8..4226066 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/JPAUtil.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/JPAUtil.java
@@ -32,32 +32,56 @@ import java.util.Set;
import javax.persistence.Embedded;
import javax.persistence.Entity;
-
/**
- *
+ * A set of utility methods to work with JPA annotated classes.
+ *
* @author Lukas Krejci
*/
public class JPAUtil {
private JPAUtil() {
-
+
}
-
+
+ /**
+ * Returns true if the class is annotated with {@link Entity} annotation.
+ * @param clazz
+ * @return true if class is a JPA entity, false otherwise
+ */
public static boolean isEntity(Class<?> clazz) {
return clazz.getAnnotation(Entity.class) != null;
}
+ /**
+ * Returns all the JPA annotations declared on the class.
+ *
+ * @param clazz
+ * @return
+ */
public static Annotations getJPAAnnotations(Class<?> clazz) {
return extractJPAAnnotations(clazz.getAnnotations());
}
+ /**
+ * Returns all the JPA annotations declared on the field.
+ *
+ * @param field
+ * @return
+ */
public static Annotations getJPAAnnotations(Field field) {
return extractJPAAnnotations(field.getAnnotations());
}
-
+
+ /**
+ * Returns all the JPA annotated fields on given class along with their annotations.
+ * Note that this also returns all the JPA annotated fields declared in the super classes of the provided class.
+ *
+ * @param clazz
+ * @return
+ */
public static Map<Field, Annotations> getJPAFields(Class<?> clazz) {
HashMap<Field, Annotations> ret = new HashMap<Field, Annotations>();
-
+
for (Field f : getAllFields(clazz)) {
if (f.getAnnotation(Embedded.class) == null) {
ret.put(f, extractJPAAnnotations(f.getAnnotations()));
@@ -65,36 +89,44 @@ public class JPAUtil {
ret.putAll(getJPAFields(f.getType()));
}
}
-
+
return ret;
}
-
+
+ /**
+ * Returns all the fields of given class that have the desired annotation defined.
+ * This returns also the fields declared in the class' super classes.
+ *
+ * @param clazz
+ * @param desiredAnnotation
+ * @return
+ */
public static Set<Field> getJPAFields(Class<?> clazz, Class<? extends Annotation> desiredAnnotation) {
HashSet<Field> ret = new HashSet<Field>();
-
- for(Field f : getAllFields(clazz)) {
+
+ for (Field f : getAllFields(clazz)) {
if (f.getAnnotation(desiredAnnotation) != null) {
ret.add(f);
} else if (f.getAnnotation(Embedded.class) != null) {
ret.addAll(getJPAFields(f.getType(), desiredAnnotation));
}
}
-
+
return ret;
}
-
+
private static Annotations extractJPAAnnotations(Annotation[] annotations) {
Annotations ret = new Annotations();
-
+
for (Annotation annon : annotations) {
if (annon.annotationType().getPackage().getName().startsWith("javax.persistence")) {
ret.put(annon.annotationType(), annon);
}
}
-
+
return ret;
}
-
+
public static Field getField(Class<?> clazz, String name) {
while (clazz != null) {
Field f = null;
@@ -105,27 +137,28 @@ public class JPAUtil {
} catch (NoSuchFieldException e) {
//let's continue below
}
-
+
if (f != null) {
return f;
} else {
clazz = clazz.getSuperclass();
}
}
-
+
return null;
}
+
private static List<Field> getAllFields(Class<?> clazz) {
ArrayList<Field> fields = new ArrayList<Field>();
-
+
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
-
+
Class<?> superClass = clazz.getSuperclass();
-
+
if (superClass != null) {
fields.addAll(getAllFields(clazz.getSuperclass()));
}
-
+
return fields;
}
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Node.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Node.java
index d477d6f..55c01ba 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Node.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/Node.java
@@ -27,31 +27,52 @@ import java.util.TreeSet;
import org.rhq.helpers.perftest.support.jpa.mapping.EntityTranslation;
+/**
+ * Represents a node in the entity dependency graph.
+ *
+ * @author Lukas Krejci
+ */
public class Node implements Comparable<Node> {
-
+
private Class<?> entity;
-
+
private Set<Edge> edges;
-
+
private EntityTranslation translation;
-
+
public Node(Class<?> entity) {
this.entity = entity;
edges = new HashSet<Edge>();
}
+ /**
+ * The class of the JPA entity this node represents.
+ */
public Class<?> getEntity() {
return entity;
}
+ /**
+ * @return the translation of this entity to the SQL terms.
+ */
public EntityTranslation getTranslation() {
return translation;
}
-
+
public void setTranslation(EntityTranslation translation) {
this.translation = translation;
}
-
+
+ /**
+ * Add a parent node. This creates a new edge with the parent node
+ * set as the "from" node and this node as the "to" node. The edge instance is
+ * shared in both this' and parent's edge set.
+ *
+ * @param parent the parent node
+ * @param parentField the field on the parent node's entity that the edge is to be linked with
+ * @param thisField the field on this node's entity that the edge is to be linked with
+ * @param dependencyType the type of the JPA dependency
+ */
public void addParent(Node parent, Field parentField, Field thisField, DependencyType dependencyType) {
Edge edge = new Edge(parent, this, parentField, thisField, dependencyType);
@@ -60,6 +81,15 @@ public class Node implements Comparable<Node> {
}
}
+ /**
+ * Similar to {@link #addParent(Node, Field, Field, DependencyType)} but creates an edge
+ * with this node being the "from" and the child node being the "to" of the newly created edge.
+ *
+ * @param child
+ * @param childField
+ * @param thisField
+ * @param dependencyType
+ */
public void addChild(Node child, Field childField, Field thisField, DependencyType dependencyType) {
Edge edge = new Edge(this, child, thisField, childField, dependencyType);
@@ -67,120 +97,165 @@ public class Node implements Comparable<Node> {
child.addEdge(edge);
}
}
-
+
+ /**
+ * This method is called from {@link #addParent(Node, Field, Field, DependencyType)} and
+ * {@link #addChild(Node, Field, Field, DependencyType)} methods to actually store an instance
+ * of an edge in this instance's edge set.
+ *
+ * @param edge
+ */
protected void addEdge(Edge edge) {
edges.add(edge);
}
-
+
+ /**
+ * @return all the edges leading from or to this node.
+ */
public Set<Edge> getEdges() {
return edges;
}
+ /**
+ * @return the edges going out of this node (i.e. edges leading to children of this node)
+ */
public Set<Edge> getOutgoingEdges() {
Set<Edge> ret = new HashSet<Edge>();
- for(Edge e : edges) {
+ for (Edge e : edges) {
if (this == e.getFrom()) {
ret.add(e);
}
}
-
+
return ret;
}
-
+
+ /**
+ * @return the edges coming to this node (i.e. edges leading from parents of this node)
+ */
public Set<Edge> getIncomingEdges() {
Set<Edge> ret = new HashSet<Edge>();
- for(Edge e : edges) {
+ for (Edge e : edges) {
if (this == e.getTo()) {
ret.add(e);
}
}
-
+
return ret;
}
-
+
+ /**
+ * Return the parents of this node.
+ * When the <code>onlyExplicitRelations</code> is true, then only
+ * the edges that have and non-null {@link Edge#getFromField() "from" field} are considered.
+ * This means that only parents that explicitly link to this entity are considered.
+ * A null from field means that the relation was only defined on the "to" side and that
+ * the parent entity has no explicit knowledge of the relationship.
+ *
+ * @param onlyExplicitRelations
+ * @return
+ */
public SortedSet<Node> getParents(boolean onlyExplicitRelations) {
SortedSet<Node> ret = new TreeSet<Node>();
-
- for(Edge e : edges) {
+
+ for (Edge e : edges) {
//== *is* correct here
- if (e.getTo() == this && (onlyExplicitRelations ? e.getFromField() != null : true)) {
+ if (e.getTo() == this && (onlyExplicitRelations ? e.getFromField() != null : true)) {
ret.add(e.getFrom());
}
}
-
+
return ret;
}
-
+
+ /**
+ * Returns the children of this node.
+ * The <code>onlyExplicitRelations</code> argument has the same meaning as for the {@link #getParents(boolean)} method.
+ *
+ * @param onlyExplicitRelations
+ * @return
+ */
public SortedSet<Node> getChildren(boolean onlyExplicitRelations) {
SortedSet<Node> ret = new TreeSet<Node>();
-
- for(Edge e : edges) {
+
+ for (Edge e : edges) {
//== *is* correct here
if (e.getFrom() == this && (onlyExplicitRelations ? e.getToField() != null : true)) {
ret.add(e.getTo());
}
}
-
+
return ret;
}
-
+
+ /**
+ * Returns this node, its parents, their parents, etc, recursively up the dependency graph.
+ *
+ * @param onlyExplicitRelations the same meaning as for {@link #getParents(boolean)}
+ * @return
+ */
public SortedSet<Node> getTransitiveParents(boolean onlyExplicitRelations) {
SortedSet<Node> ret = new TreeSet<Node>();
-
+
ret.add(this);
-
+
Set<Node> currentParents = getParents(onlyExplicitRelations);
-
+
while (!currentParents.isEmpty()) {
Set<Node> parentsCopy = new HashSet<Node>(currentParents);
-
+
if (!ret.addAll(currentParents)) {
//if the returned set already contained all the current parents,
//then we're inside a cycle and there's no need to continue.
break;
}
-
+
currentParents.clear();
-
+
for (Node p : parentsCopy) {
currentParents.addAll(p.getParents(onlyExplicitRelations));
}
}
-
+
return ret;
}
-
+
+ /**
+ * Returns this node, its children, their children, etc. recursively.
+ *
+ * @param onlyExplicitRelations the same meaning as for {@link #getParents(boolean)}
+ * @return
+ */
public SortedSet<Node> getTransitiveChildren(boolean onlyExplicitRelations) {
SortedSet<Node> ret = new TreeSet<Node>();
-
+
ret.add(this);
-
+
Set<Node> currentChildren = getChildren(onlyExplicitRelations);
-
+
while (!currentChildren.isEmpty()) {
Set<Node> childrenCopy = new HashSet<Node>(currentChildren);
-
+
if (!ret.addAll(currentChildren)) {
//if the returned set already contained all the current children,
//then we're inside a cycle and there's no need to continue.
break;
}
-
+
currentChildren.clear();
-
+
for (Node c : childrenCopy) {
currentChildren.addAll(c.getChildren(onlyExplicitRelations));
}
}
-
+
return ret;
}
-
+
public int hashCode() {
return entity.hashCode();
}
- @SuppressWarnings("unchecked")
@Override
public boolean equals(Object other) {
if (!(other instanceof Node)) {
@@ -189,33 +264,35 @@ public class Node implements Comparable<Node> {
return entity.equals(((Node) other).getEntity());
}
-
+
public int compareTo(Node o) {
return entity.getName().compareTo(o.entity.getName());
}
-
+
public String toString() {
StringBuilder bld = new StringBuilder();
-
+
bld.append(entity.getSimpleName()).append("[\n");
bld.append("attachment=").append(translation).append("\n");
- for(Edge e : edges) {
+ for (Edge e : edges) {
String fromField = e.getFromField() != null ? e.getFromField().getName() : "?";
String toField = e.getToField() != null ? e.getToField().getName() : "?";
-
+
if (e.getFrom() == this) {
bld.append("(").append(fromField);
- bld.append(") -").append(e.getDependencyType()).append("> ").append(e.getTo().getEntity().getSimpleName());
+ bld.append(") -").append(e.getDependencyType()).append("> ")
+ .append(e.getTo().getEntity().getSimpleName());
bld.append("(").append(toField).append(")");
} else {
bld.append("(").append(toField);
- bld.append(") <").append(e.getDependencyType()).append("- ").append(e.getFrom().getEntity().getSimpleName());
+ bld.append(") <").append(e.getDependencyType()).append("- ")
+ .append(e.getFrom().getEntity().getSimpleName());
bld.append("(").append(fromField).append(")");
}
bld.append("\n").append("(attachment=").append(e.getTranslation()).append(")\n");
}
bld.append("]");
-
+
return bld.toString();
}
-}
\ No newline at end of file
+}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/mapping/ColumnValuesTableMap.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/mapping/ColumnValuesTableMap.java
index dbfc5f9..7d6dd1a 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/mapping/ColumnValuesTableMap.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/jpa/mapping/ColumnValuesTableMap.java
@@ -26,20 +26,31 @@ import java.util.Set;
import org.rhq.helpers.perftest.support.jpa.ColumnValues;
/**
- *
+ * Represents a map where keys are names of database tables and values are sets of column values ({@link ColumnValues} instances).
+ *
+ * Adds {@link #getOrCreate(Object)} method to safely retrieve initialized values even for previously non-existent keys.
+ *
* @author Lukas Krejci
*/
public class ColumnValuesTableMap extends HashMap<String, Set<ColumnValues>> {
private static final long serialVersionUID = 1L;
+ /**
+ * Retrieves a set of column values for given table name.
+ * If there was no entry for the table name in this map, a new
+ * empty set is created, added to the map and returned.
+ *
+ * @param key the name of the table
+ * @return a set of column values
+ */
public Set<ColumnValues> getOrCreate(Object key) {
Set<ColumnValues> ret = super.get(key);
if (ret == null) {
ret = new LinkedHashSet<ColumnValues>();
- put((String)key, ret);
+ put((String) key, ret);
}
-
+
return ret;
}
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java
index dab03a4..6230ffc 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/CsvOutput.java
@@ -27,23 +27,24 @@ import org.dbunit.dataset.stream.IDataSetConsumer;
import org.rhq.helpers.perftest.support.Output;
/**
- *
+ * Implements the {@link Output} interface to support output to a set of CSV files using {@link CsvDataSetWriter}.
+ *
* @author Lukas Krejci
*/
public class CsvOutput implements Output {
private File directory;
private CsvDataSetWriter consumer;
-
+
public CsvOutput(File directory) {
this.directory = directory;
}
-
+
public IDataSetConsumer getConsumer() throws Exception {
if (consumer == null) {
consumer = new CsvDataSetWriter(directory);
}
-
+
return consumer;
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java
index deafa65..2ec8de0 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/output/XmlOutput.java
@@ -27,7 +27,9 @@ import org.dbunit.dataset.xml.FlatXmlWriter;
import org.rhq.helpers.perftest.support.Output;
/**
- *
+ * Implements the {@link Output} interface to ouput the database data into an XML file using
+ * {@link FlatXmlWriter}.
+ *
* @author Lukas Krejci
*/
public class XmlOutput implements Output {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/ConnectionProviderMethod.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/ConnectionProviderMethod.java
index a70ebdc..f453598 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/ConnectionProviderMethod.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/ConnectionProviderMethod.java
@@ -23,9 +23,12 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import java.sql.Connection;
/**
- *
+ * Specifies the method on the annotated class that can provide JDBC connections to the caller.
+ * The method must accept no arguments and return a {@link Connection} instance.
+ *
* @author Lukas Krejci
*/
@Retention(RetentionPolicy.RUNTIME)
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
index 850fc0f..2f8ff3f 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
@@ -37,7 +37,13 @@ import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;
/**
- *
+ * An {@link IInvokedMethodListener method listener} that performs the database setup
+ * for appropriately annotated test methods.
+ * To add database setup support to a test class, annotate the class with
+ * <code>
+ * @Listeners({org.rhq.helpers.perftest.support.testng.DatabaseSetupInterceptor.class})
+ * </code>
+ *
* @author Lukas Krejci
*/
public class DatabaseSetupInterceptor implements IInvokedMethodListener {
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
index afb0580..aaa216b 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
@@ -25,16 +25,28 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- *
+ * An annotation to associate a test method with a required state of the database.
+ *
* @author Lukas Krejci
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.METHOD })
public @interface DatabaseState {
+ /**
+ * The location of the database state export file.
+ */
String url();
-
+
+ /**
+ * Where is the export file accessible from (defaults to {@link DatabaseStateStorage#CLASSLOADER}).
+ */
DatabaseStateStorage storage() default DatabaseStateStorage.CLASSLOADER;
+ /**
+ * The name of the method to provide a JDBC connection object.
+ * If the method is not specified, the value of the {@link ConnectionProviderMethod} annotation
+ * is used.
+ */
String connectionProviderMethod() default "";
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseStateStorage.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseStateStorage.java
index bff3977..4ab2522 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseStateStorage.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseStateStorage.java
@@ -20,9 +20,18 @@
package org.rhq.helpers.perftest.support.testng;
/**
- *
+ * Specifies where is the database state export file locatable from.
+ *
* @author Lukas Krejci
*/
public enum DatabaseStateStorage {
- FILESYSTEM, CLASSLOADER
+ /**
+ * The export file is to be found in the file system.
+ */
+ FILESYSTEM,
+
+ /**
+ * The export file is to be found in the classloader resources.
+ */
+ CLASSLOADER
}
13 years, 9 months