[rhq] 6 commits - modules/core modules/enterprise
by Simeon Pinder
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 58 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java | 102 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java | 304 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java | 53 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java | 49 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java | 43 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 47 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java | 304 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java | 221 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java | 172 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java | 177 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java | 318 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java | 151 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java | 274 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java | 170 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java | 4
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 13
23 files changed, 2375 insertions(+), 164 deletions(-)
New commits:
commit 67f853ac9856444ff79ee79815256a76e80fdae5
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 17 09:06:37 2011 -0400
i)enable Resource* Activity portlets
ii)ImageManager broken image fix
iii)exclude portlets from list that are already being display. Still need to refresh for add/delete.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index 1e93fd7..43f0f69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -321,7 +321,7 @@ public class ImageManager {
}
public static String getAlertIcon() {
- return "subsystems/alert/Alert_16.png";
+ return "subsystems/alert/Alert_LOW_16.png";
}
public static String getAlertLargeIcon() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index fb17b55..384895d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -261,6 +261,13 @@ public class DashboardView extends LocatableVLayout {
//if resource passed in then add additional portlets to list
if (this.focusResource != null) {
HashMap<String, String> resourceKeyNameMap = PortletFactory.getRegisteredResourcePortletNameMap();
+ //find current list of portlets already stored. Exclude them
+ for (DashboardPortlet currentPortlet : storedDashboard.getPortlets()) {
+ if (resourceKeyNameMap.containsKey(currentPortlet.getPortletKey())) {
+ resourceKeyNameMap.remove(currentPortlet.getPortletKey());
+ }
+ }
+
for (String portletKey : resourceKeyNameMap.keySet()) {
nameKeyMap.put(resourceKeyNameMap.get(portletKey), portletKey);
}
@@ -379,6 +386,7 @@ public class DashboardView extends LocatableVLayout {
}
updateRefreshMenu();
this.refreshMenuButton.markForRedraw();
+ markForRedraw();
return editForm;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 3a15b44..aa63d77 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -24,7 +24,6 @@ import java.util.List;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
@@ -40,6 +39,13 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.Re
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceBundleDeploymentsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceEventsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOobsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourcePkgHistoryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.TagCloudPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MashupPortlet;
@@ -98,7 +104,7 @@ public class PortletFactory {
//############## Group Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
registeredGroupPortletFactoryMap = new HashMap<String, PortletViewFactory>();
- registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
+ // registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
@@ -110,7 +116,7 @@ public class PortletFactory {
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
- registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
+ // registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.NAME);
registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
@@ -122,21 +128,46 @@ public class PortletFactory {
//############## Resource Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
registeredResourcePortletFactoryMap = new HashMap<String, PortletViewFactory>();
+ registeredResourcePortletFactoryMap.put(ResourceMetricsPortlet.KEY, ResourceMetricsPortlet.Factory.INSTANCE);
+ registeredResourcePortletFactoryMap.put(ResourceEventsPortlet.KEY, ResourceEventsPortlet.Factory.INSTANCE);
+ registeredResourcePortletFactoryMap.put(ResourceOobsPortlet.KEY, ResourceOobsPortlet.Factory.INSTANCE);
+ registeredResourcePortletFactoryMap.put(ResourceAlertsPortlet.KEY, ResourceAlertsPortlet.Factory.INSTANCE);
+ registeredResourcePortletFactoryMap.put(ResourceOperationsPortlet.KEY,
+ ResourceOperationsPortlet.Factory.INSTANCE);
+ registeredResourcePortletFactoryMap.put(ResourcePkgHistoryPortlet.KEY,
+ ResourcePkgHistoryPortlet.Factory.INSTANCE);
+ registeredResourcePortletFactoryMap.put(ResourceBundleDeploymentsPortlet.KEY,
+ ResourceBundleDeploymentsPortlet.Factory.INSTANCE);
//register resource portlet names
registeredResourcePortletNameMap = new HashMap<String, String>(registeredResourcePortletFactoryMap.size());
+ registeredResourcePortletNameMap.put(ResourceMetricsPortlet.KEY, ResourceMetricsPortlet.NAME);
+ registeredResourcePortletNameMap.put(ResourceEventsPortlet.KEY, ResourceEventsPortlet.NAME);
+ registeredResourcePortletNameMap.put(ResourceOobsPortlet.KEY, ResourceOobsPortlet.NAME);
+ registeredResourcePortletNameMap.put(ResourceOperationsPortlet.KEY, ResourceOperationsPortlet.NAME);
+ registeredResourcePortletNameMap.put(ResourcePkgHistoryPortlet.KEY, ResourcePkgHistoryPortlet.NAME);
+ registeredResourcePortletNameMap.put(ResourceAlertsPortlet.KEY, ResourceAlertsPortlet.NAME);
+ registeredResourcePortletNameMap.put(ResourceBundleDeploymentsPortlet.KEY,
+ ResourceBundleDeploymentsPortlet.NAME);
//############## Portlet icon mappings ############################################
//register portlet names
registeredPortletIconMap = new HashMap<String, String>(registeredPortletFactoryMap.size());
- registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertLargeIcon());
- registeredPortletIconMap.put(GroupAlertsPortlet2.KEY, ImageManager.getAlertLargeIcon());
- registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorLargeIcon());
- registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedLargeIcon());
- registeredPortletIconMap.put(GroupEventsPortlet.KEY, ImageManager.getEventLargeIcon());
- registeredPortletIconMap.put(GroupOperationsPortlet.KEY, ImageManager.getOperationLargeIcon());
- registeredPortletIconMap.put(GroupPkgHistoryPortlet.KEY, ImageManager.getActivityPackageLargeIcon());
- registeredPortletIconMap.put(GroupBundleDeploymentsPortlet.KEY, ImageManager.getBundleLargeIcon());
+ // registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertIcon());
+ registeredPortletIconMap.put(GroupAlertsPortlet2.KEY, ImageManager.getAlertIcon());
+ registeredPortletIconMap.put(ResourceAlertsPortlet.KEY, ImageManager.getAlertIcon());
+ registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorIcon());
+ registeredPortletIconMap.put(ResourceMetricsPortlet.KEY, ImageManager.getMonitorIcon());
+ registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedIcon());
+ registeredPortletIconMap.put(ResourceOobsPortlet.KEY, ImageManager.getMonitorFailedIcon());
+ registeredPortletIconMap.put(GroupEventsPortlet.KEY, ImageManager.getEventIcon());
+ registeredPortletIconMap.put(ResourceEventsPortlet.KEY, ImageManager.getEventIcon());
+ registeredPortletIconMap.put(GroupOperationsPortlet.KEY, ImageManager.getOperationIcon());
+ registeredPortletIconMap.put(ResourceOperationsPortlet.KEY, ImageManager.getOperationIcon());
+ registeredPortletIconMap.put(GroupPkgHistoryPortlet.KEY, ImageManager.getActivityPackageIcon());
+ registeredPortletIconMap.put(ResourcePkgHistoryPortlet.KEY, ImageManager.getActivityPackageIcon());
+ registeredPortletIconMap.put(GroupBundleDeploymentsPortlet.KEY, ImageManager.getBundleIcon());
+ registeredPortletIconMap.put(ResourceBundleDeploymentsPortlet.KEY, ImageManager.getBundleIcon());
}
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
index 30a7350..565b46b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
@@ -67,10 +67,9 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet {
// A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupAlerts2";
+ public static final String KEY = "GroupAlerts";
// A default displayed, persisted name for the portlet
- // public static final String NAME = MSG.view_portlet_defaultName_recentAlerts();
- public static final String NAME = MSG.view_portlet_defaultName_group_alerts() + "2";
+ public static final String NAME = MSG.view_portlet_defaultName_group_alerts();
public static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value";
public static final String ALERT_RANGE_RESOURCE_IDS = "alert-range-resource-ids";
@@ -80,20 +79,28 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
public static final String ID = "id";
// set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
+ protected PortletWindow portletWindow;
//shared private UI elements
- private AlertResourceSelectorRegion resourceSelector;
+ protected AlertResourceSelectorRegion resourceSelector;
- private AlertPortletConfigurationDataSource dataSource;
+ protected AlertPortletConfigurationDataSource dataSource;
//instance ui widgets
- private Canvas containerCanvas;
+ protected Canvas containerCanvas;
- private Timer refreshTimer;
- private DashboardPortlet storedPortlet;
- private Configuration portletConfig;
+ protected Timer refreshTimer;
+ protected DashboardPortlet storedPortlet;
+ protected Configuration portletConfig;
private int groupId;
- private boolean portletConfigInitialized = false;
+ protected boolean portletConfigInitialized = false;
+
+ protected static HashMap<String, String> updatedMapping = new HashMap<String, String>();
+ static {
+ updatedMapping.putAll(PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION);
+ //Key, default
+ updatedMapping.put(ALERT_RANGE_RESOURCES_VALUE, RESOURCES_ALL);
+ updatedMapping.put(ALERT_RANGE_RESOURCE_IDS, RESOURCES_ALL);
+ }
public GroupAlertsPortlet2(String locatorId) {
super(locatorId);
@@ -102,28 +109,24 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
//figure out which page we're loading
String currentPage = History.getToken();
String[] elements = currentPage.split("/");
- int currentGroupIdentifier = Integer.valueOf(elements[1]);
- this.groupId = currentGroupIdentifier;
+ this.groupId = Integer.valueOf(elements[1]);
+
+ setShowFilterForm(false); //disable filter form for portlet
+ setOverflow(Overflow.VISIBLE);
+ }
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
//initalize the datasource
- this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, currentGroupIdentifier,
- null);
+ this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, this.groupId, null);
setDataSource(this.dataSource);
setShowHeader(false);
setShowFooter(true);
setShowFooterRefresh(false); //disable footer refresh
- setShowFilterForm(false); //disable filter form for portlet
-
- setOverflow(Overflow.VISIBLE);
- }
- private static HashMap<String, String> updatedMapping = new HashMap<String, String>();
- static {
- updatedMapping.putAll(PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION);
- //Key, default
- updatedMapping.put(ALERT_RANGE_RESOURCES_VALUE, RESOURCES_ALL);
- updatedMapping.put(ALERT_RANGE_RESOURCE_IDS, RESOURCES_ALL);
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
}
/** Responsible for initialization and lazy configuration of the portlet values
@@ -335,7 +338,8 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
@Override
protected void onInit() {
super.onInit();
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ initializeUi();
+ // getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
}
@Override
@@ -352,7 +356,8 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
/** Bundles a ResourceSelector instance with labeling in Canvas for display.
* Also modifies the AssignedGrid to listen for AvailbleGrid completion and act accordingly.
*/
-class AlertResourceSelectorRegion extends LocatableVLayout {
+//class AlertResourceSelectorRegion extends LocatableVLayout {
+final class AlertResourceSelectorRegion extends LocatableVLayout {
public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) {
super(locatorId);
this.currentlyAssignedIds = assigned;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java
index 6198529..4f50f15 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java
@@ -70,9 +70,26 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C
private int groupId = -1;
protected LocatableCanvas recentBundleDeployContent = new LocatableCanvas(
extendLocatorId("RecentBundleDeployments"));
- private boolean currentlyLoading = false;
- private Configuration portletConfig = null;
- private DashboardPortlet storedPortlet;
+ protected boolean currentlyLoading = false;
+ protected Configuration portletConfig = null;
+ protected DashboardPortlet storedPortlet;
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupBundleDeployments";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_bundles();
+ protected static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ protected PortletWindow portletWindow;
+ //instance ui widgets
+
+ protected Timer refreshTimer;
+
+ protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
+ }
public GroupBundleDeploymentsPortlet(String locatorId) {
super(locatorId);
@@ -81,12 +98,12 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C
String[] elements = currentPage.split("/");
int currentGroupIdentifier = Integer.valueOf(elements[1]);
this.groupId = currentGroupIdentifier;
- initializeUi();
}
@Override
protected void onInit() {
super.onInit();
+ initializeUi();
loadData();
}
@@ -98,23 +115,6 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C
addMember(recentBundleDeployContent);
}
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupBundleDeployments";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_group_bundles();
- public static final String ID = "id";
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
- //instance ui widgets
-
- private Timer refreshTimer;
-
- private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
- static {
- CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
- }
-
/** Responsible for initialization and lazy configuration of the portlet values
*/
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
index 877dbf4..636a844 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
@@ -63,11 +63,34 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class GroupEventsPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupEvents";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_events();
+
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ protected PortletWindow portletWindow;
+ //instance ui widgets
+
+ protected Timer refreshTimer;
+
+ protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_ENABLE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_LASTN);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_UNIT);
+ }
+
private int groupId = -1;
protected LocatableCanvas recentEventsContent = new LocatableCanvas(extendLocatorId("RecentEvents"));
- private boolean currentlyLoading = false;
- private Configuration portletConfig = null;
- private DashboardPortlet storedPortlet;
+ protected boolean currentlyLoading = false;
+ protected Configuration portletConfig = null;
+ protected DashboardPortlet storedPortlet;
public GroupEventsPortlet(String locatorId) {
super(locatorId);
@@ -76,12 +99,12 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
String[] elements = currentPage.split("/");
int currentGroupIdentifier = Integer.valueOf(elements[1]);
this.groupId = currentGroupIdentifier;
- initializeUi();
}
@Override
protected void onInit() {
super.onInit();
+ initializeUi();
loadData();
}
@@ -93,28 +116,6 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
addMember(recentEventsContent);
}
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupEvents";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_group_events();
- public static final String ID = "id";
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
- //instance ui widgets
-
- private Timer refreshTimer;
-
- private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
- static {
- CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
- CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
- CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG);
- CONFIG_INCLUDE.add(Constant.METRIC_RANGE_ENABLE);
- CONFIG_INCLUDE.add(Constant.METRIC_RANGE_LASTN);
- CONFIG_INCLUDE.add(Constant.METRIC_RANGE_UNIT);
- }
-
/** Responsible for initialization and lazy configuration of the portlet values
*/
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
index fa78591..80bf045 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
@@ -79,15 +79,27 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
private int groupId = -1;
protected LocatableCanvas recentMeasurementsContent = new LocatableCanvas(extendLocatorId("RecentMetrics"));
- private boolean currentlyLoading = false;
- private Configuration portletConfig = null;
- private DashboardPortlet storedPortlet;
- private String baseViewPath = "";
- private long start = -1;
- private long end = -1;
+ protected boolean currentlyLoading = false;
+ protected Configuration portletConfig = null;
+ protected DashboardPortlet storedPortlet;
+ protected String baseViewPath = "";
+ protected long start = -1;
+ protected long end = -1;
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupMetrics";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_metrics();
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ protected PortletWindow portletWindow;
+ //instance ui widgets
+
+ protected Timer refreshTimer;
//defines the list of configuration elements to load/persist for this portlet
- private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
static {
CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG);
@@ -104,12 +116,12 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
int currentGroupIdentifier = Integer.valueOf(elements[1]);
this.groupId = currentGroupIdentifier;
baseViewPath = elements[0];
- initializeUi();
}
@Override
protected void onInit() {
super.onInit();
+ initializeUi();
loadData();
}
@@ -121,18 +133,6 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
addMember(recentMeasurementsContent);
}
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupMetrics";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_group_metrics();
- public static final String ID = "id";
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
- //instance ui widgets
-
- private Timer refreshTimer;
-
/** Responsible for initialization and lazy configuration of the portlet values
*/
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
index 40a6128..206be22 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
@@ -62,11 +62,29 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class GroupOobsPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupOobs";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_oobs();
+ public static final String ID = "id";
+
private int groupId = -1;
protected LocatableCanvas recentOobContent = new LocatableCanvas(extendLocatorId("RecentOobs"));
- private boolean currentlyLoading = false;
- private Configuration portletConfig = null;
- private DashboardPortlet storedPortlet;
+ protected boolean currentlyLoading = false;
+ protected Configuration portletConfig = null;
+ protected DashboardPortlet storedPortlet;
+
+ // set on initial configuration, the window for this portlet view.
+ protected PortletWindow portletWindow;
+ //instance ui widgets
+
+ protected Timer refreshTimer;
+
+ //defines the list of configuration elements to load/persist for this portlet
+ protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
+ }
public GroupOobsPortlet(String locatorId) {
super(locatorId);
@@ -75,12 +93,12 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
String[] elements = currentPage.split("/");
int currentGroupIdentifier = Integer.valueOf(elements[1]);
this.groupId = currentGroupIdentifier;
- initializeUi();
}
@Override
protected void onInit() {
super.onInit();
+ initializeUi();
loadData();
}
@@ -92,24 +110,6 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
addMember(recentOobContent);
}
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupOobs";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_group_oobs();
- public static final String ID = "id";
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
- //instance ui widgets
-
- private Timer refreshTimer;
-
- //defines the list of configuration elements to load/persist for this portlet
- private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
- static {
- CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
- }
-
/** Responsible for initialization and lazy configuration of the portlet values
*/
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index ce30557..0a7bc76 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -79,15 +79,15 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
// A default displayed, persisted name for the portlet
public static final String NAME = MSG.view_portlet_defaultName_group_operations();
- public static final String ID = "id";
+ protected static final String ID = "id";
// set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
+ protected PortletWindow portletWindow;
- private GroupOperationsCriteriaHistoryListView dataSource;
+ protected GroupOperationsCriteriaHistoryListView dataSource;
//defines the list of configuration elements to load/persist for this portlet
- private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
static {
CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG);
@@ -101,17 +101,17 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
}
//instance ui widgets
- private Canvas containerCanvas;
+ protected Canvas containerCanvas;
- private Timer refreshTimer;
- private DashboardPortlet storedPortlet;
- private Configuration portletConfig;
- private int groupId;
- private boolean portletConfigInitialized = false;
+ protected Timer refreshTimer;
+ protected DashboardPortlet storedPortlet;
+ protected Configuration portletConfig;
+ protected int groupId;
+ protected boolean portletConfigInitialized = false;
private ResourceGroupComposite groupComposite;
- private String baseViewPath = "";
+ protected String baseViewPath = "";
protected LocatableCanvas recentOperationsContent = new LocatableCanvas(extendLocatorId("RecentOperations"));
- private String locatorId;
+ protected String locatorId;
private GroupOperationsCriteriaHistoryListView groupOperations;
public GroupOperationsPortlet(String locatorId) {
@@ -124,13 +124,12 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
this.groupId = currentGroupIdentifier;
//populate basepath
baseViewPath = elements[0];
-
- initializeUi();
}
@Override
protected void onInit() {
super.onInit();
+ initializeUi();
loadData();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java
index f93d418..b7dbf69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java
@@ -65,11 +65,29 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupPackageHistory";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_pkg_hisory();
+
private int groupId = -1;
protected LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(extendLocatorId("RecentPkgHistory"));
- private boolean currentlyLoading = false;
- private Configuration portletConfig = null;
- private DashboardPortlet storedPortlet;
+ protected boolean currentlyLoading = false;
+ protected Configuration portletConfig = null;
+ protected DashboardPortlet storedPortlet;
+
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ protected PortletWindow portletWindow;
+ //instance ui widgets
+
+ protected Timer refreshTimer;
+
+ protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
+ }
public GroupPkgHistoryPortlet(String locatorId) {
super(locatorId);
@@ -78,12 +96,12 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe
String[] elements = currentPage.split("/");
int currentGroupIdentifier = Integer.valueOf(elements[1]);
this.groupId = currentGroupIdentifier;
- initializeUi();
}
@Override
protected void onInit() {
super.onInit();
+ initializeUi();
loadData();
}
@@ -95,23 +113,6 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe
addMember(recentPkgHistoryContent);
}
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupPackageHistory";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_group_pkg_hisory();
- public static final String ID = "id";
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
- //instance ui widgets
-
- private Timer refreshTimer;
-
- private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
- static {
- CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
- }
-
/** Responsible for initialization and lazy configuration of the portlet values
*/
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java
new file mode 100644
index 0000000..53ba926
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java
@@ -0,0 +1,221 @@
+/*
+ * 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.dashboard.portlets.resource;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.Messages;
+import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource;
+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.dashboard.portlets.PortletConfigurationEditorComponent;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Simeon Pinder
+ */
+public class ResourceAlertsPortlet extends GroupAlertsPortlet2 {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceAlerts";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resource_alerts();
+
+ private int resourceId;
+
+ public ResourceAlertsPortlet(String locatorId) {
+ super(locatorId);
+
+ //override the shared datasource
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ this.resourceId = Integer.valueOf(elements[1]);
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ //initalize the datasource
+ Integer[] resourceIds = new Integer[1];
+ resourceIds[0] = this.resourceId;
+ this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, null, resourceIds);
+ setDataSource(this.dataSource);
+
+ setShowHeader(false);
+ setShowFooter(true);
+ setShowFooterRefresh(false); //disable footer refresh
+ setShowFilterForm(false); //disable filter form for portlet
+
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ }
+
+ /** Responsible for initialization and lazy configuration of the portlet values
+ */
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ //populate portlet configuration details
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+ this.storedPortlet = storedPortlet;
+ portletConfig = storedPortlet.getConfiguration();
+
+ if (!portletConfigInitialized) {
+ Integer[] resourceIds = new Integer[1];
+ resourceIds[0] = this.resourceId;
+ this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, null, resourceIds);
+ setDataSource(this.dataSource);
+ portletConfigInitialized = true;
+ }
+
+ //lazy init any elements not yet configured.
+ for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if (portletConfig.getSimple(key) == null) {
+ portletConfig.put(new PropertySimple(key,
+ PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
+ }
+ }
+
+ //resource ids to be conditionally included in the query
+ Integer[] filterResourceIds = null;
+ filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, filterResourceIds);
+ //no defaults
+
+ if (filterResourceIds != null) {
+ getDataSource().setAlertFilterResourceId(filterResourceIds);
+ }
+
+ // //conditionally display the selected resources ui
+ // if (containerCanvas != null) {
+ // //empty out earlier canvas
+ // for (Canvas c : containerCanvas.getChildren()) {
+ // c.destroy();
+ // }
+ // if ((resourceSelector != null) && getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) {
+ // containerCanvas.addChild(resourceSelector.getCanvas());
+ // } else {
+ // containerCanvas.addChild(new Canvas());
+ // }
+ // }
+
+ }
+
+ public AlertPortletConfigurationDataSource getDataSource() {
+ return dataSource;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new ResourceAlertsPortlet(locatorId);
+ }
+ }
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ Integer recordId = getId(selectedRows[0]);
+ Integer resourceId = selectedRows[0].getAttributeAsInt("resourceId");
+ CoreGUI.goToView(LinkManager.getSubsystemAlertHistoryLink(resourceId, recordId));
+ }
+ }
+ });
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ }
+ }
+}
+
+/** Bundles a ResourceSelector instance with labeling in Canvas for display.
+ * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act accordingly.
+ */
+class AlertResourceSelectorRegion extends LocatableVLayout {
+ public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) {
+ super(locatorId);
+ this.currentlyAssignedIds = assigned;
+ }
+
+ private static final Messages MSG = CoreGUI.getMessages();
+ private PortletAlertSelector selector = null;
+
+ private Integer[] currentlyAssignedIds;
+
+ public Integer[] getCurrentlyAssignedIds() {
+ return currentlyAssignedIds;
+ }
+
+ public Integer[] getListGridValues() {
+ Integer[] listGridValues = new Integer[0];
+ if (null != selector) {
+ listGridValues = selector.getAssignedListGridValues();
+ }
+ return listGridValues;
+ }
+
+ public Canvas getCanvas() {
+ if (selector == null) {
+ selector = new PortletAlertSelector(extendLocatorId("AlertSelector"), this.currentlyAssignedIds,
+ ResourceType.ANY_PLATFORM_TYPE, false);
+ }
+ return selector;
+ }
+
+ public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) {
+ this.currentlyAssignedIds = currentlyAssignedIds;
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
new file mode 100644
index 0000000..3ce4561
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
@@ -0,0 +1,172 @@
+/*
+ * 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.dashboard.portlets.resource;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceBundleDeploymentCriteria;
+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.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**This portlet allows the end user to customize the Bundle Deployment display
+ *
+ * @author Simeon Pinder
+ */
+public class ResourceBundleDeploymentsPortlet extends GroupBundleDeploymentsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceBundleDeployments";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resource_bundles();
+
+ private int resourceId = -1;
+
+ public ResourceBundleDeploymentsPortlet(String locatorId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentResourceIdentifier = Integer.valueOf(elements[1]);
+ this.resourceId = currentResourceIdentifier;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ loadData();
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentBundleDeployContent);
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new ResourceBundleDeploymentsPortlet(locatorId);
+ }
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentBundleDeployments();
+ }
+
+ /** Fetches recent bundle deployment information and updates the DynamicForm instance with details.
+ */
+ protected void getRecentBundleDeployments() {
+ final int resourceId = this.resourceId;
+ ResourceBundleDeploymentCriteria criteria = new ResourceBundleDeploymentCriteria();
+
+ int resultCount = 5;//default to
+ //result count
+ PropertySimple property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ resultCount = 5;
+ } else {
+ resultCount = Integer.valueOf(currentSetting);
+ }
+ }
+ PageControl pageControl = new PageControl(0, resultCount);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceIds(resourceId);
+ criteria.addSortStatus(PageOrdering.DESC);
+ criteria.fetchDestination(true);
+ criteria.fetchBundleVersion(true);
+ criteria.fetchResourceDeployments(true);
+
+ GWTServiceLookup.getBundleService().findBundleDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDeployment>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed bundle deployments for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<BundleDeployment> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (BundleDeployment deployment : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentBundleDeployContent
+ .extendLocatorId(deployment.getBundleVersion().getName()
+ + deployment.getBundleVersion().getVersion()));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(
+ "subsystems/content/Content_16.png", null);
+ String title = deployment.getBundleVersion().getName() + "["
+ + deployment.getBundleVersion().getVersion() + "]:";
+ String destination = ReportDecorator.GWT_BUNDLE_URL
+ + deployment.getBundleVersion().getBundle().getId() + "/destinations/"
+ + deployment.getDestination().getId();
+ LinkItem link = AbstractActivityView.newLinkItem(title, destination);
+ StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter
+ .format(deployment.getCtime()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ //insert see more link
+ //TODO: spinder:2/25/11 (add this later) no current view for seeing all bundle deployments
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentBundleDeployContent.extendLocatorId("RecentBundleContentSeeMore"));
+ // addSeeMoreLink(row, LinkManager.getResourceGroupLink(groupId) + "/Events/History/", column);
+ } else {
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentBundleDeployContent
+ .extendLocatorId("None"), MSG.view_portlet_results_empty());
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentBundleDeployContent.getChildren()) {
+ child.destroy();
+ }
+ recentBundleDeployContent.addChild(column);
+ recentBundleDeployContent.markForRedraw();
+ markForRedraw();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
new file mode 100644
index 0000000..01a0b96
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
@@ -0,0 +1,177 @@
+/*
+ * 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.dashboard.portlets.resource;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+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.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**This portlet allows the end user to customize the Events display
+ *
+ * @author Simeon Pinder
+ */
+public class ResourceEventsPortlet extends GroupEventsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceEvents";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resource_events();
+
+ private int resourceId = -1;
+
+ public ResourceEventsPortlet(String locatorId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ // int currentGroupIdentifier = Integer.valueOf(elements[1]);
+ this.resourceId = Integer.valueOf(elements[1]);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ loadData();
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentEventsContent);
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new ResourceEventsPortlet(locatorId);
+ }
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentEventUpdates();
+ }
+
+ /** Fetches recent events and updates the DynamicForm instance with the latest
+ * event information over last 24hrs.
+ */
+ private void getRecentEventUpdates() {
+ final int resourceId = this.resourceId;
+ long end = System.currentTimeMillis();
+ long start = end - (24 * 60 * 60 * 1000);
+
+ //result timeframe if enabled
+ PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ start = Long.valueOf(range[0]);
+ end = Long.valueOf(range[1]);
+ }
+ }
+
+ // GWTServiceLookup.getEventService().getEventCountsBySeverityForGroup(resourceId, start, end,
+ GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId, start, end,
+ new AsyncCallback<Map<EventSeverity, Integer>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving event counts for resource [" + resourceId + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(Map<EventSeverity, Integer> eventCounts) {
+ //Now populated Tuples
+ List<GwtTuple<EventSeverity, Integer>> results = new ArrayList<GwtTuple<EventSeverity, Integer>>();
+ for (EventSeverity severity : eventCounts.keySet()) {
+ int count = eventCounts.get(severity);
+ if (count > 0) {
+ results.add(new GwtTuple<EventSeverity, Integer>(severity, count));
+ }
+ }
+ //build display
+ VLayout column = new VLayout();
+ column.setHeight(10);
+
+ if (!results.isEmpty()) {
+ int rowNum = 0;
+ for (GwtTuple<EventSeverity, Integer> tuple : results) {
+ // event history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(2);
+ row.setWidth(10);//pack.
+
+ //icon
+ StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(ImageManager
+ .getEventSeverityIcon(tuple.getLefty()), tuple.getLefty().name());
+ //count
+ StaticTextItem count = AbstractActivityView.newTextItem(String.valueOf(tuple.righty));
+ row.setItems(iconItem, count);
+
+ column.addMember(row);
+ }
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
+ .valueOf(rowNum)));
+ // AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + resourceId
+ AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ + "/Events/History/", column);
+ } else {
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentEventsContent
+ .extendLocatorId("None"), AbstractActivityView.RECENT_CRITERIA_EVENTS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentEventsContent.getChildren()) {
+ child.destroy();
+ }
+ recentEventsContent.addChild(column);
+ recentEventsContent.markForRedraw();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
new file mode 100644
index 0000000..b7ed496
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
@@ -0,0 +1,318 @@
+/*
+ * 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.dashboard.portlets.resource;
+
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.ContentsType;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.util.PageList;
+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.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**This portlet allows the end user to customize the metric display
+ *
+ * @author Simeon Pinder
+ */
+public class ResourceMetricsPortlet extends GroupMetricsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceMetrics";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resource_metrics();
+
+ private int resourceId = -1;
+
+ public ResourceMetricsPortlet(String locatorId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentResourceIdentifier = Integer.valueOf(elements[1]);
+ this.resourceId = currentResourceIdentifier;
+ baseViewPath = elements[0];
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ loadData();
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentMeasurementsContent);
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new ResourceMetricsPortlet(locatorId);
+ }
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentMetrics();
+ }
+
+ /** Fetches recent metric information and updates the DynamicForm instance with i)sparkline information,
+ * ii) link to recent metric graph for more details and iii) last metric value formatted to show significant
+ * digits.
+ */
+ private void getRecentMetrics() {
+ //display container
+ final VLayout column = new VLayout();
+ column.setHeight(10);//pack
+
+ //initialize to defaults
+ end = System.currentTimeMillis();
+ start = end - (1000L * 60 * 60 * 8);//last 8 hrs
+
+ //result timeframe if enabled
+ PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ start = Long.valueOf(range[0]);
+ end = Long.valueOf(range[1]);
+ }
+ }
+
+ //locate resource reference
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterId(this.resourceId);
+
+ //locate the resource
+ GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving resource resource composite for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceComposite> results) {
+ if (!results.isEmpty()) {
+ final ResourceComposite resourceComposite = results.get(0);
+ final Resource resource = resourceComposite.getResource();
+ // Load the fully fetched ResourceType.
+ ResourceType resourceType = resource.getResourceType();
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ resourceType.getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.content,
+ ResourceTypeRepository.MetadataType.operations,
+ ResourceTypeRepository.MetadataType.measurements,
+ ResourceTypeRepository.MetadataType.events,
+ ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ resource.setResourceType(type);
+ //metric definitions
+ Set<MeasurementDefinition> definitions = type.getMetricDefinitions();
+
+ //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
+ final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition definition : definitions) {
+ measurementDefMap.put(definition.getDisplayName(), definition);
+ }
+ //bundle definition ids for asynch call.
+ int[] definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay)
+ .getId();
+ }
+
+ //make the asynchronous call for all the measurement data
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId,
+ definitionArrayIds, start, end, 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log
+ .debug("Error retrieving recent metrics charting data for resource ["
+ + resourceId + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(
+ List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+ boolean someChartedData = false;
+ //iterate over the retrieved charting data
+ for (int index = 0; index < displayOrder.length; index++) {
+ //retrieve the correct measurement definition
+ MeasurementDefinition md = measurementDefMap
+ .get(displayOrder[index]);
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> data = results
+ .get(index);
+
+ //locate last and minimum values.
+ double lastValue = -1;
+ double minValue = Double.MAX_VALUE;//
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ if (d.getValue() < minValue) {
+ minValue = d.getValue();
+ }
+ lastValue = d.getValue();
+ }
+ }
+
+ //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
+ String commaDelimitedList = "";
+
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ commaDelimitedList += d.getValue() + ",";
+ }
+ }
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent.extendLocatorId(md.getName()));
+ row.setNumCols(3);
+ HTMLFlow graph = new HTMLFlow();
+ // String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
+ // + commaDelimitedList + "</span>";
+ String contents = "<span id='sparkline_" + index
+ + "' class='dynamicsparkline' width='0' " + "values='"
+ + commaDelimitedList + "'>...</span>";
+ graph.setContents(contents);
+ graph.setContentsType(ContentsType.PAGE);
+ //diable scrollbars on span
+ graph.setScrollbarSize(0);
+
+ CanvasItem graphContainer = new CanvasItem();
+ graphContainer.setShowTitle(false);
+ graphContainer.setHeight(16);
+ graphContainer.setWidth(60);
+ graphContainer.setCanvas(graph);
+
+ //Link/title element
+ //TODO: spinder, change link whenever portal.war/graphing is removed.
+ String title = md.getDisplayName() + ":";
+ // String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ // + resourceId + "&m=" + md.getId();
+ String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ + resourceId + "&m=" + md.getId();
+ LinkItem link = AbstractActivityView.newLinkItem(title,
+ destination);
+
+ //Value
+ String convertedValue = lastValue + " " + md.getUnits();
+ convertedValue = AbstractActivityView
+ .convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = AbstractActivityView
+ .newTextItem(convertedValue);
+
+ row.setItems(graphContainer, link, value);
+ //if graph content returned
+ if ((md.getName().trim().indexOf("Trait.") == -1)
+ && (lastValue != -1)) {
+ column.addMember(row);
+ someChartedData = true;
+ }
+ }
+ if (!someChartedData) {// when there are results but no chartable entries.
+ LocatableDynamicForm row = AbstractActivityView
+ .createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent
+ .extendLocatorId("RecentMeasurementsContentSeeMore"));
+ AbstractActivityView.addSeeMoreLink(row,
+ ReportDecorator.GWT_RESOURCE_URL + resourceId
+ + "/Monitoring/Graphs/", column);
+ }
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row = AbstractActivityView
+ .createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ }
+ }
+ });
+ }
+ });
+ // }
+ }
+ }
+ });
+
+ //cleanup
+ for (Canvas child : recentMeasurementsContent.getChildren()) {
+ child.destroy();
+ }
+ recentMeasurementsContent.addChild(column);
+ recentMeasurementsContent.markForRedraw();
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java
new file mode 100644
index 0000000..b0e9d37
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOobsPortlet.java
@@ -0,0 +1,151 @@
+/*
+ * 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.dashboard.portlets.resource;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
+import org.rhq.core.domain.util.PageList;
+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.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**This portlet allows the end user to customize the OOB display
+ *
+ * @author Simeon Pinder
+ */
+public class ResourceOobsPortlet extends GroupOobsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceOobs";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resource_oobs();
+
+ private int resourceId = -1;
+
+ public ResourceOobsPortlet(String locatorId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ this.resourceId = Integer.valueOf(elements[1]);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ loadData();
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentOobContent);
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new ResourceOobsPortlet(locatorId);
+ }
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentOobs();
+ }
+
+ /** Fetches OOB measurements and updates the DynamicForm instance with the latest N
+ * oob change details.
+ */
+ private void getRecentOobs() {
+ final int resourceId = this.resourceId;
+ int resultCount = 5;//default to
+
+ //result count
+ PropertySimple property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ resultCount = 5;
+ } else {
+ resultCount = Integer.valueOf(currentSetting);
+ }
+ }
+
+ GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resourceId, resultCount,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving out of bound metrics for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<MeasurementOOBComposite> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (MeasurementOOBComposite oob : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOobContent.extendLocatorId(oob
+ .getScheduleName()));
+ row.setNumCols(2);
+
+ String title = oob.getScheduleName() + ":";
+ String destination = "/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId()
+ + "&id=" + resourceId + "&mode=chartSingleMetricSingleResource";
+ LinkItem link = AbstractActivityView.newLinkItem(title, destination);
+ StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter
+ .format(oob.getTimestamp()));
+
+ row.setItems(link, time);
+ column.addMember(row);
+ }
+ //insert see more link spinder(2/24/11): no page that displays all oobs... See More not possible.
+ } else {
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentOobContent
+ .extendLocatorId("None"), AbstractActivityView.RECENT_OOB_NONE);
+ column.addMember(row);
+ }
+ recentOobContent.setContents("");
+ for (Canvas child : recentOobContent.getChildren()) {
+ child.destroy();
+ }
+ recentOobContent.addChild(column);
+ recentOobContent.markForRedraw();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
new file mode 100644
index 0000000..96be005
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
@@ -0,0 +1,274 @@
+/*
+ * 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.dashboard.portlets.resource;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+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.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView;
+
+/**
+ * @author Simeon Pinder
+ */
+public class ResourceOperationsPortlet extends GroupOperationsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceOperations";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resource_operations();
+
+ private int resourceId;
+ private ResourceComposite resourceComposite;
+ private ResourceOperationsCriteriaHistoryListView resourceOperations;
+
+ public ResourceOperationsPortlet(String locatorId) {
+ super(locatorId);
+ this.locatorId = locatorId;
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ this.resourceId = Integer.valueOf(elements[1]);
+ //populate basepath
+ baseViewPath = elements[0];
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ loadData();
+ }
+
+ private void loadData() {
+ //populate composite data
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterId(this.resourceId);
+
+ criteria.fetchOperationHistories(false);
+
+ //locate the resource
+ GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving resource composite for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceComposite> results) {
+ if (!results.isEmpty()) {
+ resourceComposite = results.get(0);
+ //instantiate view
+ //populated GWT criteria objects
+ Criteria criteria = new Criteria(ResourceOperationHistoryDataSource.CriteriaField.RESOURCE_ID,
+ String.valueOf(resourceComposite.getResource().getId()));
+
+ resourceOperations = new ResourceOperationsCriteriaHistoryListView(locatorId,
+ new ResourceOperationsCriteriaDataSource(portletConfig), null, criteria, resourceComposite);
+
+ //cleanup
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
+ }
+ recentOperationsContent.addChild(resourceOperations);
+ recentOperationsContent.markForRedraw();
+ }
+ }
+ });
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new ResourceOperationsPortlet(locatorId);
+ }
+ }
+}
+
+/** Provide implementation of ResourceOperationsHistoryListView using datasource
+ * that customizes fetch based on Configuration parameters.
+ *
+ * @author spinder
+ */
+class ResourceOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView {
+
+ private AbstractOperationHistoryDataSource datasource;
+
+ public ResourceOperationsCriteriaHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource,
+ String title, Criteria criteria, ResourceComposite composite) {
+ super(locatorId, dataSource, title, criteria);
+ this.datasource = dataSource;
+ this.resourceComposite = composite;
+ setShowFooterRefresh(false); //disable footer refresh
+ }
+
+ private ResourceComposite resourceComposite;
+
+ @Override
+ protected boolean hasControlPermission() {
+ return this.resourceComposite.getResourcePermission().isControl();
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new ResourceOperationHistoryDetailsView(extendLocatorId("DetailsView"), this.resourceComposite);
+ }
+
+ public AbstractOperationHistoryDataSource getDatasource() {
+ return datasource;
+ }
+
+ public void setDatasource(AbstractOperationHistoryDataSource datasource) {
+ this.datasource = datasource;
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ }
+ }
+}
+
+/** Provide implementation of ResourceOperationHistoryDataSource that dynamically
+ * configures fetch requests for this table view.
+ *
+ * @author spinder
+ */
+class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataSource {
+
+ public ResourceOperationsCriteriaDataSource(Configuration portletConfig) {
+ this.portletConfig = portletConfig;
+ }
+
+ private Configuration portletConfig;
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
+ int resourceId = Integer
+ .parseInt((String) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID));
+ Integer[] resourceIds = new Integer[1];
+ resourceIds[0] = resourceId;
+ criteria.addFilterResourceIds(resourceIds);
+ }
+
+ //initialize to only five for quick queries.
+ PageControl pageControl = new PageControl(0, 5);//default to displaying five
+ //customize query with latest configuration selections
+
+ //retrieve previous settings from portlet config
+ if (portletConfig != null) {
+ //result sort order
+ PropertySimple property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ criteria.addSortStatus(PageOrdering.DESC);
+ } else {
+ criteria.addSortStatus(PageOrdering.ASC);
+ }
+ }
+ //result timeframe if enabled
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ }
+
+ //result count
+ property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ pageControl.setPageSize(5);
+ } else {
+ pageControl = new PageControl(0, Integer.valueOf(currentSetting));
+ }
+ }
+ criteria.setPageControl(pageControl);
+
+ //detect operation status filter
+ property = portletConfig.getSimple(Constant.OPERATION_STATUS);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (currentSetting.trim().isEmpty() || parsedValues.length == OperationRequestStatus.values().length) {
+ //all operation stati assumed
+ } else {
+ OperationRequestStatus[] operationStati = new OperationRequestStatus[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ OperationRequestStatus s = OperationRequestStatus.valueOf(priority);
+ operationStati[indx++] = s;
+ }
+ criteria.addFilterStatuses(operationStati);
+ }
+ }
+ }
+
+ operationService.findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(), caught);
+ }
+
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java
new file mode 100644
index 0000000..6110d7e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java
@@ -0,0 +1,170 @@
+/*
+ * 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.dashboard.portlets.resource;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.content.InstalledPackageHistory;
+import org.rhq.core.domain.criteria.InstalledPackageHistoryCriteria;
+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.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupPkgHistoryPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**This portlet allows the end user to customize the Package History display
+ *
+ * @author Simeon Pinder
+ */
+public class ResourcePkgHistoryPortlet extends GroupPkgHistoryPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourcePackageHistory";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resource_pkg_hisory();
+
+ private int resourceId = -1;
+
+ public ResourcePkgHistoryPortlet(String locatorId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentResourceIdentifier = Integer.valueOf(elements[1]);
+ this.resourceId = currentResourceIdentifier;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ loadData();
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentPkgHistoryContent);
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new ResourcePkgHistoryPortlet(locatorId);
+ }
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentPkgHistory();
+ }
+
+ /** Fetches recent package history information and updates the DynamicForm instance with details.
+ */
+ private void getRecentPkgHistory() {
+ final int resourceId = this.resourceId;
+ InstalledPackageHistoryCriteria criteria = new InstalledPackageHistoryCriteria();
+
+ int resultCount = 5;//default to
+ //result count
+ PropertySimple property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ resultCount = 5;
+ } else {
+ resultCount = Integer.valueOf(currentSetting);
+ }
+ }
+ PageControl pageControl = new PageControl(0, resultCount);
+ criteria.setPageControl(pageControl);
+ // criteria.addFilterResourceGroupIds(resourceId);
+ criteria.addFilterResourceId(resourceId);
+
+ criteria.addSortStatus(PageOrdering.DESC);
+
+ GWTServiceLookup.getContentService().findInstalledPackageHistoryByCriteria(criteria,
+
+ new AsyncCallback<PageList<InstalledPackageHistory>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed package history for group [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<InstalledPackageHistory> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (InstalledPackageHistory history : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ .extendLocatorId(history.getPackageVersion().getFileName()
+ + history.getPackageVersion().getVersion()));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(
+ "subsystems/content/Package_16.png", null);
+ String title = history.getPackageVersion().getFileName() + ":";
+ String destination = "/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId
+ + "&selectedHistoryId=" + history.getId();
+ LinkItem link = AbstractActivityView.newLinkItem(title, destination);
+ StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter
+ .format(history.getTimestamp()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ // //insert see more link
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ // .extendLocatorId("PkgHistoryContentSeeMore"));
+ // String destination = "/rhq/resource/content/audit-trail-item.xhtml?id=" + groupId;
+ // addSeeMoreLink(row, destination, column);
+ } else {
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentPkgHistoryContent
+ .extendLocatorId("None"), MSG.view_portlet_results_empty());
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentPkgHistoryContent.getChildren()) {
+ child.destroy();
+ }
+ recentPkgHistoryContent.addChild(column);
+ recentPkgHistoryContent.markForRedraw();
+ markForRedraw();
+ }
+ });
+ }
+}
\ 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/operation/history/ResourceOperationHistoryDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java
index 5632322..c8256f1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java
@@ -34,6 +34,7 @@ import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
@@ -50,11 +51,17 @@ public class ResourceOperationHistoryDetailsView extends AbstractOperationHistor
private String disambiguatedResourceName;
private boolean showResourceField;
+ private ResourceComposite resourceComposite;
public ResourceOperationHistoryDetailsView(String locatorId) {
this(locatorId, false);
}
+ public ResourceOperationHistoryDetailsView(String locatorId, ResourceComposite resourceComposite) {
+ this(locatorId);
+ this.resourceComposite = resourceComposite;
+ }
+
public ResourceOperationHistoryDetailsView(String locatorId, boolean showResourceField) {
super(locatorId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
index 8c03071..867251f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
@@ -107,7 +107,9 @@ public class Activity2View extends LocatableVLayout implements DashboardContaine
Canvas[] members = getMembers();
removeMembers(members);
- dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard);
+ //pass in the resource information
+ dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard, null,
+ this.resourceComposite.getResource());
addMember(dashboardView);
footer = new LocatableToolStrip(extendLocatorId("Footer"));
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 41d3251..11bafec 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
@@ -1462,6 +1462,13 @@ view_portlet_defaultName_group_metrics = Group: Metrics
view_portlet_defaultName_group_oobs = Group: OOB Metrics
view_portlet_defaultName_group_operations = Group: Operations
view_portlet_defaultName_group_pkg_hisory = Group: Package History
+view_portlet_defaultName_resource_alerts = Resource: Alerts
+view_portlet_defaultName_resource_bundles = Resource: Bundle Deployments
+view_portlet_defaultName_resource_events = Resource: Event Counts
+view_portlet_defaultName_resource_metrics = Resource: Metrics
+view_portlet_defaultName_resource_oobs = Resource: OOB Metrics
+view_portlet_defaultName_resource_operations = Resource: Operations
+view_portlet_defaultName_resource_pkg_hisory = Resource: Package History
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_bundle_deps = This portlet shows relevant bundle deployments based on display criteria configured.
commit f485bd48bc7ef68cb6c6203023e3e13ce42d73fc
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Mar 16 09:48:26 2011 -0400
exclude portlets already on dashboard available 'add' menu.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 456343d..fb17b55 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -244,6 +244,15 @@ public class DashboardView extends LocatableVLayout {
//if resourceGroup passed in then add additional portlets to list
if (this.focusGroup != null) {
HashMap<String, String> groupKeyNameMap = PortletFactory.getRegisteredGroupPortletNameMap();
+ //find current list of portlets already stored. Exclude them
+ for (DashboardPortlet currentPortlet : storedDashboard.getPortlets()) {
+ if (groupKeyNameMap.containsKey(currentPortlet.getPortletKey())) {
+ groupKeyNameMap.remove(currentPortlet.getPortletKey());
+ }
+ }
+
+ //TODO: spinder 3/16/11: still need to be done.
+ //filter out portlets not relevent for group(compat|mixed) or facets
for (String portletKey : groupKeyNameMap.keySet()) {
nameKeyMap.put(groupKeyNameMap.get(portletKey), portletKey);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index b260039..3a15b44 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -24,6 +24,7 @@ import java.util.List;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
@@ -97,7 +98,7 @@ public class PortletFactory {
//############## Group Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
registeredGroupPortletFactoryMap = new HashMap<String, PortletViewFactory>();
- // registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
@@ -109,7 +110,7 @@ public class PortletFactory {
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
- // registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
+ registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.NAME);
registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
@@ -128,7 +129,7 @@ public class PortletFactory {
//############## Portlet icon mappings ############################################
//register portlet names
registeredPortletIconMap = new HashMap<String, String>(registeredPortletFactoryMap.size());
- // registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertLargeIcon());
+ registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertLargeIcon());
registeredPortletIconMap.put(GroupAlertsPortlet2.KEY, ImageManager.getAlertLargeIcon());
registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorLargeIcon());
registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedLargeIcon());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
index cd0526a..30a7350 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
@@ -67,10 +67,10 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet {
// A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupAlerts";
+ public static final String KEY = "GroupAlerts2";
// A default displayed, persisted name for the portlet
// public static final String NAME = MSG.view_portlet_defaultName_recentAlerts();
- public static final String NAME = MSG.view_portlet_defaultName_group_alerts();
+ public static final String NAME = MSG.view_portlet_defaultName_group_alerts() + "2";
public static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value";
public static final String ALERT_RANGE_RESOURCE_IDS = "alert-range-resource-ids";
commit ae68657f9d88613b1a6324d1ff04b34e7c4e9dd0
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 18:51:25 2011 -0400
some group portlet code cleanup.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 3a15b44..b260039 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -24,7 +24,6 @@ import java.util.List;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
@@ -98,7 +97,7 @@ public class PortletFactory {
//############## Group Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
registeredGroupPortletFactoryMap = new HashMap<String, PortletViewFactory>();
- registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
+ // registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
@@ -110,7 +109,7 @@ public class PortletFactory {
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
- registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
+ // registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.NAME);
registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
@@ -129,7 +128,7 @@ public class PortletFactory {
//############## Portlet icon mappings ############################################
//register portlet names
registeredPortletIconMap = new HashMap<String, String>(registeredPortletFactoryMap.size());
- registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertLargeIcon());
+ // registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertLargeIcon());
registeredPortletIconMap.put(GroupAlertsPortlet2.KEY, ImageManager.getAlertLargeIcon());
registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorLargeIcon());
registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedLargeIcon());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
index 16437f6..cd0526a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
@@ -19,7 +19,6 @@
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
import java.util.HashMap;
-import java.util.List;
import java.util.Set;
import com.google.gwt.user.client.History;
@@ -32,8 +31,6 @@ import com.smartgwt.client.widgets.events.DoubleClickHandler;
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.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
@@ -57,8 +54,8 @@ 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.dashboard.portlets.PortletConfigurationEditorComponent;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -70,10 +67,10 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet {
// A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupAlerts2";
+ public static final String KEY = "GroupAlerts";
// A default displayed, persisted name for the portlet
// public static final String NAME = MSG.view_portlet_defaultName_recentAlerts();
- public static final String NAME = "Group: Alerts2";
+ public static final String NAME = MSG.view_portlet_defaultName_group_alerts();
public static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value";
public static final String ALERT_RANGE_RESOURCE_IDS = "alert-range-resource-ids";
@@ -215,13 +212,10 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
@Override
public void onSubmitValues(SubmitValuesEvent event) {
+ String selectedValue;
//alert severity
- String selectedValue = alertPrioritySelector.getValue().toString();
- if ((selectedValue.trim().isEmpty()) || (selectedValue.split(",").length == 3)) {//then no alertPriority specified
- portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY, ""));
- } else {//some subset of available alertPriorities will be used
- portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY, selectedValue));
- }
+ portletConfig = AbstractActivityView.saveAlertPrioritySettings(alertPrioritySelector, portletConfig);
+
// //result sort order
// selectedValue = resultSortSelector.getValue().toString();
// if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc
@@ -230,32 +224,11 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
// portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.ASC));
// }
//result count
- selectedValue = resultCountSelector.getValue().toString();
- if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(Constant.RESULT_COUNT_DEFAULT))) {//then 5
- portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, Constant.RESULT_COUNT_DEFAULT));
- } else {
- portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, selectedValue));
- }
-
- //alert time range filter. Check for enabled and then persist property. Dealing with compound widget.
- FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
- CheckboxItem itemC = (CheckboxItem) item;
- selectedValue = String.valueOf(itemC.getValueAsBoolean());
- if (!selectedValue.trim().isEmpty()) {//then call
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue));
- }
-
- //alert time advanced time filter enabled.
- selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
- if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
- }
+ portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
- //alert time frame
- List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (begEnd.get(0) != 0) {//advanced settings
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
- }
+ //time range settings
+ portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
//persist and reload portlet
storedPortlet.setConfiguration(portletConfig);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
index fa9f7ea..fa78591 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
@@ -86,6 +86,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
private long start = -1;
private long end = -1;
+ //defines the list of configuration elements to load/persist for this portlet
private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
static {
CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
@@ -172,18 +173,22 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
getRecentMetrics();
}
+ /** Builds custom config UI, using shared widgets
+ */
@Override
public DynamicForm getCustomSettingsForm() {
+ //root form.
LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings"));
+ //embed range editor in it own container
LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page"));
final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
.getMeasurementRangeEditor(portletConfig);
//submit handler
customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
-
@Override
public void onSubmitValues(SubmitValuesEvent event) {
+ //retrieve range editor values
portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
portletConfig);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
index 9f91b88..40a6128 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java
@@ -95,7 +95,7 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "GroupOobs";
// A default displayed, persisted name for the portlet
- public static final String NAME = "Group: OOB Metrics";
+ public static final String NAME = MSG.view_portlet_defaultName_group_oobs();
public static final String ID = "id";
// set on initial configuration, the window for this portlet view.
@@ -104,6 +104,7 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
private Timer refreshTimer;
+ //defines the list of configuration elements to load/persist for this portlet
private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
static {
CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index c89c284..ce30557 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -18,7 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.History;
@@ -84,6 +86,20 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
private GroupOperationsCriteriaHistoryListView dataSource;
+ //defines the list of configuration elements to load/persist for this portlet
+ private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_ENABLE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_LASTN);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_UNIT);
+ CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
+ CONFIG_INCLUDE.add(Constant.RESULT_SORT_ORDER);
+ CONFIG_INCLUDE.add(Constant.RESULT_SORT_PRIORITY);
+ CONFIG_INCLUDE.add(Constant.OPERATION_STATUS);
+ }
+
//instance ui widgets
private Canvas containerCanvas;
@@ -197,7 +213,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
//lazy init any elements not yet configured.
for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
- if (portletConfig.getSimple(key) == null) {
+ if ((portletConfig.getSimple(key) == null) && CONFIG_INCLUDE.contains(key)) {
portletConfig.put(new PropertySimple(key,
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index 42e9880..37b0052 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -39,6 +39,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.core.domain.alert.AlertPriority;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
@@ -537,6 +538,22 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
return portletConfig;
}
+ /** Takes the current value of the widget and persists it into the configuration object passed in.
+ *
+ * @param alertPrioritySelector
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ public static Configuration saveAlertPrioritySettings(SelectItem alertPrioritySelector, Configuration portletConfig) {
+ String selectedValue = alertPrioritySelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty()) || (selectedValue.split(",").length == AlertPriority.values().length)) {//then no alertPriority specified
+ portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY, ""));
+ } else {//some subset of available alertPriorities will be used
+ portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY, selectedValue));
+ }
+ return portletConfig;
+ }
+
protected boolean displayGroupConfigurationUpdates(GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
if ((groupCategory == null) || facets == null) {
return false;
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 02d7519..41d3251 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
@@ -1455,9 +1455,11 @@ view_portlet_defaultName_recentAlerts = Recent Alerts
view_portlet_defaultName_recentlyAddedResources = Recently Added Resources
view_portlet_defaultName_tagCloud = Tag Count
+view_portlet_defaultName_group_alerts =Group: Alerts
view_portlet_defaultName_group_bundles = Group: Bundle Deployments
view_portlet_defaultName_group_events = Group: Event Counts
view_portlet_defaultName_group_metrics = Group: Metrics
+view_portlet_defaultName_group_oobs = Group: OOB Metrics
view_portlet_defaultName_group_operations = Group: Operations
view_portlet_defaultName_group_pkg_hisory = Group: Package History
commit 11ffe1786be98d0c787dfdb37f5567ffd113d9b0
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 17:55:34 2011 -0400
adding bundle deployment portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index d4f018f..1e93fd7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -454,4 +454,15 @@ public class ImageManager {
return "subsystems/content/Package_24.png";
}
+ public static String getActivityPackageIcon() {
+ return "subsystems/content/Package_16.png";
+ }
+
+ public static String getBundleLargeIcon() {
+ return "subsystems/content/Content_24.png";
+ }
+
+ public static String getBundleIcon() {
+ return "subsystems/content/Content_16.png";
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 7be3753..3a15b44 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -26,6 +26,7 @@ import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet;
@@ -104,6 +105,8 @@ public class PortletFactory {
registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupPkgHistoryPortlet.KEY, GroupPkgHistoryPortlet.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupBundleDeploymentsPortlet.KEY,
+ GroupBundleDeploymentsPortlet.Factory.INSTANCE);
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
@@ -114,6 +117,7 @@ public class PortletFactory {
registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupPkgHistoryPortlet.KEY, GroupPkgHistoryPortlet.NAME);
+ registeredGroupPortletNameMap.put(GroupBundleDeploymentsPortlet.KEY, GroupBundleDeploymentsPortlet.NAME);
//############## Resource Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
@@ -132,6 +136,7 @@ public class PortletFactory {
registeredPortletIconMap.put(GroupEventsPortlet.KEY, ImageManager.getEventLargeIcon());
registeredPortletIconMap.put(GroupOperationsPortlet.KEY, ImageManager.getOperationLargeIcon());
registeredPortletIconMap.put(GroupPkgHistoryPortlet.KEY, ImageManager.getActivityPackageLargeIcon());
+ registeredPortletIconMap.put(GroupBundleDeploymentsPortlet.KEY, ImageManager.getBundleLargeIcon());
}
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java
new file mode 100644
index 0000000..6198529
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java
@@ -0,0 +1,304 @@
+/*
+ * 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.dashboard.portlets.groups;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+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.LinkItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.GroupBundleDeploymentCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+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.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+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.dashboard.portlets.PortletConfigurationEditorComponent;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**This portlet allows the end user to customize the Bundle Deployment display
+ *
+ * @author Simeon Pinder
+ */
+public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements CustomSettingsPortlet,
+ AutoRefreshPortlet {
+
+ private int groupId = -1;
+ protected LocatableCanvas recentBundleDeployContent = new LocatableCanvas(
+ extendLocatorId("RecentBundleDeployments"));
+ private boolean currentlyLoading = false;
+ private Configuration portletConfig = null;
+ private DashboardPortlet storedPortlet;
+
+ public GroupBundleDeploymentsPortlet(String locatorId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentGroupIdentifier = Integer.valueOf(elements[1]);
+ this.groupId = currentGroupIdentifier;
+ initializeUi();
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentBundleDeployContent);
+ }
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupBundleDeployments";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_bundles();
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+ //instance ui widgets
+
+ private Timer refreshTimer;
+
+ private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
+ }
+
+ /** Responsible for initialization and lazy configuration of the portlet values
+ */
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ //populate portlet configuration details
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+ this.storedPortlet = storedPortlet;
+ portletConfig = storedPortlet.getConfiguration();
+
+ //lazy init any elements not yet configured.
+ for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if ((portletConfig.getSimple(key) == null) && CONFIG_INCLUDE.contains(key)) {
+ portletConfig.put(new PropertySimple(key,
+ PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
+ }
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_bundle_deps());
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new GroupBundleDeploymentsPortlet(locatorId);
+ }
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentBundleDeployments();
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+ LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings"));
+ LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page"));
+ //build editor form container
+ final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("bundle-deps"));
+ form.setMargin(5);
+ //add result count selector
+ final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+ form.setItems(resultCountSelector);
+
+ //submit handler
+ customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+
+ //results count
+ portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
+
+ //persist
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ loadData();
+ }
+
+ });
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
+ /** Fetches recent bundle deployment information and updates the DynamicForm instance with details.
+ */
+ protected void getRecentBundleDeployments() {
+ final int groupId = this.groupId;
+ GroupBundleDeploymentCriteria criteria = new GroupBundleDeploymentCriteria();
+
+ int resultCount = 5;//default to
+ //result count
+ PropertySimple property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ resultCount = 5;
+ } else {
+ resultCount = Integer.valueOf(currentSetting);
+ }
+ }
+ PageControl pageControl = new PageControl(0, resultCount);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceGroupIds(groupId);
+ criteria.addSortStatus(PageOrdering.DESC);
+ criteria.fetchDestination(true);
+ criteria.fetchBundleVersion(true);
+
+ GWTServiceLookup.getBundleService().findBundleDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDeployment>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed bundle deployments for group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<BundleDeployment> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (BundleDeployment deployment : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentBundleDeployContent
+ .extendLocatorId(deployment.getBundleVersion().getName()
+ + deployment.getBundleVersion().getVersion()));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(
+ "subsystems/content/Content_16.png", null);
+ String title = deployment.getBundleVersion().getName() + "["
+ + deployment.getBundleVersion().getVersion() + "]:";
+ String destination = ReportDecorator.GWT_BUNDLE_URL
+ + deployment.getBundleVersion().getBundle().getId() + "/destinations/"
+ + deployment.getDestination().getId();
+ LinkItem link = AbstractActivityView.newLinkItem(title, destination);
+ StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter
+ .format(deployment.getCtime()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ //insert see more link
+ //TODO: spinder:2/25/11 (add this later) no current view for seeing all bundle deployments
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentBundleDeployContent.extendLocatorId("RecentBundleContentSeeMore"));
+ // addSeeMoreLink(row, LinkManager.getResourceGroupLink(groupId) + "/Events/History/", column);
+ } else {
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentBundleDeployContent
+ .extendLocatorId("None"), MSG.view_portlet_results_empty());
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentBundleDeployContent.getChildren()) {
+ child.destroy();
+ }
+ recentBundleDeployContent.addChild(column);
+ recentBundleDeployContent.markForRedraw();
+ markForRedraw();
+ }
+ });
+ }
+
+ @Override
+ public void startRefreshCycle() {
+ //current setting
+ final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+
+ //cancel any existing timer
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ if (refreshInterval >= MeasurementUtility.MINUTES) {
+ refreshTimer = new Timer() {
+ public void run() {
+ if (!currentlyLoading) {
+ loadData();
+ redraw();
+ }
+ }
+ };
+ refreshTimer.scheduleRepeating(refreshInterval);
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+ super.onDestroy();
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+ loadData();
+ }
+
+}
\ No newline at end of file
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 9185fb4..02d7519 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
@@ -1455,12 +1455,14 @@ view_portlet_defaultName_recentAlerts = Recent Alerts
view_portlet_defaultName_recentlyAddedResources = Recently Added Resources
view_portlet_defaultName_tagCloud = Tag Count
+view_portlet_defaultName_group_bundles = Group: Bundle Deployments
view_portlet_defaultName_group_events = Group: Event Counts
view_portlet_defaultName_group_metrics = Group: Metrics
view_portlet_defaultName_group_operations = Group: Operations
view_portlet_defaultName_group_pkg_hisory = Group: Package History
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
+view_portlet_help_bundle_deps = This portlet shows relevant bundle deployments based on display criteria configured.
view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
view_portlet_help_favoriteResources = This portlet displays the current user''s favorite resources.
view_portlet_help_graph = This portlet displays the resource metric graph.
@@ -1471,7 +1473,7 @@ view_portlet_help_message = This portlet displays a static HTML message. The <i>
view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions.
view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory.
view_portlet_help_operations_criteria = This portlet displays Operations consistent with display criteria configured.
-view_portlet_help_pkg_history = This portlet relevant package history based on display criteria configured.
+view_portlet_help_pkg_history = This portlet shows relevant package history based on display criteria configured.
view_portlet_help_platformSummary = This portlet displays information about the current user''s platform resources.
view_portlet_help_problemResources = This portlet displays the current user''s alerted or unavailable resources.
view_portlet_help_recentAlerts = This portlet displays alerts recently fired on the current user''s viewable inventory.
commit 8e98439922d366268eb7be87becdc901c81aa816
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 16:44:51 2011 -0400
change opHistoryCriteria filter from stati to statuses.
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 c5a6be4..86e4554 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
@@ -45,7 +45,7 @@ public abstract class OperationHistoryCriteria extends Criteria {
private String filterJobName;
private String filterJobGroup;
private OperationRequestStatus filterStatus;
- private List<OperationRequestStatus> filterStati; // requires overrides
+ private List<OperationRequestStatus> filterStatuses; // requires overrides
private String filterErrorMessage;
private Integer filterOperationDefinitionId; // requires override
private String filterOperationName; // requires override
@@ -71,7 +71,7 @@ public abstract class OperationHistoryCriteria extends Criteria {
+ " FROM ResourceOperationHistory roh " //
+ " WHERE roh.resource.id IN ( ? ) ) ");
- filterOverrides.put("stati", "status IN ( ? )");
+ filterOverrides.put("statuses", "status IN ( ? )");
sortOverrides.put("startTime", "startedTime");
sortOverrides.put("endTime", "modifiedTime");
@@ -96,8 +96,8 @@ public abstract class OperationHistoryCriteria extends Criteria {
this.filterStatus = filterStatus;
}
- public void addFilterStati(OperationRequestStatus... operationStatus) {
- this.filterStati = CriteriaUtils.getListIgnoringNulls(operationStatus);
+ public void addFilterStatuses(OperationRequestStatus... operationStatus) {
+ this.filterStatuses = CriteriaUtils.getListIgnoringNulls(operationStatus);
}
public void addFilterErrorMessage(String filterErrorMessage) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index dd8187e..c89c284 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -449,7 +449,7 @@ class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource
OperationRequestStatus s = OperationRequestStatus.valueOf(priority);
operationStati[indx++] = s;
}
- criteria.addFilterStati(operationStati);
+ criteria.addFilterStatuses(operationStati);
}
}
}
commit d47eb892cf3a9abf81cf5dc608b95d6274bcacda
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 16:34:22 2011 -0400
adding package history portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index d4ffb3c..d4f018f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -450,4 +450,8 @@ public class ImageManager {
return "subsystems/control/Operation_16.png";
}
+ public static String getActivityPackageLargeIcon() {
+ return "subsystems/content/Package_24.png";
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index c3ab5a5..7be3753 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -30,6 +30,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEven
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupPkgHistoryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.FavoriteResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
@@ -102,6 +103,7 @@ public class PortletFactory {
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupPkgHistoryPortlet.KEY, GroupPkgHistoryPortlet.Factory.INSTANCE);
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
@@ -111,6 +113,7 @@ public class PortletFactory {
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.NAME);
+ registeredGroupPortletNameMap.put(GroupPkgHistoryPortlet.KEY, GroupPkgHistoryPortlet.NAME);
//############## Resource Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
@@ -128,6 +131,7 @@ public class PortletFactory {
registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedLargeIcon());
registeredPortletIconMap.put(GroupEventsPortlet.KEY, ImageManager.getEventLargeIcon());
registeredPortletIconMap.put(GroupOperationsPortlet.KEY, ImageManager.getOperationLargeIcon());
+ registeredPortletIconMap.put(GroupPkgHistoryPortlet.KEY, ImageManager.getActivityPackageLargeIcon());
}
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
index 24f31b5..75710a8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
@@ -36,6 +36,8 @@ import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.events.DragResizeStopEvent;
import com.smartgwt.client.widgets.events.DragResizeStopHandler;
+import com.smartgwt.client.widgets.events.MouseOverEvent;
+import com.smartgwt.client.widgets.events.MouseOverHandler;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.dashboard.DashboardPortlet;
@@ -57,6 +59,7 @@ public class PortletWindow extends LocatableWindow {
// A reference to the stored/persisted DashboardPortlet, so changes made to this will
// get persisted when the dashboard is persisted.
private DashboardPortlet storedPortlet;
+ private HeaderControl headerIcon;
// The actual portlet content view
private Portlet view;
@@ -118,12 +121,18 @@ public class PortletWindow extends LocatableWindow {
RssHeader.setTooltip(RSS);
//detect customized Header icon
- HeaderControl headerIcon = null;
+ headerIcon = null;
String portletKey = storedPortlet.getPortletKey();
- String iconUrl = PortletFactory.getRegisteredPortletIcon(portletKey);
+ final String iconUrl = PortletFactory.getRegisteredPortletIcon(portletKey);
if ((iconUrl != null) && (!iconUrl.trim().isEmpty())) {
HeaderIcon icon = new HeaderIcon(iconUrl);
headerIcon = new HeaderControl(icon);
+ headerIcon.addMouseOverHandler(new MouseOverHandler() {
+ @Override
+ public void onMouseOver(MouseOverEvent event) {
+ headerIcon.setIcon(iconUrl);
+ }
+ });
}
// customize the appearance and order of the controls in the window header
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java
new file mode 100644
index 0000000..f93d418
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java
@@ -0,0 +1,303 @@
+/*
+ * 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.dashboard.portlets.groups;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+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.LinkItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.content.InstalledPackageHistory;
+import org.rhq.core.domain.criteria.InstalledPackageHistoryCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+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.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+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.dashboard.portlets.PortletConfigurationEditorComponent;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**This portlet allows the end user to customize the Package History display
+ *
+ * @author Simeon Pinder
+ */
+public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
+
+ private int groupId = -1;
+ protected LocatableCanvas recentPkgHistoryContent = new LocatableCanvas(extendLocatorId("RecentPkgHistory"));
+ private boolean currentlyLoading = false;
+ private Configuration portletConfig = null;
+ private DashboardPortlet storedPortlet;
+
+ public GroupPkgHistoryPortlet(String locatorId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentGroupIdentifier = Integer.valueOf(elements[1]);
+ this.groupId = currentGroupIdentifier;
+ initializeUi();
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentPkgHistoryContent);
+ }
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupPackageHistory";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_pkg_hisory();
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+ //instance ui widgets
+
+ private Timer refreshTimer;
+
+ private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
+ }
+
+ /** Responsible for initialization and lazy configuration of the portlet values
+ */
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ //populate portlet configuration details
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+ this.storedPortlet = storedPortlet;
+ portletConfig = storedPortlet.getConfiguration();
+
+ //lazy init any elements not yet configured.
+ for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if ((portletConfig.getSimple(key) == null) && CONFIG_INCLUDE.contains(key)) {
+ portletConfig.put(new PropertySimple(key,
+ PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
+ }
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_pkg_history());
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new GroupPkgHistoryPortlet(locatorId);
+ }
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentPkgHistory();
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+ LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings"));
+ LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page"));
+ //build editor form container
+ final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("pkg-history"));
+ form.setMargin(5);
+ //add result count selector
+ final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+ form.setItems(resultCountSelector);
+
+ //submit handler
+ customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+
+ //results count
+ portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
+
+ //persist
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ loadData();
+ }
+
+ });
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
+ /** Fetches recent package history information and updates the DynamicForm instance with details.
+ */
+ private void getRecentPkgHistory() {
+ final int groupId = this.groupId;
+ InstalledPackageHistoryCriteria criteria = new InstalledPackageHistoryCriteria();
+
+ int resultCount = 5;//default to
+ //result count
+ PropertySimple property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ resultCount = 5;
+ } else {
+ resultCount = Integer.valueOf(currentSetting);
+ }
+ }
+ PageControl pageControl = new PageControl(0, resultCount);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceGroupIds(groupId);
+
+ criteria.addSortStatus(PageOrdering.DESC);
+
+ GWTServiceLookup.getContentService().findInstalledPackageHistoryByCriteria(criteria,
+
+ new AsyncCallback<PageList<InstalledPackageHistory>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed package history for group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<InstalledPackageHistory> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (InstalledPackageHistory history : result) {
+ LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ .extendLocatorId(history.getPackageVersion().getFileName()
+ + history.getPackageVersion().getVersion()));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(
+ "subsystems/content/Package_16.png", null);
+ String title = history.getPackageVersion().getFileName() + ":";
+ String destination = "/rhq/resource/content/audit-trail-item.xhtml?id=" + groupId
+ + "&selectedHistoryId=" + history.getId();
+ LinkItem link = AbstractActivityView.newLinkItem(title, destination);
+ StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter
+ .format(history.getTimestamp()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ // //insert see more link
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ // .extendLocatorId("PkgHistoryContentSeeMore"));
+ // String destination = "/rhq/resource/content/audit-trail-item.xhtml?id=" + groupId;
+ // addSeeMoreLink(row, destination, column);
+ } else {
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentPkgHistoryContent
+ .extendLocatorId("None"), MSG.view_portlet_results_empty());
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentPkgHistoryContent.getChildren()) {
+ child.destroy();
+ }
+ recentPkgHistoryContent.addChild(column);
+ recentPkgHistoryContent.markForRedraw();
+ markForRedraw();
+ }
+ });
+ }
+
+ @Override
+ public void startRefreshCycle() {
+ //current setting
+ final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+
+ //cancel any existing timer
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ if (refreshInterval >= MeasurementUtility.MINUTES) {
+
+ refreshTimer = new Timer() {
+ public void run() {
+ if (!currentlyLoading) {
+ loadData();
+ redraw();
+ }
+ }
+ };
+
+ refreshTimer.scheduleRepeating(refreshInterval);
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (refreshTimer != null) {
+
+ refreshTimer.cancel();
+ }
+ super.onDestroy();
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+ loadData();
+ }
+
+}
\ No newline at end of file
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 63a07c0..9185fb4 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
@@ -1458,6 +1458,7 @@ view_portlet_defaultName_tagCloud = Tag Count
view_portlet_defaultName_group_events = Group: Event Counts
view_portlet_defaultName_group_metrics = Group: Metrics
view_portlet_defaultName_group_operations = Group: Operations
+view_portlet_defaultName_group_pkg_hisory = Group: Package History
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
@@ -1470,6 +1471,7 @@ view_portlet_help_message = This portlet displays a static HTML message. The <i>
view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions.
view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory.
view_portlet_help_operations_criteria = This portlet displays Operations consistent with display criteria configured.
+view_portlet_help_pkg_history = This portlet relevant package history based on display criteria configured.
view_portlet_help_platformSummary = This portlet displays information about the current user''s platform resources.
view_portlet_help_problemResources = This portlet displays the current user''s alerted or unavailable resources.
view_portlet_help_recentAlerts = This portlet displays alerts recently fired on the current user''s viewable inventory.
13 years, 3 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java | 33 +++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java | 39 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java | 3
3 files changed, 58 insertions(+), 17 deletions(-)
New commits:
commit 5b1659cbb5c33262b3893268f880ce410574b482
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 16 18:16:30 2011 -0400
Ancestry (Disambiguation) Work
- Added ancestry to ResourceLookupComboBox (e.g. GraphPortlet config, resource selection)
- Slight change to type formatting and public util added to get formatted Type string
- Tweaked OverviewForm to use new util for consistent Type presentation
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java
index 85e2d3c..2d3692c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java
@@ -25,10 +25,14 @@ package org.rhq.enterprise.gui.coregui.client.components.lookup;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.TextMatchStyle;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
/**
@@ -39,21 +43,40 @@ public class ResourceLookupComboBoxItem extends ComboBoxItem {
public ResourceLookupComboBoxItem(String name, String title) {
super(name, title);
- setWidth(300);
- setHint("resource search");
+ setHint(MSG.widget_resourceSelector_selectResource());
setShowHintInField(false);
setOptionDataSource(new ResourceDatasource());
ListGridField nameField = new ListGridField("name", MSG.common_title_name(), 250);
+ nameField.setShowHover(true);
+ nameField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+
+ ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry(),
+ 300);
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryValue(listGridRecord, false);
+ }
+ });
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+
ListGridField descriptionField = new ListGridField("description", MSG.common_title_description());
- ListGridField typeNameField = new ListGridField("typeName", MSG.common_title_type(), 130);
- ListGridField pluginNameField = new ListGridField("pluginName", MSG.common_title_plugin(), 100);
ListGridField categoryField = new ListGridField("category", MSG.common_title_category(), 60);
ListGridField availabilityField = new ListGridField("currentAvailability", MSG.common_title_availability(), 55);
availabilityField.setAlign(Alignment.CENTER);
- setPickListFields(nameField, descriptionField, typeNameField, pluginNameField, categoryField, availabilityField);
+ setPickListFields(nameField, ancestryField, descriptionField, categoryField, availabilityField);
setValueField("id");
setDisplayField("name");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
index e4af271..b7734c4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
@@ -115,9 +115,7 @@ public abstract class AncestryUtil {
}
ResourceType rt = types.get(ancestorTypeId);
sbTypes.append(href);
- sbTypes.append(" [" + rt.getPlugin() + " / ");
- sbTypes.append(rt.getName());
- sbTypes.append("]");
+ addFormattedType(sbTypes, rt);
}
}
@@ -129,7 +127,24 @@ public abstract class AncestryUtil {
return result;
}
+ public static String getFormattedType(ResourceType type) {
+ return addFormattedType(new StringBuilder(), type).toString();
+ }
+
+ private static StringBuilder addFormattedType(StringBuilder sb, ResourceType type) {
+ sb.append(" [<i>");
+ sb.append(type.getPlugin());
+ sb.append("</i>, ");
+ sb.append(type.getName());
+ sb.append("]");
+ return sb;
+ }
+
public static String getAncestryValue(Record record) {
+ return getAncestryValue(record, true);
+ }
+
+ public static String getAncestryValue(Record record, boolean generateLinks) {
String ancestry = record.getAttributeAsString(RESOURCE_ANCESTRY);
if (null == ancestry) {
return "";
@@ -146,10 +161,14 @@ public abstract class AncestryUtil {
String ancestorName = entryTokens[2];
sbResources.append((i > 0) ? " < " : "");
- String url = LinkManager.getResourceLink(ancestorResourceId);
- String suffix = resourceId + "_" + entryTokens[1];
- String href = SeleniumUtility.getLocatableHref(url, ancestorName, suffix);
- sbResources.append(href);
+ if (generateLinks) {
+ String url = LinkManager.getResourceLink(ancestorResourceId);
+ String suffix = resourceId + "_" + entryTokens[1];
+ String href = SeleniumUtility.getLocatableHref(url, ancestorName, suffix);
+ sbResources.append(href);
+ } else {
+ sbResources.append(ancestorName);
+ }
}
return sbResources.toString();
@@ -218,15 +237,13 @@ public abstract class AncestryUtil {
}
private static String getResourceLongName(String resourceName, ResourceType type) {
- StringBuffer sb = new StringBuffer("<b>");
+ StringBuilder sb = new StringBuilder("<b>");
sb.append(resourceName);
sb.append("</b>");
if (type != null) {
- sb.append(" [" + type.getPlugin() + " / ");
- sb.append(type.getName());
- sb.append("]");
+ addFormattedType(sb, type);
}
return sb.toString();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java
index 5720661..3cecbe9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidat
import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem.ValueEditedHandler;
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.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -149,7 +150,7 @@ public class OverviewForm extends EnhancedDynamicForm {
StaticTextItem typeItem = new StaticTextItem("type", MSG.view_summaryOverviewForm_field_type());
typeItem.setTooltip(MSG.view_summaryOverviewForm_label_plugin() + type.getPlugin() + "\n<br>"
+ MSG.view_summaryOverviewForm_label_type() + type.getName());
- typeItem.setValue(type.getName() + " (" + type.getPlugin() + ")");
+ typeItem.setValue(AncestryUtil.getFormattedType(type));
formItems.add(typeItem);
final Resource resource = this.resourceComposite.getResource();
13 years, 3 months
[rhq] modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java | 47 +++++++---
1 file changed, 35 insertions(+), 12 deletions(-)
New commits:
commit 8a4b075dbb23c09759ea64db09346e6f80bd7328
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 16 16:39:13 2011 -0400
BZ 534186 - be able to discover new resources from children deep in the hierarchy
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
index b90a1ae..e1b8d85 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
@@ -46,8 +46,6 @@ import org.rhq.core.pc.plugin.PluginComponentFactory;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
-import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
import org.rhq.core.util.exception.ExceptionPackage;
import org.rhq.core.util.exception.Severity;
@@ -138,15 +136,37 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep
// Discover platform services here
discoverForResource(platform, report, false);
- // Next discover all other services and non-top-level servers
- Set<Resource> servers = new HashSet<Resource>(platform.getChildResources()); // prevent concurrent mod
- for (Resource server : servers) {
- discoverForResource(server, report, false);
- }
+ // Next discover all other services and non-top-level servers, recursively down the hierarchy
+ discoverForResourceRecursive(platform, report);
} else {
// Run a single scan for just a resource and its descendants
discoverForResource(resource, report, false);
}
+
+ return;
+ }
+
+ private void discoverForResourceRecursive(Resource parent, InventoryReport report) throws PluginContainerException {
+ Set<Resource> children = parent.getChildResources();
+ if (children != null && !children.isEmpty()) {
+ Set<Resource> childrenCopy = new HashSet<Resource>(children); // prevent concurrent mod
+ for (Resource child : childrenCopy) {
+ // See if the child has new children itself. Then we check those children to see if there are grandchildren.
+ // Note that if the child has already been added to the report, there is no need to process it again, so skip it.
+ boolean alreadyProcessed = report.getAddedRoots().contains(child);
+ if (!alreadyProcessed) {
+ discoverForResource(child, report, alreadyProcessed);
+ // We need to recurse here even though discoverForResource recurses over child, too.
+ // This is because that discovery above only goes over newly discovered resources.
+ // It is possible this child has already existing children (e.g. previously manually added)
+ // that they themselves might have additional new children that need discovering.
+ discoverForResourceRecursive(child, report);
+ }
+ }
+ childrenCopy.clear(); // help GC
+ childrenCopy = null;
+ }
+ return;
}
/**
@@ -214,9 +234,8 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep
return;
}
- PluginComponentFactory factory = PluginContainer.getInstance().getPluginComponentFactory();
-
// For each child resource type of the server, do a discovery for resources of that type
+ PluginComponentFactory factory = PluginContainer.getInstance().getPluginComponentFactory();
for (ResourceType childResourceType : parent.getResourceType().getChildResourceTypes()) {
try {
// Make sure we have a discovery component for that type, otherwise there is nothing to do
@@ -240,8 +259,8 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep
+ childResourceType + "]");
}
Set<Resource> childResources = this.inventoryManager.executeComponentDiscovery(childResourceType,
- discoveryComponent, parentContainer, Collections.<ProcessScanResult>emptyList());
-
+ discoveryComponent, parentContainer, Collections.<ProcessScanResult> emptyList());
+
// For each discovered resource, update it in the inventory manager and recursively discover its child resources
Map<String, Resource> mergedResources = new HashMap<String, Resource>();
@@ -263,12 +282,14 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep
log.error("Error in runtime discovery", t);
}
}
+
+ return;
}
// TODO: Move this to InventoryManager, so it can be used by AutoDiscoveryExecutor too.
private void removeStaleResources(Resource parent, ResourceType childResourceType,
Map<String, Resource> mergedResources) {
- Set<Resource> existingChildResources = new HashSet(parent.getChildResources()); // wrap in new HashSet to avoid CMEs
+ Set<Resource> existingChildResources = new HashSet<Resource>(parent.getChildResources()); // wrap in new HashSet to avoid CMEs
for (Resource existingChildResource : existingChildResources) {
// NOTE: If inside Agent, only remove Resources w/ id == 0. Other Resources may still exist in the
// the Server's inventory.
@@ -279,5 +300,7 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep
this.inventoryManager.removeResourceAndIndicateIfScanIsNeeded(existingChildResource);
}
}
+ existingChildResources.clear(); // help GC
+ existingChildResources = null;
}
}
\ No newline at end of file
13 years, 3 months
[rhq] 20 commits - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java | 43 +++++++++-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java | 14 ++-
2 files changed, 53 insertions(+), 4 deletions(-)
New commits:
commit defe8a2fe8aaacc024776145691985f2343c3bf6
Merge: c4c7312 d3576dd
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Mar 16 16:09:15 2011 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit c4c7312b991b6e1a13a60dfe29c425e9f15ff093
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 16 15:25:43 2011 -0400
Ancestry (Disambiguation) Work
- Added Ancestry to group operations serial execution ordering
- ReorderableList now allows for a nameHoverCustomizer to be provided
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java
index e313835..7e06b20 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java
@@ -24,9 +24,9 @@ import java.util.List;
import java.util.Set;
import com.google.gwt.event.shared.HandlerRegistration;
-import com.smartgwt.client.types.Cursor;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordDropEvent;
@@ -56,12 +56,19 @@ public class ReorderableList extends LocatableVLayout {
private boolean isReadOnly;
+ private HoverCustomizer nameHoverCustomizer;
+
public ReorderableList(String locatorId, ListGridRecord[] records, String itemTitle, String itemIcon) {
- this(locatorId, false, records, itemTitle, itemIcon);
+ this(locatorId, false, records, itemTitle, itemIcon, null);
+ }
+
+ public ReorderableList(String locatorId, ListGridRecord[] records, String itemTitle, String itemIcon,
+ HoverCustomizer nameHoverCustomizer) {
+ this(locatorId, false, records, itemTitle, itemIcon, nameHoverCustomizer);
}
public ReorderableList(String locatorId, boolean isReadOnly, ListGridRecord[] records, String itemTitle,
- String itemIcon) {
+ String itemIcon, HoverCustomizer nameHoverCustomizer) {
super(locatorId);
this.isReadOnly = isReadOnly;
@@ -80,6 +87,8 @@ public class ReorderableList extends LocatableVLayout {
this.itemTitle = itemTitle;
this.itemIcon = itemIcon;
+
+ this.nameHoverCustomizer = nameHoverCustomizer;
}
/**
@@ -126,6 +135,10 @@ public class ReorderableList extends LocatableVLayout {
fields.add(iconField);
}
ListGridField nameField = new ListGridField(getNameField(), this.nameFieldTitle);
+ if (null != this.nameHoverCustomizer) {
+ nameField.setShowHover(true);
+ nameField.setHoverCustomizer(this.nameHoverCustomizer);
+ }
fields.add(nameField);
this.listGrid.setFields(fields.toArray(new ListGridField[fields.size()]));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
index 832acfe..843be1d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
@@ -1,5 +1,10 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
@@ -11,9 +16,11 @@ import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
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.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
@@ -21,14 +28,10 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
import org.rhq.enterprise.gui.coregui.client.components.sorter.ReorderableList;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-
/**
* The details view of the Group Operations>Schedules subtab.
*
@@ -47,8 +50,8 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
private ReorderableList memberExecutionOrderer;
public GroupOperationScheduleDetailsView(String locatorId, ResourceGroupComposite groupComposite, int scheduleId) {
- super(locatorId, new GroupOperationScheduleDataSource(groupComposite),
- groupComposite.getResourceGroup().getResourceType(), scheduleId);
+ super(locatorId, new GroupOperationScheduleDataSource(groupComposite), groupComposite.getResourceGroup()
+ .getResourceType(), scheduleId);
this.groupComposite = groupComposite;
}
@@ -61,8 +64,8 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
protected void init(final boolean isReadOnly) {
if (isNewRecord()) {
ResourceDatasource resourceDatasource = new ResourceDatasource();
- Criteria criteria = new Criteria(ResourceDatasource.FILTER_GROUP_ID,
- String.valueOf(this.groupComposite.getResourceGroup().getId()));
+ Criteria criteria = new Criteria(ResourceDatasource.FILTER_GROUP_ID, String.valueOf(this.groupComposite
+ .getResourceGroup().getId()));
resourceDatasource.fetchData(criteria, new DSCallback() {
public void execute(DSResponse response, Object rawData, DSRequest request) {
if (response.getStatus() != DSResponse.STATUS_SUCCESS) {
@@ -94,8 +97,8 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
this.executionModeForm.setNumCols(2);
this.executionModeForm.setColWidths(FIRST_COLUMN_WIDTH, "*");
- RadioGroupItem executionModeItem = new RadioGroupItem(FIELD_EXECUTION_MODE,
- MSG.view_group_operationScheduleDetails_field_execute());
+ RadioGroupItem executionModeItem = new RadioGroupItem(FIELD_EXECUTION_MODE, MSG
+ .view_group_operationScheduleDetails_field_execute());
LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(2);
valueMap.put(EXECUTION_ORDER_PARALLEL, MSG.view_group_operationScheduleDetails_value_parallel());
valueMap.put(EXECUTION_ORDER_SEQUENTIAL, MSG.view_group_operationScheduleDetails_value_sequential());
@@ -104,7 +107,7 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
executionModeItem.setShowTitle(true);
final CheckboxItem haltOnFailureItem = new CheckboxItem(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE,
- MSG.view_group_operationScheduleDetails_field_haltOnFailure());
+ MSG.view_group_operationScheduleDetails_field_haltOnFailure());
haltOnFailureItem.setDefaultValue(false);
haltOnFailureItem.setVisible(false);
haltOnFailureItem.setLabelAsTitle(true);
@@ -120,8 +123,13 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
hLayout.addMember(horizontalSpacer);
ResourceCategory resourceCategory = this.groupComposite.getResourceGroup().getResourceType().getCategory();
String memberIcon = ImageManager.getResourceIcon(resourceCategory);
+ HoverCustomizer nameHoverCustomizer = new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ };
this.memberExecutionOrderer = new ReorderableList(extendLocatorId("MemberExecutionOrderer"),
- this.memberResourceRecords, null, memberIcon);
+ this.memberResourceRecords, null, memberIcon, nameHoverCustomizer);
this.memberExecutionOrderer.setVisible(false);
this.memberExecutionOrderer.setNameFieldTitle(MSG.view_group_operationScheduleDetails_memberResource());
hLayout.addMember(this.memberExecutionOrderer);
@@ -144,22 +152,24 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
@Override
protected void editExistingRecord(Record record) {
- List<Resource> executionOrder =
- (List<Resource>) record.getAttributeAsObject(GroupOperationScheduleDataSource.Field.EXECUTION_ORDER);
+ List<Resource> executionOrder = (List<Resource>) record
+ .getAttributeAsObject(GroupOperationScheduleDataSource.Field.EXECUTION_ORDER);
if (executionOrder != null) {
this.executionModeForm.setValue(FIELD_EXECUTION_MODE, EXECUTION_ORDER_SEQUENTIAL);
ResourceDatasource resourceDatasource = new ResourceDatasource();
ListGridRecord[] resourceRecords = resourceDatasource.buildRecords(executionOrder);
this.memberExecutionOrderer.setRecords(resourceRecords);
this.memberExecutionOrderer.show();
- FormItem haltOnFailureItem = executionModeForm.getField(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
+ FormItem haltOnFailureItem = executionModeForm
+ .getField(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
haltOnFailureItem.show();
} else {
this.executionModeForm.setValue(FIELD_EXECUTION_MODE, EXECUTION_ORDER_PARALLEL);
}
Object haltOnFailure = getForm().getValue(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
- FormItem haltOnFailureItem = this.executionModeForm.getField(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
+ FormItem haltOnFailureItem = this.executionModeForm
+ .getField(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
haltOnFailureItem.setValue(haltOnFailure);
super.editExistingRecord(record);
@@ -177,9 +187,11 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
} else {
executionOrder = null;
}
- requestProperties.setAttribute(GroupOperationScheduleDataSource.RequestProperty.EXECUTION_ORDER, executionOrder);
+ requestProperties
+ .setAttribute(GroupOperationScheduleDataSource.RequestProperty.EXECUTION_ORDER, executionOrder);
- Boolean haltOnFailure = (Boolean) this.executionModeForm.getValue(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
+ Boolean haltOnFailure = (Boolean) this.executionModeForm
+ .getValue(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
getForm().setValue(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE, haltOnFailure);
super.save(requestProperties);
commit 0d25d072f7d4cf0afce6ec97ecfec80f5463531f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 16 14:17:36 2011 -0400
Ancestry (Disambiguation) Work
- Incorporate Ancestry into Favorites Button
- add some missing I18N to AncestryUtil
- add basic ancestry hover text for platforms
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 b255002..ba5e649 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
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.footer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -34,6 +35,7 @@ import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
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.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
@@ -42,6 +44,9 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
/**
@@ -117,114 +122,184 @@ public class FavoritesButton extends LocatableIMenuButton {
CoreGUI.getErrorHandler().handleError(MSG.view_dashboard_favorites_error1(), caught);
}
- public void onSuccess(Favorites favorites) {
- // generate the menus
- if (!favoriteResourceIds.isEmpty()) {
- List<MenuItem> items = new ArrayList<MenuItem>(favoriteResourceIds.size());
+ public void onSuccess(final Favorites favorites) {
+ // For Ancestry we need all the resource types and ancestry resource types loaded
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (Resource resource : favorites.resources) {
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
- for (final Integer resourceId : favoriteResourceIds) {
- Resource resource = favorites.getResource(resourceId);
- if (null == resource) {
- // if the resource is gone just skip it
- continue;
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]),
+ new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ // generate the menus
+ buildFavoriteResourcesMenu(favorites, favoriteResourcesMenu, favoriteResourceIds,
+ typesWrapper);
+ buildFavoriteGroupsMenu(favorites, favoriteGroupsMenu, favoriteGroupIds);
+ buildRecentlyViewedMenu(favorites, recentlyViewedMenu, recentResourceIds,
+ recentGroupIds, typesWrapper);
+
+ favoritesMenu.showContextMenu();
}
+ });
+ }
+ });
+ }
+ });
+ }
- MenuItem item = new MenuItem(String.valueOf(resourceId));
- // TODO: Ideally, we should use ResourceManagerLocal.disambiguate() here to obtain
- // disambiguated Resource names.
- item.setTitle(resource.getName());
- item.setIcon(ImageManager.getResourceIcon(resource));
- item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
- }
- });
- items.add(item);
- }
- favoriteResourcesMenu.setItems(items.toArray(new MenuItem[items.size()]));
- }
+ private void buildFavoriteResourcesMenu(Favorites favorites, Menu menu, Set<Integer> resourceIds,
+ AncestryUtil.MapWrapper typesWrapper) {
- if (!favoriteGroupIds.isEmpty()) {
- List<MenuItem> items = new ArrayList<MenuItem>(favoriteGroupIds.size());
+ if (resourceIds.isEmpty()) {
+ menu.setItems();
+ return;
+ }
- for (final Integer groupId : favoriteGroupIds) {
- ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
- if (null == groupComposite) {
- // if the resource group is gone just skip it
- continue;
- }
- ResourceGroup group = groupComposite.getResourceGroup();
-
- MenuItem item = new MenuItem(String.valueOf(groupId));
- item.setTitle(group.getName());
- item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite
- .getImplicitAvail()));
-
- item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceGroupLink(groupId));
- }
- });
- items.add(item);
- }
- favoriteGroupsMenu.setItems(items.toArray(new MenuItem[items.size()]));
- }
+ List<MenuItem> items = new ArrayList<MenuItem>(resourceIds.size());
- if (!(recentResourceIds.isEmpty() && recentGroupIds.isEmpty())) {
- List<MenuItem> items = new ArrayList<MenuItem>(recentResourceIds.size()
- + recentGroupIds.size());
+ for (final Integer resourceId : resourceIds) {
+ Resource resource = favorites.getResource(resourceId);
+ if (null == resource) {
+ // if the resource is gone just skip it
+ continue;
+ }
- for (final Integer resourceId : recentResourceIds) {
- Resource resource = favorites.getResource(resourceId);
- if (null == resource) {
- // if the resource is gone just skip it
- continue;
- }
+ MenuItem item = new MenuItem(resource.getName());
+ item.setIcon(ImageManager.getResourceIcon(resource));
+
+ // build a subMenu to display a disambiguated resource
+ item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId);
+ item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+ item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+ Menu ancestryMenu = new Menu();
+ MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, 0));
+ ancestryItem.setEnabled(false);
+ ancestryMenu.setItems(ancestryItem);
+ item.setSubmenu(ancestryMenu);
+
+ item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
+ }
+ });
- MenuItem item = new MenuItem(String.valueOf(resourceId));
- // TODO: Ideally, we should use ResourceManagerLocal.disambiguate() here to obtain
- // disambiguated Resource names.
- item.setTitle(resource.getName());
- item.setIcon(ImageManager.getResourceIcon(resource));
- item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
- }
- });
- items.add(item);
- }
- if (!recentResourceIds.isEmpty() && !recentGroupIds.isEmpty()) {
- items.add(new MenuItemSeparator());
- }
- for (final Integer groupId : recentGroupIds) {
- ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
- if (null == groupComposite) {
- // if the resource group is gone just skip it
- continue;
- }
- ResourceGroup group = groupComposite.getResourceGroup();
-
- MenuItem item = new MenuItem(String.valueOf(groupId));
- item.setTitle(group.getName());
- item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite
- .getImplicitAvail()));
-
- item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceGroupLink(groupId));
- }
- });
- items.add(item);
- }
+ items.add(item);
+ }
- recentlyViewedMenu.setItems(items.toArray(new MenuItem[items.size()]));
- }
+ menu.setCanSelectParentItems(Boolean.TRUE);
+ menu.setItems(items.toArray(new MenuItem[items.size()]));
+ }
- favoritesMenu.showContextMenu();
- }
- });
+ private void buildFavoriteGroupsMenu(Favorites favorites, Menu menu, Set<Integer> groupIds) {
+
+ if (groupIds.isEmpty()) {
+ menu.setItems();
+ return;
+ }
+
+ List<MenuItem> items = new ArrayList<MenuItem>(groupIds.size());
+
+ for (final Integer groupId : groupIds) {
+ ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
+ if (null == groupComposite) {
+ // if the resource group is gone just skip it
+ continue;
}
- });
+ ResourceGroup group = groupComposite.getResourceGroup();
+
+ MenuItem item = new MenuItem(String.valueOf(groupId));
+ item.setTitle(group.getName());
+ item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite.getImplicitAvail()));
+
+ item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ CoreGUI.goToView(LinkManager.getResourceGroupLink(groupId));
+ }
+ });
+ items.add(item);
+ }
+ menu.setItems(items.toArray(new MenuItem[items.size()]));
+ }
+
+ private void buildRecentlyViewedMenu(Favorites favorites, Menu menu, List<Integer> recentResourceIds,
+ List<Integer> recentGroupIds, AncestryUtil.MapWrapper typesWrapper) {
+
+ if (recentResourceIds.isEmpty() && recentGroupIds.isEmpty()) {
+ return;
+ }
+ List<MenuItem> items = new ArrayList<MenuItem>(recentResourceIds.size() + recentGroupIds.size() + 1);
+
+ for (final Integer resourceId : recentResourceIds) {
+ Resource resource = favorites.getResource(resourceId);
+ if (null == resource) {
+ // if the resource is gone just skip it
+ continue;
+ }
+
+ MenuItem item = new MenuItem(resource.getName());
+ item.setIcon(ImageManager.getResourceIcon(resource));
+
+ // build a subMenu to display a disambiguated resource
+ item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId);
+ item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+ item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ Menu ancestryMenu = new Menu();
+ MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, 0));
+ ancestryItem.setEnabled(false);
+ ancestryMenu.setItems(ancestryItem);
+ item.setSubmenu(ancestryMenu);
+
+ item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
+ }
+ });
+
+ items.add(item);
+ }
+
+ if (!recentResourceIds.isEmpty() && !recentGroupIds.isEmpty()) {
+ items.add(new MenuItemSeparator());
+ }
+
+ for (final Integer groupId : recentGroupIds) {
+ ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
+ if (null == groupComposite) {
+ // if the resource group is gone just skip it
+ continue;
+ }
+ ResourceGroup group = groupComposite.getResourceGroup();
+
+ MenuItem item = new MenuItem(String.valueOf(groupId));
+ item.setTitle(group.getName());
+ item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite.getImplicitAvail()));
+
+ item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ CoreGUI.goToView(LinkManager.getResourceGroupLink(groupId));
+ }
+ });
+ items.add(item);
+ }
+
+ menu.setCanSelectParentItems(Boolean.TRUE);
+ menu.setItems(items.toArray(new MenuItem[items.size()]));
}
private void fetchFavorites(Set<Integer> resourceIds, final Set<Integer> groupIds,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
index 33a5246..e4af271 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -36,7 +37,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Jay Shaughnessy
*/
public abstract class AncestryUtil {
-
// ListGrid Record attribute names expected to be set on records processed by the utility
public static final String RESOURCE_ANCESTRY = "resourceAncestry";
public static final String RESOURCE_ANCESTRY_VALUE = "resourceAncestryDecoded";
@@ -47,6 +47,9 @@ public abstract class AncestryUtil {
public static final String RESOURCE_NAME = "resourceName";
public static final String RESOURCE_TYPE_ID = "resourceTypeId";
+ private static final String TITLE_ANCESTRY = CoreGUI.getMessages().util_ancestry_parentAncestry() + " ";
+ private static final String TITLE_PLATFORM = CoreGUI.getMessages().common_title_platform() + ": ";
+
/**
* Get the complete set of resource types in the ancestries provided. This is useful for
* being able to load all the types in advance of generating decoded values.
@@ -158,11 +161,6 @@ public abstract class AncestryUtil {
return ancestryHover;
}
- String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
- if (null == ancestry) {
- return "";
- }
-
Integer resourceId = listGridRecord.getAttributeAsInt(RESOURCE_ID);
// if not set assume the standard "id" attr is a resourceId
resourceId = (null != resourceId) ? resourceId : listGridRecord.getAttributeAsInt("id");
@@ -174,38 +172,43 @@ public abstract class AncestryUtil {
Integer resourceTypeId = listGridRecord.getAttributeAsInt(RESOURCE_TYPE_ID);
ResourceType type = types.get(resourceTypeId);
String resourceLongName = getResourceLongName(resourceName, type);
+ String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
width = (width <= 0) ? 500 : width;
// decode ancestry
StringBuilder sb = new StringBuilder("<p style='width:");
sb.append(width);
- sb.append("px'>Parent Ancestry for: ");
+ sb.append("px'>");
+ String title = (null != ancestry) ? TITLE_ANCESTRY : TITLE_PLATFORM;
+ sb.append(title);
sb.append(resourceLongName);
- sb.append("<hr/>");
- String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
- for (int i = ancestryEntries.length - 1, j = 0; i >= 0; --i, ++j) {
- String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
- int ancestorTypeId = Integer.valueOf(entryTokens[0]);
- String ancestorName = entryTokens[2];
-
- // indent with spaces
- if (j > 0) {
- sb.append("<br/>");
- for (int k = 0; k < j; ++k) {
- sb.append(" ");
+ if (null != ancestry) {
+ sb.append("<hr/>");
+ String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
+ for (int i = ancestryEntries.length - 1, j = 0; i >= 0; --i, ++j) {
+ String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
+ int ancestorTypeId = Integer.valueOf(entryTokens[0]);
+ String ancestorName = entryTokens[2];
+
+ // indent with spaces
+ if (j > 0) {
+ sb.append("<br/>");
+ for (int k = 0; k < j; ++k) {
+ sb.append(" ");
+ }
}
+ type = types.get(ancestorTypeId);
+ sb.append(getResourceLongName(ancestorName, type));
}
- type = types.get(ancestorTypeId);
- sb.append(getResourceLongName(ancestorName, type));
- }
- // add target resource, indent with spaces
- sb.append("<br/>");
- for (int k = 0; k <= ancestryEntries.length; ++k) {
- sb.append(" ");
+ // add target resource, indent with spaces
+ sb.append("<br/>");
+ for (int k = 0; k <= ancestryEntries.length; ++k) {
+ sb.append(" ");
+ }
+ sb.append(resourceLongName);
}
- sb.append(resourceLongName);
sb.append("</p>");
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 2fe6caf..63a07c0 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
@@ -375,6 +375,10 @@ widget_durationItem_unitTypeNotSupported = Unit type [{0}] is not supported by t
#===================== Utils ======================
+# Ancestry
+#-------------------------------------------------
+util_ancestry_parentAncestry = Parent Ancestry for:
+
# Disambiguation Report Decorator
#-------------------------------------------------
util_disambiguationReportDecorator_pluginSuffix = ({0} plugin)
commit 22bb3e12be64dbefb221e63203ef8fe157b00579
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 16 10:07:51 2011 -0400
fix up skeleton plugin example. bump up version number and add the new manual add facet
diff --git a/etc/samples/skeleton-plugin/pom.xml b/etc/samples/skeleton-plugin/pom.xml
index 4e2d1b6..8055bc5 100644
--- a/etc/samples/skeleton-plugin/pom.xml
+++ b/etc/samples/skeleton-plugin/pom.xml
@@ -15,7 +15,7 @@
<description>A template for building a custom RHQ Agent plugin</description>
<properties>
- <rhq.version>3.0.0.B05</rhq.version>
+ <rhq.version>4.0.0-SNAPSHOT</rhq.version>
</properties>
<dependencies>
diff --git a/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java b/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java
index d49468f..2bb46e6 100644
--- a/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java
+++ b/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java
@@ -21,10 +21,14 @@ package org.rhq.sample.skeletonplugin;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -35,15 +39,50 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
*
* @author John Mazzitelli
*/
-public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponent {
+@SuppressWarnings("unchecked")
+public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
private final Log log = LogFactory.getLog(SamplePluginDiscoveryComponent.class);
/**
+ * This discovery method is the way the plugin supports "manual-add" capability. The plugin
+ * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
+ * If that attribute is false, this method will never be used since it will not be possible to manually
+ * add an instance of the resource.
+ *
+ * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
+ */
+ @Override
+ public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
+ ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
+
+ // pluginConfiguration contains information on a resource that was manually added by the user.
+ // take it and build a details object that represents that resource.
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Manually Added Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, pluginConfiguration, null);
+
+ return resource;
+ }
+
+ /**
* Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
* you need to do in this method.
*
* @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
*/
+ @Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
log.info("Discovering my custom plugin's resources");
@@ -54,12 +93,6 @@ public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponen
// determine if you want to include the result in this method's returned set of discovered resources
}
- List<Configuration> pluginConfigs = context.getPluginConfigurations();
- for (Configuration pluginConfig : pluginConfigs) {
- // pluginConfig contains information on a resource that was manually discovered/entered by the user
- // take it and build a details object that represents that resource
- }
-
// now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
// create a details object that describe the resource that you discovered.
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
diff --git a/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml b/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
index 3ed4e37..2547af7 100644
--- a/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
+++ b/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
@@ -29,6 +29,7 @@
<server name="Sample Plugin Server"
discovery="SamplePluginDiscoveryComponent"
class="SamplePluginServerComponent"
+ supportsManualAdd="true"
description="This is a sample resource type and should be removed.">
<!--
commit b88861bb1a91b6594b70d55b1cff1c94a346005e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Mar 15 16:49:27 2011 -0400
Ancestry (Disambiguation) Work
- Added Ancestry to Group traits Views
- added Resource filtering to Trait critria fetches
- changed to standard "Resource" column and removed obsolete I18N prop
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 102d598..d87097a 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
@@ -103,14 +103,19 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
long fetchDuration = System.currentTimeMillis() - startTime;
com.allen_sauer.gwt.log.client.Log.info(result.size() + " traits fetched in: " + fetchDuration + "ms");
- response.setData(buildRecords(result));
- // For paging to work, we have to specify size of full result set.
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
+ dataRetrieved(result, response, request);
}
});
}
+ protected void dataRetrieved(final PageList<MeasurementDataTrait> result, final DSResponse response,
+ final DSRequest request) {
+ response.setData(buildRecords(result));
+ // For paging to work, we have to specify size of full result set.
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
protected MeasurementDataTraitCriteria getCriteria(DSRequest request) {
MeasurementDataTraitCriteria criteria = new MeasurementDataTraitCriteria();
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 777cc74..152852e 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
@@ -18,16 +18,27 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
+import java.util.HashSet;
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.DataSourceField;
+import com.smartgwt.client.data.Record;
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;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
/**
* A DataSource for reading traits for the current group.
@@ -51,9 +62,13 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
fields.add(0, groupIdField);
DataSourceTextField resourceNameField = new DataSourceTextField(
- MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, MSG.dataSource_traits_group_field_memberResource());
+ MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, MSG.common_title_resource());
fields.add(0, resourceNameField);
+ DataSourceTextField ancestryField = new DataSourceTextField(AncestryUtil.RESOURCE_ANCESTRY, MSG
+ .common_title_ancestry());
+ fields.add(1, ancestryField);
+
return fields;
}
@@ -63,9 +78,50 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, this.groupId);
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, from.getSchedule().getResource()
- .getName());
+ // for ancestry handling
+ Resource resource = from.getSchedule().getResource();
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
return record;
}
+
+ protected void dataRetrieved(final PageList<MeasurementDataTrait> result, final DSResponse response,
+ final DSRequest request) {
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (MeasurementDataTrait trait : result) {
+ Resource resource = trait.getSchedule().getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
+ }
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
}
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
index 3c7f368..b374561 100644
--- 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
@@ -19,10 +19,17 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitListDetailView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* The detail view for the group Monitoring>Traits subtab.
@@ -40,12 +47,34 @@ public class TraitsDetailView extends AbstractMeasurementDataTraitListDetailView
ListGrid listGrid = getListGrid();
- // TODO (ips): Disambiguate Resource name.
ListGridField resourceNameField = listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME);
- resourceNameField.setWidth("20%");
+ resourceNameField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNameField.setShowHover(true);
+ resourceNameField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
resourceNameField.setCanGroupBy(true);
+ ListGridField ancestryField = listGrid.getField(AncestryUtil.RESOURCE_ANCESTRY);
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
}
private static Criteria createCriteria(int groupId, int definitionId) {
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 152c918..dfd3b38 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
@@ -21,11 +21,17 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.GroupStartOpen;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* The group Monitoring>Traits subtab.
@@ -48,11 +54,35 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
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.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNameField.setShowHover(true);
+ resourceNameField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
resourceNameField.setCanGroupBy(true);
+ ListGridField ancestryField = listGrid.getField(AncestryUtil.RESOURCE_ANCESTRY);
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+
super.configureTable();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
index 4c19c9d..7ff5d62 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
@@ -35,6 +35,7 @@ import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -266,8 +267,20 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
public PageList<MeasurementDataTrait> findTraitsByCriteria(MeasurementDataTraitCriteria criteria)
throws RuntimeException {
try {
- return SerialUtility.prepare(dataManager.findTraitsByCriteria(getSessionSubject(), criteria),
- "MeasurementDataService.findTraitsByCriteria");
+ PageList<MeasurementDataTrait> results = dataManager.findTraitsByCriteria(getSessionSubject(), criteria);
+ if (!results.isEmpty() && null != results.get(0).getSchedule()
+ && null != results.get(0).getSchedule().getResource()) {
+ List<Resource> resources = new ArrayList<Resource>(results.size());
+ for (MeasurementDataTrait result : results) {
+ Resource res = result.getSchedule().getResource();
+ if (null != res) {
+ resources.add(res);
+ }
+ }
+ ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet);
+ }
+
+ return SerialUtility.prepare(results, "MeasurementDataService.findTraitsByCriteria");
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
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 29d10d2..2fe6caf 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
@@ -460,7 +460,6 @@ dataSource_traits_field_definitionID = Definition ID
dataSource_traits_field_lastChanged = Last Changed
dataSource_traits_field_trait = Trait
dataSource_traits_group_field_groupId = Group ID
-dataSource_traits_group_field_memberResource = Member Resource
# Measurement OOBs
#---------------------------------
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 713ecee..242a76b 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -323,7 +323,6 @@ dataSource_traits_field_definitionID=Definition-ID
dataSource_traits_field_lastChanged=Zuletzt geändert
dataSource_traits_field_trait=Trait
dataSource_traits_group_field_groupId=Gruppen-ID
-dataSource_traits_group_field_memberResource=Mitglieds-Ressource
# Measurement OOBs
#---------------------------------
@@ -393,7 +392,6 @@ dataSource_operationHistory_error_fetchFailure = Konnte den Verlauf der Operatio
# Configuration History
#-------------------------------
dataSource_configurationHistory_field_id = ID
-dataSource_configurationHistory_field_resource = Ressource
dataSource_configurationHistory_field_createdTime = Angelegt
dataSource_configurationHistory_field_status = Status
dataSource_configurationHistory_field_subject = Benutzer
commit 8c774072f291e59d2b2382a376c14135a5b46d71
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 14:48:05 2011 -0400
removing bad filteroverride.
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 4d76880..c5a6be4 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
@@ -72,7 +72,6 @@ public abstract class OperationHistoryCriteria extends Criteria {
+ " WHERE roh.resource.id IN ( ? ) ) ");
filterOverrides.put("stati", "status IN ( ? )");
- filterOverrides.put("status", "status");
sortOverrides.put("startTime", "startedTime");
sortOverrides.put("endTime", "modifiedTime");
commit a29a95582591469a41091a2e776ab7e5c54f8969
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 13:52:58 2011 -0400
Forgot message.properties.
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 8178702..29d10d2 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
@@ -1514,7 +1514,7 @@ view_portlet_recentAlerts_fail_msg = Failed to load resources assigned for alert
view_portlet_recentlyAdded_setting_addedPlatforms = recently added platforms
view_portlet_recentlyAdded_error1 = Failed to load recently added resources
-
+view_portlet_results_empty = No results found using specified criteria.
# =================== Inventory =====================
view_inventory_adq = Discovery Queue
commit 819f5e738628becdb2a667660b8c10dd5e68e883
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 13:36:13 2011 -0400
missing i18n message.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
index 7ad5fba..16437f6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
@@ -362,7 +362,7 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
@Override
protected void onInit() {
super.onInit();
- getListGrid().setEmptyMessage("No results found using specified criteria.");
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
}
@Override
commit 75f1d281acbc13fae8c4a5ed471f40dc4c851797
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 13:31:38 2011 -0400
-fix OperationHistoryCriteria to tak multiple operation stati
-enable group operations portlet
-Operations Status select widget.
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 5f879ea..4d76880 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
@@ -22,12 +22,15 @@
*/
package org.rhq.core.domain.criteria;
+import java.util.List;
+
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.OperationHistory;
import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -42,6 +45,7 @@ public abstract class OperationHistoryCriteria extends Criteria {
private String filterJobName;
private String filterJobGroup;
private OperationRequestStatus filterStatus;
+ private List<OperationRequestStatus> filterStati; // requires overrides
private String filterErrorMessage;
private Integer filterOperationDefinitionId; // requires override
private String filterOperationName; // requires override
@@ -67,6 +71,9 @@ public abstract class OperationHistoryCriteria extends Criteria {
+ " FROM ResourceOperationHistory roh " //
+ " WHERE roh.resource.id IN ( ? ) ) ");
+ filterOverrides.put("stati", "status IN ( ? )");
+ filterOverrides.put("status", "status");
+
sortOverrides.put("startTime", "startedTime");
sortOverrides.put("endTime", "modifiedTime");
sortOverrides.put("operationName", "operationDefinition.name");
@@ -90,6 +97,10 @@ public abstract class OperationHistoryCriteria extends Criteria {
this.filterStatus = filterStatus;
}
+ public void addFilterStati(OperationRequestStatus... operationStatus) {
+ this.filterStati = CriteriaUtils.getListIgnoringNulls(operationStatus);
+ }
+
public void addFilterErrorMessage(String filterErrorMessage) {
this.filterErrorMessage = filterErrorMessage;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index 8b7cb0b..d4ffb3c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -441,4 +441,13 @@ public class ImageManager {
public static String getMonitorFailedLargeIcon() {
return "subsystems/monitor/Monitor_failed_24.png";
}
+
+ public static String getOperationLargeIcon() {
+ return "subsystems/control/Operation_24.png";
+ }
+
+ public static String getOperationIcon() {
+ return "subsystems/control/Operation_16.png";
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 85ef3db..c3ab5a5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -29,6 +29,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAler
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.FavoriteResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
@@ -100,6 +101,7 @@ public class PortletFactory {
registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.Factory.INSTANCE);
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
@@ -108,6 +110,7 @@ public class PortletFactory {
registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.NAME);
+ registeredGroupPortletNameMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.NAME);
//############## Resource Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
@@ -124,6 +127,7 @@ public class PortletFactory {
registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorLargeIcon());
registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedLargeIcon());
registeredPortletIconMap.put(GroupEventsPortlet.KEY, ImageManager.getEventLargeIcon());
+ registeredPortletIconMap.put(GroupOperationsPortlet.KEY, ImageManager.getOperationLargeIcon());
}
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
index e68b6cc..c02f378 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.widgets.form.fields.SelectItem;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
@@ -56,6 +57,7 @@ public class PortletConfigurationEditorComponent {
String RESULT_COUNT = "RESULT_COUNT";
String RESULT_COUNT_DEFAULT = "5";
String CUSTOM_REFRESH = "CUSTOM_REFRESH";
+ String OPERATION_STATUS = "OPERATION_STATUS";
}
//configuration map initialization
@@ -73,6 +75,8 @@ public class PortletConfigurationEditorComponent {
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_BEGIN_END_FLAG, String.valueOf(false));
//whether in simple mode. Ex. 8 hrs. Defaults to 8
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_LASTN, Constant.METRIC_RANGE_LASTN_DEFAULT);
+ //operation status, if empty initialize to "" i.e. all stati
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS, "");
}
/* Single select combobox for number of items to display on the dashboard
@@ -195,4 +199,78 @@ public class PortletConfigurationEditorComponent {
return new CustomConfigMeasurementRangeEditor("alertTimeFrame", portletConfig);
}
+ public static SelectItem getOperationStatusEditor(Configuration portletConfig) {
+ SelectItem priorityFilter = new SelectItem(Constant.OPERATION_STATUS, "Operation Status");
+ priorityFilter.setWrapTitle(false);
+ priorityFilter.setWidth(325);
+ priorityFilter.setMultiple(true);
+ priorityFilter.setMultipleAppearance(MultipleAppearance.PICKLIST);
+
+ LinkedHashMap<String, String> stati = new LinkedHashMap<String, String>(4);
+ stati.put(OperationRequestStatus.SUCCESS.name(), MSG.common_status_success());
+ stati.put(OperationRequestStatus.INPROGRESS.name(), MSG.common_status_inprogress());
+ stati.put(OperationRequestStatus.CANCELED.name(), MSG.common_status_canceled());
+ stati.put(OperationRequestStatus.FAILURE.name(), MSG.common_status_failed());
+
+ LinkedHashMap<String, String> statusIcons = new LinkedHashMap<String, String>(3);
+ statusIcons.put(OperationRequestStatus.SUCCESS.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.SUCCESS));
+ statusIcons.put(OperationRequestStatus.INPROGRESS.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.INPROGRESS));
+ statusIcons.put(OperationRequestStatus.CANCELED.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.CANCELED));
+ statusIcons.put(OperationRequestStatus.FAILURE.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.FAILURE));
+ priorityFilter.setValueMap(stati);
+ priorityFilter.setValueIcons(statusIcons);
+ //reload current settings if they exist, otherwise enable all.
+ String currentValue = portletConfig.getSimple(Constant.OPERATION_STATUS).getStringValue();
+ if (currentValue.isEmpty() || currentValue.split(",").length == OperationRequestStatus.values().length) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS.name(),
+ OperationRequestStatus.CANCELED.name(), OperationRequestStatus.FAILURE.name());
+ } else {
+ //spinder:3/4/11 doing this nonsense due to some weird smartgwt issue with SelectItem in VLayout.
+ if (currentValue.equalsIgnoreCase(OperationRequestStatus.SUCCESS.name())) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,CANCELED,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS
+ .name(), OperationRequestStatus.CANCELED.name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,CANCELED")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS
+ .name(), OperationRequestStatus.CANCELED.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS
+ .name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS
+ .name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,CANCELED,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.CANCELED.name(),
+ OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,CANCELED")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.CANCELED.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS")) {
+ priorityFilter.setValues(OperationRequestStatus.INPROGRESS.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,CANCELED,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.CANCELED
+ .name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,CANCELED")) {
+ priorityFilter.setValues(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.CANCELED
+ .name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.FAILURE
+ .name());
+ } else if (currentValue.equalsIgnoreCase("CANCELED")) {
+ priorityFilter.setValues(OperationRequestStatus.CANCELED.name());
+ } else if (currentValue.equalsIgnoreCase("CANCELED,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.CANCELED.name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.FAILURE.name());
+ }
+ }
+ return priorityFilter;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
index ee8cdd0..7ad5fba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
@@ -371,10 +371,7 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
if (getTableInfo() != null) {
int count = getListGrid().getSelection().length;
getTableInfo().setContents(
- // MSG.view_table_totalRows(String.valueOf(listGrid.getTotalRows()), String.valueOf(count)));
- //Ex. Total Rows: {0} (selected: {1})
- "Matching Rows: " + String.valueOf(getListGrid().getTotalRows()) + " (selected "
- + String.valueOf(count) + ")");
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
new file mode 100644
index 0000000..dd8187e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -0,0 +1,469 @@
+/*
+ * 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.dashboard.portlets.groups;
+
+import java.util.Arrays;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+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 org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.operation.GroupOperationHistory;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+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.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+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.dashboard.portlets.PortletConfigurationEditorComponent;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryDetailsView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Simeon Pinder
+ */
+public class GroupOperationsPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupOperations";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_operations();
+
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ private GroupOperationsCriteriaHistoryListView dataSource;
+
+ //instance ui widgets
+ private Canvas containerCanvas;
+
+ private Timer refreshTimer;
+ private DashboardPortlet storedPortlet;
+ private Configuration portletConfig;
+ private int groupId;
+ private boolean portletConfigInitialized = false;
+ private ResourceGroupComposite groupComposite;
+ private String baseViewPath = "";
+ protected LocatableCanvas recentOperationsContent = new LocatableCanvas(extendLocatorId("RecentOperations"));
+ private String locatorId;
+ private GroupOperationsCriteriaHistoryListView groupOperations;
+
+ public GroupOperationsPortlet(String locatorId) {
+ super(locatorId);
+ this.locatorId = locatorId;
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentGroupIdentifier = Integer.valueOf(elements[1]);
+ this.groupId = currentGroupIdentifier;
+ //populate basepath
+ baseViewPath = elements[0];
+
+ initializeUi();
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ private void loadData() {
+ //populate composite data
+ //locate resourceGroupRef
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(this.groupId);
+ criteria.fetchConfigurationUpdates(false);
+ criteria.fetchExplicitResources(false);
+ criteria.fetchGroupDefinition(false);
+ criteria.fetchOperationHistories(false);
+
+ // for autoclusters and autogroups we need to add more criteria
+ final boolean isAutoCluster = isAutoCluster();
+ final boolean isAutoGroup = isAutoGroup();
+ if (isAutoCluster) {
+ criteria.addFilterVisible(false);
+ } else if (isAutoGroup) {
+ criteria.addFilterVisible(false);
+ criteria.addFilterPrivate(true);
+ }
+
+ //locate the resource group
+ GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceGroupComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving resource group composite for group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceGroupComposite> results) {
+ if (!results.isEmpty()) {
+ groupComposite = results.get(0);
+ //instantiate view
+ //populated GWT criteria objects
+ Criteria criteria = new Criteria(GroupOperationHistoryDataSource.CriteriaField.GROUP_ID, String
+ .valueOf(groupComposite.getResourceGroup().getId()));
+
+ groupOperations = new GroupOperationsCriteriaHistoryListView(locatorId,
+ new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite);
+
+ //cleanup
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
+ }
+ recentOperationsContent.addChild(groupOperations);
+ recentOperationsContent.markForRedraw();
+ }
+ }
+ });
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ setHeight100();
+ setWidth100();
+ addMember(recentOperationsContent);
+ markForRedraw();
+ }
+
+ /** Responsible for initialization and lazy configuration of the portlet values
+ */
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ //populate portlet configuration details
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+ this.storedPortlet = storedPortlet;
+ portletConfig = storedPortlet.getConfiguration();
+
+ //lazy init any elements not yet configured.
+ for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if (portletConfig.getSimple(key) == null) {
+ portletConfig.put(new PropertySimple(key,
+ PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
+ }
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_operations_criteria());
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+ LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings"));
+ LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page"));
+ //build editor form container
+ final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("alert-filter"));
+ form.setMargin(5);
+
+ //add label about what configuration affects? redundant?
+
+ //add filter operation status type selector
+ final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
+ .getOperationStatusEditor(portletConfig);
+ //add sort priority selector
+ final SelectItem resultSortSelector = PortletConfigurationEditorComponent
+ .getResulSortOrderEditor(portletConfig);
+ //add result count selector
+ final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
+ //add range selector
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
+ .getMeasurementRangeEditor(portletConfig);
+
+ form.setItems(operationStatusSelector, resultSortSelector, resultCountSelector);
+
+ //submit handler
+ customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+
+ //result count
+ String selectedValue;
+ portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
+
+ //time range configuration
+ portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
+
+ //operation priority
+ portletConfig = AbstractActivityView.saveOperationStatusSelectorSettings(operationStatusSelector,
+ portletConfig);
+
+ //persist and reload portlet
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ //resynch the config object in the datasource
+ groupOperations.setDatasource(new GroupOperationsCriteriaDataSource(portletConfig));
+ //apply latest settings to the visible result set
+ redraw();
+ }
+ });
+ form.markForRedraw();
+ page.addMember(measurementRangeEditor);
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new GroupOperationsPortlet(locatorId);
+ }
+ }
+
+ @Override
+ public void startRefreshCycle() {
+ //current setting
+ final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+
+ //cancel any existing timer
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ if (refreshInterval >= MeasurementUtility.MINUTES) {
+
+ refreshTimer = new Timer() {
+ public void run() {
+ redraw();
+ }
+ };
+
+ refreshTimer.scheduleRepeating(refreshInterval);
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ super.onDestroy();
+ }
+
+ private boolean isAutoGroup() {
+ return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ private boolean isAutoCluster() {
+ return ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ public String getBaseViewPath() {
+ return baseViewPath;
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+ loadData();
+ }
+}
+
+/** Provide implementation of GroupOperationsHistoryListView using datasource
+ * that customizes fetch based on Configuration parameters.
+ *
+ * @author spinder
+ */
+class GroupOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView {
+
+ private AbstractOperationHistoryDataSource datasource;
+
+ public GroupOperationsCriteriaHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource,
+ String title, Criteria criteria, ResourceGroupComposite composite) {
+ super(locatorId, dataSource, title, criteria);
+ this.datasource = dataSource;
+ this.groupComposite = composite;
+ setShowFooterRefresh(false); //disable footer refresh
+ }
+
+ private ResourceGroupComposite groupComposite;
+
+ @Override
+ protected boolean hasControlPermission() {
+ return this.groupComposite.getResourcePermission().isControl();
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new GroupOperationHistoryDetailsView(extendLocatorId("DetailsView"), this.groupComposite);
+ }
+
+ public AbstractOperationHistoryDataSource getDatasource() {
+ return datasource;
+ }
+
+ public void setDatasource(AbstractOperationHistoryDataSource datasource) {
+ this.datasource = datasource;
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ }
+ }
+}
+
+/** Provide implementation of GroupOperationHistoryDataSource that dynamically
+ * configures fetch requests for this table view.
+ *
+ * @author spinder
+ */
+class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource {
+
+ public GroupOperationsCriteriaDataSource(Configuration portletConfig) {
+ this.portletConfig = portletConfig;
+ }
+
+ private Configuration portletConfig;
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_ID)) {
+ int groupId = Integer.parseInt((String) request.getCriteria().getValues().get(CriteriaField.GROUP_ID));
+ criteria.addFilterResourceGroupIds(Arrays.asList(groupId));
+ }
+
+ //initialize to only five for quick queries.
+ PageControl pageControl = new PageControl(0, 5);//default to displaying five
+ //customize query with latest configuration selections
+
+ //retrieve previous settings from portlet config
+ if (portletConfig != null) {
+ //result sort order
+ PropertySimple property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ criteria.addSortStatus(PageOrdering.DESC);
+ } else {
+ criteria.addSortStatus(PageOrdering.ASC);
+ }
+ }
+ //result timeframe if enabled
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ }
+
+ //result count
+ property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ pageControl.setPageSize(5);
+ } else {
+ pageControl = new PageControl(0, Integer.valueOf(currentSetting));
+ }
+ }
+ criteria.setPageControl(pageControl);
+
+ //detect operation status filter
+ property = portletConfig.getSimple(Constant.OPERATION_STATUS);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (currentSetting.trim().isEmpty() || parsedValues.length == OperationRequestStatus.values().length) {
+ //all operation stati assumed
+ } else {
+ OperationRequestStatus[] operationStati = new OperationRequestStatus[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ OperationRequestStatus s = OperationRequestStatus.valueOf(priority);
+ operationStati[indx++] = s;
+ }
+ criteria.addFilterStati(operationStati);
+ }
+ }
+ }
+
+ operationService.findGroupOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(), caught);
+ }
+
+ public void onSuccess(PageList<GroupOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index cda2a57..42e9880 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -43,6 +43,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceTypeFacet;
@@ -486,6 +487,25 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
/** Takes the current value of the widget and persists it into the configuration object passed in.
*
+ * @param operationStatusSelector
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ public static Configuration saveOperationStatusSelectorSettings(final SelectItem operationStatusSelector,
+ final Configuration portletConfig) {
+ String selectedValue;
+ selectedValue = operationStatusSelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty())
+ || (selectedValue.split(",").length == OperationRequestStatus.values().length)) {//then no operation status specified
+ portletConfig.put(new PropertySimple(Constant.OPERATION_STATUS, ""));
+ } else {//some subset of available alertPriorities will be used
+ portletConfig.put(new PropertySimple(Constant.OPERATION_STATUS, selectedValue));
+ }
+ return portletConfig;
+ }
+
+ /** Takes the current value of the widget and persists it into the configuration object passed in.
+ *
* @param measurementRangeEditor
* @param portletConfig
* returns populated configuration object.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
index 6a415c2..7edf2ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
+
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
@@ -32,9 +33,9 @@ public class GroupOperationHistoryListView extends AbstractOperationHistoryListV
private ResourceGroupComposite groupComposite;
public GroupOperationHistoryListView(String locatorId, ResourceGroupComposite groupComposite) {
- super(locatorId, new GroupOperationHistoryDataSource(), null,
- new Criteria(GroupOperationHistoryDataSource.CriteriaField.GROUP_ID,
- String.valueOf(groupComposite.getResourceGroup().getId())));
+ super(locatorId, new GroupOperationHistoryDataSource(), null, new Criteria(
+ GroupOperationHistoryDataSource.CriteriaField.GROUP_ID, String.valueOf(groupComposite.getResourceGroup()
+ .getId())));
this.groupComposite = groupComposite;
}
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 4dfcf51..8178702 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
@@ -1367,6 +1367,7 @@ view_selector_available = Available {0}
view_subTab_error_disabled = Cannot select disabled subTab [{0}].
view_table_drawFail = Failed to draw Table [{0}].
+view_table_matchingRows = Matching Rows: {0} (selected: {1})
view_table_totalRows = Total Rows: {0} (selected: {1})
view_tableSection_backButton = Back to List
view_tableSection_error_noId = Table [{0}] record is missing 'id' attribute - please report this bug.
@@ -1453,6 +1454,7 @@ view_portlet_defaultName_tagCloud = Tag Count
view_portlet_defaultName_group_events = Group: Event Counts
view_portlet_defaultName_group_metrics = Group: Metrics
+view_portlet_defaultName_group_operations = Group: Operations
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
@@ -1464,6 +1466,7 @@ view_portlet_help_metrics = This portlet graphs relevant recent metric data base
view_portlet_help_message = This portlet displays a static HTML message. The <i>message</i> property must be configured.
view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions.
view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory.
+view_portlet_help_operations_criteria = This portlet displays Operations consistent with display criteria configured.
view_portlet_help_platformSummary = This portlet displays information about the current user''s platform resources.
view_portlet_help_problemResources = This portlet displays the current user''s alerted or unavailable resources.
view_portlet_help_recentAlerts = This portlet displays alerts recently fired on the current user''s viewable inventory.
commit c3975e2d2e70adc4a1dfb5b74656b32c52e0a7ae
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 14 16:44:33 2011 -0400
enabling recent metrics activity as a portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 2375ece..85ef3db 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -97,7 +97,7 @@ public class PortletFactory {
registeredGroupPortletFactoryMap = new HashMap<String, PortletViewFactory>();
registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.Factory.INSTANCE);
- // registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.Factory.INSTANCE);
@@ -105,7 +105,7 @@ public class PortletFactory {
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.NAME);
- // registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
+ registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.NAME);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
index e26f08c..fa9f7ea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
@@ -18,7 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
@@ -34,8 +36,6 @@ 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.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.VLayout;
@@ -47,6 +47,7 @@ import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.resource.ResourceType;
+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;
@@ -61,6 +62,8 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigura
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
@@ -79,6 +82,18 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
private boolean currentlyLoading = false;
private Configuration portletConfig = null;
private DashboardPortlet storedPortlet;
+ private String baseViewPath = "";
+ private long start = -1;
+ private long end = -1;
+
+ private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_ENABLE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_LASTN);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_UNIT);
+ }
public GroupMetricsPortlet(String locatorId) {
super(locatorId);
@@ -87,6 +102,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
String[] elements = currentPage.split("/");
int currentGroupIdentifier = Integer.valueOf(elements[1]);
this.groupId = currentGroupIdentifier;
+ baseViewPath = elements[0];
initializeUi();
}
@@ -107,7 +123,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "GroupMetrics";
// A default displayed, persisted name for the portlet
- public static final String NAME = "Group: Metrics";
+ public static final String NAME = MSG.view_portlet_defaultName_group_metrics();
public static final String ID = "id";
// set on initial configuration, the window for this portlet view.
@@ -132,7 +148,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
//lazy init any elements not yet configured.
for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
- if (portletConfig.getSimple(key) == null) {
+ if ((portletConfig.getSimple(key) == null) && CONFIG_INCLUDE.contains(key)) {
portletConfig.put(new PropertySimple(key,
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
}
@@ -140,8 +156,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
}
public Canvas getHelpCanvas() {
- //TODO: spinder change.
- return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
+ return new HTMLFlow(MSG.view_portlet_help_metrics());
}
public static final class Factory implements PortletViewFactory {
@@ -169,26 +184,8 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
@Override
public void onSubmitValues(SubmitValuesEvent event) {
-
- //alert time range filter. Check for enabled and then persist property. Dealing with compound widget.
- FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
- CheckboxItem itemC = (CheckboxItem) item;
- String selectedValue = String.valueOf(itemC.getValueAsBoolean());
- if (!selectedValue.trim().isEmpty()) {//then call
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue));
- }
-
- //alert time advanced time filter enabled.
- selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
- if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
- }
-
- //alert time frame
- List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (begEnd.get(0) != 0) {//advanced settings
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
- }
+ portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
//persist
storedPortlet.setConfiguration(portletConfig);
@@ -206,17 +203,45 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
* digits.
*/
private void getRecentMetrics() {
-
//display container
final VLayout column = new VLayout();
column.setHeight(10);//pack
- // final int groupId = this.groupComposite.getResourceGroup().getId();
- final int groupId = this.groupId;
+
+ //initialize to defaults
+ end = System.currentTimeMillis();
+ start = end - (1000L * 60 * 60 * 8);//last 8 hrs
+
+ //result timeframe if enabled
+ PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ start = Long.valueOf(range[0]);
+ end = Long.valueOf(range[1]);
+ }
+ }
+
+ //locate resourceGroupRef
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
- criteria.addFilterIds(groupId);
- criteria.fetchGroupDefinition(true);
- criteria.fetchResourceType(true);
- criteria.fetchExplicitResources(true);
+ criteria.addFilterId(this.groupId);
+ criteria.fetchConfigurationUpdates(false);
+ criteria.fetchExplicitResources(false);
+ criteria.fetchGroupDefinition(false);
+ criteria.fetchOperationHistories(false);
+
+ // for autoclusters and autogroups we need to add more criteria
+ final boolean isAutoCluster = isAutoCluster();
+ final boolean isAutoGroup = isAutoGroup();
+ if (isAutoCluster) {
+ criteria.addFilterVisible(false);
+ } else if (isAutoGroup) {
+ criteria.addFilterVisible(false);
+ criteria.addFilterPrivate(true);
+ }
+
+ //locate the resource group
GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceGroupComposite>>() {
@Override
@@ -226,152 +251,168 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
}
@Override
- public void onSuccess(PageList<ResourceGroupComposite> result) {
- if (!result.isEmpty()) {
- //retrieve all relevant measurement definition ids.
- // Set<MeasurementDefinition> definitions = this.groupComposite.getResourceGroup().getResourceType()
- ResourceGroupComposite composite = result.get(0);
- ResourceGroup group = composite.getResourceGroup();
- ResourceType type = group.getResourceType();
- Set<MeasurementDefinition> defs = type.getMetricDefinitions();
- // Log.debug("------------- Composite:" + composite);
- // Log.debug("------------- Group:" + group);
- // Log.debug("------------- Type:" + type);
- // Log.debug("------------- Defs:" + defs);
-
- Set<MeasurementDefinition> definitions = result.get(0).getResourceGroup().getResourceType()
- .getMetricDefinitions();
-
- //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
- final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
- for (MeasurementDefinition definition : definitions) {
- measurementDefMap.put(definition.getDisplayName(), definition);
- }
- //bundle definition ids for asynch call.
- int[] definitionArrayIds = new int[definitions.size()];
- final String[] displayOrder = new String[definitions.size()];
- measurementDefMap.keySet().toArray(displayOrder);
- //sort the charting data ex. Free Memory, Free Swap Space,..System Load
- Arrays.sort(displayOrder);
-
- //organize definitionArrayIds for ordered request on server.
- int index = 0;
- for (String definitionToDisplay : displayOrder) {
- definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay).getId();
- }
+ public void onSuccess(PageList<ResourceGroupComposite> results) {
+ if (!results.isEmpty()) {
+ final ResourceGroupComposite groupComposite = results.get(0);
+ final ResourceGroup group = groupComposite.getResourceGroup();
+ if (group.getGroupCategory() == GroupCategory.COMPATIBLE) {
+ // Load the fully fetched ResourceType.
+ ResourceType groupType = group.getResourceType();
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ groupType.getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.content,
+ ResourceTypeRepository.MetadataType.operations,
+ ResourceTypeRepository.MetadataType.measurements,
+ ResourceTypeRepository.MetadataType.events,
+ ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ group.setResourceType(type);
+ //metric definitions
+ Set<MeasurementDefinition> definitions = type.getMetricDefinitions();
+
+ //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
+ final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition definition : definitions) {
+ measurementDefMap.put(definition.getDisplayName(), definition);
+ }
+ //bundle definition ids for asynch call.
+ int[] definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay)
+ .getId();
+ }
- //make the asynchronous call for all the measurement data
- GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(groupId,
- definitionArrayIds, System.currentTimeMillis() - (1000L * 60 * 60 * 8),
- System.currentTimeMillis(), 60,
- new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent metrics charting data for group [" + groupId
- + "]:" + caught.getMessage());
- }
-
- @Override
- public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
- if (!results.isEmpty()) {
- boolean someChartedData = false;
- //iterate over the retrieved charting data
- for (int index = 0; index < displayOrder.length; index++) {
- //retrieve the correct measurement definition
- MeasurementDefinition md = measurementDefMap.get(displayOrder[index]);
-
- //load the data results for the given metric definition
- List<MeasurementDataNumericHighLowComposite> data = results.get(index);
-
- //locate last and minimum values.
- double lastValue = -1;
- double minValue = Double.MAX_VALUE;//
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- if (d.getValue() < minValue) {
- minValue = d.getValue();
- }
- lastValue = d.getValue();
+ //make the asynchronous call for all the measurement data
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(
+ groupId, definitionArrayIds, start, end, 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log
+ .debug("Error retrieving recent metrics charting data for group ["
+ + groupId + "]:" + caught.getMessage());
}
- }
-
- //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
- String commaDelimitedList = "";
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- commaDelimitedList += d.getValue() + ",";
+ @Override
+ public void onSuccess(
+ List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+ boolean someChartedData = false;
+ //iterate over the retrieved charting data
+ for (int index = 0; index < displayOrder.length; index++) {
+ //retrieve the correct measurement definition
+ MeasurementDefinition md = measurementDefMap
+ .get(displayOrder[index]);
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> data = results
+ .get(index);
+
+ //locate last and minimum values.
+ double lastValue = -1;
+ double minValue = Double.MAX_VALUE;//
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ if (d.getValue() < minValue) {
+ minValue = d.getValue();
+ }
+ lastValue = d.getValue();
+ }
+ }
+
+ //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
+ String commaDelimitedList = "";
+
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ commaDelimitedList += d.getValue() + ",";
+ }
+ }
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent.extendLocatorId(md.getName()));
+ row.setNumCols(3);
+ HTMLFlow graph = new HTMLFlow();
+ // String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
+ // + commaDelimitedList + "</span>";
+ String contents = "<span id='sparkline_" + index
+ + "' class='dynamicsparkline' width='0' " + "values='"
+ + commaDelimitedList + "'>...</span>";
+ graph.setContents(contents);
+ graph.setContentsType(ContentsType.PAGE);
+ //diable scrollbars on span
+ graph.setScrollbarSize(0);
+
+ CanvasItem graphContainer = new CanvasItem();
+ graphContainer.setShowTitle(false);
+ graphContainer.setHeight(16);
+ graphContainer.setWidth(60);
+ graphContainer.setCanvas(graph);
+
+ //Link/title element
+ //TODO: spinder, change link whenever portal.war/graphing is removed.
+ String title = md.getDisplayName() + ":";
+ // String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ // + resourceId + "&m=" + md.getId();
+ String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricMultiResource&groupId="
+ + groupId + "&m=" + md.getId();
+ LinkItem link = AbstractActivityView.newLinkItem(title,
+ destination);
+
+ //Value
+ String convertedValue = lastValue + " " + md.getUnits();
+ convertedValue = AbstractActivityView
+ .convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = AbstractActivityView
+ .newTextItem(convertedValue);
+
+ row.setItems(graphContainer, link, value);
+ //if graph content returned
+ if ((md.getName().trim().indexOf("Trait.") == -1)
+ && (lastValue != -1)) {
+ column.addMember(row);
+ someChartedData = true;
+ }
+ }
+ if (!someChartedData) {// when there are results but no chartable entries.
+ LocatableDynamicForm row = AbstractActivityView
+ .createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent
+ .extendLocatorId("RecentMeasurementsContentSeeMore"));
+ AbstractActivityView.addSeeMoreLink(row,
+ ReportDecorator.GWT_GROUP_URL + groupId
+ + "/Monitoring/Graphs/", column);
+ }
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row = AbstractActivityView
+ .createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ }
}
- }
- LocatableDynamicForm row = new LocatableDynamicForm(
- recentMeasurementsContent.extendLocatorId(md.getName()));
- row.setNumCols(3);
- HTMLFlow graph = new HTMLFlow();
- // String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
- // + commaDelimitedList + "</span>";
- String contents = "<span id='sparkline_" + index
- + "' class='dynamicsparkline' width='0' " + "values='"
- + commaDelimitedList + "'>...</span>";
- graph.setContents(contents);
- graph.setContentsType(ContentsType.PAGE);
- //diable scrollbars on span
- graph.setScrollbarSize(0);
-
- CanvasItem graphContainer = new CanvasItem();
- graphContainer.setShowTitle(false);
- graphContainer.setHeight(16);
- graphContainer.setWidth(60);
- graphContainer.setCanvas(graph);
-
- //Link/title element
- //TODO: spinder, change link whenever portal.war/graphing is removed.
- String title = md.getDisplayName() + ":";
- // String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
- // + resourceId + "&m=" + md.getId();
- String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricMultiResource&groupId="
- + groupId + "&m=" + md.getId();
- LinkItem link = AbstractActivityView.newLinkItem(title, destination);
-
- //Value
- String convertedValue = lastValue + " " + md.getUnits();
- convertedValue = AbstractActivityView.convertLastValueForDisplay(lastValue,
- md);
- StaticTextItem value = AbstractActivityView.newTextItem(convertedValue);
-
- row.setItems(graphContainer, link, value);
- //if graph content returned
- if ((md.getName().trim().indexOf("Trait.") == -1) && (lastValue != -1)) {
- column.addMember(row);
- someChartedData = true;
- }
- }
- if (!someChartedData) {// when there are results but no chartable entries.
- LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(
- recentMeasurementsContent.extendLocatorId("None"),
- AbstractActivityView.RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- } else {
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(
- recentMeasurementsContent
- .extendLocatorId("RecentMeasurementsContentSeeMore"));
- AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL
- + groupId + "/Monitoring/Graphs/", column);
- }
- //call out to 3rd party javascript lib
- BrowserUtility.graphSparkLines();
- } else {
- LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(
- recentMeasurementsContent.extendLocatorId("None"),
- AbstractActivityView.RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
+ });
}
- }
- });
+ });
+ }
}
-
}
});
@@ -411,7 +452,6 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
@Override
protected void onDestroy() {
if (refreshTimer != null) {
-
refreshTimer.cancel();
}
super.onDestroy();
@@ -423,4 +463,15 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
loadData();
}
+ private boolean isAutoGroup() {
+ return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ private boolean isAutoCluster() {
+ return ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ public String getBaseViewPath() {
+ return baseViewPath;
+ }
}
\ No newline at end of file
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 e766421..4dfcf51 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
@@ -1452,6 +1452,7 @@ view_portlet_defaultName_recentlyAddedResources = Recently Added Resources
view_portlet_defaultName_tagCloud = Tag Count
view_portlet_defaultName_group_events = Group: Event Counts
+view_portlet_defaultName_group_metrics = Group: Metrics
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
@@ -1459,6 +1460,7 @@ view_portlet_help_favoriteResources = This portlet displays the current user''s
view_portlet_help_graph = This portlet displays the resource metric graph.
view_portlet_help_inventorySummary = This portlet displays a short summary of the current user''s viewable inventory and metric collection rate.
view_portlet_help_mashup = This portlet displays the returned content of a remote HTTP request (via an iframe).
+view_portlet_help_metrics = This portlet graphs relevant recent metric data based on display criteria configured.
view_portlet_help_message = This portlet displays a static HTML message. The <i>message</i> property must be configured.
view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions.
view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory.
commit 0751dc0c7e61aa0e3e5d67dd45f059c079ec8c81
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 11 11:13:45 2011 -0500
missing i18n message GroupEvents and refactor.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
index b8a7949..877dbf4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
@@ -31,8 +31,6 @@ 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.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.VLayout;
@@ -98,7 +96,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "GroupEvents";
// A default displayed, persisted name for the portlet
- public static final String NAME = "Group: Event Counts";
+ public static final String NAME = MSG.view_portlet_defaultName_group_events();
public static final String ID = "id";
// set on initial configuration, the window for this portlet view.
@@ -172,26 +170,9 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
@Override
public void onSubmitValues(SubmitValuesEvent event) {
- String selectedValue = null;
- //alert time range filter. Check for enabled and then persist property. Dealing with compound widget.
- FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
- CheckboxItem itemC = (CheckboxItem) item;
- selectedValue = String.valueOf(itemC.getValueAsBoolean());
- if (!selectedValue.trim().isEmpty()) {//then call
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue));
- }
-
- //alert time advanced time filter enabled.
- selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
- if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
- }
-
- //alert time frame
- List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (begEnd.get(0) != 0) {//advanced settings
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
- }
+ //persist the measurement range selections
+ portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
//persist
storedPortlet.setConfiguration(portletConfig);
@@ -199,7 +180,6 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
loadData();
customSettings.markForRedraw();
}
-
});
page.addMember(measurementRangeEditor);
customSettings.addChild(page);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index fdeca2c..cda2a57 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary;
+import java.util.List;
import java.util.Set;
import com.allen_sauer.gwt.log.client.Log;
@@ -27,6 +28,8 @@ import com.smartgwt.client.widgets.IButton;
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.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
@@ -49,6 +52,7 @@ 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.RefreshableView;
+import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
@@ -480,6 +484,39 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
return portletConfig;
}
+ /** Takes the current value of the widget and persists it into the configuration object passed in.
+ *
+ * @param measurementRangeEditor
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ public static Configuration saveMeasurementRangeEditorSettings(
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor, Configuration portletConfig) {
+ String selectedValue = null;
+ if ((measurementRangeEditor != null) && (portletConfig != null)) {
+ //time range filter. Check for enabled and then persist property. Dealing with compound widget.
+ FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
+ CheckboxItem itemC = (CheckboxItem) item;
+ selectedValue = String.valueOf(itemC.getValueAsBoolean());
+ if (!selectedValue.trim().isEmpty()) {//then call
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue));
+ }
+
+ //time advanced time filter enabled.
+ selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
+ if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ }
+
+ //time frame
+ List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
+ if (begEnd.get(0) != 0) {//advanced settings
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
+ }
+ }
+ return portletConfig;
+ }
+
protected boolean displayGroupConfigurationUpdates(GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
if ((groupCategory == null) || facets == null) {
return false;
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 e8066f3..e766421 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
@@ -1451,6 +1451,8 @@ view_portlet_defaultName_recentAlerts = Recent Alerts
view_portlet_defaultName_recentlyAddedResources = Recently Added Resources
view_portlet_defaultName_tagCloud = Tag Count
+view_portlet_defaultName_group_events = Group: Event Counts
+
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
view_portlet_help_favoriteResources = This portlet displays the current user''s favorite resources.
commit c64627edabd22d1c00ba938a899f22d45002dcc6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 15 13:16:57 2011 -0400
support -Pdev when building safe-invoker
diff --git a/modules/enterprise/server/safe-invoker/pom.xml b/modules/enterprise/server/safe-invoker/pom.xml
index 12ea01d..94b88bb 100644
--- a/modules/enterprise/server/safe-invoker/pom.xml
+++ b/modules/enterprise/server/safe-invoker/pom.xml
@@ -49,6 +49,63 @@
</dependencies>
<profiles>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentName>${project.build.finalName}.jar</rhq.deploymentName>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${rhq.deploymentName}" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${rhq.deploymentName}" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
<profile>
<id>cobertura</id>
<activation>
commit 23768b7d10d325172b99e0d477d6f1de56ca677a
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Mar 15 11:01:27 2011 -0400
Ancestry (Disambiguation) Work
- Add Ancestry to Group Resource Config Member view
- Add Ancestry to Group Plugin Config Member view
- Fix issue with Operation subsystem view
- Fix small optimization issue in ConfigurationHistoryDataSource
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
index 50593ec..6553b56 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
@@ -43,12 +43,13 @@ import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
@@ -238,19 +239,23 @@ public abstract class AbstractOperationHistoryListView<T extends AbstractOperati
}
protected ListGridField createResourceField() {
- ListGridField resourceField = new ListGridField(ResourceOperationHistoryDataSource.Field.RESOURCE, MSG
- .common_title_resource());
+ ListGridField resourceField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
resourceField.setAlign(Alignment.LEFT);
resourceField.setCellAlign(Alignment.LEFT);
- //resourceField.setSuppressValueIcon(true);
- //resourceField.setValueIcons(new HashMap<String, String>(0));
- /*resourceField.setCellFormatter(new CellFormatter() {
- public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- Resource resource = (Resource) value;
- String url = LinkManager.getResourceLink(resource.getId());
- return "<a href=\"" + url + "\">" + resource.getName() + "</a>";
+ resourceField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
}
- });*/
+ });
+ resourceField.setShowHover(true);
+ resourceField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+
return resourceField;
}
@@ -258,6 +263,19 @@ public abstract class AbstractOperationHistoryListView<T extends AbstractOperati
ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
ancestryField.setAlign(Alignment.LEFT);
ancestryField.setCellAlign(Alignment.LEFT);
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+
return ancestryField;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java
index 99fd567..8ea5782 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java
@@ -20,12 +20,15 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.configurat
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
+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.Record;
import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -37,6 +40,8 @@ import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
@@ -49,8 +54,12 @@ import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
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.SeleniumUtility;
/**
* Shows a table of individual resource members that belonged to the group when the group configuration was updated.
@@ -93,7 +102,36 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
@Override
protected void configureTable() {
- ListGridField fieldResource = new ListGridField(DataSource.Field.RESOURCELINK, MSG.common_title_resource());
+ ListGridField fieldResource = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
+ fieldResource.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager
+ .getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ fieldResource.setShowHover(true);
+ fieldResource.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+
+ ListGridField fieldAncestry = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
+ fieldAncestry.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ fieldAncestry.setShowHover(true);
+ fieldAncestry.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+
ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG
.common_title_dateCreated());
ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG
@@ -101,9 +139,10 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
ListGridField fieldStatus = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status());
ListGridField fieldUser = new ListGridField(DataSource.Field.USER, MSG.common_title_user());
- fieldResource.setWidth("*");
- fieldDateCreated.setWidth("15%");
- fieldLastUpdated.setWidth("15%");
+ fieldResource.setWidth("30%");
+ fieldAncestry.setWidth("*");
+ fieldDateCreated.setWidth(150);
+ fieldLastUpdated.setWidth(150);
fieldStatus.setWidth("10%");
fieldUser.setWidth("10%");
@@ -143,8 +182,8 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
});
ListGrid listGrid = getListGrid();
- listGrid.setFields(fieldResource, fieldDateCreated, fieldLastUpdated, fieldStatus, fieldUser);
- listGrid.setLinkTextProperty(DataSource.Field.RESOURCENAME);
+ listGrid
+ .setFields(fieldResource, fieldAncestry, fieldDateCreated, fieldLastUpdated, fieldStatus, fieldUser);
}
private String getStatusHtmlString(Record record) {
@@ -179,8 +218,6 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
public class Field {
public static final String ID = "id";
- public static final String RESOURCELINK = "resourceLink";
- public static final String RESOURCENAME = "resourceName";
public static final String DATECREATED = "dateCreated";
public static final String LASTUPDATED = "lastUpdated";
public static final String STATUS = "status";
@@ -198,13 +235,18 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
ListGridRecord record = new ListGridRecord();
record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.RESOURCELINK, LinkManager.getResourceLink(from.getResource().getId()));
- record.setAttribute(Field.RESOURCENAME, from.getResource().getName());
record.setAttribute(Field.DATECREATED, new Date(from.getCreatedTime()));
record.setAttribute(Field.LASTUPDATED, new Date(from.getModifiedTime()));
record.setAttribute(Field.USER, from.getSubjectName());
record.setAttribute(Field.STATUS, from.getStatus().name());
+ // for ancestry handling
+ Resource resource = from.getResource();
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+
record.setAttribute(Field.OBJECT, from);
return record;
@@ -217,17 +259,47 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
criteria
.addFilterGroupConfigurationUpdateId(HistoryGroupResourceConfigurationMembers.this.groupUpdateId);
- // TODO need to disambiguate resources
criteria.fetchResource(true);
configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
@Override
- public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
+ public void onSuccess(final PageList<ResourceConfigurationUpdate> result) {
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (ResourceConfigurationUpdate update : result) {
+ Resource resource = update.getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]),
+ new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil
+ .getAncestryValue(record));
+ }
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java
index 2af2fcf..ae76963 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java
@@ -20,12 +20,15 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
+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.Record;
import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -37,6 +40,8 @@ import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
@@ -49,8 +54,12 @@ import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
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.SeleniumUtility;
/**
* Shows a table of individual resource members that belonged to the group when the group configuration was updated.
@@ -92,7 +101,36 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
@Override
protected void configureTable() {
- ListGridField fieldResource = new ListGridField(DataSource.Field.RESOURCELINK, MSG.common_title_resource());
+ ListGridField fieldResource = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
+ fieldResource.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager
+ .getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ fieldResource.setShowHover(true);
+ fieldResource.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+
+ ListGridField fieldAncestry = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
+ fieldAncestry.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ fieldAncestry.setShowHover(true);
+ fieldAncestry.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+
ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG
.common_title_dateCreated());
ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG
@@ -100,9 +138,10 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
ListGridField fieldStatus = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status());
ListGridField fieldUser = new ListGridField(DataSource.Field.USER, MSG.common_title_user());
- fieldResource.setWidth("*");
- fieldDateCreated.setWidth("15%");
- fieldLastUpdated.setWidth("15%");
+ fieldResource.setWidth("30%");
+ fieldAncestry.setWidth("*");
+ fieldDateCreated.setWidth(150);
+ fieldLastUpdated.setWidth(150);
fieldStatus.setWidth("10%");
fieldUser.setWidth("10%");
@@ -142,8 +181,8 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
});
ListGrid listGrid = getListGrid();
- listGrid.setFields(fieldResource, fieldDateCreated, fieldLastUpdated, fieldStatus, fieldUser);
- listGrid.setLinkTextProperty(DataSource.Field.RESOURCENAME);
+ listGrid
+ .setFields(fieldResource, fieldAncestry, fieldDateCreated, fieldLastUpdated, fieldStatus, fieldUser);
}
private String getStatusHtmlString(Record record) {
@@ -178,8 +217,6 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
public class Field {
public static final String ID = "id";
- public static final String RESOURCELINK = "resourceLink";
- public static final String RESOURCENAME = "resourceName";
public static final String DATECREATED = "dateCreated";
public static final String LASTUPDATED = "lastUpdated";
public static final String STATUS = "status";
@@ -197,13 +234,18 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
ListGridRecord record = new ListGridRecord();
record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.RESOURCELINK, LinkManager.getResourceLink(from.getResource().getId()));
- record.setAttribute(Field.RESOURCENAME, from.getResource().getName());
record.setAttribute(Field.DATECREATED, new Date(from.getCreatedTime()));
record.setAttribute(Field.LASTUPDATED, new Date(from.getModifiedTime()));
record.setAttribute(Field.USER, from.getSubjectName());
record.setAttribute(Field.STATUS, from.getStatus().name());
+ // for ancestry handling
+ Resource resource = from.getResource();
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+
record.setAttribute(Field.OBJECT, from);
return record;
@@ -215,17 +257,47 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
criteria.addFilterGroupConfigurationUpdateId(HistoryGroupPluginConfigurationMembers.this.groupUpdateId);
- // TODO need to disambiguate resources
criteria.fetchResource(true);
configurationService.findPluginConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
@Override
- public void onSuccess(PageList<PluginConfigurationUpdate> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
+ public void onSuccess(final PageList<PluginConfigurationUpdate> result) {
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (PluginConfigurationUpdate update : result) {
+ Resource resource = update.getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]),
+ new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil
+ .getAncestryValue(record));
+ }
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
+ }
+ });
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
index 2b0709e..3a28dcc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
@@ -89,7 +89,6 @@ public class ConfigurationHistoryDataSource extends AbstractConfigurationHistory
}
public void onSuccess(final PageList<ResourceConfigurationUpdate> result) {
- final ListGridRecord[] records = buildRecords(result);
if (resourceId == null) {
HashSet<Integer> typesSet = new HashSet<Integer>();
HashSet<String> ancestries = new HashSet<String>();
@@ -129,6 +128,8 @@ public class ConfigurationHistoryDataSource extends AbstractConfigurationHistory
return;
}
+ final ListGridRecord[] records = buildRecords(result);
+
// we are obtaining a single resource's history items. Let's find out which is
// its latest, current config item so we can mark it as such
getConfigurationService().getLatestResourceConfigurationUpdate(resourceId.intValue(),
commit d5035af9712dd3e878d2fad6e30f66dd7ad8b139
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 14 20:39:53 2011 -0400
Ancestry (Disambiguation) for Resource and Plugin config history
- added resource filtering for the Update entities.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
index a50e8a8..4420169 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
@@ -44,6 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -59,11 +60,9 @@ public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractR
public static abstract class Field {
public static final String ID = "id";
- public static final String RESOURCE = "resource";
public static final String CREATED_TIME = "createdTime";
public static final String STATUS = "status";
public static final String SUBJECT = "subject";
- public static final String RESOURCE_TYPE_ID = "resourceTypeId";
public static final String CONFIGURATION = "configuration";
public static final String GROUP_CONFIG_UPDATE_ID = "groupConfigUpdateId";
public static final String GROUP_ID = "groupId"; // will only be non-null if group config update id is non-null
@@ -212,27 +211,46 @@ public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractR
// determine the widths of our columns
if (includeResourceFields) {
- ListGridField resourceField = new ListGridField(Field.RESOURCE, MSG.common_title_resource());
- resourceField.setCellFormatter(new CellFormatter() {
+ ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
+ resourceNameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- if (listGridRecord == null) {
- return "unknown";
- }
- Resource res = (Resource) listGridRecord.getAttributeAsObject(Field.RESOURCE);
- String url = LinkManager.getResourceLink(res.getId());
- // TODO disambiguate the resource name
- return SeleniumUtility.getLocatableHref(url, res.getName(), null);
+ String url = LinkManager
+ .getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
}
});
- fields.add(resourceField);
+ resourceNameField.setShowHover(true);
+ resourceNameField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+ fields.add(resourceNameField);
+
+ ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+ fields.add(ancestryField);
idField.setWidth("10%");
- submittedTimeField.setWidth("20%");
- completedTimeField.setWidth("20%");
+ submittedTimeField.setWidth(150);
+ completedTimeField.setWidth(150);
statusField.setWidth("10%");
subjectField.setWidth("10%");
updateTypeField.setWidth("10%");
- resourceField.setWidth("*");
+ resourceNameField.setWidth("30%");
+ ancestryField.setWidth("*");
} else {
idField.setWidth("10%");
submittedTimeField.setWidth("20%");
@@ -264,8 +282,6 @@ public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractR
public ListGridRecord copyValues(T from) {
ListGridRecord record = new ListGridRecord();
record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.RESOURCE, from.getResource());
- record.setAttribute(Field.RESOURCE_TYPE_ID, from.getResource().getResourceType().getId());
record.setAttribute(Field.SUBJECT, from.getSubjectName());
record.setAttribute(Field.STATUS, from.getStatus().name());
record.setAttribute(Field.CONFIGURATION, from.getConfiguration());
@@ -280,6 +296,14 @@ public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractR
record.setAttribute(Field.GROUP_CONFIG_UPDATE_ID, from.getAbstractGroupConfigurationUpdate().getId());
record.setAttribute(Field.GROUP_ID, from.getAbstractGroupConfigurationUpdate().getGroup().getId()); // note group must be eagerly loaded here
}
+
+ // for ancestry handling
+ Resource resource = from.getResource();
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+
record.setAttribute(Field.OBJECT, from);
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
index 47dc9a0..2b0709e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java
@@ -18,19 +18,28 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
+import java.util.HashSet;
+import java.util.Map;
+
import com.allen_sauer.gwt.log.client.Log;
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.Record;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.Resource;
+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.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
/**
* A data source that loads information about all the configuration changes that happened
@@ -82,10 +91,42 @@ public class ConfigurationHistoryDataSource extends AbstractConfigurationHistory
public void onSuccess(final PageList<ResourceConfigurationUpdate> result) {
final ListGridRecord[] records = buildRecords(result);
if (resourceId == null) {
- response.setData(records);
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- return; // we can finish now, we don't need any additional information
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (ResourceConfigurationUpdate update : result) {
+ Resource resource = update.getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]),
+ new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil
+ .getAncestryValue(record));
+ }
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ return;
}
// we are obtaining a single resource's history items. Let's find out which is
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java
index b6831a5..4918dff 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java
@@ -18,20 +18,29 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+import java.util.HashSet;
+import java.util.Map;
+
import com.allen_sauer.gwt.log.client.Log;
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.Record;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.Resource;
+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.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.AbstractConfigurationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
/**
* A data source that loads information about all the plugin configuration changes that happened
@@ -83,10 +92,42 @@ public class PluginConfigurationHistoryDataSource extends
public void onSuccess(final PageList<PluginConfigurationUpdate> result) {
final ListGridRecord[] records = buildRecords(result);
if (resourceId == null) {
- response.setData(records);
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- return; // we can finish now, we don't need any additional information
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (PluginConfigurationUpdate update : result) {
+ Resource resource = update.getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]),
+ new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil
+ .getAncestryValue(record));
+ }
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ return;
}
// we are obtaining a single resource's history items. Let's find out which is
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index 336206b..4e551ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -16,6 +16,7 @@ import org.rhq.core.domain.criteria.GroupPluginConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageControl;
@@ -155,9 +156,20 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
public PageList<ResourceConfigurationUpdate> findResourceConfigurationUpdates(Integer resourceId, Long beginDate,
Long endDate, boolean suppressOldest, PageControl pc) throws RuntimeException {
try {
- PageList<ResourceConfigurationUpdate> result = configurationManager.findResourceConfigurationUpdates(
+ PageList<ResourceConfigurationUpdate> updates = configurationManager.findResourceConfigurationUpdates(
getSessionSubject(), resourceId, beginDate, endDate, suppressOldest, pc);
- return SerialUtility.prepare(result, "ConfigurationService.findResourceConfigurationUpdates");
+ if (!updates.isEmpty()) {
+ List<Resource> resources = new ArrayList<Resource>(updates.size());
+ for (ResourceConfigurationUpdate update : updates) {
+ Resource res = update.getResource();
+ if (null != res) {
+ resources.add(res);
+ }
+ }
+ ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet);
+ }
+
+ return SerialUtility.prepare(updates, "ConfigurationService.findResourceConfigurationUpdates");
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
@@ -193,6 +205,17 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
PageList<ResourceConfigurationUpdate> updates = configurationManager
.findResourceConfigurationUpdatesByCriteria(getSessionSubject(), criteria);
+ if (!updates.isEmpty()) {
+ List<Resource> resources = new ArrayList<Resource>(updates.size());
+ for (ResourceConfigurationUpdate update : updates) {
+ Resource res = update.getResource();
+ if (null != res) {
+ resources.add(res);
+ }
+ }
+ ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet);
+ }
+
return SerialUtility.prepare(updates, "ConfigurationService.findResourceConfigurationUpdatesByCriteria");
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
@@ -205,6 +228,17 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
PageList<PluginConfigurationUpdate> updates = configurationManager
.findPluginConfigurationUpdatesByCriteria(getSessionSubject(), criteria);
+ if (!updates.isEmpty()) {
+ List<Resource> resources = new ArrayList<Resource>(updates.size());
+ for (PluginConfigurationUpdate update : updates) {
+ Resource res = update.getResource();
+ if (null != res) {
+ resources.add(res);
+ }
+ }
+ ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet);
+ }
+
return SerialUtility.prepare(updates, "ConfigurationService.findPluginConfigurationUpdatesByCriteria");
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
commit 7da7a574214406a8a5021587610bcfd8feedc0cd
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 15 00:59:43 2011 -0400
BZ 664126 - concurrent calls to setResourceError need separate transactions
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 8c0e7d6..384104a 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
@@ -1855,26 +1855,16 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
public void addResourceError(ResourceError resourceError) {
- Subject overlord = subjectManager.getOverlord();
- Resource resource;
- try {
- resource = getResourceById(overlord, resourceError.getResource().getId());
- } catch (ResourceNotFoundException rnfe) {
- throw new ResourceNotFoundException("Resource error an unknown Resource id: " + resourceError);
- }
+ ResourceErrorType resourceErrorType = resourceError.getErrorType();
- if (resourceError.getErrorType() == ResourceErrorType.INVALID_PLUGIN_CONFIGURATION
- || resourceError.getErrorType() == ResourceErrorType.AVAILABILITY_CHECK
- || resourceError.getErrorType() == ResourceErrorType.UPGRADE) {
+ if (resourceErrorType == ResourceErrorType.INVALID_PLUGIN_CONFIGURATION
+ || resourceErrorType == ResourceErrorType.AVAILABILITY_CHECK
+ || resourceErrorType == ResourceErrorType.UPGRADE) {
// there should be at most one invalid plugin configuration error, availability check
// or upgrade error per resource, so delete any currently existing ones before we add this new one
- List<ResourceError> doomedErrors = resource.getResourceErrors(resourceError.getErrorType());
-
- // there should only ever be at most 1, but loop through the list just in case something got screwed up
- // and there ended up more than 1 associated with the resource.
- for (ResourceError doomedError : doomedErrors) {
- entityManager.remove(doomedError);
- }
+ Subject overlord = subjectManager.getOverlord();
+ int resourceId = resourceError.getResource().getId();
+ resourceManager.clearResourceConfigErrorByType(overlord, resourceId, resourceErrorType);
}
entityManager.persist(resourceError);
@@ -1882,24 +1872,40 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return;
}
- public void clearResourceConfigError(int resourceId) {
- // TODO Add subject permissions to this method
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public int clearResourceConfigErrorByType(Subject subject, int resourceId, ResourceErrorType resourceErrorType) {
+
+ if (!authorizationManager.canViewResource(subject, resourceId)) {
+ throw new PermissionException("Cannot delete resource errors of type [" + resourceErrorType + "]. User ["
+ + subject.getName() + "] does not have permission to operate on resource ID [" + resourceId + "].");
+ }
Query q = entityManager
- .createQuery("delete from ResourceError e where e.resource.id = :resourceId and e.errorType = :type");
+ .createQuery("DELETE FROM ResourceError e WHERE e.resource.id = :resourceId AND e.errorType = :type");
q.setParameter("resourceId", resourceId);
- q.setParameter("type", ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
+ q.setParameter("type", resourceErrorType);
int updates = q.executeUpdate();
+ return updates;
+ }
+
+ public void clearResourceConfigError(int resourceId) {
+ // TODO change sig to get user passed in, rather than using overlord/assuming user is authz'ed
+ Subject s = subjectManager.getOverlord();
+
+ // make a direct local call - no need to go through the ByType method's REQUIRES_NEW interface here
+ int cleared = clearResourceConfigErrorByType(s, resourceId, ResourceErrorType.INVALID_PLUGIN_CONFIGURATION);
- if (updates > 1) {
- log.error("Resource [" + resourceId + "] has [" + updates
- + "] INVALID_PLUGIN_CONFIGURATION ResourceError associated with it.");
+ if (cleared > 1) {
+ log.warn("Resource [" + resourceId + "] had [" + cleared
+ + "] INVALID_PLUGIN_CONFIGURATION ResourceErrors associated with it.");
}
+ return;
}
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void deleteResourceError(Subject user, int resourceErrorId) {
ResourceError error = entityManager.find(ResourceError.class, resourceErrorId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
index 4eba088..02b0266 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java
@@ -395,6 +395,15 @@ public interface ResourceManagerLocal {
void clearResourceConfigError(int resourceId);
/**
+ * Clears errors of the given type.
+ * @param subject the user that is making the request
+ * @param resourceId id of the resource
+ * @param resourceErrorType type of error to clear
+ * @return the number of errors that were cleared
+ */
+ int clearResourceConfigErrorByType(Subject subject, int resourceId, ResourceErrorType resourceErrorType);
+
+ /**
* Returns the platform Resource associated with the specified Agent.
*
* @param agent an Agent
commit b4f322f53ed50d582482bf2e36819f08b83198c9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 14 23:44:07 2011 -0400
make win32 event log collection more fault tolerant - catch exceptions better and don't try to do things with event logs when we aren't collecting events (i.e. do null checks)
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/WindowsPlatformComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/WindowsPlatformComponent.java
index 28ed7e7..60f451a 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/WindowsPlatformComponent.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/WindowsPlatformComponent.java
@@ -27,11 +27,14 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.pluginapi.content.ContentFacet;
@@ -44,6 +47,8 @@ import org.rhq.plugins.platform.win.WindowsSoftwareDelegate;
* @author Greg Hinkle
*/
public class WindowsPlatformComponent extends PlatformComponent implements ContentFacet {
+ private final Log log = LogFactory.getLog(WindowsPlatformComponent.class);
+
private Win32EventLogDelegate eventLogDelegate;
private boolean enableContentDiscovery = false;
@@ -51,9 +56,21 @@ public class WindowsPlatformComponent extends PlatformComponent implements Conte
super.start(context);
Configuration pluginConfiguration = context.getPluginConfiguration();
if (pluginConfiguration.getSimple("eventTrackingEnabled").getBooleanValue()) {
- eventLogDelegate = new Win32EventLogDelegate(pluginConfiguration);
- eventLogDelegate.open();
- context.getEventContext().registerEventPoller(eventLogDelegate, 60);
+ try {
+ eventLogDelegate = new Win32EventLogDelegate(pluginConfiguration);
+ eventLogDelegate.open();
+ context.getEventContext().registerEventPoller(eventLogDelegate, 60);
+ } catch (Throwable t) {
+ log.error("Failed to start the event logger. Will not be able to capture Windows events", t);
+ if (eventLogDelegate != null) {
+ try {
+ eventLogDelegate.close();
+ } catch (Throwable t2) {
+ } finally {
+ eventLogDelegate = null;
+ }
+ }
+ }
}
PropertySimple contentProp = pluginConfiguration.getSimple("enableContentDiscovery");
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/win/Win32EventLogDelegate.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/win/Win32EventLogDelegate.java
index 9d6188f..62e217f 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/win/Win32EventLogDelegate.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/win/Win32EventLogDelegate.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-2011 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.plugins.platform.win;
import java.util.HashSet;
@@ -31,7 +31,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hyperic.sigar.win32.EventLog;
import org.hyperic.sigar.win32.EventLogRecord;
-import org.hyperic.sigar.win32.Win32Exception;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -85,36 +84,35 @@ public class Win32EventLogDelegate implements EventPoller {
eventLogs = new EventLog[logNames.length];
lastCollectedEventId = new int[logNames.length];
-
- for (int i = 0; (i < logNames.length); ++i) {
- eventLogs[i] = new EventLog();
- }
}
public void open() {
- try {
- int i = 0;
- for (String logName : logNames) {
-
- eventLogs[i].open(logName);
-
- // note, the first processed event will be the next one generated, this one
- // was generated in the past, prior to this call to open().
- lastCollectedEventId[i] = eventLogs[i].getNewestRecord();
+ for (int i = 0; i < eventLogs.length; i++) {
+ try {
+ if (eventLogs[i] == null) {
+ eventLogs[i] = new EventLog();
+ eventLogs[i].open(logNames[i]);
- i++;
+ // note, the first processed event will be the next one generated, this one
+ // was generated in the past, prior to this call to open().
+ lastCollectedEventId[i] = eventLogs[i].getNewestRecord();
+ }
+ } catch (Exception e) {
+ log.warn("Failed to open Windows Event Log [" + logNames[i] + "]; will not collect its events", e);
+ eventLogs[i] = null;
}
- } catch (Win32Exception e) {
- log.warn("Failed to open Windows Event Log, log tracking will not return events", e);
}
}
public void close() {
- for (EventLog eventLog : eventLogs) {
+ for (int i = 0; i < eventLogs.length; i++) {
try {
- eventLog.close();
- } catch (Win32Exception e) {
- log.warn("Failed to close Windows Event Log", e);
+ if (eventLogs[i] != null) {
+ eventLogs[i].close();
+ eventLogs[i] = null;
+ }
+ } catch (Exception e) {
+ log.warn("Failed to close Windows Event Log [" + logNames[i] + "]", e);
}
}
}
@@ -124,41 +122,43 @@ public class Win32EventLogDelegate implements EventPoller {
Set<Event> convertedEvents = null;
for (int i = 0; i < eventLogs.length; i++) {
try {
- int newest = eventLogs[i].getNewestRecord();
- if (newest > lastCollectedEventId[i]) {
- for (int eventId = lastCollectedEventId[i] + 1; eventId <= newest; eventId++) {
- eventsChecked++;
+ if (eventLogs[i] != null) {
+ int newest = eventLogs[i].getNewestRecord();
+ if (newest > lastCollectedEventId[i]) {
+ for (int eventId = lastCollectedEventId[i] + 1; eventId <= newest; eventId++) {
+ eventsChecked++;
- EventLogRecord event = eventLogs[i].read(eventId);
- Event convertedEvent = handleEvent(event);
+ EventLogRecord event = eventLogs[i].read(eventId);
+ Event convertedEvent = handleEvent(event);
- if (null != convertedEvent) {
- if (null == convertedEvents) {
- convertedEvents = new HashSet<Event>();
- }
+ if (null != convertedEvent) {
+ if (null == convertedEvents) {
+ convertedEvents = new HashSet<Event>();
+ }
- convertedEvents.add(convertedEvent);
+ convertedEvents.add(convertedEvent);
+ }
}
+ lastCollectedEventId[i] = newest;
}
- lastCollectedEventId[i] = newest;
}
- } catch (Win32Exception e) {
- log.info("An error occurred while reading the Windows Event Log", e);
+ } catch (Exception e) {
+ log.info("An error occurred while reading the Windows Event Log [" + logNames[i] + "]", e);
}
}
return convertedEvents;
}
public Event handleEvent(EventLogRecord event) {
- eventsChecked++;
-
if (regularExpression != null) {
- if (!regularExpression.matcher(event.getMessage()).find())
+ if (!regularExpression.matcher(event.getMessage()).find()) {
return null;
+ }
}
- if (!convertSeverity(event.getEventType()).isAtLeastAsSevereAs(minimumSeverity))
+ if (!convertSeverity(event.getEventType()).isAtLeastAsSevereAs(minimumSeverity)) {
return null;
+ }
Event convertedEvent = new Event(EVENT_TYPE, event.getLogName(), event.getTimeGenerated() * 1000,
convertSeverity(event.getEventType()), event.getMessage());
commit 5167bd389b242d6b3bd1558eae41e53aeb5544ae
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 14 17:51:56 2011 -0400
i see this fail one in a blue moon and still can't figure out why. I tried to replicate and step thru with debugger, and it works.
dump the resource error entity that failed to persist - maybe that can help out next time this happens
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
index 65f8c7c..9160eb4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
@@ -41,7 +41,6 @@ import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
-import org.rhq.core.domain.resource.ResourceUpgradeReport;
import org.rhq.core.util.collection.ArrayUtils;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.server.alert.AlertDefinitionCreationException;
@@ -66,8 +65,8 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
/**
* @see DiscoveryServerService#mergeInventoryReport(InventoryReport)
*/
- public ResourceSyncInfo mergeInventoryReport(InventoryReport report)
- throws InvalidInventoryReportException, StaleTypeException {
+ public ResourceSyncInfo mergeInventoryReport(InventoryReport report) throws InvalidInventoryReportException,
+ StaleTypeException {
long start = System.currentTimeMillis();
DiscoveryBossLocal discoveryBoss = LookupUtil.getDiscoveryBoss();
ResourceSyncInfo syncInfo;
@@ -163,8 +162,13 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
}
public void setResourceError(ResourceError resourceError) {
- ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
- resourceManager.addResourceError(resourceError);
+ try {
+ ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+ resourceManager.addResourceError(resourceError);
+ } catch (RuntimeException re) {
+ log.error("Failed to persist resource error: " + resourceError);
+ throw re;
+ }
}
public void clearResourceConfigError(int resourceId) {
@@ -186,7 +190,7 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
DiscoveryBossLocal discoveryBoss = LookupUtil.getDiscoveryBoss();
return discoveryBoss.upgradeResources(upgradeRequests);
}
-
+
private static Resource convertToPojoResource(Resource resource, boolean includeDescendants) {
Resource pojoResource = new Resource(resource.getId());
pojoResource.setUuid(resource.getUuid());
commit 607155405b99c245e9e1679ee785bd22b97e3505
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 14 17:14:17 2011 -0400
the operation history list is not sorted and sometimes the ordering is ad-hoc.
want to see the last executed op at the top of the list and sorted descendingly
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
index edb9ff7..50593ec 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
@@ -26,8 +26,10 @@ import com.google.gwt.i18n.client.DateTimeFormat;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickHandler;
@@ -76,6 +78,11 @@ public abstract class AbstractOperationHistoryListView<T extends AbstractOperati
List<ListGridField> fields = createFields();
setListGridFields(fields.toArray(new ListGridField[fields.size()]));
+ // explicitly sort on started time so the user can see the last operation at the top and is sorted descendingly
+ SortSpecifier sortspec = new SortSpecifier(AbstractOperationHistoryDataSource.Field.STARTED_TIME,
+ SortDirection.DESCENDING);
+ getListGrid().setSort(new SortSpecifier[] { sortspec });
+
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), getDeleteConfirmMessage(),
new TableAction() {
public boolean isEnabled(ListGridRecord[] selection) {
commit d344929e2ab8ee7fa179bd4e4420339e0daabf7f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 14 16:59:16 2011 -0400
Add Ancestry (Disambiguation) to Alert Def Subsystem View
- add Resource filtering to AlertDef criteria fetches
- eliminate a duplicate I18N property
-
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index db11bdd..4ef6e16 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -164,8 +164,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
fields.add(statusField);
if (this.entityContext.type != EntityContext.Type.Resource) {
- ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG
- .view_alerts_field_resource());
+ ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
resourceNameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
String url = LinkManager
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 d073ab1..ee50f73 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
@@ -195,12 +195,18 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
}
public void onSuccess(PageList<AlertDefinition> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
+ dataRetrieved(result, response, request);
}
});
}
+ protected void dataRetrieved(final PageList<AlertDefinition> result, final DSResponse response,
+ final DSRequest request) {
+
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+
protected abstract AlertDefinitionCriteria getCriteria(DSRequest request);
/**
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java
index 5d05431..fcd9279 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java
@@ -1,10 +1,13 @@
package org.rhq.enterprise.gui.coregui.client.report;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+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.DataSourceField;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -22,6 +25,7 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.Resource;
+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.gui.coregui.client.CoreGUI;
@@ -30,6 +34,10 @@ import org.rhq.enterprise.gui.coregui.client.alert.definitions.AbstractAlertDefi
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A tabular report that shows alert definitions on all resources in inventory.
@@ -114,19 +122,6 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
}
// add more columns
- ListGridField resourceField = new ListGridField(FIELD_RESOURCE, MSG.common_title_resource());
- resourceField.setCellFormatter(new CellFormatter() {
- @Override
- public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- AlertDefinition alertDef = copyValues(record);
- Resource resource = alertDef.getResource();
- String link = LinkManager.getResourceLink(resource.getId());
- // TODO: need disambiguation
- return "<a href=\"" + link + "\">" + resource.getName() + "</a>";
- }
- });
- fields.add(resourceField);
-
ListGridField parentField = new ListGridField(FIELD_PARENT, MSG.view_alerts_field_parent());
parentField.setWidth(100);
parentField.setShowHover(true);
@@ -182,9 +177,40 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
}
}
});
-
fields.add(parentField);
+ ListGridField resourceField = new ListGridField(FIELD_RESOURCE, MSG.common_title_resource());
+ resourceField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager
+ .getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceField.setShowHover(true);
+ resourceField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+ fields.add(resourceField);
+
+ ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+ fields.add(ancestryField);
+
return fields;
}
@@ -193,8 +219,9 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
// in order to support sorting our list grid on the parent and resource columns,
// we have to assign these to something that is sortable
ListGridRecord record = super.copyValues(from);
+ Resource resource = from.getResource();
- record.setAttribute(FIELD_RESOURCE, from.getResource().getName());
+ record.setAttribute(FIELD_RESOURCE, resource.getName());
Integer parentId = from.getParentId(); // a valid non-zero number means the alert def came from a template
AlertDefinition groupAlertDefinition = from.getGroupAlertDefinition();
@@ -205,6 +232,12 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
record.setAttribute(FIELD_PARENT, "<b>" + MSG.view_alert_definition_for_group() + "</b>");
}
+ // for ancestry handling
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+
return record;
}
@@ -229,5 +262,50 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
return fields;
}
+
+ /**
+ * Additional processing to support a cross-resource view)
+ * @param result
+ * @param response
+ * @param request
+ */
+ protected void dataRetrieved(final PageList<AlertDefinition> result, final DSResponse response,
+ final DSRequest request) {
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (AlertDefinition alertDefinition : result) {
+ Resource resource = alertDefinition.getResource();
+ if (null != resource) {
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
+
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record
+ .setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
+ }
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
index 3ed01c2..6f15250 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
@@ -18,12 +18,14 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import java.util.ArrayList;
import java.util.List;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.AlertDefinitionGWTService;
@@ -44,6 +46,17 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
try {
PageList<AlertDefinition> results = this.alertDefManager.findAlertDefinitionsByCriteria(
getSessionSubject(), criteria);
+ if (!results.isEmpty()) {
+ List<Resource> resources = new ArrayList<Resource>(results.size());
+ for (AlertDefinition alertDefinition : results) {
+ Resource res = alertDefinition.getResource();
+ if (null != res) {
+ resources.add(res);
+ }
+ }
+ ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet);
+ }
+
return SerialUtility.prepare(results, "findAlertDefinitionsByCriteria");
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
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 a6b9716..e8066f3 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
@@ -882,7 +882,6 @@ view_alerts_field_condition_text = Condition Text
view_alerts_field_condition_text_none = No Conditions
view_alerts_field_condition_text_many = Multiple Conditions
view_alerts_field_condition_value = Condition Value
-view_alerts_field_resource = Resource
view_alerts_field_priority = Priority
view_alerts_field_parent = Parent
view_alerts_field_protected = Protected
commit a12a99c6806199323f2917fdc9f26603a76c7849
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Mar 16 15:56:39 2011 -0400
[BZ 677349] Adding logic to avoid deadlock during PC initialization
This commit adds an InitializationListener api to PluginContainer. When
plugin components start up while the PC is still initializing and
register event pollers, they now do so by way of this
InitializationListener api. EventContextImpl now registers a listener,
which does not require a lock and therefore eliminates the possibility
for deadlock. When the listener is invoked, the PC has already
released the write lock, EventManager is already up and running, and
there should be no problem registering the event poller at this point.
Also note the listener runs in the same thread that executes
PluginContainer.initialize.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
index b7caddc..a5af9d1 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
@@ -26,6 +26,8 @@ import java.beans.Introspector;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
@@ -86,6 +88,17 @@ public class PluginContainer implements ContainerService {
}
}
+ /**
+ * Invoked by the plugin container immediately after it is initialized
+ */
+ public static interface InitializationListener {
+ /**
+ * Notifies the listener that the plugin container has been initialized. This method executes in the same
+ * thread in which {@link PluginContainer#initialize()} is executing.
+ */
+ void initialized();
+ }
+
// our management interface
private PluginContainerMBeanImpl mbean;
@@ -114,6 +127,9 @@ public class PluginContainer implements ContainerService {
// this is to prevent race conditions on startup between components from all the different managers
private ReadWriteLock rwLock = new ReentrantReadWriteLock();
+ private List<InitializationListener> initListeners;
+ private Object initListenersLock = new Object();
+
/**
* Returns the singleton instance.
*
@@ -228,6 +244,7 @@ public class PluginContainer implements ContainerService {
* <p>If the plugin container has already been initialized, this method does nothing and returns.</p>
*/
public void initialize() {
+ initListeners = new LinkedList<InitializationListener>();
Lock lock = obtainWriteLock();
try {
if (!started) {
@@ -276,7 +293,16 @@ public class PluginContainer implements ContainerService {
} finally {
releaseLock(lock);
}
-
+
+ synchronized (initListenersLock) {
+ if (started) {
+ for (InitializationListener listener : initListeners) {
+ listener.initialized();
+ }
+ }
+ initListeners.clear();
+ }
+
return;
}
@@ -598,4 +624,19 @@ public class PluginContainer implements ContainerService {
rebootListener.reboot();
}
+ /**
+ * Add the callback listener to notify when the plugin container is initialized. If this method is invoked and
+ * the PC is already initialized, then <code>listener</code> will be invoked immediately.
+ * @param listener The callback object to notify
+ */
+ public void addInitializationListener(InitializationListener listener) {
+ synchronized (initListenersLock) {
+ if (started) {
+ listener.initialized();
+ } else {
+ initListeners.add(listener);
+ }
+ }
+ }
+
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java
index 943ed40..64a6ff7 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java
@@ -104,12 +104,20 @@ public class EventContextImpl implements EventContext {
return getEventManager().getSigar();
}
- private void registerEventPollerInternal(EventPoller poller, int pollingInterval, String sourceLocation) {
+ private void registerEventPollerInternal(final EventPoller poller, int pollingInterval,
+ final String sourceLocation) {
EventDefinition eventDefinition = EventUtility.getEventDefinition(poller.getEventType(), this.resource.getResourceType());
if (eventDefinition == null)
throw new IllegalArgumentException("Poller has unknown event type - no EventDefinition exists with name '" + poller.getEventType() + "'.");
- int adjustedPollingInterval = Math.max(EventContext.MINIMUM_POLLING_INTERVAL, pollingInterval);
- getEventManager().registerEventPoller(poller, adjustedPollingInterval, this.resource, sourceLocation);
+ final int adjustedPollingInterval = Math.max(EventContext.MINIMUM_POLLING_INTERVAL, pollingInterval);
+ // Registering the event poller has to be done in a callback listener to avoid a potential deadlock.
+ // See https://bugzilla.redhat.com/show_bug.cgi?id=677349 for a detailed explaination.
+ PluginContainer.getInstance().addInitializationListener(new PluginContainer.InitializationListener() {
+ @Override
+ public void initialized() {
+ getEventManager().registerEventPoller(poller, adjustedPollingInterval, resource, sourceLocation);
+ }
+ });
}
private void unregisterEventPollerInternal(String eventType, String sourceLocation) {
13 years, 3 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java | 19 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java | 50 ++++++----
2 files changed, 47 insertions(+), 22 deletions(-)
New commits:
commit d3576dd47e559238253097f8f921740a5a8ce97b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 16 15:25:43 2011 -0400
Ancestry (Disambiguation) Work
- Added Ancestry to group operations serial execution ordering
- ReorderableList now allows for a nameHoverCustomizer to be provided
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java
index e313835..7e06b20 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/sorter/ReorderableList.java
@@ -24,9 +24,9 @@ import java.util.List;
import java.util.Set;
import com.google.gwt.event.shared.HandlerRegistration;
-import com.smartgwt.client.types.Cursor;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordDropEvent;
@@ -56,12 +56,19 @@ public class ReorderableList extends LocatableVLayout {
private boolean isReadOnly;
+ private HoverCustomizer nameHoverCustomizer;
+
public ReorderableList(String locatorId, ListGridRecord[] records, String itemTitle, String itemIcon) {
- this(locatorId, false, records, itemTitle, itemIcon);
+ this(locatorId, false, records, itemTitle, itemIcon, null);
+ }
+
+ public ReorderableList(String locatorId, ListGridRecord[] records, String itemTitle, String itemIcon,
+ HoverCustomizer nameHoverCustomizer) {
+ this(locatorId, false, records, itemTitle, itemIcon, nameHoverCustomizer);
}
public ReorderableList(String locatorId, boolean isReadOnly, ListGridRecord[] records, String itemTitle,
- String itemIcon) {
+ String itemIcon, HoverCustomizer nameHoverCustomizer) {
super(locatorId);
this.isReadOnly = isReadOnly;
@@ -80,6 +87,8 @@ public class ReorderableList extends LocatableVLayout {
this.itemTitle = itemTitle;
this.itemIcon = itemIcon;
+
+ this.nameHoverCustomizer = nameHoverCustomizer;
}
/**
@@ -126,6 +135,10 @@ public class ReorderableList extends LocatableVLayout {
fields.add(iconField);
}
ListGridField nameField = new ListGridField(getNameField(), this.nameFieldTitle);
+ if (null != this.nameHoverCustomizer) {
+ nameField.setShowHover(true);
+ nameField.setHoverCustomizer(this.nameHoverCustomizer);
+ }
fields.add(nameField);
this.listGrid.setFields(fields.toArray(new ListGridField[fields.size()]));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
index 832acfe..843be1d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
@@ -1,5 +1,10 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
@@ -11,9 +16,11 @@ import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
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.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
@@ -21,14 +28,10 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
import org.rhq.enterprise.gui.coregui.client.components.sorter.ReorderableList;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-
/**
* The details view of the Group Operations>Schedules subtab.
*
@@ -47,8 +50,8 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
private ReorderableList memberExecutionOrderer;
public GroupOperationScheduleDetailsView(String locatorId, ResourceGroupComposite groupComposite, int scheduleId) {
- super(locatorId, new GroupOperationScheduleDataSource(groupComposite),
- groupComposite.getResourceGroup().getResourceType(), scheduleId);
+ super(locatorId, new GroupOperationScheduleDataSource(groupComposite), groupComposite.getResourceGroup()
+ .getResourceType(), scheduleId);
this.groupComposite = groupComposite;
}
@@ -61,8 +64,8 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
protected void init(final boolean isReadOnly) {
if (isNewRecord()) {
ResourceDatasource resourceDatasource = new ResourceDatasource();
- Criteria criteria = new Criteria(ResourceDatasource.FILTER_GROUP_ID,
- String.valueOf(this.groupComposite.getResourceGroup().getId()));
+ Criteria criteria = new Criteria(ResourceDatasource.FILTER_GROUP_ID, String.valueOf(this.groupComposite
+ .getResourceGroup().getId()));
resourceDatasource.fetchData(criteria, new DSCallback() {
public void execute(DSResponse response, Object rawData, DSRequest request) {
if (response.getStatus() != DSResponse.STATUS_SUCCESS) {
@@ -94,8 +97,8 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
this.executionModeForm.setNumCols(2);
this.executionModeForm.setColWidths(FIRST_COLUMN_WIDTH, "*");
- RadioGroupItem executionModeItem = new RadioGroupItem(FIELD_EXECUTION_MODE,
- MSG.view_group_operationScheduleDetails_field_execute());
+ RadioGroupItem executionModeItem = new RadioGroupItem(FIELD_EXECUTION_MODE, MSG
+ .view_group_operationScheduleDetails_field_execute());
LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(2);
valueMap.put(EXECUTION_ORDER_PARALLEL, MSG.view_group_operationScheduleDetails_value_parallel());
valueMap.put(EXECUTION_ORDER_SEQUENTIAL, MSG.view_group_operationScheduleDetails_value_sequential());
@@ -104,7 +107,7 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
executionModeItem.setShowTitle(true);
final CheckboxItem haltOnFailureItem = new CheckboxItem(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE,
- MSG.view_group_operationScheduleDetails_field_haltOnFailure());
+ MSG.view_group_operationScheduleDetails_field_haltOnFailure());
haltOnFailureItem.setDefaultValue(false);
haltOnFailureItem.setVisible(false);
haltOnFailureItem.setLabelAsTitle(true);
@@ -120,8 +123,13 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
hLayout.addMember(horizontalSpacer);
ResourceCategory resourceCategory = this.groupComposite.getResourceGroup().getResourceType().getCategory();
String memberIcon = ImageManager.getResourceIcon(resourceCategory);
+ HoverCustomizer nameHoverCustomizer = new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ };
this.memberExecutionOrderer = new ReorderableList(extendLocatorId("MemberExecutionOrderer"),
- this.memberResourceRecords, null, memberIcon);
+ this.memberResourceRecords, null, memberIcon, nameHoverCustomizer);
this.memberExecutionOrderer.setVisible(false);
this.memberExecutionOrderer.setNameFieldTitle(MSG.view_group_operationScheduleDetails_memberResource());
hLayout.addMember(this.memberExecutionOrderer);
@@ -144,22 +152,24 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
@Override
protected void editExistingRecord(Record record) {
- List<Resource> executionOrder =
- (List<Resource>) record.getAttributeAsObject(GroupOperationScheduleDataSource.Field.EXECUTION_ORDER);
+ List<Resource> executionOrder = (List<Resource>) record
+ .getAttributeAsObject(GroupOperationScheduleDataSource.Field.EXECUTION_ORDER);
if (executionOrder != null) {
this.executionModeForm.setValue(FIELD_EXECUTION_MODE, EXECUTION_ORDER_SEQUENTIAL);
ResourceDatasource resourceDatasource = new ResourceDatasource();
ListGridRecord[] resourceRecords = resourceDatasource.buildRecords(executionOrder);
this.memberExecutionOrderer.setRecords(resourceRecords);
this.memberExecutionOrderer.show();
- FormItem haltOnFailureItem = executionModeForm.getField(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
+ FormItem haltOnFailureItem = executionModeForm
+ .getField(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
haltOnFailureItem.show();
} else {
this.executionModeForm.setValue(FIELD_EXECUTION_MODE, EXECUTION_ORDER_PARALLEL);
}
Object haltOnFailure = getForm().getValue(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
- FormItem haltOnFailureItem = this.executionModeForm.getField(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
+ FormItem haltOnFailureItem = this.executionModeForm
+ .getField(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
haltOnFailureItem.setValue(haltOnFailure);
super.editExistingRecord(record);
@@ -177,9 +187,11 @@ public class GroupOperationScheduleDetailsView extends AbstractOperationSchedule
} else {
executionOrder = null;
}
- requestProperties.setAttribute(GroupOperationScheduleDataSource.RequestProperty.EXECUTION_ORDER, executionOrder);
+ requestProperties
+ .setAttribute(GroupOperationScheduleDataSource.RequestProperty.EXECUTION_ORDER, executionOrder);
- Boolean haltOnFailure = (Boolean) this.executionModeForm.getValue(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
+ Boolean haltOnFailure = (Boolean) this.executionModeForm
+ .getValue(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE);
getForm().setValue(GroupOperationScheduleDataSource.Field.HALT_ON_FAILURE, haltOnFailure);
super.save(requestProperties);
13 years, 3 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/footer/FavoritesButton.java | 269 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java | 57 +-
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 4
3 files changed, 206 insertions(+), 124 deletions(-)
New commits:
commit ef596d52ec21a3c373cdc0e291b63b495f487214
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 16 14:17:36 2011 -0400
Ancestry (Disambiguation) Work
- Incorporate Ancestry into Favorites Button
- add some missing I18N to AncestryUtil
- add basic ancestry hover text for platforms
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 b255002..ba5e649 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
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.footer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -34,6 +35,7 @@ import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
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.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
@@ -42,6 +44,9 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
/**
@@ -117,114 +122,184 @@ public class FavoritesButton extends LocatableIMenuButton {
CoreGUI.getErrorHandler().handleError(MSG.view_dashboard_favorites_error1(), caught);
}
- public void onSuccess(Favorites favorites) {
- // generate the menus
- if (!favoriteResourceIds.isEmpty()) {
- List<MenuItem> items = new ArrayList<MenuItem>(favoriteResourceIds.size());
+ public void onSuccess(final Favorites favorites) {
+ // For Ancestry we need all the resource types and ancestry resource types loaded
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (Resource resource : favorites.resources) {
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
- for (final Integer resourceId : favoriteResourceIds) {
- Resource resource = favorites.getResource(resourceId);
- if (null == resource) {
- // if the resource is gone just skip it
- continue;
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]),
+ new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ // generate the menus
+ buildFavoriteResourcesMenu(favorites, favoriteResourcesMenu, favoriteResourceIds,
+ typesWrapper);
+ buildFavoriteGroupsMenu(favorites, favoriteGroupsMenu, favoriteGroupIds);
+ buildRecentlyViewedMenu(favorites, recentlyViewedMenu, recentResourceIds,
+ recentGroupIds, typesWrapper);
+
+ favoritesMenu.showContextMenu();
}
+ });
+ }
+ });
+ }
+ });
+ }
- MenuItem item = new MenuItem(String.valueOf(resourceId));
- // TODO: Ideally, we should use ResourceManagerLocal.disambiguate() here to obtain
- // disambiguated Resource names.
- item.setTitle(resource.getName());
- item.setIcon(ImageManager.getResourceIcon(resource));
- item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
- }
- });
- items.add(item);
- }
- favoriteResourcesMenu.setItems(items.toArray(new MenuItem[items.size()]));
- }
+ private void buildFavoriteResourcesMenu(Favorites favorites, Menu menu, Set<Integer> resourceIds,
+ AncestryUtil.MapWrapper typesWrapper) {
- if (!favoriteGroupIds.isEmpty()) {
- List<MenuItem> items = new ArrayList<MenuItem>(favoriteGroupIds.size());
+ if (resourceIds.isEmpty()) {
+ menu.setItems();
+ return;
+ }
- for (final Integer groupId : favoriteGroupIds) {
- ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
- if (null == groupComposite) {
- // if the resource group is gone just skip it
- continue;
- }
- ResourceGroup group = groupComposite.getResourceGroup();
-
- MenuItem item = new MenuItem(String.valueOf(groupId));
- item.setTitle(group.getName());
- item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite
- .getImplicitAvail()));
-
- item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceGroupLink(groupId));
- }
- });
- items.add(item);
- }
- favoriteGroupsMenu.setItems(items.toArray(new MenuItem[items.size()]));
- }
+ List<MenuItem> items = new ArrayList<MenuItem>(resourceIds.size());
- if (!(recentResourceIds.isEmpty() && recentGroupIds.isEmpty())) {
- List<MenuItem> items = new ArrayList<MenuItem>(recentResourceIds.size()
- + recentGroupIds.size());
+ for (final Integer resourceId : resourceIds) {
+ Resource resource = favorites.getResource(resourceId);
+ if (null == resource) {
+ // if the resource is gone just skip it
+ continue;
+ }
- for (final Integer resourceId : recentResourceIds) {
- Resource resource = favorites.getResource(resourceId);
- if (null == resource) {
- // if the resource is gone just skip it
- continue;
- }
+ MenuItem item = new MenuItem(resource.getName());
+ item.setIcon(ImageManager.getResourceIcon(resource));
+
+ // build a subMenu to display a disambiguated resource
+ item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId);
+ item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+ item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+ Menu ancestryMenu = new Menu();
+ MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, 0));
+ ancestryItem.setEnabled(false);
+ ancestryMenu.setItems(ancestryItem);
+ item.setSubmenu(ancestryMenu);
+
+ item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
+ }
+ });
- MenuItem item = new MenuItem(String.valueOf(resourceId));
- // TODO: Ideally, we should use ResourceManagerLocal.disambiguate() here to obtain
- // disambiguated Resource names.
- item.setTitle(resource.getName());
- item.setIcon(ImageManager.getResourceIcon(resource));
- item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
- }
- });
- items.add(item);
- }
- if (!recentResourceIds.isEmpty() && !recentGroupIds.isEmpty()) {
- items.add(new MenuItemSeparator());
- }
- for (final Integer groupId : recentGroupIds) {
- ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
- if (null == groupComposite) {
- // if the resource group is gone just skip it
- continue;
- }
- ResourceGroup group = groupComposite.getResourceGroup();
-
- MenuItem item = new MenuItem(String.valueOf(groupId));
- item.setTitle(group.getName());
- item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite
- .getImplicitAvail()));
-
- item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceGroupLink(groupId));
- }
- });
- items.add(item);
- }
+ items.add(item);
+ }
- recentlyViewedMenu.setItems(items.toArray(new MenuItem[items.size()]));
- }
+ menu.setCanSelectParentItems(Boolean.TRUE);
+ menu.setItems(items.toArray(new MenuItem[items.size()]));
+ }
- favoritesMenu.showContextMenu();
- }
- });
+ private void buildFavoriteGroupsMenu(Favorites favorites, Menu menu, Set<Integer> groupIds) {
+
+ if (groupIds.isEmpty()) {
+ menu.setItems();
+ return;
+ }
+
+ List<MenuItem> items = new ArrayList<MenuItem>(groupIds.size());
+
+ for (final Integer groupId : groupIds) {
+ ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
+ if (null == groupComposite) {
+ // if the resource group is gone just skip it
+ continue;
}
- });
+ ResourceGroup group = groupComposite.getResourceGroup();
+
+ MenuItem item = new MenuItem(String.valueOf(groupId));
+ item.setTitle(group.getName());
+ item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite.getImplicitAvail()));
+
+ item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ CoreGUI.goToView(LinkManager.getResourceGroupLink(groupId));
+ }
+ });
+ items.add(item);
+ }
+ menu.setItems(items.toArray(new MenuItem[items.size()]));
+ }
+
+ private void buildRecentlyViewedMenu(Favorites favorites, Menu menu, List<Integer> recentResourceIds,
+ List<Integer> recentGroupIds, AncestryUtil.MapWrapper typesWrapper) {
+
+ if (recentResourceIds.isEmpty() && recentGroupIds.isEmpty()) {
+ return;
+ }
+ List<MenuItem> items = new ArrayList<MenuItem>(recentResourceIds.size() + recentGroupIds.size() + 1);
+
+ for (final Integer resourceId : recentResourceIds) {
+ Resource resource = favorites.getResource(resourceId);
+ if (null == resource) {
+ // if the resource is gone just skip it
+ continue;
+ }
+
+ MenuItem item = new MenuItem(resource.getName());
+ item.setIcon(ImageManager.getResourceIcon(resource));
+
+ // build a subMenu to display a disambiguated resource
+ item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId);
+ item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+ item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ Menu ancestryMenu = new Menu();
+ MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, 0));
+ ancestryItem.setEnabled(false);
+ ancestryMenu.setItems(ancestryItem);
+ item.setSubmenu(ancestryMenu);
+
+ item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
+ }
+ });
+
+ items.add(item);
+ }
+
+ if (!recentResourceIds.isEmpty() && !recentGroupIds.isEmpty()) {
+ items.add(new MenuItemSeparator());
+ }
+
+ for (final Integer groupId : recentGroupIds) {
+ ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
+ if (null == groupComposite) {
+ // if the resource group is gone just skip it
+ continue;
+ }
+ ResourceGroup group = groupComposite.getResourceGroup();
+
+ MenuItem item = new MenuItem(String.valueOf(groupId));
+ item.setTitle(group.getName());
+ item.setIcon(ImageManager.getGroupIcon(group.getGroupCategory(), groupComposite.getImplicitAvail()));
+
+ item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ CoreGUI.goToView(LinkManager.getResourceGroupLink(groupId));
+ }
+ });
+ items.add(item);
+ }
+
+ menu.setCanSelectParentItems(Boolean.TRUE);
+ menu.setItems(items.toArray(new MenuItem[items.size()]));
}
private void fetchFavorites(Set<Integer> resourceIds, final Set<Integer> groupIds,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
index 33a5246..e4af271 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -36,7 +37,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Jay Shaughnessy
*/
public abstract class AncestryUtil {
-
// ListGrid Record attribute names expected to be set on records processed by the utility
public static final String RESOURCE_ANCESTRY = "resourceAncestry";
public static final String RESOURCE_ANCESTRY_VALUE = "resourceAncestryDecoded";
@@ -47,6 +47,9 @@ public abstract class AncestryUtil {
public static final String RESOURCE_NAME = "resourceName";
public static final String RESOURCE_TYPE_ID = "resourceTypeId";
+ private static final String TITLE_ANCESTRY = CoreGUI.getMessages().util_ancestry_parentAncestry() + " ";
+ private static final String TITLE_PLATFORM = CoreGUI.getMessages().common_title_platform() + ": ";
+
/**
* Get the complete set of resource types in the ancestries provided. This is useful for
* being able to load all the types in advance of generating decoded values.
@@ -158,11 +161,6 @@ public abstract class AncestryUtil {
return ancestryHover;
}
- String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
- if (null == ancestry) {
- return "";
- }
-
Integer resourceId = listGridRecord.getAttributeAsInt(RESOURCE_ID);
// if not set assume the standard "id" attr is a resourceId
resourceId = (null != resourceId) ? resourceId : listGridRecord.getAttributeAsInt("id");
@@ -174,38 +172,43 @@ public abstract class AncestryUtil {
Integer resourceTypeId = listGridRecord.getAttributeAsInt(RESOURCE_TYPE_ID);
ResourceType type = types.get(resourceTypeId);
String resourceLongName = getResourceLongName(resourceName, type);
+ String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
width = (width <= 0) ? 500 : width;
// decode ancestry
StringBuilder sb = new StringBuilder("<p style='width:");
sb.append(width);
- sb.append("px'>Parent Ancestry for: ");
+ sb.append("px'>");
+ String title = (null != ancestry) ? TITLE_ANCESTRY : TITLE_PLATFORM;
+ sb.append(title);
sb.append(resourceLongName);
- sb.append("<hr/>");
- String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
- for (int i = ancestryEntries.length - 1, j = 0; i >= 0; --i, ++j) {
- String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
- int ancestorTypeId = Integer.valueOf(entryTokens[0]);
- String ancestorName = entryTokens[2];
-
- // indent with spaces
- if (j > 0) {
- sb.append("<br/>");
- for (int k = 0; k < j; ++k) {
- sb.append(" ");
+ if (null != ancestry) {
+ sb.append("<hr/>");
+ String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
+ for (int i = ancestryEntries.length - 1, j = 0; i >= 0; --i, ++j) {
+ String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
+ int ancestorTypeId = Integer.valueOf(entryTokens[0]);
+ String ancestorName = entryTokens[2];
+
+ // indent with spaces
+ if (j > 0) {
+ sb.append("<br/>");
+ for (int k = 0; k < j; ++k) {
+ sb.append(" ");
+ }
}
+ type = types.get(ancestorTypeId);
+ sb.append(getResourceLongName(ancestorName, type));
}
- type = types.get(ancestorTypeId);
- sb.append(getResourceLongName(ancestorName, type));
- }
- // add target resource, indent with spaces
- sb.append("<br/>");
- for (int k = 0; k <= ancestryEntries.length; ++k) {
- sb.append(" ");
+ // add target resource, indent with spaces
+ sb.append("<br/>");
+ for (int k = 0; k <= ancestryEntries.length; ++k) {
+ sb.append(" ");
+ }
+ sb.append(resourceLongName);
}
- sb.append(resourceLongName);
sb.append("</p>");
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 2fe6caf..63a07c0 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
@@ -375,6 +375,10 @@ widget_durationItem_unitTypeNotSupported = Unit type [{0}] is not supported by t
#===================== Utils ======================
+# Ancestry
+#-------------------------------------------------
+util_ancestry_parentAncestry = Parent Ancestry for:
+
# Disambiguation Report Decorator
#-------------------------------------------------
util_disambiguationReportDecorator_pluginSuffix = ({0} plugin)
13 years, 3 months
[rhq] 3 commits - etc/samples modules/enterprise
by mazz
etc/samples/skeleton-plugin/pom.xml | 2
etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java | 47 +++++++-
etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml | 1
modules/enterprise/server/safe-invoker/pom.xml | 57 ++++++++++
4 files changed, 99 insertions(+), 8 deletions(-)
New commits:
commit 70ba6ad552ca3cd26a37f608167f93ef84f836e5
Merge: cab8164 7ae9c6f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 16 10:08:18 2011 -0400
Merge commit 'origin/master'
commit cab8164d22bf9a072efc46e71e02bcc6c5146f25
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 16 10:07:51 2011 -0400
fix up skeleton plugin example. bump up version number and add the new manual add facet
diff --git a/etc/samples/skeleton-plugin/pom.xml b/etc/samples/skeleton-plugin/pom.xml
index 4e2d1b6..8055bc5 100644
--- a/etc/samples/skeleton-plugin/pom.xml
+++ b/etc/samples/skeleton-plugin/pom.xml
@@ -15,7 +15,7 @@
<description>A template for building a custom RHQ Agent plugin</description>
<properties>
- <rhq.version>3.0.0.B05</rhq.version>
+ <rhq.version>4.0.0-SNAPSHOT</rhq.version>
</properties>
<dependencies>
diff --git a/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java b/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java
index d49468f..2bb46e6 100644
--- a/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java
+++ b/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginDiscoveryComponent.java
@@ -21,10 +21,14 @@ package org.rhq.sample.skeletonplugin;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -35,15 +39,50 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
*
* @author John Mazzitelli
*/
-public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponent {
+@SuppressWarnings("unchecked")
+public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
private final Log log = LogFactory.getLog(SamplePluginDiscoveryComponent.class);
/**
+ * This discovery method is the way the plugin supports "manual-add" capability. The plugin
+ * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
+ * If that attribute is false, this method will never be used since it will not be possible to manually
+ * add an instance of the resource.
+ *
+ * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
+ */
+ @Override
+ public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
+ ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
+
+ // pluginConfiguration contains information on a resource that was manually added by the user.
+ // take it and build a details object that represents that resource.
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Manually Added Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, pluginConfiguration, null);
+
+ return resource;
+ }
+
+ /**
* Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
* you need to do in this method.
*
* @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
*/
+ @Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
log.info("Discovering my custom plugin's resources");
@@ -54,12 +93,6 @@ public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponen
// determine if you want to include the result in this method's returned set of discovered resources
}
- List<Configuration> pluginConfigs = context.getPluginConfigurations();
- for (Configuration pluginConfig : pluginConfigs) {
- // pluginConfig contains information on a resource that was manually discovered/entered by the user
- // take it and build a details object that represents that resource
- }
-
// now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
// create a details object that describe the resource that you discovered.
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
diff --git a/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml b/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
index 3ed4e37..2547af7 100644
--- a/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
+++ b/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
@@ -29,6 +29,7 @@
<server name="Sample Plugin Server"
discovery="SamplePluginDiscoveryComponent"
class="SamplePluginServerComponent"
+ supportsManualAdd="true"
description="This is a sample resource type and should be removed.">
<!--
commit 3074609ed7d46b793a728b7762937763a524213e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 15 13:16:57 2011 -0400
support -Pdev when building safe-invoker
diff --git a/modules/enterprise/server/safe-invoker/pom.xml b/modules/enterprise/server/safe-invoker/pom.xml
index 12ea01d..94b88bb 100644
--- a/modules/enterprise/server/safe-invoker/pom.xml
+++ b/modules/enterprise/server/safe-invoker/pom.xml
@@ -49,6 +49,63 @@
</dependencies>
<profiles>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentName>${project.build.finalName}.jar</rhq.deploymentName>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${rhq.deploymentName}" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${rhq.deploymentName}" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
<profile>
<id>cobertura</id>
<activation>
13 years, 3 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java | 13 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDataSource.java | 62 +++++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java | 33 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java | 34 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java | 17 ++
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 2
7 files changed, 146 insertions(+), 16 deletions(-)
New commits:
commit 7ae9c6fbe12e84379972da3fdea79263403b58dd
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Mar 15 16:49:27 2011 -0400
Ancestry (Disambiguation) Work
- Added Ancestry to Group traits Views
- added Resource filtering to Trait critria fetches
- changed to standard "Resource" column and removed obsolete I18N prop
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 102d598..d87097a 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
@@ -103,14 +103,19 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
long fetchDuration = System.currentTimeMillis() - startTime;
com.allen_sauer.gwt.log.client.Log.info(result.size() + " traits fetched in: " + fetchDuration + "ms");
- response.setData(buildRecords(result));
- // For paging to work, we have to specify size of full result set.
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
+ dataRetrieved(result, response, request);
}
});
}
+ protected void dataRetrieved(final PageList<MeasurementDataTrait> result, final DSResponse response,
+ final DSRequest request) {
+ response.setData(buildRecords(result));
+ // For paging to work, we have to specify size of full result set.
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
protected MeasurementDataTraitCriteria getCriteria(DSRequest request) {
MeasurementDataTraitCriteria criteria = new MeasurementDataTraitCriteria();
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 777cc74..152852e 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
@@ -18,16 +18,27 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
+import java.util.HashSet;
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.DataSourceField;
+import com.smartgwt.client.data.Record;
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;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
/**
* A DataSource for reading traits for the current group.
@@ -51,9 +62,13 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
fields.add(0, groupIdField);
DataSourceTextField resourceNameField = new DataSourceTextField(
- MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, MSG.dataSource_traits_group_field_memberResource());
+ MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, MSG.common_title_resource());
fields.add(0, resourceNameField);
+ DataSourceTextField ancestryField = new DataSourceTextField(AncestryUtil.RESOURCE_ANCESTRY, MSG
+ .common_title_ancestry());
+ fields.add(1, ancestryField);
+
return fields;
}
@@ -63,9 +78,50 @@ public class TraitsDataSource extends AbstractMeasurementDataTraitDataSource {
record.setAttribute(MeasurementDataTraitCriteria.FILTER_FIELD_GROUP_ID, this.groupId);
- record.setAttribute(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME, from.getSchedule().getResource()
- .getName());
+ // for ancestry handling
+ Resource resource = from.getSchedule().getResource();
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
return record;
}
+
+ protected void dataRetrieved(final PageList<MeasurementDataTrait> result, final DSResponse response,
+ final DSRequest request) {
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (MeasurementDataTrait trait : result) {
+ Resource resource = trait.getSchedule().getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
+ }
+ response.setData(records);
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
}
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
index 3c7f368..b374561 100644
--- 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
@@ -19,10 +19,17 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitListDetailView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* The detail view for the group Monitoring>Traits subtab.
@@ -40,12 +47,34 @@ public class TraitsDetailView extends AbstractMeasurementDataTraitListDetailView
ListGrid listGrid = getListGrid();
- // TODO (ips): Disambiguate Resource name.
ListGridField resourceNameField = listGrid.getField(MeasurementDataTraitCriteria.SORT_FIELD_RESOURCE_NAME);
- resourceNameField.setWidth("20%");
+ resourceNameField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNameField.setShowHover(true);
+ resourceNameField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
resourceNameField.setCanGroupBy(true);
+ ListGridField ancestryField = listGrid.getField(AncestryUtil.RESOURCE_ANCESTRY);
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
}
private static Criteria createCriteria(int groupId, int definitionId) {
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 152c918..dfd3b38 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
@@ -21,11 +21,17 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.GroupStartOpen;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.MeasurementDataTraitCriteria;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementDataTraitListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* The group Monitoring>Traits subtab.
@@ -48,11 +54,35 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
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.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNameField.setShowHover(true);
+ resourceNameField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
resourceNameField.setCanGroupBy(true);
+ ListGridField ancestryField = listGrid.getField(AncestryUtil.RESOURCE_ANCESTRY);
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+
super.configureTable();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
index 4c19c9d..7ff5d62 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
@@ -35,6 +35,7 @@ import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -266,8 +267,20 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
public PageList<MeasurementDataTrait> findTraitsByCriteria(MeasurementDataTraitCriteria criteria)
throws RuntimeException {
try {
- return SerialUtility.prepare(dataManager.findTraitsByCriteria(getSessionSubject(), criteria),
- "MeasurementDataService.findTraitsByCriteria");
+ PageList<MeasurementDataTrait> results = dataManager.findTraitsByCriteria(getSessionSubject(), criteria);
+ if (!results.isEmpty() && null != results.get(0).getSchedule()
+ && null != results.get(0).getSchedule().getResource()) {
+ List<Resource> resources = new ArrayList<Resource>(results.size());
+ for (MeasurementDataTrait result : results) {
+ Resource res = result.getSchedule().getResource();
+ if (null != res) {
+ resources.add(res);
+ }
+ }
+ ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet);
+ }
+
+ return SerialUtility.prepare(results, "MeasurementDataService.findTraitsByCriteria");
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
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 29d10d2..2fe6caf 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
@@ -460,7 +460,6 @@ dataSource_traits_field_definitionID = Definition ID
dataSource_traits_field_lastChanged = Last Changed
dataSource_traits_field_trait = Trait
dataSource_traits_group_field_groupId = Group ID
-dataSource_traits_group_field_memberResource = Member Resource
# Measurement OOBs
#---------------------------------
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 713ecee..242a76b 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -323,7 +323,6 @@ dataSource_traits_field_definitionID=Definition-ID
dataSource_traits_field_lastChanged=Zuletzt geändert
dataSource_traits_field_trait=Trait
dataSource_traits_group_field_groupId=Gruppen-ID
-dataSource_traits_group_field_memberResource=Mitglieds-Ressource
# Measurement OOBs
#---------------------------------
@@ -393,7 +392,6 @@ dataSource_operationHistory_error_fetchFailure = Konnte den Verlauf der Operatio
# Configuration History
#-------------------------------
dataSource_configurationHistory_field_id = ID
-dataSource_configurationHistory_field_resource = Ressource
dataSource_configurationHistory_field_createdTime = Angelegt
dataSource_configurationHistory_field_status = Status
dataSource_configurationHistory_field_subject = Benutzer
13 years, 3 months
[rhq] modules/core
by Simeon Pinder
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java | 1 -
1 file changed, 1 deletion(-)
New commits:
commit ef770aa8acf16cd4c807039836157fc0ce917caa
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 14:48:05 2011 -0400
removing bad filteroverride.
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 4d76880..c5a6be4 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
@@ -72,7 +72,6 @@ public abstract class OperationHistoryCriteria extends Criteria {
+ " WHERE roh.resource.id IN ( ? ) ) ");
filterOverrides.put("stati", "status IN ( ? )");
- filterOverrides.put("status", "status");
sortOverrides.put("startTime", "startedTime");
sortOverrides.put("endTime", "modifiedTime");
13 years, 3 months
[rhq] 5 commits - modules/core modules/enterprise
by Simeon Pinder
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java | 78 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java | 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java | 399 ++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 469 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java | 57 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 7
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 9
11 files changed, 873 insertions(+), 209 deletions(-)
New commits:
commit 5d431ad794ebda994560a4ee83928c76297bf0a4
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 13:52:58 2011 -0400
Forgot message.properties.
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 8178702..29d10d2 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
@@ -1514,7 +1514,7 @@ view_portlet_recentAlerts_fail_msg = Failed to load resources assigned for alert
view_portlet_recentlyAdded_setting_addedPlatforms = recently added platforms
view_portlet_recentlyAdded_error1 = Failed to load recently added resources
-
+view_portlet_results_empty = No results found using specified criteria.
# =================== Inventory =====================
view_inventory_adq = Discovery Queue
commit 50a49f43b74d569ec98a6938cbf817c0b6e91e9f
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 13:36:13 2011 -0400
missing i18n message.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
index 7ad5fba..16437f6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
@@ -362,7 +362,7 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
@Override
protected void onInit() {
super.onInit();
- getListGrid().setEmptyMessage("No results found using specified criteria.");
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
}
@Override
commit d51b4545469ff745ccc8902557868fd446ecf574
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 15 13:31:38 2011 -0400
-fix OperationHistoryCriteria to tak multiple operation stati
-enable group operations portlet
-Operations Status select widget.
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 5f879ea..4d76880 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
@@ -22,12 +22,15 @@
*/
package org.rhq.core.domain.criteria;
+import java.util.List;
+
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.OperationHistory;
import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -42,6 +45,7 @@ public abstract class OperationHistoryCriteria extends Criteria {
private String filterJobName;
private String filterJobGroup;
private OperationRequestStatus filterStatus;
+ private List<OperationRequestStatus> filterStati; // requires overrides
private String filterErrorMessage;
private Integer filterOperationDefinitionId; // requires override
private String filterOperationName; // requires override
@@ -67,6 +71,9 @@ public abstract class OperationHistoryCriteria extends Criteria {
+ " FROM ResourceOperationHistory roh " //
+ " WHERE roh.resource.id IN ( ? ) ) ");
+ filterOverrides.put("stati", "status IN ( ? )");
+ filterOverrides.put("status", "status");
+
sortOverrides.put("startTime", "startedTime");
sortOverrides.put("endTime", "modifiedTime");
sortOverrides.put("operationName", "operationDefinition.name");
@@ -90,6 +97,10 @@ public abstract class OperationHistoryCriteria extends Criteria {
this.filterStatus = filterStatus;
}
+ public void addFilterStati(OperationRequestStatus... operationStatus) {
+ this.filterStati = CriteriaUtils.getListIgnoringNulls(operationStatus);
+ }
+
public void addFilterErrorMessage(String filterErrorMessage) {
this.filterErrorMessage = filterErrorMessage;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index 8b7cb0b..d4ffb3c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -441,4 +441,13 @@ public class ImageManager {
public static String getMonitorFailedLargeIcon() {
return "subsystems/monitor/Monitor_failed_24.png";
}
+
+ public static String getOperationLargeIcon() {
+ return "subsystems/control/Operation_24.png";
+ }
+
+ public static String getOperationIcon() {
+ return "subsystems/control/Operation_16.png";
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 85ef3db..c3ab5a5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -29,6 +29,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAler
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.FavoriteResourcesPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
@@ -100,6 +101,7 @@ public class PortletFactory {
registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.Factory.INSTANCE);
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
@@ -108,6 +110,7 @@ public class PortletFactory {
registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.NAME);
+ registeredGroupPortletNameMap.put(GroupOperationsPortlet.KEY, GroupOperationsPortlet.NAME);
//############## Resource Activity Dashboard ############################################
//defines mapping for Group Activity Dashboard
@@ -124,6 +127,7 @@ public class PortletFactory {
registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorLargeIcon());
registeredPortletIconMap.put(GroupOobsPortlet.KEY, ImageManager.getMonitorFailedLargeIcon());
registeredPortletIconMap.put(GroupEventsPortlet.KEY, ImageManager.getEventLargeIcon());
+ registeredPortletIconMap.put(GroupOperationsPortlet.KEY, ImageManager.getOperationLargeIcon());
}
public static Portlet buildPortlet(String locatorId, PortletWindow portletWindow, DashboardPortlet storedPortlet) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
index e68b6cc..c02f378 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.widgets.form.fields.SelectItem;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
@@ -56,6 +57,7 @@ public class PortletConfigurationEditorComponent {
String RESULT_COUNT = "RESULT_COUNT";
String RESULT_COUNT_DEFAULT = "5";
String CUSTOM_REFRESH = "CUSTOM_REFRESH";
+ String OPERATION_STATUS = "OPERATION_STATUS";
}
//configuration map initialization
@@ -73,6 +75,8 @@ public class PortletConfigurationEditorComponent {
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_BEGIN_END_FLAG, String.valueOf(false));
//whether in simple mode. Ex. 8 hrs. Defaults to 8
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_LASTN, Constant.METRIC_RANGE_LASTN_DEFAULT);
+ //operation status, if empty initialize to "" i.e. all stati
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS, "");
}
/* Single select combobox for number of items to display on the dashboard
@@ -195,4 +199,78 @@ public class PortletConfigurationEditorComponent {
return new CustomConfigMeasurementRangeEditor("alertTimeFrame", portletConfig);
}
+ public static SelectItem getOperationStatusEditor(Configuration portletConfig) {
+ SelectItem priorityFilter = new SelectItem(Constant.OPERATION_STATUS, "Operation Status");
+ priorityFilter.setWrapTitle(false);
+ priorityFilter.setWidth(325);
+ priorityFilter.setMultiple(true);
+ priorityFilter.setMultipleAppearance(MultipleAppearance.PICKLIST);
+
+ LinkedHashMap<String, String> stati = new LinkedHashMap<String, String>(4);
+ stati.put(OperationRequestStatus.SUCCESS.name(), MSG.common_status_success());
+ stati.put(OperationRequestStatus.INPROGRESS.name(), MSG.common_status_inprogress());
+ stati.put(OperationRequestStatus.CANCELED.name(), MSG.common_status_canceled());
+ stati.put(OperationRequestStatus.FAILURE.name(), MSG.common_status_failed());
+
+ LinkedHashMap<String, String> statusIcons = new LinkedHashMap<String, String>(3);
+ statusIcons.put(OperationRequestStatus.SUCCESS.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.SUCCESS));
+ statusIcons.put(OperationRequestStatus.INPROGRESS.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.INPROGRESS));
+ statusIcons.put(OperationRequestStatus.CANCELED.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.CANCELED));
+ statusIcons.put(OperationRequestStatus.FAILURE.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.FAILURE));
+ priorityFilter.setValueMap(stati);
+ priorityFilter.setValueIcons(statusIcons);
+ //reload current settings if they exist, otherwise enable all.
+ String currentValue = portletConfig.getSimple(Constant.OPERATION_STATUS).getStringValue();
+ if (currentValue.isEmpty() || currentValue.split(",").length == OperationRequestStatus.values().length) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS.name(),
+ OperationRequestStatus.CANCELED.name(), OperationRequestStatus.FAILURE.name());
+ } else {
+ //spinder:3/4/11 doing this nonsense due to some weird smartgwt issue with SelectItem in VLayout.
+ if (currentValue.equalsIgnoreCase(OperationRequestStatus.SUCCESS.name())) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,CANCELED,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS
+ .name(), OperationRequestStatus.CANCELED.name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,CANCELED")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS
+ .name(), OperationRequestStatus.CANCELED.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS
+ .name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,INPROGRESS")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.INPROGRESS
+ .name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,CANCELED,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.CANCELED.name(),
+ OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,CANCELED")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.CANCELED.name());
+ } else if (currentValue.equalsIgnoreCase("SUCCESS,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.SUCCESS.name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS")) {
+ priorityFilter.setValues(OperationRequestStatus.INPROGRESS.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,CANCELED,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.CANCELED
+ .name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,CANCELED")) {
+ priorityFilter.setValues(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.CANCELED
+ .name());
+ } else if (currentValue.equalsIgnoreCase("INPROGRESS,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.INPROGRESS.name(), OperationRequestStatus.FAILURE
+ .name());
+ } else if (currentValue.equalsIgnoreCase("CANCELED")) {
+ priorityFilter.setValues(OperationRequestStatus.CANCELED.name());
+ } else if (currentValue.equalsIgnoreCase("CANCELED,FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.CANCELED.name(), OperationRequestStatus.FAILURE.name());
+ } else if (currentValue.equalsIgnoreCase("FAILURE")) {
+ priorityFilter.setValues(OperationRequestStatus.FAILURE.name());
+ }
+ }
+ return priorityFilter;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
index ee8cdd0..7ad5fba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
@@ -371,10 +371,7 @@ public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSetti
if (getTableInfo() != null) {
int count = getListGrid().getSelection().length;
getTableInfo().setContents(
- // MSG.view_table_totalRows(String.valueOf(listGrid.getTotalRows()), String.valueOf(count)));
- //Ex. Total Rows: {0} (selected: {1})
- "Matching Rows: " + String.valueOf(getListGrid().getTotalRows()) + " (selected "
- + String.valueOf(count) + ")");
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
new file mode 100644
index 0000000..dd8187e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -0,0 +1,469 @@
+/*
+ * 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.dashboard.portlets.groups;
+
+import java.util.Arrays;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+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 org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.operation.GroupOperationHistory;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+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.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+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.dashboard.portlets.PortletConfigurationEditorComponent;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryDetailsView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Simeon Pinder
+ */
+public class GroupOperationsPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupOperations";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_operations();
+
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ private GroupOperationsCriteriaHistoryListView dataSource;
+
+ //instance ui widgets
+ private Canvas containerCanvas;
+
+ private Timer refreshTimer;
+ private DashboardPortlet storedPortlet;
+ private Configuration portletConfig;
+ private int groupId;
+ private boolean portletConfigInitialized = false;
+ private ResourceGroupComposite groupComposite;
+ private String baseViewPath = "";
+ protected LocatableCanvas recentOperationsContent = new LocatableCanvas(extendLocatorId("RecentOperations"));
+ private String locatorId;
+ private GroupOperationsCriteriaHistoryListView groupOperations;
+
+ public GroupOperationsPortlet(String locatorId) {
+ super(locatorId);
+ this.locatorId = locatorId;
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentGroupIdentifier = Integer.valueOf(elements[1]);
+ this.groupId = currentGroupIdentifier;
+ //populate basepath
+ baseViewPath = elements[0];
+
+ initializeUi();
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ private void loadData() {
+ //populate composite data
+ //locate resourceGroupRef
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(this.groupId);
+ criteria.fetchConfigurationUpdates(false);
+ criteria.fetchExplicitResources(false);
+ criteria.fetchGroupDefinition(false);
+ criteria.fetchOperationHistories(false);
+
+ // for autoclusters and autogroups we need to add more criteria
+ final boolean isAutoCluster = isAutoCluster();
+ final boolean isAutoGroup = isAutoGroup();
+ if (isAutoCluster) {
+ criteria.addFilterVisible(false);
+ } else if (isAutoGroup) {
+ criteria.addFilterVisible(false);
+ criteria.addFilterPrivate(true);
+ }
+
+ //locate the resource group
+ GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceGroupComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving resource group composite for group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceGroupComposite> results) {
+ if (!results.isEmpty()) {
+ groupComposite = results.get(0);
+ //instantiate view
+ //populated GWT criteria objects
+ Criteria criteria = new Criteria(GroupOperationHistoryDataSource.CriteriaField.GROUP_ID, String
+ .valueOf(groupComposite.getResourceGroup().getId()));
+
+ groupOperations = new GroupOperationsCriteriaHistoryListView(locatorId,
+ new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite);
+
+ //cleanup
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
+ }
+ recentOperationsContent.addChild(groupOperations);
+ recentOperationsContent.markForRedraw();
+ }
+ }
+ });
+ }
+
+ /**Defines layout for the portlet page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ setHeight100();
+ setWidth100();
+ addMember(recentOperationsContent);
+ markForRedraw();
+ }
+
+ /** Responsible for initialization and lazy configuration of the portlet values
+ */
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ //populate portlet configuration details
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+ this.storedPortlet = storedPortlet;
+ portletConfig = storedPortlet.getConfiguration();
+
+ //lazy init any elements not yet configured.
+ for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if (portletConfig.getSimple(key) == null) {
+ portletConfig.put(new PropertySimple(key,
+ PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
+ }
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_operations_criteria());
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+ LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings"));
+ LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page"));
+ //build editor form container
+ final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("alert-filter"));
+ form.setMargin(5);
+
+ //add label about what configuration affects? redundant?
+
+ //add filter operation status type selector
+ final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
+ .getOperationStatusEditor(portletConfig);
+ //add sort priority selector
+ final SelectItem resultSortSelector = PortletConfigurationEditorComponent
+ .getResulSortOrderEditor(portletConfig);
+ //add result count selector
+ final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
+ //add range selector
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
+ .getMeasurementRangeEditor(portletConfig);
+
+ form.setItems(operationStatusSelector, resultSortSelector, resultCountSelector);
+
+ //submit handler
+ customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+
+ //result count
+ String selectedValue;
+ portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
+
+ //time range configuration
+ portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
+
+ //operation priority
+ portletConfig = AbstractActivityView.saveOperationStatusSelectorSettings(operationStatusSelector,
+ portletConfig);
+
+ //persist and reload portlet
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ //resynch the config object in the datasource
+ groupOperations.setDatasource(new GroupOperationsCriteriaDataSource(portletConfig));
+ //apply latest settings to the visible result set
+ redraw();
+ }
+ });
+ form.markForRedraw();
+ page.addMember(measurementRangeEditor);
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new GroupOperationsPortlet(locatorId);
+ }
+ }
+
+ @Override
+ public void startRefreshCycle() {
+ //current setting
+ final int refreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval();
+
+ //cancel any existing timer
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ if (refreshInterval >= MeasurementUtility.MINUTES) {
+
+ refreshTimer = new Timer() {
+ public void run() {
+ redraw();
+ }
+ };
+
+ refreshTimer.scheduleRepeating(refreshInterval);
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ super.onDestroy();
+ }
+
+ private boolean isAutoGroup() {
+ return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ private boolean isAutoCluster() {
+ return ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ public String getBaseViewPath() {
+ return baseViewPath;
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+ loadData();
+ }
+}
+
+/** Provide implementation of GroupOperationsHistoryListView using datasource
+ * that customizes fetch based on Configuration parameters.
+ *
+ * @author spinder
+ */
+class GroupOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView {
+
+ private AbstractOperationHistoryDataSource datasource;
+
+ public GroupOperationsCriteriaHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource,
+ String title, Criteria criteria, ResourceGroupComposite composite) {
+ super(locatorId, dataSource, title, criteria);
+ this.datasource = dataSource;
+ this.groupComposite = composite;
+ setShowFooterRefresh(false); //disable footer refresh
+ }
+
+ private ResourceGroupComposite groupComposite;
+
+ @Override
+ protected boolean hasControlPermission() {
+ return this.groupComposite.getResourcePermission().isControl();
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new GroupOperationHistoryDetailsView(extendLocatorId("DetailsView"), this.groupComposite);
+ }
+
+ public AbstractOperationHistoryDataSource getDatasource() {
+ return datasource;
+ }
+
+ public void setDatasource(AbstractOperationHistoryDataSource datasource) {
+ this.datasource = datasource;
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
+ }
+ }
+}
+
+/** Provide implementation of GroupOperationHistoryDataSource that dynamically
+ * configures fetch requests for this table view.
+ *
+ * @author spinder
+ */
+class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource {
+
+ public GroupOperationsCriteriaDataSource(Configuration portletConfig) {
+ this.portletConfig = portletConfig;
+ }
+
+ private Configuration portletConfig;
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_ID)) {
+ int groupId = Integer.parseInt((String) request.getCriteria().getValues().get(CriteriaField.GROUP_ID));
+ criteria.addFilterResourceGroupIds(Arrays.asList(groupId));
+ }
+
+ //initialize to only five for quick queries.
+ PageControl pageControl = new PageControl(0, 5);//default to displaying five
+ //customize query with latest configuration selections
+
+ //retrieve previous settings from portlet config
+ if (portletConfig != null) {
+ //result sort order
+ PropertySimple property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ criteria.addSortStatus(PageOrdering.DESC);
+ } else {
+ criteria.addSortStatus(PageOrdering.ASC);
+ }
+ }
+ //result timeframe if enabled
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ }
+
+ //result count
+ property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) {
+ pageControl.setPageSize(5);
+ } else {
+ pageControl = new PageControl(0, Integer.valueOf(currentSetting));
+ }
+ }
+ criteria.setPageControl(pageControl);
+
+ //detect operation status filter
+ property = portletConfig.getSimple(Constant.OPERATION_STATUS);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (currentSetting.trim().isEmpty() || parsedValues.length == OperationRequestStatus.values().length) {
+ //all operation stati assumed
+ } else {
+ OperationRequestStatus[] operationStati = new OperationRequestStatus[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ OperationRequestStatus s = OperationRequestStatus.valueOf(priority);
+ operationStati[indx++] = s;
+ }
+ criteria.addFilterStati(operationStati);
+ }
+ }
+ }
+
+ operationService.findGroupOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(), caught);
+ }
+
+ public void onSuccess(PageList<GroupOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index cda2a57..42e9880 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -43,6 +43,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceTypeFacet;
@@ -486,6 +487,25 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
/** Takes the current value of the widget and persists it into the configuration object passed in.
*
+ * @param operationStatusSelector
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ public static Configuration saveOperationStatusSelectorSettings(final SelectItem operationStatusSelector,
+ final Configuration portletConfig) {
+ String selectedValue;
+ selectedValue = operationStatusSelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty())
+ || (selectedValue.split(",").length == OperationRequestStatus.values().length)) {//then no operation status specified
+ portletConfig.put(new PropertySimple(Constant.OPERATION_STATUS, ""));
+ } else {//some subset of available alertPriorities will be used
+ portletConfig.put(new PropertySimple(Constant.OPERATION_STATUS, selectedValue));
+ }
+ return portletConfig;
+ }
+
+ /** Takes the current value of the widget and persists it into the configuration object passed in.
+ *
* @param measurementRangeEditor
* @param portletConfig
* returns populated configuration object.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
index 6a415c2..7edf2ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
+
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
@@ -32,9 +33,9 @@ public class GroupOperationHistoryListView extends AbstractOperationHistoryListV
private ResourceGroupComposite groupComposite;
public GroupOperationHistoryListView(String locatorId, ResourceGroupComposite groupComposite) {
- super(locatorId, new GroupOperationHistoryDataSource(), null,
- new Criteria(GroupOperationHistoryDataSource.CriteriaField.GROUP_ID,
- String.valueOf(groupComposite.getResourceGroup().getId())));
+ super(locatorId, new GroupOperationHistoryDataSource(), null, new Criteria(
+ GroupOperationHistoryDataSource.CriteriaField.GROUP_ID, String.valueOf(groupComposite.getResourceGroup()
+ .getId())));
this.groupComposite = groupComposite;
}
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 4dfcf51..8178702 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
@@ -1367,6 +1367,7 @@ view_selector_available = Available {0}
view_subTab_error_disabled = Cannot select disabled subTab [{0}].
view_table_drawFail = Failed to draw Table [{0}].
+view_table_matchingRows = Matching Rows: {0} (selected: {1})
view_table_totalRows = Total Rows: {0} (selected: {1})
view_tableSection_backButton = Back to List
view_tableSection_error_noId = Table [{0}] record is missing 'id' attribute - please report this bug.
@@ -1453,6 +1454,7 @@ view_portlet_defaultName_tagCloud = Tag Count
view_portlet_defaultName_group_events = Group: Event Counts
view_portlet_defaultName_group_metrics = Group: Metrics
+view_portlet_defaultName_group_operations = Group: Operations
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
@@ -1464,6 +1466,7 @@ view_portlet_help_metrics = This portlet graphs relevant recent metric data base
view_portlet_help_message = This portlet displays a static HTML message. The <i>message</i> property must be configured.
view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions.
view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory.
+view_portlet_help_operations_criteria = This portlet displays Operations consistent with display criteria configured.
view_portlet_help_platformSummary = This portlet displays information about the current user''s platform resources.
view_portlet_help_problemResources = This portlet displays the current user''s alerted or unavailable resources.
view_portlet_help_recentAlerts = This portlet displays alerts recently fired on the current user''s viewable inventory.
commit 0a80bbb84d40708bd1d680b8ed8c620c780e30f2
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 14 16:44:33 2011 -0400
enabling recent metrics activity as a portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 2375ece..85ef3db 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -97,7 +97,7 @@ public class PortletFactory {
registeredGroupPortletFactoryMap = new HashMap<String, PortletViewFactory>();
registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.Factory.INSTANCE);
- // registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.Factory.INSTANCE);
@@ -105,7 +105,7 @@ public class PortletFactory {
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.NAME);
- // registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
+ registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.NAME);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
index e26f08c..fa9f7ea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java
@@ -18,7 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
@@ -34,8 +36,6 @@ 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.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.VLayout;
@@ -47,6 +47,7 @@ import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.resource.ResourceType;
+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;
@@ -61,6 +62,8 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigura
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
@@ -79,6 +82,18 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
private boolean currentlyLoading = false;
private Configuration portletConfig = null;
private DashboardPortlet storedPortlet;
+ private String baseViewPath = "";
+ private long start = -1;
+ private long end = -1;
+
+ private static List<String> CONFIG_INCLUDE = new ArrayList<String>();
+ static {
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_ENABLE);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_LASTN);
+ CONFIG_INCLUDE.add(Constant.METRIC_RANGE_UNIT);
+ }
public GroupMetricsPortlet(String locatorId) {
super(locatorId);
@@ -87,6 +102,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
String[] elements = currentPage.split("/");
int currentGroupIdentifier = Integer.valueOf(elements[1]);
this.groupId = currentGroupIdentifier;
+ baseViewPath = elements[0];
initializeUi();
}
@@ -107,7 +123,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "GroupMetrics";
// A default displayed, persisted name for the portlet
- public static final String NAME = "Group: Metrics";
+ public static final String NAME = MSG.view_portlet_defaultName_group_metrics();
public static final String ID = "id";
// set on initial configuration, the window for this portlet view.
@@ -132,7 +148,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
//lazy init any elements not yet configured.
for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
- if (portletConfig.getSimple(key) == null) {
+ if ((portletConfig.getSimple(key) == null) && CONFIG_INCLUDE.contains(key)) {
portletConfig.put(new PropertySimple(key,
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
}
@@ -140,8 +156,7 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
}
public Canvas getHelpCanvas() {
- //TODO: spinder change.
- return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
+ return new HTMLFlow(MSG.view_portlet_help_metrics());
}
public static final class Factory implements PortletViewFactory {
@@ -169,26 +184,8 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
@Override
public void onSubmitValues(SubmitValuesEvent event) {
-
- //alert time range filter. Check for enabled and then persist property. Dealing with compound widget.
- FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
- CheckboxItem itemC = (CheckboxItem) item;
- String selectedValue = String.valueOf(itemC.getValueAsBoolean());
- if (!selectedValue.trim().isEmpty()) {//then call
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue));
- }
-
- //alert time advanced time filter enabled.
- selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
- if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
- }
-
- //alert time frame
- List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (begEnd.get(0) != 0) {//advanced settings
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
- }
+ portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
//persist
storedPortlet.setConfiguration(portletConfig);
@@ -206,17 +203,45 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
* digits.
*/
private void getRecentMetrics() {
-
//display container
final VLayout column = new VLayout();
column.setHeight(10);//pack
- // final int groupId = this.groupComposite.getResourceGroup().getId();
- final int groupId = this.groupId;
+
+ //initialize to defaults
+ end = System.currentTimeMillis();
+ start = end - (1000L * 60 * 60 * 8);//last 8 hrs
+
+ //result timeframe if enabled
+ PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ start = Long.valueOf(range[0]);
+ end = Long.valueOf(range[1]);
+ }
+ }
+
+ //locate resourceGroupRef
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
- criteria.addFilterIds(groupId);
- criteria.fetchGroupDefinition(true);
- criteria.fetchResourceType(true);
- criteria.fetchExplicitResources(true);
+ criteria.addFilterId(this.groupId);
+ criteria.fetchConfigurationUpdates(false);
+ criteria.fetchExplicitResources(false);
+ criteria.fetchGroupDefinition(false);
+ criteria.fetchOperationHistories(false);
+
+ // for autoclusters and autogroups we need to add more criteria
+ final boolean isAutoCluster = isAutoCluster();
+ final boolean isAutoGroup = isAutoGroup();
+ if (isAutoCluster) {
+ criteria.addFilterVisible(false);
+ } else if (isAutoGroup) {
+ criteria.addFilterVisible(false);
+ criteria.addFilterPrivate(true);
+ }
+
+ //locate the resource group
GWTServiceLookup.getResourceGroupService().findResourceGroupCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceGroupComposite>>() {
@Override
@@ -226,152 +251,168 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
}
@Override
- public void onSuccess(PageList<ResourceGroupComposite> result) {
- if (!result.isEmpty()) {
- //retrieve all relevant measurement definition ids.
- // Set<MeasurementDefinition> definitions = this.groupComposite.getResourceGroup().getResourceType()
- ResourceGroupComposite composite = result.get(0);
- ResourceGroup group = composite.getResourceGroup();
- ResourceType type = group.getResourceType();
- Set<MeasurementDefinition> defs = type.getMetricDefinitions();
- // Log.debug("------------- Composite:" + composite);
- // Log.debug("------------- Group:" + group);
- // Log.debug("------------- Type:" + type);
- // Log.debug("------------- Defs:" + defs);
-
- Set<MeasurementDefinition> definitions = result.get(0).getResourceGroup().getResourceType()
- .getMetricDefinitions();
-
- //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
- final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
- for (MeasurementDefinition definition : definitions) {
- measurementDefMap.put(definition.getDisplayName(), definition);
- }
- //bundle definition ids for asynch call.
- int[] definitionArrayIds = new int[definitions.size()];
- final String[] displayOrder = new String[definitions.size()];
- measurementDefMap.keySet().toArray(displayOrder);
- //sort the charting data ex. Free Memory, Free Swap Space,..System Load
- Arrays.sort(displayOrder);
-
- //organize definitionArrayIds for ordered request on server.
- int index = 0;
- for (String definitionToDisplay : displayOrder) {
- definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay).getId();
- }
+ public void onSuccess(PageList<ResourceGroupComposite> results) {
+ if (!results.isEmpty()) {
+ final ResourceGroupComposite groupComposite = results.get(0);
+ final ResourceGroup group = groupComposite.getResourceGroup();
+ if (group.getGroupCategory() == GroupCategory.COMPATIBLE) {
+ // Load the fully fetched ResourceType.
+ ResourceType groupType = group.getResourceType();
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ groupType.getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.content,
+ ResourceTypeRepository.MetadataType.operations,
+ ResourceTypeRepository.MetadataType.measurements,
+ ResourceTypeRepository.MetadataType.events,
+ ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ group.setResourceType(type);
+ //metric definitions
+ Set<MeasurementDefinition> definitions = type.getMetricDefinitions();
+
+ //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
+ final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition definition : definitions) {
+ measurementDefMap.put(definition.getDisplayName(), definition);
+ }
+ //bundle definition ids for asynch call.
+ int[] definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay)
+ .getId();
+ }
- //make the asynchronous call for all the measurement data
- GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(groupId,
- definitionArrayIds, System.currentTimeMillis() - (1000L * 60 * 60 * 8),
- System.currentTimeMillis(), 60,
- new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent metrics charting data for group [" + groupId
- + "]:" + caught.getMessage());
- }
-
- @Override
- public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
- if (!results.isEmpty()) {
- boolean someChartedData = false;
- //iterate over the retrieved charting data
- for (int index = 0; index < displayOrder.length; index++) {
- //retrieve the correct measurement definition
- MeasurementDefinition md = measurementDefMap.get(displayOrder[index]);
-
- //load the data results for the given metric definition
- List<MeasurementDataNumericHighLowComposite> data = results.get(index);
-
- //locate last and minimum values.
- double lastValue = -1;
- double minValue = Double.MAX_VALUE;//
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- if (d.getValue() < minValue) {
- minValue = d.getValue();
- }
- lastValue = d.getValue();
+ //make the asynchronous call for all the measurement data
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(
+ groupId, definitionArrayIds, start, end, 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log
+ .debug("Error retrieving recent metrics charting data for group ["
+ + groupId + "]:" + caught.getMessage());
}
- }
-
- //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
- String commaDelimitedList = "";
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- commaDelimitedList += d.getValue() + ",";
+ @Override
+ public void onSuccess(
+ List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+ boolean someChartedData = false;
+ //iterate over the retrieved charting data
+ for (int index = 0; index < displayOrder.length; index++) {
+ //retrieve the correct measurement definition
+ MeasurementDefinition md = measurementDefMap
+ .get(displayOrder[index]);
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> data = results
+ .get(index);
+
+ //locate last and minimum values.
+ double lastValue = -1;
+ double minValue = Double.MAX_VALUE;//
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ if (d.getValue() < minValue) {
+ minValue = d.getValue();
+ }
+ lastValue = d.getValue();
+ }
+ }
+
+ //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
+ String commaDelimitedList = "";
+
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ && (String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ commaDelimitedList += d.getValue() + ",";
+ }
+ }
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent.extendLocatorId(md.getName()));
+ row.setNumCols(3);
+ HTMLFlow graph = new HTMLFlow();
+ // String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
+ // + commaDelimitedList + "</span>";
+ String contents = "<span id='sparkline_" + index
+ + "' class='dynamicsparkline' width='0' " + "values='"
+ + commaDelimitedList + "'>...</span>";
+ graph.setContents(contents);
+ graph.setContentsType(ContentsType.PAGE);
+ //diable scrollbars on span
+ graph.setScrollbarSize(0);
+
+ CanvasItem graphContainer = new CanvasItem();
+ graphContainer.setShowTitle(false);
+ graphContainer.setHeight(16);
+ graphContainer.setWidth(60);
+ graphContainer.setCanvas(graph);
+
+ //Link/title element
+ //TODO: spinder, change link whenever portal.war/graphing is removed.
+ String title = md.getDisplayName() + ":";
+ // String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ // + resourceId + "&m=" + md.getId();
+ String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricMultiResource&groupId="
+ + groupId + "&m=" + md.getId();
+ LinkItem link = AbstractActivityView.newLinkItem(title,
+ destination);
+
+ //Value
+ String convertedValue = lastValue + " " + md.getUnits();
+ convertedValue = AbstractActivityView
+ .convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = AbstractActivityView
+ .newTextItem(convertedValue);
+
+ row.setItems(graphContainer, link, value);
+ //if graph content returned
+ if ((md.getName().trim().indexOf("Trait.") == -1)
+ && (lastValue != -1)) {
+ column.addMember(row);
+ someChartedData = true;
+ }
+ }
+ if (!someChartedData) {// when there are results but no chartable entries.
+ LocatableDynamicForm row = AbstractActivityView
+ .createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(
+ recentMeasurementsContent
+ .extendLocatorId("RecentMeasurementsContentSeeMore"));
+ AbstractActivityView.addSeeMoreLink(row,
+ ReportDecorator.GWT_GROUP_URL + groupId
+ + "/Monitoring/Graphs/", column);
+ }
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row = AbstractActivityView
+ .createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
+ AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ }
}
- }
- LocatableDynamicForm row = new LocatableDynamicForm(
- recentMeasurementsContent.extendLocatorId(md.getName()));
- row.setNumCols(3);
- HTMLFlow graph = new HTMLFlow();
- // String contents = "<span id='sparkline_" + index + "' class='dynamicsparkline' width='0'>"
- // + commaDelimitedList + "</span>";
- String contents = "<span id='sparkline_" + index
- + "' class='dynamicsparkline' width='0' " + "values='"
- + commaDelimitedList + "'>...</span>";
- graph.setContents(contents);
- graph.setContentsType(ContentsType.PAGE);
- //diable scrollbars on span
- graph.setScrollbarSize(0);
-
- CanvasItem graphContainer = new CanvasItem();
- graphContainer.setShowTitle(false);
- graphContainer.setHeight(16);
- graphContainer.setWidth(60);
- graphContainer.setCanvas(graph);
-
- //Link/title element
- //TODO: spinder, change link whenever portal.war/graphing is removed.
- String title = md.getDisplayName() + ":";
- // String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
- // + resourceId + "&m=" + md.getId();
- String destination = "/resource/common/monitor/Visibility.do?mode=chartSingleMetricMultiResource&groupId="
- + groupId + "&m=" + md.getId();
- LinkItem link = AbstractActivityView.newLinkItem(title, destination);
-
- //Value
- String convertedValue = lastValue + " " + md.getUnits();
- convertedValue = AbstractActivityView.convertLastValueForDisplay(lastValue,
- md);
- StaticTextItem value = AbstractActivityView.newTextItem(convertedValue);
-
- row.setItems(graphContainer, link, value);
- //if graph content returned
- if ((md.getName().trim().indexOf("Trait.") == -1) && (lastValue != -1)) {
- column.addMember(row);
- someChartedData = true;
- }
- }
- if (!someChartedData) {// when there are results but no chartable entries.
- LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(
- recentMeasurementsContent.extendLocatorId("None"),
- AbstractActivityView.RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- } else {
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(
- recentMeasurementsContent
- .extendLocatorId("RecentMeasurementsContentSeeMore"));
- AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL
- + groupId + "/Monitoring/Graphs/", column);
- }
- //call out to 3rd party javascript lib
- BrowserUtility.graphSparkLines();
- } else {
- LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(
- recentMeasurementsContent.extendLocatorId("None"),
- AbstractActivityView.RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
+ });
}
- }
- });
+ });
+ }
}
-
}
});
@@ -411,7 +452,6 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
@Override
protected void onDestroy() {
if (refreshTimer != null) {
-
refreshTimer.cancel();
}
super.onDestroy();
@@ -423,4 +463,15 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
loadData();
}
+ private boolean isAutoGroup() {
+ return ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ private boolean isAutoCluster() {
+ return ResourceGroupDetailView.AUTO_CLUSTER_VIEW_PATH.equals(getBaseViewPath());
+ }
+
+ public String getBaseViewPath() {
+ return baseViewPath;
+ }
}
\ No newline at end of file
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 e766421..4dfcf51 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
@@ -1452,6 +1452,7 @@ view_portlet_defaultName_recentlyAddedResources = Recently Added Resources
view_portlet_defaultName_tagCloud = Tag Count
view_portlet_defaultName_group_events = Group: Event Counts
+view_portlet_defaultName_group_metrics = Group: Metrics
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
@@ -1459,6 +1460,7 @@ view_portlet_help_favoriteResources = This portlet displays the current user''s
view_portlet_help_graph = This portlet displays the resource metric graph.
view_portlet_help_inventorySummary = This portlet displays a short summary of the current user''s viewable inventory and metric collection rate.
view_portlet_help_mashup = This portlet displays the returned content of a remote HTTP request (via an iframe).
+view_portlet_help_metrics = This portlet graphs relevant recent metric data based on display criteria configured.
view_portlet_help_message = This portlet displays a static HTML message. The <i>message</i> property must be configured.
view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions.
view_portlet_help_operations = This portlet displays executing, completed and scheduled operations for the current user''s inventory.
commit 941ff94e822fc0696f7cdf124f704e5b88253c0b
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 11 11:13:45 2011 -0500
missing i18n message GroupEvents and refactor.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
index b8a7949..877dbf4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
@@ -31,8 +31,6 @@ 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.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.VLayout;
@@ -98,7 +96,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "GroupEvents";
// A default displayed, persisted name for the portlet
- public static final String NAME = "Group: Event Counts";
+ public static final String NAME = MSG.view_portlet_defaultName_group_events();
public static final String ID = "id";
// set on initial configuration, the window for this portlet view.
@@ -172,26 +170,9 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
@Override
public void onSubmitValues(SubmitValuesEvent event) {
- String selectedValue = null;
- //alert time range filter. Check for enabled and then persist property. Dealing with compound widget.
- FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
- CheckboxItem itemC = (CheckboxItem) item;
- selectedValue = String.valueOf(itemC.getValueAsBoolean());
- if (!selectedValue.trim().isEmpty()) {//then call
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue));
- }
-
- //alert time advanced time filter enabled.
- selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
- if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
- }
-
- //alert time frame
- List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (begEnd.get(0) != 0) {//advanced settings
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
- }
+ //persist the measurement range selections
+ portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
//persist
storedPortlet.setConfiguration(portletConfig);
@@ -199,7 +180,6 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
loadData();
customSettings.markForRedraw();
}
-
});
page.addMember(measurementRangeEditor);
customSettings.addChild(page);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index fdeca2c..cda2a57 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary;
+import java.util.List;
import java.util.Set;
import com.allen_sauer.gwt.log.client.Log;
@@ -27,6 +28,8 @@ import com.smartgwt.client.widgets.IButton;
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.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
@@ -49,6 +52,7 @@ 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.RefreshableView;
+import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
@@ -480,6 +484,39 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
return portletConfig;
}
+ /** Takes the current value of the widget and persists it into the configuration object passed in.
+ *
+ * @param measurementRangeEditor
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ public static Configuration saveMeasurementRangeEditorSettings(
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor, Configuration portletConfig) {
+ String selectedValue = null;
+ if ((measurementRangeEditor != null) && (portletConfig != null)) {
+ //time range filter. Check for enabled and then persist property. Dealing with compound widget.
+ FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
+ CheckboxItem itemC = (CheckboxItem) item;
+ selectedValue = String.valueOf(itemC.getValueAsBoolean());
+ if (!selectedValue.trim().isEmpty()) {//then call
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue));
+ }
+
+ //time advanced time filter enabled.
+ selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
+ if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ }
+
+ //time frame
+ List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
+ if (begEnd.get(0) != 0) {//advanced settings
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
+ }
+ }
+ return portletConfig;
+ }
+
protected boolean displayGroupConfigurationUpdates(GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
if ((groupCategory == null) || facets == null) {
return false;
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 e8066f3..e766421 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
@@ -1451,6 +1451,8 @@ view_portlet_defaultName_recentAlerts = Recent Alerts
view_portlet_defaultName_recentlyAddedResources = Recently Added Resources
view_portlet_defaultName_tagCloud = Tag Count
+view_portlet_defaultName_group_events = Group: Event Counts
+
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly discovered resources. Imported resources are added to inventory for monitoring and management. Ignored resources are not imported and are hidden from view unless explicitly unignored.
view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
view_portlet_help_favoriteResources = This portlet displays the current user''s favorite resources.
13 years, 3 months