[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 3cd15d95af19b8d07e537898f0fe6acb80478ae9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 23 10:06:21 2011 -0400
BZ 690110 - group tree context menu resource config link is fixed
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
index 43b3700..38edb6e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
@@ -164,8 +164,8 @@ public class ResourceGroupContextMenu extends LocatableMenu {
} else if (isAutoCluster) {
CoreGUI.goToView(LinkManager.getAutoClusterTabLink(group.getId(), "Configuration", "Current"));
} else {
- CoreGUI.goToView(LinkManager.getResourceGroupTabLink(group.getId(), "Inventory",
- "ConnectionSettings"));
+ CoreGUI
+ .goToView(LinkManager.getResourceGroupTabLink(group.getId(), "Configuration", "Current"));
}
}
});
13 years, 2 months
[rhq] modules/core
by mazz
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java | 7 +++++++
1 file changed, 7 insertions(+)
New commits:
commit 8fe2c0741089d3fa2e67b4a0cf2b85d6dd8edf7d
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 22 17:07:29 2011 -0400
BZ 689922 add a sort override since our ancestry fields are named "resourceAncestry" but the true field is "ancestry".
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index 5ecec8c..70bb96c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -100,6 +100,7 @@ public class ResourceCriteria extends TaggedCriteria {
private PageOrdering sortParentResourceName; // needs overrides
private PageOrdering sortAgentName; // needs overrides
private PageOrdering sortCurrentAvailability; // needs overrides
+ private PageOrdering sortResourceAncestry; // needs overrides
public ResourceCriteria() {
filterOverrides.put("resourceTypeId", "resourceType.id = ?");
@@ -133,6 +134,7 @@ public class ResourceCriteria extends TaggedCriteria {
sortOverrides.put("parentResourceName", "parentResource.name");
sortOverrides.put("agentName", "agent.name");
sortOverrides.put("currentAvailability", "currentAvailability.availabilityType");
+ sortOverrides.put("resourceAncestry", "ancestry");
}
@Override
@@ -373,6 +375,11 @@ public class ResourceCriteria extends TaggedCriteria {
this.sortCurrentAvailability = sortCurrentAvailability;
}
+ public void addSortResourceAncestry(PageOrdering sortAncestry) {
+ addSortField("resourceAncestry");
+ this.sortResourceAncestry = sortAncestry;
+ }
+
/** subclasses should override as necessary */
public boolean isInventoryManagerRequired() {
return (this.fetchChildResources || this.fetchParentResource);
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 14 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/lookup/ResourceLookupComboBoxItem.java | 8 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 26 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 14 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java | 17 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java | 15 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java | 15 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsDetailView.java | 14 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java | 15 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java | 14 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java | 51 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 13 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java | 14 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java | 14 --
14 files changed, 66 insertions(+), 178 deletions(-)
New commits:
commit 6d3b3cc1d6b25ca7ba94a7689279fb31c3b6cee0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 22 16:47:44 2011 -0400
create utility methods that create ancestry listgridfields in a single place AncestryUtil
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 5ca88d6..f776d56 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
@@ -181,19 +181,7 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
});
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);
- }
- });
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
fields.add(ancestryField);
ctimeField.setWidth(125);
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 2d3692c..a96f42a 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
@@ -59,17 +59,13 @@ public class ResourceLookupComboBoxItem extends ComboBoxItem {
ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry(),
300);
+ // needs to use a different cell formatter than what AncestryUtil.setupAncestryListGridField creates
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);
- }
- });
+ AncestryUtil.setupAncestryListGridFieldHover(ancestryField);
ListGridField descriptionField = new ListGridField("description", MSG.common_title_description());
ListGridField categoryField = new ListGridField("category", MSG.common_title_category(), 60);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index f7e3ee4..69a36a0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -180,18 +180,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
}
});
- ListGridField ancestryRecent = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
- ancestryRecent.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
- }
- });
- ancestryRecent.setShowHover(true);
- ancestryRecent.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
- }
- });
+ ListGridField ancestryRecent = AncestryUtil.setupAncestryListGridField();
ListGridField operationRecent = new ListGridField(RecentOperationsDataSource.Field.OPERATION.propertyName(),
RecentOperationsDataSource.Field.OPERATION.title());
@@ -220,18 +209,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
}
});
- ListGridField ancestryNext = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
- ancestryNext.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
- }
- });
- ancestryNext.setShowHover(true);
- ancestryNext.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
- }
- });
+ ListGridField ancestryNext = AncestryUtil.setupAncestryListGridField();
ListGridField operationNext = new ListGridField(ScheduledOperationsDataSource.Field.OPERATION.propertyName(),
ScheduledOperationsDataSource.Field.OPERATION.title());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 24820ec..bd28719 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -135,19 +135,7 @@ public class ProblemResourcesPortlet extends Table<ProblemResourcesDataSource> i
}
});
- 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);
- }
- });
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
ListGridField alertsField = new ListGridField(ALERTS.propertyName(), ALERTS.title(), 70);
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 6553b56..e058004 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
@@ -260,22 +260,7 @@ public abstract class AbstractOperationHistoryListView<T extends AbstractOperati
}
protected ListGridField createAncestryField() {
- 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);
- }
- });
-
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
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 9071b94..ae28218 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
@@ -118,20 +118,7 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
}
});
- 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 fieldAncestry = AncestryUtil.setupAncestryListGridField();
ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG
.common_title_dateCreated());
ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG
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 ec590c0..b2f923c 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
@@ -117,20 +117,7 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
}
});
- 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 fieldAncestry = AncestryUtil.setupAncestryListGridField();
ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG
.common_title_dateCreated());
ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG
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 b374561..e93a1cb 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
@@ -62,19 +62,7 @@ public class TraitsDetailView extends AbstractMeasurementDataTraitListDetailView
});
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);
- }
- });
+ AncestryUtil.setupAncestryListGridField(listGrid);
}
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 dfd3b38..f1c7cfa 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
@@ -69,20 +69,7 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
});
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);
- }
- });
-
+ AncestryUtil.setupAncestryListGridField(listGrid);
super.configureTable();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
index da178c4..b4e1257 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
@@ -59,20 +59,8 @@ public class GroupMemberResourceOperationHistoryListView extends
});
fields.add(resourceField);
- ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
ancestryField.setWidth("35%");
- 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);
ListGridField statusField = createStatusField();
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 8a2cbe2..20d9937 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
@@ -23,6 +23,11 @@ import java.util.HashSet;
import java.util.Map;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.Alignment;
+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.resource.Resource;
@@ -51,6 +56,52 @@ public abstract class AncestryUtil {
private static final String TITLE_PLATFORM = CoreGUI.getMessages().common_title_platform() + ": ";
/**
+ * Convienence method that creates a standard ancestry ListGridField.
+ * @return ancestry field
+ */
+ public static ListGridField setupAncestryListGridField() {
+ ListGridField ancestryField;
+ ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, CoreGUI.getMessages().common_title_ancestry());
+ ancestryField.setAlign(Alignment.LEFT);
+ ancestryField.setCellAlign(Alignment.LEFT);
+ setupAncestryListGridFieldCellFormatter(ancestryField);
+ setupAncestryListGridFieldHover(ancestryField);
+ return ancestryField;
+ }
+
+ /**
+ * Convienence method that creates a standard ancestry ListGridField where the field already exists
+ * in the given list grid.
+ *
+ * @return ancestry field
+ */
+ public static ListGridField setupAncestryListGridField(ListGrid listGrid) {
+ ListGridField ancestryField = listGrid.getField(AncestryUtil.RESOURCE_ANCESTRY);
+ ancestryField.setAlign(Alignment.LEFT);
+ ancestryField.setCellAlign(Alignment.LEFT);
+ setupAncestryListGridFieldCellFormatter(ancestryField);
+ setupAncestryListGridFieldHover(ancestryField);
+ return ancestryField;
+ }
+
+ public static void setupAncestryListGridFieldHover(ListGridField ancestryField) {
+ ancestryField.setShowHover(true);
+ ancestryField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
+ }
+ });
+ }
+
+ public static void setupAncestryListGridFieldCellFormatter(ListGridField ancestryField) {
+ ancestryField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
+ }
+ });
+ }
+
+ /**
* 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.
*
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 7d46996..6559a31 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -159,18 +159,7 @@ public class ResourceSearchView extends Table {
}
});
- 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);
- }
- });
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
ListGridField descriptionField = new ListGridField(DESCRIPTION.propertyName(), DESCRIPTION.title());
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 bd8c430..3d41d42 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
@@ -229,19 +229,7 @@ public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractR
});
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);
- }
- });
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
fields.add(ancestryField);
idField.setWidth("10%");
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 18f59cf..d481d86 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
@@ -196,19 +196,7 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
});
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);
- }
- });
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
fields.add(ancestryField);
return fields;
13 years, 2 months
[rhq] Branch 'as7plugin' - 104 commits - etc/dev-utils etc/samples modules/core modules/enterprise modules/plugins pom.xml
by Heiko W. Rupp
etc/dev-utils/TestLdapSettings.java | 640
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/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java | 10
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java | 28
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/StandaloneContainer.java | 8
modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java | 14
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java | 47
modules/enterprise/agent/src/etc/rhq-agent-wrapper-ec2 | 122
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java | 4
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java | 2
modules/enterprise/gui/coregui/pom.xml | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java | 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 39
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java | 47
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 129
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java | 77
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 38
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java | 33
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java | 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java | 55
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java | 36
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java | 35
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java | 36
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 110
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java | 20
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/components/measurement/AbstractMeasurementRangeEditor.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java | 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java | 15
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/components/table/Table.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java | 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 200
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java | 109
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/PortletConfigurationEditorComponent.java | 99
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java | 438
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java | 419
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java | 398
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupBundleDeploymentsPortlet.java | 303
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java | 123
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupMetricsPortlet.java | 465
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOobsPortlet.java | 48
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 514
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupPkgHistoryPortlet.java | 303
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java | 201
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java | 181
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java | 181
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 78
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 26
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 | 173
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java | 196
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java | 341
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 | 379
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourcePkgHistoryPortlet.java | 169
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/gwt/GWTServiceLookup.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java | 351
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java | 25
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java | 51
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java | 56
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java | 130
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java | 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 63
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java | 122
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/GroupPluginConfigurationEditView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java | 120
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java | 55
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java | 134
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 7
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/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java | 55
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java | 42
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java | 50
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java | 853 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java | 229
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView3.java | 702
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java | 219
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java | 58
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 41
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java | 42
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java | 63
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java | 85
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java | 81
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java | 156
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java | 39
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java | 380
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java | 82
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java | 31
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java | 203
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java | 825 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView3.java | 691
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java | 46
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/SingleResourceGroupSelector.java | 65
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 58
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 58
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java | 110
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java | 29
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 55
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java | 31
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 37
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 415
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java | 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java | 31
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java | 25
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java | 46
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java | 92
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java | 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupDefinitionExpressionBuilderGWTServiceImpl.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementChartsGWTServiceImpl.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java | 59
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementScheduleGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 49
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 39
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java | 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java | 33
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java | 20
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 7
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 60
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 5
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Flag_blue_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/js/jquery-1.4.4.js | 7179 ----------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java | 23
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java | 17
modules/enterprise/server/container/pom.xml | 2
modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java | 15
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerLocal.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/SyncEndpointAddressException.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ConcurrentJobWrapper.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ScheduledJobInvocationContext.java | 70
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulJobWrapper.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulScheduledJobInvocationContext.java | 65
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 54
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBean.java | 36
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerLocal.java | 38
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/PurgePluginsJob.java | 43
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java | 3
modules/enterprise/server/plugins/cloud/pom.xml | 146
modules/enterprise/server/plugins/cloud/src/main/java/org/rhq/enterprise/server/plugins/cloud/CloudServerPluginComponent.java | 193
modules/enterprise/server/plugins/cloud/src/main/resources/META-INF/rhq-serverplugin.xml | 57
modules/enterprise/server/safe-invoker/pom.xml | 57
modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java | 81
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 6
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 95
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java | 21
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/WindowsPlatformComponent.java | 25
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/win/Win32EventLogDelegate.java | 122
modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java | 3
modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml | 11
pom.xml | 12
246 files changed, 12671 insertions(+), 12117 deletions(-)
New commits:
commit 0f0f7680d7ddb486e63a28ec35874d93f2d1c883
Merge: 69260ab 2f4429f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 22 21:30:15 2011 +0100
Merge branch 'master' into as7plugin
commit 2f4429f5551a38ba82a23024707a290419cf0cb6
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 22 21:29:35 2011 +0100
Introduce new command 'stdin' that allows to give control back to the user.
This way it is possible to have a script do some setup and then continue manually.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index cbf6dde..b6a1d30 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -160,6 +160,10 @@ public class StandaloneContainer {
break;
}
+ if (answer.equalsIgnoreCase(Command.STDIN.toString())) {
+ br = new BufferedReader(new InputStreamReader(System.in));
+ }
+
// Check for history commands
answer = handleHistory(answer);
@@ -350,6 +354,9 @@ public class StandaloneContainer {
case SET:
set(tokens);
break;
+ case STDIN:
+ // handled in the outer loop
+ break;
case WAIT:
Thread.sleep(Integer.valueOf(tokens[1]));
break;
@@ -779,6 +786,7 @@ public class StandaloneContainer {
RESOURCES("res", "", 0, "Shows the discovered resources"), //
SET("set", "'resource' N", 2,
"Sets the resource id to work with. N can be a number or '$r' as result of last find resource call"), //
+ STDIN("stdin","",0, "Stop reading the batch file and wait for commands on stdin"), //
WAIT("w", "milliseconds", 1, "Waits the given amount of time"),
P_CONFIG("pc", "", 0, "Shows the plugin configuration of the current resource."),
R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource.");
commit 69260ab75e307e19def5831efa6520d1306abdc6
Merge: 92fd80e 6996576
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 22 21:14:53 2011 +0100
Merge branch 'master' into as7plugin
commit 699657688e73a5f6649e9ebf6f26ceade1942e8a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 22 15:52:32 2011 -0400
BZ 556960 - provide a more descriptive confirmation message when uninventorying resources.
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 a07b4b6..678ba25 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
@@ -1581,7 +1581,7 @@ view_inventory_resource_loadFailed = Resource with id [{0}] does not exist or is
view_inventory_resources_deleteConfirm = Are you sure you want to delete the selected resources?
view_inventory_resources_deleteSuccessful = You have successfully deleted the selected resources
view_inventory_resources_deleteFailed = Failed to delete the selected resources
-view_inventory_resources_uninventoryConfirm = Are you sure you want to uninventory the selected resources?
+view_inventory_resources_uninventoryConfirm = Are you sure you want to uninventory the selected resources? Note that if a selected resource still exists, then it will get rediscovered during its agent''s next discovery scan.
view_inventory_resources_uninventorySuccessful = You have successfully uninventoried the selected resources
view_inventory_resources_uninventoryFailed = Failed to uninventory the selected resources
view_inventory_resources_loadFailed = Failed to load resource composite data
commit 81d73ed70f5a5bad8c1741b9116b6f991982a568
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Mar 22 19:39:44 2011 +0100
BZ 689833 - restoring the original behavior of getMainServerSampleAddress().
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index ee3e2ea..b43e156 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -502,7 +502,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostAddressStrings.length);
if (vhostAddressStrings.length == 1 && MAIN_SERVER_RESOURCE_KEY.equals(vhostAddressStrings[0])) {
- List<HttpdAddressUtility.Address> serverAddrs = parent.getAddressUtility().getAllMainServerAddresses(tree);
+ List<HttpdAddressUtility.Address> serverAddrs = parent.getAddressUtility().getAllMainServerAddresses(tree, true);
if (serverAddrs != null) {
vhostAddresses.addAll(serverAddrs);
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index 8ecdb7b..6b9e686 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -42,7 +42,7 @@ public enum HttpdAddressUtility {
APACHE_1_3 {
- public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag) {
+ public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag, boolean substituteWildcards) {
try {
List<ApacheDirective> ports = ag.search("/Port");
List<ApacheDirective> bindAddresses = ag.search("/BindAddress");
@@ -75,14 +75,14 @@ public enum HttpdAddressUtility {
}
for (Address address : addresses) {
- if (!address.isPortDefined() || address.isPortWildcard()) {
+
+ if (!address.isPortDefined()) {
address.port = 80;
}
- if (address.host == null || address.isHostDefault() || address.isHostWildcard()) {
- address = getLocalhost(address.port);
- }
- updateWithServerName(address, ag);
+ if (substituteWildcards) {
+ substituteWildcards(ag, address);
+ }
}
return addresses;
@@ -95,17 +95,16 @@ public enum HttpdAddressUtility {
},
APACHE_2_x {
- public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag) {
+ public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag, boolean substituteWildcards) {
try {
List<Address> ret = new ArrayList<Address>();
for(ApacheDirective n : ag.search("/Listen")) {
Address addr = parseListen(n.getValues().get(0));
- if (addr.host == null || addr.isHostDefault() || addr.isHostWildcard()) {
- addr = getLocalhost(addr.port);
- }
- updateWithServerName(addr, ag);
+ if (substituteWildcards) {
+ substituteWildcards(ag, addr);
+ }
ret.add(addr);
}
@@ -283,9 +282,10 @@ public enum HttpdAddressUtility {
* This returns all the addresses the server listens on.
*
* @param ag the tree of the httpd configuration
+ * @param substituteWildcards true if wildcard substitution should be made on host and port specs
* @return the addresses or null on failure
*/
- public abstract List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag);
+ public abstract List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag, boolean substituteWildcards);
/**
* This just constructs a first available address under which the server or one of its virtual hosts can be reached.
@@ -297,7 +297,7 @@ public enum HttpdAddressUtility {
* @return the address or null on failure
*/
public Address getMainServerSampleAddress(ApacheDirectiveTree ag, String limitToHost, int limitToPort) {
- List<Address> addressesToMatch = getAllMainServerAddresses(ag);
+ List<Address> addressesToMatch = getAllMainServerAddresses(ag, false);
if (addressesToMatch == null) {
return null;
@@ -305,6 +305,7 @@ public enum HttpdAddressUtility {
for (Address address : addressesToMatch) {
if (isAddressConforming(address, limitToHost, limitToPort, false)) {
+ substituteWildcards(ag, address);
return address;
}
}
@@ -362,6 +363,19 @@ public enum HttpdAddressUtility {
return ret;
}
+ private static void substituteWildcards(ApacheDirectiveTree ag, Address address) {
+ if (address.isPortWildcard()) {
+ address.port = 80;
+ }
+
+ if (address.host == null || address.isHostDefault() || address.isHostWildcard()) {
+ address = getLocalhost(address.port);
+ }
+
+ updateWithServerName(address, ag);
+
+ }
+
/**
* Checks that given address represents a possibly wildcarded limitingHost and limitingPort values.
*
@@ -417,7 +431,7 @@ public enum HttpdAddressUtility {
}
}
- private static void updateWithServerName(Address address, ApacheDirectiveTree config) throws UnknownHostException {
+ private static void updateWithServerName(Address address, ApacheDirectiveTree config) {
//check if there is a ServerName directive
List<ApacheDirective> serverNameNodes = config.search("/ServerName");
@@ -430,7 +444,7 @@ public enum HttpdAddressUtility {
}
}
- private static void updateWithServerName(Address address, String serverName) throws UnknownHostException {
+ private static void updateWithServerName(Address address, String serverName) {
//the configuration may be invalid and/or the hostname can be unresolvable.
//we try to match the address with the servername first by IP address
//but if that fails (i.e. the hostname couldn't be resolved to an IP)
commit 40268c81269d521f62f0286322528b9200afe939
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 22 14:09:54 2011 -0400
the Configuration History reports view barfs when sorting on Resource column (and other ways).
The problem was the generated query has a bad ORDER BY clause.
some how this fix made a difference. Looks like the name of the addSortABC method needs to match the name of the override/data field member name.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
index e8c7cf6..d2e024c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
@@ -41,7 +41,7 @@ import org.rhq.core.domain.util.PageOrdering;
public class ResourceConfigurationUpdateCriteria extends AbstractResourceConfigurationUpdateCriteria {
private static final long serialVersionUID = 1L;
- public static final String SORT_FIELD_RESOURCE_NAME = "name";
+ public static final String SORT_FIELD_RESOURCE_NAME = "resourceName";
public static final String SORT_FIELD_RESOURCE_ID = "resourceId";
private Integer filterGroupConfigurationUpdateId; // required overrides
@@ -53,7 +53,7 @@ public class ResourceConfigurationUpdateCriteria extends AbstractResourceConfigu
private boolean fetchResource;
private boolean fetchGroupConfigurationUpdate;
- private PageOrdering sortName; // requires sort override
+ private PageOrdering sortResourceName; // requires sort override
private PageOrdering sortResourceId; // requires sort override
public ResourceConfigurationUpdateCriteria() {
@@ -107,7 +107,7 @@ public class ResourceConfigurationUpdateCriteria extends AbstractResourceConfigu
public void addSortResourceName(PageOrdering sortName) {
addSortField(SORT_FIELD_RESOURCE_NAME);
- this.sortName = sortName;
+ this.sortResourceName = sortName;
}
public void addSortResourceId(PageOrdering sortResourceId) {
commit 76890a051997d03d425248a2bfb16b89b4df74b8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 22 12:05:29 2011 -0400
BZ 682304 - change the RPCDataSource generic template to accept a Criteria type so we can implement a strongly typed getFetchCriteria on all datasources.
the main goal here is to ensure the pageControl is set,
and we do this by refactoring the creation of the criteria
out of the executeFetch so the subclass can get the fetch criteria
and perform some work on it (like setting page controls)
and then calling executeFetch.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
index 39c2e67..d3583ac 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
@@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Simeon Pinder
*/
-public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
+public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup, org.rhq.core.domain.criteria.Criteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
@@ -64,7 +64,7 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
public RoleLdapGroupSelector(String locatorId, ListGridRecord[] assignedRecords, boolean isReadOnly) {
super(locatorId, isReadOnly);
-
+
setAssigned(assignedRecords);
}
@@ -83,7 +83,7 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
}
@Override
- protected RPCDataSource<LdapGroup> getDataSource() {
+ protected RPCDataSource<LdapGroup, org.rhq.core.domain.criteria.Criteria> getDataSource() {
return new LdapGroupsDataSource();
}
@@ -104,7 +104,7 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
return MSG.common_title_ldapGroups();
}
- public static class LdapGroupsDataSource extends RPCDataSource<LdapGroup> {
+ public static class LdapGroupsDataSource extends RPCDataSource<LdapGroup, org.rhq.core.domain.criteria.Criteria> {
//cache ldap group data from external server
private Set<Map<String, String>> cachedLdapGroupsAvailable;
@@ -142,17 +142,24 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final org.rhq.core.domain.criteria.Criteria unused) {
//if not null then go through to initialize
if (cachedLdapGroupsAvailable == null) {
fetchLdapGroupsFromServerAsync(request, response);
} else {//use cached data and return correct response
//process cachedLdapGroupsAvailable based on criteria
PageList<LdapGroup> ldapGroups = filterCachedLdapGroups(request);
- sendSuccessResponse(request, response, ldapGroups);
+ sendSuccessResponse(request, response, ldapGroups);
}
}
+ @Override
+ protected org.rhq.core.domain.criteria.Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
private PageList<LdapGroup> filterCachedLdapGroups(DSRequest request) {
//populate the indexed map
if (cachedNameKeyedMap == null) {
@@ -181,27 +188,25 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
} else {//return full list .. as no filtering done.
locatedGroupMaps = cachedLdapGroupsAvailable;
}
- @SuppressWarnings({"UnnecessaryLocalVariable"})
+ @SuppressWarnings( { "UnnecessaryLocalVariable" })
PageList<LdapGroup> ldapGroups = convertToPageList(locatedGroupMaps);
return ldapGroups;
}
private void fetchLdapGroupsFromServerAsync(final DSRequest request, final DSResponse response) {
- GWTServiceLookup.getLdapService().findAvailableGroups(
- new AsyncCallback<Set<Map<String, String>>>() {
- public void onSuccess(Set<Map<String, String>> locatedGroupMaps) {
- Log.debug("Successfully located " + locatedGroupMaps.size() + " available LDAP groups.");
- cachedLdapGroupsAvailable = locatedGroupMaps;
- //all groups displayed initially
- PageList<LdapGroup> ldapGroups = convertToPageList(locatedGroupMaps);
- sendSuccessResponse(request, response, ldapGroups);
- }
+ GWTServiceLookup.getLdapService().findAvailableGroups(new AsyncCallback<Set<Map<String, String>>>() {
+ public void onSuccess(Set<Map<String, String>> locatedGroupMaps) {
+ Log.debug("Successfully located " + locatedGroupMaps.size() + " available LDAP groups.");
+ cachedLdapGroupsAvailable = locatedGroupMaps;
+ //all groups displayed initially
+ PageList<LdapGroup> ldapGroups = convertToPageList(locatedGroupMaps);
+ sendSuccessResponse(request, response, ldapGroups);
+ }
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError(MSG.view_adminRoles_failLdapGroupsRole(),
- throwable);
- }
- });//end of findAvailableGroups
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_adminRoles_failLdapGroupsRole(), throwable);
+ }
+ });//end of findAvailableGroups
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
index a7653e2..99e0dbf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersDataSource;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
@@ -38,18 +39,18 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class RoleSubjectSelector extends AbstractSelector<Subject> {
-
+public class RoleSubjectSelector extends AbstractSelector<Subject, SubjectCriteria> {
+
private static final String ITEM_ICON = "global/User_16.png";
public RoleSubjectSelector(String id, ListGridRecord[] subjectRecords, boolean isReadOnly) {
super(id, isReadOnly);
-
+
setAssigned(subjectRecords);
}
@Override
- protected RPCDataSource<Subject> getDataSource() {
+ protected RPCDataSource<Subject, SubjectCriteria> getDataSource() {
return new RoleUsersDataSource();
}
@@ -80,7 +81,7 @@ public class RoleSubjectSelector extends AbstractSelector<Subject> {
for (Record record : records) {
Integer id = record.getAttributeAsInt(Field.ID);
if (id.equals(ID_RHQADMIN)) {
- rhqAdminRecord = record;
+ rhqAdminRecord = record;
}
}
if (rhqAdminRecord != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
index 9fefcb3..3af67b6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
@@ -52,7 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class RolesDataSource extends RPCDataSource<Role> {
+public class RolesDataSource extends RPCDataSource<Role, RoleCriteria> {
public static abstract class Field {
public static final String ID = "id";
@@ -124,9 +124,7 @@ public class RolesDataSource extends RPCDataSource<Role> {
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- RoleCriteria criteria = getFetchCriteria(request);
-
+ public void executeFetch(final DSRequest request, final DSResponse response, final RoleCriteria criteria) {
roleService.findRolesByCriteria(criteria, new AsyncCallback<PageList<Role>>() {
public void onFailure(Throwable caught) {
sendFailureResponse(request, response, MSG.view_adminRoles_failRoles(), caught);
@@ -142,7 +140,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
protected void executeAdd(Record recordToAdd, final DSRequest request, final DSResponse response) {
Role roleToAdd = copyValues(recordToAdd);
- final String rolename = roleToAdd.getName();
roleService.createRole(roleToAdd, new AsyncCallback<Role>() {
public void onFailure(Throwable caught) {
throw new RuntimeException(caught);
@@ -235,8 +232,8 @@ public class RolesDataSource extends RPCDataSource<Role> {
if (cascade) {
Set<ResourceGroup> resourceGroups = sourceRole.getResourceGroups();
- ListGridRecord[] resourceGroupRecords = ResourceGroupsDataSource.getInstance().buildRecords(
- resourceGroups, false);
+ ListGridRecord[] resourceGroupRecords = ResourceGroupsDataSource.getInstance().buildRecords(resourceGroups,
+ false);
targetRecord.setAttribute(Field.RESOURCE_GROUPS, resourceGroupRecords);
Set<Subject> subjects = sourceRole.getSubjects();
@@ -244,8 +241,8 @@ public class RolesDataSource extends RPCDataSource<Role> {
targetRecord.setAttribute(Field.SUBJECTS, subjectRecords);
Set<LdapGroup> ldapGroups = sourceRole.getLdapGroups();
- ListGridRecord[] ldapGroupRecords = new RoleLdapGroupSelector.LdapGroupsDataSource().buildRecords(
- ldapGroups);
+ ListGridRecord[] ldapGroupRecords = new RoleLdapGroupSelector.LdapGroupsDataSource()
+ .buildRecords(ldapGroups);
targetRecord.setAttribute(Field.LDAP_GROUPS, ldapGroupRecords);
}
@@ -273,7 +270,7 @@ public class RolesDataSource extends RPCDataSource<Role> {
return permissionRecords;
}
- private RoleCriteria getFetchCriteria(DSRequest request) {
+ protected RoleCriteria getFetchCriteria(DSRequest request) {
RoleCriteria criteria = new RoleCriteria();
// Pagination
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
index f37c90a..63e49cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
@@ -23,7 +23,6 @@ import java.util.List;
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.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -64,12 +63,6 @@ public class TemplateSchedulesDataSource extends AbstractMeasurementScheduleComp
}
@Override
- protected void executeFetch(DSRequest request, DSResponse response) {
- super.executeFetch(request, response);
-
- }
-
- @Override
protected EntityContext getEntityContext(DSRequest request) {
Criteria requestCriteria = request.getCriteria();
Integer typeId = requestCriteria.getAttributeAsInt(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
index df5036c..1c27994 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesDataSource;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -34,7 +35,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class SubjectRoleSelector extends AbstractSelector<Role> {
+public class SubjectRoleSelector extends AbstractSelector<Role, RoleCriteria> {
private static final String ITEM_ICON = "global/Role_16.png";
public SubjectRoleSelector(String locatorId, ListGridRecord[] roleRecords, boolean isReadOnly) {
@@ -48,7 +49,7 @@ public class SubjectRoleSelector extends AbstractSelector<Role> {
}
@Override
- protected RPCDataSource<Role> getDataSource() {
+ protected RPCDataSource<Role, RoleCriteria> getDataSource() {
return new RolesDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
index 5b76b5e..d6f536b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
@@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class UsersDataSource extends RPCDataSource<Subject> {
+public class UsersDataSource extends RPCDataSource<Subject, SubjectCriteria> {
private static UsersDataSource INSTANCE;
@@ -162,8 +162,8 @@ public class UsersDataSource extends RPCDataSource<Subject> {
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- SubjectCriteria criteria = getFetchCriteria(request);
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, final SubjectCriteria criteria) {
subjectService.findSubjectsByCriteria(criteria, new AsyncCallback<PageList<Subject>>() {
public void onFailure(Throwable caught) {
@@ -329,6 +329,7 @@ public class UsersDataSource extends RPCDataSource<Subject> {
return to;
}
+ @Override
protected SubjectCriteria getFetchCriteria(DSRequest request) {
SubjectCriteria criteria = new SubjectCriteria();
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 ddc343f..5ca88d6 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
@@ -70,7 +70,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Joseph Marques
* @author John Mazzitelli
*/
-public class AlertDataSource extends RPCDataSource<Alert> {
+public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
private AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService();
private EntityContext entityContext;
@@ -214,11 +214,10 @@ public class AlertDataSource extends RPCDataSource<Alert> {
return fields;
}
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final AlertCriteria criteria) {
final long start = System.currentTimeMillis();
- AlertCriteria criteria = getCriteria(request);
-
this.alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
public void onFailure(Throwable caught) {
@@ -283,7 +282,8 @@ public class AlertDataSource extends RPCDataSource<Alert> {
});
}
- protected AlertCriteria getCriteria(DSRequest request) {
+ @Override
+ protected AlertCriteria getFetchCriteria(DSRequest request) {
AlertCriteria criteria = new AlertCriteria();
criteria.setPageControl(getPageControl(request));
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 ee50f73..afcb435 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
@@ -49,7 +49,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<AlertDefinition> {
+public abstract class AbstractAlertDefinitionsDataSource extends
+ RPCDataSource<AlertDefinition, AlertDefinitionCriteria> {
protected static final String FIELD_ID = "id";
protected static final String FIELD_NAME = "name";
@@ -184,8 +185,8 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- AlertDefinitionCriteria criteria = getCriteria(request);
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final AlertDefinitionCriteria criteria) {
GWTServiceLookup.getAlertDefinitionService().findAlertDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<AlertDefinition>>() {
public void onFailure(Throwable caught) {
@@ -207,8 +208,6 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
processResponse(request.getRequestId(), response);
}
- protected abstract AlertDefinitionCriteria getCriteria(DSRequest request);
-
/**
* Returns a criteria that will query for all alerts, but only for the ID and name fields.
* @return criteria for an inexpensive query to obtain all alert defs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index aa6d838..9958d0c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -38,6 +38,7 @@ import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
@@ -128,8 +129,9 @@ public class ConditionsEditor extends LocatableVLayout {
}
});
- NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"),
- conditions, ConditionsEditor.this.resourceType, new Runnable() {
+ NewConditionEditor newConditionEditor = new NewConditionEditor(
+ extendLocatorId("newConditionEditor"), conditions, ConditionsEditor.this.resourceType,
+ new Runnable() {
@Override
public void run() {
winModal.markForDestroy();
@@ -139,23 +141,23 @@ public class ConditionsEditor extends LocatableVLayout {
winModal.addItem(newConditionEditor);
winModal.show();
}
- });
-
- table.addTableAction(this.extendLocatorId("delete"), MSG.common_button_delete(), MSG
- .view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- for (ListGridRecord record : selection) {
- AlertCondition cond = getDataSource().copyValues(record);
- conditions.remove(cond);
+ });
+
+ table.addTableAction(this.extendLocatorId("delete"), MSG.common_button_delete(), MSG
+ .view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ for (ListGridRecord record : selection) {
+ AlertCondition cond = getDataSource().copyValues(record);
+ conditions.remove(cond);
+ }
+ refresh();
}
- refresh();
- }
- });
+ });
}
}
- private class ConditionDataSource extends RPCDataSource<AlertCondition> {
+ private class ConditionDataSource extends RPCDataSource<AlertCondition, Criteria> {
private static final String FIELD_OBJECT = "obj";
private static final String FIELD_CONDITION = "condition";
@@ -190,9 +192,15 @@ public class ConditionsEditor extends LocatableVLayout {
}
@Override
- protected void executeFetch(DSRequest request, DSResponse response) {
+ protected void executeFetch(DSRequest request, DSResponse response, Criteria unused) {
response.setData(buildRecords(conditions));
processResponse(request.getRequestId(), response);
}
+
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
index bb2cc71..f7d7081 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
@@ -45,7 +45,7 @@ public class GroupAlertDefinitionsDataSource extends AbstractAlertDefinitionsDat
}
@Override
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ protected AlertDefinitionCriteria getFetchCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
Criteria requestCriteria = request.getCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index 970fb66..ae0e673 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -44,6 +44,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
@@ -167,7 +168,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
}
}
- private class NotificationDataSource extends RPCDataSource<AlertNotification> {
+ private class NotificationDataSource extends RPCDataSource<AlertNotification, Criteria> {
public NotificationDataSource() {
super();
List<DataSourceField> fields = addDataSourceFields();
@@ -206,7 +207,13 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
final Record[] records = buildRecords(notifications); // partially builds the records, but we need to do another remote call to get the config preview
AlertNotification[] notifs = notifications.toArray(new AlertNotification[notifications.size()]);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index 1ac2862..de1ec1f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -120,7 +120,7 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
}
@Override
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ protected AlertDefinitionCriteria getFetchCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.fetchGroupAlertDefinition(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java
index faf8087..c4a7c51 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java
@@ -161,7 +161,7 @@ public class SystemRolesNotificationSenderForm extends AbstractNotificationSende
return builder.toString();
}
- private class RoleSelector extends AbstractSelector<Role> {
+ private class RoleSelector extends AbstractSelector<Role, RoleCriteria> {
public RoleSelector(String id, Collection<Role> roles) {
super(id);
if (roles != null) {
@@ -171,7 +171,7 @@ public class SystemRolesNotificationSenderForm extends AbstractNotificationSende
}
@Override
- protected RPCDataSource<Role> getDataSource() {
+ protected RPCDataSource<Role, RoleCriteria> getDataSource() {
return new RolesDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
index fd67e71..e7139a7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
@@ -172,7 +172,7 @@ public class SystemUsersNotificationSenderForm extends AbstractNotificationSende
return builder.toString();
}
- private class SubjectSelector extends AbstractSelector<Subject> {
+ private class SubjectSelector extends AbstractSelector<Subject, SubjectCriteria> {
public SubjectSelector(String id, Collection<Subject> subjects) {
super(id);
if (subjects != null) {
@@ -182,7 +182,7 @@ public class SystemUsersNotificationSenderForm extends AbstractNotificationSende
}
@Override
- protected RPCDataSource<Subject> getDataSource() {
+ protected RPCDataSource<Subject, SubjectCriteria> getDataSource() {
return new UsersDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
index 15163f0..9e5590e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
@@ -45,7 +45,7 @@ public class TemplateAlertDefinitionsDataSource extends AbstractAlertDefinitions
}
@Override
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ protected AlertDefinitionCriteria getFetchCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
Criteria requestCriteria = request.getCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
index c4de0d7..fd1a659 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
@@ -29,6 +29,7 @@ import com.smartgwt.client.widgets.form.fields.TextItem;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundlesDataSource;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
@@ -40,7 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Jay Shaughnessy
*/
-public class BundleSelector extends AbstractSelector<Bundle> {
+public class BundleSelector extends AbstractSelector<Bundle, BundleCriteria> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
@@ -73,7 +74,7 @@ public class BundleSelector extends AbstractSelector<Bundle> {
return availableFilterForm;
}
- protected RPCDataSource<Bundle> getDataSource() {
+ protected RPCDataSource<Bundle, BundleCriteria> getDataSource() {
return new BundlesDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java
index d04569b..1017215 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java
@@ -24,6 +24,7 @@ import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.enterprise.gui.coregui.client.bundle.BundleSelector;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
@@ -33,7 +34,7 @@ public class SelectBundleStep extends AbstractWizardStep {
private final BundleDeployWizard wizard;
- private AbstractSelector<Bundle> selector;
+ private AbstractSelector<Bundle, BundleCriteria> selector;
public SelectBundleStep(BundleDeployWizard wizard) {
this.wizard = wizard;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java
index f8ec6dc..49e373b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java
@@ -4,9 +4,7 @@ import com.smartgwt.client.data.DSRequest;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceGroupSelector;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class PlatformResourceGroupSelector extends ResourceGroupSelector {
@@ -15,7 +13,7 @@ public class PlatformResourceGroupSelector extends ResourceGroupSelector {
}
@Override
- protected RPCDataSource<ResourceGroup> getDataSource() {
+ protected SelectedPlatformResourceGroupsDataSource getDataSource() {
return new SelectedPlatformResourceGroupsDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
index 917b13d..e523cad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
@@ -46,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment> {
+public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment, BundleDeploymentCriteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
@@ -97,7 +97,23 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final BundleDeploymentCriteria criteria) {
+ bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deploy_loadDeployFailure(), caught);
+ }
+
+ public void onSuccess(PageList<BundleDeployment> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ }
+
+ @Override
+ protected BundleDeploymentCriteria getFetchCriteria(final DSRequest request) {
BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
criteria.fetchBundleVersion(true);
@@ -126,18 +142,7 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
if (request.getCriteria().getValues().get("tagName") != null) {
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
- bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deploy_loadDeployFailure(), caught);
- }
-
- public void onSuccess(PageList<BundleDeployment> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
-
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
index 74e7feb..b99ab75 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
@@ -36,19 +36,17 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
-import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundleVersionDataSource;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleDeploymentListView extends Table<RPCDataSource<BundleDeployment>> {
+public class BundleDeploymentListView extends Table<BundleDeploymentDataSource> {
private final boolean canManageBundles;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
index 019794b..6b2be22 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
@@ -44,7 +44,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleResourceDeployment> {
+public class BundleResourceDeploymentDataSource extends
+ RPCDataSource<BundleResourceDeployment, BundleResourceDeploymentCriteria> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundleResourceDeploymentDataSource() {
@@ -71,18 +72,8 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- BundleResourceDeploymentCriteria criteria = new BundleResourceDeploymentCriteria();
- criteria.fetchResource(true);
- criteria.fetchBundleDeployment(true);
- criteria.fetchHistories(true);
-
- if (request.getCriteria().getValues().containsKey("bundleDeploymentId")) {
- criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute(
- "bundleDeploymentId")));
- }
-
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final BundleResourceDeploymentCriteria criteria) {
bundleService.findBundleResourceDeploymentsByCriteria(criteria,
new AsyncCallback<PageList<BundleResourceDeployment>>() {
public void onFailure(Throwable caught) {
@@ -94,7 +85,20 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
processResponse(request.getRequestId(), response);
}
});
+ }
+ @Override
+ protected BundleResourceDeploymentCriteria getFetchCriteria(final DSRequest request) {
+ BundleResourceDeploymentCriteria criteria = new BundleResourceDeploymentCriteria();
+ criteria.fetchResource(true);
+ criteria.fetchBundleDeployment(true);
+ criteria.fetchHistories(true);
+
+ if (request.getCriteria().getValues().containsKey("bundleDeploymentId")) {
+ criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute(
+ "bundleDeploymentId")));
+ }
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
index 1a6f3dc..094571e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
@@ -47,7 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleDestinationDataSource extends RPCDataSource<BundleDestination> {
+public class BundleDestinationDataSource extends RPCDataSource<BundleDestination, BundleDestinationCriteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
@@ -107,30 +107,8 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- BundleDestinationCriteria criteria = new BundleDestinationCriteria();
-
- if (request.getCriteria().getValues().containsKey(FIELD_BUNDLE_ID)) {
- criteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString(FIELD_BUNDLE_ID)));
- }
-
- if (request.getCriteria().getValues().get("tagNamespace") != null) {
- criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
- }
-
- if (request.getCriteria().getValues().get("tagSemantic") != null) {
- criteria.addFilterTagSemantic((String) request.getCriteria().getValues().get("tagSemantic"));
- }
-
- if (request.getCriteria().getValues().get("tagName") != null) {
- criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
- }
-
- criteria.fetchBundle(true);
- criteria.fetchDeployments(true);
- criteria.fetchGroup(true);
- criteria.fetchTags(true);
-
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final BundleDestinationCriteria criteria) {
GWTServiceLookup.getBundleService().findBundleDestinationsByCriteria(criteria,
new AsyncCallback<PageList<BundleDestination>>() {
public void onFailure(Throwable caught) {
@@ -169,6 +147,33 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
@Override
+ protected BundleDestinationCriteria getFetchCriteria(final DSRequest request) {
+ BundleDestinationCriteria criteria = new BundleDestinationCriteria();
+
+ if (request.getCriteria().getValues().containsKey(FIELD_BUNDLE_ID)) {
+ criteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString(FIELD_BUNDLE_ID)));
+ }
+
+ if (request.getCriteria().getValues().get("tagNamespace") != null) {
+ criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
+ }
+
+ if (request.getCriteria().getValues().get("tagSemantic") != null) {
+ criteria.addFilterTagSemantic((String) request.getCriteria().getValues().get("tagSemantic"));
+ }
+
+ if (request.getCriteria().getValues().get("tagName") != null) {
+ criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
+ }
+
+ criteria.fetchBundle(true);
+ criteria.fetchDeployments(true);
+ criteria.fetchGroup(true);
+ criteria.fetchTags(true);
+ return criteria;
+ }
+
+ @Override
public BundleDestination copyValues(Record from) {
return (BundleDestination) from.getAttributeAsObject("object");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
index 00d25df..e95626c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
@@ -35,16 +35,14 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
-import org.rhq.core.domain.bundle.BundleDestination;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleDestinationListView extends Table<RPCDataSource<BundleDestination>> {
+public class BundleDestinationListView extends Table<BundleDestinationDataSource> {
public BundleDestinationListView(String locatorId) {
this(locatorId, null);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
index 11edfdf..5cfabd6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
@@ -40,7 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author John Mazzitelli
*/
-public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
+public class BundleVersionDataSource extends RPCDataSource<BundleVersion, BundleVersionCriteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_BUNDLE_ID = "bundleId";
@@ -83,8 +83,24 @@ public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BundleVersionCriteria criteria) {
+ bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_bundleVersion_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ public void onSuccess(PageList<BundleVersion> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected BundleVersionCriteria getFetchCriteria(final DSRequest request) {
BundleVersionCriteria criteria = new BundleVersionCriteria();
criteria.fetchBundleFiles(true);
criteria.fetchBundle(true);
@@ -106,21 +122,7 @@ public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
if (request.getCriteria().getValues().get("tagName") != null) {
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
- bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_bundleVersion_loadFailure(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<BundleVersion> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
-
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
index 4fe31e0..dd74999 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
@@ -40,7 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundlesDataSource extends RPCDataSource<Bundle> {
+public class BundlesDataSource extends RPCDataSource<Bundle, BundleCriteria> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
@@ -71,8 +71,24 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BundleCriteria criteria) {
+ bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_bundle_loadFailed(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ public void onSuccess(PageList<Bundle> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected BundleCriteria getFetchCriteria(final DSRequest request) {
BundleCriteria criteria = new BundleCriteria();
criteria.setPageControl(getPageControl(request));
@@ -98,20 +114,7 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
// criteria.setSearchExpression(request.getCriteria().getValues().get("search").toString());
// }
- bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.dataSource_bundle_loadFailed(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<Bundle> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
-
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
index ceb3c30..023fd1f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
@@ -47,7 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablem
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -58,7 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public class BundlesListView extends Table<RPCDataSource<BundleWithLatestVersionComposite>> {
+public class BundlesListView extends Table<BundlesWithLatestVersionDataSource> {
private final Set<Permission> permissions;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
index 16b48c7..fc16c70 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author John Mazzitelli
*/
-public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWithLatestVersionComposite> {
+public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWithLatestVersionComposite, BundleCriteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
@@ -57,22 +57,7 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- BundleCriteria criteria = new BundleCriteria();
- criteria.setPageControl(getPageControl(request));
- if (request.getCriteria().getValues().get("tagNamespace") != null) {
- criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
- }
-
- if (request.getCriteria().getValues().get("tagSemantic") != null) {
- criteria.addFilterTagSemantic((String) request.getCriteria().getValues().get("tagSemantic"));
- }
-
- if (request.getCriteria().getValues().get("tagName") != null) {
- criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
- }
-
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BundleCriteria criteria) {
bundleService.findBundlesWithLatestVersionCompositesByCriteria(criteria,
new AsyncCallback<PageList<BundleWithLatestVersionComposite>>() {
public void onFailure(Throwable caught) {
@@ -87,7 +72,24 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
processResponse(request.getRequestId(), response);
}
});
+ }
+
+ @Override
+ protected BundleCriteria getFetchCriteria(final DSRequest request) {
+ BundleCriteria criteria = new BundleCriteria();
+ criteria.setPageControl(getPageControl(request));
+ if (request.getCriteria().getValues().get("tagNamespace") != null) {
+ criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
+ }
+ if (request.getCriteria().getValues().get("tagSemantic") != null) {
+ criteria.addFilterTagSemantic((String) request.getCriteria().getValues().get("tagSemantic"));
+ }
+
+ if (request.getCriteria().getValues().get("tagName") != null) {
+ criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
+ }
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index 61b29ce..039bc3e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -43,6 +43,7 @@ import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleDestinationCriteria;
import org.rhq.core.domain.criteria.BundleVersionCriteria;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
@@ -52,8 +53,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-@SuppressWarnings("unchecked")
-public class BundleTreeDataSource extends RPCDataSource {
+public class BundleTreeDataSource extends RPCDataSource<Object, Criteria> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
private final boolean canManageBundles;
@@ -85,7 +85,7 @@ public class BundleTreeDataSource extends RPCDataSource {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
String p = request.getCriteria().getAttribute("parentId");
@@ -170,6 +170,13 @@ public class BundleTreeDataSource extends RPCDataSource {
}
@Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // our executeFetch will determine on its own what criteria to use based on what is to be fetched
+ // thus we don't return anything here and let the executeFetch do everything
+ return null;
+ }
+
+ @Override
public Object copyValues(Record from) {
return null; // don't need this method.
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java
index 247907a..10e1e43 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java
@@ -31,17 +31,15 @@ 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.bundle.BundleVersion;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundleVersionDataSource;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleVersionListView extends Table<RPCDataSource<BundleVersion>> {
+public class BundleVersionListView extends Table<BundleVersionDataSource> {
public BundleVersionListView(String locatorId) {
this(locatorId, null);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index 457d13b..ad1b658 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -74,7 +74,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class AbstractSelector<T> extends LocatableVLayout {
+public abstract class AbstractSelector<T, C extends org.rhq.core.domain.criteria.Criteria> extends LocatableVLayout {
private static final String SELECTOR_KEY = "id";
@@ -84,7 +84,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
protected HLayout hlayout;
protected LocatableListGrid availableGrid;
protected LocatableListGrid assignedGrid;
- protected RPCDataSource<T> datasource;
+ protected RPCDataSource<T, C> datasource;
private Set<AssignedItemsChangedHandler> assignedItemsChangedHandlers = new HashSet<AssignedItemsChangedHandler>();
@@ -159,7 +159,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
protected abstract DynamicForm getAvailableFilterForm();
- protected abstract RPCDataSource<T> getDataSource();
+ protected abstract RPCDataSource<T, C> getDataSource();
protected abstract Criteria getLatestCriteria(DynamicForm availableFilterForm);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
index a1bd824..cc6db46 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
@@ -38,20 +38,11 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class TaggingDataSource extends RPCDataSource<Tag> {
+public class TaggingDataSource extends RPCDataSource<Tag, TagCriteria> {
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- // TagCriteria criteria = new TagCriteria();
-
- String search = (String) request.getCriteria().getValues().get("tag");
- if (search != null) {
- // todo
- // criteria.addFilter
- }
-
- GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(), new AsyncCallback<PageList<Tag>>() {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final TagCriteria criteria) {
+ GWTServiceLookup.getTagService().findTagsByCriteria(criteria, new AsyncCallback<PageList<Tag>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_tags_error_1(), caught);
response.setStatus(DSResponse.STATUS_FAILURE);
@@ -63,7 +54,20 @@ public class TaggingDataSource extends RPCDataSource<Tag> {
processResponse(request.getRequestId(), response);
}
});
+ }
+
+ @Override
+ protected TagCriteria getFetchCriteria(DSRequest request) {
+ TagCriteria criteria = new TagCriteria();
+
+ /* TODO: add search filter
+ String search = (String) request.getCriteria().getValues().get("tag");
+ if (search != null) {
+ // criteria.addFilter
+ }
+ */
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
index ab2f634..5e9cf08 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
@@ -44,7 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
+public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo, RepoCriteria> {
private RepoGWTServiceAsync repoService = GWTServiceLookup.getRepoService();
@@ -75,10 +75,7 @@ public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- RepoCriteria criteria = new RepoCriteria();
-
+ protected void executeFetch(final DSRequest request, final DSResponse response, final RepoCriteria criteria) {
repoService.findReposByCriteria(criteria, new AsyncCallback<PageList<Repo>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.dataSource_ContentRepoTree_error_load(), caught);
@@ -89,7 +86,12 @@ public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
processResponse(request.getRequestId(), response);
}
});
+ }
+ @Override
+ protected RepoCriteria getFetchCriteria(final DSRequest request) {
+ RepoCriteria criteria = new RepoCriteria();
+ return criteria;
}
@Override
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 9c2be45..37813ac 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
@@ -403,7 +403,23 @@ class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource
private Configuration portletConfig;
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupOperationHistoryCriteria criteria) {
+ 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);
+ }
+ });
+ }
+
+ @Override
+ protected GroupOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
//initialize criteria
GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
@@ -493,17 +509,6 @@ class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource
}
}
}
-
- 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);
- }
- });
+ return criteria;
}
}
\ 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
index f2a0ab4..c584aaa 100644
--- 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
@@ -204,7 +204,8 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
*
* @author spinder
*/
-class ResourceOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView {
+class ResourceOperationsCriteriaHistoryListView extends
+ AbstractOperationHistoryListView<ResourceOperationsCriteriaDataSource> {
private ResourceOperationsCriteriaDataSource datasource;
@@ -266,7 +267,23 @@ class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataS
private Configuration portletConfig;
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceOperationHistoryCriteria criteria) {
+ 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);
+ }
+ });
+ }
+
+ @Override
+ protected ResourceOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
@@ -357,17 +374,6 @@ class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataS
}
}
}
-
- 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);
- }
- });
+ return criteria;
}
}
\ No newline at end of file
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 d87097a..25088bc 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
@@ -47,7 +47,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*
* @author Ian Springer
*/
-public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSource<MeasurementDataTrait> {
+public abstract class AbstractMeasurementDataTraitDataSource extends
+ RPCDataSource<MeasurementDataTrait, MeasurementDataTraitCriteria> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementDataTraitDataSource() {
@@ -87,11 +88,10 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
return fields;
}
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final MeasurementDataTraitCriteria criteria) {
final long startTime = System.currentTimeMillis();
- final MeasurementDataTraitCriteria criteria = getCriteria(request);
-
this.measurementService.findTraitsByCriteria(criteria, new AsyncCallback<PageList<MeasurementDataTrait>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.dataSource_traits_failFetch(criteria.toString()), caught);
@@ -116,7 +116,8 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
processResponse(request.getRequestId(), response);
}
- protected MeasurementDataTraitCriteria getCriteria(DSRequest request) {
+ @Override
+ protected MeasurementDataTraitCriteria getFetchCriteria(DSRequest request) {
MeasurementDataTraitCriteria criteria = new MeasurementDataTraitCriteria();
Criteria requestCriteria = request.getCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
index 8d2de00..dfc951c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
@@ -34,6 +34,7 @@ import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
@@ -49,7 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Ian Springer
*/
public abstract class AbstractMeasurementScheduleCompositeDataSource extends
- RPCDataSource<MeasurementScheduleComposite> {
+ RPCDataSource<MeasurementScheduleComposite, Criteria> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementScheduleCompositeDataSource() {
@@ -94,7 +95,14 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends
return fields;
}
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
final EntityContext entityContext = getEntityContext(request);
this.measurementService.getMeasurementScheduleCompositesByContext(entityContext,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
index 6e63435..657f2b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
@@ -53,7 +53,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Ian Springer
*/
@Deprecated
-public abstract class AbstractMeasurementScheduleDataSource extends RPCDataSource<MeasurementSchedule> {
+public abstract class AbstractMeasurementScheduleDataSource extends
+ RPCDataSource<MeasurementSchedule, MeasurementScheduleCriteria> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementScheduleDataSource() {
@@ -97,11 +98,10 @@ public abstract class AbstractMeasurementScheduleDataSource extends RPCDataSourc
return fields;
}
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final MeasurementScheduleCriteria criteria) {
final long startTime = System.currentTimeMillis();
- final MeasurementScheduleCriteria criteria = getCriteria(request);
-
this.measurementService.findMeasurementSchedulesByCriteria(criteria,
new AsyncCallback<PageList<MeasurementSchedule>>() {
public void onFailure(Throwable caught) {
@@ -124,7 +124,8 @@ public abstract class AbstractMeasurementScheduleDataSource extends RPCDataSourc
});
}
- protected MeasurementScheduleCriteria getCriteria(DSRequest request) {
+ @Override
+ protected MeasurementScheduleCriteria getFetchCriteria(DSRequest request) {
MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
criteria.fetchDefinition(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java
index c4f64a3..15606f2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -27,18 +29,19 @@ import com.smartgwt.client.data.fields.DataSourceDateTimeField;
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.OperationHistoryCriteria;
import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import java.util.List;
-
/**
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class AbstractOperationHistoryDataSource<T extends OperationHistory> extends RPCDataSource<T> {
+public abstract class AbstractOperationHistoryDataSource<T extends OperationHistory, C extends OperationHistoryCriteria>
+ extends RPCDataSource<T, C> {
private T currentOperationHistory;
@@ -86,23 +89,23 @@ public abstract class AbstractOperationHistoryDataSource<T extends OperationHist
idField.setPrimaryKey(true);
fields.add(idField);
- DataSourceTextField nameField = new DataSourceTextField(Field.OPERATION_NAME,
- MSG.dataSource_operationHistory_field_operationName());
+ DataSourceTextField nameField = new DataSourceTextField(Field.OPERATION_NAME, MSG
+ .dataSource_operationHistory_field_operationName());
fields.add(nameField);
DataSourceTextField statusField = new DataSourceTextField(Field.STATUS, MSG.common_title_status());
fields.add(statusField);
- DataSourceDateTimeField createdTimeField = new DataSourceDateTimeField(Field.CREATED_TIME,
- MSG.dataSource_operationHistory_field_createdTime());
+ DataSourceDateTimeField createdTimeField = new DataSourceDateTimeField(Field.CREATED_TIME, MSG
+ .dataSource_operationHistory_field_createdTime());
fields.add(createdTimeField);
- DataSourceDateTimeField startedTimeField = new DataSourceDateTimeField(Field.STARTED_TIME,
- MSG.dataSource_operationHistory_field_startedTime());
+ DataSourceDateTimeField startedTimeField = new DataSourceDateTimeField(Field.STARTED_TIME, MSG
+ .dataSource_operationHistory_field_startedTime());
fields.add(startedTimeField);
- DataSourceTextField subjectField = new DataSourceTextField(Field.SUBJECT,
- MSG.dataSource_operationHistory_field_subject());
+ DataSourceTextField subjectField = new DataSourceTextField(Field.SUBJECT, MSG
+ .dataSource_operationHistory_field_subject());
fields.add(subjectField);
return fields;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java
index 041c7db..7ee12ad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java
@@ -37,6 +37,7 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.bean.OperationSchedule;
import org.rhq.core.domain.resource.ResourceType;
@@ -49,7 +50,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RecordUtility;
/**
* @author Ian Springer
*/
-public abstract class AbstractOperationScheduleDataSource<T extends OperationSchedule> extends RPCDataSource<T> {
+public abstract class AbstractOperationScheduleDataSource<T extends OperationSchedule> extends
+ RPCDataSource<T, Criteria> {
public static abstract class Field {
public static final String ID = "id";
@@ -92,14 +94,14 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
protected List<DataSourceField> addDataSourceFields() {
List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID,
- MSG.dataSource_operationSchedule_field_id());
+ DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID, MSG
+ .dataSource_operationSchedule_field_id());
idField.setPrimaryKey(true);
idField.setCanEdit(false);
- fields.add(idField);
+ fields.add(idField);
- DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME,
- MSG.dataSource_operationSchedule_field_operationName(), null, 100, true);
+ DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME, MSG
+ .dataSource_operationSchedule_field_operationName(), null, 100, true);
Set<OperationDefinition> operationDefinitions = this.resourceType.getOperationDefinitions();
LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
for (OperationDefinition operationDefinition : operationDefinitions) {
@@ -108,26 +110,26 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
operationNameField.setValueMap(valueMap);
fields.add(operationNameField);
- DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME,
- MSG.dataSource_operationSchedule_field_operationDisplayName(), null, 100, true);
+ DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, MSG
+ .dataSource_operationSchedule_field_operationDisplayName(), null, 100, true);
fields.add(operationDisplayNameField);
- DataSourceField subjectField = new DataSourceField(Field.SUBJECT, FieldType.ANY,
- MSG.dataSource_operationSchedule_field_subject());
+ DataSourceField subjectField = new DataSourceField(Field.SUBJECT, FieldType.ANY, MSG
+ .dataSource_operationSchedule_field_subject());
subjectField.setCanEdit(false);
fields.add(subjectField);
- DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION,
- MSG.dataSource_operationSchedule_field_description(), null, 100, false);
+ DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION, MSG
+ .dataSource_operationSchedule_field_description(), null, 100, false);
fields.add(descriptionField);
- DataSourceDateTimeField nextFireTimeField = new DataSourceDateTimeField(Field.NEXT_FIRE_TIME,
- MSG.dataSource_operationSchedule_field_nextFireTime());
+ DataSourceDateTimeField nextFireTimeField = new DataSourceDateTimeField(Field.NEXT_FIRE_TIME, MSG
+ .dataSource_operationSchedule_field_nextFireTime());
nextFireTimeField.setCanEdit(false);
fields.add(nextFireTimeField);
- DataSourceIntegerField timeoutField = createIntegerField(Field.TIMEOUT,
- MSG.dataSource_operationSchedule_field_timeout(), 30, null, false);
+ DataSourceIntegerField timeoutField = createIntegerField(Field.TIMEOUT, MSG
+ .dataSource_operationSchedule_field_timeout(), 30, null, false);
fields.add(timeoutField);
return fields;
@@ -140,7 +142,7 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
T to = createOperationSchedule();
to.setId(from.getAttributeAsInt(Field.ID));
- to.setJobName(from.getAttribute(Field.JOB_NAME));
+ to.setJobName(from.getAttribute(Field.JOB_NAME));
to.setJobGroup(from.getAttribute(Field.JOB_GROUP));
SubjectRecord subjectRecord = (SubjectRecord) from.getAttributeAsRecord(Field.SUBJECT);
to.setSubject(subjectRecord.toSubject());
@@ -174,11 +176,11 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
Configuration parameters = from.getParameters();
to.setAttribute(Field.PARAMETERS, parameters);
to.setAttribute(Field.OPERATION_NAME, from.getOperationName());
- to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
+ to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
to.setAttribute(Field.DESCRIPTION, from.getDescription());
to.setAttribute(Field.NEXT_FIRE_TIME, from.getNextFireTime());
- to.setAttribute(Field.TIMEOUT, (parameters != null) ?
- parameters.getSimpleValue(OperationDefinition.TIMEOUT_PARAM_NAME, null) : null);
+ to.setAttribute(Field.TIMEOUT, (parameters != null) ? parameters.getSimpleValue(
+ OperationDefinition.TIMEOUT_PARAM_NAME, null) : null);
JobTrigger jobTrigger = from.getJobTrigger();
Record jobTriggerRecord = new ListGridRecord();
@@ -201,7 +203,7 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
} else {
// calendar mode
Date startTime = jobTriggerRecord.getAttributeAsDate(Field.START_TIME);
- Long repeatInterval = (Long)jobTriggerRecord.getAttributeAsObject(Field.REPEAT_INTERVAL);
+ Long repeatInterval = (Long) jobTriggerRecord.getAttributeAsObject(Field.REPEAT_INTERVAL);
Integer repeatCount = jobTriggerRecord.getAttributeAsInt(Field.REPEAT_COUNT);
Date endTime = jobTriggerRecord.getAttributeAsDate(Field.END_TIME);
@@ -243,10 +245,20 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
}
protected void addRequestPropertiesToRecord(DSRequest request, Record record) {
- Configuration parameters = (Configuration) request.getAttributeAsObject(GroupOperationScheduleDataSource.RequestProperty.PARAMETERS);
+ Configuration parameters = (Configuration) request
+ .getAttributeAsObject(GroupOperationScheduleDataSource.RequestProperty.PARAMETERS);
record.setAttribute(GroupOperationScheduleDataSource.Field.PARAMETERS, parameters);
}
+ /**
+ * All data sources extending this type do not use the normal criteria object to query.
+ * So this just returns null.
+ */
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ return null;
+ }
+
public static class SubjectRecord extends ListGridRecord {
static final String FIELD_ID = "id";
static final String FIELD_NAME = "name";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
index 64dc1a9..e7f93e4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
@@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Joseph Marques
*/
-public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
+public class EventCompositeDatasource extends RPCDataSource<EventComposite, EventCriteria> {
private EntityContext entityContext;
@@ -108,9 +108,7 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- EventCriteria criteria = getFetchCriteria(request);
-
+ protected void executeFetch(final DSRequest request, final DSResponse response, final EventCriteria criteria) {
GWTServiceLookup.getEventService().findEventCompositesByCriteria(criteria,
new AsyncCallback<PageList<EventComposite>>() {
public void onFailure(Throwable caught) {
@@ -128,7 +126,7 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
});
}
- @SuppressWarnings("unchecked")
+ @Override
protected EventCriteria getFetchCriteria(final DSRequest request) {
EventCriteria criteria = new EventCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
index e81a82e..ab30354 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
@@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Joseph Marques
*/
-public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGroupComposite> {
+public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGroupComposite, ResourceGroupCriteria> {
ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
@@ -100,9 +100,8 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceGroupCriteria criteria = getFetchCriteria(request);
-
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, ResourceGroupCriteria criteria) {
groupService.findResourceGroupCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceGroupComposite>>() {
public void onFailure(Throwable caught) {
@@ -119,6 +118,7 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
});
}
+ @Override
protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index a1a1578..83c356f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -49,7 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
+public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup, ResourceGroupCriteria> {
private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
@@ -95,9 +95,8 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceGroupCriteria criteria = getFetchCriteria(request);
-
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, final ResourceGroupCriteria criteria) {
groupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.dataSource_resourceGroups_loadFailed(), caught);
@@ -113,6 +112,7 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
});
}
+ @Override
protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
index 1c21763..cef860a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
@@ -45,7 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
* @author Greg Hinkle
* @author Joseph Marques
*/
-public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
+public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition, ResourceGroupDefinitionCriteria> {
private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
@@ -98,10 +98,8 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceGroupDefinitionCriteria criteria = new ResourceGroupDefinitionCriteria();
- criteria.setPageControl(getPageControl(request));
-
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceGroupDefinitionCriteria criteria) {
groupService.findGroupDefinitionsByCriteria(criteria, new AsyncCallback<PageList<GroupDefinition>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_definitionLoadFailure(), caught);
@@ -117,6 +115,13 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
}
@Override
+ protected ResourceGroupDefinitionCriteria getFetchCriteria(final DSRequest request) {
+ ResourceGroupDefinitionCriteria criteria = new ResourceGroupDefinitionCriteria();
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+
+ @Override
protected void executeAdd(Record recordToAdd, final DSRequest request, final DSResponse response) {
final GroupDefinition newGroupDefinition = copyValues(recordToAdd);
final String name = newGroupDefinition.getName();
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 8ea5782..9071b94 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
@@ -214,7 +214,8 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
return html;
}
- private class DataSource extends RPCDataSource<ResourceConfigurationUpdate> {
+ private class DataSource extends
+ RPCDataSource<ResourceConfigurationUpdate, ResourceConfigurationUpdateCriteria> {
public class Field {
public static final String ID = "id";
@@ -253,14 +254,10 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceConfigurationUpdateCriteria criteria) {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
- criteria
- .addFilterGroupConfigurationUpdateId(HistoryGroupResourceConfigurationMembers.this.groupUpdateId);
- criteria.fetchResource(true);
-
configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
@@ -312,6 +309,15 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
}
});
}
+
+ @Override
+ protected ResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
+ criteria
+ .addFilterGroupConfigurationUpdateId(HistoryGroupResourceConfigurationMembers.this.groupUpdateId);
+ criteria.fetchResource(true);
+ return criteria;
+ }
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
index 38174c8..d6da7d0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
@@ -214,7 +214,7 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
return html;
}
- class DataSource extends RPCDataSource<GroupResourceConfigurationUpdate> {
+ class DataSource extends RPCDataSource<GroupResourceConfigurationUpdate, GroupResourceConfigurationUpdateCriteria> {
public class Field {
public static final String ID = "id";
@@ -246,14 +246,10 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupResourceConfigurationUpdateCriteria criteria) {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
- ArrayList<Integer> groupList = new ArrayList<Integer>(1);
- groupList.add(HistoryGroupResourceConfigurationTable.this.group.getId());
- criteria.addFilterResourceGroupIds(groupList);
-
configurationService.findGroupResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>() {
@@ -272,5 +268,14 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
}
});
}
+
+ @Override
+ protected GroupResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
+ ArrayList<Integer> groupList = new ArrayList<Integer>(1);
+ groupList.add(HistoryGroupResourceConfigurationTable.this.group.getId());
+ criteria.addFilterResourceGroupIds(groupList);
+ return criteria;
+ }
}
}
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 ae76963..ec590c0 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
@@ -213,7 +213,7 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
return html;
}
- private class DataSource extends RPCDataSource<PluginConfigurationUpdate> {
+ private class DataSource extends RPCDataSource<PluginConfigurationUpdate, PluginConfigurationUpdateCriteria> {
public class Field {
public static final String ID = "id";
@@ -252,12 +252,10 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final PluginConfigurationUpdateCriteria criteria) {
- PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
- criteria.addFilterGroupConfigurationUpdateId(HistoryGroupPluginConfigurationMembers.this.groupUpdateId);
- criteria.fetchResource(true);
+ ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
configurationService.findPluginConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
@@ -310,6 +308,14 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
}
});
}
+
+ @Override
+ protected PluginConfigurationUpdateCriteria getFetchCriteria(DSRequest request) {
+ PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
+ criteria.addFilterGroupConfigurationUpdateId(HistoryGroupPluginConfigurationMembers.this.groupUpdateId);
+ criteria.fetchResource(true);
+ return criteria;
+ }
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
index fe975f2..1c36f7c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
@@ -214,7 +214,7 @@ public class HistoryGroupPluginConfigurationTable extends Table<HistoryGroupPlug
return html;
}
- class DataSource extends RPCDataSource<GroupPluginConfigurationUpdate> {
+ class DataSource extends RPCDataSource<GroupPluginConfigurationUpdate, GroupPluginConfigurationUpdateCriteria> {
public class Field {
public static final String ID = "id";
@@ -246,14 +246,10 @@ public class HistoryGroupPluginConfigurationTable extends Table<HistoryGroupPlug
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupPluginConfigurationUpdateCriteria criteria) {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- GroupPluginConfigurationUpdateCriteria criteria = new GroupPluginConfigurationUpdateCriteria();
- ArrayList<Integer> groupList = new ArrayList<Integer>(1);
- groupList.add(HistoryGroupPluginConfigurationTable.this.group.getId());
- criteria.addFilterResourceGroupIds(groupList);
-
configurationService.findGroupPluginConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<GroupPluginConfigurationUpdate>>() {
@@ -272,5 +268,14 @@ public class HistoryGroupPluginConfigurationTable extends Table<HistoryGroupPlug
}
});
}
+
+ @Override
+ protected GroupPluginConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ GroupPluginConfigurationUpdateCriteria criteria = new GroupPluginConfigurationUpdateCriteria();
+ ArrayList<Integer> groupList = new ArrayList<Integer>(1);
+ groupList.add(HistoryGroupPluginConfigurationTable.this.group.getId());
+ criteria.addFilterResourceGroupIds(groupList);
+ return criteria;
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
index 902efa7..1f4d491 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
@@ -23,7 +23,6 @@ import java.util.List;
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.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -65,12 +64,6 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected void executeFetch(DSRequest request, DSResponse response) {
- super.executeFetch(request, response);
-
- }
-
- @Override
protected EntityContext getEntityContext(DSRequest request) {
Criteria requestCriteria = request.getCriteria();
Integer groupId = requestCriteria.getAttributeAsInt(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
index ff90336..b9b78ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
@@ -19,22 +19,24 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history;
+import java.util.Arrays;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
-import java.util.Arrays;
-
/**
* @author Ian Springer
*/
-public class GroupOperationHistoryDataSource extends AbstractOperationHistoryDataSource<GroupOperationHistory> {
+public class GroupOperationHistoryDataSource extends
+ AbstractOperationHistoryDataSource<GroupOperationHistory, GroupOperationHistoryCriteria> {
public static abstract class Field extends AbstractOperationHistoryDataSource.Field {
public static final String GROUP = "group";
@@ -45,28 +47,32 @@ public class GroupOperationHistoryDataSource extends AbstractOperationHistoryDat
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupOperationHistoryCriteria criteria) {
+ 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);
+ }
+ });
+ }
+
+ @Override
+ protected GroupOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_ID)) {
- int groupId = Integer.parseInt((String)request.getCriteria().getValues().get(
- CriteriaField.GROUP_ID));
+ int groupId = Integer.parseInt((String) request.getCriteria().getValues().get(CriteriaField.GROUP_ID));
criteria.addFilterResourceGroupIds(Arrays.asList(groupId));
}
criteria.setPageControl(getPageControl(request));
-
- 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);
- }
- });
+ return criteria;
}
@Override
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 7edf2ab..8ad3170 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
@@ -28,7 +28,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.h
/**
* @author Ian Springer
*/
-public class GroupOperationHistoryListView extends AbstractOperationHistoryListView {
+public class GroupOperationHistoryListView extends AbstractOperationHistoryListView<GroupOperationHistoryDataSource> {
private ResourceGroupComposite groupComposite;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
index f41333a..56ba89e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
@@ -19,19 +19,20 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+import java.util.List;
+
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.Configuration;
+
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDataSource;
-import java.util.List;
-
/**
* A DataSource for {@link org.rhq.core.domain.operation.bean.GroupOperationSchedule}s for a given
* {@link org.rhq.core.domain.resource.group.ResourceGroup}.
@@ -64,17 +65,17 @@ public class GroupOperationScheduleDataSource extends AbstractOperationScheduleD
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
final Integer scheduleId = request.getCriteria().getAttributeAsInt(Field.ID);
if (scheduleId != null) {
- operationService.getGroupOperationSchedule(scheduleId, new AsyncCallback<GroupOperationSchedule>() {
+ operationService.getGroupOperationSchedule(scheduleId, new AsyncCallback<GroupOperationSchedule>() {
public void onSuccess(GroupOperationSchedule result) {
sendSuccessResponse(request, response, result);
}
public void onFailure(Throwable caught) {
sendFailureResponse(request, response, "Failed to fetch GroupOperationSchedule with id "
- + scheduleId + ".", caught);
+ + scheduleId + ".", caught);
}
});
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
index 27f49f2..24eb534 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
@@ -1,3 +1,26 @@
+/*
+ * 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.enterprise.gui.coregui.client.inventory.resource;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
@@ -42,7 +65,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*
* @author Jay Shaughnessy
*/
-public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite> {
+public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite, ResourceCriteria> {
private static ResourceCompositeDataSource INSTANCE;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -68,9 +91,7 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
return ResourceDatasource.addResourceDatasourceFields(fields);
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria criteria = getFetchCriteria(request);
-
+ public void executeFetch(final DSRequest request, final DSResponse response, final ResourceCriteria criteria) {
getResourceService().findResourceCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceComposite>>() {
public void onFailure(Throwable caught) {
@@ -135,6 +156,7 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
});
}
+ @Override
protected ResourceCriteria getFetchCriteria(final DSRequest request) {
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
index 192beae..097383e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
@@ -1,3 +1,26 @@
+/*
+ * 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.enterprise.gui.coregui.client.inventory.resource;
import java.util.LinkedHashMap;
@@ -44,7 +67,8 @@ public class ResourceCompositeSearchView extends ResourceSearchView {
this(locatorId, null, criteria, title, headerIcons);
}
- protected RPCDataSource<?> getDataSourceInstance() {
+ @Override
+ protected RPCDataSource getDataSourceInstance() {
return ResourceCompositeDataSource.getInstance();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 9a10084..eb948c8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -57,7 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ResourceDatasource extends RPCDataSource<Resource> {
+public class ResourceDatasource extends RPCDataSource<Resource, ResourceCriteria> {
public static final String FILTER_GROUP_ID = "groupId";
@@ -122,9 +122,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria criteria = getFetchCriteria(request);
-
+ public void executeFetch(final DSRequest request, final DSResponse response, final ResourceCriteria criteria) {
resourceService.findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_loadFailed(), caught);
@@ -182,6 +180,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
});
}
+ @Override
protected ResourceCriteria getFetchCriteria(final DSRequest request) {
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index dc6b945..7d46996 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -60,7 +60,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
*/
-@SuppressWarnings("unchecked")
public class ResourceSearchView extends Table {
private static final String DEFAULT_TITLE = MSG.view_inventory_resources_title();
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 4420169..bd8c430 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
@@ -39,6 +39,7 @@ import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.criteria.AbstractResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
@@ -55,8 +56,8 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractResourceConfigurationUpdate> extends
- RPCDataSource<T> {
+public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractResourceConfigurationUpdate, C extends AbstractResourceConfigurationUpdateCriteria>
+ extends RPCDataSource<T, C> {
public static abstract class Field {
public static final String ID = "id";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
index c8041fe..0804cbf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
@@ -29,6 +29,7 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
+import org.rhq.core.domain.criteria.AbstractResourceConfigurationUpdateCriteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationComparisonView;
@@ -45,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class AbstractConfigurationHistoryView<T extends AbstractConfigurationHistoryDataSource<? extends AbstractResourceConfigurationUpdate>>
+public abstract class AbstractConfigurationHistoryView<T extends AbstractConfigurationHistoryDataSource<? extends AbstractResourceConfigurationUpdate, ? extends AbstractResourceConfigurationUpdateCriteria>>
extends TableSection<T> {
private Integer resourceId;
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 3a28dcc..d7556d7 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
@@ -48,7 +48,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public class ConfigurationHistoryDataSource extends AbstractConfigurationHistoryDataSource<ResourceConfigurationUpdate> {
+public class ConfigurationHistoryDataSource extends
+ AbstractConfigurationHistoryDataSource<ResourceConfigurationUpdate, ResourceConfigurationUpdateCriteria> {
public ConfigurationHistoryDataSource() {
super();
@@ -65,20 +66,10 @@ public class ConfigurationHistoryDataSource extends AbstractConfigurationHistory
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
- criteria.fetchConfiguration(true);
- criteria.fetchResource(true);
- criteria.fetchGroupConfigurationUpdate(true);
-
- criteria.setPageControl(getPageControl(request));
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceConfigurationUpdateCriteria criteria) {
final Integer resourceId = (Integer) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
- if (resourceId != null) {
- criteria.addFilterResourceIds(resourceId);
- }
-
getConfigurationService().findResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
public void onFailure(Throwable caught) {
@@ -162,4 +153,20 @@ public class ConfigurationHistoryDataSource extends AbstractConfigurationHistory
}
});
}
+
+ @Override
+ protected ResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
+ criteria.fetchConfiguration(true);
+ criteria.fetchResource(true);
+ criteria.fetchGroupConfigurationUpdate(true);
+
+ criteria.setPageControl(getPageControl(request));
+
+ final Integer resourceId = (Integer) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
+ if (resourceId != null) {
+ criteria.addFilterResourceIds(resourceId);
+ }
+ return criteria;
+ }
}
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 4918dff..3e4e1d2 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
@@ -49,7 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* @author John Mazzitelli
*/
public class PluginConfigurationHistoryDataSource extends
- AbstractConfigurationHistoryDataSource<PluginConfigurationUpdate> {
+ AbstractConfigurationHistoryDataSource<PluginConfigurationUpdate, PluginConfigurationUpdateCriteria> {
public PluginConfigurationHistoryDataSource() {
super();
@@ -66,20 +66,10 @@ public class PluginConfigurationHistoryDataSource extends
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
- criteria.fetchConfiguration(true);
- criteria.fetchResource(true);
- criteria.fetchGroupConfigurationUpdate(true);
-
- criteria.setPageControl(getPageControl(request));
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final PluginConfigurationUpdateCriteria criteria) {
final Integer resourceId = (Integer) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
- if (resourceId != null) {
- criteria.addFilterResourceIds(resourceId);
- }
-
getConfigurationService().findPluginConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
public void onFailure(Throwable caught) {
@@ -162,4 +152,20 @@ public class PluginConfigurationHistoryDataSource extends
}
});
}
+
+ @Override
+ protected PluginConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
+ criteria.fetchConfiguration(true);
+ criteria.fetchResource(true);
+ criteria.fetchGroupConfigurationUpdate(true);
+
+ criteria.setPageControl(getPageControl(request));
+
+ final Integer resourceId = (Integer) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
+ if (resourceId != null) {
+ criteria.addFilterResourceIds(resourceId);
+ }
+ return criteria;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
index f2a92ce..e7589ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
@@ -33,6 +33,7 @@ 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.Criteria;
import org.rhq.core.domain.criteria.MeasurementDefinitionCriteria;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.measurement.DataType;
@@ -46,7 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ResourceScheduledMetricDatasource extends RPCDataSource<MeasurementDefinition> {
+public class ResourceScheduledMetricDatasource extends RPCDataSource<MeasurementDefinition, Criteria> {
public ResourceScheduledMetricDatasource() {
List<DataSourceField> fields = addDataSourceFields();
@@ -83,12 +84,16 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
+ // due to the conditional below which determines what kind of criteria to use, this datasource
+ // doesn't rely on getFetchCriteria and the passed in criteria object. It is up to this method to
+ // correctly prepare the criteria we build here (e.g. set the page control properly).
if (request.getCriteria().getValues().containsKey("id")) {
MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
-
criteria.addFilterId(request.getCriteria().getAttributeAsInt("id"));
+ criteria.setPageControl(getPageControl(request));
+
GWTServiceLookup.getMeasurementDataService().findMeasurementDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<MeasurementDefinition>>() {
public void onFailure(Throwable caught) {
@@ -104,8 +109,8 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
} else if (request.getCriteria().getValues().containsKey("resourceId")) {
MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
criteria.fetchDefinition(true);
-
criteria.addFilterResourceId(request.getCriteria().getAttributeAsInt("resourceId"));
+ criteria.setPageControl(getPageControl(request));
GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria,
new AsyncCallback<PageList<MeasurementSchedule>>() {
@@ -142,6 +147,13 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
}
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // our executeFetch does some special conditional checking to determine what kind of criteria to use.
+ // because of this, we don't explicitly use this method to get the criteria for this datasource, just return null
+ return null;
+ }
+
private ListGridRecord[] buildRecords(PageList<MeasurementSchedule> list) {
PageList<MeasurementDefinition> definitions = new PageList<MeasurementDefinition>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
index 85bf0f0..b6acfa1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -40,7 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
+public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite, Criteria> {
private double maxMaximum;
@@ -74,7 +75,7 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
int scheduleId = Integer.parseInt((String) request.getCriteria().getValues().get("scheduleId"));
long now = System.currentTimeMillis();
long eightHoursAgo = now - (1000L * 60 * 60 * 8);
@@ -98,6 +99,12 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
}
@Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
public CallTimeDataComposite copyValues(Record from) {
throw new UnsupportedOperationException(MSG.view_resource_monitor_calltime_editFailed());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java
index e140b2f..8228061 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java
@@ -9,6 +9,7 @@ import com.smartgwt.client.data.Record;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
@@ -29,7 +30,7 @@ import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
*
* @author John Mazzitelli
*/
-public class MeasurementTableDataSource extends RPCDataSource<MetricDisplaySummary> {
+public class MeasurementTableDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
public static final String FIELD_METRIC_LABEL = "label";
public static final String FIELD_ALERT_COUNT = "alertCount";
@@ -116,7 +117,13 @@ public class MeasurementTableDataSource extends RPCDataSource<MetricDisplaySumma
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
// see MetricsTableUIBean for the old JSF class to see where this came from
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
index 796c490..e2ab1d2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
@@ -45,7 +45,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
/**
* @author Ian Springer
*/
-public class ResourceOperationHistoryDataSource extends AbstractOperationHistoryDataSource<ResourceOperationHistory> {
+public class ResourceOperationHistoryDataSource extends
+ AbstractOperationHistoryDataSource<ResourceOperationHistory, ResourceOperationHistoryCriteria> {
public static abstract class Field extends AbstractOperationHistoryDataSource.Field {
public static final String RESOURCE = "resource";
@@ -68,21 +69,8 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
-
- if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
- int resourceId = getFilter(request, CriteriaField.RESOURCE_ID, Integer.class);
- criteria.addFilterResourceIds(resourceId);
- }
-
- if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_OPERATION_HISTORY_ID)) {
- int groupOperationHistoryId = getFilter(request, CriteriaField.GROUP_OPERATION_HISTORY_ID, Integer.class);
- criteria.addFilterGroupOperationHistoryId(groupOperationHistoryId);
- }
-
- criteria.setPageControl(getPageControl(request));
-
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceOperationHistoryCriteria criteria) {
operationService.findResourceOperationHistoriesByCriteria(criteria,
new AsyncCallback<PageList<ResourceOperationHistory>>() {
public void onFailure(Throwable caught) {
@@ -98,6 +86,24 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
});
}
+ @Override
+ protected ResourceOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
+ int resourceId = getFilter(request, CriteriaField.RESOURCE_ID, Integer.class);
+ criteria.addFilterResourceIds(resourceId);
+ }
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_OPERATION_HISTORY_ID)) {
+ int groupOperationHistoryId = getFilter(request, CriteriaField.GROUP_OPERATION_HISTORY_ID, Integer.class);
+ criteria.addFilterGroupOperationHistoryId(groupOperationHistoryId);
+ }
+
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+
protected void dataRetrieved(final PageList<ResourceOperationHistory> result, final DSResponse response,
final DSRequest request) {
HashSet<Integer> typesSet = new HashSet<Integer>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
index 5bc58d7..a2513a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
@@ -26,6 +26,7 @@ import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceComposite;
@@ -53,33 +54,33 @@ public class ResourceOperationScheduleDataSource extends AbstractOperationSchedu
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
final Integer scheduleId = request.getCriteria().getAttributeAsInt(Field.ID);
if (scheduleId != null) {
- operationService.getResourceOperationSchedule(scheduleId, new AsyncCallback<ResourceOperationSchedule>() {
+ operationService.getResourceOperationSchedule(scheduleId, new AsyncCallback<ResourceOperationSchedule>() {
public void onSuccess(ResourceOperationSchedule result) {
sendSuccessResponse(request, response, result);
}
public void onFailure(Throwable caught) {
sendFailureResponse(request, response, "Failed to fetch ResourceOperationSchedule with id "
- + scheduleId + ".", caught);
+ + scheduleId + ".", caught);
}
});
} else {
operationService.findScheduledResourceOperations(this.resourceComposite.getResource().getId(),
- new AsyncCallback<List<ResourceOperationSchedule>>() {
- public void onSuccess(List<ResourceOperationSchedule> result) {
- Record[] records = buildRecords(result);
- response.setData(records);
- processResponse(request.getRequestId(), response);
- }
-
- public void onFailure(Throwable caught) {
- throw new RuntimeException("Failed to find scheduled operations for "
- + resourceComposite.getResource() + ".", caught);
- }
- });
+ new AsyncCallback<List<ResourceOperationSchedule>>() {
+ public void onSuccess(List<ResourceOperationSchedule> result) {
+ Record[] records = buildRecords(result);
+ response.setData(records);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to find scheduled operations for "
+ + resourceComposite.getResource() + ".", caught);
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
index d69b433..5999e14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
@@ -34,6 +34,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -45,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Lukas Krejci
* @author Simeon Pinder
*/
-public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
+public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Criteria> {
public static abstract class Field {
public static final String SUMMARY = "summary";
@@ -87,7 +88,7 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
* @see org.rhq.enterprise.gui.coregui.client.util.RPCDataSource#executeFetch(com.smartgwt.client.data.DSRequest, com.smartgwt.client.data.DSResponse)
*/
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
resourceService.findResourceErrors(resourceId, new AsyncCallback<List<ResourceError>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
@@ -103,6 +104,12 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
});
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
public ResourceError copyValues(Record from) {
//This is read-only datasource, so no need to implement this.
return null;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
index 320e341..7bb5bb5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
*/
-public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
+public class ResourceGroupSelector extends AbstractSelector<ResourceGroup, ResourceGroupCriteria> {
private static LinkedHashMap<String, String> CATEGORY_VALUE_MAP = new LinkedHashMap<String, String>();
@@ -92,7 +92,7 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
return availableFilterForm;
}
- protected RPCDataSource<ResourceGroup> getDataSource() {
+ protected RPCDataSource<ResourceGroup, ResourceGroupCriteria> getDataSource() {
return new SelectedResourceGroupsDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
index f310997..853e8d0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
@@ -48,7 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
*/
-public class ResourceSelector extends AbstractSelector<Resource> {
+public class ResourceSelector extends AbstractSelector<Resource, ResourceCriteria> {
private ResourceType resourceTypeFilter;
private boolean forceResourceTypeFilter;
@@ -108,7 +108,7 @@ public class ResourceSelector extends AbstractSelector<Resource> {
return valueMap;
}
- protected RPCDataSource<Resource> getDataSource() {
+ protected RPCDataSource<Resource, ResourceCriteria> getDataSource() {
if (null == datasource) {
datasource = new SelectedResourceDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index 42808cf..cf93986 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
import org.rhq.core.domain.resource.ResourceType;
@@ -55,7 +56,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Simeon Pinder
* @author Jay Shaughnessy
*/
-public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationLastCompletedComposite> {
+public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationLastCompletedComposite, Criteria> {
public enum Field {
@@ -140,7 +141,8 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
* @param request incoming request
* @param response outgoing response
*/
- public void executeFetch(final DSRequest request, final DSResponse response) {
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
PageControl pageControl = new PageControl();
//retrieve current portlet display settings
if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) {
@@ -180,6 +182,12 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
});
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
protected void dataRetrieved(final PageList<ResourceOperationLastCompletedComposite> result,
final DSResponse response, final DSRequest request) {
HashSet<Integer> typesSet = new HashSet<Integer>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index a835711..e9ee1c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
@@ -51,7 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Simeon Pinder
* @author Jay Shaughnessy
*/
-public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperationScheduleComposite> {
+public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperationScheduleComposite, Criteria> {
public enum Field {
@@ -130,7 +131,8 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
* @param request incoming request
* @param response outgoing response
*/
- public void executeFetch(final DSRequest request, final DSResponse response) {
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
int pageSize = -1;
//retrieve current portlet display settings
@@ -169,6 +171,12 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
});
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
protected void dataRetrieved(final PageList<ResourceOperationScheduleComposite> result, final DSResponse response,
final DSRequest request) {
HashSet<Integer> typesSet = new HashSet<Integer>();
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 fcd9279..18f59cf 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
@@ -80,7 +80,7 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
private static final String FIELD_RESOURCE = "resource";
@Override
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ protected AlertDefinitionCriteria getFetchCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.addFilterResourceOnly(true); // guarantees that all alert defs we get will have a non-null Resource object
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java
index 442fefd..0eb0057 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java
@@ -190,7 +190,7 @@ public class ResourceInstallReport extends LocatableVLayout implements Bookmarka
return url;
}
- class DataSource extends RPCDataSource<ResourceInstallCount> {
+ class DataSource extends RPCDataSource<ResourceInstallCount, org.rhq.core.domain.criteria.Criteria> {
public class Field {
public static final String COUNT = "count"; // long that we convert to int
@@ -224,7 +224,14 @@ public class ResourceInstallReport extends LocatableVLayout implements Bookmarka
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected org.rhq.core.domain.criteria.Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final org.rhq.core.domain.criteria.Criteria unused) {
ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
resourceService.findResourceInstallCounts(true, new AsyncCallback<List<ResourceInstallCount>>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
index 4e93b45..9fb110c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
@@ -34,6 +34,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -45,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBComposite> {
+public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBComposite, Criteria> {
private int maximumFactor = 0;
@@ -58,22 +59,28 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
protected List<DataSourceField> addDataSourceFields() {
List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField metricField = new DataSourceTextField("scheduleName", MSG.dataSource_measurementOob_field_scheduleName());
+ DataSourceTextField metricField = new DataSourceTextField("scheduleName", MSG
+ .dataSource_measurementOob_field_scheduleName());
fields.add(metricField);
- DataSourceTextField resourceField = new DataSourceTextField("resourceName", MSG.dataSource_measurementOob_field_resourceName());
+ DataSourceTextField resourceField = new DataSourceTextField("resourceName", MSG
+ .dataSource_measurementOob_field_resourceName());
fields.add(resourceField);
- DataSourceTextField parentField = new DataSourceTextField("parentName", MSG.dataSource_measurementOob_field_parentName());
+ DataSourceTextField parentField = new DataSourceTextField("parentName", MSG
+ .dataSource_measurementOob_field_parentName());
fields.add(parentField);
- DataSourceTextField bandField = new DataSourceTextField("formattedBaseband", MSG.dataSource_measurementOob_field_formattedBaseband());
+ DataSourceTextField bandField = new DataSourceTextField("formattedBaseband", MSG
+ .dataSource_measurementOob_field_formattedBaseband());
fields.add(bandField);
- DataSourceTextField outlierField = new DataSourceTextField("formattedOutlier", MSG.dataSource_measurementOob_field_formattedOutlier());
+ DataSourceTextField outlierField = new DataSourceTextField("formattedOutlier", MSG
+ .dataSource_measurementOob_field_formattedOutlier());
fields.add(outlierField);
- DataSourceTextField factorField = new DataSourceTextField("factor", MSG.dataSource_measurementOob_field_factor());
+ DataSourceTextField factorField = new DataSourceTextField("factor", MSG
+ .dataSource_measurementOob_field_factor());
fields.add(factorField);
return fields;
@@ -81,7 +88,7 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
PageControl pc = getPageControl(request);
@@ -101,6 +108,12 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
}
@Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
public MeasurementOOBComposite copyValues(Record from) {
throw new UnsupportedOperationException("OOBs Read only");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 756bc4a..ac4318a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -33,6 +33,7 @@ import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.util.PageList;
@@ -53,7 +54,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Simeon Pinder
* @author Jay Shaughnessy
*/
-public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceComposite> {
+public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceComposite, Criteria> {
public enum Field {
@@ -128,12 +129,18 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
return fields;
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
/** Fetch the ProblemResource data, and populate the response object appropriately.
*
* @param request incoming request
* @param response outgoing response
*/
- public void executeFetch(final DSRequest request, final DSResponse response) {
+ public void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
long ctime = -1;
int maxItems = -1;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index b87345e..3fa0171 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -23,8 +23,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -50,11 +48,9 @@ import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.hibernate.validator.RangeValidator;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
@@ -66,11 +62,14 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* Base GWT-RPC oriented DataSource class.
+ *
+ * The <T> type is the entity POJO type that represents a record retrieved by the data source
+ * The <C> type is the criteria type that is used to fetch data from the data source
*
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class RPCDataSource<T> extends DataSource {
+public abstract class RPCDataSource<T, C extends org.rhq.core.domain.criteria.Criteria> extends DataSource {
protected static final Messages MSG = CoreGUI.getMessages();
@@ -111,7 +110,16 @@ public abstract class RPCDataSource<T> extends DataSource {
switch (request.getOperationType()) {
case FETCH:
- executeFetch(request, response);
+ C criteria = getFetchCriteria(request);
+ if (criteria != null) {
+ // unsure if this is the right thing to do - we are always going to supply a PageControl, but reading
+ // the javadoc for setPageControl, it says this overrides addSortField, which is used by our criteria objects.
+ // I still think this is OK, but if you are reading this as part of debugging a problem, investigate this.
+ if (criteria.getPageControlOverrides() == null) {
+ criteria.setPageControl(getPageControl(request));
+ }
+ }
+ executeFetch(request, response, criteria);
break;
case ADD:
ListGridRecord newRecord = getDataObject(request);
@@ -302,7 +310,6 @@ public abstract class RPCDataSource<T> extends DataSource {
}
Set<T> results = new LinkedHashSet<T>(records.length);
- int i = 0;
for (Record record : records) {
results.add(copyValues(record));
}
@@ -341,6 +348,15 @@ public abstract class RPCDataSource<T> extends DataSource {
}
/**
+ * Given a request, this returns a criteria object that should be used to fetch data that the request
+ * is asking for. If a particular data source subclass does not use criteria, this can return <code>null</code>.
+ *
+ * @param request the request being made for data
+ * @return a criteria object that is to be used when fetching for the requested data, or <code>null</code> if not used
+ */
+ protected abstract C getFetchCriteria(final DSRequest request);
+
+ /**
* Extensions should implement this method to retrieve data. Paging solutions should use
* {@link #getPageControl(com.smartgwt.client.data.DSRequest)}. All implementations should call processResponse()
* whether they fail or succeed. Data should be set on the request via setData. Implementations can use
@@ -348,8 +364,9 @@ public abstract class RPCDataSource<T> extends DataSource {
*
* @param request
* @param response
+ * @param criteria can be used by the method to perform queries in order to fetch the required data
*/
- protected abstract void executeFetch(final DSRequest request, final DSResponse response);
+ protected abstract void executeFetch(final DSRequest request, final DSResponse response, final C criteria);
public abstract T copyValues(Record from);
@@ -509,8 +526,8 @@ public abstract class RPCDataSource<T> extends DataSource {
@SuppressWarnings("unchecked")
public static <S> S getFilter(DSRequest request, String paramName, Class<S> type) {
Criteria criteria = request.getCriteria();
- Map<String, Object> criteriaMap = (criteria != null) ? criteria.getValues() :
- Collections.<String, Object>emptyMap();
+ Map<String, Object> criteriaMap = (criteria != null) ? criteria.getValues() : Collections
+ .<String, Object> emptyMap();
S result = null;
commit d1c21307bc3239d442473ed23ed26c6c65d0fb9f
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 22 12:01:38 2011 -0400
i)fix portlets autogroup issue
ii)make empty measurements and operations display more consistent.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
index 4fa8807..cc14736 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
@@ -108,8 +108,9 @@ public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettin
//override the shared datasource
//figure out which page we're loading
String currentPage = History.getToken();
- String[] elements = currentPage.split("/");
- this.groupId = Integer.valueOf(elements[1]);
+ //get groupId
+ int groupId = AbstractActivityView.groupIdLookup(currentPage);
+ this.groupId = groupId;
setShowFilterForm(false); //disable filter form for portlet
setOverflow(Overflow.VISIBLE);
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 4f50f15..2c4fdc1 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
@@ -95,9 +95,8 @@ public class GroupBundleDeploymentsPortlet extends LocatableVLayout implements C
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;
+ int groupId = AbstractActivityView.groupIdLookup(currentPage);
+ this.groupId = groupId;
}
@Override
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 9978a6a..ec4dae7 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
@@ -96,9 +96,8 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
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;
+ int groupId = AbstractActivityView.groupIdLookup(currentPage);
+ this.groupId = groupId;
}
@Override
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 d0a4f84..5cf7b36 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
@@ -113,8 +113,8 @@ public class GroupMetricsPortlet extends LocatableVLayout 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;
+ int groupId = AbstractActivityView.groupIdLookup(currentPage);
+ this.groupId = groupId;
baseViewPath = elements[0];
}
@@ -438,6 +438,10 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
}
});
}
+ } else {
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), AbstractActivityView.RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
}
}
});
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 206be22..ed3fb42 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
@@ -90,9 +90,8 @@ public class GroupOobsPortlet extends LocatableVLayout implements CustomSettings
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;
+ int groupId = AbstractActivityView.groupIdLookup(currentPage);
+ this.groupId = groupId;
}
@Override
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 f2322b0..9c2be45 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
@@ -43,6 +43,7 @@ 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.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -116,10 +117,10 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
//figure out which page we're loading
String currentPage = History.getToken();
String[] elements = currentPage.split("/");
- int currentGroupIdentifier = Integer.valueOf(elements[1]);
- this.groupId = currentGroupIdentifier;
+ int groupId = AbstractActivityView.groupIdLookup(currentPage);
+ this.groupId = groupId;
//populate basepath
- baseViewPath = elements[0];
+ baseViewPath = AbstractActivityView.groupPathLookup(currentPage);
}
@Override
@@ -169,14 +170,22 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
groupOperations = new GroupOperationsCriteriaHistoryListView(locatorId,
new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite);
+ } else {
+ Criteria criteria = new Criteria();
+ ResourceGroup emptyGroup = new ResourceGroup("");
+ emptyGroup.setId(-1);
+ Long zero = new Long(0);
+ groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, emptyGroup);
+ groupOperations = new GroupOperationsCriteriaHistoryListView(locatorId,
+ new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite);
+ }
- //cleanup
- for (Canvas child : recentOperationsContent.getChildren()) {
- child.destroy();
- }
- recentOperationsContent.addChild(groupOperations);
- recentOperationsContent.markForRedraw();
+ //cleanup
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
}
+ recentOperationsContent.addChild(groupOperations);
+ recentOperationsContent.markForRedraw();
}
});
}
@@ -188,6 +197,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
setMembersMargin(5);
setHeight("*");
setWidth100();
+
//tell canvas to fill it's component
recentOperationsContent.setHeight100();
addMember(recentOperationsContent);
@@ -371,6 +381,12 @@ class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListVi
protected String getBasePath() {
return "ResourceGroup/" + composite.getResourceGroup().getId() + "/Operations/History";
}
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
}
/** Provide implementation of GroupOperationHistoryDataSource that dynamically
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 b7dbf69..30c21a7 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
@@ -93,9 +93,8 @@ public class GroupPkgHistoryPortlet extends LocatableVLayout implements CustomSe
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;
+ int groupId = AbstractActivityView.groupIdLookup(currentPage);
+ this.groupId = groupId;
}
@Override
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 2da6e15..82ac645 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
@@ -594,4 +594,39 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
return ((groupCategory == GroupCategory.MIXED) || (groupCategory == GroupCategory.COMPATIBLE && facets
.contains(ResourceTypeFacet.EVENT)));
}
+
+ /* Utility method to extract groupId from
+ *
+ */
+ public static int groupIdLookup(String currentPage) {
+ int groupId = -1;
+ if ((currentPage != null) && (!currentPage.trim().isEmpty())) {
+ String[] elements = currentPage.split("/");
+ //process for groups and auto groups Ex. ResourceGroup/10111 or ResourceGroup/AutoCluster/10321
+ try {
+ groupId = Integer.valueOf(elements[1]);
+ } catch (NumberFormatException nfe) {
+ groupId = Integer.valueOf(elements[2]);
+ }
+ }
+ return groupId;
+ }
+
+ /* Utility method to extract groupId from
+ *
+ */
+ public static String groupPathLookup(String currentPage) {
+ String groupBasePath = "";
+ if ((currentPage != null) && (!currentPage.trim().isEmpty())) {
+ String[] elements = currentPage.split("/");
+ //process for groups and auto groups Ex. ResourceGroup/10111 or ResourceGroup/AutoCluster/10321
+ try {
+ Integer.valueOf(elements[1]);
+ groupBasePath = elements[0];
+ } catch (NumberFormatException nfe) {
+ groupBasePath = elements[1] + "/" + elements[1];
+ }
+ }
+ return groupBasePath;
+ }
}
commit b6e71a4f58ac52de47215a0bd0595d4689b14836
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Mar 22 17:15:17 2011 +0100
BZ 689833 - be able to match the main server with snmp index even in the case of multiple listen addresses.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index a1365da..ee3e2ea 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -502,9 +502,9 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostAddressStrings.length);
if (vhostAddressStrings.length == 1 && MAIN_SERVER_RESOURCE_KEY.equals(vhostAddressStrings[0])) {
- HttpdAddressUtility.Address serverAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, null, 0);
- if (serverAddr != null) {
- vhostAddresses.add(serverAddr);
+ List<HttpdAddressUtility.Address> serverAddrs = parent.getAddressUtility().getAllMainServerAddresses(tree);
+ if (serverAddrs != null) {
+ vhostAddresses.addAll(serverAddrs);
}
} else {
for (int i = 0; i < vhostAddressStrings.length; ++i) {
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index 0710178..8ecdb7b 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -41,7 +41,8 @@ import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
public enum HttpdAddressUtility {
APACHE_1_3 {
- public Address getMainServerSampleAddress(ApacheDirectiveTree ag, String limitToHost, int limitToPort) {
+
+ public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag) {
try {
List<ApacheDirective> ports = ag.search("/Port");
List<ApacheDirective> bindAddresses = ag.search("/BindAddress");
@@ -50,7 +51,7 @@ public enum HttpdAddressUtility {
String port = "80"; //this is the default in apache 1.3
String bindAddress = null;
- List<Address> addressesToMatch = new ArrayList<Address>();
+ List<Address> addresses = new ArrayList<Address>();
if (ports.size() > 0) {
List<String>values = ports.get(0).getValues();
@@ -67,28 +68,24 @@ public enum HttpdAddressUtility {
//listen directives take precedence over port/bindaddress combo
if (listens.size() > 0) {
for(ApacheDirective l : listens) {
- addressesToMatch.add(parseListen(l.getValues().get(0)));
+ addresses.add(parseListen(l.getValues().get(0)));
}
} else {
- addressesToMatch.add(new Address(bindAddress, Integer.parseInt(port)));
+ addresses.add(new Address(bindAddress, Integer.parseInt(port)));
}
- for (Address address : addressesToMatch) {
- if (isAddressConforming(address, limitToHost, limitToPort, false)) {
- if (!address.isPortDefined() || address.isPortWildcard()) {
- address.port = 80;
- }
- if (address.host == null || address.isHostDefault() || address.isHostWildcard()) {
- address = getLocalhost(address.port);
- }
-
- updateWithServerName(address, ag);
-
- return address;
+ for (Address address : addresses) {
+ if (!address.isPortDefined() || address.isPortWildcard()) {
+ address.port = 80;
+ }
+ if (address.host == null || address.isHostDefault() || address.isHostWildcard()) {
+ address = getLocalhost(address.port);
}
+
+ updateWithServerName(address, ag);
}
- return null;
+ return addresses;
} catch (Exception e) {
log.warn("Failed to obtain main server address.", e);
@@ -97,23 +94,23 @@ public enum HttpdAddressUtility {
}
},
APACHE_2_x {
- public Address getMainServerSampleAddress(ApacheDirectiveTree ag, String limitToHost, int limitToPort) {
+
+ public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag) {
try {
+ List<Address> ret = new ArrayList<Address>();
+
for(ApacheDirective n : ag.search("/Listen")) {
Address addr = parseListen(n.getValues().get(0));
- if (isAddressConforming(addr, limitToHost, limitToPort, false)) {
- if (addr.host == null || addr.isHostDefault() || addr.isHostWildcard()) {
- addr = getLocalhost(addr.port);
- }
-
- updateWithServerName(addr, ag);
-
- return addr;
+ if (addr.host == null || addr.isHostDefault() || addr.isHostWildcard()) {
+ addr = getLocalhost(addr.port);
}
+
+ updateWithServerName(addr, ag);
+
+ ret.add(addr);
}
- //there has to be at least one Listen directive
- throw new IllegalStateException("Could find a listen address on port " + limitToPort);
+ return ret;
} catch (Exception e) {
log.warn("Failed to obtain main server address.", e);
@@ -283,6 +280,14 @@ public enum HttpdAddressUtility {
}
/**
+ * This returns all the addresses the server listens on.
+ *
+ * @param ag the tree of the httpd configuration
+ * @return the addresses or null on failure
+ */
+ public abstract List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag);
+
+ /**
* This just constructs a first available address under which the server or one of its virtual hosts can be reached.
*
* @param ag the tree of the httpd configuration
@@ -291,7 +296,21 @@ public enum HttpdAddressUtility {
* @param limitToPort if > 0, the sample address is looked for only for the given port
* @return the address or null on failure
*/
- public abstract Address getMainServerSampleAddress(ApacheDirectiveTree ag, String limitToHost, int limitToPort);
+ public Address getMainServerSampleAddress(ApacheDirectiveTree ag, String limitToHost, int limitToPort) {
+ List<Address> addressesToMatch = getAllMainServerAddresses(ag);
+
+ if (addressesToMatch == null) {
+ return null;
+ }
+
+ for (Address address : addressesToMatch) {
+ if (isAddressConforming(address, limitToHost, limitToPort, false)) {
+ return address;
+ }
+ }
+
+ return null;
+ }
/**
* This constructs an address on which given virtual host can be accessed.
commit 4d60c27b2b60efed1ca0f4d2a4881fa05fd7ceca
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 22 08:57:19 2011 -0400
i)removing D12N column from ResourceAlertsPortlet.
ii)added remaining asynch call to add bundledeployment portlet for groups.
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 4ef6e16..ddc343f 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
@@ -390,4 +390,12 @@ public class AlertDataSource extends RPCDataSource<Alert> {
public AlertGWTServiceAsync getAlertService() {
return alertService;
}
+
+ protected EntityContext getEntityContext() {
+ return entityContext;
+ }
+
+ protected void setEntityContext(EntityContext entityContext) {
+ this.entityContext = entityContext;
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
index 2c6621d..5396bc0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
@@ -75,6 +75,7 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource {
} else if ((resourceIds != null) && (resourceIds.length > 0)) {
entityContext = EntityContext.forResource(resourceIds[0]);
}
+ setEntityContext(entityContext);
}
/** Override the executeFetch for AlertPortlet to allow specifying smaller than total
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
index 7ff4f7d..dc74fb6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
@@ -34,11 +35,16 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.dashboard.Dashboard;
import org.rhq.core.domain.dashboard.DashboardCategory;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+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.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.InitializableView;
@@ -83,8 +89,13 @@ public class ActivityView extends LocatableVLayout implements DashboardContainer
private Set<Permission> globalPermissions;
private boolean editMode = false;
-
private boolean isInitialized = false;
+ //default portlet positioning parameters
+ private int colLeft = 0;
+ private int colRight = 1;
+ private int rowLeft = 0;
+ private int rowRight = 0;
+ private boolean displayLeft = false;
public ActivityView(String locatorId, ResourceGroupComposite groupComposite) {
super(locatorId);
@@ -177,9 +188,9 @@ public class ActivityView extends LocatableVLayout implements DashboardContainer
protected Dashboard getDefaultDashboard() {
Subject sessionSubject = UserSessionManager.getSessionSubject();
- ResourceGroup group = groupComposite.getResourceGroup();
+ final ResourceGroup group = groupComposite.getResourceGroup();
- Dashboard dashboard = new Dashboard();
+ final Dashboard dashboard = new Dashboard();
dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_" + group.getId());
dashboard.setCategory(DashboardCategory.GROUP);
@@ -196,12 +207,50 @@ public class ActivityView extends LocatableVLayout implements DashboardContainer
//remove BundleDeployment and add back later if relevant.
groupKeyNameMap.remove(GroupBundleDeploymentsPortlet.KEY);
groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap, groupComposite);
- //TODO: spinder 3/21/11 need asynch call to execute and then update the menu for bundle
- int colLeft = 0;
- int colRight = 1;
- int rowLeft = 0;
- int rowRight = 0;
+ //initiate asynch call to execute and then update the dashboard with bundle deployment portlet if necessary
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(group.getId());
+ criteria.fetchExplicitResources(true);
+ criteria.setPageControl(new PageControl(0, 1));
+ GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ @Override
+ public void onSuccess(PageList<ResourceGroup> results) {
+ if (!results.isEmpty()) {
+ ResourceGroup grp = results.get(0);
+ Set<Resource> explicitMembers = grp.getExplicitResources();
+ Resource[] currentResources = new Resource[explicitMembers.size()];
+ explicitMembers.toArray(currentResources);
+ Map<String, String> portletToAdd = new HashMap<String, String>();
+ //membership dynamically determined if all platforms then will be compatible.
+ if (group.getGroupCategory().equals(GroupCategory.COMPATIBLE)) {
+ if (currentResources[0].getResourceType().getCategory().equals(ResourceCategory.PLATFORM)) {
+ //this portlet allowed to add bundle portlet monitoring
+ portletToAdd.put(GroupBundleDeploymentsPortlet.KEY, GroupBundleDeploymentsPortlet.NAME);
+ }
+ if (!portletToAdd.isEmpty()) {
+ //update dashboard with that portlet and reload
+ updateDashboardWithPortlets(portletToAdd, dashboard, 100);
+ //request reload of dashboard widget
+ setDashboard(dashboard);
+ markForRedraw();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving information for group [" + group.getId() + "]:" + caught.getMessage());
+ }
+ });
+
+ //reset positioning parameters
+ colLeft = 0;
+ colRight = 1;
+ rowLeft = 0;
+ rowRight = 0;
//Left Column
if (groupKeyNameMap.containsKey(GroupMetricsPortlet.KEY)) {//measurments top left if available
DashboardPortlet measurements = new DashboardPortlet(GroupMetricsPortlet.NAME, GroupMetricsPortlet.KEY, 220);
@@ -222,22 +271,36 @@ public class ActivityView extends LocatableVLayout implements DashboardContainer
}
//Fill out left column(typically smaller portlets) then alternate cols with remaining
- boolean displayLeft = false;
- for (String key : groupKeyNameMap.keySet()) {
- DashboardPortlet portlet = new DashboardPortlet(groupKeyNameMap.get(key), key, 100);
- if (rowLeft < 4) {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- } else {//alternate
- if (!displayLeft) {
- dashboard.addPortlet(portlet, colRight, rowRight++);
- } else {
+ displayLeft = false;
+ updateDashboardWithPortlets(groupKeyNameMap, dashboard, 100);
+ return dashboard;
+ }
+
+ /**Iterates list of new portlets and updates the dashboard reference with these new portlets.
+ * Attempts to fill the spaces around the remaining larger portlets if already installed, then alternates
+ * adding to left and right columns. Assumes dashboard has only two columns.
+ *
+ * @param keyNameMap portlet key|name map
+ * @param dashboard dasboard instance to update
+ */
+ private void updateDashboardWithPortlets(Map<String, String> keyNameMap, Dashboard dashboard, int initialHeight) {
+ if ((keyNameMap != null) && (dashboard != null)) {
+ for (String key : keyNameMap.keySet()) {
+ //locate portlet and add to dashboard
+ DashboardPortlet portlet = new DashboardPortlet(keyNameMap.get(key), key, initialHeight);
+ if (rowLeft < 4) {
dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ }
+ //toggle
+ displayLeft = !displayLeft;
}
- //toggle
- displayLeft = !displayLeft;
}
}
- return dashboard;
}
@Override
commit e46e1bc770a08dc17173994af8fa5abc28e186c4
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 21 18:21:49 2011 -0400
time range refresh fixes.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
index 39f2f52..2c6621d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert;
+import java.util.ArrayList;
+
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -40,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
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.RecentAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
/** Customize the AlertDataSource to pull fetch criteria information from
* the Configuration object passed in.
@@ -116,15 +119,38 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource {
pc.setPrimarySortOrder(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);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- criteria.addFilterStartTime(Long.valueOf(range[0]));
- criteria.addFilterEndTime(Long.valueOf(range[1]));
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ 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]));
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
}
}
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 35d5886..9978a6a 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
@@ -105,7 +105,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
protected void onInit() {
super.onInit();
initializeUi();
- loadData();
+ redraw();
}
/**Defines layout for the portlet page.
@@ -178,7 +178,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
//persist
storedPortlet.setConfiguration(portletConfig);
configure(portletWindow, storedPortlet);
- loadData();
+ redraw();
customSettings.markForRedraw();
}
});
@@ -198,12 +198,33 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
//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);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- start = Long.valueOf(range[0]);
- end = Long.valueOf(range[1]);
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ 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]);
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer.valueOf(lastUnits));
+ start = Long.valueOf(beginEnd.get(0));
+ end = Long.valueOf(beginEnd.get(1));
+ }
}
}
@@ -287,7 +308,6 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
refreshTimer = new Timer() {
public void run() {
if (!currentlyLoading) {
- loadData();
redraw();
}
}
@@ -311,5 +331,4 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
super.redraw();
loadData();
}
-
}
\ No newline at end of file
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 80bf045..d0a4f84 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
@@ -219,12 +219,33 @@ public class GroupMetricsPortlet extends LocatableVLayout implements CustomSetti
//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);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- start = Long.valueOf(range[0]);
- end = Long.valueOf(range[1]);
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ 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]);
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer.valueOf(lastUnits));
+ start = Long.valueOf(beginEnd.get(0));
+ end = Long.valueOf(beginEnd.get(1));
+ }
}
}
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
index d915351..a2a2bda 100644
--- 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
@@ -40,6 +40,7 @@ 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.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**This portlet allows the end user to customize the Events display
@@ -102,16 +103,36 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
//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);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- start = Long.valueOf(range[0]);
- end = Long.valueOf(range[1]);
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ 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]);
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer.valueOf(lastUnits));
+ start = Long.valueOf(beginEnd.get(0));
+ end = Long.valueOf(beginEnd.get(1));
+ }
}
}
- // GWTServiceLookup.getEventService().getEventCountsBySeverityForGroup(resourceId, start, end,
GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId, start, end,
new AsyncCallback<Map<EventSeverity, Integer>>() {
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
index b7ed496..e907ce6 100644
--- 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
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
@@ -52,6 +53,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.Abs
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;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**This portlet allows the end user to customize the metric display
@@ -121,12 +123,33 @@ public class ResourceMetricsPortlet extends GroupMetricsPortlet {
//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);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- start = Long.valueOf(range[0]);
- end = Long.valueOf(range[1]);
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ 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]);
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer.valueOf(lastUnits));
+ start = Long.valueOf(beginEnd.get(0));
+ end = Long.valueOf(beginEnd.get(1));
+ }
}
}
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
index 6110d7e..41ce660 100644
--- 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
@@ -110,7 +110,6 @@ public class ResourcePkgHistoryPortlet extends GroupPkgHistoryPortlet {
}
PageControl pageControl = new PageControl(0, resultCount);
criteria.setPageControl(pageControl);
- // criteria.addFilterResourceGroupIds(resourceId);
criteria.addFilterResourceId(resourceId);
criteria.addSortStatus(PageOrdering.DESC);
commit 41b30a2488ec12255afacb9a293b99a7b2553df5
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 21 17:54:27 2011 -0400
Metric Graph Portlet Work
Fix issues with adding metric portlets from the resource and group
trees. In particular, add missing support for the group tree, and group
metric graphs in general.
- refactor and rename to use an AbstractMetricGraphView supporting resource
and resource group views and portlets.
- add relevant resource or group name info to the portlets so you can see
what it is the metric data actually comes from.
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 98220d7..fa76473 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
@@ -33,9 +33,10 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetr
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.groups.graph.ResourceGroupGraphPortlet;
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;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceGraphPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformSummaryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedResourcesPortlet;
@@ -71,8 +72,8 @@ public class PortletFactory {
private static HashMap<String, String> registeredPortletIconMap;
static {
- //############## Default Dashboard ############################
- //defines portlet factory mappings for landing page Dashboard
+ // ############# Global Dashboard ############################
+ // defines portlet factory mappings for global Dashboard
registeredPortletFactoryMap = new HashMap<String, PortletViewFactory>();
registeredPortletFactoryMap.put(InventorySummaryPortlet.KEY, InventorySummaryPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(RecentlyAddedResourcesPortlet.KEY,
@@ -80,7 +81,8 @@ public class PortletFactory {
registeredPortletFactoryMap.put(PlatformSummaryPortlet.KEY, PlatformSummaryPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(AutodiscoveryPortlet.KEY, AutodiscoveryPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(RecentAlertsPortlet.KEY, RecentAlertsPortlet.Factory.INSTANCE);
- registeredPortletFactoryMap.put(GraphPortlet.KEY, GraphPortlet.Factory.INSTANCE);
+ registeredPortletFactoryMap.put(ResourceGraphPortlet.KEY, ResourceGraphPortlet.Factory.INSTANCE);
+ registeredPortletFactoryMap.put(ResourceGroupGraphPortlet.KEY, ResourceGroupGraphPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(TagCloudPortlet.KEY, TagCloudPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(FavoriteResourcesPortlet.KEY, FavoriteResourcesPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(MashupPortlet.KEY, MashupPortlet.Factory.INSTANCE);
@@ -88,14 +90,15 @@ public class PortletFactory {
registeredPortletFactoryMap.put(ProblemResourcesPortlet.KEY, ProblemResourcesPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(OperationsPortlet.KEY, OperationsPortlet.Factory.INSTANCE);
- //defines portlet name mappings for landing page Dashboard
+ // defines portlet name mappings for global Dashboard
registeredPortletNameMap = new HashMap<String, String>(registeredPortletFactoryMap.size());
registeredPortletNameMap.put(InventorySummaryPortlet.KEY, InventorySummaryPortlet.NAME);
registeredPortletNameMap.put(RecentlyAddedResourcesPortlet.KEY, RecentlyAddedResourcesPortlet.NAME);
registeredPortletNameMap.put(PlatformSummaryPortlet.KEY, PlatformSummaryPortlet.NAME);
registeredPortletNameMap.put(AutodiscoveryPortlet.KEY, AutodiscoveryPortlet.NAME);
registeredPortletNameMap.put(RecentAlertsPortlet.KEY, RecentAlertsPortlet.NAME);
- registeredPortletNameMap.put(GraphPortlet.KEY, GraphPortlet.NAME);
+ registeredPortletNameMap.put(ResourceGraphPortlet.KEY, ResourceGraphPortlet.NAME);
+ registeredPortletNameMap.put(ResourceGroupGraphPortlet.KEY, ResourceGroupGraphPortlet.NAME);
registeredPortletNameMap.put(TagCloudPortlet.KEY, TagCloudPortlet.NAME);
registeredPortletNameMap.put(FavoriteResourcesPortlet.KEY, FavoriteResourcesPortlet.NAME);
registeredPortletNameMap.put(MashupPortlet.KEY, MashupPortlet.NAME);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
new file mode 100644
index 0000000..9ac2534
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
@@ -0,0 +1,201 @@
+/*
+ * 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.inventory.groups.graph;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.TitleOrientation;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.enterprise.gui.coregui.client.components.selector.AssignedItemsChangedEvent;
+import org.rhq.enterprise.gui.coregui.client.components.selector.AssignedItemsChangedHandler;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.ResourceGroupMetricGraphView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.SingleResourceGroupSelector;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+public class ResourceGroupGraphPortlet extends ResourceGroupMetricGraphView implements CustomSettingsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceGroupMetric";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_groupMetric();
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ public static final String CFG_RESOURCE_GROUP_ID = "resourceGroupId";
+ public static final String CFG_DEFINITION_ID = "definitionId";
+
+ public ResourceGroupGraphPortlet(String locatorId) {
+ super(locatorId);
+ setOverflow(Overflow.HIDDEN);
+ }
+
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID) != null) {
+ setEntityId(storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID).getIntegerValue());
+ setDefinitionId(storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID).getIntegerValue());
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_graph());
+ }
+
+ @Override
+ protected void onDraw() {
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID) != null) {
+ super.onDraw();
+ } else {
+ removeMembers(getMembers());
+ addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>"));
+ }
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("Config"));
+ form.setWidth(750);
+ form.setNumCols(1);
+
+ final CanvasItem selectorItem = new CanvasItem();
+ selectorItem.setTitleOrientation(TitleOrientation.TOP);
+ selectorItem.setShowTitle(false);
+
+ final SingleResourceGroupSelector resourceGroupSelector = new SingleResourceGroupSelector(form
+ .extendLocatorId("Selector"), GroupCategory.COMPATIBLE, false);
+ resourceGroupSelector.setWidth(700);
+ resourceGroupSelector.setHeight(300);
+ //TODO, would probaby be nice to find a way to seed assigned with the current group
+ //ListGridRecord rec = new ListGridRecord();
+ //rec.setAttribute("id", getEntityId());
+ //rec.setAttribute("name", "current");
+ //resourceGroupSelector.setAssigned(new ListGridRecord[] { rec });
+
+ final SelectItem metric = new SelectItem(CFG_DEFINITION_ID, MSG.common_title_metric()) {
+ @Override
+ protected Criteria getPickListFilterCriteria() {
+ Criteria criteria = new Criteria();
+
+ if (resourceGroupSelector.getSelectedItems().size() == 1) {
+ int groupId = resourceGroupSelector.getSelectedItems().iterator().next().getId();
+ criteria.addCriteria(CFG_RESOURCE_GROUP_ID, groupId);
+ form.setValue(CFG_RESOURCE_GROUP_ID, groupId);
+ }
+ return criteria;
+ }
+ };
+ metric.setWidth(300);
+ metric.setTitleOrientation(TitleOrientation.TOP);
+ metric.setValueField("id");
+ metric.setDisplayField("displayName");
+ metric.setOptionDataSource(new ResourceScheduledMetricDatasource());
+
+ resourceGroupSelector.addAssignedItemsChangedHandler(new AssignedItemsChangedHandler() {
+
+ public void onSelectionChanged(AssignedItemsChangedEvent event) {
+
+ if (resourceGroupSelector.getSelectedItems().size() == 1) {
+ metric.fetchData();
+ form.clearValue(CFG_DEFINITION_ID);
+ }
+ }
+ });
+
+ final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID) != null) {
+ form.setValue(CFG_RESOURCE_GROUP_ID, storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID)
+ .getIntegerValue());
+ form.setValue(CFG_DEFINITION_ID, storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID)
+ .getIntegerValue());
+ }
+
+ selectorItem.setCanvas(resourceGroupSelector);
+ form.setFields(selectorItem, metric, new SpacerItem());
+
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(CFG_RESOURCE_GROUP_ID, form.getValue(CFG_RESOURCE_GROUP_ID)));
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(CFG_DEFINITION_ID, form.getValue(CFG_DEFINITION_ID)));
+
+ configure(portletWindow, storedPortlet);
+
+ redraw();
+ }
+ });
+
+ return form;
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+
+ removeMembers(getMembers());
+
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID) != null) {
+ renderGraph();
+ } else {
+ addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>"));
+ }
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new ResourceGroupGraphPortlet(locatorId);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java
deleted file mode 100644
index 821fe56..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph;
-
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
-import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
-
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.enterprise.gui.coregui.client.components.lookup.ResourceLookupComboBoxItem;
-import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.SmallGraphView;
-
-/**
- * @author Greg Hinkle
- */
-public class GraphPortlet extends SmallGraphView implements CustomSettingsPortlet {
-
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "Graph";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_graph();
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
-
- public static final String CFG_RESOURCE_ID = "resourceId";
- public static final String CFG_DEFINITION_ID = "definitionId";
- public static final String CFG_RESOURCE_GROUP_ID = "resourceGroupId";
-
- public GraphPortlet(String locatorId) {
- super(locatorId);
- setOverflow(Overflow.HIDDEN);
- }
-
- public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
-
- if (null == this.portletWindow && null != portletWindow) {
- this.portletWindow = portletWindow;
- }
-
- if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
- return;
- }
-
- if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
- setResourceId(storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue());
- setDefinitionId(storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID).getIntegerValue());
- }
- }
-
- public Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_graph());
- }
-
- @Override
- protected void onDraw() {
- DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
-
- if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
- super.onDraw();
- } else {
- removeMembers(getMembers());
- addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>"));
- }
- }
-
- public DynamicForm getCustomSettingsForm() {
- final DynamicForm form = new DynamicForm();
-
- final ResourceLookupComboBoxItem resourceLookupComboBoxItem = new ResourceLookupComboBoxItem(CFG_RESOURCE_ID,
- MSG.common_title_resource());
- resourceLookupComboBoxItem.setWidth(300);
-
- final SelectItem metric = new SelectItem(CFG_DEFINITION_ID, MSG.common_title_metric()) {
- @Override
- protected Criteria getPickListFilterCriteria() {
- Criteria criteria = new Criteria();
-
- if (resourceLookupComboBoxItem.getValue() != null) {
- int resourceId = (Integer) resourceLookupComboBoxItem.getValue();
- criteria.addCriteria(CFG_RESOURCE_ID, resourceId);
- }
- return criteria;
- }
- };
-
- final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
-
- metric.setWidth(300);
- metric.setValueField("id");
- metric.setDisplayField("displayName");
- metric.setOptionDataSource(new ResourceScheduledMetricDatasource());
-
- resourceLookupComboBoxItem
- .addChangedHandler(new com.smartgwt.client.widgets.form.fields.events.ChangedHandler() {
- public void onChanged(ChangedEvent event) {
-
- if (form.getValue(CFG_RESOURCE_ID) instanceof Integer) {
- metric.fetchData();
- form.clearValue("defininitionId");
- }
- }
- });
-
- if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
- form.setValue(CFG_RESOURCE_ID, storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID)
- .getIntegerValue());
- form.setValue(CFG_DEFINITION_ID, storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID)
- .getIntegerValue());
- }
-
- form.setFields(resourceLookupComboBoxItem, metric);
-
- form.addSubmitValuesHandler(new SubmitValuesHandler() {
- public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
- storedPortlet.getConfiguration().put(
- new PropertySimple(CFG_RESOURCE_ID, form.getValue(CFG_RESOURCE_ID)));
- storedPortlet.getConfiguration().put(
- new PropertySimple(CFG_DEFINITION_ID, form.getValue(CFG_DEFINITION_ID)));
-
- configure(portletWindow, storedPortlet);
-
- redraw();
- }
- });
-
- return form;
- }
-
- @Override
- public void redraw() {
- super.redraw();
-
- removeMembers(getMembers());
-
- DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
- if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
- renderGraph();
- } else {
- addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>"));
- }
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
-
- public final Portlet getInstance(String locatorId) {
-
- return new GraphPortlet(locatorId);
- }
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
new file mode 100644
index 0000000..820cf4f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
@@ -0,0 +1,181 @@
+/*
+ * 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.inventory.resource.graph;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.components.lookup.ResourceLookupComboBoxItem;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricGraphView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+public class ResourceGraphPortlet extends ResourceMetricGraphView implements CustomSettingsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceMetric";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_resourceMetric();
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ public static final String CFG_RESOURCE_ID = "resourceId";
+ public static final String CFG_DEFINITION_ID = "definitionId";
+
+ public ResourceGraphPortlet(String locatorId) {
+ super(locatorId);
+ setOverflow(Overflow.HIDDEN);
+ }
+
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
+ setEntityId(storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue());
+ setDefinitionId(storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID).getIntegerValue());
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_graph());
+ }
+
+ @Override
+ protected void onDraw() {
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
+ super.onDraw();
+ } else {
+ removeMembers(getMembers());
+ addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>"));
+ }
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ final DynamicForm form = new DynamicForm();
+
+ final ResourceLookupComboBoxItem resourceLookupComboBoxItem = new ResourceLookupComboBoxItem(CFG_RESOURCE_ID,
+ MSG.common_title_resource());
+ resourceLookupComboBoxItem.setWidth(300);
+
+ final SelectItem metric = new SelectItem(CFG_DEFINITION_ID, MSG.common_title_metric()) {
+ @Override
+ protected Criteria getPickListFilterCriteria() {
+ Criteria criteria = new Criteria();
+
+ if (resourceLookupComboBoxItem.getValue() != null) {
+ int resourceId = (Integer) resourceLookupComboBoxItem.getValue();
+ criteria.addCriteria(CFG_RESOURCE_ID, resourceId);
+ }
+ return criteria;
+ }
+ };
+
+ final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ metric.setWidth(300);
+ metric.setValueField("id");
+ metric.setDisplayField("displayName");
+ metric.setOptionDataSource(new ResourceScheduledMetricDatasource());
+
+ resourceLookupComboBoxItem
+ .addChangedHandler(new com.smartgwt.client.widgets.form.fields.events.ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+
+ if (form.getValue(CFG_RESOURCE_ID) instanceof Integer) {
+ metric.fetchData();
+ form.clearValue(CFG_DEFINITION_ID);
+ }
+ }
+ });
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
+ form.setValue(CFG_RESOURCE_ID, storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID)
+ .getIntegerValue());
+ form.setValue(CFG_DEFINITION_ID, storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID)
+ .getIntegerValue());
+ }
+
+ form.setFields(resourceLookupComboBoxItem, metric);
+
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(CFG_RESOURCE_ID, form.getValue(CFG_RESOURCE_ID)));
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(CFG_DEFINITION_ID, form.getValue(CFG_DEFINITION_ID)));
+
+ configure(portletWindow, storedPortlet);
+
+ redraw();
+ }
+ });
+
+ return form;
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+
+ removeMembers(getMembers());
+
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
+ renderGraph();
+ } else {
+ addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>"));
+ }
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new ResourceGraphPortlet(locatorId);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
new file mode 100644
index 0000000..6c9b167
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
@@ -0,0 +1,351 @@
+/*
+ * 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.inventory.common;
+
+import java.util.Date;
+import java.util.List;
+
+import ca.nanometrics.gflot.client.Axis;
+import ca.nanometrics.gflot.client.DataPoint;
+import ca.nanometrics.gflot.client.PlotItem;
+import ca.nanometrics.gflot.client.PlotModel;
+import ca.nanometrics.gflot.client.PlotPosition;
+import ca.nanometrics.gflot.client.SeriesHandler;
+import ca.nanometrics.gflot.client.SimplePlot;
+import ca.nanometrics.gflot.client.event.PlotHoverListener;
+import ca.nanometrics.gflot.client.jsni.Plot;
+import ca.nanometrics.gflot.client.options.AxisOptions;
+import ca.nanometrics.gflot.client.options.GridOptions;
+import ca.nanometrics.gflot.client.options.LineSeriesOptions;
+import ca.nanometrics.gflot.client.options.PlotOptions;
+import ca.nanometrics.gflot.client.options.PointsSeriesOptions;
+import ca.nanometrics.gflot.client.options.TickFormatter;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.smartgwt.client.types.AnimationEffect;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.events.MouseOutEvent;
+import com.smartgwt.client.widgets.events.MouseOutHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWidgetCanvas;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+public abstract class AbstractMetricGraphView extends LocatableVLayout {
+
+ private static final String INSTRUCTIONS = MSG.view_resource_monitor_graph_instructions();
+
+ /*
+ private static final String[] MONTH_NAMES = { MSG.common_calendar_january_short(),
+ MSG.common_calendar_february_short(), MSG.common_calendar_march_short(), MSG.common_calendar_april_short(),
+ MSG.common_calendar_may_short(), MSG.common_calendar_june_short(), MSG.common_calendar_july_short(),
+ MSG.common_calendar_august_short(), MSG.common_calendar_september_short(), MSG.common_calendar_october_short(),
+ MSG.common_calendar_november_short(), MSG.common_calendar_december_short() };
+ */
+
+ private final Label selectedPointLabel = new Label(INSTRUCTIONS);
+ private final Label positionLabel = new Label();
+ private final Label hoverLabel = new Label();
+
+ private int entityId;
+ private int definitionId;
+
+ private MeasurementDefinition definition;
+ private List<MeasurementDataNumericHighLowComposite> data;
+
+ public AbstractMetricGraphView(String locatorId) {
+ super(locatorId);
+ }
+
+ public AbstractMetricGraphView(String locatorId, int entityId, int definitionId) {
+ this(locatorId);
+
+ this.entityId = entityId;
+ this.definitionId = definitionId;
+ }
+
+ public AbstractMetricGraphView(String locatorId, int entityId, MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+ this(locatorId);
+
+ this.entityId = entityId;
+ this.definition = def;
+ this.data = data;
+ setHeight100();
+ setWidth100();
+ }
+
+ public abstract AbstractMetricGraphView getInstance(String locatorId, int entityId, MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data);
+
+ protected abstract void renderGraph();
+
+ protected abstract HTMLFlow getEntityTitle();
+
+ public int getEntityId() {
+ return this.entityId;
+ }
+
+ public void setEntityId(int entityId) {
+ this.entityId = entityId;
+ this.definition = null;
+ }
+
+ public int getDefinitionId() {
+ return definitionId;
+ }
+
+ public void setDefinitionId(int definitionId) {
+ this.definitionId = definitionId;
+ this.definition = null;
+ }
+
+ public MeasurementDefinition getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(MeasurementDefinition definition) {
+ this.definition = definition;
+ }
+
+ public List<MeasurementDataNumericHighLowComposite> getData() {
+ return data;
+ }
+
+ public void setData(List<MeasurementDataNumericHighLowComposite> data) {
+ this.data = data;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ removeMembers(getMembers());
+ renderGraph();
+ }
+
+ @Override
+ public void parentResized() {
+ super.parentResized();
+ removeMembers(getMembers());
+ renderGraph();
+ }
+
+ protected void drawGraph() {
+
+ HLayout titleHLayout = new LocatableHLayout(extendLocatorId("HTitle"));
+
+ if (definition != null) {
+ titleHLayout.setAutoHeight();
+ titleHLayout.setWidth100();
+
+ HTMLFlow entityTitle = getEntityTitle();
+ if (null != entityTitle) {
+ entityTitle.setWidth("*");
+ titleHLayout.addMember(entityTitle);
+ }
+
+ if (supportsLiveGraphViewDialog()) {
+ Img liveGraph = new LocatableImg(extendLocatorId("Live"), "subsystems/monitor/Monitor_16.png", 16, 16);
+ liveGraph.setTooltip(MSG.view_resource_monitor_graph_live_tooltip());
+
+ liveGraph.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ displayLiveGraphViewDialog();
+ }
+ });
+ titleHLayout.addMember(liveGraph);
+ }
+
+ addMember(titleHLayout);
+
+ HTMLFlow title = new HTMLFlow("<b>" + definition.getDisplayName() + "</b> " + definition.getDescription());
+ title.setWidth100();
+ title.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ displayAsDialog(extendLocatorId("Dialog"));
+ }
+ });
+ addMember(title);
+ }
+
+ PlotModel model = new PlotModel();
+ PlotOptions plotOptions = new PlotOptions();
+ plotOptions.setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setShow(true));
+ plotOptions.setDefaultPointsOptions(new PointsSeriesOptions().setRadius(2).setShow(true));
+ plotOptions.setDefaultShadowSize(0);
+
+ // You need make the grid hoverable <<<<<<<<<
+ plotOptions
+ .setGridOptions(new GridOptions().setHoverable(true).setMouseActiveRadius(10).setAutoHighlight(true));
+
+ // create a series
+ if (definition != null && data != null) {
+ loadData(model, plotOptions);
+ }
+
+ // create the plot
+ SimplePlot plot = new SimplePlot(model, plotOptions);
+ plot.setSize(String.valueOf(getInnerContentWidth()), String.valueOf(getInnerContentHeight()
+ - titleHLayout.getHeight() - 50));
+ // "80%","80%");
+
+ // add hover listener
+ plot.addHoverListener(new PlotHoverListener() {
+ public void onPlotHover(Plot plot, PlotPosition position, PlotItem item) {
+ if (position != null) {
+ positionLabel.setContents("position: (" + position.getX() + "," + position.getY() + ")");
+ }
+ if (item != null) {
+ hoverLabel.setContents(getHover(item));
+
+ hoverLabel.animateShow(AnimationEffect.FADE);
+ if (hoverLabel.getLeft() > 0 || hoverLabel.getTop() > 0) {
+ hoverLabel.animateMove(item.getPageX() + 10, item.getPageY() - 35);
+ } else {
+ hoverLabel.moveTo(item.getPageX() + 10, item.getPageY() - 35);
+ }
+ hoverLabel.redraw();
+
+ selectedPointLabel.setContents("x: " + item.getDataPoint().getX() + ", y: "
+ + item.getDataPoint().getY());
+ } else {
+ hoverLabel.animateHide(AnimationEffect.FADE);
+ selectedPointLabel.setContents(INSTRUCTIONS);
+ }
+ }
+ }, false);
+
+ addMouseOutHandler(new MouseOutHandler() {
+ public void onMouseOut(MouseOutEvent mouseOutEvent) {
+ hoverLabel.animateHide(AnimationEffect.FADE);
+ }
+ });
+
+ hoverLabel.setOpacity(80);
+ hoverLabel.setWrap(false);
+ hoverLabel.setHeight(25);
+ hoverLabel.setBackgroundColor("yellow");
+ hoverLabel.setBorder("1px solid orange");
+ hoverLabel.hide();
+
+ if (hoverLabel.isDrawn())
+ hoverLabel.redraw();
+ else
+ hoverLabel.draw();
+
+ // put it on a panel
+
+ addMember(new LocatableWidgetCanvas(extendLocatorId("Plot"), plot));
+
+ plot.setSize(String.valueOf(getInnerContentWidth()), String.valueOf(getInnerContentHeight()
+ - titleHLayout.getHeight() - 50));
+
+ }
+
+ protected boolean supportsLiveGraphViewDialog() {
+ return false;
+ }
+
+ protected void displayLiveGraphViewDialog() {
+ return;
+ }
+
+ @Override
+ public void destroy() {
+ hoverLabel.destroy();
+ super.destroy();
+ }
+
+ @Override
+ public void hide() {
+ super.hide();
+ hoverLabel.hide();
+ }
+
+ protected String getHover(PlotItem item) {
+ if (definition != null) {
+ com.google.gwt.i18n.client.DateTimeFormat df = DateTimeFormat.getMediumDateTimeFormat();
+ return definition.getDisplayName() + ": "
+ + MeasurementConverterClient.format(item.getDataPoint().getY(), definition.getUnits(), true) + "<br/>"
+ + df.format(new Date((long) item.getDataPoint().getX()));
+ } else {
+ return "x: " + item.getDataPoint().getX() + ", y: " + item.getDataPoint().getY();
+ }
+ }
+
+ protected void loadData(PlotModel model, PlotOptions plotOptions) {
+ SeriesHandler handler = model.addSeries(definition.getDisplayName(), "#007f00");
+
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ handler.add(new DataPoint(d.getTimestamp(), d.getValue()));
+ }
+
+ plotOptions.setYAxisOptions(new AxisOptions().setTicks(5).setLabelWidth(70).setTickFormatter(
+ new TickFormatter() {
+ public String formatTickValue(double v, Axis axis) {
+ return MeasurementConverterClient.format(v, definition.getUnits(), true);
+ }
+ }));
+
+ long max = System.currentTimeMillis();
+ long min = max - (1000L * 60 * 60 * 8);
+
+ int xTicks = getWidth() / 140;
+
+ plotOptions.setXAxisOptions(new AxisOptions().setTicks(xTicks).setMinimum(min).setMaximum(max)
+ .setTickFormatter(new TickFormatter() {
+ public String formatTickValue(double tickValue, Axis axis) {
+ com.google.gwt.i18n.client.DateTimeFormat dateFormat = DateTimeFormat.getShortDateTimeFormat();
+ return dateFormat.format(new Date((long) tickValue));
+ // return String.valueOf(new Date((long) tickValue));
+ // return MONTH_NAMES[(int) (tickValue - 1)];
+ }
+ }));
+
+ }
+
+ private void displayAsDialog(String locatorId) {
+ AbstractMetricGraphView graph = getInstance(locatorId, entityId, definition, data);
+ Window graphPopup = new Window();
+ graphPopup.setTitle(MSG.view_resource_monitor_detailed_graph_label());
+ graphPopup.setWidth(800);
+ graphPopup.setHeight(400);
+ graphPopup.setIsModal(true);
+ graphPopup.setShowModalMask(true);
+ graphPopup.setCanDragResize(true);
+ graphPopup.centerInPage();
+ graphPopup.addItem(graph);
+ graphPopup.show();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
index 65d4c88..43b3700 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
@@ -44,7 +44,7 @@ import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.groups.graph.ResourceGroupGraphPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -291,12 +291,16 @@ public class ResourceGroupContextMenu extends LocatableMenu {
addToDBItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent menuItemClickEvent) {
- DashboardPortlet p = new DashboardPortlet(def.getDisplayName() + " "
- + MSG.view_tree_common_contextMenu_chart(), GraphPortlet.KEY, 250);
+ DashboardPortlet p = new DashboardPortlet(MSG
+ .view_tree_common_contextMenu_groupGraph(), ResourceGroupGraphPortlet.KEY,
+ 250);
p.getConfiguration().put(
- new PropertySimple(GraphPortlet.CFG_RESOURCE_GROUP_ID, group.getId()));
- p.getConfiguration().put(
- new PropertySimple(GraphPortlet.CFG_DEFINITION_ID, def.getId()));
+ new PropertySimple(ResourceGroupGraphPortlet.CFG_RESOURCE_GROUP_ID, group
+ .getId()));
+ p.getConfiguration()
+ .put(
+ new PropertySimple(ResourceGroupGraphPortlet.CFG_DEFINITION_ID, def
+ .getId()));
d.addPortlet(p);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
new file mode 100644
index 0000000..61a30ce
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
@@ -0,0 +1,134 @@
+/*
+ * 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.inventory.groups.detail.monitoring;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.HTMLFlow;
+
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+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.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMetricGraphView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+public class ResourceGroupMetricGraphView extends AbstractMetricGraphView {
+
+ private HTMLFlow resourceGroupTitle;
+
+ public ResourceGroupMetricGraphView(String locatorId) {
+ super(locatorId);
+ }
+
+ public ResourceGroupMetricGraphView(String locatorId, int groupId, int definitionId) {
+ super(locatorId, groupId, definitionId);
+ }
+
+ public ResourceGroupMetricGraphView(String locatorId, int groupId, MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+
+ super(locatorId, groupId, def, data);
+ }
+
+ protected HTMLFlow getEntityTitle() {
+ return resourceGroupTitle;
+ }
+
+ protected void renderGraph() {
+ if (null == getDefinition()) {
+
+ ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
+
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(getEntityId());
+ criteria.fetchResourceType(true);
+ groupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught);
+ }
+
+ public void onSuccess(PageList<ResourceGroup> result) {
+ if (result.isEmpty()) {
+ return;
+ }
+
+ final ResourceGroup group = result.get(0);
+ String url = LinkManager.getResourceGroupLink(group.getId());
+ resourceGroupTitle = new HTMLFlow(SeleniumUtility.getLocatableHref(url, group.getName(), null));
+
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(group.getResourceType().getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(final ResourceType type) {
+
+ for (MeasurementDefinition def : type.getMetricDefinitions()) {
+ if (def.getId() == getDefinitionId()) {
+ setDefinition(def);
+
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(
+ getEntityId(), new int[] { getDefinitionId() },
+ System.currentTimeMillis() - (1000L * 60 * 60 * 8),
+ System.currentTimeMillis(), 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_resource_monitor_graphs_loadFailed(), caught);
+ }
+
+ public void onSuccess(
+ List<List<MeasurementDataNumericHighLowComposite>> result) {
+ setData(result.get(0));
+
+ drawGraph();
+ }
+ });
+ }
+ }
+ }
+ });
+ }
+ });
+
+ } else {
+
+ drawGraph();
+ }
+ }
+
+ @Override
+ public AbstractMetricGraphView getInstance(String locatorId, int entityId, MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+
+ return new ResourceGroupMetricGraphView(locatorId, entityId, def, data);
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index cf34caf..9870a42 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -71,7 +71,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceGraphPortlet;
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.gwt.ResourceGroupGWTServiceAsync;
@@ -421,8 +421,9 @@ public class ResourceTreeView extends LocatableVLayout {
MenuItem operationItem = new MenuItem(operationDefinition.getDisplayName());
operationItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(), ResourceDetailView.Tab.OPERATIONS,
- ResourceDetailView.OperationsSubTab.SCHEDULES) + "/0/" + operationDefinition.getId());
+ CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(),
+ ResourceDetailView.Tab.OPERATIONS, ResourceDetailView.OperationsSubTab.SCHEDULES)
+ + "/0/" + operationDefinition.getId());
}
});
opSubMenu.addItem(operationItem);
@@ -547,12 +548,12 @@ public class ResourceTreeView extends LocatableVLayout {
addToDBItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent menuItemClickEvent) {
- DashboardPortlet p = new DashboardPortlet(def.getDisplayName() + " Chart",
- GraphPortlet.KEY, 250);
+ DashboardPortlet p = new DashboardPortlet(MSG
+ .view_tree_common_contextMenu_resourceGraph(), ResourceGraphPortlet.KEY, 250);
p.getConfiguration().put(
- new PropertySimple(GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
+ new PropertySimple(ResourceGraphPortlet.CFG_RESOURCE_ID, resource.getId()));
p.getConfiguration().put(
- new PropertySimple(GraphPortlet.CFG_DEFINITION_ID, def.getId()));
+ new PropertySimple(ResourceGraphPortlet.CFG_DEFINITION_ID, def.getId()));
d.addPortlet(p);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
index dcd89d0..11ed7a5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
@@ -127,7 +127,7 @@ public class GraphListView extends LocatableVLayout implements ResourceSelectLis
}
private void buildGraph(MeasurementDefinition def, List<MeasurementDataNumericHighLowComposite> data) {
- SmallGraphView graph = new SmallGraphView(extendLocatorId(def.getName()), resource.getId(), def, data);
+ ResourceMetricGraphView graph = new ResourceMetricGraphView(extendLocatorId(def.getName()), resource.getId(), def, data);
graph.setWidth("95%");
graph.setHeight(220);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
new file mode 100644
index 0000000..d051b92
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
@@ -0,0 +1,156 @@
+/*
+ * 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.inventory.resource.detail.monitoring;
+
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.HTMLFlow;
+
+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.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+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.common.AbstractMetricGraphView;
+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.selenium.SeleniumUtility;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+public class ResourceMetricGraphView extends AbstractMetricGraphView {
+
+ private HTMLFlow resourceTitle;
+
+ public ResourceMetricGraphView(String locatorId) {
+ super(locatorId);
+ }
+
+ public ResourceMetricGraphView(String locatorId, int resourceId, int definitionId) {
+ super(locatorId, resourceId, definitionId);
+ }
+
+ public ResourceMetricGraphView(String locatorId, int resourceId, MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+
+ super(locatorId, resourceId, def, data);
+ }
+
+ protected HTMLFlow getEntityTitle() {
+ return resourceTitle;
+ }
+
+ protected void renderGraph() {
+ if (null == getDefinition()) {
+
+ ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ ResourceCriteria resourceCriteria = new ResourceCriteria();
+ resourceCriteria.addFilterId(getEntityId());
+ resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught);
+ }
+
+ public void onSuccess(PageList<Resource> result) {
+ if (result.isEmpty()) {
+ return;
+ }
+
+ final Resource resource = result.get(0);
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ typesSet.add(resource.getResourceType().getId());
+ HashSet<String> ancestries = new HashSet<String>();
+ 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.Cache.getInstance().getResourceTypes(
+ typesSet.toArray(new Integer[typesSet.size()]),
+ EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypesLoadedCallback() {
+
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ String url = LinkManager.getResourceLink(resource.getId());
+ resourceTitle = new HTMLFlow(SeleniumUtility.getLocatableHref(url, resource.getName(),
+ null));
+ resourceTitle.setTooltip(AncestryUtil.getAncestryHoverHTMLForResource(resource, types,
+ 0));
+
+ ResourceType type = types.get(resource.getResourceType().getId());
+ for (MeasurementDefinition def : type.getMetricDefinitions()) {
+ if (def.getId() == getDefinitionId()) {
+ setDefinition(def);
+
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(getEntityId(),
+ new int[] { getDefinitionId() },
+ System.currentTimeMillis() - (1000L * 60 * 60 * 8),
+ System.currentTimeMillis(), 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_resource_monitor_graphs_loadFailed(), caught);
+ }
+
+ public void onSuccess(
+ List<List<MeasurementDataNumericHighLowComposite>> result) {
+ setData(result.get(0));
+
+ drawGraph();
+ }
+ });
+ }
+ }
+ }
+ });
+ }
+ });
+
+ } else {
+
+ drawGraph();
+ }
+ }
+
+ protected boolean supportsLiveGraphViewDialog() {
+ return true;
+ }
+
+ protected void displayLiveGraphViewDialog() {
+ LiveGraphView.displayAsDialog(getLocatorId(), getEntityId(), getDefinition());
+ }
+
+ @Override
+ public AbstractMetricGraphView getInstance(String locatorId, int entityId, MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+
+ return new ResourceMetricGraphView(locatorId, entityId, def, data);
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
index b255539..f2a92ce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
@@ -118,6 +118,25 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
processResponse(request.getRequestId(), response);
}
});
+
+ } else if (request.getCriteria().getValues().containsKey("resourceGroupId")) {
+ MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
+ criteria.fetchDefinition(true);
+
+ criteria.addFilterResourceGroupId(request.getCriteria().getAttributeAsInt("resourceGroupId"));
+
+ GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria,
+ new AsyncCallback<PageList<MeasurementSchedule>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_schedules_loadFailed(), caught);
+ }
+
+ public void onSuccess(PageList<MeasurementSchedule> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
} else {
processResponse(request.getRequestId(), response);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
deleted file mode 100644
index a6d3fe9..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
-
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.List;
-
-import ca.nanometrics.gflot.client.Axis;
-import ca.nanometrics.gflot.client.DataPoint;
-import ca.nanometrics.gflot.client.PlotItem;
-import ca.nanometrics.gflot.client.PlotModel;
-import ca.nanometrics.gflot.client.PlotPosition;
-import ca.nanometrics.gflot.client.SeriesHandler;
-import ca.nanometrics.gflot.client.SimplePlot;
-import ca.nanometrics.gflot.client.event.PlotHoverListener;
-import ca.nanometrics.gflot.client.jsni.Plot;
-import ca.nanometrics.gflot.client.options.AxisOptions;
-import ca.nanometrics.gflot.client.options.GridOptions;
-import ca.nanometrics.gflot.client.options.LineSeriesOptions;
-import ca.nanometrics.gflot.client.options.PlotOptions;
-import ca.nanometrics.gflot.client.options.PointsSeriesOptions;
-import ca.nanometrics.gflot.client.options.TickFormatter;
-
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.AnimationEffect;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.Img;
-import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.events.MouseOutEvent;
-import com.smartgwt.client.widgets.events.MouseOutHandler;
-import com.smartgwt.client.widgets.layout.HLayout;
-
-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.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWidgetCanvas;
-
-/**
- * @author Greg Hinkle
- */
-public class SmallGraphView extends LocatableVLayout {
-
- private static final String INSTRUCTIONS = MSG.view_resource_monitor_graph_instructions();
-
- private static final String[] MONTH_NAMES = { MSG.common_calendar_january_short(),
- MSG.common_calendar_february_short(), MSG.common_calendar_march_short(), MSG.common_calendar_april_short(),
- MSG.common_calendar_may_short(), MSG.common_calendar_june_short(), MSG.common_calendar_july_short(),
- MSG.common_calendar_august_short(), MSG.common_calendar_september_short(), MSG.common_calendar_october_short(),
- MSG.common_calendar_november_short(), MSG.common_calendar_december_short() };
-
- private final Label selectedPointLabel = new Label(INSTRUCTIONS);
- private final Label positionLabel = new Label();
-
- private final Label hoverLabel = new Label();
-
- private int resourceId;
-
- private int definitionId;
-
- private MeasurementDefinition definition;
- private List<MeasurementDataNumericHighLowComposite> data;
-
- public SmallGraphView(String locatorId) {
- super(locatorId);
- }
-
- public SmallGraphView(String locatorId, int resourceId, int definitionId) {
- this(locatorId);
-
- this.resourceId = resourceId;
- this.definitionId = definitionId;
- }
-
- public SmallGraphView(String locatorId, int resourceId, MeasurementDefinition def,
- List<MeasurementDataNumericHighLowComposite> data) {
- this(locatorId);
-
- this.resourceId = resourceId;
- this.definition = def;
- this.data = data;
- setHeight100();
- setWidth100();
- }
-
- public String getName() {
- return "PlotHoverListener";
- }
-
- public int getResourceId() {
- return resourceId;
- }
-
- public void setResourceId(int resourceId) {
- this.resourceId = resourceId;
- this.definition = null;
- }
-
- public int getDefinitionId() {
- return definitionId;
- }
-
- public void setDefinitionId(int definitionId) {
- this.definitionId = definitionId;
- this.definition = null;
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
- removeMembers(getMembers());
- renderGraph();
- }
-
- @Override
- public void parentResized() {
- super.parentResized();
- removeMembers(getMembers());
- renderGraph();
- }
-
- protected void renderGraph() {
- if (this.definition == null) {
-
- ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
-
- ResourceCriteria resourceCriteria = new ResourceCriteria();
- resourceCriteria.addFilterId(resourceId);
- resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught);
- }
-
- public void onSuccess(PageList<Resource> result) {
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- result.get(0).getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(final ResourceType type) {
-
- for (MeasurementDefinition def : type.getMetricDefinitions()) {
- if (def.getId() == definitionId) {
- SmallGraphView.this.definition = def;
-
- GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId,
- new int[] { definitionId },
- System.currentTimeMillis() - (1000L * 60 * 60 * 8),
- System.currentTimeMillis(), 60,
- new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_resource_monitor_graphs_loadFailed(), caught);
- }
-
- public void onSuccess(
- List<List<MeasurementDataNumericHighLowComposite>> result) {
- SmallGraphView.this.data = result.get(0);
-
- drawGraph();
- }
- });
- }
- }
- }
- });
- }
- });
-
- } else {
-
- drawGraph();
-
- }
- }
-
- private void drawGraph() {
-
- HLayout titleLayout = new LocatableHLayout(getLocatorId());
-
- if (definition != null) {
- titleLayout.setAutoHeight();
-
- titleLayout.setWidth100();
-
- HTMLFlow title = new HTMLFlow("<b>" + definition.getDisplayName() + "</b> " + definition.getDescription());
- title.setWidth("*");
- title.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- displayAsDialog(extendLocatorId("Dialog"));
- }
- });
- titleLayout.addMember(title);
-
- Img liveGraph = new LocatableImg(getLocatorId(), "subsystems/monitor/Monitor_16.png", 16, 16);
- liveGraph.setTooltip(MSG.view_resource_monitor_graph_live_tooltip());
-
- liveGraph.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- LiveGraphView.displayAsDialog(getLocatorId(), resourceId, definition);
- }
- });
- titleLayout.addMember(liveGraph);
-
- addMember(titleLayout);
- }
-
- PlotModel model = new PlotModel();
- PlotOptions plotOptions = new PlotOptions();
- plotOptions.setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setShow(true));
- plotOptions.setDefaultPointsOptions(new PointsSeriesOptions().setRadius(2).setShow(true));
- plotOptions.setDefaultShadowSize(0);
-
- // You need make the grid hoverable <<<<<<<<<
- plotOptions
- .setGridOptions(new GridOptions().setHoverable(true).setMouseActiveRadius(10).setAutoHighlight(true));
-
- // create a series
- if (definition != null && data != null) {
- loadData(model, plotOptions);
- }
-
- // create the plot
- SimplePlot plot = new SimplePlot(model, plotOptions);
- plot.setSize(String.valueOf(getInnerContentWidth()), String.valueOf(getInnerContentHeight()
- - titleLayout.getHeight() - 50));
- // "80%","80%");
-
- // add hover listener
- plot.addHoverListener(new PlotHoverListener() {
- public void onPlotHover(Plot plot, PlotPosition position, PlotItem item) {
- if (position != null) {
- positionLabel.setContents("position: (" + position.getX() + "," + position.getY() + ")");
- }
- if (item != null) {
- hoverLabel.setContents(getHover(item));
-
- hoverLabel.animateShow(AnimationEffect.FADE);
- if (hoverLabel.getLeft() > 0 || hoverLabel.getTop() > 0) {
- hoverLabel.animateMove(item.getPageX() + 10, item.getPageY() - 35);
- } else {
- hoverLabel.moveTo(item.getPageX() + 10, item.getPageY() - 35);
- }
- hoverLabel.redraw();
-
- selectedPointLabel.setContents("x: " + item.getDataPoint().getX() + ", y: "
- + item.getDataPoint().getY());
- } else {
- hoverLabel.animateHide(AnimationEffect.FADE);
- selectedPointLabel.setContents(INSTRUCTIONS);
- }
- }
- }, false);
-
- addMouseOutHandler(new MouseOutHandler() {
- public void onMouseOut(MouseOutEvent mouseOutEvent) {
- hoverLabel.animateHide(AnimationEffect.FADE);
- }
- });
-
- hoverLabel.setOpacity(80);
- hoverLabel.setWrap(false);
- hoverLabel.setHeight(25);
- hoverLabel.setBackgroundColor("yellow");
- hoverLabel.setBorder("1px solid orange");
- hoverLabel.hide();
-
- if (hoverLabel.isDrawn())
- hoverLabel.redraw();
- else
- hoverLabel.draw();
-
- // put it on a panel
-
- addMember(new LocatableWidgetCanvas(this.getLocatorId(), plot));
-
- plot.setSize(String.valueOf(getInnerContentWidth()), String.valueOf(getInnerContentHeight()
- - titleLayout.getHeight() - 50));
-
- }
-
- @Override
- public void destroy() {
- hoverLabel.destroy();
- super.destroy();
- }
-
- @Override
- public void hide() {
- super.hide();
- hoverLabel.hide();
- }
-
- private String getHover(PlotItem item) {
- if (definition != null) {
- com.google.gwt.i18n.client.DateTimeFormat df = DateTimeFormat.getMediumDateTimeFormat();
- return definition.getDisplayName() + ": "
- + MeasurementConverterClient.format(item.getDataPoint().getY(), definition.getUnits(), true) + "<br/>"
- + df.format(new Date((long) item.getDataPoint().getX()));
- } else {
- return "x: " + item.getDataPoint().getX() + ", y: " + item.getDataPoint().getY();
- }
- }
-
- private void loadData(PlotModel model, PlotOptions plotOptions) {
- SeriesHandler handler = model.addSeries(definition.getDisplayName(), "#007f00");
-
- for (MeasurementDataNumericHighLowComposite d : data) {
- handler.add(new DataPoint(d.getTimestamp(), d.getValue()));
- }
-
- plotOptions.setYAxisOptions(new AxisOptions().setTicks(5).setLabelWidth(70).setTickFormatter(
- new TickFormatter() {
- public String formatTickValue(double v, Axis axis) {
- return MeasurementConverterClient.format(v, definition.getUnits(), true);
- }
- }));
-
- long max = System.currentTimeMillis();
- long min = max - (1000L * 60 * 60 * 8);
-
- int xTicks = getWidth() / 140;
-
- plotOptions.setXAxisOptions(new AxisOptions().setTicks(xTicks).setMinimum(min).setMaximum(max)
- .setTickFormatter(new TickFormatter() {
- public String formatTickValue(double tickValue, Axis axis) {
- com.google.gwt.i18n.client.DateTimeFormat dateFormat = DateTimeFormat.getShortDateTimeFormat();
- return dateFormat.format(new Date((long) tickValue));
- // return String.valueOf(new Date((long) tickValue));
- // return MONTH_NAMES[(int) (tickValue - 1)];
- }
- }));
-
- }
-
- private void displayAsDialog(String locatorId) {
- SmallGraphView graph = new SmallGraphView(locatorId, resourceId, definition, data);
- Window graphPopup = new Window();
- graphPopup.setTitle(MSG.view_resource_monitor_detailed_graph_label());
- graphPopup.setWidth(800);
- graphPopup.setHeight(400);
- graphPopup.setIsModal(true);
- graphPopup.setShowModalMask(true);
- graphPopup.setCanDragResize(true);
- graphPopup.centerInPage();
- graphPopup.addItem(graph);
- graphPopup.show();
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
index 48cd8da..320e341 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -31,7 +31,6 @@ import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
-import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -42,17 +41,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
- private static final ViewName GROUP_COMPATIBLE = new ViewName(GroupCategory.COMPATIBLE.getName(), MSG
- .view_group_summary_compatible());
- private static final ViewName GROUP_MIXED = new ViewName(GroupCategory.MIXED.getName(), MSG
- .view_group_summary_mixed());
private static LinkedHashMap<String, String> CATEGORY_VALUE_MAP = new LinkedHashMap<String, String>();
GroupCategory categoryFilter;
static {
- CATEGORY_VALUE_MAP.put(GroupCategory.COMPATIBLE.getName(), MSG.view_group_summary_compatible() + "-!");
- CATEGORY_VALUE_MAP.put(GroupCategory.MIXED.getName(), MSG.view_group_summary_mixed() + "-!");
+ CATEGORY_VALUE_MAP.put(GroupCategory.COMPATIBLE.getName(), MSG.view_group_summary_compatible());
+ CATEGORY_VALUE_MAP.put(GroupCategory.MIXED.getName(), MSG.view_group_summary_mixed());
}
@@ -78,7 +73,6 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
final TextItem search = new TextItem("search", MSG.common_title_search());
SelectItem groupCategorySelect = new SelectItem("groupCategory", MSG.widget_resourceSelector_groupCategory());
- //groupCategorySelect.setValueMap(GROUP_COMPATIBLE.getTitle(), GROUP_MIXED.getTitle());
groupCategorySelect.setValueMap(CATEGORY_VALUE_MAP);
if (null == categoryFilter) {
groupCategorySelect.setAllowEmptyValue(true);
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index aebcd71..a07b4b6 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
@@ -1444,7 +1444,8 @@ view_dashboardsManager_message_title_details = <h1>Welcome to RHQ</h1>\n<p>The R
view_portlet_defaultName_autodiscovery = Discovery Queue
view_portlet_defaultName_favoriteResources = Favorite Resources
-view_portlet_defaultName_graph = Resource Metric Graph
+view_portlet_defaultName_resourceMetric = Resource Metric Graph
+view_portlet_defaultName_groupMetric = Resource Group Metric Graph
view_portlet_defaultName_inventorySummary = Inventory Summary
view_portlet_defaultName_mashup = Mashup
view_portlet_defaultName_message = Message
@@ -1644,7 +1645,8 @@ view_tree_common_contextMenu_operations = Operations
view_tree_common_contextMenu_operations_loadFailed = Failure to start wizard for running operations
view_tree_common_contextMenu_measurements = Measurements
view_tree_common_contextMenu_addChartToDashboard = Add chart to dashboard [{0}]
-view_tree_common_contextMenu_chart = Chart
+view_tree_common_contextMenu_resourceGraph = Resource Metric Graph
+view_tree_common_contextMenu_groupGraph = Group Metric Graph
view_tree_common_contextMenu_saveChartToDashboardSuccessful = You have saved dashboard [{0}]
view_tree_common_contextMenu_saveChartToDashboardFailure = Failed to save the dashboard
view_tree_common_contextMenu_loadFailed_dashboard = Failed to load user dashboards
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 242a76b..805d4bf 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
@@ -1153,7 +1153,8 @@ view_tree_common_contextMenu_operations=Operations~
view_tree_common_contextMenu_operations_loadFailed=Failure to start wizard for running operations~
view_tree_common_contextMenu_measurements=Measurements~
view_tree_common_contextMenu_addChartToDashboard=Diagramm zum Dashboard [{0}] hinzufügen
-view_tree_common_contextMenu_chart=Chart~
+view_tree_common_contextMenu_resourceGraph = Resource Metric Graph~
+view_tree_common_contextMenu_groupGraph = Group Metric Graph~
view_tree_common_contextMenu_saveChartToDashboardSuccessful=sie haben das Dashboard [{0}] gesichert
view_tree_common_contextMenu_saveChartToDashboardFailure=Speichern des Dashboards fehlgeschlagen
view_tree_common_contextMenu_loadFailed_dashboard=Failed to load user dashboards
commit 2d4b0e8ae833aee4d9ea57df914ca19ec50f6810
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 21 16:19:13 2011 -0400
Add AncestryUtil entry point for getting resource hover without using a
ListGridRecord, just the required entity info.
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 b7734c4..8a2cbe2 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
@@ -189,9 +189,24 @@ public abstract class AncestryUtil {
Map<Integer, ResourceType> types = ((MapWrapper) listGridRecord.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES))
.getMap();
Integer resourceTypeId = listGridRecord.getAttributeAsInt(RESOURCE_TYPE_ID);
+ String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
+
+ String result = getAncestryHoverHTMLString(resourceId, resourceName, ancestry, resourceTypeId, types, width);
+
+ listGridRecord.setAttribute(RESOURCE_ANCESTRY_HOVER, result);
+ return result;
+ }
+
+ public static String getAncestryHoverHTMLForResource(Resource resource, Map<Integer, ResourceType> types, int width) {
+
+ return getAncestryHoverHTMLString(resource.getId(), resource.getName(), resource.getAncestry(), resource
+ .getResourceType().getId(), types, width);
+ }
+
+ private static String getAncestryHoverHTMLString(int resourceId, String resourceName, String ancestry,
+ int resourceTypeId, Map<Integer, ResourceType> types, int width) {
ResourceType type = types.get(resourceTypeId);
String resourceLongName = getResourceLongName(resourceName, type);
- String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
width = (width <= 0) ? 500 : width;
@@ -231,9 +246,7 @@ public abstract class AncestryUtil {
sb.append("</p>");
- String result = sb.toString();
- listGridRecord.setAttribute(RESOURCE_ANCESTRY_HOVER, result);
- return result;
+ return sb.toString();
}
private static String getResourceLongName(String resourceName, ResourceType type) {
commit 1cd5508cf4d898bdc29c6f6b7a705a680e338ff3
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 21 16:16:38 2011 -0400
Fix and enhance various selectors
- don't ignore construction-time criteria, so the first fetch can be filtered
- allow localized categories in the resource group selector category filter
- allow preset category filter in group selector (this, for example, can force
only compatible groups).
- add SingleResourceGroupSelector when you only want one group
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index c3ae654..457d13b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -284,12 +284,13 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
availableSectionStack.addSection(availableSection);
// Load data.
- this.datasource = getDataSource();
- populateAvailableGrid(new Criteria());
-
if (this.availableFilterForm != null) {
+ // this grabs any initial criteria prior to the first data fetch
+ latestCriteria = getLatestCriteria(availableFilterForm);
+
this.availableFilterForm.addItemChangedHandler(new ItemChangedHandler() {
public void onItemChanged(ItemChangedEvent itemChangedEvent) {
+
latestCriteria = getLatestCriteria(availableFilterForm);
Timer timer = new Timer() {
@@ -306,6 +307,8 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
}
});
}
+ this.datasource = getDataSource();
+ populateAvailableGrid((null == latestCriteria) ? new Criteria() : latestCriteria);
// Add event handlers.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
index 9424d59..48cd8da 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection;
+import java.util.LinkedHashMap;
+
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -26,8 +28,11 @@ import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -37,12 +42,32 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
+ private static final ViewName GROUP_COMPATIBLE = new ViewName(GroupCategory.COMPATIBLE.getName(), MSG
+ .view_group_summary_compatible());
+ private static final ViewName GROUP_MIXED = new ViewName(GroupCategory.MIXED.getName(), MSG
+ .view_group_summary_mixed());
+ private static LinkedHashMap<String, String> CATEGORY_VALUE_MAP = new LinkedHashMap<String, String>();
+
+ GroupCategory categoryFilter;
+
+ static {
+ CATEGORY_VALUE_MAP.put(GroupCategory.COMPATIBLE.getName(), MSG.view_group_summary_compatible() + "-!");
+ CATEGORY_VALUE_MAP.put(GroupCategory.MIXED.getName(), MSG.view_group_summary_mixed() + "-!");
+
+ }
+
public ResourceGroupSelector(String locatorId) {
this(locatorId, false);
}
-
+
public ResourceGroupSelector(String locatorId, boolean isReadOnly) {
+ this(locatorId, null, isReadOnly);
+ }
+
+ public ResourceGroupSelector(String locatorId, GroupCategory categoryFilter, boolean isReadOnly) {
super(locatorId, isReadOnly);
+
+ this.categoryFilter = categoryFilter;
}
protected DynamicForm getAvailableFilterForm() {
@@ -53,8 +78,21 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
final TextItem search = new TextItem("search", MSG.common_title_search());
SelectItem groupCategorySelect = new SelectItem("groupCategory", MSG.widget_resourceSelector_groupCategory());
- groupCategorySelect.setValueMap("Compatible", "Mixed"); // I don't think we can i18n these, may need these literal values - need to double check this
- groupCategorySelect.setAllowEmptyValue(true);
+ //groupCategorySelect.setValueMap(GROUP_COMPATIBLE.getTitle(), GROUP_MIXED.getTitle());
+ groupCategorySelect.setValueMap(CATEGORY_VALUE_MAP);
+ if (null == categoryFilter) {
+ groupCategorySelect.setAllowEmptyValue(true);
+ } else {
+ switch (categoryFilter) {
+ case COMPATIBLE:
+ groupCategorySelect.setValue(GroupCategory.COMPATIBLE.getName());
+ break;
+ case MIXED:
+ groupCategorySelect.setValue(GroupCategory.MIXED.getName());
+ break;
+ }
+ groupCategorySelect.setDisabled(true);
+ }
availableFilterForm.setItems(search, groupCategorySelect, new SpacerItem());
return availableFilterForm;
@@ -72,10 +110,10 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
String category = (String) availableFilterForm.getValue("groupCategory");
Criteria criteria = new Criteria();
if (null != search) {
- criteria.addCriteria("name", search);
+ criteria.addCriteria(ResourceGroupDataSourceField.NAME.propertyName(), search);
}
if (null != category) {
- criteria.addCriteria("category", category);
+ criteria.addCriteria(ResourceGroupDataSourceField.CATEGORY.propertyName(), category);
}
return criteria;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/SingleResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/SingleResourceGroupSelector.java
new file mode 100644
index 0000000..513419f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/SingleResourceGroupSelector.java
@@ -0,0 +1,65 @@
+/*
+ * 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.inventory.resource.selection;
+
+import com.smartgwt.client.types.SelectionStyle;
+
+import org.rhq.core.domain.resource.group.GroupCategory;
+
+/**
+ * This forces the user to only be able to select a single resource.
+ *
+ * @author Jay Shaughnessy
+ */
+public class SingleResourceGroupSelector extends ResourceGroupSelector {
+
+ public SingleResourceGroupSelector(String locatorId) {
+ super(locatorId);
+ }
+
+ public SingleResourceGroupSelector(String locatorId, GroupCategory categoryFilter, boolean isReadOnly) {
+ super(locatorId, categoryFilter, isReadOnly);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // we only allow a single resource to be selected
+ availableGrid.setSelectionType(SelectionStyle.SINGLE);
+ }
+
+ @Override
+ protected void updateButtonEnablement() {
+ addButton.setDisabled(!availableGrid.anySelected() || availableGrid.getTotalRows() == 0
+ || assignedGrid.getTotalRows() > 0);
+ removeButton.setDisabled(!assignedGrid.anySelected());
+ addAllButton.hide();
+ removeAllButton.hide();
+ }
+
+ @Override
+ public void addSelectedRows() {
+ // do not allow more than one row into the assigned grid
+ if (assignedGrid.getTotalRows() == 0) {
+ super.addSelectedRows();
+ }
+ }
+}
commit ab15b97d5183df6b04242d52b14d6023d40097fb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 21 15:04:15 2011 -0400
BZ 560760 don't allow the user to edit alert defs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index 82aeea7..2bacf3d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -52,6 +52,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
private Button saveButton;
private Button cancelButton;
+ private boolean allowedToModifyAlertDefinitions;
+
public SingleAlertDefinitionView(String locatorId, AbstractAlertDefinitionsView alertDefView) {
this(locatorId, alertDefView, null);
}
@@ -61,6 +63,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
super(locatorId);
this.alertDefinition = alertDefinition;
+ this.allowedToModifyAlertDefinitions = alertDefView.isAllowedToModifyAlertDefinitions();
LocatableTabSet tabSet = new LocatableTabSet(this.getLocatorId());
tabSet.setHeight100();
@@ -107,6 +110,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
buttons.addMember(saveButton);
buttons.addMember(cancelButton);
+ editButton.setDisabled(!allowedToModifyAlertDefinitions);
+
editButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
@@ -121,7 +126,7 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
setAlertDefinition(getAlertDefinition()); // loads data into static fields
makeViewOnly();
- alertDefView.commitAlertDefinition(getAlertDefinition());
+ alertDefView.commitAlertDefinition(getAlertDefinition());
}
});
@@ -155,6 +160,12 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
}
public void makeEditable() {
+ if (!this.allowedToModifyAlertDefinitions) {
+ // this is just a safety measure - we should never get here if we don't have perms, but just in case,
+ // don't do anything to allow the def to be editable. Should we notify the message center?
+ return;
+ }
+
saveButton.show();
cancelButton.show();
editButton.hide();
commit 33815da4e801a6ebce0f9be4e01b4c1da7d0a2df
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 21 12:46:05 2011 -0400
fix resourceOps link issue.
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
index a1f9c3e..f2a0ab4 100644
--- 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
@@ -245,6 +245,11 @@ class ResourceOperationsCriteriaHistoryListView extends AbstractOperationHistory
MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
}
}
+
+ @Override
+ protected String getBasePath() {
+ return "Resource/" + resourceComposite.getResource().getId() + "/Operations/History";
+ }
}
/** Provide implementation of ResourceOperationHistoryDataSource that dynamically
commit 13336db776cbdf7f8133f9ff3ab6eb38035dccba
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 21 11:52:43 2011 -0400
fix/enforce unmodifiable PortletFactory mapping data.
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 10610e4..e8ee80c 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
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.dashboard;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -194,7 +195,8 @@ public class DashboardView extends LocatableVLayout {
private DynamicForm buildEditForm() {
editForm = new LocatableDynamicForm(extendLocatorId("Editor"));
- final HashMap<String, String> groupKeyNameMap = PortletFactory.getRegisteredGroupPortletNameMap();
+ final Map<String, String> groupKeyNameMap = new HashMap<String, String>(PortletFactory
+ .getRegisteredGroupPortletNameMap());
//remove BundleDeployment and add back later if relevant.
groupKeyNameMap.remove(GroupBundleDeploymentsPortlet.KEY);
//if group, need to do asynch check for bundlePortlet to ensure only Platform members
@@ -246,7 +248,7 @@ public class DashboardView extends LocatableVLayout {
*
* @param groupKeyNameMap
*/
- private void populateBuildEditForm(HashMap<String, String> groupKeyNameMap) {
+ private void populateBuildEditForm(Map<String, String> groupKeyNameMap) {
editForm.setMargin(5);
editForm.setAutoWidth();
editForm.setNumCols(canEditName() ? 12 : 10);
@@ -312,7 +314,7 @@ public class DashboardView extends LocatableVLayout {
});
final Menu addPortletMenu = new LocatableMenu(editForm.extendLocatorId("PortletMenu"));
- HashMap<String, String> keyNameMap = PortletFactory.getRegisteredPortletNameMap();
+ HashMap<String, String> keyNameMap = new HashMap<String, String>(PortletFactory.getRegisteredPortletNameMap());
// the assumption here is that the portlet names are unique. we want a sorted menu here, so create a
// sorted map from portlet name to portlet key and use that to generate the menu. It would be nice if you
// could just call Menu.sort() but it's not supported (yet?).
@@ -333,7 +335,8 @@ public class DashboardView extends LocatableVLayout {
}
}
- HashMap<String, String> resourceKeyNameMap = PortletFactory.getRegisteredResourcePortletNameMap();
+ HashMap<String, String> resourceKeyNameMap = new HashMap<String, String>(PortletFactory
+ .getRegisteredResourcePortletNameMap());
//if resource passed in then add additional portlets to list
if (this.resource != null) {
//trim out portlets that should not be visible
@@ -504,7 +507,7 @@ public class DashboardView extends LocatableVLayout {
/**Process the portletName map to exclude portlets that should not be visible for this
* group. All except BundleDeployment visibility is handled here. Bundle requires runtime check.
*/
- public static HashMap<String, String> processPortletNameMapForGroup(HashMap<String, String> groupKeyNameMap,
+ public static Map<String, String> processPortletNameMapForGroup(Map<String, String> groupKeyNameMap,
ResourceGroupComposite composite) {
if ((composite != null) && (composite.getResourceGroup() != null) && (groupKeyNameMap != null)
&& !groupKeyNameMap.isEmpty()) {
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 b42ffa5..98220d7 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
@@ -19,8 +19,10 @@
package org.rhq.enterprise.gui.coregui.client.dashboard;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
@@ -66,7 +68,7 @@ public class PortletFactory {
private static final HashMap<String, PortletViewFactory> registeredResourcePortletFactoryMap;
private static final HashMap<String, String> registeredGroupPortletNameMap;
private static final HashMap<String, String> registeredResourcePortletNameMap;
- private static final HashMap<String, String> registeredPortletIconMap;
+ private static HashMap<String, String> registeredPortletIconMap;
static {
//############## Default Dashboard ############################
@@ -209,19 +211,24 @@ public class PortletFactory {
/**
* @return Unmodifiable Map of registered portlet keys to names
*/
- public static HashMap<String, String> getRegisteredPortletNameMap() {
-
- return registeredPortletNameMap;
+ public static Map<String, String> getRegisteredPortletNameMap() {
+ return Collections.unmodifiableMap(registeredPortletNameMap);
}
- public static HashMap<String, String> getRegisteredGroupPortletNameMap() {
+ /**
+ * @return Unmodifiable Map of registered portlet keys to names
+ */
+ public static Map<String, String> getRegisteredGroupPortletNameMap() {
- return registeredGroupPortletNameMap;
+ return Collections.unmodifiableMap(registeredGroupPortletNameMap);
}
- public static HashMap<String, String> getRegisteredResourcePortletNameMap() {
+ /**
+ * @return Unmodifiable Map of registered portlet keys to names
+ */
+ public static Map<String, String> getRegisteredResourcePortletNameMap() {
- return registeredResourcePortletNameMap;
+ return Collections.unmodifiableMap(registeredResourcePortletNameMap);
}
public static String getRegisteredPortletName(String key) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
index 106ac4b..7ff4f7d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -48,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
@@ -189,8 +191,13 @@ public class ActivityView extends LocatableVLayout implements DashboardContainer
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
//figure out which portlets to display and how
- HashMap<String, String> groupKeyNameMap = PortletFactory.getRegisteredGroupPortletNameMap();
+ Map<String, String> groupKeyNameMap = new HashMap<String, String>(PortletFactory
+ .getRegisteredGroupPortletNameMap());
+ //remove BundleDeployment and add back later if relevant.
+ groupKeyNameMap.remove(GroupBundleDeploymentsPortlet.KEY);
groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap, groupComposite);
+ //TODO: spinder 3/21/11 need asynch call to execute and then update the menu for bundle
+
int colLeft = 0;
int colRight = 1;
int rowLeft = 0;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
index ee64837..4cec210 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
@@ -172,7 +172,8 @@ public class ActivityView extends LocatableVLayout implements DashboardContainer
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
//figure out which portlets to display and how
- HashMap<String, String> resKeyNameMap = PortletFactory.getRegisteredResourcePortletNameMap();
+ HashMap<String, String> resKeyNameMap = new HashMap<String, String>(PortletFactory
+ .getRegisteredResourcePortletNameMap());
resKeyNameMap = DashboardView.processPortletNameMapForResource(resKeyNameMap, resourceComposite);
int colLeft = 0;
int colRight = 1;
commit 0fcd909efb4236646d9faaa1e1278ce4545ed678
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 21 09:15:00 2011 -0400
i)moved portlet dashboard to first activitytab. Still trailing dashboard reset issue
ii)disable sort results widget
iii)fix resourceOperationsPortlet init issue
iv)add NPE check to messageCenter execution.
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 a1a1c98..10610e4 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
@@ -474,22 +474,24 @@ public class DashboardView extends LocatableVLayout {
Resource resource = composite.getResource();
//filter out portlets not relevent for facets
Set<ResourceTypeFacet> facets = composite.getResourceFacets().getFacets();
- //Operation related portlets
- if (!facets.contains(ResourceTypeFacet.OPERATION)) {
- resourceKeyNameMap.remove(ResourceOperationsPortlet.KEY);
- }
- //MEASUREMENT related portlets(METRICS)
- if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
- resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
- resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
- }
- //Content related portlets
- if (!facets.contains(ResourceTypeFacet.CONTENT)) {
- resourceKeyNameMap.remove(ResourcePkgHistoryPortlet.KEY);
- }
- //Event related portlets
- if (!facets.contains(ResourceTypeFacet.EVENT)) {
- resourceKeyNameMap.remove(ResourceEventsPortlet.KEY);
+ if (!facets.isEmpty()) {
+ //Operation related portlets
+ if (!facets.contains(ResourceTypeFacet.OPERATION)) {
+ resourceKeyNameMap.remove(ResourceOperationsPortlet.KEY);
+ }
+ //MEASUREMENT related portlets(METRICS)
+ if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
+ resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ }
+ //Content related portlets
+ if (!facets.contains(ResourceTypeFacet.CONTENT)) {
+ resourceKeyNameMap.remove(ResourcePkgHistoryPortlet.KEY);
+ }
+ //Event related portlets
+ if (!facets.contains(ResourceTypeFacet.EVENT)) {
+ resourceKeyNameMap.remove(ResourceEventsPortlet.KEY);
+ }
}
//Bundle related portlet
if (!resource.getResourceType().getCategory().equals(ResourceCategory.PLATFORM)) {
@@ -513,18 +515,20 @@ public class DashboardView extends LocatableVLayout {
// ResourceGroup group = composite.getResourceGroup();
//compatible if not a compatible group may need to do some pruning.
if (groupCategory != GroupCategory.COMPATIBLE) {
- //Operations related portlets(Config,PkgHistory)
- if (!facets.contains(ResourceTypeFacet.OPERATION)) {
- groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
- }
- //MEASUREMENT related portlets(METRICS)
- if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
- groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
- groupKeyNameMap.remove(GroupOobsPortlet.KEY);
- }
- //CONTENT related portlets(CONTENT)
- if (!facets.contains(ResourceTypeFacet.CONTENT)) {
- groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY);
+ if (!facets.isEmpty()) {
+ //Operations related portlets(Config,PkgHistory)
+ if (!facets.contains(ResourceTypeFacet.OPERATION)) {
+ groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
+ }
+ //MEASUREMENT related portlets(METRICS)
+ if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
+ groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
+ groupKeyNameMap.remove(GroupOobsPortlet.KEY);
+ }
+ //CONTENT related portlets(CONTENT)
+ if (!facets.contains(ResourceTypeFacet.CONTENT)) {
+ groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY);
+ }
}
// //EVENT related portlets
// if (!facets.contains(ResourceTypeFacet.EVENT)) {
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 b8d2ddc..b42ffa5 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
@@ -57,16 +57,16 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePort
*/
public class PortletFactory {
- private static HashMap<String, PortletViewFactory> registeredPortletFactoryMap;
- private static HashMap<String, String> registeredPortletNameMap;
+ private static final HashMap<String, PortletViewFactory> registeredPortletFactoryMap;
+ private static final HashMap<String, String> registeredPortletNameMap;
//Group portlet registrations, diff from default portlets as only applicable for specific group
- private static HashMap<String, PortletViewFactory> registeredGroupPortletFactoryMap;
+ private static final HashMap<String, PortletViewFactory> registeredGroupPortletFactoryMap;
//Resource portlet registrations, diff from default portlets as only applicable for specific resource
- private static HashMap<String, PortletViewFactory> registeredResourcePortletFactoryMap;
- private static HashMap<String, String> registeredGroupPortletNameMap;
- private static HashMap<String, String> registeredResourcePortletNameMap;
- private static HashMap<String, String> registeredPortletIconMap;
+ private static final HashMap<String, PortletViewFactory> registeredResourcePortletFactoryMap;
+ private static final HashMap<String, String> registeredGroupPortletNameMap;
+ private static final HashMap<String, String> registeredResourcePortletNameMap;
+ private static final HashMap<String, String> registeredPortletIconMap;
static {
//############## Default Dashboard ############################
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 e148b1e..f2322b0 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
@@ -46,7 +46,6 @@ 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;
@@ -93,8 +92,8 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
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.RESULT_SORT_ORDER);
+ // CONFIG_INCLUDE.add(Constant.RESULT_SORT_PRIORITY);
CONFIG_INCLUDE.add(Constant.OPERATION_STATUS);
}
@@ -234,9 +233,9 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
//add filter operation status type selector
final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
.getOperationStatusEditor(portletConfig);
- //add sort priority selector
- final SelectItem resultSortSelector = PortletConfigurationEditorComponent
- .getResulSortOrderEditor(portletConfig);
+ // //add sort priority selector
+ // final SelectItem resultSortSelector = PortletConfigurationEditorComponent
+ // .getResulSortOrderEditor(portletConfig);
//add result count selector
final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
@@ -244,7 +243,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
.getMeasurementRangeEditor(portletConfig);
- form.setItems(operationStatusSelector, resultSortSelector, resultCountSelector);
+ form.setItems(operationStatusSelector, resultCountSelector);
//submit handler
customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
@@ -404,18 +403,18 @@ class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource
//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 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);
+ PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
boolean isAdvanced = false;
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
index 30929c1..a1f9c3e 100644
--- 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
@@ -41,7 +41,6 @@ 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.components.measurement.CustomConfigMeasurementRangeEditor;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
@@ -87,7 +86,7 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
protected void onInit() {
// super.onInit();
initializeUi();
- // loadData();
+ loadData();
}
@Override
@@ -107,9 +106,9 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
//add filter operation status type selector
final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
.getOperationStatusEditor(portletConfig);
- //add sort priority selector
- final SelectItem resultSortSelector = PortletConfigurationEditorComponent
- .getResulSortOrderEditor(portletConfig);
+ // //add sort priority selector
+ // final SelectItem resultSortSelector = PortletConfigurationEditorComponent
+ // .getResulSortOrderEditor(portletConfig);
//add result count selector
final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
@@ -117,7 +116,7 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
.getMeasurementRangeEditor(portletConfig);
- form.setItems(operationStatusSelector, resultSortSelector, resultCountSelector);
+ form.setItems(operationStatusSelector, resultCountSelector);
//submit handler
customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
@@ -279,18 +278,18 @@ class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataS
//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 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);
+ PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
boolean isAdvanced = false;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9b89dff..86a7c1c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -64,7 +64,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule.GroupOperationScheduleListView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView2;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView3;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
@@ -263,7 +263,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
updateSubTab(this.summaryTab, this.summaryActivity2, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return new ActivityView2(summaryActivity2.extendLocatorId("View2"), groupComposite);
+ return new ActivityView3(summaryActivity2.extendLocatorId("View2"), groupComposite);
}
});
// TODO (ips): Add Timeline subtab?
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
index eb0f23c..106ac4b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
@@ -18,685 +18,240 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.ContentsType;
+import com.smartgwt.client.util.BooleanCallback;
+import com.smartgwt.client.util.SC;
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.alert.Alert;
-import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
-import org.rhq.core.domain.content.InstalledPackageHistory;
-import org.rhq.core.domain.criteria.AlertCriteria;
-import org.rhq.core.domain.criteria.GroupBundleDeploymentCriteria;
-import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
-import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
-import org.rhq.core.domain.criteria.InstalledPackageHistoryCriteria;
-import org.rhq.core.domain.event.EventSeverity;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
-import org.rhq.core.domain.operation.GroupOperationHistory;
-import org.rhq.core.domain.resource.ResourceTypeFacet;
-import org.rhq.core.domain.resource.group.GroupCategory;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardCategory;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.group.ResourceGroup;
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.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.InitializableView;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
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.BrowserUtility;
-import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
-import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
- * The content pane for the group Summary>Activity subtab.
+ * The content pane for the group Summary>Dashboard subtab.
*
* @author Simeon Pinder
+ * @author Jay Shaughnessy
*/
-public class ActivityView extends AbstractActivityView {
- private ResourceGroupComposite groupComposite;
+public class ActivityView extends LocatableVLayout implements DashboardContainer, InitializableView {
- public ActivityView(String locatorId, ResourceGroupComposite groupComposite) {
- super(locatorId, groupComposite, null);
- this.groupComposite = groupComposite;
- }
+ private static final String DASHBOARD_NAME_PREFIX = "GroupDashboard_";
- @Override
- protected void onInit() {
- super.onInit();
- loadData();
- }
-
- /**Initiates data request.
- */
- protected void loadData() {
- ResourceGroup group = null;
- GroupCategory groupCategory = null;
- Set<ResourceTypeFacet> facets = null;
- if ((groupComposite != null) && (groupComposite.getResourceGroup() != null)) {
- group = groupComposite.getResourceGroup();
- groupCategory = groupComposite.getResourceGroup().getGroupCategory();
- //Load Facets to conditionally display relevant tabs
- facets = groupComposite.getResourceFacets().getFacets();
-
- getRecentAlerts();
- //events
- if (displayGroupEvents(groupCategory, facets)) {
- getRecentEventUpdates();
- }
- //operations
- if (displayGroupOperations(groupCategory, facets)) {
- getRecentOperations();
- }
- //Config updates
- if (displayGroupConfigurationUpdates(groupCategory, facets)) {
- getRecentConfigurationUpdates();
- }
- //recentMetrics,oobs,pkghistory
- if (groupCategory == GroupCategory.COMPATIBLE) {
- getRecentOobs();
- getRecentPkgHistory();
- getRecentMetrics();
- }
-
- //conditionally display Bundle deployments for groups of platforms only
- displayBundleDeploymentsForPlatformGroups(group);
- }
- }
-
- /** Fetches alerts and updates the DynamicForm instance with the latest
- * alert information.
- */
- private void getRecentAlerts() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- //fetches last five alerts for this resource
- AlertCriteria criteria = new AlertCriteria();
- PageControl pageControl = new PageControl(0, 5);
- pageControl.initDefaultOrderingField("ctime", PageOrdering.DESC);
- criteria.setPageControl(pageControl);
- criteria.addFilterResourceGroupIds(groupId);
- GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
- @Override
- public void onSuccess(PageList<Alert> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (Alert alert : result) {
- // alert history records do not have a usable locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- row.setNumCols(3);
-
- StaticTextItem iconItem = newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
- .getPriority()), alert.getAlertDefinition().getPriority().getDisplayName());
- LinkItem link = newLinkItem(alert.getAlertDefinition().getName() + ": ",
- ReportDecorator.GWT_GROUP_URL + groupId + "/Alerts/History/" + alert.getId());
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Alerts/History/", column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
- RECENT_ALERTS_NONE);
- column.addMember(row);
- }
- for (Canvas child : recentAlertsContent.getChildren()) {
- child.destroy();
- }
- recentAlertsContent.addChild(column);
- recentAlertsContent.markForRedraw();
- }
+ private ResourceGroupComposite groupComposite;
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent alerts for group [" + groupId + "]:" + caught.getMessage());
- }
- });
- }
+ private DashboardGWTServiceAsync dashboardService = GWTServiceLookup.getDashboardService();
- /** Fetches operations and updates the DynamicForm instance with the latest
- * operation information.
- */
- private void getRecentOperations() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- //fetches five most recent operations.
- PageControl pageControl = new PageControl(0, 5);
-
- GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
- List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
- filterResourceGroupIds.add(groupId);
- criteria.addFilterResourceGroupIds(filterResourceGroupIds);
- criteria.setPageControl(pageControl);
- criteria.addSortStatus(PageOrdering.DESC);
-
- GWTServiceLookup.getOperationService().findGroupOperationHistoriesByCriteria(criteria,
- new AsyncCallback<PageList<GroupOperationHistory>>() {
-
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent operations for group [" + groupId + "]:" + caught.getMessage());
- }
+ private DashboardView dashboardView;
- @Override
- public void onSuccess(PageList<GroupOperationHistory> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (GroupOperationHistory report : result) {
- // operation history records do not have a usable locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(3);
-
- StaticTextItem iconItem = newTextItemIcon(ImageManager.getOperationResultsIcon(report
- .getStatus()), report.getStatus().getDisplayName());
- LinkItem link = newLinkItem(report.getOperationDefinition().getDisplayName() + ": ",
- ReportDecorator.GWT_GROUP_URL + groupId + "/Operations/History/" + report.getId());
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(report
- .getStartedTime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
- .extendLocatorId(String.valueOf(rowNum)));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Operations/History/", column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentOperationsContent
- .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
- column.addMember(row);
- }
- for (Canvas child : recentOperationsContent.getChildren()) {
- child.destroy();
- }
- recentOperationsContent.addChild(column);
- recentOperationsContent.markForRedraw();
- }
- });
- }
+ private LocatableToolStrip footer;
+ private IButton editButton;
+ private IButton resetButton;
- /** Fetches configuration updates and updates the DynamicForm instance with the latest
- * config change information.
- */
- private void getRecentConfigurationUpdates() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
-
- PageControl lastFive = new PageControl(0, 5);
- GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
- criteria.setPageControl(lastFive);
- criteria.addSortStatus(PageOrdering.DESC);
- List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
- filterResourceGroupIds.add(groupId);
- criteria.addFilterResourceGroupIds(filterResourceGroupIds);
-
- GWTServiceLookup.getConfigurationService().findGroupResourceConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>() {
-
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent configuration updates for group [" + groupId + "]:"
- + caught.getMessage());
- }
+ // Capture the user's global permissions for use by any dashboard or portlet that may need it for rendering.
+ private Set<Permission> globalPermissions;
- @Override
- public void onSuccess(PageList<GroupResourceConfigurationUpdate> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (GroupResourceConfigurationUpdate update : result) {
- // config update history records do not have a usable locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(3);
-
- StaticTextItem iconItem = newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
- .getStatus()), null);
- String linkTitle = MSG.view_resource_inventory_activity_changed_by() + " "
- + update.getSubjectName() + ":";
- if ((update.getSubjectName() == null) || (update.getSubjectName().trim().isEmpty())) {
- linkTitle = MSG.common_msg_changeAutoDetected();
- }
- LinkItem link = newLinkItem(linkTitle, ReportDecorator.GWT_GROUP_URL + groupId
- + "/Configuration/History/" + update.getId());
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(update
- .getCreatedTime()));
+ private boolean editMode = false;
- row.setItems(iconItem, link, time);
- column.addMember(row);
- }
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId(String.valueOf(rowNum)));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Configuration/History/", column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentConfigurationContent
- .extendLocatorId("None"), RECENT_CONFIGURATIONS_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentConfigurationContent.getChildren()) {
- child.destroy();
- }
- recentConfigurationContent.addChild(column);
- recentConfigurationContent.markForRedraw();
+ private boolean isInitialized = false;
- }
- });
+ public ActivityView(String locatorId, ResourceGroupComposite groupComposite) {
+ super(locatorId);
+ this.groupComposite = groupComposite;
}
- /** Fetches recent events and updates the DynamicForm instance with the latest
- * event information over last 24hrs.
- */
- private void getRecentEventUpdates() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- long now = System.currentTimeMillis();
- long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
- GWTServiceLookup.getEventService().getEventCountsBySeverityForGroup(groupId, nowMinus24Hours, now,
- new AsyncCallback<Map<EventSeverity, Integer>>() {
-
- @Override
- public void onFailure(Throwable caught) {
- Log
- .debug("Error retrieving recent event counts for group [" + groupId + "]:"
- + 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 = newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
- .getLefty()), tuple.getLefty().name());
- //count
- StaticTextItem count = newTextItem(String.valueOf(tuple.righty));
- row.setItems(iconItem, count);
-
- column.addMember(row);
+ @Override
+ protected void onInit() {
+ if (!isInitialized()) {
+ super.onInit();
+
+ // first async call to get global permissions
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ globalPermissions = permissions;
+
+ // now make async call to look for customized dash for this user and entity
+ DashboardCriteria criteria = new DashboardCriteria();
+ criteria.addFilterCategory(DashboardCategory.GROUP);
+ criteria.addFilterGroupId(groupComposite.getResourceGroup().getId());
+ dashboardService.findDashboardsByCriteria(criteria, new AsyncCallback<PageList<Dashboard>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error1(), caught);
}
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
- .valueOf(rowNum)));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Events/History/", column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
- RECENT_EVENTS_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentEventsContent.getChildren()) {
- child.destroy();
- }
- recentEventsContent.addChild(column);
- recentEventsContent.markForRedraw();
- }
- });
- }
- /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
- * oob change details.
- */
- private void getRecentOobs() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
-
- GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForGroup(groupId, 5,
- new AsyncCallback<PageList<MeasurementOOBComposite>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent out of bound metrics for group [" + groupId + "]:"
- + caught.getMessage());
- }
+ public void onSuccess(final PageList<Dashboard> result) {
+ Dashboard dashboard = result.isEmpty() ? getDefaultDashboard() : result.get(0);
+ setDashboard(dashboard);
+
+ isInitialized = true;
- @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=" + groupId + "&mode=chartSingleMetricSingleResource";
- LinkItem link = newLinkItem(title, destination);
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(oob.getTimestamp()));
-
- row.setItems(link, time);
- column.addMember(row);
+ // draw() may be done since onInit finishes asynchronously, if so redraw
+ if (isDrawn()) {
+ markForRedraw();
+ }
}
- //insert see more link spinder(2/24/11): no page that displays all oobs... See More not possible.
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
- RECENT_OOB_NONE);
- column.addMember(row);
- }
- recentOobContent.setContents("");
- for (Canvas child : recentOobContent.getChildren()) {
- child.destroy();
- }
- recentOobContent.addChild(column);
- recentOobContent.markForRedraw();
+ });
}
});
+ }
}
- /** Fetches recent package history information and updates the DynamicForm instance with details.
- */
- private void getRecentPkgHistory() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- InstalledPackageHistoryCriteria criteria = new InstalledPackageHistoryCriteria();
- PageControl pageControl = new PageControl(0, 5);
- 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());
+ private void setDashboard(Dashboard dashboard) {
+ Canvas[] members = getMembers();
+ removeMembers(members);
+ //pass in the group information
+ dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard, groupComposite, null);
+ addMember(dashboardView);
+
+ footer = new LocatableToolStrip(extendLocatorId("Footer"));
+ footer.setPadding(5);
+ footer.setWidth100();
+ footer.setMembersMargin(15);
+
+ editButton = new LocatableIButton(footer.extendLocatorId("Mode"), editMode ? MSG.common_title_view_mode() : MSG
+ .common_title_edit_mode());
+ editButton.setAutoFit(true);
+ editButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ editMode = !editMode;
+ editButton.setTitle(editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode());
+ dashboardView.setEditMode(editMode);
}
+ });
- @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 = 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 = newLinkItem(title, destination);
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(history.getTimestamp()));
-
- row.setItems(iconItem, link, time);
- column.addMember(row);
+ resetButton = new LocatableIButton(footer.extendLocatorId("Reset"), MSG.common_button_reset());
+ resetButton.setAutoFit(true);
+ resetButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ String message = MSG.view_summaryDashboard_resetConfirm();
+
+ SC.ask(message, new BooleanCallback() {
+ public void execute(Boolean confirmed) {
+ if (confirmed) {
+ dashboardView.delete();
+ setDashboard(getDefaultDashboard());
+ markForRedraw();
+ }
}
- // //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 = createEmptyDisplayRow(recentPkgHistoryContent.extendLocatorId("None"),
- RECENT_PKG_HISTORY_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentPkgHistoryContent.getChildren()) {
- child.destroy();
- }
- recentPkgHistoryContent.addChild(column);
- recentPkgHistoryContent.markForRedraw();
+ });
}
});
- }
- /** 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() {
+ footer.addMember(editButton);
+ footer.addMember(resetButton);
- //display container
- final VLayout column = new VLayout();
- column.setHeight(10);//pack
- final int groupId = this.groupComposite.getResourceGroup().getId();
+ addMember(footer);
+ }
- //retrieve all relevant measurement definition ids.
- Set<MeasurementDefinition> definitions = this.groupComposite.getResourceGroup().getResourceType()
- .getMetricDefinitions();
+ protected Dashboard getDefaultDashboard() {
+ Subject sessionSubject = UserSessionManager.getSessionSubject();
+ ResourceGroup group = groupComposite.getResourceGroup();
+
+ Dashboard dashboard = new Dashboard();
+
+ dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_" + group.getId());
+ dashboard.setCategory(DashboardCategory.GROUP);
+ dashboard.setGroup(group);
+ dashboard.setColumns(2);
+
+ // set leftmost column and let the rest be equally divided
+ dashboard.setColumnWidths("40%");
+ dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
+
+ //figure out which portlets to display and how
+ HashMap<String, String> groupKeyNameMap = PortletFactory.getRegisteredGroupPortletNameMap();
+ groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap, groupComposite);
+ int colLeft = 0;
+ int colRight = 1;
+ int rowLeft = 0;
+ int rowRight = 0;
+ //Left Column
+ if (groupKeyNameMap.containsKey(GroupMetricsPortlet.KEY)) {//measurments top left if available
+ DashboardPortlet measurements = new DashboardPortlet(GroupMetricsPortlet.NAME, GroupMetricsPortlet.KEY, 220);
+ dashboard.addPortlet(measurements, colLeft, rowLeft++);
+ groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
+ }
- //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);
+ // right Column(approx 60%. As larger more room to display table and N rows.)
+ if (groupKeyNameMap.containsKey(GroupAlertsPortlet.KEY)) {//alerts top right if available
+ DashboardPortlet alerts = new DashboardPortlet(GroupAlertsPortlet.NAME, GroupAlertsPortlet.KEY, 220);
+ dashboard.addPortlet(alerts, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupAlertsPortlet.KEY);
}
- //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();
+ if (groupKeyNameMap.containsKey(GroupOperationsPortlet.KEY)) {//operations if available
+ DashboardPortlet ops = new DashboardPortlet(GroupOperationsPortlet.NAME, GroupOperationsPortlet.KEY, 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
}
- //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());
+ //Fill out left column(typically smaller portlets) then alternate cols with remaining
+ boolean displayLeft = false;
+ for (String key : groupKeyNameMap.keySet()) {
+ DashboardPortlet portlet = new DashboardPortlet(groupKeyNameMap.get(key), key, 100);
+ if (rowLeft < 4) {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
}
+ //toggle
+ displayLeft = !displayLeft;
+ }
+ }
+ return dashboard;
+ }
- @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 = newLinkItem(title, destination);
-
- //Value
- String convertedValue = lastValue + " " + md.getUnits();
- convertedValue = convertLastValueForDisplay(lastValue, md);
- StaticTextItem value = 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 = createEmptyDisplayRow(recentMeasurementsContent
- .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- } else {
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(recentMeasurementsContent
- .extendLocatorId("RecentMeasurementsContentSeeMore"));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Monitoring/Graphs/", column);
- }
- //call out to 3rd party javascript lib
- BrowserUtility.graphSparkLines();
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentMeasurementsContent
- .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- }
- }
- });
+ @Override
+ public boolean isInitialized() {
+ return isInitialized;
+ }
- //cleanup
- for (Canvas child : recentMeasurementsContent.getChildren()) {
- child.destroy();
- }
- recentMeasurementsContent.addChild(column);
- recentMeasurementsContent.markForRedraw();
+ public Set<Permission> getGlobalPermissions() {
+ return globalPermissions;
}
- /** Fetches recent bundle deployment information and updates the DynamicForm instance with details.
+ /**
+ * name update not supported because the name is derived from the entity id.
+ * @return
*/
- protected void getRecentBundleDeployments() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- GroupBundleDeploymentCriteria criteria = new GroupBundleDeploymentCriteria();
- PageControl pageControl = new PageControl(0, 5);
- 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());
- }
+ public boolean supportsDashboardNameEdit() {
+ return false;
+ }
- @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 = 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 = newLinkItem(title, destination);
- StaticTextItem time = 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 = createEmptyDisplayRow(recentBundleDeployContent
- .extendLocatorId("None"), RECENT_BUNDLE_DEPLOY_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentBundleDeployContent.getChildren()) {
- child.destroy();
- }
- recentBundleDeployContent.addChild(column);
- recentBundleDeployContent.markForRedraw();
- }
- });
+ public void updateDashboardNames() {
+ return;
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
deleted file mode 100644
index af8d09c..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
-
-import java.util.HashMap;
-import java.util.Set;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.util.BooleanCallback;
-import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DashboardCriteria;
-import org.rhq.core.domain.dashboard.Dashboard;
-import org.rhq.core.domain.dashboard.DashboardCategory;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-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.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.InitializableView;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
-import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * The content pane for the group Summary>Dashboard subtab.
- *
- * @author Simeon Pinder
- * @author Jay Shaughnessy
- */
-
-public class ActivityView2 extends LocatableVLayout implements DashboardContainer, InitializableView {
-
- private static final String DASHBOARD_NAME_PREFIX = "GroupDashboard_";
-
- private ResourceGroupComposite groupComposite;
-
- private DashboardGWTServiceAsync dashboardService = GWTServiceLookup.getDashboardService();
-
- private DashboardView dashboardView;
-
- private LocatableToolStrip footer;
- private IButton editButton;
- private IButton resetButton;
-
- // Capture the user's global permissions for use by any dashboard or portlet that may need it for rendering.
- private Set<Permission> globalPermissions;
-
- private boolean editMode = false;
-
- private boolean isInitialized = false;
-
- public ActivityView2(String locatorId, ResourceGroupComposite groupComposite) {
- super(locatorId);
- this.groupComposite = groupComposite;
- }
-
- @Override
- protected void onInit() {
- if (!isInitialized()) {
- super.onInit();
-
- // first async call to get global permissions
- new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
-
- public void onPermissionsLoaded(Set<Permission> permissions) {
- globalPermissions = permissions;
-
- // now make async call to look for customized dash for this user and entity
- DashboardCriteria criteria = new DashboardCriteria();
- criteria.addFilterCategory(DashboardCategory.GROUP);
- criteria.addFilterGroupId(groupComposite.getResourceGroup().getId());
- dashboardService.findDashboardsByCriteria(criteria, new AsyncCallback<PageList<Dashboard>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error1(), caught);
- }
-
- public void onSuccess(final PageList<Dashboard> result) {
- Dashboard dashboard = result.isEmpty() ? getDefaultDashboard() : result.get(0);
- setDashboard(dashboard);
-
- isInitialized = true;
-
- // draw() may be done since onInit finishes asynchronously, if so redraw
- if (isDrawn()) {
- markForRedraw();
- }
- }
- });
- }
- });
- }
- }
-
- private void setDashboard(Dashboard dashboard) {
- Canvas[] members = getMembers();
- removeMembers(members);
- //pass in the group information
- dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard, groupComposite, null);
- addMember(dashboardView);
-
- footer = new LocatableToolStrip(extendLocatorId("Footer"));
- footer.setPadding(5);
- footer.setWidth100();
- footer.setMembersMargin(15);
-
- editButton = new LocatableIButton(footer.extendLocatorId("Mode"), editMode ? MSG.common_title_view_mode() : MSG
- .common_title_edit_mode());
- editButton.setAutoFit(true);
- editButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- editMode = !editMode;
- editButton.setTitle(editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode());
- dashboardView.setEditMode(editMode);
- }
- });
-
- resetButton = new LocatableIButton(footer.extendLocatorId("Reset"), MSG.common_button_reset());
- resetButton.setAutoFit(true);
- resetButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- String message = MSG.view_summaryDashboard_resetConfirm();
-
- SC.ask(message, new BooleanCallback() {
- public void execute(Boolean confirmed) {
- if (confirmed) {
- dashboardView.delete();
- setDashboard(getDefaultDashboard());
- markForRedraw();
- }
- }
- });
- }
- });
-
- footer.addMember(editButton);
- footer.addMember(resetButton);
-
- addMember(footer);
- }
-
- protected Dashboard getDefaultDashboard() {
- Subject sessionSubject = UserSessionManager.getSessionSubject();
- ResourceGroup group = groupComposite.getResourceGroup();
-
- Dashboard dashboard = new Dashboard();
-
- dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_" + group.getId());
- dashboard.setCategory(DashboardCategory.GROUP);
- dashboard.setGroup(group);
- dashboard.setColumns(2);
-
- // set leftmost column and let the rest be equally divided
- dashboard.setColumnWidths("40%");
- dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
-
- //figure out which portlets to display and how
- HashMap<String, String> groupKeyNameMap = PortletFactory.getRegisteredGroupPortletNameMap();
- groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap, groupComposite);
- int colLeft = 0;
- int colRight = 1;
- int rowLeft = 0;
- int rowRight = 0;
- //Left Column
- if (groupKeyNameMap.containsKey(GroupMetricsPortlet.KEY)) {//measurments top left if available
- DashboardPortlet measurements = new DashboardPortlet(GroupMetricsPortlet.NAME, GroupMetricsPortlet.KEY, 220);
- dashboard.addPortlet(measurements, colLeft, rowLeft++);
- groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
- }
-
- // right Column(approx 60%. As larger more room to display table and N rows.)
- if (groupKeyNameMap.containsKey(GroupAlertsPortlet.KEY)) {//alerts top right if available
- DashboardPortlet alerts = new DashboardPortlet(GroupAlertsPortlet.NAME, GroupAlertsPortlet.KEY, 220);
- dashboard.addPortlet(alerts, colRight, rowRight++);
- groupKeyNameMap.remove(GroupAlertsPortlet.KEY);
- }
- if (groupKeyNameMap.containsKey(GroupOperationsPortlet.KEY)) {//operations if available
- DashboardPortlet ops = new DashboardPortlet(GroupOperationsPortlet.NAME, GroupOperationsPortlet.KEY, 220);
- dashboard.addPortlet(ops, colRight, rowRight++);
- groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
- }
-
- //Fill out left column(typically smaller portlets) then alternate cols with remaining
- boolean displayLeft = false;
- for (String key : groupKeyNameMap.keySet()) {
- DashboardPortlet portlet = new DashboardPortlet(groupKeyNameMap.get(key), key, 100);
- if (rowLeft < 4) {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- } else {//alternate
- if (!displayLeft) {
- dashboard.addPortlet(portlet, colRight, rowRight++);
- } else {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- }
- //toggle
- displayLeft = !displayLeft;
- }
- }
- return dashboard;
- }
-
- @Override
- public boolean isInitialized() {
- return isInitialized;
- }
-
- public Set<Permission> getGlobalPermissions() {
- return globalPermissions;
- }
-
- /**
- * name update not supported because the name is derived from the entity id.
- * @return
- */
- public boolean supportsDashboardNameEdit() {
- return false;
- }
-
- public void updateDashboardNames() {
- return;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView3.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView3.java
new file mode 100644
index 0000000..d8ef22f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView3.java
@@ -0,0 +1,702 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.allen_sauer.gwt.log.client.Log;
+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.alert.Alert;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
+import org.rhq.core.domain.content.InstalledPackageHistory;
+import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.criteria.GroupBundleDeploymentCriteria;
+import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
+import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.criteria.InstalledPackageHistoryCriteria;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
+import org.rhq.core.domain.operation.GroupOperationHistory;
+import org.rhq.core.domain.resource.ResourceTypeFacet;
+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.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+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.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * The content pane for the group Summary>Activity subtab.
+ *
+ * @author Simeon Pinder
+ */
+public class ActivityView3 extends AbstractActivityView {
+
+ private ResourceGroupComposite groupComposite;
+
+ public ActivityView3(String locatorId, ResourceGroupComposite groupComposite) {
+ super(locatorId, groupComposite, null);
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ /**Initiates data request.
+ */
+ protected void loadData() {
+ ResourceGroup group = null;
+ GroupCategory groupCategory = null;
+ Set<ResourceTypeFacet> facets = null;
+ if ((groupComposite != null) && (groupComposite.getResourceGroup() != null)) {
+ group = groupComposite.getResourceGroup();
+ groupCategory = groupComposite.getResourceGroup().getGroupCategory();
+ //Load Facets to conditionally display relevant tabs
+ facets = groupComposite.getResourceFacets().getFacets();
+
+ getRecentAlerts();
+ //events
+ if (displayGroupEvents(groupCategory, facets)) {
+ getRecentEventUpdates();
+ }
+ //operations
+ if (displayGroupOperations(groupCategory, facets)) {
+ getRecentOperations();
+ }
+ //Config updates
+ if (displayGroupConfigurationUpdates(groupCategory, facets)) {
+ getRecentConfigurationUpdates();
+ }
+ //recentMetrics,oobs,pkghistory
+ if (groupCategory == GroupCategory.COMPATIBLE) {
+ getRecentOobs();
+ getRecentPkgHistory();
+ getRecentMetrics();
+ }
+
+ //conditionally display Bundle deployments for groups of platforms only
+ displayBundleDeploymentsForPlatformGroups(group);
+ }
+ }
+
+ /** Fetches alerts and updates the DynamicForm instance with the latest
+ * alert information.
+ */
+ private void getRecentAlerts() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ //fetches last five alerts for this resource
+ AlertCriteria criteria = new AlertCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ pageControl.initDefaultOrderingField("ctime", PageOrdering.DESC);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceGroupIds(groupId);
+ GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
+ @Override
+ public void onSuccess(PageList<Alert> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (Alert alert : result) {
+ // alert history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
+ .getPriority()), alert.getAlertDefinition().getPriority().getDisplayName());
+ LinkItem link = newLinkItem(alert.getAlertDefinition().getName() + ": ",
+ ReportDecorator.GWT_GROUP_URL + groupId + "/Alerts/History/" + alert.getId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Alerts/History/", column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
+ RECENT_ALERTS_NONE);
+ column.addMember(row);
+ }
+ for (Canvas child : recentAlertsContent.getChildren()) {
+ child.destroy();
+ }
+ recentAlertsContent.addChild(column);
+ recentAlertsContent.markForRedraw();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent alerts for group [" + groupId + "]:" + caught.getMessage());
+ }
+ });
+ }
+
+ /** Fetches operations and updates the DynamicForm instance with the latest
+ * operation information.
+ */
+ private void getRecentOperations() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ //fetches five most recent operations.
+ PageControl pageControl = new PageControl(0, 5);
+
+ GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
+ List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
+ filterResourceGroupIds.add(groupId);
+ criteria.addFilterResourceGroupIds(filterResourceGroupIds);
+ criteria.setPageControl(pageControl);
+ criteria.addSortStatus(PageOrdering.DESC);
+
+ GWTServiceLookup.getOperationService().findGroupOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupOperationHistory>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent operations for group [" + groupId + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<GroupOperationHistory> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (GroupOperationHistory report : result) {
+ // operation history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getOperationResultsIcon(report
+ .getStatus()), report.getStatus().getDisplayName());
+ LinkItem link = newLinkItem(report.getOperationDefinition().getDisplayName() + ": ",
+ ReportDecorator.GWT_GROUP_URL + groupId + "/Operations/History/" + report.getId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(report
+ .getStartedTime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Operations/History/", column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentOperationsContent
+ .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
+ column.addMember(row);
+ }
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
+ }
+ recentOperationsContent.addChild(column);
+ recentOperationsContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches configuration updates and updates the DynamicForm instance with the latest
+ * config change information.
+ */
+ private void getRecentConfigurationUpdates() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+
+ PageControl lastFive = new PageControl(0, 5);
+ GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
+ criteria.setPageControl(lastFive);
+ criteria.addSortStatus(PageOrdering.DESC);
+ List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
+ filterResourceGroupIds.add(groupId);
+ criteria.addFilterResourceGroupIds(filterResourceGroupIds);
+
+ GWTServiceLookup.getConfigurationService().findGroupResourceConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent configuration updates for group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<GroupResourceConfigurationUpdate> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (GroupResourceConfigurationUpdate update : result) {
+ // config update history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
+ .getStatus()), null);
+ String linkTitle = MSG.view_resource_inventory_activity_changed_by() + " "
+ + update.getSubjectName() + ":";
+ if ((update.getSubjectName() == null) || (update.getSubjectName().trim().isEmpty())) {
+ linkTitle = MSG.common_msg_changeAutoDetected();
+ }
+ LinkItem link = newLinkItem(linkTitle, ReportDecorator.GWT_GROUP_URL + groupId
+ + "/Configuration/History/" + update.getId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(update
+ .getCreatedTime()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Configuration/History/", column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentConfigurationContent
+ .extendLocatorId("None"), RECENT_CONFIGURATIONS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentConfigurationContent.getChildren()) {
+ child.destroy();
+ }
+ recentConfigurationContent.addChild(column);
+ recentConfigurationContent.markForRedraw();
+
+ }
+ });
+ }
+
+ /** Fetches recent events and updates the DynamicForm instance with the latest
+ * event information over last 24hrs.
+ */
+ private void getRecentEventUpdates() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ long now = System.currentTimeMillis();
+ long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
+ GWTServiceLookup.getEventService().getEventCountsBySeverityForGroup(groupId, nowMinus24Hours, now,
+ new AsyncCallback<Map<EventSeverity, Integer>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log
+ .debug("Error retrieving recent event counts for group [" + groupId + "]:"
+ + 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 = newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
+ .getLefty()), tuple.getLefty().name());
+ //count
+ StaticTextItem count = 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)));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Events/History/", column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
+ RECENT_EVENTS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentEventsContent.getChildren()) {
+ child.destroy();
+ }
+ recentEventsContent.addChild(column);
+ recentEventsContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
+ * oob change details.
+ */
+ private void getRecentOobs() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+
+ GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForGroup(groupId, 5,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent out of bound metrics for group [" + groupId + "]:"
+ + 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=" + groupId + "&mode=chartSingleMetricSingleResource";
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time = 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 = createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
+ RECENT_OOB_NONE);
+ column.addMember(row);
+ }
+ recentOobContent.setContents("");
+ for (Canvas child : recentOobContent.getChildren()) {
+ child.destroy();
+ }
+ recentOobContent.addChild(column);
+ recentOobContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches recent package history information and updates the DynamicForm instance with details.
+ */
+ private void getRecentPkgHistory() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ InstalledPackageHistoryCriteria criteria = new InstalledPackageHistoryCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ 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 = 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 = newLinkItem(title, destination);
+ StaticTextItem time = 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 = createEmptyDisplayRow(recentPkgHistoryContent.extendLocatorId("None"),
+ RECENT_PKG_HISTORY_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentPkgHistoryContent.getChildren()) {
+ child.destroy();
+ }
+ recentPkgHistoryContent.addChild(column);
+ recentPkgHistoryContent.markForRedraw();
+ }
+ });
+ }
+
+ /** 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
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+
+ //retrieve all relevant measurement definition ids.
+ Set<MeasurementDefinition> definitions = this.groupComposite.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();
+ }
+
+ //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();
+ }
+ }
+
+ //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 = newLinkItem(title, destination);
+
+ //Value
+ String convertedValue = lastValue + " " + md.getUnits();
+ convertedValue = convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = 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 = createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(recentMeasurementsContent
+ .extendLocatorId("RecentMeasurementsContentSeeMore"));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId + "/Monitoring/Graphs/", column);
+ }
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ }
+ }
+ });
+
+ //cleanup
+ for (Canvas child : recentMeasurementsContent.getChildren()) {
+ child.destroy();
+ }
+ recentMeasurementsContent.addChild(column);
+ recentMeasurementsContent.markForRedraw();
+ }
+
+ /** Fetches recent bundle deployment information and updates the DynamicForm instance with details.
+ */
+ protected void getRecentBundleDeployments() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ GroupBundleDeploymentCriteria criteria = new GroupBundleDeploymentCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ 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 = 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 = newLinkItem(title, destination);
+ StaticTextItem time = 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 = createEmptyDisplayRow(recentBundleDeployContent
+ .extendLocatorId("None"), RECENT_BUNDLE_DEPLOY_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentBundleDeployContent.getChildren()) {
+ child.destroy();
+ }
+ recentBundleDeployContent.addChild(column);
+ recentBundleDeployContent.markForRedraw();
+ }
+ });
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index aec77ac..38e09eb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -67,8 +67,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitorin
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.Activity2View;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView3;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -287,7 +287,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.summaryTab, this.summaryActivity2, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return new Activity2View(summaryActivity2.extendLocatorId("View"), resourceComposite);
+ return new ActivityView3(summaryActivity2.extendLocatorId("View"), resourceComposite);
}
});
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
deleted file mode 100644
index ad6e607..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
+++ /dev/null
@@ -1,243 +0,0 @@
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
-
-import java.util.HashMap;
-import java.util.Set;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.util.BooleanCallback;
-import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DashboardCriteria;
-import org.rhq.core.domain.dashboard.Dashboard;
-import org.rhq.core.domain.dashboard.DashboardCategory;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-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.InitializableView;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
-import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * The content pane for the resource Summary>Dashboard subtab.
- *
- * @author Jay Shaughnessy
- */
-
-public class Activity2View extends LocatableVLayout implements DashboardContainer, InitializableView {
-
- private static final String DASHBOARD_NAME_PREFIX = "ResourceDashboard_";
-
- private ResourceComposite resourceComposite;
-
- private DashboardGWTServiceAsync dashboardService = GWTServiceLookup.getDashboardService();
-
- private DashboardView dashboardView;
-
- private LocatableToolStrip footer;
- private IButton editButton;
- private IButton resetButton;
-
- // Capture the user's global permissions for use by any dashboard or portlet that may need it for rendering.
- private Set<Permission> globalPermissions;
-
- private boolean editMode = false;
-
- private boolean isInitialized = false;
-
- public Activity2View(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId);
- this.resourceComposite = resourceComposite;
- }
-
- @Override
- protected void onInit() {
- if (!isInitialized()) {
- super.onInit();
-
- // first async call to get global permissions
- new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
-
- public void onPermissionsLoaded(Set<Permission> permissions) {
- globalPermissions = permissions;
-
- // now make async call to look for customized dash for this user and entity
- DashboardCriteria criteria = new DashboardCriteria();
- criteria.addFilterCategory(DashboardCategory.RESOURCE);
- criteria.addFilterResourceId(resourceComposite.getResource().getId());
- dashboardService.findDashboardsByCriteria(criteria, new AsyncCallback<PageList<Dashboard>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error1(), caught);
- }
-
- public void onSuccess(final PageList<Dashboard> result) {
- Dashboard dashboard = result.isEmpty() ? getDefaultDashboard() : result.get(0);
- setDashboard(dashboard);
-
- isInitialized = true;
-
- // draw() may be done since onInit finishes asynchronously, if so redraw
- if (isDrawn()) {
- markForRedraw();
- }
- }
- });
- }
- });
- }
- }
-
- private void setDashboard(Dashboard dashboard) {
- Canvas[] members = getMembers();
- removeMembers(members);
- //pass in the resource information
- dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard, null,
- resourceComposite);
- addMember(dashboardView);
-
- footer = new LocatableToolStrip(extendLocatorId("Footer"));
- footer.setPadding(5);
- footer.setWidth100();
- footer.setMembersMargin(15);
-
- editButton = new LocatableIButton(footer.extendLocatorId("Mode"), editMode ? MSG.common_title_view_mode() : MSG
- .common_title_edit_mode());
- editButton.setAutoFit(true);
- editButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- editMode = !editMode;
- editButton.setTitle(editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode());
- dashboardView.setEditMode(editMode);
- }
- });
-
- resetButton = new LocatableIButton(footer.extendLocatorId("Reset"), MSG.common_button_reset());
- resetButton.setAutoFit(true);
- resetButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- String message = MSG.view_summaryDashboard_resetConfirm();
-
- SC.ask(message, new BooleanCallback() {
- public void execute(Boolean confirmed) {
- if (confirmed) {
- dashboardView.delete();
- setDashboard(getDefaultDashboard());
- markForRedraw();
- }
- }
- });
- }
- });
-
- footer.addMember(editButton);
- footer.addMember(resetButton);
-
- addMember(footer);
- }
-
- protected Dashboard getDefaultDashboard() {
- Subject sessionSubject = UserSessionManager.getSessionSubject();
- Resource resource = resourceComposite.getResource();
-
- Dashboard dashboard = new Dashboard();
-
- dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_" + resource.getId());
- dashboard.setCategory(DashboardCategory.RESOURCE);
- dashboard.setResource(resource);
- dashboard.setColumns(2);
-
- // TODO, add real portlets
- // set leftmost column and let the rest be equally divided
- dashboard.setColumnWidths("40%");
- dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
-
- //figure out which portlets to display and how
- HashMap<String, String> resKeyNameMap = PortletFactory.getRegisteredResourcePortletNameMap();
- resKeyNameMap = DashboardView.processPortletNameMapForResource(resKeyNameMap, resourceComposite);
- int colLeft = 0;
- int colRight = 1;
- int rowLeft = 0;
- int rowRight = 0;
- //Left Column
- if (resKeyNameMap.containsKey(ResourceMetricsPortlet.KEY)) {//measurments top left if available
- DashboardPortlet measurements = new DashboardPortlet(ResourceMetricsPortlet.NAME,
- ResourceMetricsPortlet.KEY, 220);
- dashboard.addPortlet(measurements, colLeft, rowLeft++);
- resKeyNameMap.remove(ResourceMetricsPortlet.KEY);
- }
-
- // right Column(approx 60%. As larger more room to display table and N rows.)
- if (resKeyNameMap.containsKey(ResourceAlertsPortlet.KEY)) {//alerts top right if available
- DashboardPortlet alerts = new DashboardPortlet(ResourceAlertsPortlet.NAME, ResourceAlertsPortlet.KEY, 220);
- dashboard.addPortlet(alerts, colRight, rowRight++);
- resKeyNameMap.remove(ResourceAlertsPortlet.KEY);
- }
- if (resKeyNameMap.containsKey(ResourceOperationsPortlet.KEY)) {//operations if available
- DashboardPortlet ops = new DashboardPortlet(ResourceOperationsPortlet.NAME, ResourceOperationsPortlet.KEY,
- 220);
- dashboard.addPortlet(ops, colRight, rowRight++);
- resKeyNameMap.remove(ResourceOperationsPortlet.KEY);
- }
-
- //Fill out left column(typically smaller portlets) then alternate cols with remaining
- boolean displayLeft = false;
- for (String key : resKeyNameMap.keySet()) {
- DashboardPortlet portlet = new DashboardPortlet(resKeyNameMap.get(key), key, 100);
- if (rowLeft < 4) {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- } else {//alternate
- if (!displayLeft) {
- dashboard.addPortlet(portlet, colRight, rowRight++);
- } else {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- }
- //toggle
- displayLeft = !displayLeft;
- }
- }
-
- return dashboard;
- }
-
- @Override
- public boolean isInitialized() {
- return isInitialized;
- }
-
- public Set<Permission> getGlobalPermissions() {
- return globalPermissions;
- }
-
- /**
- * name update not supported because the name is derived from the entity id.
- * @return
- */
- public boolean supportsDashboardNameEdit() {
- return false;
- }
-
- public void updateDashboardNames() {
- return;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
index 1ef75de..ee64837 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
@@ -1,691 +1,243 @@
-/*
- * 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.inventory.resource.detail.summary;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.ContentsType;
+import com.smartgwt.client.util.BooleanCallback;
+import com.smartgwt.client.util.SC;
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.alert.Alert;
-import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
-import org.rhq.core.domain.content.InstalledPackageHistory;
-import org.rhq.core.domain.criteria.AlertCriteria;
-import org.rhq.core.domain.criteria.InstalledPackageCriteria;
-import org.rhq.core.domain.criteria.ResourceBundleDeploymentCriteria;
-import org.rhq.core.domain.event.EventSeverity;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
-import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardCategory;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.ResourceTypeFacet;
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.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.InitializableView;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
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.BrowserUtility;
-import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
-import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
- * The content pane of the Resource Summary>Activity tab.
+ * The content pane for the resource Summary>Dashboard subtab.
*
- * @author Simeon Pinder
+ * @author Jay Shaughnessy
*/
-public class ActivityView extends AbstractActivityView {
-
- private ResourceComposite resourceComposite;
-
- public ActivityView(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId, null, resourceComposite);
- this.resourceComposite = resourceComposite;
- }
- @Override
- protected void onInit() {
- super.onInit();
- loadData();
- }
+public class ActivityView extends LocatableVLayout implements DashboardContainer, InitializableView {
- /**Initiates data request.
- */
- protected void loadData() {
-
- ResourceType type = null;
- Resource resource = null;
- Set<ResourceTypeFacet> facets = null;
-
- if ((resourceComposite != null) && (resourceComposite.getResource() != null)) {
- resource = resourceComposite.getResource();
- type = this.resourceComposite.getResource().getResourceType();
- facets = this.resourceComposite.getResourceFacets().getFacets();
-
- //alerts
- getRecentAlerts();
- //operations
- if (facets.contains(ResourceTypeFacet.OPERATION)) {
- getRecentOperations();
- }
- //config updates
- if (facets.contains(ResourceTypeFacet.CONFIGURATION)) {
- getRecentConfigurationUpdates();
- }
- //events
- if (facets.contains(ResourceTypeFacet.EVENT)) {
- getRecentEventUpdates();
- }
- //measurements
- getRecentOobs();
- getRecentPkgHistory();
- getRecentMetrics();
-
- //conditionally display Bundle Deployments region.
- if (displayBundlesForResource(resource)) {
- getRecentBundleDeployments();
- }
- }
- }
-
- /** Fetches alerts and updates the DynamicForm instance with the latest
- * alert information.
- */
- private void getRecentAlerts() {
- final int resourceId = this.resourceComposite.getResource().getId();
- //fetches last five alerts for this resource
- AlertCriteria criteria = new AlertCriteria();
- PageControl pageControl = new PageControl(0, 5);
- pageControl.initDefaultOrderingField("ctime", PageOrdering.DESC);
- criteria.setPageControl(pageControl);
- criteria.addFilterResourceIds(resourceId);
- GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
- @Override
- public void onSuccess(PageList<Alert> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (Alert alert : result) {
- // alert history records do not have a usable locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- row.setNumCols(3);
- StaticTextItem iconItem = newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
- .getPriority()), alert.getAlertDefinition().getPriority().getDisplayName());
- LinkItem link = newLinkItem(alert.getAlertDefinition().getName() + ": ",
- ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/History/" + alert.getId());
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/History/", column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
- RECENT_ALERTS_NONE);
- column.addMember(row);
- }
- for (Canvas child : recentAlertsContent.getChildren()) {
- child.destroy();
- }
- recentAlertsContent.addChild(column);
- recentAlertsContent.markForRedraw();
- }
+ private static final String DASHBOARD_NAME_PREFIX = "ResourceDashboard_";
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent alerts for resource [" + resourceId + "]:" + caught.getMessage());
- }
- });
- }
-
- /** Fetches operations and updates the DynamicForm instance with the latest
- * operation information.
- */
- private void getRecentOperations() {
- final int resourceId = this.resourceComposite.getResource().getId();
- //fetches five most recent operations.
- PageControl pageControl = new PageControl(0, 5);
- pageControl.initDefaultOrderingField("ro.createdTime", PageOrdering.DESC);
- GWTServiceLookup.getOperationService().findRecentCompletedOperations(resourceId, pageControl,
- new AsyncCallback<PageList<ResourceOperationLastCompletedComposite>>() {
-
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent operations for resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ private ResourceComposite resourceComposite;
- @Override
- public void onSuccess(PageList<ResourceOperationLastCompletedComposite> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (ResourceOperationLastCompletedComposite report : result) {
- // operation history records do not have a usable locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(3);
-
- StaticTextItem iconItem = newTextItemIcon(ImageManager.getOperationResultsIcon(report
- .getOperationStatus()), report.getOperationStatus().getDisplayName());
- LinkItem link = newLinkItem(report.getOperationName() + ": ", LinkManager
- .getResourceLink(resourceId)
- + "/Operations/History/" + report.getOperationHistoryId());
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(report
- .getOperationStartTime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
- .extendLocatorId(String.valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Operations/History/",
- column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentOperationsContent
- .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
- column.addMember(row);
- }
- for (Canvas child : recentOperationsContent.getChildren()) {
- child.destroy();
- }
- recentOperationsContent.addChild(column);
- recentOperationsContent.markForRedraw();
- }
- });
- }
+ private DashboardGWTServiceAsync dashboardService = GWTServiceLookup.getDashboardService();
- /** Fetches configuration updates and updates the DynamicForm instance with the latest
- * config change information.
- */
- private void getRecentConfigurationUpdates() {
- final int resourceId = this.resourceComposite.getResource().getId();
+ private DashboardView dashboardView;
- PageControl lastFive = new PageControl(0, 5);
- lastFive.initDefaultOrderingField("cu.createdTime", PageOrdering.DESC);
+ private LocatableToolStrip footer;
+ private IButton editButton;
+ private IButton resetButton;
- GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdates(resourceId, null, null, true,
- lastFive, new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+ // Capture the user's global permissions for use by any dashboard or portlet that may need it for rendering.
+ private Set<Permission> globalPermissions;
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent configuration updates for resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ private boolean editMode = false;
- @Override
- public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (ResourceConfigurationUpdate update : result) {
- // config update history records do not have a usable locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(3);
-
- StaticTextItem iconItem = newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
- .getStatus()), null);
- String linkTitle = MSG.view_resource_inventory_activity_changed_by() + " "
- + update.getSubjectName() + ":";
- if ((update.getSubjectName() == null) || (update.getSubjectName().trim().isEmpty())) {
- linkTitle = MSG.common_msg_changeAutoDetected();
- }
- LinkItem link = newLinkItem(linkTitle, LinkManager.getResourceLink(resourceId)
- + "/Configuration/History/" + update.getId());
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(update
- .getCreatedTime()));
+ private boolean isInitialized = false;
- row.setItems(iconItem, link, time);
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId(String.valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Configuration/History/",
- column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentConfigurationContent
- .extendLocatorId("None"), RECENT_CONFIGURATIONS_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentConfigurationContent.getChildren()) {
- child.destroy();
- }
- recentConfigurationContent.addChild(column);
- recentConfigurationContent.markForRedraw();
- }
- });
+ public ActivityView(String locatorId, ResourceComposite resourceComposite) {
+ super(locatorId);
+ this.resourceComposite = resourceComposite;
}
- /** Fetches recent events and updates the DynamicForm instance with the latest
- * event information over last 24hrs.
- */
- private void getRecentEventUpdates() {
-
- final int resourceId = this.resourceComposite.getResource().getId();
- long now = System.currentTimeMillis();
- long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
+ @Override
+ protected void onInit() {
+ if (!isInitialized()) {
+ super.onInit();
+
+ // first async call to get global permissions
+ new PermissionsLoader().loadExplicitGlobalPermissions(new PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ globalPermissions = permissions;
+
+ // now make async call to look for customized dash for this user and entity
+ DashboardCriteria criteria = new DashboardCriteria();
+ criteria.addFilterCategory(DashboardCategory.RESOURCE);
+ criteria.addFilterResourceId(resourceComposite.getResource().getId());
+ dashboardService.findDashboardsByCriteria(criteria, new AsyncCallback<PageList<Dashboard>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error1(), caught);
+ }
- GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId, nowMinus24Hours, now,
- new AsyncCallback<Map<EventSeverity, Integer>>() {
+ public void onSuccess(final PageList<Dashboard> result) {
+ Dashboard dashboard = result.isEmpty() ? getDefaultDashboard() : result.get(0);
+ setDashboard(dashboard);
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent event counts for resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ isInitialized = true;
- @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 = newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
- .getLefty()), tuple.getLefty().name());
- //count
- StaticTextItem count = newTextItem(String.valueOf(tuple.righty));
- row.setItems(iconItem, count);
-
- column.addMember(row);
+ // draw() may be done since onInit finishes asynchronously, if so redraw
+ if (isDrawn()) {
+ markForRedraw();
+ }
}
- LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Events/History/", column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
- RECENT_EVENTS_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentEventsContent.getChildren()) {
- child.destroy();
- }
- recentEventsContent.addChild(column);
- recentEventsContent.markForRedraw();
+ });
}
});
+ }
}
- /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
- * oob change details.
- */
- private void getRecentOobs() {
- final int resourceId = this.resourceComposite.getResource().getId();
- GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resourceId, 5,
- new AsyncCallback<PageList<MeasurementOOBComposite>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent out of bound metrics for resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ private void setDashboard(Dashboard dashboard) {
+ Canvas[] members = getMembers();
+ removeMembers(members);
+ //pass in the resource information
+ dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard, null,
+ resourceComposite);
+ addMember(dashboardView);
+
+ footer = new LocatableToolStrip(extendLocatorId("Footer"));
+ footer.setPadding(5);
+ footer.setWidth100();
+ footer.setMembersMargin(15);
+
+ editButton = new LocatableIButton(footer.extendLocatorId("Mode"), editMode ? MSG.common_title_view_mode() : MSG
+ .common_title_edit_mode());
+ editButton.setAutoFit(true);
+ editButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ editMode = !editMode;
+ editButton.setTitle(editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode());
+ dashboardView.setEditMode(editMode);
+ }
+ });
- @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 = newLinkItem(title, destination);
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(oob.getTimestamp()));
-
- row.setItems(link, time);
- column.addMember(row);
+ resetButton = new LocatableIButton(footer.extendLocatorId("Reset"), MSG.common_button_reset());
+ resetButton.setAutoFit(true);
+ resetButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ String message = MSG.view_summaryDashboard_resetConfirm();
+
+ SC.ask(message, new BooleanCallback() {
+ public void execute(Boolean confirmed) {
+ if (confirmed) {
+ dashboardView.delete();
+ setDashboard(getDefaultDashboard());
+ markForRedraw();
}
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
- RECENT_OOB_NONE);
- column.addMember(row);
- }
- recentOobContent.setContents("");
- for (Canvas child : recentOobContent.getChildren()) {
- child.destroy();
}
- recentOobContent.addChild(column);
- recentOobContent.markForRedraw();
- }
- });
- }
+ });
+ }
+ });
- /** Fetches recent package history information and updates the DynamicForm instance with details.
- */
- private void getRecentPkgHistory() {
- final int resourceId = this.resourceComposite.getResource().getId();
- InstalledPackageCriteria criteria = new InstalledPackageCriteria();
- criteria.addFilterResourceId(resourceId);
- PageControl pageControl = new PageControl(0, 5);
- criteria.setPageControl(pageControl);
-
- GWTServiceLookup.getContentService().getInstalledPackageHistoryForResource(resourceId, 5,
- new AsyncCallback<PageList<InstalledPackageHistory>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving installed package history for resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ footer.addMember(editButton);
+ footer.addMember(resetButton);
- @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 = 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 = newLinkItem(title, destination);
- StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(history
- .getTimestamp()));
-
- row.setItems(iconItem, link, time);
- column.addMember(row);
- }
- // //insert see more link
- // LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
- // .extendLocatorId("RecentPkgHistorySeeMore"));
- // String destination = "/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId;
- // addSeeMoreLink(row, destination, column);
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentPkgHistoryContent
- .extendLocatorId("None"), RECENT_PKG_HISTORY_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentPkgHistoryContent.getChildren()) {
- child.destroy();
- }
- recentPkgHistoryContent.addChild(column);
- recentPkgHistoryContent.markForRedraw();
- }
- });
+ addMember(footer);
}
- /** 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
- final int resourceId = this.resourceComposite.getResource().getId();
-
- //retrieve all relevant measurement definition ids.
- Set<MeasurementDefinition> definitions = this.resourceComposite.getResource().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);
+ protected Dashboard getDefaultDashboard() {
+ Subject sessionSubject = UserSessionManager.getSessionSubject();
+ Resource resource = resourceComposite.getResource();
+
+ Dashboard dashboard = new Dashboard();
+
+ dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_" + resource.getId());
+ dashboard.setCategory(DashboardCategory.RESOURCE);
+ dashboard.setResource(resource);
+ dashboard.setColumns(2);
+
+ // TODO, add real portlets
+ // set leftmost column and let the rest be equally divided
+ dashboard.setColumnWidths("40%");
+ dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
+
+ //figure out which portlets to display and how
+ HashMap<String, String> resKeyNameMap = PortletFactory.getRegisteredResourcePortletNameMap();
+ resKeyNameMap = DashboardView.processPortletNameMapForResource(resKeyNameMap, resourceComposite);
+ int colLeft = 0;
+ int colRight = 1;
+ int rowLeft = 0;
+ int rowRight = 0;
+ //Left Column
+ if (resKeyNameMap.containsKey(ResourceMetricsPortlet.KEY)) {//measurments top left if available
+ DashboardPortlet measurements = new DashboardPortlet(ResourceMetricsPortlet.NAME,
+ ResourceMetricsPortlet.KEY, 220);
+ dashboard.addPortlet(measurements, colLeft, rowLeft++);
+ resKeyNameMap.remove(ResourceMetricsPortlet.KEY);
}
- //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();
+ // right Column(approx 60%. As larger more room to display table and N rows.)
+ if (resKeyNameMap.containsKey(ResourceAlertsPortlet.KEY)) {//alerts top right if available
+ DashboardPortlet alerts = new DashboardPortlet(ResourceAlertsPortlet.NAME, ResourceAlertsPortlet.KEY, 220);
+ dashboard.addPortlet(alerts, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceAlertsPortlet.KEY);
+ }
+ if (resKeyNameMap.containsKey(ResourceOperationsPortlet.KEY)) {//operations if available
+ DashboardPortlet ops = new DashboardPortlet(ResourceOperationsPortlet.NAME, ResourceOperationsPortlet.KEY,
+ 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceOperationsPortlet.KEY);
}
- //make the asynchronous call for all the measurement data
- GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId, 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 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();
- }
- }
+ //Fill out left column(typically smaller portlets) then alternate cols with remaining
+ boolean displayLeft = false;
+ for (String key : resKeyNameMap.keySet()) {
+ DashboardPortlet portlet = new DashboardPortlet(resKeyNameMap.get(key), key, 100);
+ if (rowLeft < 4) {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ }
+ //toggle
+ displayLeft = !displayLeft;
+ }
+ }
- //collapse the data into comma delimited list for consumption by third party javascript library(jquery.sparkline)
- String commaDelimitedList = "";
+ return dashboard;
+ }
- 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();
- LinkItem link = newLinkItem(title, destination);
-
- //Value
- String convertedValue = lastValue + " " + md.getUnits();
- convertedValue = convertLastValueForDisplay(lastValue, md);
- StaticTextItem value = 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 = createEmptyDisplayRow(recentMeasurementsContent
- .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- } else {
- //insert see more link
- LocatableDynamicForm row = new LocatableDynamicForm(recentMeasurementsContent
- .extendLocatorId("RecentMeasurementsContentSeeMore"));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Monitoring/Graphs/",
- column);
- }
- //call out to 3rd party javascript lib
- BrowserUtility.graphSparkLines();
- } else {
- LocatableDynamicForm row = createEmptyDisplayRow(recentMeasurementsContent
- .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- }
- }
- });
+ @Override
+ public boolean isInitialized() {
+ return isInitialized;
+ }
- //cleanup
- for (Canvas child : recentMeasurementsContent.getChildren()) {
- child.destroy();
- }
- recentMeasurementsContent.addChild(column);
- recentMeasurementsContent.markForRedraw();
+ public Set<Permission> getGlobalPermissions() {
+ return globalPermissions;
}
- /** Fetches recent bundle deployment information and updates the DynamicForm instance with details.
+ /**
+ * name update not supported because the name is derived from the entity id.
+ * @return
*/
- protected void getRecentBundleDeployments() {
- final int resourceId = this.resourceComposite.getResource().getId();
- ResourceBundleDeploymentCriteria criteria = new ResourceBundleDeploymentCriteria();
- PageControl pageControl = new PageControl(0, 5);
- 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());
- }
+ public boolean supportsDashboardNameEdit() {
+ return false;
+ }
- @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 = 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 = newLinkItem(title, destination);
- StaticTextItem time = 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 = createEmptyDisplayRow(recentBundleDeployContent
- .extendLocatorId("None"), RECENT_BUNDLE_DEPLOY_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentBundleDeployContent.getChildren()) {
- child.destroy();
- }
- recentBundleDeployContent.addChild(column);
- recentBundleDeployContent.markForRedraw();
- }
- });
+ public void updateDashboardNames() {
+ return;
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView3.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView3.java
new file mode 100644
index 0000000..355a19a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView3.java
@@ -0,0 +1,691 @@
+/*
+ * 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.inventory.resource.detail.summary;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.allen_sauer.gwt.log.client.Log;
+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.alert.Alert;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.content.InstalledPackageHistory;
+import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.criteria.InstalledPackageCriteria;
+import org.rhq.core.domain.criteria.ResourceBundleDeploymentCriteria;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
+import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.ResourceTypeFacet;
+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.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+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.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * The content pane of the Resource Summary>Activity tab.
+ *
+ * @author Simeon Pinder
+ */
+public class ActivityView3 extends AbstractActivityView {
+
+ private ResourceComposite resourceComposite;
+
+ public ActivityView3(String locatorId, ResourceComposite resourceComposite) {
+ super(locatorId, null, resourceComposite);
+ this.resourceComposite = resourceComposite;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ /**Initiates data request.
+ */
+ protected void loadData() {
+
+ ResourceType type = null;
+ Resource resource = null;
+ Set<ResourceTypeFacet> facets = null;
+
+ if ((resourceComposite != null) && (resourceComposite.getResource() != null)) {
+ resource = resourceComposite.getResource();
+ type = this.resourceComposite.getResource().getResourceType();
+ facets = this.resourceComposite.getResourceFacets().getFacets();
+
+ //alerts
+ getRecentAlerts();
+ //operations
+ if (facets.contains(ResourceTypeFacet.OPERATION)) {
+ getRecentOperations();
+ }
+ //config updates
+ if (facets.contains(ResourceTypeFacet.CONFIGURATION)) {
+ getRecentConfigurationUpdates();
+ }
+ //events
+ if (facets.contains(ResourceTypeFacet.EVENT)) {
+ getRecentEventUpdates();
+ }
+ //measurements
+ getRecentOobs();
+ getRecentPkgHistory();
+ getRecentMetrics();
+
+ //conditionally display Bundle Deployments region.
+ if (displayBundlesForResource(resource)) {
+ getRecentBundleDeployments();
+ }
+ }
+ }
+
+ /** Fetches alerts and updates the DynamicForm instance with the latest
+ * alert information.
+ */
+ private void getRecentAlerts() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ //fetches last five alerts for this resource
+ AlertCriteria criteria = new AlertCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ pageControl.initDefaultOrderingField("ctime", PageOrdering.DESC);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceIds(resourceId);
+ GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
+ @Override
+ public void onSuccess(PageList<Alert> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (Alert alert : result) {
+ // alert history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ row.setNumCols(3);
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
+ .getPriority()), alert.getAlertDefinition().getPriority().getDisplayName());
+ LinkItem link = newLinkItem(alert.getAlertDefinition().getName() + ": ",
+ ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/History/" + alert.getId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Alerts/History/", column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
+ RECENT_ALERTS_NONE);
+ column.addMember(row);
+ }
+ for (Canvas child : recentAlertsContent.getChildren()) {
+ child.destroy();
+ }
+ recentAlertsContent.addChild(column);
+ recentAlertsContent.markForRedraw();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent alerts for resource [" + resourceId + "]:" + caught.getMessage());
+ }
+ });
+ }
+
+ /** Fetches operations and updates the DynamicForm instance with the latest
+ * operation information.
+ */
+ private void getRecentOperations() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ //fetches five most recent operations.
+ PageControl pageControl = new PageControl(0, 5);
+ pageControl.initDefaultOrderingField("ro.createdTime", PageOrdering.DESC);
+ GWTServiceLookup.getOperationService().findRecentCompletedOperations(resourceId, pageControl,
+ new AsyncCallback<PageList<ResourceOperationLastCompletedComposite>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent operations for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceOperationLastCompletedComposite> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (ResourceOperationLastCompletedComposite report : result) {
+ // operation history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getOperationResultsIcon(report
+ .getOperationStatus()), report.getOperationStatus().getDisplayName());
+ LinkItem link = newLinkItem(report.getOperationName() + ": ", LinkManager
+ .getResourceLink(resourceId)
+ + "/Operations/History/" + report.getOperationHistoryId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(report
+ .getOperationStartTime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Operations/History/",
+ column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentOperationsContent
+ .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
+ column.addMember(row);
+ }
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
+ }
+ recentOperationsContent.addChild(column);
+ recentOperationsContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches configuration updates and updates the DynamicForm instance with the latest
+ * config change information.
+ */
+ private void getRecentConfigurationUpdates() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+
+ PageControl lastFive = new PageControl(0, 5);
+ lastFive.initDefaultOrderingField("cu.createdTime", PageOrdering.DESC);
+
+ GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdates(resourceId, null, null, true,
+ lastFive, new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent configuration updates for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceConfigurationUpdate> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (ResourceConfigurationUpdate update : result) {
+ // config update history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
+ .getStatus()), null);
+ String linkTitle = MSG.view_resource_inventory_activity_changed_by() + " "
+ + update.getSubjectName() + ":";
+ if ((update.getSubjectName() == null) || (update.getSubjectName().trim().isEmpty())) {
+ linkTitle = MSG.common_msg_changeAutoDetected();
+ }
+ LinkItem link = newLinkItem(linkTitle, LinkManager.getResourceLink(resourceId)
+ + "/Configuration/History/" + update.getId());
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(update
+ .getCreatedTime()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Configuration/History/",
+ column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentConfigurationContent
+ .extendLocatorId("None"), RECENT_CONFIGURATIONS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentConfigurationContent.getChildren()) {
+ child.destroy();
+ }
+ recentConfigurationContent.addChild(column);
+ recentConfigurationContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches recent events and updates the DynamicForm instance with the latest
+ * event information over last 24hrs.
+ */
+ private void getRecentEventUpdates() {
+
+ final int resourceId = this.resourceComposite.getResource().getId();
+ long now = System.currentTimeMillis();
+ long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
+
+ GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId, nowMinus24Hours, now,
+ new AsyncCallback<Map<EventSeverity, Integer>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent 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 = newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
+ .getLefty()), tuple.getLefty().name());
+ //count
+ StaticTextItem count = newTextItem(String.valueOf(tuple.righty));
+ row.setItems(iconItem, count);
+
+ column.addMember(row);
+ }
+ LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Events/History/", column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
+ RECENT_EVENTS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentEventsContent.getChildren()) {
+ child.destroy();
+ }
+ recentEventsContent.addChild(column);
+ recentEventsContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
+ * oob change details.
+ */
+ private void getRecentOobs() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resourceId, 5,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent 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 = newLinkItem(title, destination);
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(oob.getTimestamp()));
+
+ row.setItems(link, time);
+ column.addMember(row);
+ }
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
+ RECENT_OOB_NONE);
+ column.addMember(row);
+ }
+ recentOobContent.setContents("");
+ for (Canvas child : recentOobContent.getChildren()) {
+ child.destroy();
+ }
+ recentOobContent.addChild(column);
+ recentOobContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches recent package history information and updates the DynamicForm instance with details.
+ */
+ private void getRecentPkgHistory() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ InstalledPackageCriteria criteria = new InstalledPackageCriteria();
+ criteria.addFilterResourceId(resourceId);
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+
+ GWTServiceLookup.getContentService().getInstalledPackageHistoryForResource(resourceId, 5,
+ new AsyncCallback<PageList<InstalledPackageHistory>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed package history for resource [" + 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 = 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 = newLinkItem(title, destination);
+ StaticTextItem time = newTextItem(GwtRelativeDurationConverter.format(history
+ .getTimestamp()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ // //insert see more link
+ // LocatableDynamicForm row = new LocatableDynamicForm(recentPkgHistoryContent
+ // .extendLocatorId("RecentPkgHistorySeeMore"));
+ // String destination = "/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId;
+ // addSeeMoreLink(row, destination, column);
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentPkgHistoryContent
+ .extendLocatorId("None"), RECENT_PKG_HISTORY_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentPkgHistoryContent.getChildren()) {
+ child.destroy();
+ }
+ recentPkgHistoryContent.addChild(column);
+ recentPkgHistoryContent.markForRedraw();
+ }
+ });
+ }
+
+ /** 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
+ final int resourceId = this.resourceComposite.getResource().getId();
+
+ //retrieve all relevant measurement definition ids.
+ Set<MeasurementDefinition> definitions = this.resourceComposite.getResource().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();
+ }
+ //make the asynchronous call for all the measurement data
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId, 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 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();
+ LinkItem link = newLinkItem(title, destination);
+
+ //Value
+ String convertedValue = lastValue + " " + md.getUnits();
+ convertedValue = convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = 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 = createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new LocatableDynamicForm(recentMeasurementsContent
+ .extendLocatorId("RecentMeasurementsContentSeeMore"));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId + "/Monitoring/Graphs/",
+ column);
+ }
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row = createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"), RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ }
+ }
+ });
+
+ //cleanup
+ for (Canvas child : recentMeasurementsContent.getChildren()) {
+ child.destroy();
+ }
+ recentMeasurementsContent.addChild(column);
+ recentMeasurementsContent.markForRedraw();
+ }
+
+ /** Fetches recent bundle deployment information and updates the DynamicForm instance with details.
+ */
+ protected void getRecentBundleDeployments() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ ResourceBundleDeploymentCriteria criteria = new ResourceBundleDeploymentCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ 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 = 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 = newLinkItem(title, destination);
+ StaticTextItem time = 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 = createEmptyDisplayRow(recentBundleDeployContent
+ .extendLocatorId("None"), RECENT_BUNDLE_DEPLOY_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentBundleDeployContent.getChildren()) {
+ child.destroy();
+ }
+ recentBundleDeployContent.addChild(column);
+ recentBundleDeployContent.markForRedraw();
+ }
+ });
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index df35e27..f9ac79c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -291,7 +291,9 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
public void refresh() {
try {
super.refresh();
- getListGrid().setRecords(transform(CoreGUI.getMessageCenter().getMessages()));
+ if ((getListGrid() != null) && (CoreGUI.getMessageCenter().getMessages() != null)) {
+ getListGrid().setRecords(transform(CoreGUI.getMessageCenter().getMessages()));
+ }
refreshTableInfo();
} catch (Throwable e) {
Log.error("Cannot refresh messages", e);
commit b0a6460388ce646db376eebad485212f7d7427d1
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sun Mar 20 22:15:48 2011 -0400
i)fix for MeasurementRangeEditor alignment issue
ii)configuration editor widget property cleanup
iii)fix icon refresh issue with event portlets
iv)fix data init duplication issue with resourceOperationsPortlet
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
index d8c69b8..1978665 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
@@ -219,6 +219,7 @@ public abstract class AbstractMeasurementRangeEditor extends LocatableDynamicFor
advancedStartItem.enable();
advancedEndItem.enable();
advancedSimpleButton.enable();
+ markForRedraw();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
index 01794cb..f349f5d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
@@ -36,8 +36,8 @@ public class CustomConfigMeasurementRangeEditor extends AbstractMeasurementRange
public static final String ALERT_METRIC_RANGE_ENABLE = Constant.METRIC_RANGE_ENABLE;
public static final String DEFAULT_VALUE_RANGE_RO = Boolean.FALSE.toString();
- public static final Integer DEFAULT_VALUE_RANGE_LASTN = Integer.valueOf(8);
- public static final Integer DEFAULT_VALUE_RANGE_UNIT = Integer.valueOf(3);
+ public static final Integer DEFAULT_VALUE_RANGE_LASTN = Integer.valueOf(Constant.METRIC_RANGE_LASTN_DEFAULT);
+ public static final Integer DEFAULT_VALUE_RANGE_UNIT = Integer.valueOf(Constant.METRIC_RANGE_UNIT_DEFAULT);
private ConfigurationMeasurementPreferences measurementPrefs;
@@ -106,7 +106,7 @@ public class CustomConfigMeasurementRangeEditor extends AbstractMeasurementRange
if (metricRangePreferences == null) {
metricRangePreferences = new MetricRangePreferences();
}
- // //parse config and lazily init timing elements
+ //parse config and lazily init timing elements
metricRangePreferences.explicitBeginEnd = Boolean.valueOf(
config.getSimple(PREF_METRIC_RANGE_BEGIN_END_FLAG).getStringValue()).booleanValue();
//check to display advanced settings widget components
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 6eb15c4..cea94a9 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
@@ -46,41 +46,50 @@ public class PortletConfigurationEditorComponent {
public interface Constant {
String ALERT_PRIORITY = "ALERT_PRIORITY";
+ String ALERT_PRIORITY_DEFAULT = "";//all priorities==no priorities
String METRIC_RANGE_ENABLE = "METRIC_RANGE_ENABLE";
+ String METRIC_RANGE_ENABLE_DEFAULT = String.valueOf(false);//disabled
String METRIC_RANGE_BEGIN_END_FLAG = "METRIC_RANGE_BEGIN_END_FLAG";
+ String METRIC_RANGE_BEGIN_END_FLAG_DEFAULT = String.valueOf(false);//disabled
String METRIC_RANGE = "METRIC_RANGE";
+ String METRIC_RANGE_DEFAULT = "";//no previous range.
String METRIC_RANGE_LASTN = "METRIC_RANGE_LASTN";
String METRIC_RANGE_LASTN_DEFAULT = String.valueOf(8);
String METRIC_RANGE_UNIT = "METRIC_RANGE_UNIT";
String METRIC_RANGE_UNIT_DEFAULT = String.valueOf(MeasurementUtility.UNIT_HOURS);
String RESULT_SEVERITY = "severities";
+ String RESULT_SEVERITY_DEFAULT = "";//all severities
String RESULT_SORT_ORDER = "RESULT_SORT_ORDER";
+ String RESULT_SORT_ORDER_DEFAULT = PageOrdering.DESC.name();//descending
String RESULT_SORT_PRIORITY = "sort.priority";
+ // String RESULT_SORT_PRIORITY_DEFAULT = "sort.priority";
String RESULT_COUNT = "RESULT_COUNT";
String RESULT_COUNT_DEFAULT = "5";
String CUSTOM_REFRESH = "CUSTOM_REFRESH";
String OPERATION_STATUS = "OPERATION_STATUS";
+ String OPERATION_STATUS_DEFAULT = "";//empty
}
//configuration map initialization
public static Map<String, String> CONFIG_PROPERTY_INITIALIZATION = new HashMap<String, String>();
static {// Key, Default value
//alert priority, if empty initialize to "" i.e. all priorities
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.ALERT_PRIORITY, "");
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.ALERT_PRIORITY, Constant.ALERT_PRIORITY_DEFAULT);
//result sort order, if empty initialize to "DESC"
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.RESULT_SORT_ORDER, PageOrdering.DESC.name());
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.RESULT_SORT_ORDER, Constant.RESULT_SORT_ORDER_DEFAULT);
//result count, if empty initialize to 5
CONFIG_PROPERTY_INITIALIZATION.put(Constant.RESULT_COUNT, Constant.RESULT_COUNT_DEFAULT);
//whether to specify time range for alerts. Defaults to false
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_ENABLE, String.valueOf(false));
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_ENABLE, Constant.METRIC_RANGE_ENABLE_DEFAULT);
//whether Begin and End values set for time. Aka. Advanced/full range setting Defaults to false
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_BEGIN_END_FLAG, String.valueOf(false));
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_BEGIN_END_FLAG,
+ Constant.METRIC_RANGE_BEGIN_END_FLAG_DEFAULT);
//whether in simple mode. Ex. 8 hrs. Defaults to 8
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_LASTN, Constant.METRIC_RANGE_LASTN_DEFAULT);
- //whether in simple mode. Ex. 8 hrs. Defaults to 8
+ //whether in simple mode. Ex. hrs. Defaults to hours
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_UNIT, Constant.METRIC_RANGE_UNIT_DEFAULT);
//operation status, if empty initialize to "" i.e. all stati
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS, "");
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS, Constant.OPERATION_STATUS_DEFAULT);
}
/* Single select combobox for number of items to display on the dashboard
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
index 120c974..4fa8807 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
@@ -273,7 +273,6 @@ public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettin
refreshTimer = new Timer() {
public void run() {
-
redraw();
}
};
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 2ee782e..35d5886 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
@@ -250,6 +250,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
column.addMember(row);
}
+ column.markForRedraw();
//insert see more link
LocatableDynamicForm row = new LocatableDynamicForm(recentEventsContent.extendLocatorId(String
.valueOf(rowNum)));
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 0e2e00c..e148b1e 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
@@ -58,7 +58,6 @@ 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.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;
@@ -83,7 +82,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
// set on initial configuration, the window for this portlet view.
protected PortletWindow portletWindow;
- protected GroupOperationsCriteriaHistoryListView dataSource;
+ private GroupOperationsCriteriaHistoryListView groupOperations;
//defines the list of configuration elements to load/persist for this portlet
protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
@@ -111,7 +110,6 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
protected String baseViewPath = "";
protected LocatableCanvas recentOperationsContent = new LocatableCanvas(extendLocatorId("RecentOperations"));
protected String locatorId;
- private GroupOperationsCriteriaHistoryListView groupOperations;
public GroupOperationsPortlet(String locatorId) {
super(locatorId);
@@ -233,7 +231,6 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
form.setMargin(5);
//add label about what configuration affects? redundant?
-
//add filter operation status type selector
final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
.getOperationStatusEditor(portletConfig);
@@ -256,7 +253,6 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
public void onSubmitValues(SubmitValuesEvent event) {
//result count
- String selectedValue;
portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
//time range configuration
@@ -350,16 +346,16 @@ class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListVi
private ResourceGroupComposite composite;
- public GroupOperationsCriteriaHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource,
+ public GroupOperationsCriteriaHistoryListView(String locatorId, GroupOperationsCriteriaDataSource dataSource,
String title, Criteria criteria, ResourceGroupComposite composite) {
super(locatorId, composite);
- setDataSource(dataSource);
+ super.setDataSource(dataSource);
this.composite = composite;
setShowFooterRefresh(false); //disable footer refresh
}
- public void setDatasource(AbstractOperationHistoryDataSource datasource) {
- setDataSource(datasource);
+ public void setDatasource(GroupOperationsCriteriaDataSource datasource) {
+ super.setDataSource(datasource);
}
@Override
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
index 01a0b96..d915351 100644
--- 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
@@ -60,7 +60,6 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
//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]);
}
@@ -157,7 +156,6 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
//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 {
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
index 96be005..30929c1 100644
--- 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
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
+import java.util.ArrayList;
+
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -25,6 +27,10 @@ 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.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;
@@ -37,15 +43,20 @@ 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.components.measurement.CustomConfigMeasurementRangeEditor;
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;
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.common.detail.summary.AbstractActivityView;
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;
+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;
/**
* @author Simeon Pinder
@@ -74,11 +85,73 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
@Override
protected void onInit() {
- super.onInit();
+ // super.onInit();
initializeUi();
+ // loadData();
+ }
+
+ @Override
+ public void redraw() {
loadData();
}
+ @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
+ 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
+ resourceOperations.setDatasource(new ResourceOperationsCriteriaDataSource(portletConfig));
+ //apply latest settings to the visible result set
+ redraw();
+ }
+ });
+ form.markForRedraw();
+ page.addMember(measurementRangeEditor);
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
private void loadData() {
//populate composite data
ResourceCriteria criteria = new ResourceCriteria();
@@ -134,9 +207,9 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
*/
class ResourceOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView {
- private AbstractOperationHistoryDataSource datasource;
+ private ResourceOperationsCriteriaDataSource datasource;
- public ResourceOperationsCriteriaHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource,
+ public ResourceOperationsCriteriaHistoryListView(String locatorId, ResourceOperationsCriteriaDataSource dataSource,
String title, Criteria criteria, ResourceComposite composite) {
super(locatorId, dataSource, title, criteria);
this.datasource = dataSource;
@@ -156,11 +229,11 @@ class ResourceOperationsCriteriaHistoryListView extends AbstractOperationHistory
return new ResourceOperationHistoryDetailsView(extendLocatorId("DetailsView"), this.resourceComposite);
}
- public AbstractOperationHistoryDataSource getDatasource() {
+ public ResourceOperationsCriteriaDataSource getDatasource() {
return datasource;
}
- public void setDatasource(AbstractOperationHistoryDataSource datasource) {
+ public void setDatasource(ResourceOperationsCriteriaDataSource datasource) {
this.datasource = datasource;
}
@@ -219,12 +292,34 @@ class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataS
//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);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- criteria.addFilterStartTime(Long.valueOf(range[0]));
- criteria.addFilterEndTime(Long.valueOf(range[1]));
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ 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]));
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
}
}
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 c67dce9..2da6e15 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
@@ -58,6 +58,7 @@ import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfig
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;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.measurement.GwtMonitorUtils;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -517,29 +518,40 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
//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.
- boolean isAdvanceTimeSetting = false;
- selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
- if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
- isAdvanceTimeSetting = Boolean.valueOf(selectedValue);
- }
-
- //time frame
- List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (isAdvanceTimeSetting) {//advanced settings
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
- } else {
- //save not advanced time range
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN, measurementRangeEditor
- .getMetricRangePreferences().lastN));
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT, measurementRangeEditor
- .getMetricRangePreferences().unit));
+ boolean persistTimeRangeSettings = itemC.getValueAsBoolean();
+ if (persistTimeRangeSettings) {//retrieve values and persist
+ 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.
+ boolean isAdvanceTimeSetting = false;
+ selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
+ if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ isAdvanceTimeSetting = Boolean.valueOf(selectedValue);
+ }
+
+ //time frame
+ List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
+ if (isAdvanceTimeSetting) {//advanced settings
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
+ } else {
+ //save not advanced time range
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN, measurementRangeEditor
+ .getMetricRangePreferences().lastN));
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT, measurementRangeEditor
+ .getMetricRangePreferences().unit));
+ }
+ } else {//if disabled, reset time defaults
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, false));
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, false));
+ List<Long> rangeArray = MeasurementUtility.calculateTimeFrame(Integer
+ .valueOf(Constant.METRIC_RANGE_LASTN_DEFAULT), Integer.valueOf(Constant.METRIC_RANGE_UNIT_DEFAULT));
+ // String[] range = {String.valueOf(rangeArray.get(0)),String.valueOf(rangeArray.get(1))};
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
+ (String.valueOf(rangeArray.get(0)) + "," + String.valueOf(rangeArray.get(1)))));
}
}
return portletConfig;
commit e581e677447f29be3be27fedf9849284e299c1b4
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 19 21:18:13 2011 -0400
i)edit config bug ii)fix dashboard edit mode on init iii)display messages.
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 1d17199..a1a1c98 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
@@ -460,7 +460,6 @@ public class DashboardView extends LocatableVLayout {
this.refreshMenuButton.markForRedraw();
markForRedraw();
//attempt to initialize
- editForm.show();
editForm.markForRedraw();
markForRedraw();
}
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 c02f378..6eb15c4 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
@@ -33,6 +33,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
/** Shared portlet configuration component where initial configuration settings
* and widgets shared across portlet editors is defined.
@@ -51,6 +52,7 @@ public class PortletConfigurationEditorComponent {
String METRIC_RANGE_LASTN = "METRIC_RANGE_LASTN";
String METRIC_RANGE_LASTN_DEFAULT = String.valueOf(8);
String METRIC_RANGE_UNIT = "METRIC_RANGE_UNIT";
+ String METRIC_RANGE_UNIT_DEFAULT = String.valueOf(MeasurementUtility.UNIT_HOURS);
String RESULT_SEVERITY = "severities";
String RESULT_SORT_ORDER = "RESULT_SORT_ORDER";
String RESULT_SORT_PRIORITY = "sort.priority";
@@ -75,6 +77,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);
+ //whether in simple mode. Ex. 8 hrs. Defaults to 8
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_UNIT, Constant.METRIC_RANGE_UNIT_DEFAULT);
//operation status, if empty initialize to "" i.e. all stati
CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS, "");
}
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 2e37d6c..aebcd71 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
@@ -1472,7 +1472,7 @@ 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.
-view_portlet_help_eventcounts = This portlet displays Event counts based consistent with display criteria configured.
+view_portlet_help_eventcounts = This portlet displays Event counts 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.
view_portlet_help_inventorySummary = This portlet displays a short summary of the current user''s viewable inventory and metric collection rate.
commit 4fc496a1cf495e44ed2cd19a21f2d69998c23031
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 19 19:28:35 2011 -0400
define default portlet ordering for res and group portlets.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
index 5f2de37..af8d09c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
+import java.util.HashMap;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -45,7 +46,10 @@ import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -180,25 +184,52 @@ public class ActivityView2 extends LocatableVLayout implements DashboardContaine
dashboard.setGroup(group);
dashboard.setColumns(2);
- // TODO, add real portlets
// set leftmost column and let the rest be equally divided
dashboard.setColumnWidths("40%");
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
- // Left Column
- // DashboardPortlet dummyLeft = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 220);
- // dummyLeft.getConfiguration().put(new PropertySimple("message", "<br/>Coming Soon... :-)"));
- // dashboard.addPortlet(dummyLeft, 0, 0);
-
- // DashboardPortlet groupAlerts = new DashboardPortlet(GroupAlertsPortlet3.NAME, GroupAlertsPortlet3.KEY, 220);
- // groupAlerts.getConfiguration().put(new PropertySimple("message", "<br/>Coming Soon... :-)"));
- // dashboard.addPortlet(groupAlerts, 0, 0);
+ //figure out which portlets to display and how
+ HashMap<String, String> groupKeyNameMap = PortletFactory.getRegisteredGroupPortletNameMap();
+ groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap, groupComposite);
+ int colLeft = 0;
+ int colRight = 1;
+ int rowLeft = 0;
+ int rowRight = 0;
+ //Left Column
+ if (groupKeyNameMap.containsKey(GroupMetricsPortlet.KEY)) {//measurments top left if available
+ DashboardPortlet measurements = new DashboardPortlet(GroupMetricsPortlet.NAME, GroupMetricsPortlet.KEY, 220);
+ dashboard.addPortlet(measurements, colLeft, rowLeft++);
+ groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
+ }
- // right Column
- DashboardPortlet dummyRight = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 220);
- dummyRight.getConfiguration().put(new PropertySimple("message", "<br/>Coming Soon... :-)"));
- dashboard.addPortlet(dummyRight, 1, 0);
+ // right Column(approx 60%. As larger more room to display table and N rows.)
+ if (groupKeyNameMap.containsKey(GroupAlertsPortlet.KEY)) {//alerts top right if available
+ DashboardPortlet alerts = new DashboardPortlet(GroupAlertsPortlet.NAME, GroupAlertsPortlet.KEY, 220);
+ dashboard.addPortlet(alerts, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupAlertsPortlet.KEY);
+ }
+ if (groupKeyNameMap.containsKey(GroupOperationsPortlet.KEY)) {//operations if available
+ DashboardPortlet ops = new DashboardPortlet(GroupOperationsPortlet.NAME, GroupOperationsPortlet.KEY, 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
+ }
+ //Fill out left column(typically smaller portlets) then alternate cols with remaining
+ boolean displayLeft = false;
+ for (String key : groupKeyNameMap.keySet()) {
+ DashboardPortlet portlet = new DashboardPortlet(groupKeyNameMap.get(key), key, 100);
+ if (rowLeft < 4) {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ }
+ //toggle
+ displayLeft = !displayLeft;
+ }
+ }
return dashboard;
}
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 20b5e65..ad6e607 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
@@ -1,5 +1,6 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
+import java.util.HashMap;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -27,7 +28,10 @@ import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -167,15 +171,50 @@ public class Activity2View extends LocatableVLayout implements DashboardContaine
dashboard.setColumnWidths("40%");
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
- // Left Column
- DashboardPortlet dummyLeft = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 220);
- dummyLeft.getConfiguration().put(new PropertySimple("message", "<br/>Coming Soon... :-)"));
- dashboard.addPortlet(dummyLeft, 0, 0);
+ //figure out which portlets to display and how
+ HashMap<String, String> resKeyNameMap = PortletFactory.getRegisteredResourcePortletNameMap();
+ resKeyNameMap = DashboardView.processPortletNameMapForResource(resKeyNameMap, resourceComposite);
+ int colLeft = 0;
+ int colRight = 1;
+ int rowLeft = 0;
+ int rowRight = 0;
+ //Left Column
+ if (resKeyNameMap.containsKey(ResourceMetricsPortlet.KEY)) {//measurments top left if available
+ DashboardPortlet measurements = new DashboardPortlet(ResourceMetricsPortlet.NAME,
+ ResourceMetricsPortlet.KEY, 220);
+ dashboard.addPortlet(measurements, colLeft, rowLeft++);
+ resKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ }
+
+ // right Column(approx 60%. As larger more room to display table and N rows.)
+ if (resKeyNameMap.containsKey(ResourceAlertsPortlet.KEY)) {//alerts top right if available
+ DashboardPortlet alerts = new DashboardPortlet(ResourceAlertsPortlet.NAME, ResourceAlertsPortlet.KEY, 220);
+ dashboard.addPortlet(alerts, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceAlertsPortlet.KEY);
+ }
+ if (resKeyNameMap.containsKey(ResourceOperationsPortlet.KEY)) {//operations if available
+ DashboardPortlet ops = new DashboardPortlet(ResourceOperationsPortlet.NAME, ResourceOperationsPortlet.KEY,
+ 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceOperationsPortlet.KEY);
+ }
- // right Column
- DashboardPortlet dummyRight = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 220);
- dummyRight.getConfiguration().put(new PropertySimple("message", "<br/>Coming Soon... :-)"));
- dashboard.addPortlet(dummyRight, 1, 0);
+ //Fill out left column(typically smaller portlets) then alternate cols with remaining
+ boolean displayLeft = false;
+ for (String key : resKeyNameMap.keySet()) {
+ DashboardPortlet portlet = new DashboardPortlet(resKeyNameMap.get(key), key, 100);
+ if (rowLeft < 4) {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ }
+ //toggle
+ displayLeft = !displayLeft;
+ }
+ }
return dashboard;
}
commit a5993d8891b49bbba0d897f8d44b0e3b1609b9d9
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 19 18:45:35 2011 -0400
i)conditionally render available dash portlets based on group/resource
ii)groupEvents portlet refresh issue
iii)groupOperationsPortlet null link fix.
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 25923ba..1d17199 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
@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.TreeMap;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.AnimationCallback;
@@ -48,14 +49,32 @@ import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.dashboard.Dashboard;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceTypeFacet;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+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.PageControl;
+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.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.form.ColorButtonItem;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
+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.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.ResourceOperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourcePkgHistoryPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -94,8 +113,10 @@ public class DashboardView extends LocatableVLayout {
private int refreshInterval = 0;
private LocatableIMenuButton refreshMenuButton;
private HashMap<String, PortletViewFactory> portletMap = null;
- private ResourceGroup focusGroup = null;
- private Resource focusResource = null;
+ private ResourceGroup group = null;
+ private ResourceGroupComposite groupComposite = null;
+ private Resource resource = null;
+ private ResourceComposite resourceComposite = null;
// this is used to prevent an odd smartgwt problem where onInit() can get called multiple times if
// the view is set to a Tab's pane.
@@ -109,10 +130,16 @@ public class DashboardView extends LocatableVLayout {
}
public DashboardView(String locatorId, DashboardContainer dashboardContainer, Dashboard storedDashboard,
- ResourceGroup group, Resource resource) {
+ ResourceGroupComposite groupCompositeValue, ResourceComposite resourceCompositeValue) {
this(locatorId, dashboardContainer, storedDashboard);
- this.focusGroup = group;
- this.focusResource = resource;
+ groupComposite = groupCompositeValue;
+ if (groupComposite != null) {
+ group = groupCompositeValue.getResourceGroup();
+ }
+ resourceComposite = resourceCompositeValue;
+ if (resourceComposite != null) {
+ resource = resourceComposite.getResource();
+ }
}
@Override
@@ -167,10 +194,62 @@ public class DashboardView extends LocatableVLayout {
private DynamicForm buildEditForm() {
editForm = new LocatableDynamicForm(extendLocatorId("Editor"));
+ final HashMap<String, String> groupKeyNameMap = PortletFactory.getRegisteredGroupPortletNameMap();
+ //remove BundleDeployment and add back later if relevant.
+ groupKeyNameMap.remove(GroupBundleDeploymentsPortlet.KEY);
+ //if group, need to do asynch check for bundlePortlet to ensure only Platform members
+ if (groupComposite != null) {
+ final ResourceGroup group = groupComposite.getResourceGroup();
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(group.getId());
+ criteria.fetchExplicitResources(true);
+ criteria.setPageControl(new PageControl(0, 1));
+ GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ @Override
+ public void onSuccess(PageList<ResourceGroup> results) {
+ if (!results.isEmpty()) {
+ ResourceGroup grp = results.get(0);
+ Set<Resource> explicitMembers = grp.getExplicitResources();
+ Resource[] currentResources = new Resource[explicitMembers.size()];
+ explicitMembers.toArray(currentResources);
+ //membership dynamically determined if all platforms then will be compatible.
+ if (group.getGroupCategory().equals(GroupCategory.COMPATIBLE)) {
+ if (currentResources[0].getResourceType().getCategory().equals(
+ ResourceCategory.PLATFORM)) {
+ //this portlet allowed to add bundle portlet monitoring
+ groupKeyNameMap.put(GroupBundleDeploymentsPortlet.KEY,
+ GroupBundleDeploymentsPortlet.NAME);
+ }
+ }
+ }
+ //now complet populating of portlet edit form.
+ populateBuildEditForm(groupKeyNameMap);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving information for group [" + group.getId() + "]:"
+ + caught.getMessage());
+ }
+ });
+
+ } else {//otherwise default groupKeyNameMap is sufficient as won't be used.
+ populateBuildEditForm(groupKeyNameMap);
+ }
+
+ return editForm;
+ }
+
+ /** Responsible for populating the edit form widget.
+ * groupKepNameMap is updated for bundles.
+ *
+ * @param groupKeyNameMap
+ */
+ private void populateBuildEditForm(HashMap<String, String> groupKeyNameMap) {
editForm.setMargin(5);
editForm.setAutoWidth();
editForm.setNumCols(canEditName() ? 12 : 10);
-
TextItem nameItem = null;
if (dashboardContainer.supportsDashboardNameEdit()) {
@@ -232,47 +311,40 @@ public class DashboardView extends LocatableVLayout {
}
});
- Menu addPortletMenu = new LocatableMenu(editForm.extendLocatorId("PortletMenu"));
+ final Menu addPortletMenu = new LocatableMenu(editForm.extendLocatorId("PortletMenu"));
HashMap<String, String> keyNameMap = PortletFactory.getRegisteredPortletNameMap();
// the assumption here is that the portlet names are unique. we want a sorted menu here, so create a
// sorted map from portlet name to portlet key and use that to generate the menu. It would be nice if you
// could just call Menu.sort() but it's not supported (yet?).
- TreeMap<String, String> nameKeyMap = new TreeMap<String, String>();
+ final TreeMap<String, String> nameKeyMap = new TreeMap<String, String>();
for (String portletKey : keyNameMap.keySet()) {
nameKeyMap.put(keyNameMap.get(portletKey), portletKey);
}
- //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.
+
+ //if resourceGroup passed in then upate portlets list depending on grouptype and facets
+ if (this.group != null) {
+
//filter out portlets not relevent for group(compat|mixed) or facets
+ groupKeyNameMap = processPortletNameMapForGroup(groupKeyNameMap, this.groupComposite);
+
+ //add to default list of portlets.
for (String portletKey : groupKeyNameMap.keySet()) {
nameKeyMap.put(groupKeyNameMap.get(portletKey), portletKey);
}
}
+ HashMap<String, String> resourceKeyNameMap = PortletFactory.getRegisteredResourcePortletNameMap();
//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());
- // }
- // }
+ if (this.resource != null) {
+ //trim out portlets that should not be visible
+ resourceKeyNameMap = processPortletNameMapForResource(resourceKeyNameMap, this.resourceComposite);
for (String portletKey : resourceKeyNameMap.keySet()) {
nameKeyMap.put(resourceKeyNameMap.get(portletKey), portletKey);
}
}
+ //build the addPortlet Menu item
// now use the reversed map for the menu generation
for (String portletName : nameKeyMap.keySet()) {
MenuItem menuItem = new MenuItem(portletName);
@@ -387,8 +459,82 @@ public class DashboardView extends LocatableVLayout {
updateRefreshMenu();
this.refreshMenuButton.markForRedraw();
markForRedraw();
+ //attempt to initialize
+ editForm.show();
+ editForm.markForRedraw();
+ markForRedraw();
+ }
- return editForm;
+ /**Process the portletName map to exclude portlets that should not be visible for this
+ * resource.
+ */
+ public static HashMap<String, String> processPortletNameMapForResource(HashMap<String, String> resourceKeyNameMap,
+ ResourceComposite composite) {
+ if ((composite != null) && (composite.getResource() != null) && (resourceKeyNameMap != null)
+ && !resourceKeyNameMap.isEmpty()) {
+ Resource resource = composite.getResource();
+ //filter out portlets not relevent for facets
+ Set<ResourceTypeFacet> facets = composite.getResourceFacets().getFacets();
+ //Operation related portlets
+ if (!facets.contains(ResourceTypeFacet.OPERATION)) {
+ resourceKeyNameMap.remove(ResourceOperationsPortlet.KEY);
+ }
+ //MEASUREMENT related portlets(METRICS)
+ if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
+ resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ }
+ //Content related portlets
+ if (!facets.contains(ResourceTypeFacet.CONTENT)) {
+ resourceKeyNameMap.remove(ResourcePkgHistoryPortlet.KEY);
+ }
+ //Event related portlets
+ if (!facets.contains(ResourceTypeFacet.EVENT)) {
+ resourceKeyNameMap.remove(ResourceEventsPortlet.KEY);
+ }
+ //Bundle related portlet
+ if (!resource.getResourceType().getCategory().equals(ResourceCategory.PLATFORM)) {
+ resourceKeyNameMap.remove(ResourceBundleDeploymentsPortlet.KEY);
+ }
+ }
+ return resourceKeyNameMap;
+ }
+
+ /**Process the portletName map to exclude portlets that should not be visible for this
+ * group. All except BundleDeployment visibility is handled here. Bundle requires runtime check.
+ */
+ public static HashMap<String, String> processPortletNameMapForGroup(HashMap<String, String> groupKeyNameMap,
+ ResourceGroupComposite composite) {
+ if ((composite != null) && (composite.getResourceGroup() != null) && (groupKeyNameMap != null)
+ && !groupKeyNameMap.isEmpty()) {
+
+ //filter out portlets not relevent for facets
+ Set<ResourceTypeFacet> facets = composite.getResourceFacets().getFacets();
+ GroupCategory groupCategory = composite.getResourceGroup().getGroupCategory();
+ // ResourceGroup group = composite.getResourceGroup();
+ //compatible if not a compatible group may need to do some pruning.
+ if (groupCategory != GroupCategory.COMPATIBLE) {
+ //Operations related portlets(Config,PkgHistory)
+ if (!facets.contains(ResourceTypeFacet.OPERATION)) {
+ groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
+ }
+ //MEASUREMENT related portlets(METRICS)
+ if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
+ groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
+ groupKeyNameMap.remove(GroupOobsPortlet.KEY);
+ }
+ //CONTENT related portlets(CONTENT)
+ if (!facets.contains(ResourceTypeFacet.CONTENT)) {
+ groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY);
+ }
+ // //EVENT related portlets
+ // if (!facets.contains(ResourceTypeFacet.EVENT)) {
+ // groupKeyNameMap.remove(GroupEventsPortlet.KEY);
+ // }
+
+ }
+ }
+ return groupKeyNameMap;
}
private void loadPortletWindows() {
@@ -671,6 +817,7 @@ public class DashboardView extends LocatableVLayout {
this.editMode = editMode;
if (editMode) {
this.editForm.show();
+ //
} else {
this.editForm.hide();
}
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 636a844..2ee782e 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
@@ -266,6 +266,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements CustomSettin
}
recentEventsContent.addChild(column);
recentEventsContent.markForRedraw();
+ markForRedraw();
}
});
}
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 d840bcc..0e2e00c 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
@@ -348,10 +348,13 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
*/
class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListView {
+ private ResourceGroupComposite composite;
+
public GroupOperationsCriteriaHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource,
String title, Criteria criteria, ResourceGroupComposite composite) {
super(locatorId, composite);
setDataSource(dataSource);
+ this.composite = composite;
setShowFooterRefresh(false); //disable footer refresh
}
@@ -368,6 +371,11 @@ class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListVi
MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count)));
}
}
+
+ @Override
+ protected String getBasePath() {
+ return "ResourceGroup/" + composite.getResourceGroup().getId() + "/Operations/History";
+ }
}
/** Provide implementation of GroupOperationHistoryDataSource that dynamically
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
index 3ce4561..3cb8256 100644
--- 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
@@ -163,6 +163,7 @@ public class ResourceBundleDeploymentsPortlet extends GroupBundleDeploymentsPort
for (Canvas child : recentBundleDeployContent.getChildren()) {
child.destroy();
}
+ column.markForRedraw();
recentBundleDeployContent.addChild(column);
recentBundleDeployContent.markForRedraw();
markForRedraw();
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 f9fae66..c67dce9 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
@@ -156,7 +156,6 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
Set<ResourceTypeFacet> resourceFacets = null;
if ((groupComposite != null) && (groupComposite.getResourceGroup() != null)) {
group = groupComposite.getResourceGroup();
- group = groupComposite.getResourceGroup();
groupCategory = groupComposite.getResourceGroup().getGroupCategory();
facets = groupComposite.getResourceFacets().getFacets();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
index c57b591..5f2de37 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
@@ -125,10 +125,8 @@ public class ActivityView2 extends LocatableVLayout implements DashboardContaine
private void setDashboard(Dashboard dashboard) {
Canvas[] members = getMembers();
removeMembers(members);
-
//pass in the group information
- dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard, this.groupComposite
- .getResourceGroup(), null);
+ dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard, groupComposite, null);
addMember(dashboardView);
footer = new LocatableToolStrip(extendLocatorId("Footer"));
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 867251f..20b5e65 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
@@ -106,10 +106,9 @@ public class Activity2View extends LocatableVLayout implements DashboardContaine
private void setDashboard(Dashboard dashboard) {
Canvas[] members = getMembers();
removeMembers(members);
-
//pass in the resource information
dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this, dashboard, null,
- this.resourceComposite.getResource());
+ resourceComposite);
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 9d9da4f..2e37d6c 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
@@ -1459,13 +1459,13 @@ 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_oobs = Group: OOB Conditions
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_metrics = Resource: Measurements
view_portlet_defaultName_resource_oobs = Resource: OOB Metrics
view_portlet_defaultName_resource_operations = Resource: Operations
view_portlet_defaultName_resource_pkg_hisory = Resource: Package History
commit d95526648b72a4f82620a1cda714e820dbba1dbf
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 18 08:34:45 2011 -0400
some portlet cleanup.
i)get rid of (non-table) GroupAlerts portlet
ii)rename tabular GroupAlerts 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 aa63d77..b8d2ddc 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,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.GroupAlertsPortlet2;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
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;
@@ -104,8 +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(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.Factory.INSTANCE);
@@ -116,8 +115,7 @@ public class PortletFactory {
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String, String>(registeredGroupPortletFactoryMap.size());
- // registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
- registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY, GroupAlertsPortlet2.NAME);
+ registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY, GroupAlertsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY, GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY, GroupEventsPortlet.NAME);
@@ -153,8 +151,7 @@ public class PortletFactory {
//############## Portlet icon mappings ############################################
//register portlet names
registeredPortletIconMap = new HashMap<String, String>(registeredPortletFactoryMap.size());
- // registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertIcon());
- registeredPortletIconMap.put(GroupAlertsPortlet2.KEY, ImageManager.getAlertIcon());
+ registeredPortletIconMap.put(GroupAlertsPortlet.KEY, ImageManager.getAlertIcon());
registeredPortletIconMap.put(ResourceAlertsPortlet.KEY, ImageManager.getAlertIcon());
registeredPortletIconMap.put(GroupMetricsPortlet.KEY, ImageManager.getMonitorIcon());
registeredPortletIconMap.put(ResourceMetricsPortlet.KEY, ImageManager.getMonitorIcon());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
index 483d858..120c974 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
@@ -18,35 +18,35 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
-import java.util.List;
+import java.util.HashMap;
+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.Timer;
-import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+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.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 com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.AlertCriteria;
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.ImageManager;
+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.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView;
+import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource;
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;
@@ -54,68 +54,80 @@ 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.AlertGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+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.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;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-/**This portlet allows the end user to customize the:
- * i)range
- * ii)priority
- * iii)etc.
- * of alerts to display for the given group
- *
+/**
* @author Simeon Pinder
*/
-public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
- private int groupId = -1;
- protected LocatableCanvas recentAlertsContent = new LocatableCanvas(extendLocatorId("RecentAlerts"));
- private static AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService();
- private boolean currentlyLoading = false;
- private Configuration portletConfig = null;
- private DashboardPortlet storedPortlet;
+public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupAlerts";
+ // A default displayed, persisted name for the portlet
+ 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";
+ public static final String RESOURCES_ALL = MSG.common_label_all_resources();
+ public static final String RESOURCES_SELECTED = MSG.common_label_selected_resources();
+ public static final String defaultResourceValue = RESOURCES_ALL;
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ protected PortletWindow portletWindow;
+
+ //shared private UI elements
+ protected AlertResourceSelectorRegion resourceSelector;
+
+ protected AlertPortletConfigurationDataSource dataSource;
+ //instance ui widgets
+ protected Canvas containerCanvas;
+
+ protected Timer refreshTimer;
+ protected DashboardPortlet storedPortlet;
+ protected Configuration portletConfig;
+ private int groupId;
+ 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 GroupAlertsPortlet(String locatorId) {
super(locatorId);
+
+ //override the shared datasource
//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();
- }
+ this.groupId = Integer.valueOf(elements[1]);
- @Override
- protected void onInit() {
- super.onInit();
- loadData();
+ setShowFilterForm(false); //disable filter form for portlet
+ setOverflow(Overflow.VISIBLE);
}
- /**Defines layout for the Activity page.
+ /**Defines layout for the portlet page.
*/
protected void initializeUi() {
- setPadding(5);
- setMembersMargin(5);
- addMember(recentAlertsContent);
- }
+ //initalize the datasource
+ this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, this.groupId, null);
+ setDataSource(this.dataSource);
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupAlerts";
- // A default displayed, persisted name for the portlet
- public static final String NAME = "Group: Alerts";
- public static final String ID = "id";
+ setShowHeader(false);
+ setShowFooter(true);
+ setShowFooterRefresh(false); //disable footer refresh
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
- //instance ui widgets
-
- private Timer refreshTimer;
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
/** Responsible for initialization and lazy configuration of the portlet values
*/
@@ -131,6 +143,12 @@ public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettin
this.storedPortlet = storedPortlet;
portletConfig = storedPortlet.getConfiguration();
+ if (!portletConfigInitialized) {
+ this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, this.groupId, null);
+ 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) {
@@ -138,137 +156,33 @@ public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettin
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
}
}
- }
- public Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
+ //resource ids to be conditionally included in the query
+ Integer[] filterResourceIds = null;
+ filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, filterResourceIds);
+ //no defaults
- public final Portlet getInstance(String locatorId) {
- return new GroupAlertsPortlet(locatorId);
+ if (filterResourceIds != null) {
+ getDataSource().setAlertFilterResourceId(filterResourceIds);
}
- }
- /** Fetches alerts and updates the DynamicForm instance with the latest
- * alert information.
- */
- private void getRecentAlerts() {
- final int groupId = this.groupId;
- currentlyLoading = false;
- //fetches last five alerts for this resource
- AlertCriteria criteria = new AlertCriteria();
- //filter priority
- PropertySimple property = portletConfig.getSimple(Constant.ALERT_PRIORITY);
- if (property != null) {
- String currentSetting = property.getStringValue();
- String[] parsedValues = currentSetting.trim().split(",");
- if (currentSetting.trim().isEmpty() || parsedValues.length == 3) {
- //all alert priorities assumed
- } else {
- AlertPriority[] filterPriorities = new AlertPriority[parsedValues.length];
- int indx = 0;
- for (String priority : parsedValues) {
- AlertPriority p = AlertPriority.valueOf(priority);
- filterPriorities[indx++] = p;
- }
- criteria.addFilterPriorities(filterPriorities);
- }
- }
- PageControl pc = new PageControl();
- //result sort order
- property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
- if (property != null) {
- String currentSetting = property.getStringValue();
- if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
- criteria.addSortCtime(PageOrdering.DESC);
- pc.setPrimarySortOrder(PageOrdering.DESC);
- } else {
- criteria.addSortCtime(PageOrdering.ASC);
- pc.setPrimarySortOrder(PageOrdering.ASC);
+ //conditionally display the selected resources ui
+ if (containerCanvas != null) {
+ //empty out earlier canvas
+ for (Canvas c : containerCanvas.getChildren()) {
+ c.destroy();
}
- }
- //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 pageControl = new PageControl(0, 5);
- pc.setPageSize(5);
+ if ((resourceSelector != null) && getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) {
+ containerCanvas.addChild(resourceSelector.getCanvas());
} else {
- PageControl pageControl = new PageControl(0, Integer.valueOf(currentSetting));
- pc.setPageSize(Integer.valueOf(currentSetting));
+ containerCanvas.addChild(new Canvas());
}
}
- criteria.setPageControl(pc);
- criteria.addFilterResourceGroupIds(groupId);
- alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
- @Override
- public void onSuccess(PageList<Alert> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (Alert alert : result) {
- // alert history records do not have a usable locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- row.setNumCols(3);
-
- StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(ImageManager.getAlertIcon(alert
- .getAlertDefinition().getPriority()), alert.getAlertDefinition().getPriority()
- .getDisplayName());
- LinkItem link = AbstractActivityView.newLinkItem(alert.getAlertDefinition().getName() + ": ",
- ReportDecorator.GWT_GROUP_URL + groupId + "/Alerts/History/" + alert.getId());
- StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter
- .format(alert.getCtime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId
- + "/Alerts/History/", column);
- } else {
- LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentAlertsContent
- // .extendLocatorId("None"), AbstractActivityView.RECENT_ALERTS_NONE);
- .extendLocatorId("None"), "No results found using criteria specified.");
- column.addMember(row);
- }
- for (Canvas child : recentAlertsContent.getChildren()) {
- child.destroy();
- }
- recentAlertsContent.addChild(column);
- recentAlertsContent.markForRedraw();
- }
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent alerts for group [" + groupId + "]:" + caught.getMessage());
- }
- });
}
- protected void loadData() {
- currentlyLoading = true;
- getRecentAlerts();
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
}
@Override
@@ -289,11 +203,11 @@ public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettin
// .getResulSortOrderEditor(portletConfig);
//add result count selector
final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
//add range selector
final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
.getMeasurementRangeEditor(portletConfig);
- //TODO: spinder 3/10/11 renable sort selector once it's working in criteria
- // form.setItems(alertPrioritySelector, resultSortSelector, resultCountSelector);
+
form.setItems(alertPrioritySelector, resultCountSelector);
//submit handler
@@ -301,13 +215,10 @@ public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettin
@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
@@ -316,37 +227,16 @@ public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettin
// 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
+ //persist and reload portlet
storedPortlet.setConfiguration(portletConfig);
configure(portletWindow, storedPortlet);
- loadData();
+ refresh();
}
});
form.markForRedraw();
@@ -356,6 +246,19 @@ public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettin
return customSettings;
}
+ 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 GroupAlertsPortlet(locatorId);
+ }
+ }
+
@Override
public void startRefreshCycle() {
//current setting
@@ -370,10 +273,8 @@ public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettin
refreshTimer = new Timer() {
public void run() {
- if (!currentlyLoading) {
- loadData();
- redraw();
- }
+
+ redraw();
}
};
@@ -384,15 +285,110 @@ public class GroupAlertsPortlet extends LocatableVLayout implements CustomSettin
@Override
protected void onDestroy() {
if (refreshTimer != null) {
-
refreshTimer.cancel();
}
+
super.onDestroy();
}
@Override
- public void redraw() {
- super.redraw();
- loadData();
+ protected void setupTableInteractions(boolean hasWriteAccess) {
+ // The portlet is a "subsystem" view. Meaning the alerts displayed can be from any accessible group for
+ // the user. This means the user can have varying permissions on the underlying groups and/or resources,
+ // which makes button enablement tricky. So, for the portlet don't even show the buttons unless the user
+ // is inventory manager. Other users will just have to navigate to the alert in question in order to
+ // manipulate it.
+
+ //determine if the user is inventory manager and if so render the buttons
+ Set<Permission> permissions = this.portletWindow.getGlobalPermissions();
+ if ((null != permissions) && permissions.contains(Permission.MANAGE_INVENTORY)) {
+ super.setupTableInteractions(true);
+ }
+ }
+
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ Integer recordId = getId(record);
+ Integer resourceId = record.getAttributeAsInt("resourceId");
+ String detailsUrl = LinkManager.getSubsystemAlertHistoryLink(resourceId, recordId);
+ return SeleniumUtility.getLocatableHref(detailsUrl, value.toString(), null);
+ }
+ };
+ }
+
+ @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 onInit() {
+ super.onInit();
+ initializeUi();
+ // getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
+
+ @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 {
+final 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/groups/GroupAlertsPortlet2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
deleted file mode 100644
index 565b46b..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
-
-import java.util.HashMap;
-import java.util.Set;
-
-import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.Timer;
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-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.SelectItem;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.configuration.Configuration;
-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.UserSessionManager;
-import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView;
-import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource;
-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.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;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-
-/**
- * @author Simeon Pinder
- */
-public class GroupAlertsPortlet2 extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet {
-
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupAlerts";
- // A default displayed, persisted name for the portlet
- 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";
- public static final String RESOURCES_ALL = MSG.common_label_all_resources();
- public static final String RESOURCES_SELECTED = MSG.common_label_selected_resources();
- public static final String defaultResourceValue = RESOURCES_ALL;
- public static final String ID = "id";
-
- // set on initial configuration, the window for this portlet view.
- protected PortletWindow portletWindow;
-
- //shared private UI elements
- protected AlertResourceSelectorRegion resourceSelector;
-
- protected AlertPortletConfigurationDataSource dataSource;
- //instance ui widgets
- protected Canvas containerCanvas;
-
- protected Timer refreshTimer;
- protected DashboardPortlet storedPortlet;
- protected Configuration portletConfig;
- private int groupId;
- 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);
-
- //override the shared datasource
- //figure out which page we're loading
- String currentPage = History.getToken();
- String[] elements = currentPage.split("/");
- 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, this.groupId, null);
- setDataSource(this.dataSource);
-
- setShowHeader(false);
- setShowFooter(true);
- setShowFooterRefresh(false); //disable footer refresh
-
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
- }
-
- /** 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) {
- this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, this.groupId, null);
- 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 Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
- }
-
- @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
-
- //add alert priority selector
- final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent
- .getAlertPriorityEditor(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(alertPrioritySelector, resultCountSelector);
-
- //submit handler
- customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
-
- @Override
- public void onSubmitValues(SubmitValuesEvent event) {
- String selectedValue;
- //alert severity
- portletConfig = AbstractActivityView.saveAlertPrioritySettings(alertPrioritySelector, portletConfig);
-
- // //result sort order
- // selectedValue = resultSortSelector.getValue().toString();
- // if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc
- // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.DESC));
- // } else {
- // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.ASC));
- // }
- //result count
- portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
-
- //time range settings
- portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
- portletConfig);
-
- //persist and reload portlet
- storedPortlet.setConfiguration(portletConfig);
- configure(portletWindow, storedPortlet);
- refresh();
- }
- });
- form.markForRedraw();
- page.addMember(measurementRangeEditor);
- page.addMember(form);
- customSettings.addChild(page);
- return customSettings;
- }
-
- 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 GroupAlertsPortlet2(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();
- }
-
- @Override
- protected void setupTableInteractions(boolean hasWriteAccess) {
- // The portlet is a "subsystem" view. Meaning the alerts displayed can be from any accessible group for
- // the user. This means the user can have varying permissions on the underlying groups and/or resources,
- // which makes button enablement tricky. So, for the portlet don't even show the buttons unless the user
- // is inventory manager. Other users will just have to navigate to the alert in question in order to
- // manipulate it.
-
- //determine if the user is inventory manager and if so render the buttons
- Set<Permission> permissions = this.portletWindow.getGlobalPermissions();
- if ((null != permissions) && permissions.contains(Permission.MANAGE_INVENTORY)) {
- super.setupTableInteractions(true);
- }
- }
-
- protected CellFormatter getDetailsLinkColumnCellFormatter() {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int i1) {
- Integer recordId = getId(record);
- Integer resourceId = record.getAttributeAsInt("resourceId");
- String detailsUrl = LinkManager.getSubsystemAlertHistoryLink(resourceId, recordId);
- return SeleniumUtility.getLocatableHref(detailsUrl, value.toString(), null);
- }
- };
- }
-
- @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 onInit() {
- super.onInit();
- initializeUi();
- // getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
- }
-
- @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 {
-final 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/groups/GroupAlertsPortlet3.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java
new file mode 100644
index 0000000..7c166ad
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java
@@ -0,0 +1,398 @@
+/*
+ * 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.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.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+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.alert.Alert;
+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.AlertCriteria;
+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.ImageManager;
+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.AlertGWTServiceAsync;
+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:
+ * i)range
+ * ii)priority
+ * iii)etc.
+ * of alerts to display for the given group
+ *
+ * @author Simeon Pinder
+ */
+public class GroupAlertsPortlet3 extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet {
+ private int groupId = -1;
+ protected LocatableCanvas recentAlertsContent = new LocatableCanvas(extendLocatorId("RecentAlerts"));
+ private static AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService();
+ private boolean currentlyLoading = false;
+ private Configuration portletConfig = null;
+ private DashboardPortlet storedPortlet;
+
+ public GroupAlertsPortlet3(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 Activity page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentAlertsContent);
+ }
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupAlerts";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = "Group: Alerts";
+ 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) {
+ //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_recentAlerts());
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new GroupAlertsPortlet3(locatorId);
+ }
+ }
+
+ /** Fetches alerts and updates the DynamicForm instance with the latest
+ * alert information.
+ */
+ private void getRecentAlerts() {
+ final int groupId = this.groupId;
+ currentlyLoading = false;
+ //fetches last five alerts for this resource
+ AlertCriteria criteria = new AlertCriteria();
+ //filter priority
+ PropertySimple property = portletConfig.getSimple(Constant.ALERT_PRIORITY);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (currentSetting.trim().isEmpty() || parsedValues.length == 3) {
+ //all alert priorities assumed
+ } else {
+ AlertPriority[] filterPriorities = new AlertPriority[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ AlertPriority p = AlertPriority.valueOf(priority);
+ filterPriorities[indx++] = p;
+ }
+ criteria.addFilterPriorities(filterPriorities);
+ }
+ }
+ PageControl pc = new PageControl();
+ //result sort order
+ property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ criteria.addSortCtime(PageOrdering.DESC);
+ pc.setPrimarySortOrder(PageOrdering.DESC);
+ } else {
+ criteria.addSortCtime(PageOrdering.ASC);
+ pc.setPrimarySortOrder(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 pageControl = new PageControl(0, 5);
+ pc.setPageSize(5);
+ } else {
+ PageControl pageControl = new PageControl(0, Integer.valueOf(currentSetting));
+ pc.setPageSize(Integer.valueOf(currentSetting));
+ }
+ }
+ criteria.setPageControl(pc);
+ criteria.addFilterResourceGroupIds(groupId);
+ alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
+ @Override
+ public void onSuccess(PageList<Alert> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (Alert alert : result) {
+ // alert history records do not have a usable locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(ImageManager.getAlertIcon(alert
+ .getAlertDefinition().getPriority()), alert.getAlertDefinition().getPriority()
+ .getDisplayName());
+ LinkItem link = AbstractActivityView.newLinkItem(alert.getAlertDefinition().getName() + ": ",
+ ReportDecorator.GWT_GROUP_URL + groupId + "/Alerts/History/" + alert.getId());
+ StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter
+ .format(alert.getCtime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId
+ + "/Alerts/History/", column);
+ } else {
+ LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentAlertsContent
+ // .extendLocatorId("None"), AbstractActivityView.RECENT_ALERTS_NONE);
+ .extendLocatorId("None"), "No results found using criteria specified.");
+ column.addMember(row);
+ }
+ for (Canvas child : recentAlertsContent.getChildren()) {
+ child.destroy();
+ }
+ recentAlertsContent.addChild(column);
+ recentAlertsContent.markForRedraw();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent alerts for group [" + groupId + "]:" + caught.getMessage());
+ }
+ });
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentAlerts();
+ }
+
+ @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
+
+ //add alert priority selector
+ final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent
+ .getAlertPriorityEditor(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);
+ //TODO: spinder 3/10/11 renable sort selector once it's working in criteria
+ // form.setItems(alertPrioritySelector, resultSortSelector, resultCountSelector);
+ form.setItems(alertPrioritySelector, resultCountSelector);
+
+ //submit handler
+ customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ //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));
+ }
+ // //result sort order
+ // selectedValue = resultSortSelector.getValue().toString();
+ // if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc
+ // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.DESC));
+ // } else {
+ // 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));
+ }
+
+ //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
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ loadData();
+ }
+ });
+ form.markForRedraw();
+ page.addMember(measurementRangeEditor);
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
+ @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/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
index 53ba926..c79b9f9 100644
--- 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
@@ -36,14 +36,14 @@ 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.groups.GroupAlertsPortlet;
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 {
+public class ResourceAlertsPortlet extends GroupAlertsPortlet {
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "ResourceAlerts";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
index d819d8b..c57b591 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
@@ -45,7 +45,6 @@ import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -193,9 +192,9 @@ public class ActivityView2 extends LocatableVLayout implements DashboardContaine
// dummyLeft.getConfiguration().put(new PropertySimple("message", "<br/>Coming Soon... :-)"));
// dashboard.addPortlet(dummyLeft, 0, 0);
- DashboardPortlet groupAlerts = new DashboardPortlet(GroupAlertsPortlet.NAME, GroupAlertsPortlet.KEY, 220);
+ // DashboardPortlet groupAlerts = new DashboardPortlet(GroupAlertsPortlet3.NAME, GroupAlertsPortlet3.KEY, 220);
// groupAlerts.getConfiguration().put(new PropertySimple("message", "<br/>Coming Soon... :-)"));
- dashboard.addPortlet(groupAlerts, 0, 0);
+ // dashboard.addPortlet(groupAlerts, 0, 0);
// right Column
DashboardPortlet dummyRight = new DashboardPortlet(MessagePortlet.NAME, MessagePortlet.KEY, 220);
commit fc6850969088d587f4cf8faee4a7b7bc73ec7cdb
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 18 08:25:05 2011 -0400
i)fix problem with time range not reloading settings correctly
ii)enable duplicate portlets on dashboard.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
index 82be574..d8c69b8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
@@ -48,9 +48,9 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
public abstract class AbstractMeasurementRangeEditor extends LocatableDynamicForm implements TableWidget {
//keyed map of translated date units Ex. minutes,hours,days
- private static LinkedHashMap<String, String> lastUnits;
+ protected static LinkedHashMap<String, String> lastUnits;
//array of values available for displaying/selecting 'last N hours|minutes|days'.
- private static String[] lastValues;
+ protected static String[] lastValues;
protected boolean advanced;
private ButtonItem advancedSimpleButton;
@@ -222,7 +222,7 @@ public abstract class AbstractMeasurementRangeEditor extends LocatableDynamicFor
}
}
- private void update() {
+ protected void update() {
if (advanced) {
advancedSimpleButton.setTitle(MSG.view_measureRange_simple());
showItem("start");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
index f4e9a0e..01794cb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.components.measurement;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.rhq.core.domain.configuration.Configuration;
@@ -59,6 +60,8 @@ public class CustomConfigMeasurementRangeEditor extends AbstractMeasurementRange
} else {
int lastN = Integer.valueOf(simpleLastValuesItem.getValueAsString());
String unit = simpleLastUnitsItem.getValueAsString();
+ measurementPrefs.metricRangePreferences.lastN = lastN;
+ measurementPrefs.metricRangePreferences.unit = Integer.valueOf(unit);
return MeasurementUtility.calculateTimeFrame(lastN, Integer.valueOf(unit));
}
}
@@ -108,7 +111,11 @@ public class CustomConfigMeasurementRangeEditor extends AbstractMeasurementRange
config.getSimple(PREF_METRIC_RANGE_BEGIN_END_FLAG).getStringValue()).booleanValue();
//check to display advanced settings widget components
if (metricRangePreferences.explicitBeginEnd == false) {
+ //retrieve lastN
metricRangePreferences.lastN = config.getSimple(PREF_METRIC_RANGE_LASTN).getIntegerValue();
+ //retrieve lastN units
+ metricRangePreferences.unit = config.getSimple(PREF_METRIC_RANGE_UNIT).getIntegerValue();
+
List<Long> range = MeasurementUtility.calculateTimeFrame(metricRangePreferences.lastN,
metricRangePreferences.unit);
metricRangePreferences.begin = range.get(0);
@@ -170,10 +177,21 @@ public class CustomConfigMeasurementRangeEditor extends AbstractMeasurementRange
enableRangeItem.setValue(false);
enableMeasurementRange(true);
}
- //AlertMetric rangeValues
- cp = measurementPrefs.configuration.getSimple(PREF_METRIC_RANGE);
- if ((cp != null) && (!cp.getStringValue().trim().isEmpty())) {
- String metricRange = cp.getStringValue();
+ //is advanced
+ boolean advanced = measurementPrefs.metricRangePreferences.explicitBeginEnd;
+ if (advanced) {
+ ArrayList<Long> beginEnd = measurementPrefs.metricRangePreferences.getBeginEndTimes();
+ if ((beginEnd != null) && (!beginEnd.isEmpty())) {
+ advancedStartItem.setValue(beginEnd.get(0));
+ advancedEndItem.setValue(beginEnd.get(1));
+ }
+ } else {//simple: set LastN and Units
+ if (lastUnits.containsKey(String.valueOf(measurementPrefs.metricRangePreferences.unit))) {
+ simpleLastUnitsItem.setValue(String.valueOf(measurementPrefs.metricRangePreferences.unit));
+ }
+ if (Arrays.asList(lastValues).contains(String.valueOf(measurementPrefs.metricRangePreferences.lastN))) {
+ simpleLastValuesItem.setValue(String.valueOf(measurementPrefs.metricRangePreferences.lastN));
+ }
}
}
}
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 384895d..25923ba 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,12 +244,12 @@ 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());
- }
- }
+ // //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
@@ -261,12 +261,12 @@ 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());
- }
- }
+ // //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);
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 072d82c..d840bcc 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
@@ -59,11 +59,10 @@ 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.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.inventory.groups.detail.operation.history.GroupOperationHistoryListView;
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;
@@ -347,36 +346,17 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
*
* @author spinder
*/
-class GroupOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView {
-
- private AbstractOperationHistoryDataSource datasource;
+class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListView {
public GroupOperationsCriteriaHistoryListView(String locatorId, AbstractOperationHistoryDataSource dataSource,
String title, Criteria criteria, ResourceGroupComposite composite) {
- super(locatorId, dataSource, title, criteria);
- this.datasource = dataSource;
- this.groupComposite = composite;
+ super(locatorId, composite);
+ setDataSource(dataSource);
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;
+ setDataSource(datasource);
}
@Override
@@ -405,8 +385,10 @@ class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
+ //initialize criteria
GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
+ //retrieve group identifier
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));
@@ -431,12 +413,34 @@ class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource
//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);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- criteria.addFilterStartTime(Long.valueOf(range[0]));
- criteria.addFilterEndTime(Long.valueOf(range[1]));
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ 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]));
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
}
}
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 37b0052..f9fae66 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
@@ -524,15 +524,23 @@ public abstract class AbstractActivityView extends LocatableVLayout implements R
}
//time advanced time filter enabled.
+ boolean isAdvanceTimeSetting = false;
selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ isAdvanceTimeSetting = Boolean.valueOf(selectedValue);
}
//time frame
List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (begEnd.get(0) != 0) {//advanced settings
+ if (isAdvanceTimeSetting) {//advanced settings
portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1))));
+ } else {
+ //save not advanced time range
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN, measurementRangeEditor
+ .getMetricRangePreferences().lastN));
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT, measurementRangeEditor
+ .getMetricRangePreferences().unit));
}
}
return portletConfig;
commit f5920e31ffb0e47f5113679938029d1fe240279d
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 17 16:46:35 2011 -0400
i)D12N problem with Group alerts portlet.
ii)Have GroupOperationsPortlet fill it's portlet.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
index 8ebfed5..39f2f52 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
@@ -26,6 +26,7 @@ import com.smartgwt.client.rpc.RPCResponse;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
@@ -53,6 +54,7 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource {
private Integer groupId = null;
private Integer[] resourceIds = null;
private String alertResourcesToUse;
+ private EntityContext entityContext;
public AlertPortletConfigurationDataSource() {
super();
@@ -65,6 +67,11 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource {
this.configuration = configuration;
this.groupId = groupId;
this.resourceIds = resourceIds;
+ if (groupId != null) {
+ entityContext = EntityContext.forGroup(groupId);
+ } else if ((resourceIds != null) && (resourceIds.length > 0)) {
+ entityContext = EntityContext.forResource(resourceIds[0]);
+ }
}
/** Override the executeFetch for AlertPortlet to allow specifying smaller than total
@@ -155,9 +162,13 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource {
public void onSuccess(PageList<Alert> result) {
long fetchTime = System.currentTimeMillis() - start;
Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
+ if (entityContext.type != EntityContext.Type.Resource) {
+ dataRetrieved(result, response, request);
+ } else {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
}
});
}
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 0a7bc76..072d82c 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
@@ -190,8 +190,10 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
protected void initializeUi() {
setPadding(5);
setMembersMargin(5);
- setHeight100();
+ setHeight("*");
setWidth100();
+ //tell canvas to fill it's component
+ recentOperationsContent.setHeight100();
addMember(recentOperationsContent);
markForRedraw();
}
commit 2e233f7d30e19118e7052a36443d35d9d7032873
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 18 17:13:06 2011 -0400
reuse the message center window - don't keep re-creating it.
this avoids selenium ID conflicts and is much snappier when clicking the message center button
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
index c61ff23..2f31bb8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
@@ -38,7 +38,9 @@ import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageBar;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenterView;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Greg Hinkle
@@ -82,13 +84,34 @@ public class Footer extends LocatableHLayout {
favoritesLayout.addMember(favoritesButton);
addMember(favoritesLayout);
- addMember(messageCenter.getMessageCenterButton());
+ addMember(getMessageCenterButton());
addMember(createHSpacer(0));
alertsMessage.schedule(60000);
}
+ private LocatableVLayout getMessageCenterButton() {
+ LocatableVLayout layout = new LocatableVLayout(extendLocatorId("layout"));
+ layout.setMembersMargin(5);
+ layout.setHeight100();
+ layout.setAlign(Alignment.CENTER);
+ layout.setAutoWidth();
+
+ LocatableIButton button = new LocatableIButton(extendLocatorId("button"), MSG.view_messageCenter_messageTitle());
+ button.setAlign(Alignment.CENTER);
+ button.setAutoFit(true);
+ button.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ messageCenter.showMessageCenterWindow();
+ }
+ });
+
+ layout.addMember(button);
+ return layout;
+ }
+
public abstract static class RefreshableLabel extends LocatableLabel {
public RefreshableLabel(String locatorId) {
super(locatorId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index cdf116b..df35e27 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -31,10 +31,7 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.types.TimeFormatter;
import com.smartgwt.client.types.VerticalAlignment;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.events.DoubleClickEvent;
@@ -47,7 +44,6 @@ import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.SortNormalizer;
-import com.smartgwt.client.widgets.layout.Layout;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
@@ -55,8 +51,6 @@ import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
@@ -65,10 +59,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
* also be displayed in its own non-modal dialog window. If you want this table
* shown in a dialog window, call {@link #showMessageCenterWindow()}.
*
- * This Table also can provide a standalone button that you can add to any layout,
- * see {@link #getMessageCenterButton()}. The button, when pressed, will popup
- * the dialog message window as explained above.
- *
* Note: this class has to be very careful about catching any and all exceptions.
* Otherwise, an uncaught exception will cause a flooding of global exception
* messages (since the unhandled exception handler in CoreGUI will recursively
@@ -87,12 +77,11 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
private static final String FIELD_CONCISEMESSAGE = "conciseMessage";
private static final String FIELD_OBJECT = "object";
- private Layout messageCenterButton;
private MessageCenterWindow window;
public MessageCenterView(String locatorId) {
- super(locatorId, MSG.view_messageCenter_messageTitle(), new SortSpecifier[] { new SortSpecifier(FIELD_TIME,
- SortDirection.DESCENDING) });
+ super(locatorId, MSG.view_messageCenter_messageTitle(), null, new SortSpecifier[] { new SortSpecifier(
+ FIELD_TIME, SortDirection.DESCENDING) }, null, false);
CoreGUI.getMessageCenter().addMessageListener(this);
}
@@ -107,38 +96,6 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
}
}
- /**
- * Returns a button enclosed in a layout. When the button is pressed, the
- * Message Center non-modal dialog window will popup.
- *
- * To press the button programmatically (i.e. to popup the message center window),
- * call {@link #showMessageCenterWindow()}.
- *
- * @return layout enclosing the button to popup the message center window
- */
- public Layout getMessageCenterButton() {
- if (messageCenterButton == null) {
- messageCenterButton = new LocatableVLayout(extendLocatorId("layout"));
- messageCenterButton.setMembersMargin(5);
- messageCenterButton.setHeight100();
- messageCenterButton.setAlign(Alignment.CENTER);
- messageCenterButton.setAutoWidth();
-
- IButton button = new LocatableIButton(extendLocatorId("button"), MSG.view_messageCenter_messageTitle());
- button.setAlign(Alignment.CENTER);
- button.setAutoFit(true);
- button.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- showMessageCenterWindow();
- }
- });
-
- messageCenterButton.addMember(button);
- }
- return messageCenterButton;
- }
-
private Window createWindow() {
if (window == null) {
window = new MessageCenterWindow("MessageCenterViewWindow");
@@ -147,17 +104,9 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
@Override
public void onCloseClick(CloseClientEvent event) {
try {
- // try really really hard to make selenium ID generation happy (TODO: it still doesn't)
- Canvas[] members = MessageCenterView.this.getMembers();
- for (Canvas member : members) {
- member.destroy();
- }
- MessageCenterView.this.destroy();
- window.destroy();
+ window.hide();
} catch (Throwable e) {
Log.warn("Cannot destroy message center", e);
- } finally {
- window = null;
}
}
});
@@ -296,7 +245,7 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
maxMessagesMap.put("50", Integer.valueOf("50"));
maxMessagesMap.put("100", Integer.valueOf("100"));
maxMessagesMap.put("200", Integer.valueOf("200"));
- addTableAction(extendLocatorId("maxMessageMeny"), MSG.view_messageCenter_maxMessages(), null, maxMessagesMap,
+ addTableAction(extendLocatorId("maxMessageMenu"), MSG.view_messageCenter_maxMessages(), null, maxMessagesMap,
new AbstractTableAction(TableActionEnablement.ALWAYS) {
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -317,7 +266,7 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
new AbstractTableAction(TableActionEnablement.ALWAYS) {
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- for (Severity severity : EnumSet.allOf(Severity.class)) {
+ for (Severity severity : java.util.EnumSet.allOf(Severity.class)) {
Message m = new Message(severity.name() + ':' + System.currentTimeMillis(), severity);
CoreGUI.getMessageCenter().notify(m);
}
@@ -389,22 +338,22 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
form.setItems(title, severity, date, detail);
- final Window window = new LocatableWindow(this.extendLocatorId("MessageWindow"));
- window.setTitle(MSG.common_title_message());
- window.setWidth(600);
- window.setHeight(400);
- window.setIsModal(true);
- window.setShowModalMask(true);
- window.setCanDragResize(true);
- window.setShowMaximizeButton(true);
- window.setShowMinimizeButton(false);
- window.centerInPage();
- window.addItem(form);
- window.show();
- window.addCloseClickHandler(new CloseClickHandler() {
+ final Window dialogWin = new LocatableWindow(this.extendLocatorId("MessageWindow"));
+ dialogWin.setTitle(MSG.common_title_message());
+ dialogWin.setWidth(600);
+ dialogWin.setHeight(400);
+ dialogWin.setIsModal(true);
+ dialogWin.setShowModalMask(true);
+ dialogWin.setCanDragResize(true);
+ dialogWin.setShowMaximizeButton(true);
+ dialogWin.setShowMinimizeButton(false);
+ dialogWin.centerInPage();
+ dialogWin.addItem(form);
+ dialogWin.show();
+ dialogWin.addCloseClickHandler(new CloseClickHandler() {
@Override
public void onCloseClick(CloseClientEvent event) {
- window.destroy();
+ dialogWin.destroy();
}
});
}
commit f40a6a433eadce7ba15f5a7213e3d64eb3d84b4c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 18 16:17:24 2011 -0400
BZ 681355 new window message center
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 41af140..3fe259e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -143,6 +143,15 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
});
+ KeyIdentifier messageCenterWindowKey = new KeyIdentifier();
+ messageCenterWindowKey.setCtrlKey(true);
+ messageCenterWindowKey.setKeyName("M");
+ Page.registerKey(messageCenterWindowKey, new KeyCallback() {
+ public void execute(String keyName) {
+ footer.getMessageCenter().showMessageCenterWindow();
+ }
+ });
+
GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
public void onUncaughtException(Throwable e) {
getErrorHandler().handleError(MSG.view_core_uncaught(), e);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
index 1cfdd50..c61ff23 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
@@ -48,6 +48,7 @@ public class Footer extends LocatableHLayout {
private static final String LOCATOR_ID = "CoreFooter";
private MessageBar messageBar;
+ private MessageCenterView messageCenter;
public Footer() {
super(LOCATOR_ID);
@@ -62,7 +63,7 @@ public class Footer extends LocatableHLayout {
protected void onDraw() {
super.onDraw();
- final MessageCenterView messageCenter = new MessageCenterView(extendLocatorId(MessageCenterView.LOCATOR_ID));
+ messageCenter = new MessageCenterView(extendLocatorId(MessageCenterView.LOCATOR_ID));
final FavoritesButton favoritesButton = new FavoritesButton(extendLocatorId("Favorites"));
final AlertsMessage alertsMessage = new AlertsMessage(extendLocatorId("Alerts"));
messageBar = new MessageBar();
@@ -81,7 +82,7 @@ public class Footer extends LocatableHLayout {
favoritesLayout.addMember(favoritesButton);
addMember(favoritesLayout);
- addMember(messageCenter);
+ addMember(messageCenter.getMessageCenterButton());
addMember(createHSpacer(0));
@@ -171,6 +172,10 @@ public class Footer extends LocatableHLayout {
return messageBar;
}
+ public MessageCenterView getMessageCenter() {
+ return messageCenter;
+ }
+
private HLayout createHSpacer(int width) {
HLayout spacer = new HLayout();
spacer.setWidth(width);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
index 96e1740..91ae345 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
@@ -38,6 +38,7 @@ public class Message {
// TODO: Add Debug severity?
public enum Severity {
+ // keep the order - the ordinals are sorted least severe to highest severe
Blank("InfoBlank", "info/icn_info_blank.png"), //
Info("InfoBlock", "info/icn_info_blue.png"), //
Warning("WarnBlock", "info/icn_info_orange.png"), //
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
index 1a4845d..d9fba53 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
@@ -32,14 +32,15 @@ public class MessageCenter {
private LinkedList<Message> messages = new LinkedList<Message>();
private List<MessageListener> listeners = new ArrayList<MessageListener>();
- private static final int MAX_MESSAGES = 50;
+ private int maxMessages = 50;
public void notify(Message message) {
log(message);
if (!message.isTransient()) {
- this.messages.add(message);
- if (messages.size() > MAX_MESSAGES) {
- messages.removeFirst();
+ // put the newest messages up front; old messages are at the end
+ this.messages.addFirst(message);
+ if (messages.size() > maxMessages) {
+ messages.removeLast(); // we should only have 1 extra, so removeLast should remove all extras
}
}
for (MessageListener listener : listeners) {
@@ -51,6 +52,18 @@ public class MessageCenter {
this.listeners.add(listener);
}
+ public int getMaxMessages() {
+ return maxMessages;
+ }
+
+ public void setMaxMessages(int max) {
+ // if we are shrinking the list, clip the extra, older, messages
+ if (max < this.maxMessages && messages.size() > max) {
+ messages.subList(max, messages.size()).clear();
+ }
+ this.maxMessages = max;
+ }
+
/**
* Returns a list of recently published non-transient messages.
*
@@ -65,7 +78,8 @@ public class MessageCenter {
}
private void log(Message message) {
- String formattedMessage = "On " + message.getFired() + ", MessageCenter received " + message.getConciseMessage();
+ String formattedMessage = "At [" + message.getFired() + "] MessageCenter received: "
+ + message.getConciseMessage();
if (message.severity == Message.Severity.Info) {
Log.info(formattedMessage);
} else if (message.severity == Message.Severity.Warning) {
@@ -78,5 +92,5 @@ public class MessageCenter {
Log.debug(formattedMessage);
}
}
-
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index 1891bd4..cdf116b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -18,110 +18,352 @@
*/
package org.rhq.enterprise.gui.coregui.client.util.message;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.types.TimeFormatter;
import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.menu.IMenuButton;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+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 com.smartgwt.client.widgets.grid.SortNormalizer;
+import com.smartgwt.client.widgets.layout.Layout;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
- * @author Greg Hinkle
+ * Message Center view that shows the latest messages generated by the app.
+ * This is a Table and can therefore be a member to any layout. However, it can
+ * also be displayed in its own non-modal dialog window. If you want this table
+ * shown in a dialog window, call {@link #showMessageCenterWindow()}.
+ *
+ * This Table also can provide a standalone button that you can add to any layout,
+ * see {@link #getMessageCenterButton()}. The button, when pressed, will popup
+ * the dialog message window as explained above.
+ *
+ * Note: this class has to be very careful about catching any and all exceptions.
+ * Otherwise, an uncaught exception will cause a flooding of global exception
+ * messages (since the unhandled exception handler in CoreGUI will recursively
+ * call into this message center).
+ *
+ * @author John Mazzitelli
*/
-public class MessageCenterView extends LocatableVLayout implements MessageCenter.MessageListener {
+@SuppressWarnings("unchecked")
+public class MessageCenterView extends Table implements MessageCenter.MessageListener {
public static final String LOCATOR_ID = "MessageCenter";
+ public static final String TABLE_TITLE = MSG.view_messageCenter_messageTitle();
+
+ private static final String FIELD_TIME = "time";
+ private static final String FIELD_SEVERITY = "severity";
+ private static final String FIELD_CONCISEMESSAGE = "conciseMessage";
+ private static final String FIELD_OBJECT = "object";
- private Menu messagesMenu;
- private IMenuButton messageCenterButton;
- private int messageCount;
+ private Layout messageCenterButton;
+ private MessageCenterWindow window;
public MessageCenterView(String locatorId) {
- super(locatorId, 5);
- setHeight100();
- setAlign(Alignment.CENTER);
- setAutoWidth();
+ super(locatorId, MSG.view_messageCenter_messageTitle(), new SortSpecifier[] { new SortSpecifier(FIELD_TIME,
+ SortDirection.DESCENDING) });
+ CoreGUI.getMessageCenter().addMessageListener(this);
}
- @Override
- protected void onDraw() {
- super.onDraw();
-
- messagesMenu = new LocatableMenu(this.extendLocatorId("Messages"));
+ /**
+ * This will popup a non-modal dialog window with the messages in a list.
+ */
+ public void showMessageCenterWindow() {
+ try {
+ createWindow().show();
+ } catch (Throwable e) {
+ Log.error("Cannot show message center window", e);
+ }
+ }
- messageCenterButton = new LocatableIMenuButton(extendLocatorId("RecentEvents"), MSG
- .view_messageCenter_messageTitle(), messagesMenu);
- messageCenterButton.setAutoFit(true);
+ /**
+ * Returns a button enclosed in a layout. When the button is pressed, the
+ * Message Center non-modal dialog window will popup.
+ *
+ * To press the button programmatically (i.e. to popup the message center window),
+ * call {@link #showMessageCenterWindow()}.
+ *
+ * @return layout enclosing the button to popup the message center window
+ */
+ public Layout getMessageCenterButton() {
+ if (messageCenterButton == null) {
+ messageCenterButton = new LocatableVLayout(extendLocatorId("layout"));
+ messageCenterButton.setMembersMargin(5);
+ messageCenterButton.setHeight100();
+ messageCenterButton.setAlign(Alignment.CENTER);
+ messageCenterButton.setAutoWidth();
- emptyMenu();
- addMember(messageCenterButton);
+ IButton button = new LocatableIButton(extendLocatorId("button"), MSG.view_messageCenter_messageTitle());
+ button.setAlign(Alignment.CENTER);
+ button.setAutoFit(true);
+ button.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ showMessageCenterWindow();
+ }
+ });
- CoreGUI.getMessageCenter().addMessageListener(this);
+ messageCenterButton.addMember(button);
+ }
+ return messageCenterButton;
}
- public void onMessage(final Message message) {
- if (!message.isTransient()) {
- if (messageCount == 0) {
- addClearMenuItem();
- }
- messageCount++;
-
- MenuItem messageItem = new MenuItem(message.conciseMessage, getSeverityIcon(message.severity));
- messageItem.addClickHandler(new ClickHandler() {
+ private Window createWindow() {
+ if (window == null) {
+ window = new MessageCenterWindow("MessageCenterViewWindow");
+ window.addItem(this);
+ window.addCloseClickHandler(new CloseClickHandler() {
@Override
- public void onClick(MenuItemClickEvent event) {
- showDetails(message);
+ public void onCloseClick(CloseClientEvent event) {
+ try {
+ // try really really hard to make selenium ID generation happy (TODO: it still doesn't)
+ Canvas[] members = MessageCenterView.this.getMembers();
+ for (Canvas member : members) {
+ member.destroy();
+ }
+ MessageCenterView.this.destroy();
+ window.destroy();
+ } catch (Throwable e) {
+ Log.warn("Cannot destroy message center", e);
+ } finally {
+ window = null;
+ }
}
});
- messagesMenu.addItem(messageItem, 2); // put this just below the "clear all msgs" item and the separator
-
- // to avoid flooding the message center, clip old messages
- final int maxMessages = 25;
- if (messageCount > maxMessages) {
- MenuItem[] items = messagesMenu.getItems();
- MenuItem[] clippedItems = new MenuItem[maxMessages + 2]; // +2 to take into account the Clear All Messages item and the separator
- System.arraycopy(items, 0, clippedItems, 0, clippedItems.length);
- messagesMenu.setItems(clippedItems);
+ }
+
+ return window;
+ }
+
+ @Override
+ public void onMessage(final Message message) {
+ try {
+ if (!message.isTransient()) {
+ refresh();
+ if (window != null) {
+ window.blink();
+ }
}
+ } catch (Throwable e) {
+ Log.error("Cannot process message", e);
}
}
- private void addClearMenuItem() {
- MenuItem clearItem = new MenuItem(MSG.view_messageCenter_clearAllMessages());
- clearItem.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ @Override
+ protected void configureTable() {
+ getListGrid().setEmptyMessage(MSG.view_messageCenter_noRecentMessages());
+
+ setTableTitle(MSG.view_messageCenter_lastNMessages(String.valueOf(CoreGUI.getMessageCenter().getMaxMessages())));
+
+ ListGridField severityField = new ListGridField(FIELD_SEVERITY);
+ severityField.setType(ListGridFieldType.ICON);
+ severityField.setAlign(Alignment.CENTER);
+ severityField.setShowValueIconOnly(true);
+ HashMap<String, String> severityIcons = new HashMap<String, String>(5);
+ severityIcons.put(Severity.Blank.name(), getSeverityIcon(Severity.Blank));
+ severityIcons.put(Severity.Info.name(), getSeverityIcon(Severity.Info));
+ severityIcons.put(Severity.Warning.name(), getSeverityIcon(Severity.Warning));
+ severityIcons.put(Severity.Error.name(), getSeverityIcon(Severity.Error));
+ severityIcons.put(Severity.Fatal.name(), getSeverityIcon(Severity.Fatal));
+ severityField.setValueIcons(severityIcons);
+ severityField.setShowHover(true);
+ severityField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ try {
+ Severity severity = ((Message) record.getAttributeAsObject(FIELD_OBJECT)).getSeverity();
+ switch (severity) {
+ case Info:
+ return MSG.common_severity_info();
+ case Warning:
+ return MSG.common_severity_warn();
+ case Error:
+ return MSG.common_severity_error();
+ case Fatal:
+ return MSG.common_severity_fatal();
+ }
+ } catch (Throwable e) {
+ Log.error("Cannot get severity hover", e);
+ }
+ return null;
+ }
+ });
+ severityField.setSortNormalizer(new SortNormalizer() {
+ @Override
+ public Object normalize(ListGridRecord record, String fieldName) {
+ try {
+ Severity severity = ((Message) record.getAttributeAsObject(FIELD_OBJECT)).getSeverity();
+ return Integer.valueOf(severity.ordinal());
+ } catch (Throwable e) {
+ Log.error("Cannot get sort nomalizer", e);
+ }
+ return Integer.valueOf(0);
+ }
+ });
+
+ ListGridField timeField = new ListGridField(FIELD_TIME, MSG.view_messageCenter_messageTime());
+ timeField.setType(ListGridFieldType.TIME);
+ timeField.setAttribute("displayFormat", TimeFormatter.TOPADDEDTIME);
+ timeField.setAlign(Alignment.LEFT);
+
+ ListGridField messageField = new ListGridField(FIELD_CONCISEMESSAGE, MSG.common_title_message());
+
+ severityField.setWidth(25);
+ timeField.setWidth("15%");
+ messageField.setWidth("*");
+
+ getListGrid().setFields(severityField, timeField, messageField);
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
@Override
- public void onClick(MenuItemClickEvent event) {
- emptyMenu();
+ public void onDoubleClick(DoubleClickEvent event) {
+ try {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length > 0) {
+ Message message = (Message) selectedRows[0].getAttributeAsObject(FIELD_OBJECT); // show the first selected
+ showDetails(message);
+ }
+ } catch (Throwable e) {
+ Log.error("Cannot show details for message", e);
+ }
}
});
- messagesMenu.setItems(clearItem); // setItems making this the only item in the menu
- MenuItem separator = new MenuItem();
- separator.setIsSeparator(true);
- messagesMenu.addItem(separator);
+ addTableAction(extendLocatorId("delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
+ new AbstractTableAction(TableActionEnablement.ANY) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ try {
+ for (ListGridRecord record : selection) {
+ Object doomed = record.getAttributeAsObject(FIELD_OBJECT);
+ CoreGUI.getMessageCenter().getMessages().remove(doomed);
+ }
+ refresh();
+ } catch (Throwable e) {
+ Log.error("Cannot delete messages", e);
+ }
+ }
+ });
+
+ addTableAction(extendLocatorId("deleteAll"), MSG.common_button_delete_all(), MSG.common_msg_areYouSure(),
+ new AbstractTableAction(TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ try {
+ CoreGUI.getMessageCenter().getMessages().clear();
+ refresh();
+ } catch (Throwable e) {
+ Log.error("Cannot delete all messages", e);
+ }
+ }
+ });
+
+ LinkedHashMap<String, Integer> maxMessagesMap = new LinkedHashMap<String, Integer>();
+ maxMessagesMap.put("10", Integer.valueOf("10"));
+ maxMessagesMap.put("25", Integer.valueOf("25"));
+ maxMessagesMap.put("50", Integer.valueOf("50"));
+ maxMessagesMap.put("100", Integer.valueOf("100"));
+ maxMessagesMap.put("200", Integer.valueOf("200"));
+ addTableAction(extendLocatorId("maxMessageMeny"), MSG.view_messageCenter_maxMessages(), null, maxMessagesMap,
+ new AbstractTableAction(TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ try {
+ Integer maxSize = (Integer) actionValue;
+ CoreGUI.getMessageCenter().setMaxMessages(maxSize.intValue());
+ setTableTitle(MSG.view_messageCenter_lastNMessages(maxSize.toString()));
+ refresh();
+ } catch (Throwable e) {
+ Log.error("Cannot set max messages", e);
+ }
+ }
+ });
+
+ /*
+ // TODO only for testing, remove this when done testing
+ addTableAction(extendLocatorId("test"), "TEST MSG", null,
+ new AbstractTableAction(TableActionEnablement.ALWAYS) {
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ for (Severity severity : EnumSet.allOf(Severity.class)) {
+ Message m = new Message(severity.name() + ':' + System.currentTimeMillis(), severity);
+ CoreGUI.getMessageCenter().notify(m);
+ }
+ }
+ });
+ */
- markForRedraw();
+ // initial population of the list with current messages
+ try {
+ refresh();
+ } catch (Throwable e) {
+ Log.error("Cannot perform initial refresh", e);
+ }
}
- private void emptyMenu() {
- CoreGUI.getMessageCenter().getMessages().clear();
- messageCount = 0;
- messagesMenu.setItems(new MenuItem(MSG.view_messageCenter_noRecentMessages()));
- markForRedraw();
+ @Override
+ protected SelectionStyle getDefaultSelectionStyle() {
+ return SelectionStyle.MULTIPLE;
+ }
+
+ @Override
+ public void refresh() {
+ try {
+ super.refresh();
+ getListGrid().setRecords(transform(CoreGUI.getMessageCenter().getMessages()));
+ refreshTableInfo();
+ } catch (Throwable e) {
+ Log.error("Cannot refresh messages", e);
+ }
+ }
+
+ private ListGridRecord[] transform(List<Message> list) {
+ ListGridRecord[] results = new ListGridRecord[list.size()];
+ for (int i = 0; i < list.size(); i++) {
+ results[i] = transform(list.get(i));
+ }
+ return results;
+ }
+
+ private ListGridRecord transform(Message msg) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(FIELD_TIME, msg.fired);
+ record.setAttribute(FIELD_SEVERITY, (msg.severity != null) ? msg.severity.name() : Severity.Info.name());
+ record.setAttribute(FIELD_CONCISEMESSAGE, msg.conciseMessage);
+ record.setAttribute(FIELD_OBJECT, msg);
+ return record;
}
private void showDetails(Message message) {
@@ -148,7 +390,7 @@ public class MessageCenterView extends LocatableVLayout implements MessageCenter
form.setItems(title, severity, date, detail);
final Window window = new LocatableWindow(this.extendLocatorId("MessageWindow"));
- window.setTitle(MSG.view_messageCenter_messageTitle());
+ window.setTitle(MSG.common_title_message());
window.setWidth(600);
window.setHeight(400);
window.setIsModal(true);
@@ -168,19 +410,58 @@ public class MessageCenterView extends LocatableVLayout implements MessageCenter
}
private String getSeverityIcon(Message.Severity severity) {
- String iconSrc = null;
- switch (severity) {
- case Info:
- iconSrc = "info/icn_info_blue.png";
- break;
- case Warning:
- iconSrc = "info/icn_info_orange.png";
- break;
- case Error:
- case Fatal:
- iconSrc = "info/icn_info_red.png";
- break;
+ if (severity == null) {
+ severity = Severity.Blank;
}
- return iconSrc;
+ return severity.getIcon();
}
+
+ static class MessageCenterWindow extends LocatableWindow {
+ private Timer blinkTimer;
+
+ public MessageCenterWindow(String locatorId) {
+ super(locatorId);
+ setTitle(TABLE_TITLE);
+ setShowMinimizeButton(true);
+ setShowMaximizeButton(true);
+ setShowCloseButton(true);
+ setIsModal(false);
+ setShowModalMask(false);
+ setWidth(700);
+ setHeight(300);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+
+ final String origColor = getBodyColor();
+ blinkTimer = new Timer() {
+ @Override
+ public void run() {
+ try {
+ setBodyColor(origColor);
+ setTitle(TABLE_TITLE);
+ redraw();
+ } catch (Throwable e) {
+ Log.error("Blink timer failed", e);
+ }
+ }
+ };
+ }
+
+ public void blink() {
+ try {
+ // window.flash() isn' t working so do it ourselves
+ if (getMinimized()) {
+ setTitle(TABLE_TITLE + " *");
+ } else {
+ setBodyColor(getHiliteBodyColor());
+ }
+ redraw();
+ blinkTimer.schedule(250);
+ } catch (Throwable e) {
+ Log.error("Cannot blink message center window", e);
+ }
+ }
+ }
+
}
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 b7bc5c4..9d9da4f 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
@@ -2085,11 +2085,12 @@ view_searchGUI_loginStatus = Unable to determine login status, check server stat
# Message Center
#--------------------------
-view_messageCenter_button_messages = Messages
+view_messageCenter_messageTitle = Message Center
view_messageCenter_noRecentMessages = No Recent Messages
+view_messageCenter_maxMessages = Max Messages
+view_messageCenter_lastNMessages = Last {0} Messages
view_messageCenter_clearAllMessages = Clear All Messages
-view_messageCenter_messageTitle = Message Center
-view_messageCenter_messageSeverity = Severity
view_messageCenter_messageTime = Time
+view_messageCenter_messageSeverity = Severity
view_messageCenter_messageDetail = Detail
view_messageCenter_stackTraceFollows = --- STACK TRACE FOLLOWS ---
commit b426b2e42cec8cbb9dfd1f396bac330b9db008db
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Mar 18 13:43:33 2011 -0400
Re-establish working metric graphs in the GraphPortlet (SmallGraph)
- remove explicit provision of 1.4.4 jquery lib. jquery.sparkline requires
jquery but jquery is already embedded in the GFlot JAR (the charting
lib used for GraphPortlet). GFlot 1.0.0 requires/provides an older
version(1.3.2) that what is currently available, but fortunately
sparkline is compatible with this older version. We will need to provide
jquery explicitly if we remove GFlot.
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 09c58dd..bf14b52 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -140,7 +140,9 @@
</dependency>
-->
- <!-- the GWT graphing library -->
+ <!-- the GWT graphing library (note, this provides jquery 1.3.2. If we get rid of GFlot we will need
+ to provide jquery explcitly for jquery.sparkline support. See CoreGUI.gwt.xml for the jquery.sparkline
+ declaration and coregui/webapp/js for the lib inclusion.) -->
<dependency>
<groupId>ca.nanometrics</groupId>
<artifactId>gflot</artifactId>
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index 980f9ca..3d1f770 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -64,7 +64,12 @@
</generate-with>
<!-- External javascript libraries -->
- <script src="/coregui/js/jquery-1.4.4.js"/>
+ <!-- jquery.sparkline requires jquery. We don't explicitly provide jquery here because it is already
+ embedded in the GFlot JAR (the charting lib used for GraphPortlet). Furthermore, GFlot 1.0.0 requires
+ its older, embedded version of jquery (1.3.2). Fortunately, sparkline is compatible with this older version.
+ We will need to provide jquery explicitly (like the commented version below) if we remove GFlot.
+ <script src="/coregui/js/jquery-1.4.4.js"/>
+ -->
<script src="/coregui/js/jquery.sparkline-1.6.js"/>
<!--
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/js/jquery-1.4.4.js b/modules/enterprise/gui/coregui/src/main/webapp/js/jquery-1.4.4.js
deleted file mode 100644
index c53482c..0000000
--- a/modules/enterprise/gui/coregui/src/main/webapp/js/jquery-1.4.4.js
+++ /dev/null
@@ -1,7179 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.4.4
- * http://jquery.com/
- *
- * Copyright 2010, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2010, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Thu Nov 11 19:04:53 2010 -0500
- */
-(function( window, undefined ) {
-
-// Use the correct document accordingly with window argument (sandbox)
-var document = window.document;
-var jQuery = (function() {
-
-// Define a local copy of jQuery
-var jQuery = function( selector, context ) {
- // The jQuery object is actually just the init constructor 'enhanced'
- return new jQuery.fn.init( selector, context );
- },
-
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
-
- // Map over the $ in case of overwrite
- _$ = window.$,
-
- // A central reference to the root jQuery(document)
- rootjQuery,
-
- // A simple way to check for HTML strings or ID strings
- // (both of which we optimize for)
- quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
-
- // Is it a simple selector
- isSimple = /^.[^:#\[\.,]*$/,
-
- // Check if a string has a non-whitespace character in it
- rnotwhite = /\S/,
- rwhite = /\s/,
-
- // Used for trimming whitespace
- trimLeft = /^\s+/,
- trimRight = /\s+$/,
-
- // Check for non-word characters
- rnonword = /\W/,
-
- // Check for digits
- rdigit = /\d/,
-
- // Match a standalone tag
- rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
-
- // JSON RegExp
- rvalidchars = /^[\],:{}\s]*$/,
- rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
- rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
- rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
-
- // Useragent RegExp
- rwebkit = /(webkit)[ \/]([\w.]+)/,
- ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
- rmsie = /(msie) ([\w.]+)/,
- rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
-
- // Keep a UserAgent string for use with jQuery.browser
- userAgent = navigator.userAgent,
-
- // For matching the engine and version of the browser
- browserMatch,
-
- // Has the ready events already been bound?
- readyBound = false,
-
- // The functions to execute on DOM ready
- readyList = [],
-
- // The ready event handler
- DOMContentLoaded,
-
- // Save a reference to some core methods
- toString = Object.prototype.toString,
- hasOwn = Object.prototype.hasOwnProperty,
- push = Array.prototype.push,
- slice = Array.prototype.slice,
- trim = String.prototype.trim,
- indexOf = Array.prototype.indexOf,
-
- // [[Class]] -> type pairs
- class2type = {};
-
-jQuery.fn = jQuery.prototype = {
- init: function( selector, context ) {
- var match, elem, ret, doc;
-
- // Handle $(""), $(null), or $(undefined)
- if ( !selector ) {
- return this;
- }
-
- // Handle $(DOMElement)
- if ( selector.nodeType ) {
- this.context = this[0] = selector;
- this.length = 1;
- return this;
- }
-
- // The body element only exists once, optimize finding it
- if ( selector === "body" && !context && document.body ) {
- this.context = document;
- this[0] = document.body;
- this.selector = "body";
- this.length = 1;
- return this;
- }
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- // Are we dealing with HTML string or an ID?
- match = quickExpr.exec( selector );
-
- // Verify a match, and that no context was specified for #id
- if ( match && (match[1] || !context) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[1] ) {
- doc = (context ? context.ownerDocument || context : document);
-
- // If a single string is passed in and it's a single tag
- // just do a createElement and skip the rest
- ret = rsingleTag.exec( selector );
-
- if ( ret ) {
- if ( jQuery.isPlainObject( context ) ) {
- selector = [ document.createElement( ret[1] ) ];
- jQuery.fn.attr.call( selector, context, true );
-
- } else {
- selector = [ doc.createElement( ret[1] ) ];
- }
-
- } else {
- ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
- selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
- }
-
- return jQuery.merge( this, selector );
-
- // HANDLE: $("#id")
- } else {
- elem = document.getElementById( match[2] );
-
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id !== match[2] ) {
- return rootjQuery.find( selector );
- }
-
- // Otherwise, we inject the element directly into the jQuery object
- this.length = 1;
- this[0] = elem;
- }
-
- this.context = document;
- this.selector = selector;
- return this;
- }
-
- // HANDLE: $("TAG")
- } else if ( !context && !rnonword.test( selector ) ) {
- this.selector = selector;
- this.context = document;
- selector = document.getElementsByTagName( selector );
- return jQuery.merge( this, selector );
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return (context || rootjQuery).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return jQuery( context ).find( selector );
- }
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( jQuery.isFunction( selector ) ) {
- return rootjQuery.ready( selector );
- }
-
- if (selector.selector !== undefined) {
- this.selector = selector.selector;
- this.context = selector.context;
- }
-
- return jQuery.makeArray( selector, this );
- },
-
- // Start with an empty selector
- selector: "",
-
- // The current version of jQuery being used
- jquery: "1.4.4",
-
- // The default length of a jQuery object is 0
- length: 0,
-
- // The number of elements contained in the matched element set
- size: function() {
- return this.length;
- },
-
- toArray: function() {
- return slice.call( this, 0 );
- },
-
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
- return num == null ?
-
- // Return a 'clean' array
- this.toArray() :
-
- // Return just the object
- ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
- },
-
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems, name, selector ) {
- // Build a new jQuery matched element set
- var ret = jQuery();
-
- if ( jQuery.isArray( elems ) ) {
- push.apply( ret, elems );
-
- } else {
- jQuery.merge( ret, elems );
- }
-
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
-
- ret.context = this.context;
-
- if ( name === "find" ) {
- ret.selector = this.selector + (this.selector ? " " : "") + selector;
- } else if ( name ) {
- ret.selector = this.selector + "." + name + "(" + selector + ")";
- }
-
- // Return the newly-formed element set
- return ret;
- },
-
- // Execute a callback for every element in the matched set.
- // (You can seed the arguments with an array of args, but this is
- // only used internally.)
- each: function( callback, args ) {
- return jQuery.each( this, callback, args );
- },
-
- ready: function( fn ) {
- // Attach the listeners
- jQuery.bindReady();
-
- // If the DOM is already ready
- if ( jQuery.isReady ) {
- // Execute the function immediately
- fn.call( document, jQuery );
-
- // Otherwise, remember the function for later
- } else if ( readyList ) {
- // Add the function to the wait list
- readyList.push( fn );
- }
-
- return this;
- },
-
- eq: function( i ) {
- return i === -1 ?
- this.slice( i ) :
- this.slice( i, +i + 1 );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- slice: function() {
- return this.pushStack( slice.apply( this, arguments ),
- "slice", slice.call(arguments).join(",") );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map(this, function( elem, i ) {
- return callback.call( elem, i, elem );
- }));
- },
-
- end: function() {
- return this.prevObject || jQuery(null);
- },
-
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: push,
- sort: [].sort,
- splice: [].splice
-};
-
-// Give the init function the jQuery prototype for later instantiation
-jQuery.fn.init.prototype = jQuery.fn;
-
-jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
- target = arguments[0] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
- target = {};
- }
-
- // extend jQuery itself if only one argument is passed
- if ( length === i ) {
- target = this;
- --i;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && jQuery.isArray(src) ? src : [];
-
- } else {
- clone = src && jQuery.isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend({
- noConflict: function( deep ) {
- window.$ = _$;
-
- if ( deep ) {
- window.jQuery = _jQuery;
- }
-
- return jQuery;
- },
-
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Handle when the DOM is ready
- ready: function( wait ) {
- // A third-party is pushing the ready event forwards
- if ( wait === true ) {
- jQuery.readyWait--;
- }
-
- // Make sure that the DOM is not already loaded
- if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready, 1 );
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- if ( readyList ) {
- // Execute all of them
- var fn,
- i = 0,
- ready = readyList;
-
- // Reset the list of functions
- readyList = null;
-
- while ( (fn = ready[ i++ ]) ) {
- fn.call( document, jQuery );
- }
-
- // Trigger any bound ready events
- if ( jQuery.fn.trigger ) {
- jQuery( document ).trigger( "ready" ).unbind( "ready" );
- }
- }
- }
- },
-
- bindReady: function() {
- if ( readyBound ) {
- return;
- }
-
- readyBound = true;
-
- // Catch cases where $(document).ready() is called after the
- // browser event has already occurred.
- if ( document.readyState === "complete" ) {
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- return setTimeout( jQuery.ready, 1 );
- }
-
- // Mozilla, Opera and webkit nightlies currently support this event
- if ( document.addEventListener ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", jQuery.ready, false );
-
- // If IE event model is used
- } else if ( document.attachEvent ) {
- // ensure firing before onload,
- // maybe late but safe also for iframes
- document.attachEvent("onreadystatechange", DOMContentLoaded);
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", jQuery.ready );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var toplevel = false;
-
- try {
- toplevel = window.frameElement == null;
- } catch(e) {}
-
- if ( document.documentElement.doScroll && toplevel ) {
- doScrollCheck();
- }
- }
- },
-
- // See test/unit/core.js for details concerning isFunction.
- // Since version 1.3, DOM methods and functions like alert
- // aren't supported. They return false on IE (#2968).
- isFunction: function( obj ) {
- return jQuery.type(obj) === "function";
- },
-
- isArray: Array.isArray || function( obj ) {
- return jQuery.type(obj) === "array";
- },
-
- // A crude way of determining if an object is a window
- isWindow: function( obj ) {
- return obj && typeof obj === "object" && "setInterval" in obj;
- },
-
- isNaN: function( obj ) {
- return obj == null || !rdigit.test( obj ) || isNaN( obj );
- },
-
- type: function( obj ) {
- return obj == null ?
- String( obj ) :
- class2type[ toString.call(obj) ] || "object";
- },
-
- isPlainObject: function( obj ) {
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !hasOwn.call(obj, "constructor") &&
- !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
- return false;
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
-
- var key;
- for ( key in obj ) {}
-
- return key === undefined || hasOwn.call( obj, key );
- },
-
- isEmptyObject: function( obj ) {
- for ( var name in obj ) {
- return false;
- }
- return true;
- },
-
- error: function( msg ) {
- throw msg;
- },
-
- parseJSON: function( data ) {
- if ( typeof data !== "string" || !data ) {
- return null;
- }
-
- // Make sure leading/trailing whitespace is removed (IE can't handle it)
- data = jQuery.trim( data );
-
- // Make sure the incoming data is actual JSON
- // Logic borrowed from http://json.org/json2.js
- if ( rvalidchars.test(data.replace(rvalidescape, "@")
- .replace(rvalidtokens, "]")
- .replace(rvalidbraces, "")) ) {
-
- // Try to use the native JSON parser first
- return window.JSON && window.JSON.parse ?
- window.JSON.parse( data ) :
- (new Function("return " + data))();
-
- } else {
- jQuery.error( "Invalid JSON: " + data );
- }
- },
-
- noop: function() {},
-
- // Evalulates a script in a global context
- globalEval: function( data ) {
- if ( data && rnotwhite.test(data) ) {
- // Inspired by code by Andrea Giammarchi
- // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom...
- var head = document.getElementsByTagName("head")[0] || document.documentElement,
- script = document.createElement("script");
-
- script.type = "text/javascript";
-
- if ( jQuery.support.scriptEval ) {
- script.appendChild( document.createTextNode( data ) );
- } else {
- script.text = data;
- }
-
- // Use insertBefore instead of appendChild to circumvent an IE6 bug.
- // This arises when a base node is used (#2709).
- head.insertBefore( script, head.firstChild );
- head.removeChild( script );
- }
- },
-
- nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
- },
-
- // args is for internal usage only
- each: function( object, callback, args ) {
- var name, i = 0,
- length = object.length,
- isObj = length === undefined || jQuery.isFunction(object);
-
- if ( args ) {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.apply( object[ name ], args ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.apply( object[ i++ ], args ) === false ) {
- break;
- }
- }
- }
-
- // A special, fast, case for the most common use of each
- } else {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
- break;
- }
- }
- } else {
- for ( var value = object[0];
- i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
- }
- }
-
- return object;
- },
-
- // Use native String.trim function wherever possible
- trim: trim ?
- function( text ) {
- return text == null ?
- "" :
- trim.call( text );
- } :
-
- // Otherwise use our own trimming functionality
- function( text ) {
- return text == null ?
- "" :
- text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
- },
-
- // results is for internal usage only
- makeArray: function( array, results ) {
- var ret = results || [];
-
- if ( array != null ) {
- // The window, strings (and functions) also have 'length'
- // The extra typeof function check is to prevent crashes
- // in Safari 2 (See: #3039)
- // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
- var type = jQuery.type(array);
-
- if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
- push.call( ret, array );
- } else {
- jQuery.merge( ret, array );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, array ) {
- if ( array.indexOf ) {
- return array.indexOf( elem );
- }
-
- for ( var i = 0, length = array.length; i < length; i++ ) {
- if ( array[ i ] === elem ) {
- return i;
- }
- }
-
- return -1;
- },
-
- merge: function( first, second ) {
- var i = first.length,
- j = 0;
-
- if ( typeof second.length === "number" ) {
- for ( var l = second.length; j < l; j++ ) {
- first[ i++ ] = second[ j ];
- }
-
- } else {
- while ( second[j] !== undefined ) {
- first[ i++ ] = second[ j++ ];
- }
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, inv ) {
- var ret = [], retVal;
- inv = !!inv;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( var i = 0, length = elems.length; i < length; i++ ) {
- retVal = !!callback( elems[ i ], i );
- if ( inv !== retVal ) {
- ret.push( elems[ i ] );
- }
- }
-
- return ret;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var ret = [], value;
-
- // Go through the array, translating each of the items to their
- // new value (or values).
- for ( var i = 0, length = elems.length; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
-
- return ret.concat.apply( [], ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- proxy: function( fn, proxy, thisObject ) {
- if ( arguments.length === 2 ) {
- if ( typeof proxy === "string" ) {
- thisObject = fn;
- fn = thisObject[ proxy ];
- proxy = undefined;
-
- } else if ( proxy && !jQuery.isFunction( proxy ) ) {
- thisObject = proxy;
- proxy = undefined;
- }
- }
-
- if ( !proxy && fn ) {
- proxy = function() {
- return fn.apply( thisObject || this, arguments );
- };
- }
-
- // Set the guid of unique handler to the same of original handler, so it can be removed
- if ( fn ) {
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
- }
-
- // So proxy can be declared as an argument
- return proxy;
- },
-
- // Mutifunctional method to get and set values to a collection
- // The value/s can be optionally by executed if its a function
- access: function( elems, key, value, exec, fn, pass ) {
- var length = elems.length;
-
- // Setting many attributes
- if ( typeof key === "object" ) {
- for ( var k in key ) {
- jQuery.access( elems, k, key[k], exec, fn, value );
- }
- return elems;
- }
-
- // Setting one attribute
- if ( value !== undefined ) {
- // Optionally, function values get executed if exec is true
- exec = !pass && exec && jQuery.isFunction(value);
-
- for ( var i = 0; i < length; i++ ) {
- fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
- }
-
- return elems;
- }
-
- // Getting an attribute
- return length ? fn( elems[0], key ) : undefined;
- },
-
- now: function() {
- return (new Date()).getTime();
- },
-
- // Use of jQuery.browser is frowned upon.
- // More details: http://docs.jquery.com/Utilities/jQuery.browser
- uaMatch: function( ua ) {
- ua = ua.toLowerCase();
-
- var match = rwebkit.exec( ua ) ||
- ropera.exec( ua ) ||
- rmsie.exec( ua ) ||
- ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
- [];
-
- return { browser: match[1] || "", version: match[2] || "0" };
- },
-
- browser: {}
-});
-
-// Populate the class2type map
-jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-browserMatch = jQuery.uaMatch( userAgent );
-if ( browserMatch.browser ) {
- jQuery.browser[ browserMatch.browser ] = true;
- jQuery.browser.version = browserMatch.version;
-}
-
-// Deprecated, use jQuery.browser.webkit instead
-if ( jQuery.browser.webkit ) {
- jQuery.browser.safari = true;
-}
-
-if ( indexOf ) {
- jQuery.inArray = function( elem, array ) {
- return indexOf.call( array, elem );
- };
-}
-
-// Verify that \s matches non-breaking spaces
-// (IE fails on this test)
-if ( !rwhite.test( "\xA0" ) ) {
- trimLeft = /^[\s\xA0]+/;
- trimRight = /[\s\xA0]+$/;
-}
-
-// All jQuery objects should point back to these
-rootjQuery = jQuery(document);
-
-// Cleanup functions for the document ready method
-if ( document.addEventListener ) {
- DOMContentLoaded = function() {
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- jQuery.ready();
- };
-
-} else if ( document.attachEvent ) {
- DOMContentLoaded = function() {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( document.readyState === "complete" ) {
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
- jQuery.ready();
- }
- };
-}
-
-// The DOM ready check for Internet Explorer
-function doScrollCheck() {
- if ( jQuery.isReady ) {
- return;
- }
-
- try {
- // If IE is used, use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- document.documentElement.doScroll("left");
- } catch(e) {
- setTimeout( doScrollCheck, 1 );
- return;
- }
-
- // and execute any waiting functions
- jQuery.ready();
-}
-
-// Expose jQuery to the global object
-return (window.jQuery = window.$ = jQuery);
-
-})();
-
-
-(function() {
-
- jQuery.support = {};
-
- var root = document.documentElement,
- script = document.createElement("script"),
- div = document.createElement("div"),
- id = "script" + jQuery.now();
-
- div.style.display = "none";
- div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
-
- var all = div.getElementsByTagName("*"),
- a = div.getElementsByTagName("a")[0],
- select = document.createElement("select"),
- opt = select.appendChild( document.createElement("option") );
-
- // Can't get basic test support
- if ( !all || !all.length || !a ) {
- return;
- }
-
- jQuery.support = {
- // IE strips leading whitespace when .innerHTML is used
- leadingWhitespace: div.firstChild.nodeType === 3,
-
- // Make sure that tbody elements aren't automatically inserted
- // IE will insert them into empty tables
- tbody: !div.getElementsByTagName("tbody").length,
-
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- htmlSerialize: !!div.getElementsByTagName("link").length,
-
- // Get the style information from getAttribute
- // (IE uses .cssText insted)
- style: /red/.test( a.getAttribute("style") ),
-
- // Make sure that URLs aren't manipulated
- // (IE normalizes it by default)
- hrefNormalized: a.getAttribute("href") === "/a",
-
- // Make sure that element opacity exists
- // (IE uses filter instead)
- // Use a regex to work around a WebKit issue. See #5145
- opacity: /^0.55$/.test( a.style.opacity ),
-
- // Verify style float existence
- // (IE uses styleFloat instead of cssFloat)
- cssFloat: !!a.style.cssFloat,
-
- // Make sure that if no value is specified for a checkbox
- // that it defaults to "on".
- // (WebKit defaults to "" instead)
- checkOn: div.getElementsByTagName("input")[0].value === "on",
-
- // Make sure that a selected-by-default option has a working selected property.
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
- optSelected: opt.selected,
-
- // Will be defined later
- deleteExpando: true,
- optDisabled: false,
- checkClone: false,
- scriptEval: false,
- noCloneEvent: true,
- boxModel: null,
- inlineBlockNeedsLayout: false,
- shrinkWrapBlocks: false,
- reliableHiddenOffsets: true
- };
-
- // Make sure that the options inside disabled selects aren't marked as disabled
- // (WebKit marks them as diabled)
- select.disabled = true;
- jQuery.support.optDisabled = !opt.disabled;
-
- script.type = "text/javascript";
- try {
- script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
- } catch(e) {}
-
- root.insertBefore( script, root.firstChild );
-
- // Make sure that the execution of code works by injecting a script
- // tag with appendChild/createTextNode
- // (IE doesn't support this, fails, and uses .text instead)
- if ( window[ id ] ) {
- jQuery.support.scriptEval = true;
- delete window[ id ];
- }
-
- // Test to see if it's possible to delete an expando from an element
- // Fails in Internet Explorer
- try {
- delete script.test;
-
- } catch(e) {
- jQuery.support.deleteExpando = false;
- }
-
- root.removeChild( script );
-
- if ( div.attachEvent && div.fireEvent ) {
- div.attachEvent("onclick", function click() {
- // Cloning a node shouldn't copy over any
- // bound event handlers (IE does this)
- jQuery.support.noCloneEvent = false;
- div.detachEvent("onclick", click);
- });
- div.cloneNode(true).fireEvent("onclick");
- }
-
- div = document.createElement("div");
- div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
-
- var fragment = document.createDocumentFragment();
- fragment.appendChild( div.firstChild );
-
- // WebKit doesn't clone checked state correctly in fragments
- jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
-
- // Figure out if the W3C box model works as expected
- // document.body must exist before we can do this
- jQuery(function() {
- var div = document.createElement("div");
- div.style.width = div.style.paddingLeft = "1px";
-
- document.body.appendChild( div );
- jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
-
- if ( "zoom" in div.style ) {
- // Check if natively block-level elements act like inline-block
- // elements when setting their display to 'inline' and giving
- // them layout
- // (IE < 8 does this)
- div.style.display = "inline";
- div.style.zoom = 1;
- jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
-
- // Check if elements with layout shrink-wrap their children
- // (IE 6 does this)
- div.style.display = "";
- div.innerHTML = "<div style='width:4px;'></div>";
- jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
- }
-
- div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";
- var tds = div.getElementsByTagName("td");
-
- // Check if table cells still have offsetWidth/Height when they are set
- // to display:none and there are still other visible table cells in a
- // table row; if so, offsetWidth/Height are not reliable for use when
- // determining if an element has been hidden directly using
- // display:none (it is still safe to use offsets if a parent element is
- // hidden; don safety goggles and see bug #4512 for more information).
- // (only IE 8 fails this test)
- jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
-
- tds[0].style.display = "";
- tds[1].style.display = "none";
-
- // Check if empty table cells still have offsetWidth/Height
- // (IE < 8 fail this test)
- jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
- div.innerHTML = "";
-
- document.body.removeChild( div ).style.display = "none";
- div = tds = null;
- });
-
- // Technique from Juriy Zaytsev
- // http://thinkweb2.com/projects/prototype/detecting-event-support-without-b...
- var eventSupported = function( eventName ) {
- var el = document.createElement("div");
- eventName = "on" + eventName;
-
- var isSupported = (eventName in el);
- if ( !isSupported ) {
- el.setAttribute(eventName, "return;");
- isSupported = typeof el[eventName] === "function";
- }
- el = null;
-
- return isSupported;
- };
-
- jQuery.support.submitBubbles = eventSupported("submit");
- jQuery.support.changeBubbles = eventSupported("change");
-
- // release memory in IE
- root = script = div = all = a = null;
-})();
-
-
-
-var windowData = {},
- rbrace = /^(?:\{.*\}|\[.*\])$/;
-
-jQuery.extend({
- cache: {},
-
- // Please use with caution
- uuid: 0,
-
- // Unique for each copy of jQuery on the page
- expando: "jQuery" + jQuery.now(),
-
- // The following elements throw uncatchable exceptions if you
- // attempt to add expando properties to them.
- noData: {
- "embed": true,
- // Ban all objects except for Flash (which handle expandos)
- "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
- "applet": true
- },
-
- data: function( elem, name, data ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- elem = elem == window ?
- windowData :
- elem;
-
- var isNode = elem.nodeType,
- id = isNode ? elem[ jQuery.expando ] : null,
- cache = jQuery.cache, thisCache;
-
- if ( isNode && !id && typeof name === "string" && data === undefined ) {
- return;
- }
-
- // Get the data from the object directly
- if ( !isNode ) {
- cache = elem;
-
- // Compute a unique ID for the element
- } else if ( !id ) {
- elem[ jQuery.expando ] = id = ++jQuery.uuid;
- }
-
- // Avoid generating a new cache unless none exists and we
- // want to manipulate it.
- if ( typeof name === "object" ) {
- if ( isNode ) {
- cache[ id ] = jQuery.extend(cache[ id ], name);
-
- } else {
- jQuery.extend( cache, name );
- }
-
- } else if ( isNode && !cache[ id ] ) {
- cache[ id ] = {};
- }
-
- thisCache = isNode ? cache[ id ] : cache;
-
- // Prevent overriding the named cache with undefined values
- if ( data !== undefined ) {
- thisCache[ name ] = data;
- }
-
- return typeof name === "string" ? thisCache[ name ] : thisCache;
- },
-
- removeData: function( elem, name ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- elem = elem == window ?
- windowData :
- elem;
-
- var isNode = elem.nodeType,
- id = isNode ? elem[ jQuery.expando ] : elem,
- cache = jQuery.cache,
- thisCache = isNode ? cache[ id ] : id;
-
- // If we want to remove a specific section of the element's data
- if ( name ) {
- if ( thisCache ) {
- // Remove the section of cache data
- delete thisCache[ name ];
-
- // If we've removed all the data, remove the element's cache
- if ( isNode && jQuery.isEmptyObject(thisCache) ) {
- jQuery.removeData( elem );
- }
- }
-
- // Otherwise, we want to remove all of the element's data
- } else {
- if ( isNode && jQuery.support.deleteExpando ) {
- delete elem[ jQuery.expando ];
-
- } else if ( elem.removeAttribute ) {
- elem.removeAttribute( jQuery.expando );
-
- // Completely remove the data cache
- } else if ( isNode ) {
- delete cache[ id ];
-
- // Remove all fields from the object
- } else {
- for ( var n in elem ) {
- delete elem[ n ];
- }
- }
- }
- },
-
- // A method for determining if a DOM node can handle the data expando
- acceptData: function( elem ) {
- if ( elem.nodeName ) {
- var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
-
- if ( match ) {
- return !(match === true || elem.getAttribute("classid") !== match);
- }
- }
-
- return true;
- }
-});
-
-jQuery.fn.extend({
- data: function( key, value ) {
- var data = null;
-
- if ( typeof key === "undefined" ) {
- if ( this.length ) {
- var attr = this[0].attributes, name;
- data = jQuery.data( this[0] );
-
- for ( var i = 0, l = attr.length; i < l; i++ ) {
- name = attr[i].name;
-
- if ( name.indexOf( "data-" ) === 0 ) {
- name = name.substr( 5 );
- dataAttr( this[0], name, data[ name ] );
- }
- }
- }
-
- return data;
-
- } else if ( typeof key === "object" ) {
- return this.each(function() {
- jQuery.data( this, key );
- });
- }
-
- var parts = key.split(".");
- parts[1] = parts[1] ? "." + parts[1] : "";
-
- if ( value === undefined ) {
- data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
-
- // Try to fetch any internally stored data first
- if ( data === undefined && this.length ) {
- data = jQuery.data( this[0], key );
- data = dataAttr( this[0], key, data );
- }
-
- return data === undefined && parts[1] ?
- this.data( parts[0] ) :
- data;
-
- } else {
- return this.each(function() {
- var $this = jQuery( this ),
- args = [ parts[0], value ];
-
- $this.triggerHandler( "setData" + parts[1] + "!", args );
- jQuery.data( this, key, value );
- $this.triggerHandler( "changeData" + parts[1] + "!", args );
- });
- }
- },
-
- removeData: function( key ) {
- return this.each(function() {
- jQuery.removeData( this, key );
- });
- }
-});
-
-function dataAttr( elem, key, data ) {
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
- data = elem.getAttribute( "data-" + key );
-
- if ( typeof data === "string" ) {
- try {
- data = data === "true" ? true :
- data === "false" ? false :
- data === "null" ? null :
- !jQuery.isNaN( data ) ? parseFloat( data ) :
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
- data;
- } catch( e ) {}
-
- // Make sure we set the data so it isn't changed later
- jQuery.data( elem, key, data );
-
- } else {
- data = undefined;
- }
- }
-
- return data;
-}
-
-
-
-
-jQuery.extend({
- queue: function( elem, type, data ) {
- if ( !elem ) {
- return;
- }
-
- type = (type || "fx") + "queue";
- var q = jQuery.data( elem, type );
-
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( !data ) {
- return q || [];
- }
-
- if ( !q || jQuery.isArray(data) ) {
- q = jQuery.data( elem, type, jQuery.makeArray(data) );
-
- } else {
- q.push( data );
- }
-
- return q;
- },
-
- dequeue: function( elem, type ) {
- type = type || "fx";
-
- var queue = jQuery.queue( elem, type ),
- fn = queue.shift();
-
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- }
-
- if ( fn ) {
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift("inprogress");
- }
-
- fn.call(elem, function() {
- jQuery.dequeue(elem, type);
- });
- }
- }
-});
-
-jQuery.fn.extend({
- queue: function( type, data ) {
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- }
-
- if ( data === undefined ) {
- return jQuery.queue( this[0], type );
- }
- return this.each(function( i ) {
- var queue = jQuery.queue( this, type, data );
-
- if ( type === "fx" && queue[0] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- });
- },
- dequeue: function( type ) {
- return this.each(function() {
- jQuery.dequeue( this, type );
- });
- },
-
- // Based off of the plugin by Clint Helfers, with permission.
- // http://blindsignals.com/index.php/2009/07/jquery-delay/
- delay: function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
- type = type || "fx";
-
- return this.queue( type, function() {
- var elem = this;
- setTimeout(function() {
- jQuery.dequeue( elem, type );
- }, time );
- });
- },
-
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- }
-});
-
-
-
-
-var rclass = /[\n\t]/g,
- rspaces = /\s+/,
- rreturn = /\r/g,
- rspecialurl = /^(?:href|src|style)$/,
- rtype = /^(?:button|input)$/i,
- rfocusable = /^(?:button|input|object|select|textarea)$/i,
- rclickable = /^a(?:rea)?$/i,
- rradiocheck = /^(?:radio|checkbox)$/i;
-
-jQuery.props = {
- "for": "htmlFor",
- "class": "className",
- readonly: "readOnly",
- maxlength: "maxLength",
- cellspacing: "cellSpacing",
- rowspan: "rowSpan",
- colspan: "colSpan",
- tabindex: "tabIndex",
- usemap: "useMap",
- frameborder: "frameBorder"
-};
-
-jQuery.fn.extend({
- attr: function( name, value ) {
- return jQuery.access( this, name, value, true, jQuery.attr );
- },
-
- removeAttr: function( name, fn ) {
- return this.each(function(){
- jQuery.attr( this, name, "" );
- if ( this.nodeType === 1 ) {
- this.removeAttribute( name );
- }
- });
- },
-
- addClass: function( value ) {
- if ( jQuery.isFunction(value) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- self.addClass( value.call(this, i, self.attr("class")) );
- });
- }
-
- if ( value && typeof value === "string" ) {
- var classNames = (value || "").split( rspaces );
-
- for ( var i = 0, l = this.length; i < l; i++ ) {
- var elem = this[i];
-
- if ( elem.nodeType === 1 ) {
- if ( !elem.className ) {
- elem.className = value;
-
- } else {
- var className = " " + elem.className + " ",
- setClass = elem.className;
-
- for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
- if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
- setClass += " " + classNames[c];
- }
- }
- elem.className = jQuery.trim( setClass );
- }
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- if ( jQuery.isFunction(value) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- self.removeClass( value.call(this, i, self.attr("class")) );
- });
- }
-
- if ( (value && typeof value === "string") || value === undefined ) {
- var classNames = (value || "").split( rspaces );
-
- for ( var i = 0, l = this.length; i < l; i++ ) {
- var elem = this[i];
-
- if ( elem.nodeType === 1 && elem.className ) {
- if ( value ) {
- var className = (" " + elem.className + " ").replace(rclass, " ");
- for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
- className = className.replace(" " + classNames[c] + " ", " ");
- }
- elem.className = jQuery.trim( className );
-
- } else {
- elem.className = "";
- }
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value,
- isBool = typeof stateVal === "boolean";
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
- });
- }
-
- return this.each(function() {
- if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- state = stateVal,
- classNames = value.split( rspaces );
-
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space seperated list
- state = isBool ? state : !self.hasClass( className );
- self[ state ? "addClass" : "removeClass" ]( className );
- }
-
- } else if ( type === "undefined" || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- jQuery.data( this, "__className__", this.className );
- }
-
- // toggle whole className
- this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
- }
- });
- },
-
- hasClass: function( selector ) {
- var className = " " + selector + " ";
- for ( var i = 0, l = this.length; i < l; i++ ) {
- if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
- return true;
- }
- }
-
- return false;
- },
-
- val: function( value ) {
- if ( !arguments.length ) {
- var elem = this[0];
-
- if ( elem ) {
- if ( jQuery.nodeName( elem, "option" ) ) {
- // attributes.value is undefined in Blackberry 4.7 but
- // uses .value. See #6932
- var val = elem.attributes.value;
- return !val || val.specified ? elem.value : elem.text;
- }
-
- // We need to handle select boxes special
- if ( jQuery.nodeName( elem, "select" ) ) {
- var index = elem.selectedIndex,
- values = [],
- options = elem.options,
- one = elem.type === "select-one";
-
- // Nothing was selected
- if ( index < 0 ) {
- return null;
- }
-
- // Loop through all the selected options
- for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
- var option = options[ i ];
-
- // Don't return options that are disabled or in a disabled optgroup
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
- (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
-
- // Get the specific value for the option
- value = jQuery(option).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- return values;
- }
-
- // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
- if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
- return elem.getAttribute("value") === null ? "on" : elem.value;
- }
-
-
- // Everything else, we just grab the value
- return (elem.value || "").replace(rreturn, "");
-
- }
-
- return undefined;
- }
-
- var isFunction = jQuery.isFunction(value);
-
- return this.each(function(i) {
- var self = jQuery(this), val = value;
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( isFunction ) {
- val = value.call(this, i, self.val());
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray(val) ) {
- val = jQuery.map(val, function (value) {
- return value == null ? "" : value + "";
- });
- }
-
- if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
- this.checked = jQuery.inArray( self.val(), val ) >= 0;
-
- } else if ( jQuery.nodeName( this, "select" ) ) {
- var values = jQuery.makeArray(val);
-
- jQuery( "option", this ).each(function() {
- this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
- });
-
- if ( !values.length ) {
- this.selectedIndex = -1;
- }
-
- } else {
- this.value = val;
- }
- });
- }
-});
-
-jQuery.extend({
- attrFn: {
- val: true,
- css: true,
- html: true,
- text: true,
- data: true,
- width: true,
- height: true,
- offset: true
- },
-
- attr: function( elem, name, value, pass ) {
- // don't set attributes on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
- return undefined;
- }
-
- if ( pass && name in jQuery.attrFn ) {
- return jQuery(elem)[name](value);
- }
-
- var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
- // Whether we are setting (or getting)
- set = value !== undefined;
-
- // Try to normalize/fix the name
- name = notxml && jQuery.props[ name ] || name;
-
- // These attributes require special treatment
- var special = rspecialurl.test( name );
-
- // Safari mis-reports the default selected property of an option
- // Accessing the parent's selectedIndex property fixes it
- if ( name === "selected" && !jQuery.support.optSelected ) {
- var parent = elem.parentNode;
- if ( parent ) {
- parent.selectedIndex;
-
- // Make sure that it also works with optgroups, see #5701
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- }
-
- // If applicable, access the attribute via the DOM 0 way
- // 'in' checks fail in Blackberry 4.7 #6931
- if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
- if ( set ) {
- // We can't allow the type property to be changed (since it causes problems in IE)
- if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
- jQuery.error( "type property can't be changed" );
- }
-
- if ( value === null ) {
- if ( elem.nodeType === 1 ) {
- elem.removeAttribute( name );
- }
-
- } else {
- elem[ name ] = value;
- }
- }
-
- // browsers index elements by id/name on forms, give priority to attributes.
- if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
- return elem.getAttributeNode( name ).nodeValue;
- }
-
- // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
- // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabi...
- if ( name === "tabIndex" ) {
- var attributeNode = elem.getAttributeNode( "tabIndex" );
-
- return attributeNode && attributeNode.specified ?
- attributeNode.value :
- rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
- 0 :
- undefined;
- }
-
- return elem[ name ];
- }
-
- if ( !jQuery.support.style && notxml && name === "style" ) {
- if ( set ) {
- elem.style.cssText = "" + value;
- }
-
- return elem.style.cssText;
- }
-
- if ( set ) {
- // convert the value to a string (all browsers do this but IE) see #1070
- elem.setAttribute( name, "" + value );
- }
-
- // Ensure that missing attributes return undefined
- // Blackberry 4.7 returns "" from getAttribute #6938
- if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
- return undefined;
- }
-
- var attr = !jQuery.support.hrefNormalized && notxml && special ?
- // Some attributes require a special call on IE
- elem.getAttribute( name, 2 ) :
- elem.getAttribute( name );
-
- // Non-existent attributes return null, we normalize to undefined
- return attr === null ? undefined : attr;
- }
-});
-
-
-
-
-var rnamespaces = /\.(.*)$/,
- rformElems = /^(?:textarea|input|select)$/i,
- rperiod = /\./g,
- rspace = / /g,
- rescape = /[^\w\s.|`]/g,
- fcleanup = function( nm ) {
- return nm.replace(rescape, "\\$&");
- },
- focusCounts = { focusin: 0, focusout: 0 };
-
-/*
- * A number of helper functions used for managing events.
- * Many of the ideas behind this code originated from
- * Dean Edwards' addEvent library.
- */
-jQuery.event = {
-
- // Bind an event to an element
- // Original by Dean Edwards
- add: function( elem, types, handler, data ) {
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- // For whatever reason, IE has trouble passing the window object
- // around, causing it to be cloned in the process
- if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
- elem = window;
- }
-
- if ( handler === false ) {
- handler = returnFalse;
- } else if ( !handler ) {
- // Fixes bug #7229. Fix recommended by jdalton
- return;
- }
-
- var handleObjIn, handleObj;
-
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- }
-
- // Make sure that the function being executed has a unique ID
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
-
- // Init the element's event structure
- var elemData = jQuery.data( elem );
-
- // If no elemData is found then we must be trying to bind to one of the
- // banned noData elements
- if ( !elemData ) {
- return;
- }
-
- // Use a key less likely to result in collisions for plain JS objects.
- // Fixes bug #7150.
- var eventKey = elem.nodeType ? "events" : "__events__",
- events = elemData[ eventKey ],
- eventHandle = elemData.handle;
-
- if ( typeof events === "function" ) {
- // On plain objects events is a fn that holds the the data
- // which prevents this data from being JSON serialized
- // the function does not need to be called, it just contains the data
- eventHandle = events.handle;
- events = events.events;
-
- } else if ( !events ) {
- if ( !elem.nodeType ) {
- // On plain objects, create a fn that acts as the holder
- // of the values to avoid JSON serialization of event data
- elemData[ eventKey ] = elemData = function(){};
- }
-
- elemData.events = events = {};
- }
-
- if ( !eventHandle ) {
- elemData.handle = eventHandle = function() {
- // Handle the second event of a trigger and when
- // an event is called after a page has unloaded
- return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
- jQuery.event.handle.apply( eventHandle.elem, arguments ) :
- undefined;
- };
- }
-
- // Add elem as a property of the handle function
- // This is to prevent a memory leak with non-native events in IE.
- eventHandle.elem = elem;
-
- // Handle multiple events separated by a space
- // jQuery(...).bind("mouseover mouseout", fn);
- types = types.split(" ");
-
- var type, i = 0, namespaces;
-
- while ( (type = types[ i++ ]) ) {
- handleObj = handleObjIn ?
- jQuery.extend({}, handleObjIn) :
- { handler: handler, data: data };
-
- // Namespaced event handlers
- if ( type.indexOf(".") > -1 ) {
- namespaces = type.split(".");
- type = namespaces.shift();
- handleObj.namespace = namespaces.slice(0).sort().join(".");
-
- } else {
- namespaces = [];
- handleObj.namespace = "";
- }
-
- handleObj.type = type;
- if ( !handleObj.guid ) {
- handleObj.guid = handler.guid;
- }
-
- // Get the current list of functions bound to this event
- var handlers = events[ type ],
- special = jQuery.event.special[ type ] || {};
-
- // Init the event handler queue
- if ( !handlers ) {
- handlers = events[ type ] = [];
-
- // Check for a special event handler
- // Only use addEventListener/attachEvent if the special
- // events handler returns false
- if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
- // Bind the global event handler to the element
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
-
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- }
- }
-
- if ( special.add ) {
- special.add.call( elem, handleObj );
-
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
-
- // Add the function to the element's handler list
- handlers.push( handleObj );
-
- // Keep track of which events have been used, for global triggering
- jQuery.event.global[ type ] = true;
- }
-
- // Nullify elem to prevent memory leaks in IE
- elem = null;
- },
-
- global: {},
-
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, pos ) {
- // don't do events on text and comment nodes
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- if ( handler === false ) {
- handler = returnFalse;
- }
-
- var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
- eventKey = elem.nodeType ? "events" : "__events__",
- elemData = jQuery.data( elem ),
- events = elemData && elemData[ eventKey ];
-
- if ( !elemData || !events ) {
- return;
- }
-
- if ( typeof events === "function" ) {
- elemData = events;
- events = events.events;
- }
-
- // types is actually an event object here
- if ( types && types.type ) {
- handler = types.handler;
- types = types.type;
- }
-
- // Unbind all events for the element
- if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
- types = types || "";
-
- for ( type in events ) {
- jQuery.event.remove( elem, type + types );
- }
-
- return;
- }
-
- // Handle multiple events separated by a space
- // jQuery(...).unbind("mouseover mouseout", fn);
- types = types.split(" ");
-
- while ( (type = types[ i++ ]) ) {
- origType = type;
- handleObj = null;
- all = type.indexOf(".") < 0;
- namespaces = [];
-
- if ( !all ) {
- // Namespaced event handlers
- namespaces = type.split(".");
- type = namespaces.shift();
-
- namespace = new RegExp("(^|\\.)" +
- jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
- }
-
- eventType = events[ type ];
-
- if ( !eventType ) {
- continue;
- }
-
- if ( !handler ) {
- for ( j = 0; j < eventType.length; j++ ) {
- handleObj = eventType[ j ];
-
- if ( all || namespace.test( handleObj.namespace ) ) {
- jQuery.event.remove( elem, origType, handleObj.handler, j );
- eventType.splice( j--, 1 );
- }
- }
-
- continue;
- }
-
- special = jQuery.event.special[ type ] || {};
-
- for ( j = pos || 0; j < eventType.length; j++ ) {
- handleObj = eventType[ j ];
-
- if ( handler.guid === handleObj.guid ) {
- // remove the given handler for the given type
- if ( all || namespace.test( handleObj.namespace ) ) {
- if ( pos == null ) {
- eventType.splice( j--, 1 );
- }
-
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
-
- if ( pos != null ) {
- break;
- }
- }
- }
-
- // remove generic event handler if no more handlers exist
- if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
- if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
- jQuery.removeEvent( elem, type, elemData.handle );
- }
-
- ret = null;
- delete events[ type ];
- }
- }
-
- // Remove the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- var handle = elemData.handle;
- if ( handle ) {
- handle.elem = null;
- }
-
- delete elemData.events;
- delete elemData.handle;
-
- if ( typeof elemData === "function" ) {
- jQuery.removeData( elem, eventKey );
-
- } else if ( jQuery.isEmptyObject( elemData ) ) {
- jQuery.removeData( elem );
- }
- }
- },
-
- // bubbling is internal
- trigger: function( event, data, elem /*, bubbling */ ) {
- // Event object or event type
- var type = event.type || event,
- bubbling = arguments[3];
-
- if ( !bubbling ) {
- event = typeof event === "object" ?
- // jQuery.Event object
- event[ jQuery.expando ] ? event :
- // Object literal
- jQuery.extend( jQuery.Event(type), event ) :
- // Just the event type (string)
- jQuery.Event(type);
-
- if ( type.indexOf("!") >= 0 ) {
- event.type = type = type.slice(0, -1);
- event.exclusive = true;
- }
-
- // Handle a global trigger
- if ( !elem ) {
- // Don't bubble custom events when global (to avoid too much overhead)
- event.stopPropagation();
-
- // Only trigger if we've ever bound an event for it
- if ( jQuery.event.global[ type ] ) {
- jQuery.each( jQuery.cache, function() {
- if ( this.events && this.events[type] ) {
- jQuery.event.trigger( event, data, this.handle.elem );
- }
- });
- }
- }
-
- // Handle triggering a single element
-
- // don't do events on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
- return undefined;
- }
-
- // Clean up in case it is reused
- event.result = undefined;
- event.target = elem;
-
- // Clone the incoming data, if any
- data = jQuery.makeArray( data );
- data.unshift( event );
- }
-
- event.currentTarget = elem;
-
- // Trigger the event, it is assumed that "handle" is a function
- var handle = elem.nodeType ?
- jQuery.data( elem, "handle" ) :
- (jQuery.data( elem, "__events__" ) || {}).handle;
-
- if ( handle ) {
- handle.apply( elem, data );
- }
-
- var parent = elem.parentNode || elem.ownerDocument;
-
- // Trigger an inline bound script
- try {
- if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
- if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
- event.result = false;
- event.preventDefault();
- }
- }
-
- // prevent IE from throwing an error for some elements with some event types, see #3533
- } catch (inlineError) {}
-
- if ( !event.isPropagationStopped() && parent ) {
- jQuery.event.trigger( event, data, parent, true );
-
- } else if ( !event.isDefaultPrevented() ) {
- var old,
- target = event.target,
- targetType = type.replace( rnamespaces, "" ),
- isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
- special = jQuery.event.special[ targetType ] || {};
-
- if ( (!special._default || special._default.call( elem, event ) === false) &&
- !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
-
- try {
- if ( target[ targetType ] ) {
- // Make sure that we don't accidentally re-trigger the onFOO events
- old = target[ "on" + targetType ];
-
- if ( old ) {
- target[ "on" + targetType ] = null;
- }
-
- jQuery.event.triggered = true;
- target[ targetType ]();
- }
-
- // prevent IE from throwing an error for some elements with some event types, see #3533
- } catch (triggerError) {}
-
- if ( old ) {
- target[ "on" + targetType ] = old;
- }
-
- jQuery.event.triggered = false;
- }
- }
- },
-
- handle: function( event ) {
- var all, handlers, namespaces, namespace_re, events,
- namespace_sort = [],
- args = jQuery.makeArray( arguments );
-
- event = args[0] = jQuery.event.fix( event || window.event );
- event.currentTarget = this;
-
- // Namespaced event handlers
- all = event.type.indexOf(".") < 0 && !event.exclusive;
-
- if ( !all ) {
- namespaces = event.type.split(".");
- event.type = namespaces.shift();
- namespace_sort = namespaces.slice(0).sort();
- namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
- }
-
- event.namespace = event.namespace || namespace_sort.join(".");
-
- events = jQuery.data(this, this.nodeType ? "events" : "__events__");
-
- if ( typeof events === "function" ) {
- events = events.events;
- }
-
- handlers = (events || {})[ event.type ];
-
- if ( events && handlers ) {
- // Clone the handlers to prevent manipulation
- handlers = handlers.slice(0);
-
- for ( var j = 0, l = handlers.length; j < l; j++ ) {
- var handleObj = handlers[ j ];
-
- // Filter the functions by class
- if ( all || namespace_re.test( handleObj.namespace ) ) {
- // Pass in a reference to the handler function itself
- // So that we can later remove it
- event.handler = handleObj.handler;
- event.data = handleObj.data;
- event.handleObj = handleObj;
-
- var ret = handleObj.handler.apply( this, args );
-
- if ( ret !== undefined ) {
- event.result = ret;
- if ( ret === false ) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
-
- if ( event.isImmediatePropagationStopped() ) {
- break;
- }
- }
- }
- }
-
- return event.result;
- },
-
- props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
-
- fix: function( event ) {
- if ( event[ jQuery.expando ] ) {
- return event;
- }
-
- // store a copy of the original event object
- // and "clone" to set read-only properties
- var originalEvent = event;
- event = jQuery.Event( originalEvent );
-
- for ( var i = this.props.length, prop; i; ) {
- prop = this.props[ --i ];
- event[ prop ] = originalEvent[ prop ];
- }
-
- // Fix target property, if necessary
- if ( !event.target ) {
- // Fixes #1925 where srcElement might not be defined either
- event.target = event.srcElement || document;
- }
-
- // check if target is a textnode (safari)
- if ( event.target.nodeType === 3 ) {
- event.target = event.target.parentNode;
- }
-
- // Add relatedTarget, if necessary
- if ( !event.relatedTarget && event.fromElement ) {
- event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
- }
-
- // Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && event.clientX != null ) {
- var doc = document.documentElement,
- body = document.body;
-
- event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
- event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
- }
-
- // Add which for key events
- if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
- event.which = event.charCode != null ? event.charCode : event.keyCode;
- }
-
- // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
- if ( !event.metaKey && event.ctrlKey ) {
- event.metaKey = event.ctrlKey;
- }
-
- // Add which for click: 1 === left; 2 === middle; 3 === right
- // Note: button is not normalized, so don't use it
- if ( !event.which && event.button !== undefined ) {
- event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
- }
-
- return event;
- },
-
- // Deprecated, use jQuery.guid instead
- guid: 1E8,
-
- // Deprecated, use jQuery.proxy instead
- proxy: jQuery.proxy,
-
- special: {
- ready: {
- // Make sure the ready event is setup
- setup: jQuery.bindReady,
- teardown: jQuery.noop
- },
-
- live: {
- add: function( handleObj ) {
- jQuery.event.add( this,
- liveConvert( handleObj.origType, handleObj.selector ),
- jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
- },
-
- remove: function( handleObj ) {
- jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
- }
- },
-
- beforeunload: {
- setup: function( data, namespaces, eventHandle ) {
- // We only want to do this special case on windows
- if ( jQuery.isWindow( this ) ) {
- this.onbeforeunload = eventHandle;
- }
- },
-
- teardown: function( namespaces, eventHandle ) {
- if ( this.onbeforeunload === eventHandle ) {
- this.onbeforeunload = null;
- }
- }
- }
- }
-};
-
-jQuery.removeEvent = document.removeEventListener ?
- function( elem, type, handle ) {
- if ( elem.removeEventListener ) {
- elem.removeEventListener( type, handle, false );
- }
- } :
- function( elem, type, handle ) {
- if ( elem.detachEvent ) {
- elem.detachEvent( "on" + type, handle );
- }
- };
-
-jQuery.Event = function( src ) {
- // Allow instantiation without the 'new' keyword
- if ( !this.preventDefault ) {
- return new jQuery.Event( src );
- }
-
- // Event object
- if ( src && src.type ) {
- this.originalEvent = src;
- this.type = src.type;
- // Event type
- } else {
- this.type = src;
- }
-
- // timeStamp is buggy for some events on Firefox(#3843)
- // So we won't rely on the native value
- this.timeStamp = jQuery.now();
-
- // Mark it as fixed
- this[ jQuery.expando ] = true;
-};
-
-function returnFalse() {
- return false;
-}
-function returnTrue() {
- return true;
-}
-
-// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
-// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-bind...
-jQuery.Event.prototype = {
- preventDefault: function() {
- this.isDefaultPrevented = returnTrue;
-
- var e = this.originalEvent;
- if ( !e ) {
- return;
- }
-
- // if preventDefault exists run it on the original event
- if ( e.preventDefault ) {
- e.preventDefault();
-
- // otherwise set the returnValue property of the original event to false (IE)
- } else {
- e.returnValue = false;
- }
- },
- stopPropagation: function() {
- this.isPropagationStopped = returnTrue;
-
- var e = this.originalEvent;
- if ( !e ) {
- return;
- }
- // if stopPropagation exists run it on the original event
- if ( e.stopPropagation ) {
- e.stopPropagation();
- }
- // otherwise set the cancelBubble property of the original event to true (IE)
- e.cancelBubble = true;
- },
- stopImmediatePropagation: function() {
- this.isImmediatePropagationStopped = returnTrue;
- this.stopPropagation();
- },
- isDefaultPrevented: returnFalse,
- isPropagationStopped: returnFalse,
- isImmediatePropagationStopped: returnFalse
-};
-
-// Checks if an event happened on an element within another element
-// Used in jQuery.event.special.mouseenter and mouseleave handlers
-var withinElement = function( event ) {
- // Check if mouse(over|out) are still within the same parent element
- var parent = event.relatedTarget;
-
- // Firefox sometimes assigns relatedTarget a XUL element
- // which we cannot access the parentNode property of
- try {
- // Traverse up the tree
- while ( parent && parent !== this ) {
- parent = parent.parentNode;
- }
-
- if ( parent !== this ) {
- // set the correct event type
- event.type = event.data;
-
- // handle event if we actually just moused on to a non sub-element
- jQuery.event.handle.apply( this, arguments );
- }
-
- // assuming we've left the element since we most likely mousedover a xul element
- } catch(e) { }
-},
-
-// In case of event delegation, we only need to rename the event.type,
-// liveHandler will take care of the rest.
-delegate = function( event ) {
- event.type = event.data;
- jQuery.event.handle.apply( this, arguments );
-};
-
-// Create mouseenter and mouseleave events
-jQuery.each({
- mouseenter: "mouseover",
- mouseleave: "mouseout"
-}, function( orig, fix ) {
- jQuery.event.special[ orig ] = {
- setup: function( data ) {
- jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
- },
- teardown: function( data ) {
- jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
- }
- };
-});
-
-// submit delegation
-if ( !jQuery.support.submitBubbles ) {
-
- jQuery.event.special.submit = {
- setup: function( data, namespaces ) {
- if ( this.nodeName.toLowerCase() !== "form" ) {
- jQuery.event.add(this, "click.specialSubmit", function( e ) {
- var elem = e.target,
- type = elem.type;
-
- if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
- e.liveFired = undefined;
- return trigger( "submit", this, arguments );
- }
- });
-
- jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
- var elem = e.target,
- type = elem.type;
-
- if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
- e.liveFired = undefined;
- return trigger( "submit", this, arguments );
- }
- });
-
- } else {
- return false;
- }
- },
-
- teardown: function( namespaces ) {
- jQuery.event.remove( this, ".specialSubmit" );
- }
- };
-
-}
-
-// change delegation, happens here so we have bind.
-if ( !jQuery.support.changeBubbles ) {
-
- var changeFilters,
-
- getVal = function( elem ) {
- var type = elem.type, val = elem.value;
-
- if ( type === "radio" || type === "checkbox" ) {
- val = elem.checked;
-
- } else if ( type === "select-multiple" ) {
- val = elem.selectedIndex > -1 ?
- jQuery.map( elem.options, function( elem ) {
- return elem.selected;
- }).join("-") :
- "";
-
- } else if ( elem.nodeName.toLowerCase() === "select" ) {
- val = elem.selectedIndex;
- }
-
- return val;
- },
-
- testChange = function testChange( e ) {
- var elem = e.target, data, val;
-
- if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
- return;
- }
-
- data = jQuery.data( elem, "_change_data" );
- val = getVal(elem);
-
- // the current data will be also retrieved by beforeactivate
- if ( e.type !== "focusout" || elem.type !== "radio" ) {
- jQuery.data( elem, "_change_data", val );
- }
-
- if ( data === undefined || val === data ) {
- return;
- }
-
- if ( data != null || val ) {
- e.type = "change";
- e.liveFired = undefined;
- return jQuery.event.trigger( e, arguments[1], elem );
- }
- };
-
- jQuery.event.special.change = {
- filters: {
- focusout: testChange,
-
- beforedeactivate: testChange,
-
- click: function( e ) {
- var elem = e.target, type = elem.type;
-
- if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
- return testChange.call( this, e );
- }
- },
-
- // Change has to be called before submit
- // Keydown will be called before keypress, which is used in submit-event delegation
- keydown: function( e ) {
- var elem = e.target, type = elem.type;
-
- if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
- (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
- type === "select-multiple" ) {
- return testChange.call( this, e );
- }
- },
-
- // Beforeactivate happens also before the previous element is blurred
- // with this event you can't trigger a change event, but you can store
- // information
- beforeactivate: function( e ) {
- var elem = e.target;
- jQuery.data( elem, "_change_data", getVal(elem) );
- }
- },
-
- setup: function( data, namespaces ) {
- if ( this.type === "file" ) {
- return false;
- }
-
- for ( var type in changeFilters ) {
- jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
- }
-
- return rformElems.test( this.nodeName );
- },
-
- teardown: function( namespaces ) {
- jQuery.event.remove( this, ".specialChange" );
-
- return rformElems.test( this.nodeName );
- }
- };
-
- changeFilters = jQuery.event.special.change.filters;
-
- // Handle when the input is .focus()'d
- changeFilters.focus = changeFilters.beforeactivate;
-}
-
-function trigger( type, elem, args ) {
- args[0].type = type;
- return jQuery.event.handle.apply( elem, args );
-}
-
-// Create "bubbling" focus and blur events
-if ( document.addEventListener ) {
- jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
- jQuery.event.special[ fix ] = {
- setup: function() {
- if ( focusCounts[fix]++ === 0 ) {
- document.addEventListener( orig, handler, true );
- }
- },
- teardown: function() {
- if ( --focusCounts[fix] === 0 ) {
- document.removeEventListener( orig, handler, true );
- }
- }
- };
-
- function handler( e ) {
- e = jQuery.event.fix( e );
- e.type = fix;
- return jQuery.event.trigger( e, null, e.target );
- }
- });
-}
-
-jQuery.each(["bind", "one"], function( i, name ) {
- jQuery.fn[ name ] = function( type, data, fn ) {
- // Handle object literals
- if ( typeof type === "object" ) {
- for ( var key in type ) {
- this[ name ](key, data, type[key], fn);
- }
- return this;
- }
-
- if ( jQuery.isFunction( data ) || data === false ) {
- fn = data;
- data = undefined;
- }
-
- var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
- jQuery( this ).unbind( event, handler );
- return fn.apply( this, arguments );
- }) : fn;
-
- if ( type === "unload" && name !== "one" ) {
- this.one( type, data, fn );
-
- } else {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- jQuery.event.add( this[i], type, handler, data );
- }
- }
-
- return this;
- };
-});
-
-jQuery.fn.extend({
- unbind: function( type, fn ) {
- // Handle object literals
- if ( typeof type === "object" && !type.preventDefault ) {
- for ( var key in type ) {
- this.unbind(key, type[key]);
- }
-
- } else {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- jQuery.event.remove( this[i], type, fn );
- }
- }
-
- return this;
- },
-
- delegate: function( selector, types, data, fn ) {
- return this.live( types, data, fn, selector );
- },
-
- undelegate: function( selector, types, fn ) {
- if ( arguments.length === 0 ) {
- return this.unbind( "live" );
-
- } else {
- return this.die( types, null, fn, selector );
- }
- },
-
- trigger: function( type, data ) {
- return this.each(function() {
- jQuery.event.trigger( type, data, this );
- });
- },
-
- triggerHandler: function( type, data ) {
- if ( this[0] ) {
- var event = jQuery.Event( type );
- event.preventDefault();
- event.stopPropagation();
- jQuery.event.trigger( event, data, this[0] );
- return event.result;
- }
- },
-
- toggle: function( fn ) {
- // Save reference to arguments for access in closure
- var args = arguments,
- i = 1;
-
- // link all the functions, so any of them can unbind this click handler
- while ( i < args.length ) {
- jQuery.proxy( fn, args[ i++ ] );
- }
-
- return this.click( jQuery.proxy( fn, function( event ) {
- // Figure out which function to execute
- var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
- jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
-
- // Make sure that clicks stop
- event.preventDefault();
-
- // and execute the function
- return args[ lastToggle ].apply( this, arguments ) || false;
- }));
- },
-
- hover: function( fnOver, fnOut ) {
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- }
-});
-
-var liveMap = {
- focus: "focusin",
- blur: "focusout",
- mouseenter: "mouseover",
- mouseleave: "mouseout"
-};
-
-jQuery.each(["live", "die"], function( i, name ) {
- jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
- var type, i = 0, match, namespaces, preType,
- selector = origSelector || this.selector,
- context = origSelector ? this : jQuery( this.context );
-
- if ( typeof types === "object" && !types.preventDefault ) {
- for ( var key in types ) {
- context[ name ]( key, data, types[key], selector );
- }
-
- return this;
- }
-
- if ( jQuery.isFunction( data ) ) {
- fn = data;
- data = undefined;
- }
-
- types = (types || "").split(" ");
-
- while ( (type = types[ i++ ]) != null ) {
- match = rnamespaces.exec( type );
- namespaces = "";
-
- if ( match ) {
- namespaces = match[0];
- type = type.replace( rnamespaces, "" );
- }
-
- if ( type === "hover" ) {
- types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
- continue;
- }
-
- preType = type;
-
- if ( type === "focus" || type === "blur" ) {
- types.push( liveMap[ type ] + namespaces );
- type = type + namespaces;
-
- } else {
- type = (liveMap[ type ] || type) + namespaces;
- }
-
- if ( name === "live" ) {
- // bind live handler
- for ( var j = 0, l = context.length; j < l; j++ ) {
- jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
- { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
- }
-
- } else {
- // unbind live handler
- context.unbind( "live." + liveConvert( type, selector ), fn );
- }
- }
-
- return this;
- };
-});
-
-function liveHandler( event ) {
- var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
- elems = [],
- selectors = [],
- events = jQuery.data( this, this.nodeType ? "events" : "__events__" );
-
- if ( typeof events === "function" ) {
- events = events.events;
- }
-
- // Make sure we avoid non-left-click bubbling in Firefox (#3861)
- if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
- return;
- }
-
- if ( event.namespace ) {
- namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
- }
-
- event.liveFired = this;
-
- var live = events.live.slice(0);
-
- for ( j = 0; j < live.length; j++ ) {
- handleObj = live[j];
-
- if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
- selectors.push( handleObj.selector );
-
- } else {
- live.splice( j--, 1 );
- }
- }
-
- match = jQuery( event.target ).closest( selectors, event.currentTarget );
-
- for ( i = 0, l = match.length; i < l; i++ ) {
- close = match[i];
-
- for ( j = 0; j < live.length; j++ ) {
- handleObj = live[j];
-
- if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
- elem = close.elem;
- related = null;
-
- // Those two events require additional checking
- if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
- event.type = handleObj.preType;
- related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
- }
-
- if ( !related || related !== elem ) {
- elems.push({ elem: elem, handleObj: handleObj, level: close.level });
- }
- }
- }
- }
-
- for ( i = 0, l = elems.length; i < l; i++ ) {
- match = elems[i];
-
- if ( maxLevel && match.level > maxLevel ) {
- break;
- }
-
- event.currentTarget = match.elem;
- event.data = match.handleObj.data;
- event.handleObj = match.handleObj;
-
- ret = match.handleObj.origHandler.apply( match.elem, arguments );
-
- if ( ret === false || event.isPropagationStopped() ) {
- maxLevel = match.level;
-
- if ( ret === false ) {
- stop = false;
- }
- if ( event.isImmediatePropagationStopped() ) {
- break;
- }
- }
- }
-
- return stop;
-}
-
-function liveConvert( type, selector ) {
- return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
-}
-
-jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
-
- // Handle event binding
- jQuery.fn[ name ] = function( data, fn ) {
- if ( fn == null ) {
- fn = data;
- data = null;
- }
-
- return arguments.length > 0 ?
- this.bind( name, data, fn ) :
- this.trigger( name );
- };
-
- if ( jQuery.attrFn ) {
- jQuery.attrFn[ name ] = true;
- }
-});
-
-// Prevent memory leaks in IE
-// Window isn't included so as not to unbind existing unload events
-// More info:
-// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
-if ( window.attachEvent && !window.addEventListener ) {
- jQuery(window).bind("unload", function() {
- for ( var id in jQuery.cache ) {
- if ( jQuery.cache[ id ].handle ) {
- // Try/Catch is to handle iframes being unloaded, see #4280
- try {
- jQuery.event.remove( jQuery.cache[ id ].handle.elem );
- } catch(e) {}
- }
- }
- });
-}
-
-
-/*!
- * Sizzle CSS Selector Engine - v1.0
- * Copyright 2009, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- * More information: http://sizzlejs.com/
- */
-(function(){
-
-var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
- done = 0,
- toString = Object.prototype.toString,
- hasDuplicate = false,
- baseHasDuplicate = true;
-
-// Here we check if the JavaScript engine is using some sort of
-// optimization where it does not always call our comparision
-// function. If that is the case, discard the hasDuplicate value.
-// Thus far that includes Google Chrome.
-[0, 0].sort(function() {
- baseHasDuplicate = false;
- return 0;
-});
-
-var Sizzle = function( selector, context, results, seed ) {
- results = results || [];
- context = context || document;
-
- var origContext = context;
-
- if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
- return [];
- }
-
- if ( !selector || typeof selector !== "string" ) {
- return results;
- }
-
- var m, set, checkSet, extra, ret, cur, pop, i,
- prune = true,
- contextXML = Sizzle.isXML( context ),
- parts = [],
- soFar = selector;
-
- // Reset the position of the chunker regexp (start from head)
- do {
- chunker.exec( "" );
- m = chunker.exec( soFar );
-
- if ( m ) {
- soFar = m[3];
-
- parts.push( m[1] );
-
- if ( m[2] ) {
- extra = m[3];
- break;
- }
- }
- } while ( m );
-
- if ( parts.length > 1 && origPOS.exec( selector ) ) {
-
- if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
- set = posProcess( parts[0] + parts[1], context );
-
- } else {
- set = Expr.relative[ parts[0] ] ?
- [ context ] :
- Sizzle( parts.shift(), context );
-
- while ( parts.length ) {
- selector = parts.shift();
-
- if ( Expr.relative[ selector ] ) {
- selector += parts.shift();
- }
-
- set = posProcess( selector, set );
- }
- }
-
- } else {
- // Take a shortcut and set the context if the root selector is an ID
- // (but not if it'll be faster if the inner selector is an ID)
- if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
- Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
-
- ret = Sizzle.find( parts.shift(), context, contextXML );
- context = ret.expr ?
- Sizzle.filter( ret.expr, ret.set )[0] :
- ret.set[0];
- }
-
- if ( context ) {
- ret = seed ?
- { expr: parts.pop(), set: makeArray(seed) } :
- Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
-
- set = ret.expr ?
- Sizzle.filter( ret.expr, ret.set ) :
- ret.set;
-
- if ( parts.length > 0 ) {
- checkSet = makeArray( set );
-
- } else {
- prune = false;
- }
-
- while ( parts.length ) {
- cur = parts.pop();
- pop = cur;
-
- if ( !Expr.relative[ cur ] ) {
- cur = "";
- } else {
- pop = parts.pop();
- }
-
- if ( pop == null ) {
- pop = context;
- }
-
- Expr.relative[ cur ]( checkSet, pop, contextXML );
- }
-
- } else {
- checkSet = parts = [];
- }
- }
-
- if ( !checkSet ) {
- checkSet = set;
- }
-
- if ( !checkSet ) {
- Sizzle.error( cur || selector );
- }
-
- if ( toString.call(checkSet) === "[object Array]" ) {
- if ( !prune ) {
- results.push.apply( results, checkSet );
-
- } else if ( context && context.nodeType === 1 ) {
- for ( i = 0; checkSet[i] != null; i++ ) {
- if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
- results.push( set[i] );
- }
- }
-
- } else {
- for ( i = 0; checkSet[i] != null; i++ ) {
- if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
- results.push( set[i] );
- }
- }
- }
-
- } else {
- makeArray( checkSet, results );
- }
-
- if ( extra ) {
- Sizzle( extra, origContext, results, seed );
- Sizzle.uniqueSort( results );
- }
-
- return results;
-};
-
-Sizzle.uniqueSort = function( results ) {
- if ( sortOrder ) {
- hasDuplicate = baseHasDuplicate;
- results.sort( sortOrder );
-
- if ( hasDuplicate ) {
- for ( var i = 1; i < results.length; i++ ) {
- if ( results[i] === results[ i - 1 ] ) {
- results.splice( i--, 1 );
- }
- }
- }
- }
-
- return results;
-};
-
-Sizzle.matches = function( expr, set ) {
- return Sizzle( expr, null, null, set );
-};
-
-Sizzle.matchesSelector = function( node, expr ) {
- return Sizzle( expr, null, null, [node] ).length > 0;
-};
-
-Sizzle.find = function( expr, context, isXML ) {
- var set;
-
- if ( !expr ) {
- return [];
- }
-
- for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
- var match,
- type = Expr.order[i];
-
- if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
- var left = match[1];
- match.splice( 1, 1 );
-
- if ( left.substr( left.length - 1 ) !== "\\" ) {
- match[1] = (match[1] || "").replace(/\\/g, "");
- set = Expr.find[ type ]( match, context, isXML );
-
- if ( set != null ) {
- expr = expr.replace( Expr.match[ type ], "" );
- break;
- }
- }
- }
- }
-
- if ( !set ) {
- set = context.getElementsByTagName( "*" );
- }
-
- return { set: set, expr: expr };
-};
-
-Sizzle.filter = function( expr, set, inplace, not ) {
- var match, anyFound,
- old = expr,
- result = [],
- curLoop = set,
- isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
-
- while ( expr && set.length ) {
- for ( var type in Expr.filter ) {
- if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
- var found, item,
- filter = Expr.filter[ type ],
- left = match[1];
-
- anyFound = false;
-
- match.splice(1,1);
-
- if ( left.substr( left.length - 1 ) === "\\" ) {
- continue;
- }
-
- if ( curLoop === result ) {
- result = [];
- }
-
- if ( Expr.preFilter[ type ] ) {
- match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
-
- if ( !match ) {
- anyFound = found = true;
-
- } else if ( match === true ) {
- continue;
- }
- }
-
- if ( match ) {
- for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
- if ( item ) {
- found = filter( item, match, i, curLoop );
- var pass = not ^ !!found;
-
- if ( inplace && found != null ) {
- if ( pass ) {
- anyFound = true;
-
- } else {
- curLoop[i] = false;
- }
-
- } else if ( pass ) {
- result.push( item );
- anyFound = true;
- }
- }
- }
- }
-
- if ( found !== undefined ) {
- if ( !inplace ) {
- curLoop = result;
- }
-
- expr = expr.replace( Expr.match[ type ], "" );
-
- if ( !anyFound ) {
- return [];
- }
-
- break;
- }
- }
- }
-
- // Improper expression
- if ( expr === old ) {
- if ( anyFound == null ) {
- Sizzle.error( expr );
-
- } else {
- break;
- }
- }
-
- old = expr;
- }
-
- return curLoop;
-};
-
-Sizzle.error = function( msg ) {
- throw "Syntax error, unrecognized expression: " + msg;
-};
-
-var Expr = Sizzle.selectors = {
- order: [ "ID", "NAME", "TAG" ],
-
- match: {
- ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
- CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
- NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
- ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
- TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
- CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
- POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
- PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
- },
-
- leftMatch: {},
-
- attrMap: {
- "class": "className",
- "for": "htmlFor"
- },
-
- attrHandle: {
- href: function( elem ) {
- return elem.getAttribute( "href" );
- }
- },
-
- relative: {
- "+": function(checkSet, part){
- var isPartStr = typeof part === "string",
- isTag = isPartStr && !/\W/.test( part ),
- isPartStrNotTag = isPartStr && !isTag;
-
- if ( isTag ) {
- part = part.toLowerCase();
- }
-
- for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
- if ( (elem = checkSet[i]) ) {
- while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
-
- checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
- elem || false :
- elem === part;
- }
- }
-
- if ( isPartStrNotTag ) {
- Sizzle.filter( part, checkSet, true );
- }
- },
-
- ">": function( checkSet, part ) {
- var elem,
- isPartStr = typeof part === "string",
- i = 0,
- l = checkSet.length;
-
- if ( isPartStr && !/\W/.test( part ) ) {
- part = part.toLowerCase();
-
- for ( ; i < l; i++ ) {
- elem = checkSet[i];
-
- if ( elem ) {
- var parent = elem.parentNode;
- checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
- }
- }
-
- } else {
- for ( ; i < l; i++ ) {
- elem = checkSet[i];
-
- if ( elem ) {
- checkSet[i] = isPartStr ?
- elem.parentNode :
- elem.parentNode === part;
- }
- }
-
- if ( isPartStr ) {
- Sizzle.filter( part, checkSet, true );
- }
- }
- },
-
- "": function(checkSet, part, isXML){
- var nodeCheck,
- doneName = done++,
- checkFn = dirCheck;
-
- if ( typeof part === "string" && !/\W/.test(part) ) {
- part = part.toLowerCase();
- nodeCheck = part;
- checkFn = dirNodeCheck;
- }
-
- checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
- },
-
- "~": function( checkSet, part, isXML ) {
- var nodeCheck,
- doneName = done++,
- checkFn = dirCheck;
-
- if ( typeof part === "string" && !/\W/.test( part ) ) {
- part = part.toLowerCase();
- nodeCheck = part;
- checkFn = dirNodeCheck;
- }
-
- checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
- }
- },
-
- find: {
- ID: function( match, context, isXML ) {
- if ( typeof context.getElementById !== "undefined" && !isXML ) {
- var m = context.getElementById(match[1]);
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- return m && m.parentNode ? [m] : [];
- }
- },
-
- NAME: function( match, context ) {
- if ( typeof context.getElementsByName !== "undefined" ) {
- var ret = [],
- results = context.getElementsByName( match[1] );
-
- for ( var i = 0, l = results.length; i < l; i++ ) {
- if ( results[i].getAttribute("name") === match[1] ) {
- ret.push( results[i] );
- }
- }
-
- return ret.length === 0 ? null : ret;
- }
- },
-
- TAG: function( match, context ) {
- return context.getElementsByTagName( match[1] );
- }
- },
- preFilter: {
- CLASS: function( match, curLoop, inplace, result, not, isXML ) {
- match = " " + match[1].replace(/\\/g, "") + " ";
-
- if ( isXML ) {
- return match;
- }
-
- for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
- if ( elem ) {
- if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
- if ( !inplace ) {
- result.push( elem );
- }
-
- } else if ( inplace ) {
- curLoop[i] = false;
- }
- }
- }
-
- return false;
- },
-
- ID: function( match ) {
- return match[1].replace(/\\/g, "");
- },
-
- TAG: function( match, curLoop ) {
- return match[1].toLowerCase();
- },
-
- CHILD: function( match ) {
- if ( match[1] === "nth" ) {
- // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
- var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
- match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
- !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
-
- // calculate the numbers (first)n+(last) including if they are negative
- match[2] = (test[1] + (test[2] || 1)) - 0;
- match[3] = test[3] - 0;
- }
-
- // TODO: Move to normal caching system
- match[0] = done++;
-
- return match;
- },
-
- ATTR: function( match, curLoop, inplace, result, not, isXML ) {
- var name = match[1].replace(/\\/g, "");
-
- if ( !isXML && Expr.attrMap[name] ) {
- match[1] = Expr.attrMap[name];
- }
-
- if ( match[2] === "~=" ) {
- match[4] = " " + match[4] + " ";
- }
-
- return match;
- },
-
- PSEUDO: function( match, curLoop, inplace, result, not ) {
- if ( match[1] === "not" ) {
- // If we're dealing with a complex expression, or a simple one
- if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
- match[3] = Sizzle(match[3], null, null, curLoop);
-
- } else {
- var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
-
- if ( !inplace ) {
- result.push.apply( result, ret );
- }
-
- return false;
- }
-
- } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
- return true;
- }
-
- return match;
- },
-
- POS: function( match ) {
- match.unshift( true );
-
- return match;
- }
- },
-
- filters: {
- enabled: function( elem ) {
- return elem.disabled === false && elem.type !== "hidden";
- },
-
- disabled: function( elem ) {
- return elem.disabled === true;
- },
-
- checked: function( elem ) {
- return elem.checked === true;
- },
-
- selected: function( elem ) {
- // Accessing this property makes selected-by-default
- // options in Safari work properly
- elem.parentNode.selectedIndex;
-
- return elem.selected === true;
- },
-
- parent: function( elem ) {
- return !!elem.firstChild;
- },
-
- empty: function( elem ) {
- return !elem.firstChild;
- },
-
- has: function( elem, i, match ) {
- return !!Sizzle( match[3], elem ).length;
- },
-
- header: function( elem ) {
- return (/h\d/i).test( elem.nodeName );
- },
-
- text: function( elem ) {
- return "text" === elem.type;
- },
- radio: function( elem ) {
- return "radio" === elem.type;
- },
-
- checkbox: function( elem ) {
- return "checkbox" === elem.type;
- },
-
- file: function( elem ) {
- return "file" === elem.type;
- },
- password: function( elem ) {
- return "password" === elem.type;
- },
-
- submit: function( elem ) {
- return "submit" === elem.type;
- },
-
- image: function( elem ) {
- return "image" === elem.type;
- },
-
- reset: function( elem ) {
- return "reset" === elem.type;
- },
-
- button: function( elem ) {
- return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
- },
-
- input: function( elem ) {
- return (/input|select|textarea|button/i).test( elem.nodeName );
- }
- },
- setFilters: {
- first: function( elem, i ) {
- return i === 0;
- },
-
- last: function( elem, i, match, array ) {
- return i === array.length - 1;
- },
-
- even: function( elem, i ) {
- return i % 2 === 0;
- },
-
- odd: function( elem, i ) {
- return i % 2 === 1;
- },
-
- lt: function( elem, i, match ) {
- return i < match[3] - 0;
- },
-
- gt: function( elem, i, match ) {
- return i > match[3] - 0;
- },
-
- nth: function( elem, i, match ) {
- return match[3] - 0 === i;
- },
-
- eq: function( elem, i, match ) {
- return match[3] - 0 === i;
- }
- },
- filter: {
- PSEUDO: function( elem, match, i, array ) {
- var name = match[1],
- filter = Expr.filters[ name ];
-
- if ( filter ) {
- return filter( elem, i, match, array );
-
- } else if ( name === "contains" ) {
- return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
-
- } else if ( name === "not" ) {
- var not = match[3];
-
- for ( var j = 0, l = not.length; j < l; j++ ) {
- if ( not[j] === elem ) {
- return false;
- }
- }
-
- return true;
-
- } else {
- Sizzle.error( "Syntax error, unrecognized expression: " + name );
- }
- },
-
- CHILD: function( elem, match ) {
- var type = match[1],
- node = elem;
-
- switch ( type ) {
- case "only":
- case "first":
- while ( (node = node.previousSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
- }
- }
-
- if ( type === "first" ) {
- return true;
- }
-
- node = elem;
-
- case "last":
- while ( (node = node.nextSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
- }
- }
-
- return true;
-
- case "nth":
- var first = match[2],
- last = match[3];
-
- if ( first === 1 && last === 0 ) {
- return true;
- }
-
- var doneName = match[0],
- parent = elem.parentNode;
-
- if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
- var count = 0;
-
- for ( node = parent.firstChild; node; node = node.nextSibling ) {
- if ( node.nodeType === 1 ) {
- node.nodeIndex = ++count;
- }
- }
-
- parent.sizcache = doneName;
- }
-
- var diff = elem.nodeIndex - last;
-
- if ( first === 0 ) {
- return diff === 0;
-
- } else {
- return ( diff % first === 0 && diff / first >= 0 );
- }
- }
- },
-
- ID: function( elem, match ) {
- return elem.nodeType === 1 && elem.getAttribute("id") === match;
- },
-
- TAG: function( elem, match ) {
- return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
- },
-
- CLASS: function( elem, match ) {
- return (" " + (elem.className || elem.getAttribute("class")) + " ")
- .indexOf( match ) > -1;
- },
-
- ATTR: function( elem, match ) {
- var name = match[1],
- result = Expr.attrHandle[ name ] ?
- Expr.attrHandle[ name ]( elem ) :
- elem[ name ] != null ?
- elem[ name ] :
- elem.getAttribute( name ),
- value = result + "",
- type = match[2],
- check = match[4];
-
- return result == null ?
- type === "!=" :
- type === "=" ?
- value === check :
- type === "*=" ?
- value.indexOf(check) >= 0 :
- type === "~=" ?
- (" " + value + " ").indexOf(check) >= 0 :
- !check ?
- value && result !== false :
- type === "!=" ?
- value !== check :
- type === "^=" ?
- value.indexOf(check) === 0 :
- type === "$=" ?
- value.substr(value.length - check.length) === check :
- type === "|=" ?
- value === check || value.substr(0, check.length + 1) === check + "-" :
- false;
- },
-
- POS: function( elem, match, i, array ) {
- var name = match[2],
- filter = Expr.setFilters[ name ];
-
- if ( filter ) {
- return filter( elem, i, match, array );
- }
- }
- }
-};
-
-var origPOS = Expr.match.POS,
- fescape = function(all, num){
- return "\\" + (num - 0 + 1);
- };
-
-for ( var type in Expr.match ) {
- Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
- Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
-}
-
-var makeArray = function( array, results ) {
- array = Array.prototype.slice.call( array, 0 );
-
- if ( results ) {
- results.push.apply( results, array );
- return results;
- }
-
- return array;
-};
-
-// Perform a simple check to determine if the browser is capable of
-// converting a NodeList to an array using builtin methods.
-// Also verifies that the returned array holds DOM nodes
-// (which is not the case in the Blackberry browser)
-try {
- Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
-
-// Provide a fallback method if it does not work
-} catch( e ) {
- makeArray = function( array, results ) {
- var i = 0,
- ret = results || [];
-
- if ( toString.call(array) === "[object Array]" ) {
- Array.prototype.push.apply( ret, array );
-
- } else {
- if ( typeof array.length === "number" ) {
- for ( var l = array.length; i < l; i++ ) {
- ret.push( array[i] );
- }
-
- } else {
- for ( ; array[i]; i++ ) {
- ret.push( array[i] );
- }
- }
- }
-
- return ret;
- };
-}
-
-var sortOrder, siblingCheck;
-
-if ( document.documentElement.compareDocumentPosition ) {
- sortOrder = function( a, b ) {
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
- return a.compareDocumentPosition ? -1 : 1;
- }
-
- return a.compareDocumentPosition(b) & 4 ? -1 : 1;
- };
-
-} else {
- sortOrder = function( a, b ) {
- var al, bl,
- ap = [],
- bp = [],
- aup = a.parentNode,
- bup = b.parentNode,
- cur = aup;
-
- // The nodes are identical, we can exit early
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
-
- // If the nodes are siblings (or identical) we can do a quick check
- } else if ( aup === bup ) {
- return siblingCheck( a, b );
-
- // If no parents were found then the nodes are disconnected
- } else if ( !aup ) {
- return -1;
-
- } else if ( !bup ) {
- return 1;
- }
-
- // Otherwise they're somewhere else in the tree so we need
- // to build up a full list of the parentNodes for comparison
- while ( cur ) {
- ap.unshift( cur );
- cur = cur.parentNode;
- }
-
- cur = bup;
-
- while ( cur ) {
- bp.unshift( cur );
- cur = cur.parentNode;
- }
-
- al = ap.length;
- bl = bp.length;
-
- // Start walking down the tree looking for a discrepancy
- for ( var i = 0; i < al && i < bl; i++ ) {
- if ( ap[i] !== bp[i] ) {
- return siblingCheck( ap[i], bp[i] );
- }
- }
-
- // We ended someplace up the tree so do a sibling check
- return i === al ?
- siblingCheck( a, bp[i], -1 ) :
- siblingCheck( ap[i], b, 1 );
- };
-
- siblingCheck = function( a, b, ret ) {
- if ( a === b ) {
- return ret;
- }
-
- var cur = a.nextSibling;
-
- while ( cur ) {
- if ( cur === b ) {
- return -1;
- }
-
- cur = cur.nextSibling;
- }
-
- return 1;
- };
-}
-
-// Utility function for retreiving the text value of an array of DOM nodes
-Sizzle.getText = function( elems ) {
- var ret = "", elem;
-
- for ( var i = 0; elems[i]; i++ ) {
- elem = elems[i];
-
- // Get the text from text nodes and CDATA nodes
- if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
- ret += elem.nodeValue;
-
- // Traverse everything else, except comment nodes
- } else if ( elem.nodeType !== 8 ) {
- ret += Sizzle.getText( elem.childNodes );
- }
- }
-
- return ret;
-};
-
-// Check to see if the browser returns elements by name when
-// querying by getElementById (and provide a workaround)
-(function(){
- // We're going to inject a fake input element with a specified name
- var form = document.createElement("div"),
- id = "script" + (new Date()).getTime(),
- root = document.documentElement;
-
- form.innerHTML = "<a name='" + id + "'/>";
-
- // Inject it into the root element, check its status, and remove it quickly
- root.insertBefore( form, root.firstChild );
-
- // The workaround has to do additional checks after a getElementById
- // Which slows things down for other browsers (hence the branching)
- if ( document.getElementById( id ) ) {
- Expr.find.ID = function( match, context, isXML ) {
- if ( typeof context.getElementById !== "undefined" && !isXML ) {
- var m = context.getElementById(match[1]);
-
- return m ?
- m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
- [m] :
- undefined :
- [];
- }
- };
-
- Expr.filter.ID = function( elem, match ) {
- var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
-
- return elem.nodeType === 1 && node && node.nodeValue === match;
- };
- }
-
- root.removeChild( form );
-
- // release memory in IE
- root = form = null;
-})();
-
-(function(){
- // Check to see if the browser returns only elements
- // when doing getElementsByTagName("*")
-
- // Create a fake element
- var div = document.createElement("div");
- div.appendChild( document.createComment("") );
-
- // Make sure no comments are found
- if ( div.getElementsByTagName("*").length > 0 ) {
- Expr.find.TAG = function( match, context ) {
- var results = context.getElementsByTagName( match[1] );
-
- // Filter out possible comments
- if ( match[1] === "*" ) {
- var tmp = [];
-
- for ( var i = 0; results[i]; i++ ) {
- if ( results[i].nodeType === 1 ) {
- tmp.push( results[i] );
- }
- }
-
- results = tmp;
- }
-
- return results;
- };
- }
-
- // Check to see if an attribute returns normalized href attributes
- div.innerHTML = "<a href='#'></a>";
-
- if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
- div.firstChild.getAttribute("href") !== "#" ) {
-
- Expr.attrHandle.href = function( elem ) {
- return elem.getAttribute( "href", 2 );
- };
- }
-
- // release memory in IE
- div = null;
-})();
-
-if ( document.querySelectorAll ) {
- (function(){
- var oldSizzle = Sizzle,
- div = document.createElement("div"),
- id = "__sizzle__";
-
- div.innerHTML = "<p class='TEST'></p>";
-
- // Safari can't handle uppercase or unicode characters when
- // in quirks mode.
- if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
- return;
- }
-
- Sizzle = function( query, context, extra, seed ) {
- context = context || document;
-
- // Make sure that attribute selectors are quoted
- query = query.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
-
- // Only use querySelectorAll on non-XML documents
- // (ID selectors don't work in non-HTML documents)
- if ( !seed && !Sizzle.isXML(context) ) {
- if ( context.nodeType === 9 ) {
- try {
- return makeArray( context.querySelectorAll(query), extra );
- } catch(qsaError) {}
-
- // qSA works strangely on Element-rooted queries
- // We can work around this by specifying an extra ID on the root
- // and working up from there (Thanks to Andrew Dupont for the technique)
- // IE 8 doesn't work on object elements
- } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- var old = context.getAttribute( "id" ),
- nid = old || id;
-
- if ( !old ) {
- context.setAttribute( "id", nid );
- }
-
- try {
- return makeArray( context.querySelectorAll( "#" + nid + " " + query ), extra );
-
- } catch(pseudoError) {
- } finally {
- if ( !old ) {
- context.removeAttribute( "id" );
- }
- }
- }
- }
-
- return oldSizzle(query, context, extra, seed);
- };
-
- for ( var prop in oldSizzle ) {
- Sizzle[ prop ] = oldSizzle[ prop ];
- }
-
- // release memory in IE
- div = null;
- })();
-}
-
-(function(){
- var html = document.documentElement,
- matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
- pseudoWorks = false;
-
- try {
- // This should fail with an exception
- // Gecko does not error, returns false instead
- matches.call( document.documentElement, "[test!='']:sizzle" );
-
- } catch( pseudoError ) {
- pseudoWorks = true;
- }
-
- if ( matches ) {
- Sizzle.matchesSelector = function( node, expr ) {
- // Make sure that attribute selectors are quoted
- expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
-
- if ( !Sizzle.isXML( node ) ) {
- try {
- if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
- return matches.call( node, expr );
- }
- } catch(e) {}
- }
-
- return Sizzle(expr, null, null, [node]).length > 0;
- };
- }
-})();
-
-(function(){
- var div = document.createElement("div");
-
- div.innerHTML = "<div class='test e'></div><div class='test'></div>";
-
- // Opera can't find a second classname (in 9.6)
- // Also, make sure that getElementsByClassName actually exists
- if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
- return;
- }
-
- // Safari caches class attributes, doesn't catch changes (in 3.2)
- div.lastChild.className = "e";
-
- if ( div.getElementsByClassName("e").length === 1 ) {
- return;
- }
-
- Expr.order.splice(1, 0, "CLASS");
- Expr.find.CLASS = function( match, context, isXML ) {
- if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
- return context.getElementsByClassName(match[1]);
- }
- };
-
- // release memory in IE
- div = null;
-})();
-
-function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
- for ( var i = 0, l = checkSet.length; i < l; i++ ) {
- var elem = checkSet[i];
-
- if ( elem ) {
- var match = false;
-
- elem = elem[dir];
-
- while ( elem ) {
- if ( elem.sizcache === doneName ) {
- match = checkSet[elem.sizset];
- break;
- }
-
- if ( elem.nodeType === 1 && !isXML ){
- elem.sizcache = doneName;
- elem.sizset = i;
- }
-
- if ( elem.nodeName.toLowerCase() === cur ) {
- match = elem;
- break;
- }
-
- elem = elem[dir];
- }
-
- checkSet[i] = match;
- }
- }
-}
-
-function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
- for ( var i = 0, l = checkSet.length; i < l; i++ ) {
- var elem = checkSet[i];
-
- if ( elem ) {
- var match = false;
-
- elem = elem[dir];
-
- while ( elem ) {
- if ( elem.sizcache === doneName ) {
- match = checkSet[elem.sizset];
- break;
- }
-
- if ( elem.nodeType === 1 ) {
- if ( !isXML ) {
- elem.sizcache = doneName;
- elem.sizset = i;
- }
-
- if ( typeof cur !== "string" ) {
- if ( elem === cur ) {
- match = true;
- break;
- }
-
- } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
- match = elem;
- break;
- }
- }
-
- elem = elem[dir];
- }
-
- checkSet[i] = match;
- }
- }
-}
-
-if ( document.documentElement.contains ) {
- Sizzle.contains = function( a, b ) {
- return a !== b && (a.contains ? a.contains(b) : true);
- };
-
-} else if ( document.documentElement.compareDocumentPosition ) {
- Sizzle.contains = function( a, b ) {
- return !!(a.compareDocumentPosition(b) & 16);
- };
-
-} else {
- Sizzle.contains = function() {
- return false;
- };
-}
-
-Sizzle.isXML = function( elem ) {
- // documentElement is verified for cases where it doesn't yet exist
- // (such as loading iframes in IE - #4833)
- var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
-
- return documentElement ? documentElement.nodeName !== "HTML" : false;
-};
-
-var posProcess = function( selector, context ) {
- var match,
- tmpSet = [],
- later = "",
- root = context.nodeType ? [context] : context;
-
- // Position selectors must be done after the filter
- // And so must :not(positional) so we move all PSEUDOs to the end
- while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
- later += match[0];
- selector = selector.replace( Expr.match.PSEUDO, "" );
- }
-
- selector = Expr.relative[selector] ? selector + "*" : selector;
-
- for ( var i = 0, l = root.length; i < l; i++ ) {
- Sizzle( selector, root[i], tmpSet );
- }
-
- return Sizzle.filter( later, tmpSet );
-};
-
-// EXPOSE
-jQuery.find = Sizzle;
-jQuery.expr = Sizzle.selectors;
-jQuery.expr[":"] = jQuery.expr.filters;
-jQuery.unique = Sizzle.uniqueSort;
-jQuery.text = Sizzle.getText;
-jQuery.isXMLDoc = Sizzle.isXML;
-jQuery.contains = Sizzle.contains;
-
-
-})();
-
-
-var runtil = /Until$/,
- rparentsprev = /^(?:parents|prevUntil|prevAll)/,
- // Note: This RegExp should be improved, or likely pulled from Sizzle
- rmultiselector = /,/,
- isSimple = /^.[^:#\[\.,]*$/,
- slice = Array.prototype.slice,
- POS = jQuery.expr.match.POS;
-
-jQuery.fn.extend({
- find: function( selector ) {
- var ret = this.pushStack( "", "find", selector ),
- length = 0;
-
- for ( var i = 0, l = this.length; i < l; i++ ) {
- length = ret.length;
- jQuery.find( selector, this[i], ret );
-
- if ( i > 0 ) {
- // Make sure that the results are unique
- for ( var n = length; n < ret.length; n++ ) {
- for ( var r = 0; r < length; r++ ) {
- if ( ret[r] === ret[n] ) {
- ret.splice(n--, 1);
- break;
- }
- }
- }
- }
- }
-
- return ret;
- },
-
- has: function( target ) {
- var targets = jQuery( target );
- return this.filter(function() {
- for ( var i = 0, l = targets.length; i < l; i++ ) {
- if ( jQuery.contains( this, targets[i] ) ) {
- return true;
- }
- }
- });
- },
-
- not: function( selector ) {
- return this.pushStack( winnow(this, selector, false), "not", selector);
- },
-
- filter: function( selector ) {
- return this.pushStack( winnow(this, selector, true), "filter", selector );
- },
-
- is: function( selector ) {
- return !!selector && jQuery.filter( selector, this ).length > 0;
- },
-
- closest: function( selectors, context ) {
- var ret = [], i, l, cur = this[0];
-
- if ( jQuery.isArray( selectors ) ) {
- var match, selector,
- matches = {},
- level = 1;
-
- if ( cur && selectors.length ) {
- for ( i = 0, l = selectors.length; i < l; i++ ) {
- selector = selectors[i];
-
- if ( !matches[selector] ) {
- matches[selector] = jQuery.expr.match.POS.test( selector ) ?
- jQuery( selector, context || this.context ) :
- selector;
- }
- }
-
- while ( cur && cur.ownerDocument && cur !== context ) {
- for ( selector in matches ) {
- match = matches[selector];
-
- if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
- ret.push({ selector: selector, elem: cur, level: level });
- }
- }
-
- cur = cur.parentNode;
- level++;
- }
- }
-
- return ret;
- }
-
- var pos = POS.test( selectors ) ?
- jQuery( selectors, context || this.context ) : null;
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- cur = this[i];
-
- while ( cur ) {
- if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
- ret.push( cur );
- break;
-
- } else {
- cur = cur.parentNode;
- if ( !cur || !cur.ownerDocument || cur === context ) {
- break;
- }
- }
- }
- }
-
- ret = ret.length > 1 ? jQuery.unique(ret) : ret;
-
- return this.pushStack( ret, "closest", selectors );
- },
-
- // Determine the position of an element within
- // the matched set of elements
- index: function( elem ) {
- if ( !elem || typeof elem === "string" ) {
- return jQuery.inArray( this[0],
- // If it receives a string, the selector is used
- // If it receives nothing, the siblings are used
- elem ? jQuery( elem ) : this.parent().children() );
- }
- // Locate the position of the desired element
- return jQuery.inArray(
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[0] : elem, this );
- },
-
- add: function( selector, context ) {
- var set = typeof selector === "string" ?
- jQuery( selector, context || this.context ) :
- jQuery.makeArray( selector ),
- all = jQuery.merge( this.get(), set );
-
- return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
- all :
- jQuery.unique( all ) );
- },
-
- andSelf: function() {
- return this.add( this.prevObject );
- }
-});
-
-// A painfully simple check to see if an element is disconnected
-// from a document (should be improved, where feasible).
-function isDisconnected( node ) {
- return !node || !node.parentNode || node.parentNode.nodeType === 11;
-}
-
-jQuery.each({
- parent: function( elem ) {
- var parent = elem.parentNode;
- return parent && parent.nodeType !== 11 ? parent : null;
- },
- parents: function( elem ) {
- return jQuery.dir( elem, "parentNode" );
- },
- parentsUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "parentNode", until );
- },
- next: function( elem ) {
- return jQuery.nth( elem, 2, "nextSibling" );
- },
- prev: function( elem ) {
- return jQuery.nth( elem, 2, "previousSibling" );
- },
- nextAll: function( elem ) {
- return jQuery.dir( elem, "nextSibling" );
- },
- prevAll: function( elem ) {
- return jQuery.dir( elem, "previousSibling" );
- },
- nextUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "nextSibling", until );
- },
- prevUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "previousSibling", until );
- },
- siblings: function( elem ) {
- return jQuery.sibling( elem.parentNode.firstChild, elem );
- },
- children: function( elem ) {
- return jQuery.sibling( elem.firstChild );
- },
- contents: function( elem ) {
- return jQuery.nodeName( elem, "iframe" ) ?
- elem.contentDocument || elem.contentWindow.document :
- jQuery.makeArray( elem.childNodes );
- }
-}, function( name, fn ) {
- jQuery.fn[ name ] = function( until, selector ) {
- var ret = jQuery.map( this, fn, until );
-
- if ( !runtil.test( name ) ) {
- selector = until;
- }
-
- if ( selector && typeof selector === "string" ) {
- ret = jQuery.filter( selector, ret );
- }
-
- ret = this.length > 1 ? jQuery.unique( ret ) : ret;
-
- if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
- ret = ret.reverse();
- }
-
- return this.pushStack( ret, name, slice.call(arguments).join(",") );
- };
-});
-
-jQuery.extend({
- filter: function( expr, elems, not ) {
- if ( not ) {
- expr = ":not(" + expr + ")";
- }
-
- return elems.length === 1 ?
- jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
- jQuery.find.matches(expr, elems);
- },
-
- dir: function( elem, dir, until ) {
- var matched = [],
- cur = elem[ dir ];
-
- while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
- if ( cur.nodeType === 1 ) {
- matched.push( cur );
- }
- cur = cur[dir];
- }
- return matched;
- },
-
- nth: function( cur, result, dir, elem ) {
- result = result || 1;
- var num = 0;
-
- for ( ; cur; cur = cur[dir] ) {
- if ( cur.nodeType === 1 && ++num === result ) {
- break;
- }
- }
-
- return cur;
- },
-
- sibling: function( n, elem ) {
- var r = [];
-
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- r.push( n );
- }
- }
-
- return r;
- }
-});
-
-// Implement the identical functionality for filter and not
-function winnow( elements, qualifier, keep ) {
- if ( jQuery.isFunction( qualifier ) ) {
- return jQuery.grep(elements, function( elem, i ) {
- var retVal = !!qualifier.call( elem, i, elem );
- return retVal === keep;
- });
-
- } else if ( qualifier.nodeType ) {
- return jQuery.grep(elements, function( elem, i ) {
- return (elem === qualifier) === keep;
- });
-
- } else if ( typeof qualifier === "string" ) {
- var filtered = jQuery.grep(elements, function( elem ) {
- return elem.nodeType === 1;
- });
-
- if ( isSimple.test( qualifier ) ) {
- return jQuery.filter(qualifier, filtered, !keep);
- } else {
- qualifier = jQuery.filter( qualifier, filtered );
- }
- }
-
- return jQuery.grep(elements, function( elem, i ) {
- return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
- });
-}
-
-
-
-
-var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
- rleadingWhitespace = /^\s+/,
- rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
- rtagName = /<([\w:]+)/,
- rtbody = /<tbody/i,
- rhtml = /<|&#?\w+;/,
- rnocache = /<(?:script|object|embed|option|style)/i,
- // checked="checked" or checked (html5)
- rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
- raction = /\=([^="'>\s]+\/)>/g,
- wrapMap = {
- option: [ 1, "<select multiple='multiple'>", "</select>" ],
- legend: [ 1, "<fieldset>", "</fieldset>" ],
- thead: [ 1, "<table>", "</table>" ],
- tr: [ 2, "<table><tbody>", "</tbody></table>" ],
- td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
- col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
- area: [ 1, "<map>", "</map>" ],
- _default: [ 0, "", "" ]
- };
-
-wrapMap.optgroup = wrapMap.option;
-wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
-wrapMap.th = wrapMap.td;
-
-// IE can't serialize <link> and <script> tags normally
-if ( !jQuery.support.htmlSerialize ) {
- wrapMap._default = [ 1, "div<div>", "</div>" ];
-}
-
-jQuery.fn.extend({
- text: function( text ) {
- if ( jQuery.isFunction(text) ) {
- return this.each(function(i) {
- var self = jQuery( this );
-
- self.text( text.call(this, i, self.text()) );
- });
- }
-
- if ( typeof text !== "object" && text !== undefined ) {
- return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
- }
-
- return jQuery.text( this );
- },
-
- wrapAll: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapAll( html.call(this, i) );
- });
- }
-
- if ( this[0] ) {
- // The elements to wrap the target around
- var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
-
- if ( this[0].parentNode ) {
- wrap.insertBefore( this[0] );
- }
-
- wrap.map(function() {
- var elem = this;
-
- while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
- elem = elem.firstChild;
- }
-
- return elem;
- }).append(this);
- }
-
- return this;
- },
-
- wrapInner: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapInner( html.call(this, i) );
- });
- }
-
- return this.each(function() {
- var self = jQuery( this ),
- contents = self.contents();
-
- if ( contents.length ) {
- contents.wrapAll( html );
-
- } else {
- self.append( html );
- }
- });
- },
-
- wrap: function( html ) {
- return this.each(function() {
- jQuery( this ).wrapAll( html );
- });
- },
-
- unwrap: function() {
- return this.parent().each(function() {
- if ( !jQuery.nodeName( this, "body" ) ) {
- jQuery( this ).replaceWith( this.childNodes );
- }
- }).end();
- },
-
- append: function() {
- return this.domManip(arguments, true, function( elem ) {
- if ( this.nodeType === 1 ) {
- this.appendChild( elem );
- }
- });
- },
-
- prepend: function() {
- return this.domManip(arguments, true, function( elem ) {
- if ( this.nodeType === 1 ) {
- this.insertBefore( elem, this.firstChild );
- }
- });
- },
-
- before: function() {
- if ( this[0] && this[0].parentNode ) {
- return this.domManip(arguments, false, function( elem ) {
- this.parentNode.insertBefore( elem, this );
- });
- } else if ( arguments.length ) {
- var set = jQuery(arguments[0]);
- set.push.apply( set, this.toArray() );
- return this.pushStack( set, "before", arguments );
- }
- },
-
- after: function() {
- if ( this[0] && this[0].parentNode ) {
- return this.domManip(arguments, false, function( elem ) {
- this.parentNode.insertBefore( elem, this.nextSibling );
- });
- } else if ( arguments.length ) {
- var set = this.pushStack( this, "after", arguments );
- set.push.apply( set, jQuery(arguments[0]).toArray() );
- return set;
- }
- },
-
- // keepData is for internal use only--do not document
- remove: function( selector, keepData ) {
- for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
- if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
- if ( !keepData && elem.nodeType === 1 ) {
- jQuery.cleanData( elem.getElementsByTagName("*") );
- jQuery.cleanData( [ elem ] );
- }
-
- if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
- }
- }
- }
-
- return this;
- },
-
- empty: function() {
- for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
- // Remove element nodes and prevent memory leaks
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( elem.getElementsByTagName("*") );
- }
-
- // Remove any remaining nodes
- while ( elem.firstChild ) {
- elem.removeChild( elem.firstChild );
- }
- }
-
- return this;
- },
-
- clone: function( events ) {
- // Do the clone
- var ret = this.map(function() {
- if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
- // IE copies events bound via attachEvent when
- // using cloneNode. Calling detachEvent on the
- // clone will also remove the events from the orignal
- // In order to get around this, we use innerHTML.
- // Unfortunately, this means some modifications to
- // attributes in IE that are actually only stored
- // as properties will not be copied (such as the
- // the name attribute on an input).
- var html = this.outerHTML,
- ownerDocument = this.ownerDocument;
-
- if ( !html ) {
- var div = ownerDocument.createElement("div");
- div.appendChild( this.cloneNode(true) );
- html = div.innerHTML;
- }
-
- return jQuery.clean([html.replace(rinlinejQuery, "")
- // Handle the case in IE 8 where action=/test/> self-closes a tag
- .replace(raction, '="$1">')
- .replace(rleadingWhitespace, "")], ownerDocument)[0];
- } else {
- return this.cloneNode(true);
- }
- });
-
- // Copy the events from the original to the clone
- if ( events === true ) {
- cloneCopyEvent( this, ret );
- cloneCopyEvent( this.find("*"), ret.find("*") );
- }
-
- // Return the cloned set
- return ret;
- },
-
- html: function( value ) {
- if ( value === undefined ) {
- return this[0] && this[0].nodeType === 1 ?
- this[0].innerHTML.replace(rinlinejQuery, "") :
- null;
-
- // See if we can take a shortcut and just use innerHTML
- } else if ( typeof value === "string" && !rnocache.test( value ) &&
- (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
- !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
-
- value = value.replace(rxhtmlTag, "<$1></$2>");
-
- try {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- // Remove element nodes and prevent memory leaks
- if ( this[i].nodeType === 1 ) {
- jQuery.cleanData( this[i].getElementsByTagName("*") );
- this[i].innerHTML = value;
- }
- }
-
- // If using innerHTML throws an exception, use the fallback method
- } catch(e) {
- this.empty().append( value );
- }
-
- } else if ( jQuery.isFunction( value ) ) {
- this.each(function(i){
- var self = jQuery( this );
-
- self.html( value.call(this, i, self.html()) );
- });
-
- } else {
- this.empty().append( value );
- }
-
- return this;
- },
-
- replaceWith: function( value ) {
- if ( this[0] && this[0].parentNode ) {
- // Make sure that the elements are removed from the DOM before they are inserted
- // this can help fix replacing a parent with child elements
- if ( jQuery.isFunction( value ) ) {
- return this.each(function(i) {
- var self = jQuery(this), old = self.html();
- self.replaceWith( value.call( this, i, old ) );
- });
- }
-
- if ( typeof value !== "string" ) {
- value = jQuery( value ).detach();
- }
-
- return this.each(function() {
- var next = this.nextSibling,
- parent = this.parentNode;
-
- jQuery( this ).remove();
-
- if ( next ) {
- jQuery(next).before( value );
- } else {
- jQuery(parent).append( value );
- }
- });
- } else {
- return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
- }
- },
-
- detach: function( selector ) {
- return this.remove( selector, true );
- },
-
- domManip: function( args, table, callback ) {
- var results, first, fragment, parent,
- value = args[0],
- scripts = [];
-
- // We can't cloneNode fragments that contain checked, in WebKit
- if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
- return this.each(function() {
- jQuery(this).domManip( args, table, callback, true );
- });
- }
-
- if ( jQuery.isFunction(value) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- args[0] = value.call(this, i, table ? self.html() : undefined);
- self.domManip( args, table, callback );
- });
- }
-
- if ( this[0] ) {
- parent = value && value.parentNode;
-
- // If we're in a fragment, just use that instead of building a new one
- if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
- results = { fragment: parent };
-
- } else {
- results = jQuery.buildFragment( args, this, scripts );
- }
-
- fragment = results.fragment;
-
- if ( fragment.childNodes.length === 1 ) {
- first = fragment = fragment.firstChild;
- } else {
- first = fragment.firstChild;
- }
-
- if ( first ) {
- table = table && jQuery.nodeName( first, "tr" );
-
- for ( var i = 0, l = this.length; i < l; i++ ) {
- callback.call(
- table ?
- root(this[i], first) :
- this[i],
- i > 0 || results.cacheable || this.length > 1 ?
- fragment.cloneNode(true) :
- fragment
- );
- }
- }
-
- if ( scripts.length ) {
- jQuery.each( scripts, evalScript );
- }
- }
-
- return this;
- }
-});
-
-function root( elem, cur ) {
- return jQuery.nodeName(elem, "table") ?
- (elem.getElementsByTagName("tbody")[0] ||
- elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
- elem;
-}
-
-function cloneCopyEvent(orig, ret) {
- var i = 0;
-
- ret.each(function() {
- if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
- return;
- }
-
- var oldData = jQuery.data( orig[i++] ),
- curData = jQuery.data( this, oldData ),
- events = oldData && oldData.events;
-
- if ( events ) {
- delete curData.handle;
- curData.events = {};
-
- for ( var type in events ) {
- for ( var handler in events[ type ] ) {
- jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
- }
- }
- }
- });
-}
-
-jQuery.buildFragment = function( args, nodes, scripts ) {
- var fragment, cacheable, cacheresults,
- doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
-
- // Only cache "small" (1/2 KB) strings that are associated with the main document
- // Cloning options loses the selected state, so don't cache them
- // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
- // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
- if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
- !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
-
- cacheable = true;
- cacheresults = jQuery.fragments[ args[0] ];
- if ( cacheresults ) {
- if ( cacheresults !== 1 ) {
- fragment = cacheresults;
- }
- }
- }
-
- if ( !fragment ) {
- fragment = doc.createDocumentFragment();
- jQuery.clean( args, doc, fragment, scripts );
- }
-
- if ( cacheable ) {
- jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
- }
-
- return { fragment: fragment, cacheable: cacheable };
-};
-
-jQuery.fragments = {};
-
-jQuery.each({
- appendTo: "append",
- prependTo: "prepend",
- insertBefore: "before",
- insertAfter: "after",
- replaceAll: "replaceWith"
-}, function( name, original ) {
- jQuery.fn[ name ] = function( selector ) {
- var ret = [],
- insert = jQuery( selector ),
- parent = this.length === 1 && this[0].parentNode;
-
- if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
- insert[ original ]( this[0] );
- return this;
-
- } else {
- for ( var i = 0, l = insert.length; i < l; i++ ) {
- var elems = (i > 0 ? this.clone(true) : this).get();
- jQuery( insert[i] )[ original ]( elems );
- ret = ret.concat( elems );
- }
-
- return this.pushStack( ret, name, insert.selector );
- }
- };
-});
-
-jQuery.extend({
- clean: function( elems, context, fragment, scripts ) {
- context = context || document;
-
- // !context.createElement fails in IE with an error but returns typeof 'object'
- if ( typeof context.createElement === "undefined" ) {
- context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
- }
-
- var ret = [];
-
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
- if ( typeof elem === "number" ) {
- elem += "";
- }
-
- if ( !elem ) {
- continue;
- }
-
- // Convert html string into DOM nodes
- if ( typeof elem === "string" && !rhtml.test( elem ) ) {
- elem = context.createTextNode( elem );
-
- } else if ( typeof elem === "string" ) {
- // Fix "XHTML"-style tags in all browsers
- elem = elem.replace(rxhtmlTag, "<$1></$2>");
-
- // Trim whitespace, otherwise indexOf won't work as expected
- var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
- wrap = wrapMap[ tag ] || wrapMap._default,
- depth = wrap[0],
- div = context.createElement("div");
-
- // Go to html and back, then peel off extra wrappers
- div.innerHTML = wrap[1] + elem + wrap[2];
-
- // Move to the right depth
- while ( depth-- ) {
- div = div.lastChild;
- }
-
- // Remove IE's autoinserted <tbody> from table fragments
- if ( !jQuery.support.tbody ) {
-
- // String was a <table>, *may* have spurious <tbody>
- var hasBody = rtbody.test(elem),
- tbody = tag === "table" && !hasBody ?
- div.firstChild && div.firstChild.childNodes :
-
- // String was a bare <thead> or <tfoot>
- wrap[1] === "<table>" && !hasBody ?
- div.childNodes :
- [];
-
- for ( var j = tbody.length - 1; j >= 0 ; --j ) {
- if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
- tbody[ j ].parentNode.removeChild( tbody[ j ] );
- }
- }
-
- }
-
- // IE completely kills leading whitespace when innerHTML is used
- if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
- div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
- }
-
- elem = div.childNodes;
- }
-
- if ( elem.nodeType ) {
- ret.push( elem );
- } else {
- ret = jQuery.merge( ret, elem );
- }
- }
-
- if ( fragment ) {
- for ( i = 0; ret[i]; i++ ) {
- if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
- scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
-
- } else {
- if ( ret[i].nodeType === 1 ) {
- ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
- }
- fragment.appendChild( ret[i] );
- }
- }
- }
-
- return ret;
- },
-
- cleanData: function( elems ) {
- var data, id, cache = jQuery.cache,
- special = jQuery.event.special,
- deleteExpando = jQuery.support.deleteExpando;
-
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
- if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
- continue;
- }
-
- id = elem[ jQuery.expando ];
-
- if ( id ) {
- data = cache[ id ];
-
- if ( data && data.events ) {
- for ( var type in data.events ) {
- if ( special[ type ] ) {
- jQuery.event.remove( elem, type );
-
- } else {
- jQuery.removeEvent( elem, type, data.handle );
- }
- }
- }
-
- if ( deleteExpando ) {
- delete elem[ jQuery.expando ];
-
- } else if ( elem.removeAttribute ) {
- elem.removeAttribute( jQuery.expando );
- }
-
- delete cache[ id ];
- }
- }
- }
-});
-
-function evalScript( i, elem ) {
- if ( elem.src ) {
- jQuery.ajax({
- url: elem.src,
- async: false,
- dataType: "script"
- });
- } else {
- jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
- }
-
- if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
- }
-}
-
-
-
-
-var ralpha = /alpha\([^)]*\)/i,
- ropacity = /opacity=([^)]*)/,
- rdashAlpha = /-([a-z])/ig,
- rupper = /([A-Z])/g,
- rnumpx = /^-?\d+(?:px)?$/i,
- rnum = /^-?\d/,
-
- cssShow = { position: "absolute", visibility: "hidden", display: "block" },
- cssWidth = [ "Left", "Right" ],
- cssHeight = [ "Top", "Bottom" ],
- curCSS,
-
- getComputedStyle,
- currentStyle,
-
- fcamelCase = function( all, letter ) {
- return letter.toUpperCase();
- };
-
-jQuery.fn.css = function( name, value ) {
- // Setting 'undefined' is a no-op
- if ( arguments.length === 2 && value === undefined ) {
- return this;
- }
-
- return jQuery.access( this, name, value, true, function( elem, name, value ) {
- return value !== undefined ?
- jQuery.style( elem, name, value ) :
- jQuery.css( elem, name );
- });
-};
-
-jQuery.extend({
- // Add in style property hooks for overriding the default
- // behavior of getting and setting a style property
- cssHooks: {
- opacity: {
- get: function( elem, computed ) {
- if ( computed ) {
- // We should always get a number back from opacity
- var ret = curCSS( elem, "opacity", "opacity" );
- return ret === "" ? "1" : ret;
-
- } else {
- return elem.style.opacity;
- }
- }
- }
- },
-
- // Exclude the following css properties to add px
- cssNumber: {
- "zIndex": true,
- "fontWeight": true,
- "opacity": true,
- "zoom": true,
- "lineHeight": true
- },
-
- // Add in properties whose names you wish to fix before
- // setting or getting the value
- cssProps: {
- // normalize float css property
- "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
- },
-
- // Get and set the style property on a DOM Node
- style: function( elem, name, value, extra ) {
- // Don't set styles on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
- return;
- }
-
- // Make sure that we're working with the right name
- var ret, origName = jQuery.camelCase( name ),
- style = elem.style, hooks = jQuery.cssHooks[ origName ];
-
- name = jQuery.cssProps[ origName ] || origName;
-
- // Check if we're setting a value
- if ( value !== undefined ) {
- // Make sure that NaN and null values aren't set. See: #7116
- if ( typeof value === "number" && isNaN( value ) || value == null ) {
- return;
- }
-
- // If a number was passed in, add 'px' to the (except for certain CSS properties)
- if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) {
- value += "px";
- }
-
- // If a hook was provided, use that value, otherwise just set the specified value
- if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
- // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
- // Fixes bug #5509
- try {
- style[ name ] = value;
- } catch(e) {}
- }
-
- } else {
- // If a hook was provided get the non-computed value from there
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
- return ret;
- }
-
- // Otherwise just get the value from the style object
- return style[ name ];
- }
- },
-
- css: function( elem, name, extra ) {
- // Make sure that we're working with the right name
- var ret, origName = jQuery.camelCase( name ),
- hooks = jQuery.cssHooks[ origName ];
-
- name = jQuery.cssProps[ origName ] || origName;
-
- // If a hook was provided get the computed value from there
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
- return ret;
-
- // Otherwise, if a way to get the computed value exists, use that
- } else if ( curCSS ) {
- return curCSS( elem, name, origName );
- }
- },
-
- // A method for quickly swapping in/out CSS properties to get correct calculations
- swap: function( elem, options, callback ) {
- var old = {};
-
- // Remember the old values, and insert the new ones
- for ( var name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
-
- callback.call( elem );
-
- // Revert the old values
- for ( name in options ) {
- elem.style[ name ] = old[ name ];
- }
- },
-
- camelCase: function( string ) {
- return string.replace( rdashAlpha, fcamelCase );
- }
-});
-
-// DEPRECATED, Use jQuery.css() instead
-jQuery.curCSS = jQuery.css;
-
-jQuery.each(["height", "width"], function( i, name ) {
- jQuery.cssHooks[ name ] = {
- get: function( elem, computed, extra ) {
- var val;
-
- if ( computed ) {
- if ( elem.offsetWidth !== 0 ) {
- val = getWH( elem, name, extra );
-
- } else {
- jQuery.swap( elem, cssShow, function() {
- val = getWH( elem, name, extra );
- });
- }
-
- if ( val <= 0 ) {
- val = curCSS( elem, name, name );
-
- if ( val === "0px" && currentStyle ) {
- val = currentStyle( elem, name, name );
- }
-
- if ( val != null ) {
- // Should return "auto" instead of 0, use 0 for
- // temporary backwards-compat
- return val === "" || val === "auto" ? "0px" : val;
- }
- }
-
- if ( val < 0 || val == null ) {
- val = elem.style[ name ];
-
- // Should return "auto" instead of 0, use 0 for
- // temporary backwards-compat
- return val === "" || val === "auto" ? "0px" : val;
- }
-
- return typeof val === "string" ? val : val + "px";
- }
- },
-
- set: function( elem, value ) {
- if ( rnumpx.test( value ) ) {
- // ignore negative width and height values #1599
- value = parseFloat(value);
-
- if ( value >= 0 ) {
- return value + "px";
- }
-
- } else {
- return value;
- }
- }
- };
-});
-
-if ( !jQuery.support.opacity ) {
- jQuery.cssHooks.opacity = {
- get: function( elem, computed ) {
- // IE uses filters for opacity
- return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
- (parseFloat(RegExp.$1) / 100) + "" :
- computed ? "1" : "";
- },
-
- set: function( elem, value ) {
- var style = elem.style;
-
- // IE has trouble with opacity if it does not have layout
- // Force it by setting the zoom level
- style.zoom = 1;
-
- // Set the alpha filter to set the opacity
- var opacity = jQuery.isNaN(value) ?
- "" :
- "alpha(opacity=" + value * 100 + ")",
- filter = style.filter || "";
-
- style.filter = ralpha.test(filter) ?
- filter.replace(ralpha, opacity) :
- style.filter + ' ' + opacity;
- }
- };
-}
-
-if ( document.defaultView && document.defaultView.getComputedStyle ) {
- getComputedStyle = function( elem, newName, name ) {
- var ret, defaultView, computedStyle;
-
- name = name.replace( rupper, "-$1" ).toLowerCase();
-
- if ( !(defaultView = elem.ownerDocument.defaultView) ) {
- return undefined;
- }
-
- if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
- ret = computedStyle.getPropertyValue( name );
- if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
- ret = jQuery.style( elem, name );
- }
- }
-
- return ret;
- };
-}
-
-if ( document.documentElement.currentStyle ) {
- currentStyle = function( elem, name ) {
- var left, rsLeft,
- ret = elem.currentStyle && elem.currentStyle[ name ],
- style = elem.style;
-
- // From the awesome hack by Dean Edwards
- // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
-
- // If we're not dealing with a regular pixel number
- // but a number that has a weird ending, we need to convert it to pixels
- if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
- // Remember the original values
- left = style.left;
- rsLeft = elem.runtimeStyle.left;
-
- // Put in the new values to get a computed value out
- elem.runtimeStyle.left = elem.currentStyle.left;
- style.left = name === "fontSize" ? "1em" : (ret || 0);
- ret = style.pixelLeft + "px";
-
- // Revert the changed values
- style.left = left;
- elem.runtimeStyle.left = rsLeft;
- }
-
- return ret === "" ? "auto" : ret;
- };
-}
-
-curCSS = getComputedStyle || currentStyle;
-
-function getWH( elem, name, extra ) {
- var which = name === "width" ? cssWidth : cssHeight,
- val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
-
- if ( extra === "border" ) {
- return val;
- }
-
- jQuery.each( which, function() {
- if ( !extra ) {
- val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
- }
-
- if ( extra === "margin" ) {
- val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
-
- } else {
- val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
- }
- });
-
- return val;
-}
-
-if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.hidden = function( elem ) {
- var width = elem.offsetWidth,
- height = elem.offsetHeight;
-
- return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
- };
-
- jQuery.expr.filters.visible = function( elem ) {
- return !jQuery.expr.filters.hidden( elem );
- };
-}
-
-
-
-
-var jsc = jQuery.now(),
- rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
- rselectTextarea = /^(?:select|textarea)/i,
- rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
- rnoContent = /^(?:GET|HEAD)$/,
- rbracket = /\[\]$/,
- jsre = /\=\?(&|$)/,
- rquery = /\?/,
- rts = /([?&])_=[^&]*/,
- rurl = /^(\w+:)?\/\/([^\/?#]+)/,
- r20 = /%20/g,
- rhash = /#.*$/,
-
- // Keep a copy of the old load method
- _load = jQuery.fn.load;
-
-jQuery.fn.extend({
- load: function( url, params, callback ) {
- if ( typeof url !== "string" && _load ) {
- return _load.apply( this, arguments );
-
- // Don't do a request if no elements are being requested
- } else if ( !this.length ) {
- return this;
- }
-
- var off = url.indexOf(" ");
- if ( off >= 0 ) {
- var selector = url.slice(off, url.length);
- url = url.slice(0, off);
- }
-
- // Default to a GET request
- var type = "GET";
-
- // If the second parameter was provided
- if ( params ) {
- // If it's a function
- if ( jQuery.isFunction( params ) ) {
- // We assume that it's the callback
- callback = params;
- params = null;
-
- // Otherwise, build a param string
- } else if ( typeof params === "object" ) {
- params = jQuery.param( params, jQuery.ajaxSettings.traditional );
- type = "POST";
- }
- }
-
- var self = this;
-
- // Request the remote document
- jQuery.ajax({
- url: url,
- type: type,
- dataType: "html",
- data: params,
- complete: function( res, status ) {
- // If successful, inject the HTML into all the matched elements
- if ( status === "success" || status === "notmodified" ) {
- // See if a selector was specified
- self.html( selector ?
- // Create a dummy div to hold the results
- jQuery("<div>")
- // inject the contents of the document in, removing the scripts
- // to avoid any 'Permission Denied' errors in IE
- .append(res.responseText.replace(rscript, ""))
-
- // Locate the specified elements
- .find(selector) :
-
- // If not, just inject the full result
- res.responseText );
- }
-
- if ( callback ) {
- self.each( callback, [res.responseText, status, res] );
- }
- }
- });
-
- return this;
- },
-
- serialize: function() {
- return jQuery.param(this.serializeArray());
- },
-
- serializeArray: function() {
- return this.map(function() {
- return this.elements ? jQuery.makeArray(this.elements) : this;
- })
- .filter(function() {
- return this.name && !this.disabled &&
- (this.checked || rselectTextarea.test(this.nodeName) ||
- rinput.test(this.type));
- })
- .map(function( i, elem ) {
- var val = jQuery(this).val();
-
- return val == null ?
- null :
- jQuery.isArray(val) ?
- jQuery.map( val, function( val, i ) {
- return { name: elem.name, value: val };
- }) :
- { name: elem.name, value: val };
- }).get();
- }
-});
-
-// Attach a bunch of functions for handling common AJAX events
-jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
- jQuery.fn[o] = function( f ) {
- return this.bind(o, f);
- };
-});
-
-jQuery.extend({
- get: function( url, data, callback, type ) {
- // shift arguments if data argument was omited
- if ( jQuery.isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = null;
- }
-
- return jQuery.ajax({
- type: "GET",
- url: url,
- data: data,
- success: callback,
- dataType: type
- });
- },
-
- getScript: function( url, callback ) {
- return jQuery.get(url, null, callback, "script");
- },
-
- getJSON: function( url, data, callback ) {
- return jQuery.get(url, data, callback, "json");
- },
-
- post: function( url, data, callback, type ) {
- // shift arguments if data argument was omited
- if ( jQuery.isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = {};
- }
-
- return jQuery.ajax({
- type: "POST",
- url: url,
- data: data,
- success: callback,
- dataType: type
- });
- },
-
- ajaxSetup: function( settings ) {
- jQuery.extend( jQuery.ajaxSettings, settings );
- },
-
- ajaxSettings: {
- url: location.href,
- global: true,
- type: "GET",
- contentType: "application/x-www-form-urlencoded",
- processData: true,
- async: true,
- /*
- timeout: 0,
- data: null,
- username: null,
- password: null,
- traditional: false,
- */
- // This function can be overriden by calling jQuery.ajaxSetup
- xhr: function() {
- return new window.XMLHttpRequest();
- },
- accepts: {
- xml: "application/xml, text/xml",
- html: "text/html",
- script: "text/javascript, application/javascript",
- json: "application/json, text/javascript",
- text: "text/plain",
- _default: "*/*"
- }
- },
-
- ajax: function( origSettings ) {
- var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings),
- jsonp, status, data, type = s.type.toUpperCase(), noContent = rnoContent.test(type);
-
- s.url = s.url.replace( rhash, "" );
-
- // Use original (not extended) context object if it was provided
- s.context = origSettings && origSettings.context != null ? origSettings.context : s;
-
- // convert data if not already a string
- if ( s.data && s.processData && typeof s.data !== "string" ) {
- s.data = jQuery.param( s.data, s.traditional );
- }
-
- // Handle JSONP Parameter Callbacks
- if ( s.dataType === "jsonp" ) {
- if ( type === "GET" ) {
- if ( !jsre.test( s.url ) ) {
- s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
- }
- } else if ( !s.data || !jsre.test(s.data) ) {
- s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
- }
- s.dataType = "json";
- }
-
- // Build temporary JSONP function
- if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
- jsonp = s.jsonpCallback || ("jsonp" + jsc++);
-
- // Replace the =? sequence both in the query string and the data
- if ( s.data ) {
- s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
- }
-
- s.url = s.url.replace(jsre, "=" + jsonp + "$1");
-
- // We need to make sure
- // that a JSONP style response is executed properly
- s.dataType = "script";
-
- // Handle JSONP-style loading
- var customJsonp = window[ jsonp ];
-
- window[ jsonp ] = function( tmp ) {
- if ( jQuery.isFunction( customJsonp ) ) {
- customJsonp( tmp );
-
- } else {
- // Garbage collect
- window[ jsonp ] = undefined;
-
- try {
- delete window[ jsonp ];
- } catch( jsonpError ) {}
- }
-
- data = tmp;
- jQuery.handleSuccess( s, xhr, status, data );
- jQuery.handleComplete( s, xhr, status, data );
-
- if ( head ) {
- head.removeChild( script );
- }
- };
- }
-
- if ( s.dataType === "script" && s.cache === null ) {
- s.cache = false;
- }
-
- if ( s.cache === false && noContent ) {
- var ts = jQuery.now();
-
- // try replacing _= if it is there
- var ret = s.url.replace(rts, "$1_=" + ts);
-
- // if nothing was replaced, add timestamp to the end
- s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
- }
-
- // If data is available, append data to url for GET/HEAD requests
- if ( s.data && noContent ) {
- s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
- }
-
- // Watch for a new set of requests
- if ( s.global && jQuery.active++ === 0 ) {
- jQuery.event.trigger( "ajaxStart" );
- }
-
- // Matches an absolute URL, and saves the domain
- var parts = rurl.exec( s.url ),
- remote = parts && (parts[1] && parts[1].toLowerCase() !== location.protocol || parts[2].toLowerCase() !== location.host);
-
- // If we're requesting a remote document
- // and trying to load JSON or Script with a GET
- if ( s.dataType === "script" && type === "GET" && remote ) {
- var head = document.getElementsByTagName("head")[0] || document.documentElement;
- var script = document.createElement("script");
- if ( s.scriptCharset ) {
- script.charset = s.scriptCharset;
- }
- script.src = s.url;
-
- // Handle Script loading
- if ( !jsonp ) {
- var done = false;
-
- // Attach handlers for all browsers
- script.onload = script.onreadystatechange = function() {
- if ( !done && (!this.readyState ||
- this.readyState === "loaded" || this.readyState === "complete") ) {
- done = true;
- jQuery.handleSuccess( s, xhr, status, data );
- jQuery.handleComplete( s, xhr, status, data );
-
- // Handle memory leak in IE
- script.onload = script.onreadystatechange = null;
- if ( head && script.parentNode ) {
- head.removeChild( script );
- }
- }
- };
- }
-
- // Use insertBefore instead of appendChild to circumvent an IE6 bug.
- // This arises when a base node is used (#2709 and #4378).
- head.insertBefore( script, head.firstChild );
-
- // We handle everything using the script element injection
- return undefined;
- }
-
- var requestDone = false;
-
- // Create the request object
- var xhr = s.xhr();
-
- if ( !xhr ) {
- return;
- }
-
- // Open the socket
- // Passing null username, generates a login popup on Opera (#2865)
- if ( s.username ) {
- xhr.open(type, s.url, s.async, s.username, s.password);
- } else {
- xhr.open(type, s.url, s.async);
- }
-
- // Need an extra try/catch for cross domain requests in Firefox 3
- try {
- // Set content-type if data specified and content-body is valid for this type
- if ( (s.data != null && !noContent) || (origSettings && origSettings.contentType) ) {
- xhr.setRequestHeader("Content-Type", s.contentType);
- }
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- if ( jQuery.lastModified[s.url] ) {
- xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
- }
-
- if ( jQuery.etag[s.url] ) {
- xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
- }
- }
-
- // Set header so the called script knows that it's an XMLHttpRequest
- // Only send the header if it's not a remote XHR
- if ( !remote ) {
- xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
- }
-
- // Set the Accepts header for the server, depending on the dataType
- xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
- s.accepts[ s.dataType ] + ", */*; q=0.01" :
- s.accepts._default );
- } catch( headerError ) {}
-
- // Allow custom headers/mimetypes and early abort
- if ( s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false ) {
- // Handle the global AJAX counter
- if ( s.global && jQuery.active-- === 1 ) {
- jQuery.event.trigger( "ajaxStop" );
- }
-
- // close opended socket
- xhr.abort();
- return false;
- }
-
- if ( s.global ) {
- jQuery.triggerGlobal( s, "ajaxSend", [xhr, s] );
- }
-
- // Wait for a response to come back
- var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
- // The request was aborted
- if ( !xhr || xhr.readyState === 0 || isTimeout === "abort" ) {
- // Opera doesn't call onreadystatechange before this point
- // so we simulate the call
- if ( !requestDone ) {
- jQuery.handleComplete( s, xhr, status, data );
- }
-
- requestDone = true;
- if ( xhr ) {
- xhr.onreadystatechange = jQuery.noop;
- }
-
- // The transfer is complete and the data is available, or the request timed out
- } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
- requestDone = true;
- xhr.onreadystatechange = jQuery.noop;
-
- status = isTimeout === "timeout" ?
- "timeout" :
- !jQuery.httpSuccess( xhr ) ?
- "error" :
- s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
- "notmodified" :
- "success";
-
- var errMsg;
-
- if ( status === "success" ) {
- // Watch for, and catch, XML document parse errors
- try {
- // process the data (runs the xml through httpData regardless of callback)
- data = jQuery.httpData( xhr, s.dataType, s );
- } catch( parserError ) {
- status = "parsererror";
- errMsg = parserError;
- }
- }
-
- // Make sure that the request was successful or notmodified
- if ( status === "success" || status === "notmodified" ) {
- // JSONP handles its own success callback
- if ( !jsonp ) {
- jQuery.handleSuccess( s, xhr, status, data );
- }
- } else {
- jQuery.handleError( s, xhr, status, errMsg );
- }
-
- // Fire the complete handlers
- if ( !jsonp ) {
- jQuery.handleComplete( s, xhr, status, data );
- }
-
- if ( isTimeout === "timeout" ) {
- xhr.abort();
- }
-
- // Stop memory leaks
- if ( s.async ) {
- xhr = null;
- }
- }
- };
-
- // Override the abort handler, if we can (IE 6 doesn't allow it, but that's OK)
- // Opera doesn't fire onreadystatechange at all on abort
- try {
- var oldAbort = xhr.abort;
- xhr.abort = function() {
- if ( xhr ) {
- // oldAbort has no call property in IE7 so
- // just do it this way, which works in all
- // browsers
- Function.prototype.call.call( oldAbort, xhr );
- }
-
- onreadystatechange( "abort" );
- };
- } catch( abortError ) {}
-
- // Timeout checker
- if ( s.async && s.timeout > 0 ) {
- setTimeout(function() {
- // Check to see if the request is still happening
- if ( xhr && !requestDone ) {
- onreadystatechange( "timeout" );
- }
- }, s.timeout);
- }
-
- // Send the data
- try {
- xhr.send( noContent || s.data == null ? null : s.data );
-
- } catch( sendError ) {
- jQuery.handleError( s, xhr, null, sendError );
-
- // Fire the complete handlers
- jQuery.handleComplete( s, xhr, status, data );
- }
-
- // firefox 1.5 doesn't fire statechange for sync requests
- if ( !s.async ) {
- onreadystatechange();
- }
-
- // return XMLHttpRequest to allow aborting the request etc.
- return xhr;
- },
-
- // Serialize an array of form elements or a set of
- // key/values into a query string
- param: function( a, traditional ) {
- var s = [],
- add = function( key, value ) {
- // If value is a function, invoke it and return its value
- value = jQuery.isFunction(value) ? value() : value;
- s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
- };
-
- // Set traditional to true for jQuery <= 1.3.2 behavior.
- if ( traditional === undefined ) {
- traditional = jQuery.ajaxSettings.traditional;
- }
-
- // If an array was passed in, assume that it is an array of form elements.
- if ( jQuery.isArray(a) || a.jquery ) {
- // Serialize the form elements
- jQuery.each( a, function() {
- add( this.name, this.value );
- });
-
- } else {
- // If traditional, encode the "old" way (the way 1.3.2 or older
- // did it), otherwise encode params recursively.
- for ( var prefix in a ) {
- buildParams( prefix, a[prefix], traditional, add );
- }
- }
-
- // Return the resulting serialization
- return s.join("&").replace(r20, "+");
- }
-});
-
-function buildParams( prefix, obj, traditional, add ) {
- if ( jQuery.isArray(obj) && obj.length ) {
- // Serialize array item.
- jQuery.each( obj, function( i, v ) {
- if ( traditional || rbracket.test( prefix ) ) {
- // Treat each array item as a scalar.
- add( prefix, v );
-
- } else {
- // If array item is non-scalar (array or object), encode its
- // numeric index to resolve deserialization ambiguity issues.
- // Note that rack (as of 1.0.0) can't currently deserialize
- // nested arrays properly, and attempting to do so may cause
- // a server error. Possible fixes are to modify rack's
- // deserialization algorithm or to provide an option or flag
- // to force array serialization to be shallow.
- buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
- }
- });
-
- } else if ( !traditional && obj != null && typeof obj === "object" ) {
- if ( jQuery.isEmptyObject( obj ) ) {
- add( prefix, "" );
-
- // Serialize object item.
- } else {
- jQuery.each( obj, function( k, v ) {
- buildParams( prefix + "[" + k + "]", v, traditional, add );
- });
- }
-
- } else {
- // Serialize scalar item.
- add( prefix, obj );
- }
-}
-
-// This is still on the jQuery object... for now
-// Want to move this to jQuery.ajax some day
-jQuery.extend({
-
- // Counter for holding the number of active queries
- active: 0,
-
- // Last-Modified header cache for next request
- lastModified: {},
- etag: {},
-
- handleError: function( s, xhr, status, e ) {
- // If a local callback was specified, fire it
- if ( s.error ) {
- s.error.call( s.context, xhr, status, e );
- }
-
- // Fire the global callback
- if ( s.global ) {
- jQuery.triggerGlobal( s, "ajaxError", [xhr, s, e] );
- }
- },
-
- handleSuccess: function( s, xhr, status, data ) {
- // If a local callback was specified, fire it and pass it the data
- if ( s.success ) {
- s.success.call( s.context, data, status, xhr );
- }
-
- // Fire the global callback
- if ( s.global ) {
- jQuery.triggerGlobal( s, "ajaxSuccess", [xhr, s] );
- }
- },
-
- handleComplete: function( s, xhr, status ) {
- // Process result
- if ( s.complete ) {
- s.complete.call( s.context, xhr, status );
- }
-
- // The request was completed
- if ( s.global ) {
- jQuery.triggerGlobal( s, "ajaxComplete", [xhr, s] );
- }
-
- // Handle the global AJAX counter
- if ( s.global && jQuery.active-- === 1 ) {
- jQuery.event.trigger( "ajaxStop" );
- }
- },
-
- triggerGlobal: function( s, type, args ) {
- (s.context && s.context.url == null ? jQuery(s.context) : jQuery.event).trigger(type, args);
- },
-
- // Determines if an XMLHttpRequest was successful or not
- httpSuccess: function( xhr ) {
- try {
- // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
- return !xhr.status && location.protocol === "file:" ||
- xhr.status >= 200 && xhr.status < 300 ||
- xhr.status === 304 || xhr.status === 1223;
- } catch(e) {}
-
- return false;
- },
-
- // Determines if an XMLHttpRequest returns NotModified
- httpNotModified: function( xhr, url ) {
- var lastModified = xhr.getResponseHeader("Last-Modified"),
- etag = xhr.getResponseHeader("Etag");
-
- if ( lastModified ) {
- jQuery.lastModified[url] = lastModified;
- }
-
- if ( etag ) {
- jQuery.etag[url] = etag;
- }
-
- return xhr.status === 304;
- },
-
- httpData: function( xhr, type, s ) {
- var ct = xhr.getResponseHeader("content-type") || "",
- xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
- data = xml ? xhr.responseXML : xhr.responseText;
-
- if ( xml && data.documentElement.nodeName === "parsererror" ) {
- jQuery.error( "parsererror" );
- }
-
- // Allow a pre-filtering function to sanitize the response
- // s is checked to keep backwards compatibility
- if ( s && s.dataFilter ) {
- data = s.dataFilter( data, type );
- }
-
- // The filter can actually parse the response
- if ( typeof data === "string" ) {
- // Get the JavaScript object, if JSON is used.
- if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
- data = jQuery.parseJSON( data );
-
- // If the type is "script", eval it in global context
- } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
- jQuery.globalEval( data );
- }
- }
-
- return data;
- }
-
-});
-
-/*
- * Create the request object; Microsoft failed to properly
- * implement the XMLHttpRequest in IE7 (can't request local files),
- * so we use the ActiveXObject when it is available
- * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
- * we need a fallback.
- */
-if ( window.ActiveXObject ) {
- jQuery.ajaxSettings.xhr = function() {
- if ( window.location.protocol !== "file:" ) {
- try {
- return new window.XMLHttpRequest();
- } catch(xhrError) {}
- }
-
- try {
- return new window.ActiveXObject("Microsoft.XMLHTTP");
- } catch(activeError) {}
- };
-}
-
-// Does this browser support XHR requests?
-jQuery.support.ajax = !!jQuery.ajaxSettings.xhr();
-
-
-
-
-var elemdisplay = {},
- rfxtypes = /^(?:toggle|show|hide)$/,
- rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/,
- timerId,
- fxAttrs = [
- // height animations
- [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
- // width animations
- [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
- // opacity animations
- [ "opacity" ]
- ];
-
-jQuery.fn.extend({
- show: function( speed, easing, callback ) {
- var elem, display;
-
- if ( speed || speed === 0 ) {
- return this.animate( genFx("show", 3), speed, easing, callback);
-
- } else {
- for ( var i = 0, j = this.length; i < j; i++ ) {
- elem = this[i];
- display = elem.style.display;
-
- // Reset the inline display of this element to learn if it is
- // being hidden by cascaded rules or not
- if ( !jQuery.data(elem, "olddisplay") && display === "none" ) {
- display = elem.style.display = "";
- }
-
- // Set elements which have been overridden with display: none
- // in a stylesheet to whatever the default browser style is
- // for such an element
- if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
- jQuery.data(elem, "olddisplay", defaultDisplay(elem.nodeName));
- }
- }
-
- // Set the display of most of the elements in a second loop
- // to avoid the constant reflow
- for ( i = 0; i < j; i++ ) {
- elem = this[i];
- display = elem.style.display;
-
- if ( display === "" || display === "none" ) {
- elem.style.display = jQuery.data(elem, "olddisplay") || "";
- }
- }
-
- return this;
- }
- },
-
- hide: function( speed, easing, callback ) {
- if ( speed || speed === 0 ) {
- return this.animate( genFx("hide", 3), speed, easing, callback);
-
- } else {
- for ( var i = 0, j = this.length; i < j; i++ ) {
- var display = jQuery.css( this[i], "display" );
-
- if ( display !== "none" ) {
- jQuery.data( this[i], "olddisplay", display );
- }
- }
-
- // Set the display of the elements in a second loop
- // to avoid the constant reflow
- for ( i = 0; i < j; i++ ) {
- this[i].style.display = "none";
- }
-
- return this;
- }
- },
-
- // Save the old toggle function
- _toggle: jQuery.fn.toggle,
-
- toggle: function( fn, fn2, callback ) {
- var bool = typeof fn === "boolean";
-
- if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
- this._toggle.apply( this, arguments );
-
- } else if ( fn == null || bool ) {
- this.each(function() {
- var state = bool ? fn : jQuery(this).is(":hidden");
- jQuery(this)[ state ? "show" : "hide" ]();
- });
-
- } else {
- this.animate(genFx("toggle", 3), fn, fn2, callback);
- }
-
- return this;
- },
-
- fadeTo: function( speed, to, easing, callback ) {
- return this.filter(":hidden").css("opacity", 0).show().end()
- .animate({opacity: to}, speed, easing, callback);
- },
-
- animate: function( prop, speed, easing, callback ) {
- var optall = jQuery.speed(speed, easing, callback);
-
- if ( jQuery.isEmptyObject( prop ) ) {
- return this.each( optall.complete );
- }
-
- return this[ optall.queue === false ? "each" : "queue" ](function() {
- // XXX 'this' does not always have a nodeName when running the
- // test suite
-
- var opt = jQuery.extend({}, optall), p,
- isElement = this.nodeType === 1,
- hidden = isElement && jQuery(this).is(":hidden"),
- self = this;
-
- for ( p in prop ) {
- var name = jQuery.camelCase( p );
-
- if ( p !== name ) {
- prop[ name ] = prop[ p ];
- delete prop[ p ];
- p = name;
- }
-
- if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
- return opt.complete.call(this);
- }
-
- if ( isElement && ( p === "height" || p === "width" ) ) {
- // Make sure that nothing sneaks out
- // Record all 3 overflow attributes because IE does not
- // change the overflow attribute when overflowX and
- // overflowY are set to the same value
- opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
-
- // Set display property to inline-block for height/width
- // animations on inline elements that are having width/height
- // animated
- if ( jQuery.css( this, "display" ) === "inline" &&
- jQuery.css( this, "float" ) === "none" ) {
- if ( !jQuery.support.inlineBlockNeedsLayout ) {
- this.style.display = "inline-block";
-
- } else {
- var display = defaultDisplay(this.nodeName);
-
- // inline-level elements accept inline-block;
- // block-level elements need to be inline with layout
- if ( display === "inline" ) {
- this.style.display = "inline-block";
-
- } else {
- this.style.display = "inline";
- this.style.zoom = 1;
- }
- }
- }
- }
-
- if ( jQuery.isArray( prop[p] ) ) {
- // Create (if needed) and add to specialEasing
- (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
- prop[p] = prop[p][0];
- }
- }
-
- if ( opt.overflow != null ) {
- this.style.overflow = "hidden";
- }
-
- opt.curAnim = jQuery.extend({}, prop);
-
- jQuery.each( prop, function( name, val ) {
- var e = new jQuery.fx( self, opt, name );
-
- if ( rfxtypes.test(val) ) {
- e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
-
- } else {
- var parts = rfxnum.exec(val),
- start = e.cur() || 0;
-
- if ( parts ) {
- var end = parseFloat( parts[2] ),
- unit = parts[3] || "px";
-
- // We need to compute starting value
- if ( unit !== "px" ) {
- jQuery.style( self, name, (end || 1) + unit);
- start = ((end || 1) / e.cur()) * start;
- jQuery.style( self, name, start + unit);
- }
-
- // If a +=/-= token was provided, we're doing a relative animation
- if ( parts[1] ) {
- end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
- }
-
- e.custom( start, end, unit );
-
- } else {
- e.custom( start, val, "" );
- }
- }
- });
-
- // For JS strict compliance
- return true;
- });
- },
-
- stop: function( clearQueue, gotoEnd ) {
- var timers = jQuery.timers;
-
- if ( clearQueue ) {
- this.queue([]);
- }
-
- this.each(function() {
- // go in reverse order so anything added to the queue during the loop is ignored
- for ( var i = timers.length - 1; i >= 0; i-- ) {
- if ( timers[i].elem === this ) {
- if (gotoEnd) {
- // force the next step to be the last
- timers[i](true);
- }
-
- timers.splice(i, 1);
- }
- }
- });
-
- // start the next in the queue if the last step wasn't forced
- if ( !gotoEnd ) {
- this.dequeue();
- }
-
- return this;
- }
-
-});
-
-function genFx( type, num ) {
- var obj = {};
-
- jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
- obj[ this ] = type;
- });
-
- return obj;
-}
-
-// Generate shortcuts for custom animations
-jQuery.each({
- slideDown: genFx("show", 1),
- slideUp: genFx("hide", 1),
- slideToggle: genFx("toggle", 1),
- fadeIn: { opacity: "show" },
- fadeOut: { opacity: "hide" },
- fadeToggle: { opacity: "toggle" }
-}, function( name, props ) {
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return this.animate( props, speed, easing, callback );
- };
-});
-
-jQuery.extend({
- speed: function( speed, easing, fn ) {
- var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
- complete: fn || !fn && easing ||
- jQuery.isFunction( speed ) && speed,
- duration: speed,
- easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
- };
-
- opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
- opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
-
- // Queueing
- opt.old = opt.complete;
- opt.complete = function() {
- if ( opt.queue !== false ) {
- jQuery(this).dequeue();
- }
- if ( jQuery.isFunction( opt.old ) ) {
- opt.old.call( this );
- }
- };
-
- return opt;
- },
-
- easing: {
- linear: function( p, n, firstNum, diff ) {
- return firstNum + diff * p;
- },
- swing: function( p, n, firstNum, diff ) {
- return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
- }
- },
-
- timers: [],
-
- fx: function( elem, options, prop ) {
- this.options = options;
- this.elem = elem;
- this.prop = prop;
-
- if ( !options.orig ) {
- options.orig = {};
- }
- }
-
-});
-
-jQuery.fx.prototype = {
- // Simple function for setting a style value
- update: function() {
- if ( this.options.step ) {
- this.options.step.call( this.elem, this.now, this );
- }
-
- (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
- },
-
- // Get the current size
- cur: function() {
- if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
- return this.elem[ this.prop ];
- }
-
- var r = parseFloat( jQuery.css( this.elem, this.prop ) );
- return r && r > -10000 ? r : 0;
- },
-
- // Start an animation from one number to another
- custom: function( from, to, unit ) {
- var self = this,
- fx = jQuery.fx;
-
- this.startTime = jQuery.now();
- this.start = from;
- this.end = to;
- this.unit = unit || this.unit || "px";
- this.now = this.start;
- this.pos = this.state = 0;
-
- function t( gotoEnd ) {
- return self.step(gotoEnd);
- }
-
- t.elem = this.elem;
-
- if ( t() && jQuery.timers.push(t) && !timerId ) {
- timerId = setInterval(fx.tick, fx.interval);
- }
- },
-
- // Simple 'show' function
- show: function() {
- // Remember where we started, so that we can go back to it later
- this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
- this.options.show = true;
-
- // Begin the animation
- // Make sure that we start at a small width/height to avoid any
- // flash of content
- this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
-
- // Start by showing the element
- jQuery( this.elem ).show();
- },
-
- // Simple 'hide' function
- hide: function() {
- // Remember where we started, so that we can go back to it later
- this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
- this.options.hide = true;
-
- // Begin the animation
- this.custom(this.cur(), 0);
- },
-
- // Each step of an animation
- step: function( gotoEnd ) {
- var t = jQuery.now(), done = true;
-
- if ( gotoEnd || t >= this.options.duration + this.startTime ) {
- this.now = this.end;
- this.pos = this.state = 1;
- this.update();
-
- this.options.curAnim[ this.prop ] = true;
-
- for ( var i in this.options.curAnim ) {
- if ( this.options.curAnim[i] !== true ) {
- done = false;
- }
- }
-
- if ( done ) {
- // Reset the overflow
- if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
- var elem = this.elem,
- options = this.options;
-
- jQuery.each( [ "", "X", "Y" ], function (index, value) {
- elem.style[ "overflow" + value ] = options.overflow[index];
- } );
- }
-
- // Hide the element if the "hide" operation was done
- if ( this.options.hide ) {
- jQuery(this.elem).hide();
- }
-
- // Reset the properties, if the item has been hidden or shown
- if ( this.options.hide || this.options.show ) {
- for ( var p in this.options.curAnim ) {
- jQuery.style( this.elem, p, this.options.orig[p] );
- }
- }
-
- // Execute the complete function
- this.options.complete.call( this.elem );
- }
-
- return false;
-
- } else {
- var n = t - this.startTime;
- this.state = n / this.options.duration;
-
- // Perform the easing function, defaults to swing
- var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
- var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
- this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
- this.now = this.start + ((this.end - this.start) * this.pos);
-
- // Perform the next step of the animation
- this.update();
- }
-
- return true;
- }
-};
-
-jQuery.extend( jQuery.fx, {
- tick: function() {
- var timers = jQuery.timers;
-
- for ( var i = 0; i < timers.length; i++ ) {
- if ( !timers[i]() ) {
- timers.splice(i--, 1);
- }
- }
-
- if ( !timers.length ) {
- jQuery.fx.stop();
- }
- },
-
- interval: 13,
-
- stop: function() {
- clearInterval( timerId );
- timerId = null;
- },
-
- speeds: {
- slow: 600,
- fast: 200,
- // Default speed
- _default: 400
- },
-
- step: {
- opacity: function( fx ) {
- jQuery.style( fx.elem, "opacity", fx.now );
- },
-
- _default: function( fx ) {
- if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
- fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
- } else {
- fx.elem[ fx.prop ] = fx.now;
- }
- }
- }
-});
-
-if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.animated = function( elem ) {
- return jQuery.grep(jQuery.timers, function( fn ) {
- return elem === fn.elem;
- }).length;
- };
-}
-
-function defaultDisplay( nodeName ) {
- if ( !elemdisplay[ nodeName ] ) {
- var elem = jQuery("<" + nodeName + ">").appendTo("body"),
- display = elem.css("display");
-
- elem.remove();
-
- if ( display === "none" || display === "" ) {
- display = "block";
- }
-
- elemdisplay[ nodeName ] = display;
- }
-
- return elemdisplay[ nodeName ];
-}
-
-
-
-
-var rtable = /^t(?:able|d|h)$/i,
- rroot = /^(?:body|html)$/i;
-
-if ( "getBoundingClientRect" in document.documentElement ) {
- jQuery.fn.offset = function( options ) {
- var elem = this[0], box;
-
- if ( options ) {
- return this.each(function( i ) {
- jQuery.offset.setOffset( this, options, i );
- });
- }
-
- if ( !elem || !elem.ownerDocument ) {
- return null;
- }
-
- if ( elem === elem.ownerDocument.body ) {
- return jQuery.offset.bodyOffset( elem );
- }
-
- try {
- box = elem.getBoundingClientRect();
- } catch(e) {}
-
- var doc = elem.ownerDocument,
- docElem = doc.documentElement;
-
- // Make sure we're not dealing with a disconnected DOM node
- if ( !box || !jQuery.contains( docElem, elem ) ) {
- return box || { top: 0, left: 0 };
- }
-
- var body = doc.body,
- win = getWindow(doc),
- clientTop = docElem.clientTop || body.clientTop || 0,
- clientLeft = docElem.clientLeft || body.clientLeft || 0,
- scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ),
- scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
- top = box.top + scrollTop - clientTop,
- left = box.left + scrollLeft - clientLeft;
-
- return { top: top, left: left };
- };
-
-} else {
- jQuery.fn.offset = function( options ) {
- var elem = this[0];
-
- if ( options ) {
- return this.each(function( i ) {
- jQuery.offset.setOffset( this, options, i );
- });
- }
-
- if ( !elem || !elem.ownerDocument ) {
- return null;
- }
-
- if ( elem === elem.ownerDocument.body ) {
- return jQuery.offset.bodyOffset( elem );
- }
-
- jQuery.offset.initialize();
-
- var computedStyle,
- offsetParent = elem.offsetParent,
- prevOffsetParent = elem,
- doc = elem.ownerDocument,
- docElem = doc.documentElement,
- body = doc.body,
- defaultView = doc.defaultView,
- prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
- top = elem.offsetTop,
- left = elem.offsetLeft;
-
- while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
- if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
- break;
- }
-
- computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
- top -= elem.scrollTop;
- left -= elem.scrollLeft;
-
- if ( elem === offsetParent ) {
- top += elem.offsetTop;
- left += elem.offsetLeft;
-
- if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
- top += parseFloat( computedStyle.borderTopWidth ) || 0;
- left += parseFloat( computedStyle.borderLeftWidth ) || 0;
- }
-
- prevOffsetParent = offsetParent;
- offsetParent = elem.offsetParent;
- }
-
- if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
- top += parseFloat( computedStyle.borderTopWidth ) || 0;
- left += parseFloat( computedStyle.borderLeftWidth ) || 0;
- }
-
- prevComputedStyle = computedStyle;
- }
-
- if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
- top += body.offsetTop;
- left += body.offsetLeft;
- }
-
- if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
- top += Math.max( docElem.scrollTop, body.scrollTop );
- left += Math.max( docElem.scrollLeft, body.scrollLeft );
- }
-
- return { top: top, left: left };
- };
-}
-
-jQuery.offset = {
- initialize: function() {
- var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
- html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
-
- jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
-
- container.innerHTML = html;
- body.insertBefore( container, body.firstChild );
- innerDiv = container.firstChild;
- checkDiv = innerDiv.firstChild;
- td = innerDiv.nextSibling.firstChild.firstChild;
-
- this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
- this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
-
- checkDiv.style.position = "fixed";
- checkDiv.style.top = "20px";
-
- // safari subtracts parent border width here which is 5px
- this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
- checkDiv.style.position = checkDiv.style.top = "";
-
- innerDiv.style.overflow = "hidden";
- innerDiv.style.position = "relative";
-
- this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
-
- this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
-
- body.removeChild( container );
- body = container = innerDiv = checkDiv = table = td = null;
- jQuery.offset.initialize = jQuery.noop;
- },
-
- bodyOffset: function( body ) {
- var top = body.offsetTop,
- left = body.offsetLeft;
-
- jQuery.offset.initialize();
-
- if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
- top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
- left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
- }
-
- return { top: top, left: left };
- },
-
- setOffset: function( elem, options, i ) {
- var position = jQuery.css( elem, "position" );
-
- // set position first, in-case top/left are set even on static elem
- if ( position === "static" ) {
- elem.style.position = "relative";
- }
-
- var curElem = jQuery( elem ),
- curOffset = curElem.offset(),
- curCSSTop = jQuery.css( elem, "top" ),
- curCSSLeft = jQuery.css( elem, "left" ),
- calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1),
- props = {}, curPosition = {}, curTop, curLeft;
-
- // need to be able to calculate position if either top or left is auto and position is absolute
- if ( calculatePosition ) {
- curPosition = curElem.position();
- }
-
- curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
- curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
-
- if ( jQuery.isFunction( options ) ) {
- options = options.call( elem, i, curOffset );
- }
-
- if (options.top != null) {
- props.top = (options.top - curOffset.top) + curTop;
- }
- if (options.left != null) {
- props.left = (options.left - curOffset.left) + curLeft;
- }
-
- if ( "using" in options ) {
- options.using.call( elem, props );
- } else {
- curElem.css( props );
- }
- }
-};
-
-
-jQuery.fn.extend({
- position: function() {
- if ( !this[0] ) {
- return null;
- }
-
- var elem = this[0],
-
- // Get *real* offsetParent
- offsetParent = this.offsetParent(),
-
- // Get correct offsets
- offset = this.offset(),
- parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
-
- // Subtract element margins
- // note: when an element has margin: auto the offsetLeft and marginLeft
- // are the same in Safari causing offset.left to incorrectly be 0
- offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
- offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
-
- // Add offsetParent borders
- parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
- parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
-
- // Subtract the two offsets
- return {
- top: offset.top - parentOffset.top,
- left: offset.left - parentOffset.left
- };
- },
-
- offsetParent: function() {
- return this.map(function() {
- var offsetParent = this.offsetParent || document.body;
- while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
- offsetParent = offsetParent.offsetParent;
- }
- return offsetParent;
- });
- }
-});
-
-
-// Create scrollLeft and scrollTop methods
-jQuery.each( ["Left", "Top"], function( i, name ) {
- var method = "scroll" + name;
-
- jQuery.fn[ method ] = function(val) {
- var elem = this[0], win;
-
- if ( !elem ) {
- return null;
- }
-
- if ( val !== undefined ) {
- // Set the scroll offset
- return this.each(function() {
- win = getWindow( this );
-
- if ( win ) {
- win.scrollTo(
- !i ? val : jQuery(win).scrollLeft(),
- i ? val : jQuery(win).scrollTop()
- );
-
- } else {
- this[ method ] = val;
- }
- });
- } else {
- win = getWindow( elem );
-
- // Return the scroll offset
- return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
- jQuery.support.boxModel && win.document.documentElement[ method ] ||
- win.document.body[ method ] :
- elem[ method ];
- }
- };
-});
-
-function getWindow( elem ) {
- return jQuery.isWindow( elem ) ?
- elem :
- elem.nodeType === 9 ?
- elem.defaultView || elem.parentWindow :
- false;
-}
-
-
-
-
-// Create innerHeight, innerWidth, outerHeight and outerWidth methods
-jQuery.each([ "Height", "Width" ], function( i, name ) {
-
- var type = name.toLowerCase();
-
- // innerHeight and innerWidth
- jQuery.fn["inner" + name] = function() {
- return this[0] ?
- parseFloat( jQuery.css( this[0], type, "padding" ) ) :
- null;
- };
-
- // outerHeight and outerWidth
- jQuery.fn["outer" + name] = function( margin ) {
- return this[0] ?
- parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
- null;
- };
-
- jQuery.fn[ type ] = function( size ) {
- // Get window width or height
- var elem = this[0];
- if ( !elem ) {
- return size == null ? null : this;
- }
-
- if ( jQuery.isFunction( size ) ) {
- return this.each(function( i ) {
- var self = jQuery( this );
- self[ type ]( size.call( this, i, self[ type ]() ) );
- });
- }
-
- if ( jQuery.isWindow( elem ) ) {
- // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
- return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
- elem.document.body[ "client" + name ];
-
- // Get document width or height
- } else if ( elem.nodeType === 9 ) {
- // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
- return Math.max(
- elem.documentElement["client" + name],
- elem.body["scroll" + name], elem.documentElement["scroll" + name],
- elem.body["offset" + name], elem.documentElement["offset" + name]
- );
-
- // Get or set width or height on the element
- } else if ( size === undefined ) {
- var orig = jQuery.css( elem, type ),
- ret = parseFloat( orig );
-
- return jQuery.isNaN( ret ) ? orig : ret;
-
- // Set the width or height on the element (default to pixels if value is unitless)
- } else {
- return this.css( type, typeof size === "string" ? size : size + "px" );
- }
- };
-
-});
-
-
-})(window);
commit da30a6ee7d9cfaebafed74721d7eebb061c2e114
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 18 11:08:22 2011 -0400
add javadoc
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java
index 1cfe874..50f3766 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/Locatable.java
@@ -1,10 +1,34 @@
+/*
+ * 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.enterprise.gui.coregui.client.util.selenium;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
/**
- * TODO
+ * Interface to all locatable components.
+ * Implement this to ensure Selenium testability for the implementing component.
*/
public interface Locatable {
commit 94be9df7fdad867c1643259d860e80b5c966d477
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 18 11:01:22 2011 -0400
this is a locatable class, so it should be implementing Locatable interface
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java
index 359abfd..ea6a2f1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableIButton.java
@@ -7,10 +7,19 @@ import com.smartgwt.client.widgets.IButton;
*
* @author Jay Shaughnessy
*/
-public class LocatableIButton extends IButton {
+public class LocatableIButton extends IButton implements Locatable {
+ private String locatorId;
+
+ /**
+ * <pre>
+ * ID Format: "simpleClassname_locatorId"
+ * </pre>
+ * @param locatorId not null or empty.
+ */
public LocatableIButton(String locatorId) {
- this(locatorId, null);
+ super();
+ init(locatorId);
}
/**
@@ -18,10 +27,23 @@ public class LocatableIButton extends IButton {
* ID Format: "simpleClassname_locatorId"
* </pre>
* @param locatorId not null or empty.
+ * @param title
*/
public LocatableIButton(String locatorId, String title) {
super(title);
+ init(locatorId);
+ }
+
+ private void init(String locatorId) {
+ this.locatorId = locatorId;
SeleniumUtility.setID(this, locatorId);
}
+ public String getLocatorId() {
+ return locatorId;
+ }
+
+ public String extendLocatorId(String extension) {
+ return this.locatorId + "_" + extension;
+ }
}
commit 411d51c2651217a4994651670e3c121c969e21c7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 18 10:06:10 2011 -0400
add separator
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index d0588ca..1891bd4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -87,13 +87,13 @@ public class MessageCenterView extends LocatableVLayout implements MessageCenter
showDetails(message);
}
});
- messagesMenu.addItem(messageItem, 1);
+ messagesMenu.addItem(messageItem, 2); // put this just below the "clear all msgs" item and the separator
// to avoid flooding the message center, clip old messages
final int maxMessages = 25;
if (messageCount > maxMessages) {
MenuItem[] items = messagesMenu.getItems();
- MenuItem[] clippedItems = new MenuItem[maxMessages + 1]; // +1 to take into account the Clear All Messages item
+ MenuItem[] clippedItems = new MenuItem[maxMessages + 2]; // +2 to take into account the Clear All Messages item and the separator
System.arraycopy(items, 0, clippedItems, 0, clippedItems.length);
messagesMenu.setItems(clippedItems);
}
@@ -109,6 +109,11 @@ public class MessageCenterView extends LocatableVLayout implements MessageCenter
}
});
messagesMenu.setItems(clearItem); // setItems making this the only item in the menu
+
+ MenuItem separator = new MenuItem();
+ separator.setIsSeparator(true);
+ messagesMenu.addItem(separator);
+
markForRedraw();
}
commit ef4dc73f70fd6c1fd2e1b45b13d5645b5b5ed1e0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 17 17:58:34 2011 -0400
BZ 681355 - message center enhancements. you can now clear the messages via the top "Clear All Messages" menu item.
The newest/latest message appears at the top - the messages are now in descending order.
There is a limit to the number of messages in the message center, the older messages get clipped.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index a96b25a..d0588ca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -18,14 +18,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.util.message;
-import java.util.List;
-
-import com.allen_sauer.gwt.log.client.Log;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -34,6 +29,7 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.menu.IMenuButton;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -50,6 +46,10 @@ public class MessageCenterView extends LocatableVLayout implements MessageCenter
public static final String LOCATOR_ID = "MessageCenter";
+ private Menu messagesMenu;
+ private IMenuButton messageCenterButton;
+ private int messageCount;
+
public MessageCenterView(String locatorId) {
super(locatorId, 5);
setHeight100();
@@ -60,39 +60,63 @@ public class MessageCenterView extends LocatableVLayout implements MessageCenter
@Override
protected void onDraw() {
super.onDraw();
+
+ messagesMenu = new LocatableMenu(this.extendLocatorId("Messages"));
+
+ messageCenterButton = new LocatableIMenuButton(extendLocatorId("RecentEvents"), MSG
+ .view_messageCenter_messageTitle(), messagesMenu);
+ messageCenterButton.setAutoFit(true);
+
+ emptyMenu();
+ addMember(messageCenterButton);
+
CoreGUI.getMessageCenter().addMessageListener(this);
+ }
- final Menu recentEventsMenu = new LocatableMenu(this.extendLocatorId("Messages"));
-
- IMenuButton recentEventsButton = new LocatableIMenuButton(extendLocatorId("RecentEvents"), MSG
- .view_messageCenter_messageTitle(), recentEventsMenu);
- recentEventsButton.setAutoFit(true);
-
- recentEventsButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- List<Message> messages = CoreGUI.getMessageCenter().getMessages();
- if (messages.isEmpty()) {
- recentEventsMenu.setItems(new MenuItem(MSG.view_messageCenter_noRecentMessages()));
- } else {
- MenuItem[] items = new MenuItem[messages.size()];
- for (int i = 0, messagesSize = messages.size(); i < messagesSize; i++) {
- final Message message = messages.get(i);
- MenuItem messageItem = new MenuItem(message.conciseMessage, getSeverityIcon(message.severity));
-
- items[i] = messageItem;
-
- messageItem.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- showDetails(message);
- }
- });
- }
- recentEventsMenu.setItems(items);
+ public void onMessage(final Message message) {
+ if (!message.isTransient()) {
+ if (messageCount == 0) {
+ addClearMenuItem();
+ }
+ messageCount++;
+
+ MenuItem messageItem = new MenuItem(message.conciseMessage, getSeverityIcon(message.severity));
+ messageItem.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(MenuItemClickEvent event) {
+ showDetails(message);
}
+ });
+ messagesMenu.addItem(messageItem, 1);
+
+ // to avoid flooding the message center, clip old messages
+ final int maxMessages = 25;
+ if (messageCount > maxMessages) {
+ MenuItem[] items = messagesMenu.getItems();
+ MenuItem[] clippedItems = new MenuItem[maxMessages + 1]; // +1 to take into account the Clear All Messages item
+ System.arraycopy(items, 0, clippedItems, 0, clippedItems.length);
+ messagesMenu.setItems(clippedItems);
+ }
+ }
+ }
+
+ private void addClearMenuItem() {
+ MenuItem clearItem = new MenuItem(MSG.view_messageCenter_clearAllMessages());
+ clearItem.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
+ @Override
+ public void onClick(MenuItemClickEvent event) {
+ emptyMenu();
}
});
+ messagesMenu.setItems(clearItem); // setItems making this the only item in the menu
+ markForRedraw();
+ }
- addMember(recentEventsButton);
+ private void emptyMenu() {
+ CoreGUI.getMessageCenter().getMessages().clear();
+ messageCount = 0;
+ messagesMenu.setItems(new MenuItem(MSG.view_messageCenter_noRecentMessages()));
+ markForRedraw();
}
private void showDetails(Message message) {
@@ -138,31 +162,6 @@ public class MessageCenterView extends LocatableVLayout implements MessageCenter
});
}
- public void onMessage(final Message message) {
- if (!message.isTransient()) {
- logMessage(message);
- }
- }
-
- private void logMessage(Message message) {
- // TODO: Format the message better.
- String logMessage = message.toString();
- switch (message.getSeverity()) {
- case Info:
- Log.info(logMessage);
- break;
- case Warning:
- Log.warn(logMessage);
- break;
- case Error:
- Log.error(logMessage);
- break;
- case Fatal:
- Log.fatal(logMessage);
- break;
- }
- }
-
private String getSeverityIcon(Message.Severity severity) {
String iconSrc = null;
switch (severity) {
@@ -179,5 +178,4 @@ public class MessageCenterView extends LocatableVLayout implements MessageCenter
}
return iconSrc;
}
-
}
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 11bafec..b7bc5c4 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
@@ -2087,6 +2087,7 @@ view_searchGUI_loginStatus = Unable to determine login status, check server stat
#--------------------------
view_messageCenter_button_messages = Messages
view_messageCenter_noRecentMessages = No Recent Messages
+view_messageCenter_clearAllMessages = Clear All Messages
view_messageCenter_messageTitle = Message Center
view_messageCenter_messageSeverity = Severity
view_messageCenter_messageTime = Time
commit 0f155ea0c73e15258b6489a59ff758bdbe1c8bcc
Merge: da19c1a 189da6b
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Mar 17 16:26:10 2011 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit da19c1a6b8d117e0ca04702938e5c7abce6348b6
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Mar 17 16:17:59 2011 -0400
[BZ 683545] scan plugins directory after deleting plugin and fix purge logic
This commit addresses a problem that occurs when deleting, purging, then
re-adding the plugin. The agent plugin scanner maintains a cache of
plugins on the file system, and that cache was getting dirty. This
results in the scanner failing to detect a plugin that has been re-added
as a new plugin, and consequently, the plugin did not get re-installed.
Now when deleting a plugin, a scan is immediately triggered.
Then if you went yo purge right away, you could wind up with a
constraint violoation in rhq_resource_type. Resource types are purged in
a scheduled job, so it was possible to purge and re-add a plugin before
its resource types have been purged. Now the plugin is marked to be
purged. The purge is done in a scheduled job and is not done until all
resource types from the plugin have been purged.
Once the user sees that the plugin has been purged, he knows it is safe
to re-add it.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
index 61a7211..34eb929 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/Plugin.java
@@ -218,7 +218,29 @@ import javax.persistence.NamedQuery;
+ " JOIN res.resourceType rt " //
+ " WHERE ( rt.category = :resourceCategory OR :resourceCategory IS NULL ) " //
+ " AND ( rt.name = :resourceTypeName OR :resourceTypeName IS NULL ) ) " //
- + " ORDER BY p.name") //
+ + " ORDER BY p.name"), //
+
+ @NamedQuery(name = Plugin.QUERY_FIND_ALL_TO_PURGE, query = ""
+ + " SELECT new org.rhq.core.domain.plugin.Plugin( " //
+ + " p.id, "
+ + " p.name, "
+ + " p.path, "
+ + " p.displayName, "
+ + " p.enabled, "
+ + " p.status, "
+ + " p.description, "
+ + " p.help, "
+ + " p.md5, "
+ + " p.version, "
+ + " p.ampsVersion, "
+ + " p.ctime, "
+ + " p.mtime) "
+ + " FROM Plugin p "
+ + " WHERE p.ctime = -1 AND p.status = 'DELETED'"
+ ),
+
+ @NamedQuery(name = Plugin.PURGE_PLUGINS, query = ""
+ + " DELETE FROM Plugin p WHERE p IN (:plugins)")
})
@Entity
public class Plugin extends AbstractPlugin {
@@ -233,9 +255,13 @@ public class Plugin extends AbstractPlugin {
public static final String QUERY_FIND_ALL = "Plugin.findAll";
public static final String QUERY_FIND_ALL_INSTALLED = "Plugin.findAllInstalled";
public static final String QUERY_FIND_ALL_DELETED = "Plugin.findAllDeleted";
+ public static final String QUERY_FIND_ALL_TO_PURGE = "Plugin.findAllToPurge";
public static final String UPDATE_PLUGINS_ENABLED_BY_IDS = "Plugin.updatePluginsEnabledByIds";
public static final String QUERY_FIND_BY_RESOURCE_TYPE_AND_CATEGORY = "Plugin.findByResourceType";
public static final String UPDATE_PLUGIN_ENABLED_BY_ID = "Plugin.updatePluginEnabledById";
+ public static final String PURGE_PLUGINS = "Plugin.purgePlugins";
+
+ public static final long PURGED = -1;
public Plugin() {
super();
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
index 5eb3f93..10fc861 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/plugin/InstalledPluginsUIBean.java
@@ -221,6 +221,8 @@ public class InstalledPluginsUIBean {
}
pluginMgr.deletePlugins(subject, Arrays.asList(getSelectedPluginIds()));
+ PluginDeploymentScannerMBean scanner = LookupUtil.getPluginDeploymentScanner();
+ scanner.scanAndRegister();
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted plugins: " + pluginNames);
} catch (Exception e) {
processException("Failed to delete agent plugins", e);
@@ -368,14 +370,31 @@ public class InstalledPluginsUIBean {
return;
}
+ List<String> pluginsToDelete = new ArrayList<String>();
+ for (Plugin plugin : selectedPlugins) {
+ if (plugin.getStatus() != PluginStatusType.DELETED) {
+ pluginsToDelete.add(plugin.getName());
+ }
+ }
+
+ if (!pluginsToDelete.isEmpty()) {
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN, "Plugins must be deleted before they " +
+ "they can be purged. The following plugins must first be deleted: " + pluginsToDelete + ". No " +
+ "plugins were purged.");
+ return;
+ }
+
List<String> pluginNames = new ArrayList<String>();
for (Plugin plugin : selectedPlugins) {
pluginNames.add(plugin.getName());
}
Subject subject = EnterpriseFacesContextUtility.getSubject();
- pluginMgr.purgePlugins(subject, getIds(getSelectedAgentPlugins()));
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Purged server plugins: " + pluginNames);
+ pluginMgr.markPluginsForPurge(subject, getIds(getSelectedAgentPlugins()));
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Preparing to purge agent plugins: " +
+ pluginNames + ". This make take a few minutes since all type definitions from the plugins must " +
+ "first be purged from the system. The plugins will still be visible on this page until they have " +
+ "been purged.");
} catch (Exception e) {
processException("Failed to purge agent plugins", e);
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
index b5c0ac9..0799f70 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
@@ -384,6 +384,15 @@ public class StartupServlet extends HttpServlet {
log("Cannot schedule purge resource types job: " + e.getMessage());
}
+ try {
+ // Do not check until we are up at least 1 min, and every 5 minutes thereafter.
+ final long initialDelay = 1000L * 60;
+ final long interval = 1000L * 60 * 5;
+ scheduler.scheduleSimpleRepeatingJob(PurgePluginsJob.class, true, false, initialDelay, interval);
+ } catch (Exception e) {
+ log("Cannot schedule purge plugins job: " + e.getMessage());
+ }
+
// DynaGroup Auto-Recalculation Job
try {
// Do not check until we are up at least 1 min, and every minute thereafter.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBean.java
index 15193c6..b0ca65d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBean.java
@@ -31,12 +31,17 @@ import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.plugin.PluginStatusType;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.inventory.InventoryManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
@@ -70,6 +75,9 @@ public class PluginManagerBean implements PluginManagerLocal {
@EJB
private ResourceManagerLocal resourceMgr;
+ @EJB
+ private SubjectManagerLocal subjectMgr;
+
/**
* Returns the information on the given plugin as found in the database.
* @param name the name of a plugin
@@ -84,17 +92,30 @@ public class PluginManagerBean implements PluginManagerLocal {
}
@Override
- public void purgePlugins(Subject subject, List<Integer> pluginIds) throws Exception {
- deletePlugins(subject, pluginIds);
-
+ public void markPluginsForPurge(Subject subject, List<Integer> pluginIds) throws Exception {
for (Integer id : pluginIds) {
Plugin plugin = entityManager.find(Plugin.class, id);
- log.info("Purging [" + plugin + "] from the database");
- entityManager.remove(plugin);
+ plugin.setCtime(Plugin.PURGED);
+ log.info("Scheduling plugin [" + plugin + "] to be purged from the database.");
}
}
@Override
+ public boolean isReadyForPurge(Plugin plugin) {
+ ResourceTypeCriteria criteria = new ResourceTypeCriteria();
+ criteria.addFilterPluginName(plugin.getName());
+ criteria.setRestriction(Criteria.Restriction.COUNT_ONLY);
+ PageList results = resourceTypeMgr.findResourceTypesByCriteria(subjectMgr.getOverlord(), criteria);
+
+ return results.getTotalSize() == 0;
+ }
+
+ @Override
+ public void purgePlugins(List<Plugin> plugins) {
+ entityManager.createNamedQuery(Plugin.PURGE_PLUGINS).setParameter("plugins", plugins).executeUpdate();
+ }
+
+ @Override
public List<Plugin> getPlugins() {
return entityManager.createNamedQuery(Plugin.QUERY_FIND_ALL).getResultList();
}
@@ -110,6 +131,11 @@ public class PluginManagerBean implements PluginManagerLocal {
return entityManager.createNamedQuery(Plugin.QUERY_FIND_ALL_DELETED).getResultList();
}
+ @Override
+ public List<Plugin> findPluginsMarkedForPurge() {
+ return entityManager.createNamedQuery(Plugin.QUERY_FIND_ALL_TO_PURGE).getResultList();
+ }
+
@SuppressWarnings("unchecked")
public List<Plugin> getAllPluginsById(List<Integer> pluginIds) {
if (pluginIds == null || pluginIds.size() == 0) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerLocal.java
index 0a1ad1b..7ae1738 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginManagerLocal.java
@@ -36,8 +36,17 @@ public interface PluginManagerLocal {
*/
List<Plugin> getInstalledPlugins();
+ /**
+ * @return All plugins that have been marked deleted.
+ */
List<Plugin> findAllDeletedPlugins();
+
+ /**
+ * @return All plugins that are scheduled to be purged.
+ */
+ List<Plugin> findPluginsMarkedForPurge();
+
/**
* Returns a list of plugins with the specified ids. Both installed and deleted plugins will be included in the
* results.
@@ -69,17 +78,34 @@ public interface PluginManagerLocal {
void deletePlugins(Subject subject, List<Integer> pluginIds) throws Exception;
/**
- * Permanently removes the plugins with the specified ids from the database. This operation first calls
- * {@link #deletePlugins(Subject, List)} as a safeguard to ensure that the plugins are first deleted. In a HA
- * deployment however, you should wait at least 5 minutes after deleting a plugin before purging it. Five minutes
- * is the default interval of the agent plugin scanner. This should be sufficient time for servers in the cluster
- * to delete the plugin from the file system.
+ * Schedules a plugin to be purged. Purging a plugin permanently deletes it from the database. Purging is done
+ * asynchronously and will not happen until all resource types defined by the plugin have first been purged. Plugins
+ * must first be deleted before they can be purged. A plugin is considered a candidate for being purged if its
+ * status is set to <code>DELETED</code> and its <code>ctime</code> is set to {@link Plugin#PURGED}. This method
+ * does not flip the status of the plugins to <code>DELETED</code> since it assumes that has already been done. It
+ * only sets <code>ctime</code> to <code>PURGED</code>.
*
* @param subject The user purging the plugin
* @param pluginIds The ids of the plugins to be purged
* @throws Exception if an error occurs
+ * @see org.rhq.enterprise.server.scheduler.jobs.PurgePluginsJob PurgePluginsJob
+ */
+ void markPluginsForPurge(Subject subject, List<Integer> pluginIds) throws Exception;
+
+ /**
+ * @param plugin The plugin to check
+ * @return true if the plugin can be purged, false otherwise. A plugin can only be purged when all resource types
+ * defined by the plugin have already been purged.
+ */
+ boolean isReadyForPurge(Plugin plugin);
+
+ /**
+ * Permanently deletes the plugins from the database. This method assumes that the plugins are already in the
+ * deleted state. This method is not intended for general use. It is called from
+ * {@link org.rhq.enterprise.server.scheduler.jobs.PurgePluginsJob PurgePluginsJob}.
+ * @param plugins The plugins to remove from the database.
*/
- void purgePlugins(Subject subject, List<Integer> pluginIds) throws Exception;
+ void purgePlugins(List<Plugin> plugins);
void setPluginEnabledFlag(Subject subject, int pluginId, boolean enabled) throws Exception;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/PurgePluginsJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/PurgePluginsJob.java
new file mode 100644
index 0000000..79e49b7
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/PurgePluginsJob.java
@@ -0,0 +1,43 @@
+package org.rhq.enterprise.server.scheduler.jobs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import org.rhq.core.domain.plugin.Plugin;
+import org.rhq.enterprise.server.resource.metadata.PluginManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * This job purges plugins from the database asynchronously. It queries for plugins that are scheduled to be purged.
+ * A plugin is considered a candidate for purging when its status is <code>DELETED</code> and its <code>ctime</code>
+ * is set to {@link Plugin#PURGED}. A plugin is only purged when all of the resource types defined by the plugin have
+ * already been purged. Puring resource types is performed by {@link PurgeResourceTypesJob}.
+ */
+public class PurgePluginsJob extends AbstractStatefulJob {
+
+ private static final Log log = LogFactory.getLog(PurgePluginsJob.class);
+
+ @Override
+ public void executeJobCode(JobExecutionContext context) throws JobExecutionException {
+ PluginManagerLocal pluginMgr = LookupUtil.getPluginManager();
+ List<Plugin> plugins = pluginMgr.findPluginsMarkedForPurge();
+ List<Plugin> pluginsToPurge = new ArrayList<Plugin>();
+
+ for (Plugin plugin : plugins) {
+ if (pluginMgr.isReadyForPurge(plugin)) {
+ log.debug("Preparing to purge plugin [" + plugin.getName() + "]");
+ pluginsToPurge.add(plugin);
+ }
+ }
+
+ if (!pluginsToPurge.isEmpty()) {
+ pluginMgr.purgePlugins(pluginsToPurge);
+ log.debug("Purged " + pluginsToPurge.size() + " plugins");
+ }
+ }
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java
index 13b864c..a12d7a8 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/PluginManagerBeanTest.java
@@ -1,6 +1,5 @@
package org.rhq.enterprise.server.resource.metadata;
-import java.util.Arrays;
import java.util.List;
import javax.ejb.EJBException;
@@ -131,7 +130,7 @@ public class PluginManagerBeanTest extends MetadataBeanTest {
Plugin plugin2 = getPlugin("PluginManagerBeanTestPlugin2",
"Deleting a plugin should not remove it from the database");
- pluginMgr.purgePlugins(subjectMgr.getOverlord(), asList(plugin1.getId(), plugin2.getId()));
+ pluginMgr.markPluginsForPurge(subjectMgr.getOverlord(), asList(plugin1.getId(), plugin2.getId()));
assertEquals("Failed to purge plugins from the database", 1, pluginMgr.getPlugins().size());
}
commit 189da6b3f02c7b17c0fcb64193e67d0165281c3a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 17 16:14:21 2011 -0400
BZ 688000 - we cannot recurse over HashSet fields because HashSet$KeySet doesn't support addAll and thus the old code threw an UnsupportedOperationException.
need to convert the Set to a List so we can process each individual item, but then convert it back to a Set since that's the type of the real field.
diff --git a/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java b/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java
index e56f076..dcc6643 100644
--- a/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java
+++ b/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java
@@ -18,15 +18,6 @@
*/
package org.rhq.enterprise.server.util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.Hibernate;
-import org.hibernate.proxy.HibernateProxy;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlTransient;
-
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
@@ -43,9 +34,19 @@ import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.Hibernate;
+import org.hibernate.proxy.HibernateProxy;
+
/**
* @author Greg Hinkle
*/
+@SuppressWarnings("unchecked")
public class HibernateDetachUtility {
private static final Log LOG = LogFactory.getLog(HibernateDetachUtility.class);
@@ -67,7 +68,7 @@ public class HibernateDetachUtility {
}
private static void nullOutUninitializedFields(Object value, Set<Integer> nulledObjects, int depth,
- SerializationType serializationType) throws Exception {
+ SerializationType serializationType) throws Exception {
if (depth > 50) {
LOG.warn("Getting different object hierarchies back from calls: " + value.getClass().getName());
return;
@@ -87,7 +88,7 @@ public class HibernateDetachUtility {
} else if (value instanceof List) {
// Null out any entries in initialized collections
- ListIterator i = ((List)value).listIterator();
+ ListIterator i = ((List) value).listIterator();
while (i.hasNext()) {
Object val = i.next();
Object replace = replaceObject(val);
@@ -112,7 +113,7 @@ public class HibernateDetachUtility {
nullOutUninitializedFields(item, nulledObjects, depth + 1, serializationType);
}
collection.removeAll(itemsToBeReplaced);
- collection.addAll(replacementItems);
+ collection.addAll(replacementItems); // watch out! if this collection is a Set, HashMap$MapSet doesn't support addAll. See BZ 688000
} else if (value instanceof Map) {
for (Object key : ((Map) value).keySet()) {
nullOutUninitializedFields(((Map) value).get(key), nulledObjects, depth + 1, serializationType);
@@ -123,26 +124,21 @@ public class HibernateDetachUtility {
return;
}
-
if (serializationType == SerializationType.JAXB) {
XmlAccessorType at = value.getClass().getAnnotation(XmlAccessorType.class);
if (at != null && at.value() == XmlAccessType.FIELD) {
- //System.out.println("----------XML--------- field access");
nullOutFieldsByFieldAccess(value, nulledObjects, depth, serializationType);
} else {
- //System.out.println("----------XML--------- accessor access");
nullOutFieldsByAccessors(value, nulledObjects, depth, serializationType);
}
} else if (serializationType == SerializationType.SERIALIZATION) {
- // System.out.println("-----------JRMP-------- field access");
nullOutFieldsByFieldAccess(value, nulledObjects, depth, serializationType);
}
}
private static void nullOutFieldsByFieldAccess(Object object, Set<Integer> nulledObjects, int depth,
- SerializationType serializationType) throws Exception {
-
+ SerializationType serializationType) throws Exception {
Class tmpClass = object.getClass();
List<Field> fieldsToClean = new ArrayList<Field>();
@@ -154,10 +150,8 @@ public class HibernateDetachUtility {
nullOutFieldsByFieldAccess(object, fieldsToClean, nulledObjects, depth, serializationType);
}
-
- @SuppressWarnings("unchecked")
- private static void nullOutFieldsByFieldAccess(Object object, List<Field> classFields, Set<Integer> nulledObjects, int depth,
- SerializationType serializationType) throws Exception {
+ private static void nullOutFieldsByFieldAccess(Object object, List<Field> classFields, Set<Integer> nulledObjects,
+ int depth, SerializationType serializationType) throws Exception {
boolean accessModifierFlag = false;
for (Field field : classFields) {
@@ -189,7 +183,7 @@ public class HibernateDetachUtility {
replacement = null;
}
} catch (Exception e) {
- System.out.println("Unable to write replace object " + fieldValue.getClass());
+ LOG.error("Unable to write replace object " + fieldValue.getClass(), e);
}
}
@@ -197,12 +191,13 @@ public class HibernateDetachUtility {
String className = ((HibernateProxy) fieldValue).getHibernateLazyInitializer().getEntityName();
Class clazz = Class.forName(className);
- Class[] constArgs = {Integer.class};
+ Class[] constArgs = { Integer.class };
Constructor construct = null;
try {
construct = clazz.getConstructor(constArgs);
- replacement = construct.newInstance((Integer) ((HibernateProxy) fieldValue).getHibernateLazyInitializer().getIdentifier());
+ replacement = construct.newInstance((Integer) ((HibernateProxy) fieldValue)
+ .getHibernateLazyInitializer().getIdentifier());
field.set(object, replacement);
} catch (NoSuchMethodException nsme) {
@@ -214,17 +209,17 @@ public class HibernateDetachUtility {
if (!idField.isAccessible()) {
idField.setAccessible(true);
}
- idField.set(replacement, (Integer) ((HibernateProxy) fieldValue).getHibernateLazyInitializer().getIdentifier());
+ idField.set(replacement, (Integer) ((HibernateProxy) fieldValue)
+ .getHibernateLazyInitializer().getIdentifier());
} catch (Exception e) {
e.printStackTrace();
- System.out.println("No id constructor and unable to set field id for base bean " + className);
+ LOG.error("No id constructor and unable to set field id for base bean " + className, e);
}
field.set(object, replacement);
}
}
-
} else {
if (fieldValue instanceof org.hibernate.collection.PersistentCollection) {
// Replace hibernate specific collection types
@@ -234,26 +229,30 @@ public class HibernateDetachUtility {
} else {
Object replacement = null;
+ boolean needToNullOutFields = true; // needed for BZ 688000
if (fieldValue instanceof Map) {
replacement = new HashMap((Map) fieldValue);
} else if (fieldValue instanceof List) {
replacement = new ArrayList((List) fieldValue);
} else if (fieldValue instanceof Set) {
- replacement = new HashSet((Set) fieldValue);
+ ArrayList l = new ArrayList((Set) fieldValue); // cannot recurse Sets, see BZ 688000
+ nullOutUninitializedFields(l, nulledObjects, depth + 1, serializationType);
+ replacement = new HashSet(l); // convert it back to a Set since that's the type of the real collection, see BZ 688000
+ needToNullOutFields = false;
} else if (fieldValue instanceof Collection) {
replacement = new ArrayList((Collection) fieldValue);
}
setField(object, field.getName(), replacement);
- nullOutUninitializedFields(replacement, nulledObjects, depth + 1, serializationType);
+ if (needToNullOutFields) {
+ nullOutUninitializedFields(replacement, nulledObjects, depth + 1, serializationType);
+ }
}
} else {
- if (fieldValue != null &&
- (fieldValue.getClass().getName().contains("org.rhq") ||
- fieldValue instanceof Collection ||
- fieldValue instanceof Object[] ||
- fieldValue instanceof Map))
+ if (fieldValue != null
+ && (fieldValue.getClass().getName().contains("org.rhq") || fieldValue instanceof Collection
+ || fieldValue instanceof Object[] || fieldValue instanceof Map))
nullOutUninitializedFields((fieldValue), nulledObjects, depth + 1, serializationType);
}
}
@@ -264,7 +263,6 @@ public class HibernateDetachUtility {
}
-
private static Object replaceObject(Object object) {
Object replacement = null;
@@ -277,16 +275,15 @@ public class HibernateDetachUtility {
String className = object.getClass().getName();
} catch (Exception e) {
- System.out.println("Unable to write replace object " + object.getClass());
+ LOG.error("Unable to write replace object " + object.getClass(), e);
}
}
}
return replacement;
}
-
private static void nullOutFieldsByAccessors(Object value, Set<Integer> nulledObjects, int depth,
- SerializationType serializationType) throws Exception {
+ SerializationType serializationType) throws Exception {
// Null out any collections that aren't loaded
BeanInfo bi = Introspector.getBeanInfo(value.getClass(), Object.class);
@@ -309,18 +306,18 @@ public class HibernateDetachUtility {
Method writeMethod = pd.getWriteMethod();
if ((writeMethod != null) && (writeMethod.getAnnotation(XmlTransient.class) == null)) {
- pd.getWriteMethod().invoke(value, new Object[]{null});
+ pd.getWriteMethod().invoke(value, new Object[] { null });
} else {
nullOutField(value, pd.getName());
}
} catch (Exception lie) {
LOG.debug("Couldn't null out: " + pd.getName() + " off of " + value.getClass().getSimpleName()
- + " trying field access", lie);
+ + " trying field access", lie);
nullOutField(value, pd.getName());
}
} else {
if ((propertyValue instanceof Collection)
- || ((propertyValue != null) && propertyValue.getClass().getName().startsWith("org.rhq.core.domain"))) {
+ || ((propertyValue != null) && propertyValue.getClass().getName().startsWith("org.rhq.core.domain"))) {
nullOutUninitializedFields(propertyValue, nulledObjects, depth + 1, serializationType);
}
}
commit 88c4388fd80b226f34826153fe21c7cbb56f676e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 17 14:42:40 2011 -0400
initial commit of TestLdapSetting dev-tool for setup/debug of LDAP-RHQ integrations
diff --git a/etc/dev-utils/TestLdapSettings.java b/etc/dev-utils/TestLdapSettings.java
new file mode 100644
index 0000000..4df79dc
--- /dev/null
+++ b/etc/dev-utils/TestLdapSettings.java
@@ -0,0 +1,640 @@
+package com.test;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.InitialLdapContext;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.border.LineBorder;
+import javax.swing.border.TitledBorder;
+
+//import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
+
+/* Is a development test tool that allows the user to simulate the RHQ server side
+ * LDAP calls during auth/authz operations.
+ *
+ * @author Simeon Pinder
+ */
+public class TestLdapSettings extends JFrame {
+ //shared fields
+ private JTextArea testResults;
+ private JCheckBox ssl;
+ private JTextField testUserNameValue;
+ private JTextField testUserPasswordValue;
+ private HashMap<String, JTextField> fieldMappings;
+ private String[] keys;
+ private JCheckBox enableLdapReferral;
+ private JCheckBox enableVerboseDebugging;
+ private JCheckBox enableVerboseGroupParsing;
+ private String advdb = "**Verbose:debug ----";
+
+ private static final long serialVersionUID = 1L;
+ int textBoxWidth = 20;
+
+ public static void main(String args[]) {
+ new TestLdapSettings();
+ }
+
+ // Configure window properties
+ private TestLdapSettings() {
+
+ setTitle("Check LDAP Settings: Simulates LDAP checks/queries of RHQ LDAP integration");
+ getContentPane().setLayout(new BorderLayout());
+ // top panel definition
+ JPanel top = new JPanel();
+ top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS));
+ top.setBorder(LineBorder.createGrayLineBorder());
+ keys = new String[] { "URL:", "Search Filter:",
+ "Search Base:","Login Property",
+ "Username:", "Group Search Filter:",
+ "Password:", "Group Member Filter:",
+ };
+ fieldMappings = loadUiFields(top, keys);
+
+ //add the two checkboxes for additiona debugging options
+ enableLdapReferral= new JCheckBox("[follow] ldap referrals");
+ enableLdapReferral.setSelected(false);
+ enableVerboseDebugging= new JCheckBox("more verbose logging");
+ enableVerboseDebugging.setSelected(false);
+ enableVerboseGroupParsing= new JCheckBox("more detailed group parsing");
+ enableVerboseGroupParsing.setSelected(false);
+ //put into row display
+ JPanel advancedDebugRegion = new JPanel();
+ advancedDebugRegion.setLayout(new FlowLayout(FlowLayout.LEFT));
+ LineBorder advancedBorder = new LineBorder(Color.BLACK, 2);
+ TitledBorder debugBorder = new TitledBorder(advancedBorder, "Debug:");
+ advancedDebugRegion.setBorder(debugBorder);
+ advancedDebugRegion.add(enableLdapReferral);
+ advancedDebugRegion.add(enableVerboseDebugging);
+ advancedDebugRegion.add(enableVerboseGroupParsing);
+ top.add(advancedDebugRegion);
+
+ ssl = new JCheckBox("SSL:");
+ ssl.setEnabled(false);
+ top.add(ssl);
+ // test user auth region
+ JPanel testUserRegion = new JPanel();
+ testUserRegion.setLayout(new FlowLayout(FlowLayout.LEFT));
+ LineBorder border = new LineBorder(Color.BLUE, 2);
+ TitledBorder tBorder = new TitledBorder(border, "Authentication/Authorization Check Credentials: (insert valid ldap user assigned to group)");
+ testUserRegion.setBorder(tBorder);
+ JLabel testUserName = new JLabel("Test UserName:");
+ testUserNameValue = new JTextField(textBoxWidth);
+ JLabel testUserPassword = new JLabel("Test Password:");
+ testUserPasswordValue = new JTextField(textBoxWidth);
+ testUserRegion.add(testUserName);
+ testUserRegion.add(testUserNameValue);
+ testUserRegion.add(testUserPassword);
+ testUserRegion.add(testUserPasswordValue);
+ top.add(testUserRegion);
+
+ // center
+ JPanel center = new JPanel();
+ center.setLayout(new BoxLayout(center, BoxLayout.X_AXIS));
+ // build center panel
+ buildCenterPanel(center);
+
+ // final component layout
+ getContentPane().add(top, BorderLayout.NORTH);
+ getContentPane().add(center, BorderLayout.CENTER);
+ this.setSize(720, 700);
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ setVisible(true);
+ }
+
+ // define the center display panel.
+ private void buildCenterPanel(JPanel center) {
+ // First element is Test Button
+ JButton test = new JButton("Test Settings");
+ center.add(test);
+ // second is large text box that display ldap queries
+ testResults = new JTextArea("(click button to test settings values: simulates 4 separate checks showing ldap filters used)",
+ 40, 40);
+ JScrollPane jsp = new JScrollPane(testResults);
+ center.add(jsp);
+ test.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ testResults.setText("");//clear out empty msg
+ //trim spaces from all fields
+ String ldapServer = fieldMappings.get(keys[0]).getText().trim();
+ String searchFilter = fieldMappings.get(keys[1]).getText().trim();
+ String searchBase = fieldMappings.get(keys[2]).getText().trim();
+ String loginProperty = fieldMappings.get(keys[3]).getText().trim();
+ String bindUserName = fieldMappings.get(keys[4]).getText().trim();
+ String groupSearchFilter = fieldMappings.get(keys[5]).getText().trim();
+ String bindPassword = fieldMappings.get(keys[6]).getText().trim();
+ String groupMemberFilter = fieldMappings.get(keys[7]).getText().trim();
+ String testUserName = testUserNameValue.getText().trim();
+ String testUserPassword = testUserPasswordValue.getText().trim();
+ // validate initial required elements
+ String msg = null;
+ boolean proceed = true;
+ //valid required details set.
+ if (ldapServer.isEmpty() || bindUserName.isEmpty()
+ || bindPassword.isEmpty() || searchBase.isEmpty()) {
+ msg ="STEP-1:FAIL: "+ keys[0] + ", " + keys[2] + ", " + keys[4] + ", "
+ + keys[6] + " cannot be empty to proceed.";
+ log(msg);
+ proceed = false;
+ }
+ Properties env;
+ InitialLdapContext ctx = null;
+ if (proceed) {// attempt initial ldap bind from RHQ server
+ msg = "STEP-1:TESTING: Attempting to bind to server:" + ldapServer
+ + "\n with user '" + bindUserName
+ + "' and password entered.";
+ log(msg);
+ env = getProperties(ldapServer);
+ env.setProperty(Context.SECURITY_PRINCIPAL, bindUserName);
+ env.setProperty(Context.SECURITY_CREDENTIALS, bindPassword);
+ env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
+ try {
+ ctx = new InitialLdapContext(env, null);
+ msg = "STEP-1:PASS: LDAP bind credentials are correct. Successfully connected to '"
+ + ldapServer
+ + "'.\n This means the LDAP Bind credentials for the RHQ Server authentication/authorization requests to ldap server "
+ + "are correct.";
+ if(enableVerboseDebugging.isSelected()){
+ msg+="\n"+advdb+" LDAP simple authentication bind successful.";
+ }
+ log(msg);
+ proceed = true;
+ } catch (Exception ex) {
+ msg = "STEP-1:FAIL: Unable to connect to the LDAP server with credentials specified.\n";
+ msg+="Exception:"+ex.getMessage();
+ if(enableVerboseDebugging.isSelected()){
+ msg = appendStacktraceToMsg(msg, ex);
+ }
+ log(msg);
+ proceed = false;
+ }
+ }
+ if (proceed) {// retrieve test credentials to test run auth
+ // load search controls
+ SearchControls searchControls = getSearchControls();
+ // validating searchFilter and test user/pass creds
+ proceed = true;
+ if (testUserName.isEmpty() || (testUserPassword.isEmpty())) {
+ msg = "STEP-2:FAIL: Test Username/Password fields cannot be empty for this step.";
+ log(msg);
+ proceed = false;
+ }
+ // testing a valid user involves a filtered ldap search
+ // using the loginProperty, and optionally searchFilter
+ String userDN = "";
+ if (proceed) {
+ // default loginProperty to cn if it's not set
+ if (loginProperty.isEmpty()) {
+ loginProperty = "cn";
+ if(enableVerboseDebugging.isSelected()){
+ String mesg = "As you have not specified a login property, defaulting to 'cn'";
+ log(advdb+" "+msg);
+ }
+ }
+ String filter;
+ if (!searchFilter.isEmpty()) {
+ filter = "(&(" + loginProperty + "=" + testUserName
+ + ")" + "(" + searchFilter + "))";
+ } else {
+ filter = "(" + loginProperty + "=" + testUserName
+ + ")";
+ }
+ if(enableVerboseDebugging.isSelected()){
+ log(advdb+" The searchfilter is optionally appended to login property for additional shared attribute across users.");
+ }
+ msg = "STEP-2:TESTING: To validate the test user the following LDAP filtered component will be used to find matching users:\n";
+ msg += filter;
+ log(msg);
+ // test out the search on the target ldap server
+ try {
+ String[] baseDNs = searchBase.split(";");
+ for (int x = 0; x < baseDNs.length; x++) {
+ NamingEnumeration answer = ctx.search(
+ baseDNs[x], filter, searchControls);
+ if(enableVerboseDebugging.isSelected()){
+ log(advdb+" this search was excuted against DN component '"+baseDNs[x]+"'.");
+ }
+ // boolean ldapApiNpeFound = false;
+ if (!answer.hasMoreElements()) {
+ msg="STEP-2:WARN Unable to locate a matching users for the filter'"+filter+
+ "'. Please check your loginProperty. Usually 'cn' or 'uid'";
+ log(msg);
+ continue;
+ }
+ // Going with the first match
+ SearchResult si = (SearchResult) answer.next();
+
+ // Construct the UserDN
+ userDN = si.getName() + "," + baseDNs[x];
+ msg = "STEP-2:PASS: The test user '"
+ + testUserName
+ + "' was succesfully located, and the following userDN will be used in authorization check:\n";
+ msg += userDN;
+ log(msg);
+
+ ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN);
+ ctx.addToEnvironment(Context.SECURITY_CREDENTIALS,testUserPassword);
+ ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION,"simple");
+
+ // if successful then verified that user and pw
+ // are valid ldap credentials
+ ctx.reconnect(null);
+ msg = "STEP-2:PASS: The user '"
+ + testUserName
+ + "' was succesfully authenticated using userDN '"
+ + userDN + "' and password provided.\n"
+ +"*Note: the loginProperty must match the loginProperty listed in dn: for the user. It is the DN that RHQ will lookup and use.";
+ log(msg);
+ }
+ } catch (Exception ex) {
+ msg = "STEP-2:FAIL: There was an error while searching for or authenticating the user '"
+ + testUserName + "'\n";
+ msg += ex.getMessage();
+ if(enableVerboseDebugging.isSelected()){
+ msg = appendStacktraceToMsg(msg, ex);
+ }
+ log(msg);
+ proceed=false;
+ }
+ }
+ // with authentication completed, now check authorization.
+ // validate filter components to list all available groups
+ proceed = false;
+ if (!groupSearchFilter.isEmpty()) {
+ Set<Map<String, String>> ret = new HashSet<Map<String, String>>();
+ String filter = String
+ .format("(%s)", groupSearchFilter);
+ msg = "STEP-3:TESTING: This ldap filter "
+ + filter
+ + " will be used to locate ALL available LDAP groups";
+ log(msg);
+ try {
+ String[] baseDNs = searchBase.split(";");
+ for (int x = 0; x < baseDNs.length; x++) {
+ if(enableVerboseDebugging.isSelected()){
+ log(advdb+" this search was excuted against DN component '"+baseDNs[x]+"'.");
+ }
+ NamingEnumeration answer = ctx.search(
+ baseDNs[x], filter, searchControls);
+
+ if(enableVerboseGroupParsing.isSelected()){//in this mode report initial state of Enumeration results
+ log(advdb+" LDAP Group Search/Enumeration found "+((answer.hasMore())? " SOME ":" NO ")+" matching group(s).");
+ }
+
+ boolean ldapApiEnumerationBugEncountered = false;
+ while ((!ldapApiEnumerationBugEncountered)
+ && answer.hasMoreElements()) {
+ // We use the first match
+ SearchResult si = null;
+ try {
+ si = (SearchResult) answer.next();
+ } catch (NullPointerException npe) {
+ if(enableVerboseDebugging.isSelected()){
+ log(advdb+" NullPtr exception detected. If known LDAP api enum npe ignore: "+npe.getMessage()+".");
+ }
+ ldapApiEnumerationBugEncountered = true;
+ break;
+ }
+ Map<String, String> entry = new HashMap<String, String>();
+ if(enableVerboseDebugging.isSelected()||enableVerboseGroupParsing.isSelected()){
+ Attributes attributeContainer = si.getAttributes();
+ NamingEnumeration<? extends Attribute> attributes = attributeContainer.getAll();
+ String attributesReturned = " ";
+ while(attributes.hasMore()){
+ attributesReturned+=attributes.next().getID()+",";
+ }
+ String dbugMesg="\n"+advdb+" Group search LDAP ("+attributeContainer.size()+") attributes located for group '"+si.getName()+"' are ["+
+ attributesReturned.substring(0, attributesReturned.length()-1)+"].";
+ //directly update here to shorten messages for lots of groups
+ testResults.setText(testResults.getText() + dbugMesg);
+
+ //additionally parse attribute ids and values for illegal ldap characters
+ if(enableVerboseGroupParsing.isSelected()){
+ attributes = attributeContainer.getAll();
+ String currentAttributeId ="";
+ String currentValue ="";
+ //spinder: 3/17/11: should we bail on first bad data or display them all?
+ while(attributes.hasMore()){
+ boolean badData = false;
+ Attribute att = attributes.next();
+ currentAttributeId =att.getID();
+ if(containsIllegalLdap(currentAttributeId)){
+ log(advdb+" LDAP Group: bad atrribute data detected for group '"+si.getName()+"' for attribute '"+currentAttributeId+"'.");
+ badData=true;
+ }
+ if(att.getAll()!=null){
+ NamingEnumeration<?> enumer = att.getAll();
+ while(enumer.hasMore()){
+ currentValue = enumer.next()+"";
+ if(containsIllegalLdap(currentValue)){
+ log(advdb+" LDAP Group: bad data detected for group '"+si.getName()+"' with attribute '"+currentAttributeId+"' and value:"+currentValue);
+ badData=true;
+ }
+ }
+ }
+ if(badData){
+ log(advdb+"** LDAP Group: Some bad LDAP data detected for group '"+si.getName()+"'.");
+ }
+ }
+ }
+ }
+
+ Attribute commonNameAttr = si.getAttributes()
+ .get("cn");
+ if(commonNameAttr!=null){
+ String name = (String) commonNameAttr.get();
+ name = name.trim();
+ Attribute desc = si.getAttributes().get(
+ "description");
+ String description = desc != null ? (String) desc
+ .get()
+ : "";
+ description = description.trim();
+ entry.put("id", name);
+ entry.put("name", name);
+ entry.put("description", description);
+ ret.add(entry);
+ }else{//unable to retrieve details for specific group.
+ log(advdb+" There was an error retrieving 'cn' attribute for group '"+si.getName()+"'. Not adding to returned list of groups. ");
+ }
+ }
+ }
+ msg = "STEP-3:TESTING: Using Group Search Filter '" + filter
+ + "', " + ret.size()
+ + " ldap group(s) were located.\n";
+ if (ret.size() > 0) {
+ HashMap<String, String>[] ldapLists = new HashMap[ret.size()];
+ ret.toArray(ldapLists);
+ if(enableVerboseGroupParsing.isSelected()){//in this mode go beyond the first ten results.
+ msg += "STEP-3:PASS: Listing 'all' of the ldap groups located: \n";
+ for (int i = 0; i < ret.size(); i++) {
+ msg += ldapLists[i] + "\n";
+ }
+ }else{//otherwise only show first 10[subset of available groups]
+ msg += "STEP-3:PASS: Listing a few(<=10) of the ldap groups located: \n";
+ for (int i = 0; (i < ret.size() && i < 10); i++) {
+ msg += ldapLists[i] + "\n";
+ }
+ }
+ proceed = true;// then can proceed to next step.
+ }
+ log(msg);
+ } catch (Exception ex) {
+ msg = "STEP-3:FAIL: There was an error searching with the groupFilter supplied: "
+ + groupSearchFilter + "'\n";
+ msg += ex.getMessage();
+ if(enableVerboseDebugging.isSelected()){
+ msg = appendStacktraceToMsg(msg, ex);
+ }
+ log(msg);
+ proceed=false;
+ }
+ } else {
+ msg = "STEP-3:FAIL: Group Search Filter: cannot be empty to proceed.";
+ log(msg);
+ proceed=false;
+ }
+ // retrieve lists of authorized groups available for the
+ if (proceed) {
+ // check groupMember
+ if (!groupMemberFilter.isEmpty()) {
+ Set<Map<String, String>> ret = new HashSet<Map<String, String>>();
+ String filter = String.format("(&(%s)(%s=%s))",
+ groupSearchFilter, groupMemberFilter,
+ userDN);
+ msg = "STEP-4:TESTING: about to do ldap search with filter \n'"
+ + filter
+ + "'\n to locate groups that test user IS authorized to access.";
+ log(msg);
+ try {
+ String[] baseDNs = searchBase.split(";");
+ for (int x = 0; x < baseDNs.length; x++) {
+ NamingEnumeration answer = ctx.search(
+ baseDNs[x], filter, searchControls);
+ boolean ldapApiEnumerationBugEncountered = false;
+ //BZ:582471- ldap api bug change
+ while ((!ldapApiEnumerationBugEncountered)
+ && answer.hasMoreElements()) {
+ // We use the first match
+ SearchResult si = null;
+ try {
+ si = (SearchResult) answer.next();
+ } catch (NullPointerException npe) {
+ ldapApiEnumerationBugEncountered = true;
+ break;
+ }
+ Map<String, String> entry = new HashMap<String, String>();
+ String name = (String) si
+ .getAttributes().get("cn")
+ .get();
+ name = name.trim();
+ Attribute desc = si.getAttributes()
+ .get("description");
+ String description = desc != null ? (String) desc
+ .get()
+ : "";
+ description = description.trim();
+ entry.put("id", name);
+ entry.put("name", name);
+ entry.put("description", description);
+ ret.add(entry);
+ }
+ }
+ msg = "STEP-4:TESTING: Using Group Search Filter '"
+ + filter + "', " + ret.size()
+ + " ldap group(s) were located.\n";
+ if (ret.size() > 0) {
+ HashMap<String, String>[] ldapLists = new HashMap[ret
+ .size()];
+ ret.toArray(ldapLists);
+ msg += "STEP-4:PASS: Listing a few of the ldap groups located: \n";
+ // iterate over first ten or less to demonstrate retrieve
+ for (int i = 0; (i < ret.size() && i < 10); i++) {
+ msg += ldapLists[i] + "\n";
+ }
+ proceed = true;// then can proceed to next
+ // step.
+ }else{
+ msg+="STEP-4:WARN: With current settings, test user is not authorized for any groups. Is this correct?";
+ }
+ log(msg);
+ } catch (Exception ex) {
+ msg = "STEP-4:FAIL: There was an error searching with the groupFilter supplied: "
+ + groupSearchFilter + "'\n";
+ msg += ex.getMessage();
+ if(enableVerboseDebugging.isSelected()){
+ msg = appendStacktraceToMsg(msg, ex);
+ }
+ log(msg);
+ proceed=false;
+ }
+
+ } else {
+ msg = "STEP-4:FAIL: Group Member Filter must be non-empty to proceed with simulating authorization check for test user.";
+ log(msg);
+ }
+ }
+ if(proceed){
+ msg="COMPLETED:PASS: The current settings, for successful steps, should be correct to enter into your RHQ server.";
+ msg+="\n\n\n\n When you encounter failures, warnings or other unexpected results you should use an external ";
+ msg+="LDAP search utility to check that the generated filters return the expected LDAP results.";
+ log(msg);
+ }
+ }
+ }
+
+ private boolean containsIllegalLdap(String currentValue) {
+ boolean invalidData = false;
+ if((currentValue!=null)&&(!currentValue.trim().isEmpty())){
+ //TODO: spinder 3/17/11: need to figure out regex to filter/detect bad data in returned ldap. Giving up for now.
+// String regex = "(?<=(?:[^\\]|^)(\\\\)+|[^\\]|^)[/,+\"><;=#]|(?<=(?:[^\\]|^)(\\\\)+|[^\\]|^)\\(?!\\|[/,+\"><;=#]| $|(?<=^\\) )|^";
+// regex = "(?<=(?:[^\\\\]|^)(\\\\\\\\)+|[^\\\\]|^)[/,+\\\"><;=#]|(?<=(?:[^\\\\]|^)(\\\\\\\\)+|[^\\\\]|^)\\\\(?!\\\\|[/,+\\\"><;=#]| $|(?<=^\\\\) )|^";
+// System.out.println("++++++++ CURR VAL:"+currentValue+":INV-CHeck:"+currentValue.matches(",+\"\\<;\n=/")+":NEWCHECK:"+(currentValue.matches(regex)));
+// if(currentValue.matches(",+\"\\<;\n=/")){
+// invalidData=true;
+// }
+// String badList = ",+\"\\<;\n=";
+ String badList = "+\"\\<;\n";
+ for(char car :currentValue.toCharArray()){
+ for(char c :badList.toCharArray()){
+ if(car == c){
+ invalidData=true;
+ }
+ }
+ }
+
+ }
+ return invalidData;
+ }
+
+ private String appendStacktraceToMsg(String msg, Exception ex) {
+ String moreVerbose = "";
+ moreVerbose+=advdb+" Exception type:"+ex.getClass()+"\n";
+ moreVerbose+=advdb+" Exception stack trace reference:"+ex.getStackTrace()+"\n";
+ if(ex.getStackTrace()!=null){
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ ex.printStackTrace(pw);
+ moreVerbose+=advdb+" stack trace reference:"+sw.toString();
+ }
+ msg+="\n"+moreVerbose;
+ return msg;
+ }
+ });
+ }
+
+ // throw the label and fields together, two to a row.
+ private HashMap<String, JTextField> loadUiFields(JPanel top,
+ String[] componentKeys) {
+ HashMap<String, JTextField> mappings = new HashMap<String, JTextField>();
+ for (int i = 0; i < componentKeys.length; i++) {
+ String firstLabelKey = componentKeys[i];
+ String secondLabelKey = componentKeys[++i];
+ // locate second key
+ JPanel row = new JPanel();
+ row.setLayout(new FlowLayout(FlowLayout.LEFT));
+ JLabel label1 = new JLabel(firstLabelKey);
+ label1.setSize(textBoxWidth, 5);
+ JTextField value1 = new JTextField(textBoxWidth);
+ JLabel label2 = new JLabel(secondLabelKey);
+ JTextField value2 = new JTextField(textBoxWidth);
+ row.add(label1);
+ row.add(value1);
+ row.add(Box.createRigidArea(new Dimension(0, 5)));
+ row.add(label2);
+ row.add(value2);
+ mappings.put(firstLabelKey, value1);
+ mappings.put(secondLabelKey, value2);
+ top.add(row);
+ }
+
+ return mappings;
+ }
+
+ private Properties getProperties(String contentProvider) {
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ "com.sun.jndi.ldap.LdapCtxFactory");
+ env.setProperty(Context.PROVIDER_URL, contentProvider);
+ if(!enableLdapReferral.isSelected()){
+ env.setProperty(Context.REFERRAL, "ignore");
+ }else{
+ String msg="**---- You have chosen to tell LDAP servers to [FOLLOW] context referrals. Default is [IGNORE] referrals. --**";
+ log(msg);
+ env.setProperty(Context.REFERRAL, "follow");
+ }
+
+// // Setup SSL if requested
+// String protocol = ssl.isSelected()? "ssl":"";
+// if ((protocol != null) && protocol.equals("ssl")) {
+// String ldapSocketFactory = env
+// .getProperty("java.naming.ldap.factory.socket");
+// if (ldapSocketFactory == null) {
+// env.put("java.naming.ldap.factory.socket",
+// UntrustedSSLSocketFactory.class.getName());
+// }
+// env.put(Context.SECURITY_PROTOCOL, "ssl");
+// }
+
+ return env;
+ }
+
+ private String delineate() {
+ String line = "-";
+ for (int i = 0; i < 30; i++) {
+ line += "-";
+ }
+ return line;
+ }
+
+ private void log(String msg) {
+ String message = "\n" + delineate() + "\n";
+ message += msg;
+ message += "\n" + delineate() + "\n\n";
+ testResults.setText(testResults.getText() + message);
+ }
+
+ private SearchControls getSearchControls() {
+ int scope = SearchControls.SUBTREE_SCOPE;
+ int timeLimit = 0;
+ long countLimit = 0;
+ String[] returnedAttributes = null;
+ boolean returnObject = false;
+ boolean deference = false;
+ SearchControls constraints = new SearchControls(scope, countLimit,
+ timeLimit, returnedAttributes, returnObject, deference);
+ return constraints;
+ }
+}
commit bee528cb2c27de06c50a3bb0e8cf23513d715702
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 17 14:42:03 2011 -0400
some missing documentation.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
index 6ccd6af..8ebfed5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
@@ -1,3 +1,21 @@
+/*
+ * 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.alert;
import com.allen_sauer.gwt.log.client.Log;
@@ -22,6 +40,11 @@ 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.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
+/** Customize the AlertDataSource to pull fetch criteria information from
+ * the Configuration object passed in.
+ *
+ * @author Simeon
+ */
public class AlertPortletConfigurationDataSource extends AlertDataSource {
//configuration attributes
private Integer[] alertFilterResourceIds = {};
commit 33af4dd34bfda0276352a7824e2b03fbb357abd9
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 17 10:39:01 2011 -0400
fixing small alert icon method in ImageManager to be consistent with other subsystems.
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 43f0f69..f30c23b 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_LOW_16.png";
+ return "subsystems/alert/Flag_blue_16.png";
}
public static String getAlertLargeIcon() {
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Flag_blue_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Flag_blue_16.png
new file mode 100644
index 0000000..f7f04b3
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/alert/Flag_blue_16.png differ
commit 97f2a0a2c31661bf07b140b95143b586ffd3b0d6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Mar 17 14:21:19 2011 -0400
config editor now throws a prop changed event at init if one or more props have invalid values (most commonly this happens when the props have a non-null erroMessage field)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
index 15ca21f..5e83850 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
@@ -22,7 +22,6 @@ package org.rhq.enterprise.gui.coregui.client.admin;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.IButton;
@@ -204,8 +203,8 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
@Override
public void propertyValueChanged(PropertyValueChangeEvent event) {
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (event.isInvalidPropertySetChanged()) {
+ Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 5f4c47e..9d1c1ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.EnumSet;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -56,7 +57,6 @@ import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.FloatItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.HeaderItem;
import com.smartgwt.client.widgets.form.fields.IntegerItem;
import com.smartgwt.client.widgets.form.fields.PasswordItem;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
@@ -72,7 +72,6 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.form.validator.CustomValidator;
import com.smartgwt.client.widgets.form.validator.FloatRangeValidator;
import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
-import com.smartgwt.client.widgets.form.validator.IsBooleanValidator;
import com.smartgwt.client.widgets.form.validator.IsFloatValidator;
import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
@@ -162,7 +161,7 @@ public class ConfigurationEditor extends LocatableVLayout {
private String editorTitle = null;
private boolean readOnly = false;
- private Set<String> invalidPropertyNames = new HashSet<String>();
+ private Map<String, String> invalidPropertyNameToDisplayNameMap = new HashMap<String, String>();
private Set<PropertyValueChangeListener> propertyValueChangeListeners = new HashSet<PropertyValueChangeListener>();
public static enum ConfigType {
@@ -246,11 +245,11 @@ public class ConfigurationEditor extends LocatableVLayout {
}
public boolean validate() {
- return this.topLevelPropertiesValuesManager.validate();
+ return (this.topLevelPropertiesValuesManager.validate());
}
public boolean isValid() {
- return this.topLevelPropertiesValuesManager.hasErrors();
+ return (!this.topLevelPropertiesValuesManager.hasErrors());
}
public void addPropertyValueChangeListener(PropertyValueChangeListener propertyValueChangeListener) {
@@ -397,6 +396,7 @@ public class ConfigurationEditor extends LocatableVLayout {
DynamicForm form = buildPropertiesForm(layout.extendLocatorId("Props"), propertyDefinitions, configuration);
form.setBorder("1px solid #AAA");
+ form.validate();
layout.addMember(form);
} else {
// One or more prop groups, so create a section stack with one section per group.
@@ -421,9 +421,27 @@ public class ConfigurationEditor extends LocatableVLayout {
layout.addMember(sectionStack);
}
+ fireInitialPropertyChangedEvent();
+
return layout;
}
+ private void fireInitialPropertyChangedEvent() {
+ Map validationErrors = this.topLevelPropertiesValuesManager.getErrors();
+ if (validationErrors != null) {
+ for (Object key : validationErrors.keySet()) {
+ String propertyName = (String) key;
+ PropertyDefinition propertyDefinition = this.configurationDefinition.get(propertyName);
+ this.invalidPropertyNameToDisplayNameMap.put(propertyName, propertyDefinition.getDisplayName());
+ }
+ if (!this.invalidPropertyNameToDisplayNameMap.isEmpty()) {
+ PropertyValueChangeEvent event = new PropertyValueChangeEvent(null, null, true,
+ this.invalidPropertyNameToDisplayNameMap);
+ firePropertyChangedEvent(event);
+ }
+ }
+ }
+
private LocatableToolStrip buildToolStrip(LocatableVLayout layout, final SectionStack sectionStack) {
LocatableToolStrip toolStrip = new LocatableToolStrip(layout.extendLocatorId("Tools"));
toolStrip.setBackgroundImage(null);
@@ -471,7 +489,7 @@ public class ConfigurationEditor extends LocatableVLayout {
SectionStackSection section;
if (group == null) {
section = new SectionStackSection(MSG.common_title_generalProp());
-
+ section.setExpanded(true);
} else {
section = new SectionStackSection(
"<div style=\"float:left; font-weight: bold;\">"
@@ -489,6 +507,12 @@ public class ConfigurationEditor extends LocatableVLayout {
DynamicForm form = buildPropertiesForm(locatorId, propertyDefinitions, configuration);
+ // If the group contains any invalid properties, expand the section so the user can see the error icons next to
+ // the invalid properties.
+ if (!form.validate()) {
+ section.setExpanded(true);
+ }
+
section.addItem(form);
return section;
}
@@ -697,25 +721,31 @@ public class ConfigurationEditor extends LocatableVLayout {
}
protected void firePropertyChangedEvent(Property property, PropertyDefinition propertyDefinition, boolean isValid) {
- boolean wasValidBefore = this.invalidPropertyNames.isEmpty();
- Property topLevelProperty = getTopLevelProperty(property);
+ boolean wasValidBefore = this.invalidPropertyNameToDisplayNameMap.isEmpty();
+ PropertyDefinition topLevelPropertyDefinition = getTopLevelPropertyDefinition(propertyDefinition);
+ boolean invalidPropertySetChanged;
if (isValid) {
- this.invalidPropertyNames.remove(topLevelProperty.getName());
+ invalidPropertySetChanged =
+ (this.invalidPropertyNameToDisplayNameMap.remove(topLevelPropertyDefinition.getName()) != null);
} else {
- this.invalidPropertyNames.add(topLevelProperty.getName());
+ invalidPropertySetChanged =
+ (this.invalidPropertyNameToDisplayNameMap.put(topLevelPropertyDefinition.getName(),
+ topLevelPropertyDefinition.getDisplayName()) != null);
}
- boolean isValidNow = this.invalidPropertyNames.isEmpty();
- boolean validationStateChanged = (isValidNow != wasValidBefore);
+ PropertyValueChangeEvent event = new PropertyValueChangeEvent(property, propertyDefinition,
+ invalidPropertySetChanged, this.invalidPropertyNameToDisplayNameMap);
+ firePropertyChangedEvent(event);
+ }
+
+ private void firePropertyChangedEvent(PropertyValueChangeEvent event) {
for (PropertyValueChangeListener propertyValueChangeListener : this.propertyValueChangeListeners) {
- PropertyValueChangeEvent event = new PropertyValueChangeEvent(property, propertyDefinition,
- validationStateChanged, this.invalidPropertyNames);
propertyValueChangeListener.propertyValueChanged(event);
}
}
- public Set<String> getInvalidPropertyNames() {
- return this.invalidPropertyNames;
+ public Map<String, String> getInvalidPropertyNames() {
+ return this.invalidPropertyNameToDisplayNameMap;
}
private FormItem buildMapField(String parentLocatorId, PropertyDefinitionMap propertyDefinitionMap,
@@ -1346,6 +1376,21 @@ public class ConfigurationEditor extends LocatableVLayout {
propertySimple.setValue(value);
}
+ protected static PropertyDefinition getTopLevelPropertyDefinition(PropertyDefinition propertyDefinition) {
+ PropertyDefinition currentPropertyDefinition = propertyDefinition;
+ while (currentPropertyDefinition.getConfigurationDefinition() == null) {
+ if (currentPropertyDefinition.getParentPropertyListDefinition() != null) {
+ currentPropertyDefinition = currentPropertyDefinition.getParentPropertyListDefinition();
+ } else if (currentPropertyDefinition.getParentPropertyMapDefinition() != null) {
+ currentPropertyDefinition = currentPropertyDefinition.getParentPropertyMapDefinition();
+ } else {
+ Log.error("Property definition " + currentPropertyDefinition + " has no parent.");
+ break;
+ }
+ }
+ return currentPropertyDefinition;
+ }
+
protected static Property getTopLevelProperty(Property property) {
Property currentProperty = property;
while (currentProperty.getConfiguration() == null) {
@@ -1424,7 +1469,7 @@ public class ConfigurationEditor extends LocatableVLayout {
return (propertyDefinition.isReadOnly());
}
- protected List<Validator> buildValidators(PropertyDefinitionSimple propertyDefinition, Property property) {
+ protected List<Validator> buildValidators(PropertyDefinitionSimple propertyDefinition, PropertySimple property) {
List<Validator> validators = new ArrayList<Validator>();
Validator typeValidator = null;
@@ -1480,11 +1525,8 @@ public class ConfigurationEditor extends LocatableVLayout {
}
}
- if (property.getErrorMessage() != null) {
- this.invalidPropertyNames.add(property.getName());
- PluginReportedErrorValidator validator = new PluginReportedErrorValidator(property);
- validators.add(validator);
- }
+ PluginReportedErrorValidator validator = new PluginReportedErrorValidator(property);
+ validators.add(validator);
return validators;
}
@@ -1631,7 +1673,7 @@ public class ConfigurationEditor extends LocatableVLayout {
@Override
protected boolean condition(Object value) {
String errorMessage = this.property.getErrorMessage();
- boolean valid = (errorMessage != null);
+ boolean valid = (errorMessage == null);
if (!valid) {
setErrorMessage(errorMessage);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java
index 2ba852d..c4db776 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java
@@ -19,7 +19,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.components.configuration;
-import java.util.Set;
+import java.util.Map;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
@@ -28,16 +28,17 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinition;
* @author Ian Springer
*/
public class PropertyValueChangeEvent {
+
private Property property;
private PropertyDefinition propertyDefinition;
- private boolean validationStateChanged;
- private Set<String> invalidPropertyNames;
+ private boolean invalidPropertySetChanged;
+ private Map<String, String> invalidPropertyNames;
- public PropertyValueChangeEvent(Property property, PropertyDefinition propertyDefinition, boolean validationStatechanged,
- Set<String> invalidPropertyNames) {
+ public PropertyValueChangeEvent(Property property, PropertyDefinition propertyDefinition, boolean invalidPropertySetChanged,
+ Map<String, String> invalidPropertyNames) {
this.property = property;
this.propertyDefinition = propertyDefinition;
- this.validationStateChanged = validationStatechanged;
+ this.invalidPropertySetChanged = invalidPropertySetChanged;
this.invalidPropertyNames = invalidPropertyNames;
}
@@ -49,11 +50,12 @@ public class PropertyValueChangeEvent {
return propertyDefinition;
}
- public boolean isValidationStateChanged() {
- return validationStateChanged;
+ public boolean isInvalidPropertySetChanged() {
+ return invalidPropertySetChanged;
}
- public Set<String> getInvalidPropertyNames() {
+ public Map<String, String> getInvalidPropertyNames() {
return invalidPropertyNames;
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 93d31d7..4864145 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -69,7 +69,6 @@ import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionEvent;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
-import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.menu.IMenuButton;
import com.smartgwt.client.widgets.menu.MenuItem;
import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
@@ -100,7 +99,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
protected static final String FIELD_ID = "id";
protected static final String FIELD_NAME = "name";
- private VLayout contents;
+ private LocatableVLayout contents;
private HTMLFlow title;
@@ -211,6 +210,12 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
protected void onInit() {
super.onInit();
+ contents = new LocatableVLayout(extendLocatorId("tableContents"));
+ contents.setWidth100();
+ contents.setHeight100();
+ //contents.setOverflow(Overflow.AUTO);
+ addMember(contents);
+
filterForm = new TableFilter(this);
/*
@@ -227,7 +232,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
}
}
- listGrid = new LocatableListGrid(getLocatorId());
+ listGrid = new LocatableListGrid(contents.extendLocatorId("ListGrid"));
listGrid.setAutoFetchData(autoFetchData);
if (criteria != null) {
@@ -261,12 +266,6 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
listGrid.setDataSource(dataSource);
}
- contents = new LocatableVLayout(extendLocatorId("tableContents"));
- contents.setWidth100();
- contents.setHeight100();
- //contents.setOverflow(Overflow.AUTO);
- addMember(contents);
-
contents.addMember(listGrid);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java
index cb789b5..208d669 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/GroupResourceConfigurationEditView.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
@@ -220,15 +219,15 @@ public class GroupResourceConfigurationEditView extends LocatableVLayout impleme
public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (event.isInvalidPropertySetChanged()) {
+ Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
message = new Message(MSG.view_group_resConfig_edit_valid(), Message.Severity.Info, EnumSet.of(
Message.Option.Transient, Message.Option.Sticky));
} else {
this.saveButton.disable();
- message = new Message(MSG.view_group_resConfig_edit_invalid(invalidPropertyNames.toString()),
+ message = new Message(MSG.view_group_resConfig_edit_invalid(invalidPropertyNames.values().toString()),
Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
messageCenter.notify(message);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/GroupPluginConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/GroupPluginConfigurationEditView.java
index 973c371..98b785f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/GroupPluginConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/GroupPluginConfigurationEditView.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
@@ -230,15 +229,15 @@ public class GroupPluginConfigurationEditView extends LocatableVLayout implement
public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (event.isInvalidPropertySetChanged()) {
+ Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
message = new Message(MSG.view_group_pluginConfig_edit_valid(), Message.Severity.Info, EnumSet.of(
Message.Option.Transient, Message.Option.Sticky));
} else {
this.saveButton.disable();
- message = new Message(MSG.view_group_pluginConfig_edit_invalid(invalidPropertyNames.toString()),
+ message = new Message(MSG.view_group_pluginConfig_edit_invalid(invalidPropertyNames.values().toString()),
Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
messageCenter.notify(message);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index 87476e8..101bf32 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -19,7 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
import java.util.EnumSet;
-import java.util.Set;
+import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
@@ -183,8 +183,8 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (event.isInvalidPropertySetChanged()) {
+ Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
message = new Message(MSG.view_configurationDetails_allPropertiesValid(), Message.Severity.Info,
@@ -192,7 +192,7 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
} else {
this.saveButton.disable();
message = new Message(MSG.view_configurationDetails_somePropertiesInvalid(invalidPropertyNames
- .toString()), Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ .values().toString()), Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
messageCenter.notify(message);
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
index 1195d1e..9789c6f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
@@ -19,7 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
import java.util.EnumSet;
-import java.util.Set;
+import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
@@ -158,8 +158,8 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Pro
public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (event.isInvalidPropertySetChanged()) {
+ Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
message = new Message(MSG.view_connectionSettingsDetails_allPropertiesValid(), Message.Severity.Info,
@@ -167,7 +167,7 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Pro
} else {
this.saveButton.disable();
message = new Message(MSG.view_connectionSettingsDetails_somePropertiesInvalid(invalidPropertyNames
- .toString()), Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ .values().toString()), Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
messageCenter.notify(message);
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
index f1bb986..08c94d7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
@@ -221,8 +221,10 @@ public abstract class TestConfigurationFactory {
configuration.setVersion(1);
configuration.put(new PropertySimple("String1", "blah"));
- configuration.put(new PropertySimple("String2",
- "a really, really, really, really, really long value that won't fit in the text input box"));
+ PropertySimple string2Prop = new PropertySimple("String2",
+ "a really, really, really, really, really long value that won't fit in the text input box");
+ string2Prop.setErrorMessage("illegal value!");
+ configuration.put(string2Prop);
configuration.put(new PropertySimple("LongString", "blah blah blah\nblah blah blah"));
configuration.put(new PropertySimple("Password", null));
configuration.put(new PropertySimple("Boolean", false));
@@ -280,7 +282,9 @@ public abstract class TestConfigurationFactory {
configuration.put(new PropertyList("ReadOnlyListOfMaps", propMap4, propMap5));
configuration.put(new PropertySimple("myString1", "grouped String 1"));
- configuration.put(new PropertySimple("myString2", "grouped String 2"));
+ PropertySimple myString2Prop = new PropertySimple("myString2", "grouped String 2");
+ myString2Prop.setErrorMessage("bogus value!");
+ configuration.put(myString2Prop);
configuration.put(new PropertySimple("myString3", "strings are cool"));
configuration.put(new PropertySimple("myEnum", "Burlington"));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
index f1845b7..3f3e154 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -20,13 +20,12 @@
package org.rhq.enterprise.gui.coregui.client.test.configuration;
import java.util.EnumSet;
-import java.util.Set;
+import java.util.Map;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.LayoutSpacer;
-import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -37,6 +36,7 @@ import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyVa
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -64,12 +64,12 @@ public class TestConfigurationView
setWidth100();
setHeight100();
- ToolStrip toolStrip = new ToolStrip();
+ LocatableToolStrip toolStrip = new LocatableToolStrip(extendLocatorId("ToolStrip"));
toolStrip.setWidth100();
toolStrip.addMember(new LayoutSpacer());
- this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), MSG.common_button_save());
+ this.saveButton = new LocatableIButton(toolStrip.extendLocatorId("Save"), MSG.common_button_save());
this.saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
save();
@@ -90,8 +90,8 @@ public class TestConfigurationView
public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (event.isInvalidPropertySetChanged()) {
+ Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
message = new Message("All properties now have valid values, so the configuration can now be saved.",
@@ -100,7 +100,7 @@ public class TestConfigurationView
else {
this.saveButton.disable();
message = new Message(
- "The following properties have invalid values: " + invalidPropertyNames
+ "The following properties have invalid values: " + invalidPropertyNames.values()
+ " - the values must be corrected before the configuration can be saved.",
Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
@@ -120,10 +120,12 @@ public class TestConfigurationView
editor = createConfigurationEditor();
addMember(editor);
+ markForRedraw();
}
protected ConfigurationEditor createConfigurationEditor() {
- ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition, this.configuration);
+ ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition,
+ this.configuration);
editor.setEditorTitle("Test Configuration");
editor.setOverflow(Overflow.AUTO);
editor.addPropertyValueChangeListener(this);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java
index 8179fbd..d2d9c94 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java
@@ -22,7 +22,7 @@ package org.rhq.enterprise.gui.coregui.client.test.configuration;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
-import java.util.Set;
+import java.util.Map;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.events.ClickEvent;
@@ -99,8 +99,8 @@ public class TestGroupConfigurationView
public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (event.isInvalidPropertySetChanged()) {
+ Map<String, String> invalidPropertyNames = event.getInvalidPropertyNames();
if (invalidPropertyNames.isEmpty()) {
this.saveButton.enable();
message = new Message("All properties now have valid values, so the configuration can now be saved.",
@@ -109,7 +109,7 @@ public class TestGroupConfigurationView
else {
this.saveButton.disable();
message = new Message(
- "The following properties have invalid values: " + invalidPropertyNames
+ "The following properties have invalid values: " + invalidPropertyNames.values()
+ " - the values must be corrected before the configuration can be saved.",
Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index 29d7b75..39648a2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -61,6 +61,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
label.setAlign(Alignment.CENTER);
label.setWidth("600px");
label.setHeight("30px");
+ label.setCanSelectText(true);
setLabelEmpty();
addMember(label);
commit 154b0692271ea83e1c80ca5d0721abedee4879e9
Merge: 5fc7467 24f2511
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 17 13:30:01 2011 -0400
Merge commit 'origin/master'
commit 5fc7467f24614ef244d3a07f53b797038cdf1df9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 17 13:29:29 2011 -0400
BZ 688679 - correlate server side exceptions with gwt client exception messages. make sure we log the exceptions on server side because gwt error messages some times are not helpful
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
index cd7e631..f4d8085 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
@@ -59,9 +59,9 @@ public interface OperationGWTService extends RemoteService {
int scheduleGroupOperation(GroupOperationSchedule groupOperationSchedule) throws RuntimeException;
- ResourceOperationSchedule getResourceOperationSchedule(int scheduleId);
+ ResourceOperationSchedule getResourceOperationSchedule(int scheduleId) throws RuntimeException;
- GroupOperationSchedule getGroupOperationSchedule(int scheduleId);
+ GroupOperationSchedule getGroupOperationSchedule(int scheduleId) throws RuntimeException;
void unscheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java
index 51416e6..81308cc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AbstractGWTServiceImpl.java
@@ -31,6 +31,7 @@ import com.google.gwt.user.server.rpc.RPCRequest;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.util.HibernatePerformanceMonitor;
@@ -94,6 +95,37 @@ public abstract class AbstractGWTServiceImpl extends RemoteServiceServlet {
this.rpcMethod.set(className + "." + methodName);
}
+ /**
+ * Our GWT Service implementations should call this whenever it needs to send an exception to the GWT client.
+ * @param t the server side exception that needs to be thrown
+ * @returns a RuntimeException that is the real exception that should be thrown to the GWT client
+ */
+ protected RuntimeException getExceptionToThrowToClient(Throwable t) throws RuntimeException {
+ return getExceptionToThrowToClient(t, null);
+ }
+
+ /**
+ * Our GWT Service implementations should call this whenever it needs to send an exception to the GWT client.
+ * @param t the server side exception that needs to be thrown
+ * @param message an extra message to put in the returned exception
+ * @returns a RuntimeException that is the real exception that should be thrown to the GWT client
+ */
+ protected RuntimeException getExceptionToThrowToClient(Throwable t, String message) throws RuntimeException {
+ // this id is so the user can correlate this exception in the server log with the client message in the browser
+ StringBuilder id = new StringBuilder("[");
+ id.append(System.currentTimeMillis());
+ if (message != null) {
+ id.append(" ").append(message);
+ }
+ id.append("] ");
+
+ // log the exception server-side
+ Log.warn("Sending exception to client: " + id.toString(), t);
+
+ // cannot assume gwt client has our exception classes, only send the messages in a generic runtime exception
+ return new RuntimeException(id.toString() + ThrowableUtil.getAllMessages(t));
+ }
+
@SuppressWarnings("unchecked")
private void printHeaders(HttpServletRequest req) {
// TODO: figure out why SESSION_NAME header and other GWT-specific headers are missing occasionally
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java
index 448debd..b23aa79 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AgentGWTServiceImpl.java
@@ -41,7 +41,7 @@ public class AgentGWTServiceImpl extends AbstractGWTServiceImpl implements Agent
return SerialUtility.prepare(agentManager.getAgentByResourceId(getSessionSubject(), resourceId),
"AgentService.getAgentForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -52,7 +52,7 @@ public class AgentGWTServiceImpl extends AbstractGWTServiceImpl implements Agent
return SerialUtility.prepare(agentManager.pingAgentByResourceId(getSessionSubject(), resourceId),
"AgentService.pingAgentForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -61,7 +61,7 @@ public class AgentGWTServiceImpl extends AbstractGWTServiceImpl implements Agent
// return SerialUtility.prepare(availabilityManager.findAvailabilityForResource(getSessionSubject(),
// resourceId, pc), "AvailabilityService.findAvailabilityForResource");
// } catch (Throwable t) {
- // throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ // throw getExceptionToThrowToClient(t);
// }
// }
}
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 6f15250..e26aa8a 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
@@ -59,7 +59,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(results, "findAlertDefinitionsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -69,7 +69,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
int results = alertDefManager.createAlertDefinition(getSessionSubject(), alertDefinition, resourceId);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -81,7 +81,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
alertDefinition, updateInternals);
return SerialUtility.prepare(results, "updateAlertDefinition");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -91,7 +91,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
int results = alertDefManager.enableAlertDefinitions(getSessionSubject(), alertDefinitionIds);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -101,7 +101,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
int results = alertDefManager.disableAlertDefinitions(getSessionSubject(), alertDefinitionIds);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -111,7 +111,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
int results = alertDefManager.removeAlertDefinitions(getSessionSubject(), alertDefinitionIds);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -121,7 +121,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
String[] results = alertDefManager.getAlertNotificationConfigurationPreview(getSessionSubject(), notifs);
return SerialUtility.prepare(results, "getAlertNotificationConfigurationPreview");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -134,7 +134,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
}
return SerialUtility.prepare(results.toArray(new String[results.size()]), "getAllAlertSenders");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -144,7 +144,7 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
ConfigurationDefinition results = alertNotifManager.getConfigurationDefinitionForSender(sender);
return SerialUtility.prepare(results, "getConfigurationDefinitionForSender");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
index 3ae0259..0fd72f7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
@@ -53,7 +53,7 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
}
return SerialUtility.prepare(result, "AlertService.findAlertsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -61,7 +61,7 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
try {
return this.alertManager.deleteAlerts(getSessionSubject(), alertIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -69,7 +69,7 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
try {
return this.alertManager.deleteAlertsByContext(getSessionSubject(), context);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -77,7 +77,7 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
try {
return this.alertManager.acknowledgeAlerts(getSessionSubject(), alertIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -85,7 +85,7 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
try {
return this.alertManager.acknowledgeAlertsByContext(getSessionSubject(), context);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
index 7179ffc..724bcb2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertTemplateGWTServiceImpl.java
@@ -37,7 +37,7 @@ public class AlertTemplateGWTServiceImpl extends AbstractGWTServiceImpl implemen
.createAlertTemplate(getSessionSubject(), alertDefinition, resourceTypeId);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -49,7 +49,7 @@ public class AlertTemplateGWTServiceImpl extends AbstractGWTServiceImpl implemen
purgeInternals);
return SerialUtility.prepare(results, "AlertTemplateService.updateAlertTemplate");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -59,7 +59,7 @@ public class AlertTemplateGWTServiceImpl extends AbstractGWTServiceImpl implemen
alertTemplateManager.enableAlertTemplates(getSessionSubject(), alertDefinitionIds);
return;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -69,7 +69,7 @@ public class AlertTemplateGWTServiceImpl extends AbstractGWTServiceImpl implemen
alertTemplateManager.disableAlertTemplates(getSessionSubject(), alertDefinitionIds);
return;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -79,7 +79,7 @@ public class AlertTemplateGWTServiceImpl extends AbstractGWTServiceImpl implemen
alertTemplateManager.removeAlertTemplates(getSessionSubject(), alertDefinitionIds);
return;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
index a23bf27..bf56c99 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
@@ -42,7 +42,7 @@ public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getExplicitResourcePermissions(
getSessionSubject(), resourceId)), "AuthorizationManager.getExplicitResourcePermissions");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -51,7 +51,7 @@ public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getImplicitResourcePermissions(
getSessionSubject(), resourceId)), "AuthorizationManager.getImplicitResourcePermissions");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -60,7 +60,7 @@ public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getExplicitGroupPermissions(
getSessionSubject(), groupId)), "AuthorizationManager.getExplicitGroupPermissions");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -69,7 +69,7 @@ public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(new HashSet<Permission>(authorizationManager.getImplicitGroupPermissions(
getSessionSubject(), groupId)), "AuthorizationManager.getImplicitGroupPermissions");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -79,7 +79,7 @@ public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implemen
.getExplicitGlobalPermissions(getSessionSubject())),
"AuthorizationManager.getExplicitGlobalPermissions");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
index 93e16c9..3685915 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AvailabilityGWTServiceImpl.java
@@ -41,7 +41,7 @@ public class AvailabilityGWTServiceImpl extends AbstractGWTServiceImpl implement
return SerialUtility.prepare(availabilityManager.findAvailabilityForResource(getSessionSubject(),
resourceId, pc), "AvailabilityService.findAvailabilityForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
index daf457d..3d9c312 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
@@ -53,7 +53,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
BundleVersion results = bundleManager.createBundleVersionViaURL(getSessionSubject(), url);
return SerialUtility.prepare(results, "createBundleVersionViaURL");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -62,7 +62,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
BundleVersion results = bundleManager.createBundleVersionViaRecipe(getSessionSubject(), recipe);
return SerialUtility.prepare(results, "createBundleVersionViaRecipe");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -75,7 +75,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
bundleDestinationId, description, configuration);
return SerialUtility.prepare(result, "createBundleDeployment");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -87,7 +87,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
description, deployDir, groupId);
return SerialUtility.prepare(result, "createBundleDestination");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -98,7 +98,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
version, recipe);
return SerialUtility.prepare(results, "createBundleVersion");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -106,7 +106,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
try {
bundleManager.deleteBundles(getSessionSubject(), bundleIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -114,7 +114,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
try {
bundleManager.deleteBundle(getSessionSubject(), bundleId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -122,7 +122,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
try {
bundleManager.deleteBundleDeployment(getSessionSubject(), bundleDeploymentId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -130,7 +130,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
try {
bundleManager.deleteBundleDestination(getSessionSubject(), bundleDestinationId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -138,7 +138,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
try {
bundleManager.deleteBundleVersion(getSessionSubject(), bundleVersionId, deleteBundleIfEmpty);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -148,7 +148,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
bundleTypes.addAll(bundleManager.getAllBundleTypes(getSessionSubject()));
return SerialUtility.prepare(bundleTypes, "getAllBundleTypes");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -158,7 +158,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
results.putAll(bundleManager.getAllBundleVersionFilenames(getSessionSubject(), bundleVersionId));
return SerialUtility.prepare(results, "getAllBundleVersionFilenames");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -170,7 +170,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
prevDeploymentId);
return SerialUtility.prepare(result, "getBundleDeploymentName");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -181,7 +181,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
isCleanDeployment);
return SerialUtility.prepare(result, "scheduleBundleDeployment");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -192,7 +192,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
bundleDeploymentId, deploymentDescription, isCleanDeployment);
return SerialUtility.prepare(result, "scheduleRevertBundleDeployment");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -201,7 +201,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
PageList<Bundle> results = bundleManager.findBundlesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(results, "findBundlesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -212,7 +212,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
criteria);
return SerialUtility.prepare(result, "BundleService.findBundleDeploymentsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -223,7 +223,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
criteria);
return SerialUtility.prepare(result, "BundleService.findBundleDestinationsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -232,7 +232,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
PageList<BundleFile> result = bundleManager.findBundleFilesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(result, "BundleService.findBundleFilesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -243,7 +243,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
getSessionSubject(), criteria);
return SerialUtility.prepare(result, "BundleService.findBundleResourceDeploymentsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -252,7 +252,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
PageList<BundleVersion> results = bundleManager.findBundleVersionsByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(results, "findBundleVersionsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -263,7 +263,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(results, "findBundlesWithLatestVersionCompositesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -271,7 +271,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
try {
bundleManager.purgeBundleDestination(getSessionSubject(), bundleDestinationId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
index ad81c84..4001ab0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ClusterGWTServiceImpl.java
@@ -49,7 +49,7 @@ public class ClusterGWTServiceImpl extends AbstractGWTServiceImpl implements Clu
return SerialUtility.prepare(clusterManager.createAutoClusterBackingGroup(getSessionSubject(), clusterKey,
addResources), "ClusterGWTServiceImpl.createAutoClusterBackingGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -58,7 +58,7 @@ public class ClusterGWTServiceImpl extends AbstractGWTServiceImpl implements Clu
return SerialUtility.prepare(clusterManager.getAutoClusterBackingGroup(getSessionSubject(), clusterKey),
"ClusterGWTServiceImpl.getAutoClusterBackingGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -67,7 +67,7 @@ public class ClusterGWTServiceImpl extends AbstractGWTServiceImpl implements Clu
return SerialUtility.prepare(clusterManager.getAutoClusterResources(getSessionSubject(), clusterKey),
"ClusterGWTServiceImpl.getAutoClusterResources");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -76,7 +76,7 @@ public class ClusterGWTServiceImpl extends AbstractGWTServiceImpl implements Clu
return SerialUtility.prepare(clusterManager.getClusterTree(getSessionSubject(), groupId),
"ClusterGWTServiceImpl.getClusterTree");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
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 4e551ed..22aadb6 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
@@ -54,7 +54,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
this.configurationManager.purgePluginConfigurationUpdates(getSessionSubject(), configUpdateIds,
purgeInProgress);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -65,7 +65,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
configurationManager.purgeResourceConfigurationUpdates(getSessionSubject(), configUpdateIds,
purgeInProgress);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -74,7 +74,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
configurationManager.rollbackResourceConfiguration(getSessionSubject(), resourceId, configHistoryId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -83,7 +83,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
configurationManager.rollbackPluginConfiguration(getSessionSubject(), resourceId, configHistoryId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -94,7 +94,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
getSessionSubject(), resourceId);
return SerialUtility.prepare(update, "ConfigurationService.getLatestResourceConfigurationUpdate");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -105,7 +105,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
getSessionSubject(), resourceId);
return SerialUtility.prepare(update, "ConfigurationService.getLatestPluginConfigurationUpdate");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -115,7 +115,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
Configuration configuration = configurationManager.getPluginConfiguration(getSessionSubject(), resourceId);
return SerialUtility.prepare(configuration, "ConfigurationService.getPluginConfiguration");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -126,7 +126,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
getSessionSubject(), resourceTypeId);
return SerialUtility.prepare(definition, "ConfigurationService.getPluginConfigDefinition");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -137,7 +137,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
.getResourceConfiguration(getSessionSubject(), resourceId);
return SerialUtility.prepare(configuration, "ResourceConfiguration");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -148,7 +148,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
.getResourceConfigurationDefinitionWithTemplatesForResourceType(getSessionSubject(), resourceTypeId);
return SerialUtility.prepare(definition, "ResourceDefinition");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -171,7 +171,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(updates, "ConfigurationService.findResourceConfigurationUpdates");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -183,7 +183,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
resourceId, configuration);
return SerialUtility.prepare(update, "ConfigurationService.updateResourceConfiguration");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -195,7 +195,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
resourceId, configuration);
return SerialUtility.prepare(update, "ConfigurationService.updatePluginConfiguration");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -218,7 +218,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(updates, "ConfigurationService.findResourceConfigurationUpdatesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -241,7 +241,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(updates, "ConfigurationService.findPluginConfigurationUpdatesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -254,7 +254,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(updates,
"ConfigurationService.findGroupResourceConfigurationUpdatesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -266,7 +266,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
.findGroupPluginConfigurationUpdatesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(updates, "ConfigurationService.findGroupPluginConfigurationUpdatesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -287,7 +287,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(disambiguatedConfigurationComposites,
"ConfigurationService.findResourceConfigurationsForGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -307,7 +307,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(disambiguatedConfigurationComposites,
"ConfigurationService.findPluginConfigurationsForGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -327,7 +327,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(disambiguatedConfigurationComposites,
"ConfigurationService.findResourceConfigurationsForGroupUpdate");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -347,7 +347,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(disambiguatedConfigurationComposites,
"ConfigurationService.findPluginConfigurationsForGroupUpdate");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -359,7 +359,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
this.configurationManager.scheduleGroupResourceConfigurationUpdate(getSessionSubject(), groupId,
configurations);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -371,7 +371,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
this.configurationManager.scheduleGroupPluginConfigurationUpdate(getSessionSubject(), groupId,
configurations);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -382,7 +382,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
this.configurationManager.deleteGroupPluginConfigurationUpdates(getSessionSubject(), groupId,
groupPluginConfigUpdateIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -393,7 +393,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
this.configurationManager.deleteGroupResourceConfigurationUpdates(getSessionSubject(), groupId,
groupResourceConfigUpdateIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -410,7 +410,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
return configurationComposites;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -424,7 +424,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
return configurations;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
index 69c5d20..3de4c93 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ContentGWTServiceImpl.java
@@ -60,7 +60,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
try {
contentManager.deletePackageVersion(getSessionSubject(), packageVersionId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -70,7 +70,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
return SerialUtility.prepare(contentManager.findPackageVersionsByCriteria(getSessionSubject(), criteria),
"ContentService.findPackageVersionsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -79,7 +79,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
return SerialUtility.prepare(contentManager.findPackagesByCriteria(getSessionSubject(), criteria),
"ContentService.findPackagesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -91,7 +91,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
"ContentService.findInstalledPackageHistoryByCriteria");
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -100,7 +100,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
return SerialUtility.prepare(contentManager.findPackagesWithLatestVersion(getSessionSubject(), criteria),
"ContentService.findPackagesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
public PageList<InstalledPackageHistory> getInstalledPackageHistoryForResource(int resourceId, int count)
@@ -110,7 +110,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
return SerialUtility.prepare(contentUiManager.getInstalledPackageHistoryForResource(resourceId, pc),
"ContentService.getInstalledPackageHistoryForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -119,7 +119,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
return SerialUtility.prepare(contentManager.findArchitectures(getSessionSubject()),
"ContentService.getArchitectures");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -128,7 +128,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
return SerialUtility.prepare(contentManager.getResourceCreationPackageType(resourceTypeId),
"ContentService.getResourceCreationPackageType");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -138,7 +138,7 @@ public class ContentGWTServiceImpl extends AbstractGWTServiceImpl implements Con
return SerialUtility.prepare(contentManager.findPackageTypeWithVersionFormat(getSessionSubject(), resourceTypeId, packageTypeName),
"ContentService.findPackageType");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
index 3aa0910..a97c8ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DashboardGWTServiceImpl.java
@@ -45,7 +45,7 @@ public class DashboardGWTServiceImpl extends AbstractGWTServiceImpl implements D
return SerialUtility.prepare(dashboardManager.findDashboardsByCriteria(getSessionSubject(), criteria),
"DashboardManager.findDashboardsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -54,7 +54,7 @@ public class DashboardGWTServiceImpl extends AbstractGWTServiceImpl implements D
return SerialUtility.prepare(dashboardManager.storeDashboard(getSessionSubject(), dashboard),
"DashboardManager.storeDashboard");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -62,7 +62,7 @@ public class DashboardGWTServiceImpl extends AbstractGWTServiceImpl implements D
try {
dashboardManager.removeDashboard(getSessionSubject(), dashboardId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
index 2303a5c..b770e55 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/EventGWTServiceImpl.java
@@ -31,7 +31,6 @@ import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.EventGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.event.EventManagerLocal;
@@ -53,7 +52,7 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
return SerialUtility.prepare(eventManager.getSeverityBuckets(getSessionSubject(), resourceId, begin, end,
numBuckets), "EventService.getSeverityBuckets");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -64,7 +63,7 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
parentResourceId, resourceTypeId, begin, end, numBuckets),
"EventService.getSeverityBucketsForAutoGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -74,7 +73,7 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
return SerialUtility.prepare(eventManager.getSeverityBucketsForCompGroup(getSessionSubject(),
resourceGroupId, begin, end, numBuckets), "EventService.getSeverityBucketsForCompGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -82,8 +81,8 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
try {
return SerialUtility.prepare(eventManager.getEventCountsBySeverity(getSessionSubject(), resourceId,
startDate, endDate), "EventService.getEventCountsBySeverity");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
}
}
@@ -91,8 +90,8 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
try {
return SerialUtility.prepare(eventManager.getEventCountsBySeverityForGroup(getSessionSubject(), groupId,
startDate, endDate), "EventService.getEventCountsBySeverityForGroup");
- } catch (Exception e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
}
}
@@ -101,7 +100,7 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
return SerialUtility.prepare(eventManager.findEventsByCriteria(getSessionSubject(), criteria),
"EventService.findEventsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -110,7 +109,7 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
return SerialUtility.prepare(eventManager.findEventCompositesByCriteria(getSessionSubject(), criteria),
"EventService.findEventsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -118,7 +117,7 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
try {
return eventManager.deleteEventsForContext(getSessionSubject(), context, eventIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -126,7 +125,7 @@ public class EventGWTServiceImpl extends AbstractGWTServiceImpl implements Event
try {
return eventManager.purgeEventsForContext(getSessionSubject(), context);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
index 38a076b..867a2cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
@@ -39,7 +39,7 @@ public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl i
resourceGroupId);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -51,7 +51,7 @@ public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl i
groupAlertDefinition, purgeInternals);
return SerialUtility.prepare(results, "updateGroupAlertDefinitions");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -62,7 +62,7 @@ public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl i
.enableGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -73,7 +73,7 @@ public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl i
groupAlertDefinitionIds);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -84,7 +84,7 @@ public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl i
.removeGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupDefinitionExpressionBuilderGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupDefinitionExpressionBuilderGWTServiceImpl.java
index 7e629bd..28dd5b5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupDefinitionExpressionBuilderGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupDefinitionExpressionBuilderGWTServiceImpl.java
@@ -42,7 +42,7 @@ public class GroupDefinitionExpressionBuilderGWTServiceImpl extends AbstractGWTS
try {
return new ArrayList<String>(builder.getPluginConfigurationPropertyNames(resourceTypeId));
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -51,7 +51,7 @@ public class GroupDefinitionExpressionBuilderGWTServiceImpl extends AbstractGWTS
try {
return new ArrayList<String>(builder.getResourceConfigurationPropertyNames(resourceTypeId));
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -60,7 +60,7 @@ public class GroupDefinitionExpressionBuilderGWTServiceImpl extends AbstractGWTS
try {
return new ArrayList<String>(builder.getTraitPropertyNames(resourceTypeId));
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementChartsGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementChartsGWTServiceImpl.java
index 4ba2327..60c0ef6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementChartsGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementChartsGWTServiceImpl.java
@@ -45,7 +45,7 @@ public class MeasurementChartsGWTServiceImpl extends AbstractGWTServiceImpl impl
.getMetricDisplaySummariesForAutoGroup(getSessionSubject(), parent, type, viewName));
return SerialUtility.prepare(list, "MeasurementCharts.getMetricDisplaySummariesForAutoGroup1");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -58,7 +58,7 @@ public class MeasurementChartsGWTServiceImpl extends AbstractGWTServiceImpl impl
enabledOnly));
return SerialUtility.prepare(list, "MeasurementCharts.getMetricDisplaySummariesForAutoGroup2");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -73,7 +73,7 @@ public class MeasurementChartsGWTServiceImpl extends AbstractGWTServiceImpl impl
.getMetricDisplaySummariesForCompatibleGroup(getSessionSubject(), groupId, viewName));
return SerialUtility.prepare(list, "MeasurementCharts.getMetricDisplaySummariesForCompatibleGroup1");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -86,7 +86,7 @@ public class MeasurementChartsGWTServiceImpl extends AbstractGWTServiceImpl impl
enabledOnly));
return SerialUtility.prepare(list, "MeasurementCharts.getMetricDisplaySummariesForCompatibleGroup2");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -101,7 +101,7 @@ public class MeasurementChartsGWTServiceImpl extends AbstractGWTServiceImpl impl
.getMetricDisplaySummariesForResource(getSessionSubject(), resourceId, viewName));
return SerialUtility.prepare(list, "MeasurementCharts.getMetricDisplaySummariesForResource1");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -113,7 +113,7 @@ public class MeasurementChartsGWTServiceImpl extends AbstractGWTServiceImpl impl
.getMetricDisplaySummariesForResource(getSessionSubject(), resourceId, schedIds, begin, end));
return SerialUtility.prepare(list, "MeasurementCharts.getMetricDisplaySummariesForResource2");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
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 7ff5d62..9ff56a1 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
@@ -69,7 +69,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(dataManager.findCurrentTraitsForResource(getSessionSubject(), resourceId,
displayType), "MeasurementDataService.findCurrentTraitsForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -78,7 +78,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(dataManager.findLiveData(getSessionSubject(), resourceId, definitionIds),
"MeasurementDataService.findLiveData");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -88,7 +88,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(dataManager.findDataForResource(getSessionSubject(), resourceId,
definitionIds, beginTime, endTime, numPoints), "MeasurementDataService.findDataForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -103,7 +103,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
}
return SerialUtility.prepare(results, "MeasurementDataService.findDataForCompatibleGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -113,7 +113,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(callTimeDataManager.findCallTimeDataForResource(getSessionSubject(),
scheduleId, start, end, pageControl), "MeasurementDataService.findCallTimeDataForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -123,7 +123,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(definitionManager.findMeasurementDefinitionsByCriteria(getSessionSubject(),
criteria), "MeasurementDataService.findMeasurementDefinintionsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -133,7 +133,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(scheduleManager.findSchedulesByCriteria(getSessionSubject(), criteria),
"MeasurementDataService.findMeasurementSchedulesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -144,7 +144,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
context, PageControl.getUnlimitedInstance()),
"MeasurementDataService.getMeasurementScheduleCompositesByContext");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -155,7 +155,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
metricNameFilter, resourceNameFilter, parentNameFilter, pc),
"MeasurementDataService.getSchedulesWithOOBs");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -164,7 +164,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(measurementOOBManager.getHighestNOOBsForResource(getSessionSubject(),
resourceId, n), "MeasurementDataService.getHighestNOOBsForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -174,7 +174,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
measurementOOBManager.getHighestNOOBsForGroup(getSessionSubject(), groupId, n),
"MeasurementDataService.getHighestNOOBsForGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -182,7 +182,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
try {
scheduleManager.enableSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -190,7 +190,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
try {
scheduleManager.disableSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -200,7 +200,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
scheduleManager.updateSchedulesForResource(getSessionSubject(), resourceId, measurementDefinitionIds,
collectionInterval);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -210,7 +210,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
scheduleManager.enableSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
measurementDefinitionIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -220,7 +220,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
scheduleManager.disableSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
measurementDefinitionIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -230,7 +230,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
scheduleManager.updateSchedulesForCompatibleGroup(getSessionSubject(), resourceGroupId,
measurementDefinitionIds, collectionInterval);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -240,7 +240,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
measurementDefinitionIds, 0, updateExistingSchedules);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -250,7 +250,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
measurementDefinitionIds, -1, updateExistingSchedules);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -260,7 +260,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
measurementDefinitionIds, collectionInterval, updateExistingSchedules);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -282,7 +282,7 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
return SerialUtility.prepare(results, "MeasurementDataService.findTraitsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementScheduleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementScheduleGWTServiceImpl.java
index 2ae5e40..d6c3e7b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementScheduleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementScheduleGWTServiceImpl.java
@@ -44,7 +44,7 @@ public class MeasurementScheduleGWTServiceImpl extends AbstractGWTServiceImpl im
return SerialUtility.prepare(new ArrayList<MeasurementSchedule>(schedules),
"MeasurementSchedule.findSchedulesForResourceAndType");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index 0290135..59ad907 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -38,7 +38,6 @@ import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposit
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;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
@@ -77,7 +76,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
return SerialUtility.prepare(result, "OperationService.findResourceOperationHistoriesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -89,15 +88,15 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
return SerialUtility.prepare(result, "OperationService.findGroupOperationHistoriesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
- public void deleteOperationHistory(int operationHistoryId, boolean deleteEvenIfInProgress) {
+ public void deleteOperationHistory(int operationHistoryId, boolean deleteEvenIfInProgress) throws RuntimeException {
try {
operationManager.deleteOperationHistory(getSessionSubject(), operationHistoryId, deleteEvenIfInProgress);
- } catch (RuntimeException e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
}
}
@@ -108,7 +107,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
ResourceOperationSchedule opSchedule = operationManager.scheduleResourceOperation(getSessionSubject(),
resourceId, operationName, 0, 0, 0, 0, parameters, description);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -121,35 +120,33 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
ResourceOperationSchedule opSchedule = operationManager.scheduleResourceOperation(getSessionSubject(),
resourceId, operationName, parameters, cronTrigger, description);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
public int scheduleResourceOperation(ResourceOperationSchedule resourceOperationSchedule) throws RuntimeException {
try {
return operationManager.scheduleResourceOperation(getSessionSubject(), resourceOperationSchedule);
- } catch (RuntimeException e) {
- e.printStackTrace();
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
}
}
public int scheduleGroupOperation(GroupOperationSchedule groupOperationSchedule) throws RuntimeException {
try {
return operationManager.scheduleGroupOperation(getSessionSubject(), groupOperationSchedule);
- } catch (RuntimeException e) {
- e.printStackTrace();
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
}
}
- public ResourceOperationSchedule getResourceOperationSchedule(int scheduleId) {
+ public ResourceOperationSchedule getResourceOperationSchedule(int scheduleId) throws RuntimeException {
ResourceOperationSchedule resourceOperationSchedule = operationManager.getResourceOperationSchedule(
getSessionSubject(), scheduleId);
return SerialUtility.prepare(resourceOperationSchedule, "getResourceOperationSchedule");
}
- public GroupOperationSchedule getGroupOperationSchedule(int scheduleId) {
+ public GroupOperationSchedule getGroupOperationSchedule(int scheduleId) throws RuntimeException {
GroupOperationSchedule groupOperationSchedule = operationManager.getGroupOperationSchedule(getSessionSubject(),
scheduleId);
return SerialUtility.prepare(groupOperationSchedule, "getGroupOperationSchedule");
@@ -160,9 +157,8 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
try {
operationManager.unscheduleResourceOperation(getSessionSubject(), resourceOperationSchedule.getJobId()
.toString(), resourceOperationSchedule.getResource().getId());
- } catch (RuntimeException e) {
- e.printStackTrace();
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
}
}
@@ -170,9 +166,8 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
try {
operationManager.unscheduleGroupOperation(getSessionSubject(),
groupOperationSchedule.getJobId().toString(), groupOperationSchedule.getGroup().getId());
- } catch (RuntimeException e) {
- e.printStackTrace();
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
}
}
@@ -191,7 +186,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
return SerialUtility.prepare(lastCompletedResourceOps, "OperationService.findRecentCompletedOperations");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -206,7 +201,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
return SerialUtility.prepare(scheduledResourceOps, "OperationService.findScheduledOperations");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -217,7 +212,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
return SerialUtility.prepare(resourceOperationSchedules, "findScheduledResourceOperations");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -228,7 +223,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
return SerialUtility.prepare(groupOperationSchedules, "findScheduledGroupOperations");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginGWTServiceImpl.java
index 692c46a..45d98bc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginGWTServiceImpl.java
@@ -40,7 +40,7 @@ public class PluginGWTServiceImpl extends AbstractGWTServiceImpl implements Plug
try {
return new ArrayList<Plugin>(manager.getInstalledPlugins());
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java
index b397c15..3362bf9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RemoteInstallGWTServiceImpl.java
@@ -44,7 +44,7 @@ public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(remoteInstallManager.agentInstallCheck(getSessionSubject(), remoteAccessInfo,
agentInstallPath), "RemoteInstallService.agentInstallCheck");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -53,7 +53,7 @@ public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(remoteInstallManager.installAgent(getSessionSubject(), remoteAccessInfo,
parentPath), "RemoteInstallService.installAgent");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -62,7 +62,7 @@ public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(remoteInstallManager.startAgent(getSessionSubject(), remoteAccessInfo,
agentInstallPath), "RemoteInstallService.startAgent");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -71,7 +71,7 @@ public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(remoteInstallManager.stopAgent(getSessionSubject(), remoteAccessInfo,
agentInstallPath), "RemoteInstallService.stopAgent");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -80,7 +80,7 @@ public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(remoteInstallManager.agentStatus(getSessionSubject(), remoteAccessInfo,
agentInstallPath), "RemoteInstallService.agentStatus");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -89,7 +89,7 @@ public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare((remoteInstallManager.findAgentInstallPath(getSessionSubject(),
remoteAccessInfo, parentPath)), "RemoteInstallService.findAgentInstallPath");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -98,7 +98,7 @@ public class RemoteInstallGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare((remoteInstallManager.remotePathDiscover(getSessionSubject(),
remoteAccessInfo, parentPath)), "RemoteInstallService.remotePathDiscover");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
index 100289c..f3be776 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RepoGWTServiceImpl.java
@@ -45,7 +45,7 @@ public class RepoGWTServiceImpl extends AbstractGWTServiceImpl implements RepoGW
return SerialUtility.prepare(repoManager.findReposByCriteria(getSessionSubject(), criteria),
"RepoService.findReposByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
index 34019fe..d3bcc8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceBossGWTServiceImpl.java
@@ -43,7 +43,7 @@ public class ResourceBossGWTServiceImpl extends AbstractGWTServiceImpl implement
// note: this does not need to be sent through SerialUtility.prepare as it has no entities
return resourceBoss.getInventorySummary(getSessionSubject());
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 4c474c1..7b32034 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -44,7 +44,6 @@ import org.rhq.core.domain.resource.composite.ResourceInstallCount;
import org.rhq.core.domain.resource.composite.ResourceLineageComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
@@ -126,7 +125,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(result, "ResourceService.findResourcesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -145,7 +144,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(result, "ResourceService.findResourceCompositesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -160,7 +159,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(result, "ResourceService.findProblemResources");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -171,7 +170,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
"ResourceService.getResourceLineageAndSiblings");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -180,7 +179,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(resourceManager.getRootResourceForResource(resourceId),
"ResourceService.getPlatformForResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -198,7 +197,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(platforms, "ResourceService.findRecentlyAddedResources");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -207,7 +206,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(), resourceIds),
"ResourceService.uninventoryResources");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -215,7 +214,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
try {
resourceManager.updateResource(getSessionSubject(), resource);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -237,7 +236,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
resourceFactoryManager.createResource(getSessionSubject(), parentResourceId, newResourceTypeId,
newResourceName, pluginConfig, newResourceConfiguration);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -259,7 +258,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
resourceFactoryManager.createPackageBackedResourceViaPackageVersion(getSessionSubject(), parentResourceId,
newResourceTypeId, newResourceName, pluginConfig, deploymentTimeConfiguration, packageVersionId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -268,7 +267,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(resourceFactoryManager.deleteResources(getSessionSubject(), resourceIds),
"ResourceService.deleteResources");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -278,7 +277,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(discoveryBoss.getQueuedPlatformsAndServers(getSessionSubject(), EnumSet
.copyOf(statuses), pc), "ResourceService.getQueuedPlatformsAndServers");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -286,7 +285,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
try {
discoveryBoss.importResources(getSessionSubject(), resourceIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -294,7 +293,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
try {
discoveryBoss.ignoreResources(getSessionSubject(), resourceIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -302,7 +301,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
try {
discoveryBoss.unignoreResources(getSessionSubject(), resourceIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -311,7 +310,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
return SerialUtility.prepare(resourceManager.findResourceErrors(getSessionSubject(), resourceId),
"ResourceService.getResourceErrors");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -322,7 +321,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
pluginConfiguration);
return SerialUtility.prepare(result, "ResourceService.manuallyAddResource");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -332,7 +331,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
groupByVersions);
return SerialUtility.prepare(result, "ResourceService.findResourceInstallCounts");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
index 6963b8c..b185242 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
@@ -47,7 +47,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
PageList<ResourceGroup> groups = groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(groups, "ResourceGroupService.findResourceGroupsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -58,7 +58,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
getSessionSubject(), criteria);
return SerialUtility.prepare(composites, "ResourceGroupService.findResourceGroupCompositesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -69,7 +69,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
getSessionSubject(), criteria);
return SerialUtility.prepare(definitions, "ResourceGroupService.findGroupDefinitionsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -77,7 +77,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
groupManager.setAssignedResources(getSessionSubject(), groupId, resourceIds, setType);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -87,7 +87,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
groupManager.setAssignedResourceGroupsForResource(getSessionSubject(), resourceId, resourceGroupIds,
setType);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -98,7 +98,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
groupManager.setAssignedResources(user, group.getId(), resourceIds, true);
return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -109,7 +109,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
groupManager.setAssignedResources(user, group.getId(), resourceIds, true);
return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -117,7 +117,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
groupManager.deleteResourceGroups(getSessionSubject(), groupIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -125,7 +125,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
groupManager.updateResourceGroup(getSessionSubject(), group);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -133,7 +133,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
groupManager.updateResourceGroup(getSessionSubject(), group, null, updateMembership);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -143,7 +143,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
return SerialUtility.prepare(results, "ResourceGroupService.createGroupDefinition");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -151,7 +151,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
definitionManager.updateGroupDefinition(getSessionSubject(), groupDefinition);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -161,7 +161,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
definitionManager.calculateGroupMembership(getSessionSubject(), nextGroupDefinitionId);
}
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -171,7 +171,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
definitionManager.removeGroupDefinition(getSessionSubject(), nextGroupDefinitionId);
}
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -180,7 +180,7 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
groupManager.setRecursive(getSessionSubject(), groupId, isRecursive);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
index 223a23e..7a3d964 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
@@ -29,7 +29,7 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
return SerialUtility.prepare(typeManager.findResourceTypesByCriteria(getSessionSubject(), criteria),
"ResourceTypes.findResourceTypesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -47,7 +47,7 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
}
return SerialUtility.prepare(types, "ResourceTypes.getResourceTypesForResourceAncestors");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -59,7 +59,7 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
return SerialUtility
.prepare(new ArrayList<ResourceType>(list), "ResourceTypes.getAllResourceTypeAncestors");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -72,7 +72,7 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
resourceTypeId);
return SerialUtility.prepare(map, "ResourceTypes.getResourceTypeDescendantsWithOperations");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -83,7 +83,7 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
Map<Integer, ResourceTypeTemplateCountComposite> map = typeManager.getTemplateCountCompositeMap();
return SerialUtility.prepare(map, "ResourceTypes.getTemplateCountCompositeMap");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
index 73659e0..8ff8457 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/RoleGWTServiceImpl.java
@@ -41,7 +41,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
return SerialUtility.prepare(roleManager.findRolesByCriteria(getSessionSubject(), criteria),
"RoleService.findRolesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -49,7 +49,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
try {
return SerialUtility.prepare(roleManager.createRole(getSessionSubject(), role), "RoleService.createRole");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -57,7 +57,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
try {
return SerialUtility.prepare(roleManager.updateRole(getSessionSubject(), role), "RoleService.updateRole");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -65,7 +65,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
try {
roleManager.deleteRoles(getSessionSubject(), roleIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -73,7 +73,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
try {
roleManager.setAssignedResourceGroups(getSessionSubject(), roleId, resourceGroupIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -81,7 +81,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
try {
roleManager.setAssignedSubjects(getSessionSubject(), roleId, subjectIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -89,7 +89,7 @@ public class RoleGWTServiceImpl extends AbstractGWTServiceImpl implements RoleGW
try {
roleManager.setAssignedSubjectRoles(getSessionSubject(), subjectId, roleIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
index 1af6f3f..fac1c35 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SearchGWTServiceImpl.java
@@ -47,7 +47,7 @@ public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements Sear
List<SearchSuggestion> results = searchAssistManager.getTabAwareSuggestions(expression, caretPosition, tab);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -58,7 +58,7 @@ public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements Sear
List<SearchSuggestion> results = searchAssistManager.getSuggestions(expression, caretPosition);
return results;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -66,7 +66,7 @@ public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements Sear
try {
return savedSearchManager.createSavedSearch(getSessionSubject(), savedSearch);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -76,7 +76,7 @@ public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements Sear
savedSearch.setName(newName);
return savedSearchManager.updateSavedSearch(getSessionSubject(), savedSearch);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -86,7 +86,7 @@ public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements Sear
savedSearch.setPattern(newPattern);
return savedSearchManager.updateSavedSearch(getSessionSubject(), savedSearch);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -94,7 +94,7 @@ public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements Sear
try {
savedSearchManager.deleteSavedSearch(getSessionSubject(), savedSearchId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -103,7 +103,7 @@ public class SearchGWTServiceImpl extends AbstractGWTServiceImpl implements Sear
return SerialUtility.prepare(savedSearchManager.findSavedSearchesByCriteria(getSessionSubject(), criteria),
"SearchService.findRolesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
index e690d84..064035d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.SubjectGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
@@ -41,7 +40,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
try {
subjectManager.createPrincipal(getSessionSubject(), username, password);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -50,7 +49,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
return SerialUtility.prepare(subjectManager.createSubject(getSessionSubject(), subjectToCreate),
"SubjectManager.createSubject");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -59,7 +58,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
return SerialUtility.prepare(subjectManager.createSubject(getSessionSubject(), subjectToCreate, password),
"SubjectManager.createSubject");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -67,7 +66,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
try {
subjectManager.deleteSubjects(getSessionSubject(), subjectIds);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -75,7 +74,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
try {
return SerialUtility.prepare(subjectManager.login(username, password), "SubjectManager.login");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -83,7 +82,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
try {
subjectManager.logout(sessionId);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -92,7 +91,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
return SerialUtility.prepare(subjectManager.updateSubject(getSessionSubject(), subjectToModify),
"SubjectManager.updateSubject");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -101,7 +100,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
return SerialUtility.prepare(subjectManager
.updateSubject(getSessionSubject(), subjectToModify, newPassword), "SubjectManager.updateSubject");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -110,10 +109,10 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
try {
Subject processedSubject = subjectManager.processSubjectForLdap(subjectToModify, password);
return SerialUtility.prepare(processedSubject, "SubjectManager.processSubjectForLdap");
- } catch (LoginException e) {
- throw new RuntimeException("LoginException: " + e.getMessage());
- } catch (RuntimeException e) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ } catch (LoginException le) {
+ throw new RuntimeException("LoginException: " + le.getMessage());
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
}
}
@@ -122,7 +121,7 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
return SerialUtility.prepare(subjectManager.findSubjectsByCriteria(getSessionSubject(), criteria),
"SubjectManager.findSubjectsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -130,16 +129,16 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
try {
return subjectManager.isUserWithPrincipal(username);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
public Subject checkAuthentication(String username, String password) {
try {
- return SerialUtility.prepare(subjectManager.checkAuthentication(username, password),
+ return SerialUtility.prepare(subjectManager.checkAuthentication(username, password),
"SubjectManager.checkAuthentication");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
index c2dae6e..bb94c66 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
@@ -28,7 +28,6 @@ import java.util.Properties;
import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
-import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.gui.coregui.client.gwt.SystemGWTService;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
@@ -53,7 +52,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
try {
return systemManager.getServerDetails(getSessionSubject()).getProductInfo();
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -62,7 +61,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
try {
return systemManager.getServerDetails(getSessionSubject());
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -72,7 +71,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
Properties props = systemManager.getSystemConfiguration(getSessionSubject());
return convertFromProperties(props);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -82,7 +81,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
Properties props = convertToProperties(map);
systemManager.setSystemConfiguration(getSessionSubject(), props, skipValidation);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -96,7 +95,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
return convertFromProperties(props);
} catch (Throwable t) {
- throw new RuntimeException("Agent download information not available. " + ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t, "Agent download information not available.");
}
}
@@ -115,7 +114,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
}
return map;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -146,7 +145,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
p.load(new FileInputStream(versionFile));
return convertFromProperties(p);
} catch (Throwable t) {
- throw new RuntimeException("Unable to retrieve client version info. " + ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t, "Unable to retrieve client version info.");
}
}
@@ -163,7 +162,7 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
ret.put(file.getName(), "/downloads/bundle-deployer/" + file.getName());
return ret;
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
index 2f28bbf..38a298c0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TagGWTServiceImpl.java
@@ -48,7 +48,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
return SerialUtility.prepare(tagManager.findTagsByCriteria(getSessionSubject(), tagCriteria),
"TagService.findTagsByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -56,7 +56,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
try {
return SerialUtility.prepare(tagManager.addTags(getSessionSubject(), tags), "TagService.addTags");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -64,7 +64,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
try {
tagManager.removeTags(getSessionSubject(), tags);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -72,7 +72,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
try {
tagManager.updateResourceTags(getSessionSubject(), resourceId, tags);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -80,7 +80,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
try {
tagManager.updateResourceGroupTags(getSessionSubject(), resourceGroupId, tags);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -88,7 +88,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
try {
tagManager.updateBundleTags(getSessionSubject(), bundleId, tags);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -96,7 +96,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
try {
tagManager.updateBundleVersionTags(getSessionSubject(), bundleVersionId, tags);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -104,7 +104,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
try {
tagManager.updateBundleDeploymentTags(getSessionSubject(), bundleDeploymentId, tags);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -112,7 +112,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
try {
tagManager.updateBundleDestinationTags(getSessionSubject(), bundleDestinationId, tags);
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
@@ -123,7 +123,7 @@ public class TagGWTServiceImpl extends AbstractGWTServiceImpl implements TagGWTS
tagManager.findTagReportCompositesByCriteria(getSessionSubject(), tagCriteria),
"TagService.findTagReportCompositesByCriteria");
} catch (Throwable t) {
- throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ throw getExceptionToThrowToClient(t);
}
}
}
commit 24f25116d56dc5d46ca9a4b733240e1dedf7f5f8
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Mar 17 12:31:27 2011 -0400
Rendering of JSF monitor (avail) pages failed if the resource type had no
resource facets (for example, Embedded JBossWeb Server resources or, I think,
Bundle handler resources). Added handling for this.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java
index de91285..7f13169 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java
@@ -62,7 +62,11 @@ public class ResourceActivationContext extends AbstractResourceOrGroupActivation
if (this.facets == null) {
ResourceFacets resourceFacets = this.resourceTypeManager.getResourceFacets(resource.getResourceType()
.getId());
- this.facets = EnumSet.copyOf(resourceFacets.getFacets());
+ try {
+ this.facets = EnumSet.copyOf(resourceFacets.getFacets());
+ } catch (IllegalArgumentException e) {
+ this.facets = EnumSet.noneOf(ResourceTypeFacet.class);
+ }
}
return this.facets;
}
commit 39bddd7e8616e65a5d6b74035a1597203b69c327
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Mar 17 12:29:11 2011 -0400
Switching tabs quickly in the resource detail view could result in a
lock up where the tabs endlessly "rotated". This results because the
content of tab1 finishes loading after the request for tab2. This fix
disables the tabset between the tab selection and the load completion, thus
(in theory) preventing tab2 from being fired until it's safe. It seems to be
working...
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
index b722739..e303c50 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -134,7 +134,14 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
}
public void onTabSelected(TwoLevelTabSelectedEvent tabSelectedEvent) {
+
+ // We want to finish the tab selection process, which may involve async loading of content,
+ // before allowing more tab selection. This avoids potential tab "looping" that happens when a new
+ // tab is selected before the previous one could finish loading. So, disable the tab set here, and
+ // re-enable it later when the tab content is actuall rendered (see selectTab).
+
if (getSelectedItemId() == null) {
+ this.tabSet.disable();
CoreGUI.goToView(History.getToken());
} else {
String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
@@ -144,6 +151,7 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
// than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
// current history item.
if (!(History.getToken().equals(path) || History.getToken().startsWith(path + "/"))) {
+ this.tabSet.disable();
CoreGUI.goToView(path);
}
}
@@ -228,8 +236,11 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
((RefreshableView) subView).refresh();
}
+ // ensure the tabset is enabled (disabled in onTabSelected), and redraw
+ this.tabSet.enable();
this.tabSet.markForRedraw();
} catch (Exception e) {
+ this.tabSet.enable();
Log.info("Failed to select tab " + tabName + "/" + subtabName + ": " + e);
}
}
commit 4629ee6ce064e487c2b1adab06ad7e2524f63d05
Merge: 88ab6d9 67f853a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 17 12:28:09 2011 -0400
Merge commit 'origin/master'
commit 88ab6d906ca33bfa8136b451c7c18f2e94ca713c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 17 12:05:32 2011 -0400
in the gui ui - we are losing the plugin exception message that tells us why the manual add failed
don't wrap an exception in an exception - just throw the original, the gwt service impl will handle scrubbing the exception so gwt ui can handle it
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index b4d092d..84ae777 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -339,16 +339,12 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
Resource result = null;
- try {
- ResourceType resourceType = this.resourceTypeManager.getResourceTypeById(subject, resourceTypeId);
- // the subsequent call to manuallyAddResource requires a detached ResourceType param so clear
- entityManager.clear();
- MergeResourceResponse response = manuallyAddResource(subject, resourceType, parentResourceId,
- pluginConfiguration);
- result = this.resourceManager.getResourceById(subject, response.getResourceId());
- } catch (Exception e) {
- throw new Exception(e.getMessage());
- }
+ ResourceType resourceType = this.resourceTypeManager.getResourceTypeById(subject, resourceTypeId);
+ // the subsequent call to manuallyAddResource requires a detached ResourceType param so clear
+ entityManager.clear();
+ MergeResourceResponse response = manuallyAddResource(subject, resourceType, parentResourceId,
+ pluginConfiguration);
+ result = this.resourceManager.getResourceById(subject, response.getResourceId());
return result;
}
commit 79d201ae9f77c9f48d4b121275d05d3be0c67720
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 17 11:46:11 2011 -0400
manually adding a resource may take some time to complete, give 5m max
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index 63014aa..fd9e3ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -66,6 +66,10 @@ public class GWTServiceLookup {
return secure(ResourceGWTServiceAsync.Util.getInstance());
}
+ public static ResourceGWTServiceAsync getResourceService(int timeout) {
+ return secure(ResourceGWTServiceAsync.Util.getInstance(), timeout);
+ }
+
public static ResourceGroupGWTServiceAsync getResourceGroupService() {
return secure(ResourceGroupGWTServiceAsync.Util.getInstance());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java
index 2723440..8e45760 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryImportWizard.java
@@ -79,8 +79,8 @@ public class ResourceFactoryImportWizard extends AbstractResourceFactoryWizard {
int createTypeId = getChildType().getId();
Configuration newConfiguration = this.getNewResourceConfiguration();
- GWTServiceLookup.getResourceService().manuallyAddResource(createTypeId, parentResourceId, newConfiguration,
- new AsyncCallback<Resource>() {
+ GWTServiceLookup.getResourceService(300000).manuallyAddResource(createTypeId, parentResourceId,
+ newConfiguration, new AsyncCallback<Resource>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.widget_resourceFactoryWizard_importFailure(), caught);
getView().closeDialog();
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.
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();
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
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) {
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);
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)
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 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
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");
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.
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>
commit 01126cb3b531ac706e8280ab97f049d44db91399
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 1d07b7f622c024bde84191b1ac573b27e63b205f
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 29960f759d35ace3e8bac334ee49abafaefd2055
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 be007b5c9e336e2401b9fe10a8361d918fe3b31c
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 b7c4250fd086b7c3a2e7a883fc884c9d9a82f6c8
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 73c923e8ea8e3b016138d06a027189393e8f2684
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 acb761df457d4753ac4f9277a95831358110513d
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 fcd0a45565086410ecfbc443b7312743a6bb017d
Merge: 0f4f948 0846d35
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Mar 14 15:30:51 2011 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 0846d3579e9e5c16617493a370ba6db998572b49
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 14 15:23:27 2011 -0400
fix the events history ui - provide i18n with icons - show hover for full name of source, pretty up details view
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 1894c09..8b7cb0b 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
@@ -405,6 +405,19 @@ public class ImageManager {
return "subsystems/event/Events" + icon + "_16.png";
}
+ /**
+ * This returns an icon of the badge (e.g. the red X or the blue I) without the
+ * event icon. This is used if you have a table of events and the user knows they are
+ * events so there is no need to show the event icon itself- showing a bigger badge
+ * to indicate severity is more useful.
+ *
+ * @param severity
+ * @return badge icon
+ */
+ public static String getEventSeverityBadge(EventSeverity severity) {
+ return "subsystems/event/" + severity.name() + "_16.png";
+ }
+
public static String getEventLargeIcon() {
return "subsystems/event/Events_24.png";
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
index ea01164..40a342f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDetailsView.java
@@ -34,6 +34,7 @@ import org.rhq.core.domain.event.composite.EventComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -83,12 +84,31 @@ public class EventCompositeDetailsView extends LocatableVLayout implements Bookm
DynamicForm form = new LocatableDynamicForm(extendLocatorId("form"));
form.setWidth100();
form.setHeight100();
+ form.setWrapItemTitles(false);
StaticTextItem id = new StaticTextItem("id", MSG.common_title_id());
id.setValue(composite.getEventId());
StaticTextItem severity = new StaticTextItem("severity", MSG.view_inventory_eventHistory_severity());
- severity.setValue(composite.getSeverity().name());
+ String severityValue = Canvas.imgHTML(ImageManager.getEventSeverityBadge(composite.getSeverity()));
+ switch (composite.getSeverity()) {
+ case DEBUG:
+ severityValue += MSG.common_severity_debug();
+ break;
+ case INFO:
+ severityValue += MSG.common_severity_info();
+ break;
+ case WARN:
+ severityValue += MSG.common_severity_warn();
+ break;
+ case ERROR:
+ severityValue += MSG.common_severity_error();
+ break;
+ case FATAL:
+ severityValue += MSG.common_severity_fatal();
+ break;
+ }
+ severity.setValue(severityValue);
StaticTextItem source = new StaticTextItem("source", MSG.view_inventory_eventHistory_sourceLocation());
source.setValue(composite.getSourceLocation());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 7209c17..0657f04 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -27,10 +27,12 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -39,6 +41,7 @@ import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
@@ -50,7 +53,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
* @author Joseph Marques
*/
-public class EventCompositeHistoryView extends TableSection {
+public class EventCompositeHistoryView extends TableSection<EventCompositeDatasource> {
private static SortSpecifier DEFAULT_SORT_SPECIFIER = new SortSpecifier("timestamp", SortDirection.DESCENDING);
private EntityContext context;
@@ -97,18 +100,53 @@ public class EventCompositeHistoryView extends TableSection {
@Override
protected void configureTable() {
- ListGridField timestampField = new ListGridField("timestamp", MSG.view_inventory_eventHistory_timestamp(), 125);
- ListGridField severityField = new ListGridField("severity", MSG.view_inventory_eventHistory_severity(), 75);
+ ListGridField timestampField = new ListGridField("timestamp", MSG.view_inventory_eventHistory_timestamp());
+
+ ListGridField severityField = new ListGridField("severity", MSG.view_inventory_eventHistory_severity());
+ severityField.setAlign(Alignment.CENTER);
severityField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- return Canvas.imgHTML("subsystems/event/" + o + "_16.png", 16, 16) + o;
+ String icon = ImageManager.getEventSeverityBadge(EventSeverity.valueOf(o.toString()));
+ return Canvas.imgHTML(icon);
+ }
+ });
+ severityField.setShowHover(true);
+ severityField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ EventSeverity severity = EventSeverity.valueOf(record.getAttribute("severity"));
+ switch (severity) {
+ case DEBUG:
+ return MSG.common_severity_debug();
+ case INFO:
+ return MSG.common_severity_info();
+ case WARN:
+ return MSG.common_severity_warn();
+ case ERROR:
+ return MSG.common_severity_error();
+ case FATAL:
+ return MSG.common_severity_fatal();
+ }
+ return null;
}
});
+
ListGridField detailsField = new ListGridField("details-highlight", MSG.view_inventory_eventHistory_details());
- ListGridField sourceField = new ListGridField("source", MSG.view_inventory_eventHistory_sourceLocation(), 275);
+ detailsField.setCellFormatter(new CellFormatter() {
+ @Override
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ if (((String) value).length() <= 200) {
+ return (String) value;
+ } else {
+ return ((String) value).substring(0, 200); // first 200 chars
+ }
+ }
+ });
+
+ ListGridField sourceField = new ListGridField("source", MSG.view_inventory_eventHistory_sourceLocation());
sourceField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- String sourceLocation = (String) o;
+ String sourceLocation = listGridRecord.getAttribute("source");
int length = sourceLocation.length();
if (length > 40) {
return "..." + sourceLocation.substring(length - 40); // the last 40 chars
@@ -116,6 +154,19 @@ public class EventCompositeHistoryView extends TableSection {
return sourceLocation;
}
});
+ sourceField.setShowHover(true);
+ sourceField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String sourceLocation = record.getAttribute("source");
+ return (sourceLocation.length() > 40) ? sourceLocation : null;
+ }
+ });
+
+ timestampField.setWidth("20%");
+ severityField.setWidth("25");
+ detailsField.setWidth("*");
+ sourceField.setWidth("20%");
setListGridFields(timestampField, severityField, detailsField, sourceField);
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 8293144..a6b9716 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
@@ -81,6 +81,14 @@ common_unit_weeks = weeks
common_unit_months = months
common_unit_years = years
+# Common Severities
+#------------------
+common_severity_debug = Debug
+common_severity_info = Info
+common_severity_warn = Warn
+common_severity_error = Error
+common_severity_fatal = Fatal
+
# Common Titles
#--------------
common_title_address = Address
commit 0f4f94855bca6fae56f83919d378c8168e648410
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Mar 14 15:14:31 2011 -0400
Updating version of cloud server plugin
diff --git a/modules/enterprise/server/plugins/cloud/pom.xml b/modules/enterprise/server/plugins/cloud/pom.xml
index 8d10fcd..b66ad28 100644
--- a/modules/enterprise/server/plugins/cloud/pom.xml
+++ b/modules/enterprise/server/plugins/cloud/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-enterprise-server-plugins-parent</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
commit 332f77eb8450aed98d2c33935f47680b7d29e392
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Mar 14 15:09:53 2011 -0400
Squahshing 13 commits from ec2 branch
first commit message:
Adding new operation to rhq-agent plugin to update the server endpoint url
Invoking the switchToServer operation will result in the operation switching
over to the specified server. In an EC2 deployment, the server can invoke this
operation whenever its IP address has changed. Then the agent will have a valid
server endpoint url from which it can download its failover list.
second commit message:
Initial commit for rhq-agent-wrapper-ec2 script
This is a wrapper script for rhq-agent-wrapper.sh that additionally configures
the server endpoint url and will also set up the agent to run as a service.
third commit message:
Adding logic to check for and skip initialization if it has already run
The initialization function only needs to run the first time an agent
runs so that the server endpoint url can be specified. That url will be
supplied in the AMI's user-defined data. Also adding logic to force
initialization to run when specifying the <init> cmd line arg.
fourth commit message:
Adding ability for plugin jobs to persist data across invocations of jobs
Server plugin scheduled jobs previously had no mechanism provided by the plugin
framework for persisting data across invocations of the job. Quartz however
provides this capability when using a StatefulJob. Server plugin jobs run as
StatefulJob objects when they do not run concurrently. The only change needed
then was to expose a hook to the JobDataMap. A map has been added to
ScheduledJobInvocationContext which comes from the JobDataMap. Anything added
to this map by the server plugin job will be persisted from invocation of the
job to the next.
Initial commit for cloud plugin which at this point is just testing that
persisting job data works as expected.
fifth commit message:
Adding support for syncing the server endpoint url at start up.
The behavior is turned off by default. It can be enabled by setting
rhq.sync.endpoint-address=true
in rhq-server.properties. When this is enabled, the server at start up will
compare its endpoint address to the host name/address found on the host machine.
If they differ, the server endpoint address will be updated to the value found
on the host machine. This addresses the (first part of the problem of)
address/host name changes that will occur in EC2 when a server machine is
restarted.
sixth commit message:
Restricting plugins to storing only string in the job data
Quartz is already configured to only allow strings to be stored in the job data
map when a job is scheduled for concurrent execution. Restricting entries in
the map to strings is recommended to avoid class versioning errors that are
common during deserialization. ScheduledInvocationContext has been refactored
a bit so that the underlying map is no longer directly exposed. To edit values
in the map it now exposes get/put methods that help enforce and ensure only
strings are stored in the map. There is still a getProperties() method; however,
it returns a read-only view of the data map.
seventh commit message:
Updating plugin descriptor to make cloud plugin clustered
Also refactoring plugin to work with new methods in
ScheduledJobInvocationContext
eigth commit message:
Only allow job data to be persisted when the job is not marked concurrent
Adding logic such that persisting job data in the
ScheduledJobInvocationContext is only supported when the job is not
marked as concurrent. If the job is marked as concurrent, and the plugin
calls a method to access or update properties, an exception will be
thrown.
Also adding some javadocs to explain how/when persisting job data is
supported
ninth commmit message:
Fixing methods to throw the correct exception type
tenth commit message:
Adding logic to detect changed addresses
eleventh commit message:
Schedule the 'switchToServer' agent resource operation
twelth commit message:
Exposing address sync job as an operation that can be manually invoked.
This is a first code at this plugin operation. Some error handling needs
to be added along with some logging.
thirteenth commit message:
Adding logic to purge stale servers from the sync list
If a server has been taken down and removed from the system, then we
need to remove it from the list of servers we look at to see if their
addresses need to be synced.
Adding a bunch of debug logging.
Conflicts:
modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
diff --git a/modules/enterprise/agent/src/etc/rhq-agent-wrapper-ec2 b/modules/enterprise/agent/src/etc/rhq-agent-wrapper-ec2
new file mode 100755
index 0000000..3808ba0
--- /dev/null
+++ b/modules/enterprise/agent/src/etc/rhq-agent-wrapper-ec2
@@ -0,0 +1,122 @@
+#!/bin/bash
+
+# =============================================================================
+# RHQ AGENT LINUX/EC2 Boot Script
+#
+# This script is a wrapper script for rhq-agent-wrapper.sh which is used to
+# start/stop the agent on LINUX/UNIX platforms. This script provides some
+# additional functionality for automatically configuring the agent in an EC2
+# environment.
+#
+# When the agent is started with this script, it will check to see if server
+# endpoint URL has been configured. If it finds that the agent has not already
+# been configured the script fetches paramerters specified as part of the AMIs
+# user-defined data, parses the parameters, looking for the jon.server.url
+# parameter. The rhq.agent.server.bind-address setting is then configured with
+# the parameter's value. If the jon.server.url parameter is not found, an error
+# message is logged and the agent will not be started.
+#
+# To force initialization or to re-initialize the agent run,
+#
+# $ rhq-agent-wrapper-ec2 init
+# =============================================================================
+
+RHQ_AGENT_HOME=/usr/share/rhq-agent-<VERSION>
+SCRIPT_NAME=rhq-wrapper-agent-ec2
+
+function load_user_data
+{
+ user_data_url="http://169.254.169.254/1.0/user-data/"
+ user_data_file="/tmp/user_data"
+
+ #curl $user_data_url > $user_data_file
+
+ user_data=`cat $user_data_file`
+}
+
+function parse_jon_server_url
+{
+ ORIG_IFS=$IFS
+ IFS=$','
+
+ read -rda params <<< $user_data
+
+ IFS=$ORIG_IFS
+
+ for param in $params
+ do
+ idx=`expr index $param =`
+ key=${param:0:idx - 1}
+
+ if [ $key = jon.server.url ]; then
+ jon_server_url=${param:idx}
+ return 0
+ fi
+ done
+}
+
+function init
+{
+ force_init=$1
+ default_prefs=~/.java/.userPrefs/rhq-agent/default/prefs.xml
+
+ if [ -s $default_prefs ] && [ "force" != $force_init ]; then
+ echo "Default configuration found at $default_prefs. Skipping " \
+ "configuration. Run $SCRIPT_NAME <init> to force configuration " \
+ "of server endpoint URL."
+ fi
+
+ load_user_data
+ parse_jon_server_url
+
+ if [ -z $jon_server_url ]; then
+ echo "Warning: Failed find jon.server.url parameter. You need to " \
+ "manually set the rhq.agent.server.bind-address property in " \
+ "<RHQ_AGENT>/conf/agent-configuration.xml. Cannot start agent."
+ return 1
+ fi
+
+ export RHQ_AGENT_CMDLINE_OPTS="--daemon $RHQ_AGENT_CMDLINE_OPTS"
+ export RHQ_AGENT_CMDLINE_OPTS="-Drhq.agent.server.bind-address=$jon_server_url $RHQ_AGENT_CMDLINE_OPTS"
+
+ return 0
+}
+
+
+cd $RHQ_AGENT_HOME/bin
+
+case "$1" in
+'init')
+ init "force"
+ ;;
+'start')
+ if init
+ then
+ ./rhq-agent-wrapper.sh start
+ else
+ echo "Failed: Cannot start the agent do to previous initialization errors"
+ fi
+ ;;
+'stop')
+ ./rhq-agent-wrapper.sh stop
+ ;;
+'kill')
+ ./rhq-agent-wrapper.sh kill
+ ;;
+'status')
+ ./rhq-agent-wrapper.sh status
+ ;;
+'restart')
+ ./rhq-agent-wrapper.sh restart
+ ;;
+'quiet-restart')
+ ./rhq-agent-wrapper.sh quiet-restart
+ ;;
+'echo')
+ echo "script: $0"
+ ;;
+*)
+ echo "Usage: $0 { init | start | stop | kill | restart | status }"
+ exit 1
+ ;;
+esac
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
index 42dd631..1a51f43 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
@@ -87,6 +87,10 @@ public class AgentManagement implements AgentManagementMBean, MBeanRegistration
m_agent = agent;
}
+ public void switchToServer(String server) {
+ m_agent.switchToServer(server);
+ }
+
public void restart() {
// restarting the agent is a suicidal act - this MBean instance will
// be unregistered after we shutdown. Therefore, we must do this in a
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
index 62108a1..1be62dc 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
@@ -82,6 +82,8 @@ public interface AgentManagementMBean {
*/
String PLUGIN_INFO_MD5 = "md5";
+ void switchToServer(String server);
+
/**
* This will perform an agent <i>hot-restart</i>. The agent will be {@link #shutdown()} and then immediately started
* again. This is usually called after a client has
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
index ae89a83..b5c0ac9 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
@@ -51,6 +51,7 @@ import org.rhq.enterprise.server.alert.engine.internal.AlertConditionCacheCoordi
import org.rhq.enterprise.server.auth.SessionManager;
import org.rhq.enterprise.server.auth.prefs.SubjectPreferencesCache;
import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal;
+import org.rhq.enterprise.server.cloud.instance.SyncEndpointAddressException;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.core.CustomJaasDeploymentServiceMBean;
import org.rhq.enterprise.server.core.comm.ServerCommunicationsServiceUtil;
@@ -165,6 +166,13 @@ public class StartupServlet extends HttpServlet {
// Establish the current server mode for the server. This will move the server to NORMAL
// mode from DOWN if necessary. This can also affect comm layer behavior.
serverManager.establishCurrentServerMode();
+ if ("true".equals(System.getProperty("rhq.sync.endpoint-address", "false"))) {
+ try {
+ serverManager.syncEndpointAddress();
+ } catch (SyncEndpointAddressException e) {
+ log("Failed to sync server endpoint address.", e);
+ }
+ }
}
/**
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index 1ec4552..b4116aa 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -203,6 +203,8 @@
<property name="rhq.server.enable.ws" value="${rhq.server.enable.ws}" />
<property name="jbossws-native-dist.version" value="${jbossws-native-dist.version}" />
+
+ <property name="rhq.sync.endpoint-address" value="${rhq.sync.endpoint-address}"/>
</ant>
</tasks>
</configuration>
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index d45932d..c98dd12 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -20,6 +20,8 @@
<property name="default.rhq.server.quartz.selectWithLockSQL" value="SELECT * FROM {0}LOCKS WHERE LOCK_NAME = ? FOR UPDATE" />
<property name="default.rhq.server.quartz.lockHandlerClass" value="org.quartz.impl.jdbcjobstore.StdRowLockSemaphore" />
+ <property name="rhq.sync.endpoint-address" value="false"/>
+
<target name="set-predeploy-prop">
<condition property="predeploy" value="true">
<or>
@@ -604,6 +606,7 @@ rhq.server.plugin-scan-period-ms=${rhq.server.plugin-scan-period-ms}
rhq.autoinstall.enabled=false
rhq.autoinstall.database=auto
rhq.autoinstall.public-endpoint-address=
+rhq.sync.endpoint-address=${rhq.sync.endpoint-address}
</echo>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java
index cc2c565..be91c65 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerBean.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.server.cloud.instance;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Collection;
import java.util.List;
@@ -284,6 +286,19 @@ public class ServerManagerBean implements ServerManagerLocal {
Server.OperationMode.MAINTENANCE.name());
}
+ public void syncEndpointAddress() throws SyncEndpointAddressException {
+ Server server = getServer();
+ try {
+ String hostName = InetAddress.getLocalHost().getHostName();
+
+ if (!hostName.equals(server.getAddress())) {
+ server.setAddress(hostName);
+ }
+ } catch (UnknownHostException e) {
+ throw new SyncEndpointAddressException("Failed to sync endpoint address for " + server, e);
+ }
+ }
+
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void beat() {
Server server = getServer();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerLocal.java
index 135db97..04e244c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/ServerManagerLocal.java
@@ -102,6 +102,15 @@ public interface ServerManagerLocal {
void establishCurrentServerMode();
/**
+ * Synchronizes the endpoint address of this server with the host name or address found on the host machine. If the
+ * host name or address of this machine differs from {@link Server#getAddress()} then this server will be updated
+ * with the value of this machine's host name/address.
+ *
+ * @throws SyncEndpointAddressException
+ */
+ void syncEndpointAddress() throws SyncEndpointAddressException;
+
+ /**
* Updates server mtime to register active heart beat
*/
void beat();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/SyncEndpointAddressException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/SyncEndpointAddressException.java
new file mode 100644
index 0000000..a3924d7
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/instance/SyncEndpointAddressException.java
@@ -0,0 +1,20 @@
+package org.rhq.enterprise.server.cloud.instance;
+
+public class SyncEndpointAddressException extends Exception {
+
+ public SyncEndpointAddressException() {
+ super();
+ }
+
+ public SyncEndpointAddressException(String message) {
+ super(message);
+ }
+
+ public SyncEndpointAddressException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SyncEndpointAddressException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java
index 19c8eb8..5c61f8b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractJobWrapper.java
@@ -19,13 +19,18 @@
package org.rhq.enterprise.server.plugin.pc;
+import java.io.Serializable;
import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@@ -108,6 +113,9 @@ abstract class AbstractJobWrapper implements Job {
*/
public static final String DATAMAP_IS_CLUSTERED = DATAMAP_LEADER + "isClustered";
+ protected abstract ScheduledJobInvocationContext createContext(ScheduledJobDefinition jobDefinition,
+ ServerPluginContext pluginContext, ServerPluginComponent serverPluginComponent, Map<String, String> jobData);
+
/**
* This is the method that quartz calls when the schedule has triggered. This method will
* delegate to the plugin component that is responsible to do work for the plugin.
@@ -229,7 +237,7 @@ abstract class AbstractJobWrapper implements Job {
ScheduledJobDefinition jobDefinition = new ScheduledJobDefinition(jobId, true, jobClass, jobMethodName,
scheduleType, callbackData);
ServerPluginContext pluginContext = pluginManager.getServerPluginContext(pluginEnv);
- params[0] = new ScheduledJobInvocationContext(jobDefinition, pluginContext, pluginComponent);
+ params[0] = createContext(jobDefinition, pluginContext, pluginComponent,dataMap);
} catch (NoSuchMethodException e) {
try {
// see if there is a no-arg method of the given name
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java
index b8e760c..c7fc556 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/AbstractTypeServerPluginContainer.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.plugin.pc;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ConcurrentJobWrapper.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ConcurrentJobWrapper.java
index 13cbfc4..dfbb941 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ConcurrentJobWrapper.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ConcurrentJobWrapper.java
@@ -19,6 +19,10 @@
package org.rhq.enterprise.server.plugin.pc;
+import java.util.Map;
+
+import org.rhq.enterprise.server.xmlschema.ScheduledJobDefinition;
+
/**
* The actual quartz job that the plugin container will submit when it needs to invoke
* a concurrent scheduled job on behalf of a plugin. This is a normal non-stateful "job"
@@ -31,4 +35,9 @@ package org.rhq.enterprise.server.plugin.pc;
* @author John Mazzitelli
*/
public class ConcurrentJobWrapper extends AbstractJobWrapper {
+ @Override
+ protected ScheduledJobInvocationContext createContext(ScheduledJobDefinition jobDefinition,
+ ServerPluginContext pluginContext, ServerPluginComponent serverPluginComponent, Map<String, String> jobData) {
+ return new ScheduledJobInvocationContext(jobDefinition, pluginContext, serverPluginComponent);
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ScheduledJobInvocationContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ScheduledJobInvocationContext.java
index cdb0ebf..b69fc9c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ScheduledJobInvocationContext.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ScheduledJobInvocationContext.java
@@ -19,12 +19,26 @@
package org.rhq.enterprise.server.plugin.pc;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
import org.rhq.enterprise.server.xmlschema.ScheduledJobDefinition;
/**
+ * <p>
* A scheduled job's invocation method can take a single argument of this type.
* If this is the case, the scheduled job's method will be passed an object of this type enabling
* the job being invoked to be given information about the invocation.
+ * </p>
+ * <p>
+ * When a job is <strong>not</strong> marked for concurrent execution, it can store data in the context in the form of
+ * key/value properties. These properties will be persisted across invocations of the job. If the job is marked to as
+ * clustered, the job data will persist across server restarts as well. Lastly, if the job is marked to run
+ * concurrently, the methods for accessing/updating properties will throw an exception.
+ * </p>
*
* @author John Mazzitelli
*/
@@ -68,4 +82,60 @@ public class ScheduledJobInvocationContext {
public ServerPluginComponent getServerPluginComponent() {
return serverPluginComponent;
}
+
+ /**
+ * Adds a property to the context that is persisted across invocations of the job. The property is persisted across
+ * server restarts <strong>only if</strong> the scheduled job is declared to run as clustered. Note that method
+ * will throw an exception if the job is declared for concurrent execution.
+ *
+ * @param key The property name
+ * @param value The property value
+ * @throws UnsupportedOperationException if the job is marked for concurrent execution
+ */
+ public void put(String key, String value) {
+ throw new UnsupportedOperationException("This operation is only supported for stateful jobs.");
+ }
+
+ /**
+ * Retrieves a property value from the context.
+ *
+ * @param key The property key
+ * @return The property value or <code>null<code> if the key is not found
+ * @throws UnsupportedOperationException if the job is marked for concurrent execution
+ */
+ public String get(String key) {
+ throw new UnsupportedOperationException("This operation is only supported for stateful jobs.");
+ }
+
+ /**
+ * Removes the property value associated with the specified key
+ *
+ * @param key The property key
+ * @return The value previously associated with the key or <code>null</code> if the key is present in the context
+ * @throws UnsupportedOperationException if the job is marked for concurrent execution
+ */
+ public String remove(String key) {
+ throw new UnsupportedOperationException("This operation is only supported for stateful jobs.");
+ }
+
+ /**
+ * Checks to see whether or not the property key is stored in the context.
+ * @param key The property key
+ * @return <code>true</code> if the key is found, <code>false</code> otherwise.
+ * @throws UnsupportedOperationException if the job is marked for concurrent execution
+ */
+ public boolean containsKey(String key) {
+ throw new UnsupportedOperationException("This operation is only supported for stateful jobs.");
+ }
+
+ /**
+ * Returns a <strong>read-only</strong> view of the properties stored in the context.
+ *
+ * @return A <strong>read-only</strong> view of the properties stored in the context.
+ * @throws UnsupportedOperationException if the job is marked for concurrent execution
+ */
+ public Map<String, String> getJobData() {
+ throw new UnsupportedOperationException("This operation is only supported for stateful jobs.");
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulJobWrapper.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulJobWrapper.java
index d04558b..61a151a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulJobWrapper.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulJobWrapper.java
@@ -19,8 +19,12 @@
package org.rhq.enterprise.server.plugin.pc;
+import java.util.Map;
+
import org.quartz.StatefulJob;
+import org.rhq.enterprise.server.xmlschema.ScheduledJobDefinition;
+
/**
* The actual quartz job that the plugin container will submit when it needs to invoke
* a scheduled job on behalf of a plugin. This is a "stateful job" which tells quartz
@@ -33,4 +37,9 @@ import org.quartz.StatefulJob;
* @author John Mazzitelli
*/
public class StatefulJobWrapper extends AbstractJobWrapper implements StatefulJob {
+ @Override
+ protected ScheduledJobInvocationContext createContext(ScheduledJobDefinition jobDefinition,
+ ServerPluginContext pluginContext, ServerPluginComponent serverPluginComponent, Map<String, String> jobData) {
+ return new StatefulScheduledJobInvocationContext(jobDefinition, pluginContext, serverPluginComponent, jobData);
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulScheduledJobInvocationContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulScheduledJobInvocationContext.java
new file mode 100644
index 0000000..c526400
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/StatefulScheduledJobInvocationContext.java
@@ -0,0 +1,65 @@
+package org.rhq.enterprise.server.plugin.pc;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.rhq.enterprise.server.xmlschema.ScheduledJobDefinition;
+
+public class StatefulScheduledJobInvocationContext extends ScheduledJobInvocationContext {
+ private Map<String, String> jobData;
+
+ public StatefulScheduledJobInvocationContext(ScheduledJobDefinition jobDefinition,
+ ServerPluginContext pluginContext, ServerPluginComponent serverPluginComponent, Map<String, String> jobData) {
+ super(jobDefinition, pluginContext, serverPluginComponent);
+ this.jobData = jobData;
+ }
+
+ /**
+ * Adds a property to the context that is persisted across invocations of the job.
+ *
+ * @param key The property name
+ * @param value The property value
+ */
+ public void put(String key, String value) {
+ jobData.put(key, value);
+ }
+
+ /**
+ * Retrieves a property value from the context.
+ *
+ * @param key The property key
+ * @return The property value or <code>null<code> if the key is not found
+ */
+ public String get(String key) {
+ return jobData.get(key);
+ }
+
+ /**
+ * Removes the property value associated with the specified key
+ *
+ * @param key The property key
+ * @return The value previously associated with the key or <code>null</code> if the key is present in the context
+ */
+ public String remove(String key) {
+ return jobData.remove(key);
+ }
+
+ /**
+ * Checks to see whether or not the property key is stored in the context.
+ * @param key The property key
+ * @return <code>true</code> if the key is found, <code>false</code> otherwise.
+ */
+ public boolean containsKey(String key) {
+ return jobData.containsKey(key);
+ }
+
+ /**
+ * Returns a <strong>read-only</strong> view of the properties stored in the context.
+ *
+ * @return A <strong>read-only</strong> view of the properties stored in the context.
+ */
+ public Map<String, String> getJobData() {
+ return Collections.unmodifiableMap(jobData);
+ }
+
+}
diff --git a/modules/enterprise/server/plugins/cloud/pom.xml b/modules/enterprise/server/plugins/cloud/pom.xml
new file mode 100644
index 0000000..8d10fcd
--- /dev/null
+++ b/modules/enterprise/server/plugins/cloud/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server-plugins-parent</artifactId>
+ <version>3.0.1-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-serverplugin-cloud</artifactId>
+
+ <name>RHQ Enterprise Server Cloud Plugin</name>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/server/...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/server/...</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/enterprise/server/plugins/cloud/</scm.module.path>
+ <cobber4j.version>0.1</cobber4j.version>
+ </properties>
+
+ <dependencies>
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <!--
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy-libs</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <!--
+ <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
+ -->
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-serverplugins</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}/${project.build.finalName}.jar" />
+ <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}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**" />
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+</project>
diff --git a/modules/enterprise/server/plugins/cloud/src/main/java/org/rhq/enterprise/server/plugins/cloud/CloudServerPluginComponent.java b/modules/enterprise/server/plugins/cloud/src/main/java/org/rhq/enterprise/server/plugins/cloud/CloudServerPluginComponent.java
new file mode 100644
index 0000000..88eb3ba
--- /dev/null
+++ b/modules/enterprise/server/plugins/cloud/src/main/java/org/rhq/enterprise/server/plugins/cloud/CloudServerPluginComponent.java
@@ -0,0 +1,193 @@
+package org.rhq.enterprise.server.plugins.cloud;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.cloud.Server;
+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.resource.Agent;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.cloud.CloudManagerLocal;
+import org.rhq.enterprise.server.operation.OperationManagerLocal;
+import org.rhq.enterprise.server.operation.ResourceOperationSchedule;
+import org.rhq.enterprise.server.plugin.pc.ControlFacet;
+import org.rhq.enterprise.server.plugin.pc.ControlResults;
+import org.rhq.enterprise.server.plugin.pc.ScheduledJobInvocationContext;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class CloudServerPluginComponent implements ServerPluginComponent, ControlFacet {
+
+ private static Log log = LogFactory.getLog(CloudServerPluginComponent.class);
+
+ public void initialize(ServerPluginContext context) throws Exception {
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public void shutdown() {
+ }
+
+ public ControlResults invoke(String name, Configuration parameters) {
+ if ("syncServerEndpoint".equals(name)) {
+ String serverName = parameters.getSimpleValue("name", null);
+ String serverAddr = parameters.getSimpleValue("address", null);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Invoked syncServerEndpoint with [name: " + serverName + ", address: " + serverAddr + "]");
+ }
+
+ ControlResults results = new ControlResults();
+
+ CloudManagerLocal cloudMgr = LookupUtil.getCloudManager();
+ Server server = cloudMgr.getServerByName(serverName);
+
+ if (server == null) {
+ log.warn("Failed to locate server. No address sync will be performed.");
+ results.setError("No update performed. Failed to find server " + server.getName());
+ return results;
+ }
+
+ if (serverAddr != null) {
+ SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
+
+ server.setAddress(serverAddr);
+ cloudMgr.updateServer(subjectMgr.getOverlord(), server);
+ }
+
+ int updateCount = notifyAgents(server);
+
+ Configuration complexResults = results.getComplexResults();
+ complexResults.put(new PropertySimple("results", updateCount + " agents have been updated."));
+
+ if (log.isDebugEnabled()) {
+ log.debug("Notified " + updateCount + " agents of the address change.");
+ }
+
+ return results;
+ }
+
+ return null;
+ }
+
+ public void syncServerEndpoints(ScheduledJobInvocationContext context) {
+ log.debug("Preparing to sync server endpoints.");
+
+ CloudManagerLocal cloudMgr = LookupUtil.getCloudManager();
+ List<Server> servers = cloudMgr.getAllServers();
+
+ purgeStaleServers(context, servers);
+
+ for (Server server : servers) {
+ if (!context.containsKey("server:" + server.getName())) {
+ log.debug("Adding server [" + server.getName() + "] to sync list.");
+ context.put("server:" + server.getName(), server.getAddress());
+ } else if (addressChanged(context, server)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Detected address change for " + server);
+ log.debug("Old address was " + context.get("server:" + server.getName() + ", new address is " +
+ server.getAddress()));
+ }
+ context.put("server:" + server.getName(), server.getAddress());
+ notifyAgents(server);
+ }
+ }
+ }
+
+ private void purgeStaleServers(ScheduledJobInvocationContext context, List<Server> servers) {
+ List<String> purgeList = new ArrayList<String>();
+
+ Set<String> serverNames = new HashSet<String>();
+ for (Server server : servers) {
+ serverNames.add(server.getName());
+ }
+
+ for (String key : context.getJobData().keySet()) {
+ if (key.startsWith("server:")) {
+ String serverName = parseServerName(key);
+ if (!serverNames.contains(serverName)) {
+ log.debug("Detected a stale server: " + serverName);
+ log.debug(serverName + " will be removed from the sync list.");
+ purgeList.add(key);
+ }
+ }
+ }
+
+ for (String staleServer : purgeList) {
+ context.remove(staleServer);
+ }
+ }
+
+ private String parseServerName(String key) {
+ return key.substring("server:".length());
+ }
+
+ private boolean addressChanged(ScheduledJobInvocationContext context, Server server) {
+ String lastKnownAddr = context.get("server:" + server.getName());
+ return !server.getAddress().endsWith(lastKnownAddr);
+ }
+
+ @SuppressWarnings("unchecked")
+ private int notifyAgents(Server server) {
+ EntityManager entityMgr = LookupUtil.getEntityManager();
+ String queryString = "select r " +
+ "from Resource r " +
+ "where r.resourceType.plugin = :pluginName and " +
+ "r.resourceType.name = :resourceTypeName and " +
+ "r.agent in (select a " +
+ "from Agent a " +
+ "where a.server = :server)";
+
+ List<Resource> agents = entityMgr.createQuery(queryString)
+ .setParameter("pluginName", "RHQAgent")
+ .setParameter("resourceTypeName", "RHQ Agent")
+ .setParameter("server", server)
+ .getResultList();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Found " + agents.size() + " to be updated with new server endpoint for " + server);
+ }
+
+ int numUpdated = 0;
+ for (Resource agent : agents) {
+ updateAgent(agent, server);
+ numUpdated++;
+ }
+
+ return numUpdated;
+ }
+
+ private void updateAgent(Resource agent, Server server) {
+ OperationManagerLocal operationMgr = LookupUtil.getOperationManager();
+ SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
+
+ Configuration params = new Configuration();
+ params.put(new PropertySimple("server", server.getAddress()));
+
+ ResourceOperationSchedule schedule = operationMgr.scheduleResourceOperation(subjectMgr.getOverlord(),
+ agent.getId(), "switchToServer", 0, 0, 0, 0, params, "Cloud Plugin: syncing server endpoint address");
+
+ if (log.isDebugEnabled()) {
+ log.debug("Schedule address sync for agent [name: " + agent.getName() + "].");
+ log.debug("Operation schedule is " + schedule);
+ }
+ }
+}
diff --git a/modules/enterprise/server/plugins/cloud/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/cloud/src/main/resources/META-INF/rhq-serverplugin.xml
new file mode 100644
index 0000000..e6944c0
--- /dev/null
+++ b/modules/enterprise/server/plugins/cloud/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -0,0 +1,57 @@
+<generic-plugin name="CloudServerPlugin"
+ displayName="Cloud"
+ description=""
+ package="org.rhq.enterprise.server.plugins.cloud"
+ disabledOnDiscovery="false"
+ xmlns="urn:xmlns:rhq-serverplugin.generic"
+ xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+ <serverplugin:plugin-component class="CloudServerPluginComponent">
+ <serverplugin:control name="syncServerEndpoint" description="">
+ <serverplugin:parameters>
+ <c:simple-property name="name"
+ required="true"
+ description="The server name"/>
+ <c:simple-property name="address"
+ required="false"
+ description="If an address is specified, it will overwrite the server's current value
+ in the database. If an address is not specified then the server's
+ current address will be sent down to its agents."/>
+ </serverplugin:parameters>
+ <serverplugin:results>
+ <c:simple-property name="results" description="Contains a status or error message"/>
+ </serverplugin:results>
+ </serverplugin:control>
+ </serverplugin:plugin-component>
+
+ <serverplugin:scheduled-jobs>
+ <c:map-property name="syncServerEndpoints">
+ <c:simple-property name="scheduleType"
+ type="string"
+ required="true"
+ default="periodic"
+ summary="true"
+ description="Indicates the type of trigger this synchronize job will use">
+ <c:property-options>
+ <c:option value="periodic" default="true"/>
+ <c:option value="cron"/>
+ </c:property-options>
+ </c:simple-property>
+ <c:simple-property name="scheduleTrigger" default="300000"/>
+ <c:simple-property name="concurrent"
+ type="boolean"
+ required="true"
+ default="false"
+ summary="false"
+ readOnly="true"
+ description="This must always be false - only want one sync job running at a time"/>
+ <c:simple-property name="clustered"
+ type="boolean"
+ required="true"
+ default="true"
+ summary="false"
+ readOnly="true"
+ description="This must always be true"/>
+ </c:map-property>
+ </serverplugin:scheduled-jobs>
+</generic-plugin>
\ No newline at end of file
diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java
index 2c83140..d352ae9 100644
--- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java
+++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java
@@ -194,6 +194,9 @@ public class AgentServerComponent extends JMXServerComponent implements JMXCompo
throw eie;
}
}
+ } else if (name.equals("switchToServer")) {
+ String server = params.getSimpleValue("server", null);
+ getAgentBean().getOperation(name).invoke(server);
} else {
// this should really never happen
throw new IllegalArgumentException("Operation [" + name + "] does not support params");
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index 2361c2d..438cbd5 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -170,6 +170,17 @@
</results>
</operation>
+ <operation name="switchToServer"
+ description="Tell the agent to immediately switch to another server. The given server can be a simple
+ hostname in which case, the current transport, port and transport parameters being used to
+ talk to the current server will stay the same. Otherwise, it will be assumed the server
+ is a full endpoint URL.">
+ <parameters>
+ <c:simple-property name="server" description="A simple hostname or a full endpoint URL"
+ required="true"/>
+ </parameters>
+ </operation>
+
<metric property="Trait.SigarVersion"
displayName="SIGAR Version"
dataType="trait"
diff --git a/pom.xml b/pom.xml
index ba31907..3c49e2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -147,6 +147,18 @@
<rhq.server.enable.ws>false</rhq.server.enable.ws>
+ <!--
+ When this property is set to true will compare its endpoint address
+ that is stored in the database against the actual host name/IP address
+ returned by the host system. If they differ, the address stored in the
+ datbase will be updated to the value found on the host machine. While
+ host name changes are/should be uncommon in a typical deployment, they
+ are more common in a cloud deployment such as EC2. And in a cloud
+ deployment like EC2, we want to turn this behavior on to ensure that
+ the server endpoint accurately reflects the current machine address.
+ -->
+ <rhq.sync.endpoint-address>false</rhq.sync.endpoint-address>
+
<!-- NOTE: The below line is a workaround for a Maven bug, where it does not expand settings.* properties
used in the distributionManagement section of the POM. -->
<localRepository>${user.home}/.m2/repository</localRepository>
commit 7998b60510c104396ceac2d5492bcc6324dcea16
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 14 14:41:19 2011 -0400
Try and improve portlet layout by better lining up recent/sched columns.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 4e1aac7..f7e3ee4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -81,8 +81,12 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
//TODO: change this to use the Smart GWT default value.
public static String RANGE_DISABLED_MESSAGE_DEFAULT = MSG.common_msg_noItemsToShow();
- private static String recentOperations = MSG.common_title_recent_operations();
- private static String scheduledOperations = MSG.common_title_scheduled_operations();
+ private static final String RECENT_OPERATIONS = MSG.common_title_recent_operations();
+ private static final String SCHEDULED_OPERATIONS = MSG.common_title_scheduled_operations();
+
+ private static final int WIDTH_RECENT_TIME = 150;
+ private static final int WIDTH_RECENT_STATUS = 50;
+ private static final int WIDTH_SCHEDULED_TIME = WIDTH_RECENT_TIME + WIDTH_RECENT_STATUS;
// set on initial configuration, the window for this portlet view.
private PortletWindow portletWindow;
@@ -114,10 +118,10 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
protected void onInit() {
super.onInit();
- this.recentOperationsGrid = new LocatableListGrid(recentOperations);
+ this.recentOperationsGrid = new LocatableListGrid(RECENT_OPERATIONS);
recentOperationsGrid.setDataSource(getDataSourceCompleted());
recentOperationsGrid.setAutoFetchData(true);
- recentOperationsGrid.setTitle(recentOperations);
+ recentOperationsGrid.setTitle(RECENT_OPERATIONS);
recentOperationsGrid.setWidth100();
//defining header span
String[] completedRows = new String[] { //
@@ -126,7 +130,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
RecentOperationsDataSource.Field.OPERATION.propertyName(), //
RecentOperationsDataSource.Field.TIME.propertyName(), //
RecentOperationsDataSource.Field.STATUS.propertyName() };
- recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, completedRows));
+ recentOperationsGrid.setHeaderSpans(new HeaderSpan(RECENT_OPERATIONS, completedRows));
recentOperationsGrid.setHeaderSpanHeight(20);
recentOperationsGrid.setHeaderHeight(40);
recentOperationsGrid.setResizeFieldsInRealTime(true);
@@ -135,21 +139,21 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
addMember(recentOperationsGrid);
// Add the list table as the top half of the view.
- this.scheduledOperationsGrid = new LocatableListGrid(scheduledOperations);
+ this.scheduledOperationsGrid = new LocatableListGrid(SCHEDULED_OPERATIONS);
scheduledOperationsGrid.setDataSource(getDataSourceScheduled());
scheduledOperationsGrid.setAutoFetchData(true);
- scheduledOperationsGrid.setTitle(scheduledOperations);
+ scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS);
scheduledOperationsGrid.setWidth100();
String[] scheduledRows = new String[] { //
ScheduledOperationsDataSource.Field.RESOURCE.propertyName(), //
AncestryUtil.RESOURCE_ANCESTRY, //
ScheduledOperationsDataSource.Field.OPERATION.propertyName(), //
ScheduledOperationsDataSource.Field.TIME.propertyName() };
- scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, scheduledRows));
+ scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(SCHEDULED_OPERATIONS, scheduledRows));
scheduledOperationsGrid.setHeaderSpanHeight(20);
scheduledOperationsGrid.setHeaderHeight(40);
- scheduledOperationsGrid.setTitle(scheduledOperations);
+ scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS);
scheduledOperationsGrid.setResizeFieldsInRealTime(true);
scheduledOperationsGrid.setCellHeight(50);
scheduledOperationsGrid.setWrapCells(true);
@@ -193,10 +197,10 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
RecentOperationsDataSource.Field.OPERATION.title());
ListGridField timeRecent = new ListGridField(RecentOperationsDataSource.Field.TIME.propertyName(),
- RecentOperationsDataSource.Field.TIME.title(), 150);
+ RecentOperationsDataSource.Field.TIME.title(), WIDTH_RECENT_TIME);
ListGridField statusRecent = new ListGridField(RecentOperationsDataSource.Field.STATUS.propertyName(),
- RecentOperationsDataSource.Field.STATUS.title(), 50);
+ RecentOperationsDataSource.Field.STATUS.title(), WIDTH_RECENT_STATUS);
statusRecent.setAlign(Alignment.CENTER);
recentOperationsGrid.setFields(resourceRecent, ancestryRecent, operationRecent, timeRecent, statusRecent);
@@ -233,7 +237,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
ScheduledOperationsDataSource.Field.OPERATION.title());
ListGridField timeNext = new ListGridField(ScheduledOperationsDataSource.Field.TIME.propertyName(),
- ScheduledOperationsDataSource.Field.TIME.title(), 150);
+ ScheduledOperationsDataSource.Field.TIME.title(), WIDTH_SCHEDULED_TIME);
scheduledOperationsGrid.setFields(resourceNext, ancestryNext, operationNext, timeNext);
}
commit 3b64aac3b9f1e0809c9934272cfb13b224ada082
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 14 14:40:34 2011 -0400
Reduce verbosity on some Alert Condition text display. The 'Exceeds' is
unnecessary, takes up valuable column space, and is, I think, confusing
when not using a greater-than operator.
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 ac808be..8293144 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
@@ -1048,15 +1048,15 @@ view_alert_common_tab_conditions_value = Value
view_alert_common_tab_conditions_type_availability = Availability Change
view_alert_common_tab_conditions_type_availability_down = Went down
view_alert_common_tab_conditions_type_availability_up = Came up
-view_alert_common_tab_conditions_type_metric_threshold = Metric Value Exceeds Threshold
-view_alert_common_tab_conditions_type_metric_calltime_threshold = Call Time Value Exceeds Threshold
+view_alert_common_tab_conditions_type_metric_threshold = Metric Value Threshold
+view_alert_common_tab_conditions_type_metric_calltime_threshold = Call Time Value Threshold
view_alert_common_tab_conditions_type_metric_calltime_destination = with call destination matching
view_alert_common_tab_conditions_type_metric_calltime_change = Call Time Value Changes
view_alert_common_tab_conditions_type_metric_calltime_change_verb = by at least
view_alert_common_tab_conditions_type_metric_calltime_delta_grows = Grows
view_alert_common_tab_conditions_type_metric_calltime_delta_shrinks = Shrinks
view_alert_common_tab_conditions_type_metric_calltime_delta_other = Changes
-view_alert_common_tab_conditions_type_metric_baseline = Metric Value Exceeds Baseline
+view_alert_common_tab_conditions_type_metric_baseline = Metric Value Baseline
view_alert_common_tab_conditions_type_metric_baseline_verb = of
view_alert_common_tab_conditions_type_metric_change = Metric Value Change
view_alert_common_tab_conditions_type_metric_trait_change = Trait Change
commit 032810bc2ba918cdd1691593f7abd3259a667a57
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 14 13:59:37 2011 -0400
Resource Ancestry (Disambiguation) Work
Incorporate feedback into design and perform some refactoring to clean up
impl.
- Keep Name and Ancestry fields simple with only linked resource names displayed
- Enhance hover values for both Name (with type info) and Ancestry (with hierarchy and type info)
- Move more logic to AncestryUtil for simplified Impl. Use standard Record
attributes, defined here, across Ancestry using datasources and views.
- Remove Ancestry and in some places, Type as DS fields. These should be DS
fields, only, if necessary, ListGrid fields.
- Add Ancestry to AlertDataSource and its users
- Fix issue with the Ancestry hover for Assigned resources in Resource
Selector.
- Added Resource filtering prior to gwt serialization for Alerts.
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 02c76a2..db11bdd 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
@@ -20,7 +20,9 @@ package org.rhq.enterprise.gui.coregui.client.alert;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import com.allen_sauer.gwt.log.client.Log;
@@ -47,6 +49,8 @@ import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.alert.notification.AlertNotificationLog;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.AlertCriteria;
+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;
@@ -54,6 +58,9 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.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.MeasurementConverterClient;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
@@ -109,7 +116,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
ListGridField nameField = new ListGridField("name", MSG.view_alerts_field_name());
nameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- Integer resourceId = listGridRecord.getAttributeAsInt("resourceId");
+ Integer resourceId = listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
Integer defId = listGridRecord.getAttributeAsInt("definitionId");
String url = LinkManager.getSubsystemAlertDefinitionLink(resourceId, defId);
return SeleniumUtility.getLocatableHref(url, o.toString(), null);
@@ -157,25 +164,48 @@ public class AlertDataSource extends RPCDataSource<Alert> {
fields.add(statusField);
if (this.entityContext.type != EntityContext.Type.Resource) {
- // TODO need to disambiguate this
- ListGridField resourceNameField = new ListGridField("resourceName", MSG.view_alerts_field_resource());
+ ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG
+ .view_alerts_field_resource());
resourceNameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- Integer resourceId = listGridRecord.getAttributeAsInt("resourceId");
- String url = LinkManager.getResourceLink(resourceId);
+ 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);
+ }
+ });
fields.add(resourceNameField);
- ctimeField.setWidth(100);
- nameField.setWidth("25%");
- conditionField.setWidth("40%");
+ 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);
+
+ ctimeField.setWidth(125);
+ nameField.setWidth("20%");
+ conditionField.setWidth("30%");
priorityField.setWidth(50);
- statusField.setWidth("15%");
- resourceNameField.setWidth("20%");
+ statusField.setWidth("80");
+ resourceNameField.setWidth("25%");
+ ancestryField.setWidth("25%");
} else {
- ctimeField.setWidth(100);
+ ctimeField.setWidth(125);
nameField.setWidth("35%");
conditionField.setWidth("40%");
priorityField.setWidth(50);
@@ -201,9 +231,54 @@ public class AlertDataSource extends RPCDataSource<Alert> {
public void onSuccess(PageList<Alert> result) {
long fetchTime = System.currentTimeMillis() - start;
Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
- response.setData(buildRecords(result));
- // For paging to work, we have to specify size of full result set.
- response.setTotalRows(result.getTotalSize());
+
+ if (entityContext.type != EntityContext.Type.Resource) {
+ dataRetrieved(result, response, request);
+ } else {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
+ processResponse(request.getRequestId(), response);
+ }
+ }
+ });
+ }
+
+ /**
+ * Additional processing to support a cross-resource view)
+ * @param result
+ * @param response
+ * @param request
+ */
+ protected void dataRetrieved(final PageList<Alert> result, final DSResponse response, final DSRequest request) {
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (Alert alert : result) {
+ Resource resource = alert.getAlertDefinition().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);
}
});
@@ -240,11 +315,16 @@ public class AlertDataSource extends RPCDataSource<Alert> {
record.setAttribute("acknowledgingSubject", from.getAcknowledgingSubject());
record.setAttribute("definitionId", from.getAlertDefinition().getId());
- record.setAttribute("resourceId", from.getAlertDefinition().getResource().getId());
- record.setAttribute("resourceName", from.getAlertDefinition().getResource().getName());
+ Resource resource = from.getAlertDefinition().getResource();
record.setAttribute("name", from.getAlertDefinition().getName());
record.setAttribute("priority", ImageManager.getAlertIcon(from.getAlertDefinition().getPriority()));
+ // 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());
+
Set<AlertConditionLog> conditionLogs = from.getConditionLogs();
String conditionText;
String conditionValue;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
index 721b559..f80a435 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
@@ -1,6 +1,5 @@
package org.rhq.enterprise.gui.coregui.client.alert;
-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;
@@ -96,11 +95,7 @@ public class AlertPortletDataSource extends AlertDataSource {
}
public void onSuccess(PageList<Alert> result) {
- long fetchTime = System.currentTimeMillis() - start;
- Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
+ dataRetrieved(result, response, request);
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 54f6d41..4e1aac7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -42,13 +42,14 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
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.inventory.resource.ResourceDatasource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
@@ -57,6 +58,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A view that displays a live table of completed Operations and scheduled operations.
@@ -120,7 +122,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
//defining header span
String[] completedRows = new String[] { //
RecentOperationsDataSource.Field.RESOURCE.propertyName(), //
- RecentOperationsDataSource.Field.ANCESTRY.propertyName(), //
+ AncestryUtil.RESOURCE_ANCESTRY, //
RecentOperationsDataSource.Field.OPERATION.propertyName(), //
RecentOperationsDataSource.Field.TIME.propertyName(), //
RecentOperationsDataSource.Field.STATUS.propertyName() };
@@ -140,7 +142,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
scheduledOperationsGrid.setWidth100();
String[] scheduledRows = new String[] { //
ScheduledOperationsDataSource.Field.RESOURCE.propertyName(), //
- ScheduledOperationsDataSource.Field.ANCESTRY.propertyName(), //
+ AncestryUtil.RESOURCE_ANCESTRY, //
ScheduledOperationsDataSource.Field.OPERATION.propertyName(), //
ScheduledOperationsDataSource.Field.TIME.propertyName() };
scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, scheduledRows));
@@ -161,20 +163,29 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
ListGridField resourceRecent = new ListGridField(RecentOperationsDataSource.Field.RESOURCE.propertyName(),
RecentOperationsDataSource.Field.RESOURCE.title());
+ resourceRecent.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);
+ }
+ });
+ resourceRecent.setShowHover(true);
+ resourceRecent.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
- ListGridField ancestryRecent = new ListGridField(RecentOperationsDataSource.Field.ANCESTRY.propertyName(),
- RecentOperationsDataSource.Field.ANCESTRY.title());
+ ListGridField ancestryRecent = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
ancestryRecent.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES);
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
}
});
ancestryRecent.setShowHover(true);
ancestryRecent.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return "<p style='width:400px'>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>";
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
}
});
@@ -192,20 +203,29 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
ListGridField resourceNext = new ListGridField(ScheduledOperationsDataSource.Field.RESOURCE.propertyName(),
ScheduledOperationsDataSource.Field.RESOURCE.title());
+ resourceNext.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);
+ }
+ });
+ resourceNext.setShowHover(true);
+ resourceNext.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
- ListGridField ancestryNext = new ListGridField(ScheduledOperationsDataSource.Field.ANCESTRY.propertyName(),
- ScheduledOperationsDataSource.Field.ANCESTRY.title());
+ ListGridField ancestryNext = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
ancestryNext.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES);
+ return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE);
}
});
ancestryNext.setShowHover(true);
ancestryNext.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return "<p style='width:400px'>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>";
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 7e6cf94..24820ec 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems
//import java.text.SimpleDateFormat;
import static org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource.Field.ALERTS;
-import static org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource.Field.ANCESTRY;
import static org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource.Field.AVAILABILITY;
import static org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource.Field.RESOURCE;
@@ -49,6 +48,7 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget;
@@ -57,12 +57,13 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A view that displays a paginated table of Resources with alerts,
@@ -121,19 +122,30 @@ public class ProblemResourcesPortlet extends Table<ProblemResourcesDataSource> i
}
ListGridField resourceField = new ListGridField(RESOURCE.propertyName(), RESOURCE.title());
+ resourceField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("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);
+ }
+ });
- ListGridField ancestryField = new ListGridField(ANCESTRY.propertyName(), ANCESTRY.title());
+ 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(ResourceDatasource.ATTR_ANCESTRY_RESOURCES);
+ 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 "<p style='width:400px'>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>";
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
}
});
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 c2e47fa..edb9ff7 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,6 +43,7 @@ import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
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;
@@ -247,8 +248,7 @@ public abstract class AbstractOperationHistoryListView<T extends AbstractOperati
}
protected ListGridField createAncestryField() {
- ListGridField ancestryField = new ListGridField(ResourceOperationHistoryDataSource.Field.ANCESTRY, MSG
- .common_title_ancestry());
+ ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry());
ancestryField.setAlign(Alignment.LEFT);
ancestryField.setCellAlign(Alignment.LEFT);
return ancestryField;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
index 587a8ca..e678426 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
@@ -23,30 +23,77 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.Overflow;
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.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
/**
* @author Jay Shaughnessy
*/
public class ResourceGroupResourceSelector extends ResourceSelector {
+ Collection<Resource> resources;
+
public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources,
ResourceType resourceTypeFilter, boolean forceResourceTypeFilter) {
super(locatorId, resourceTypeFilter, forceResourceTypeFilter);
- if (null != resources) {
- ListGridRecord[] data = (new ResourceDatasource()).buildRecords(resources);
- setAssigned(data);
- }
+ this.resources = resources;
this.setOverflow(Overflow.AUTO);
}
+
+ @Override
+ protected void onInit() {
+
+ if (null != this.resources) {
+ // to properly handle ancestry we need to provide the LGRecords with necessary ResourceType info for
+ // the initially assigned resources
+
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (Resource resource : this.resources) {
+ 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);
+
+ ListGridRecord[] records = (new ResourceDatasource()).buildRecords(resources);
+
+ 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);
+ }
+
+ setAssigned(records);
+ ResourceGroupResourceSelector.super.onInit();
+ }
+ });
+ } else {
+ super.onInit();
+ }
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
index 8132abd..da178c4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
@@ -1,30 +1,37 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history;
+import java.util.ArrayList;
+import java.util.List;
+
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
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.AncestryUtil;
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;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Ian Springer
*/
-public class GroupMemberResourceOperationHistoryListView
- extends AbstractOperationHistoryListView<ResourceOperationHistoryDataSource> {
+public class GroupMemberResourceOperationHistoryListView extends
+ AbstractOperationHistoryListView<ResourceOperationHistoryDataSource> {
private ResourceGroupComposite groupComposite;
public GroupMemberResourceOperationHistoryListView(String locatorId, ResourceGroupComposite groupComposite,
- int groupOperationHistoryId) {
- super(locatorId, new ResourceOperationHistoryDataSource(), null,
- new Criteria(ResourceOperationHistoryDataSource.CriteriaField.GROUP_OPERATION_HISTORY_ID,
- String.valueOf(groupOperationHistoryId)));
+ int groupOperationHistoryId) {
+ super(locatorId, new ResourceOperationHistoryDataSource(), null, new Criteria(
+ ResourceOperationHistoryDataSource.CriteriaField.GROUP_OPERATION_HISTORY_ID, String
+ .valueOf(groupOperationHistoryId)));
this.groupComposite = groupComposite;
}
@@ -37,9 +44,37 @@ public class GroupMemberResourceOperationHistoryListView
fields.add(idField);
ListGridField resourceField = createResourceField();
- resourceField.setWidth("70%");
+ resourceField.setWidth("25%");
+ resourceField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("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.setWidth("35%");
+ 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);
+
ListGridField statusField = createStatusField();
fields.add(statusField);
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 6dd55ac..33a5246 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
@@ -22,6 +22,9 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
+import com.smartgwt.client.data.Record;
+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.LinkManager;
@@ -34,6 +37,16 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*/
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";
+ public static final String RESOURCE_ANCESTRY_HOVER = "resourceAncestryHover";
+ public static final String RESOURCE_ANCESTRY_TYPES = "resourceAncestryTypes";
+ public static final String RESOURCE_HOVER = "resourceHover";
+ public static final String RESOURCE_ID = "resourceId";
+ public static final String RESOURCE_NAME = "resourceName";
+ public static final String RESOURCE_TYPE_ID = "resourceTypeId";
+
/**
* 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.
@@ -75,7 +88,7 @@ public abstract class AncestryUtil {
}
StringBuilder sbResources = new StringBuilder();
- StringBuilder sbTypes = (null != types) ? new StringBuilder() : null;
+ StringBuilder sbTypes = (null != types) ? new StringBuilder("Parent Ancestry<hr/>") : null;
String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
for (int i = 0; i < ancestryEntries.length; ++i) {
String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
@@ -83,15 +96,25 @@ public abstract class AncestryUtil {
int ancestorResourceId = Integer.valueOf(entryTokens[1]);
String ancestorName = entryTokens[2];
- sbResources.append((i > 0) ? " > " : "");
+ sbResources.append((i > 0) ? " < " : "");
+ //sbResources.append(" < ");
String url = LinkManager.getResourceLink(ancestorResourceId);
String suffix = resourceId + "_" + entryTokens[1];
- sbResources.append(SeleniumUtility.getLocatableHref(url, ancestorName, suffix));
+ String href = SeleniumUtility.getLocatableHref(url, ancestorName, suffix);
+ sbResources.append(href);
if (null != sbTypes) {
- sbTypes.append((i > 0) ? " > " : "");
+ if (i > 0) {
+ sbTypes.append("<br/>");
+ for (int j = 0; j < i; ++j) {
+ sbTypes.append(" ");
+ }
+ }
ResourceType rt = types.get(ancestorTypeId);
- sbTypes.append(rt.getName() + "[" + rt.getPlugin() + "]");
+ sbTypes.append(href);
+ sbTypes.append(" [" + rt.getPlugin() + " / ");
+ sbTypes.append(rt.getName());
+ sbTypes.append("]");
}
}
@@ -103,6 +126,109 @@ public abstract class AncestryUtil {
return result;
}
+ public static String getAncestryValue(Record record) {
+ String ancestry = record.getAttributeAsString(RESOURCE_ANCESTRY);
+ if (null == ancestry) {
+ return "";
+ }
+
+ Integer resourceId = record.getAttributeAsInt(RESOURCE_ID);
+ // if not set assume the standard "id" attr is a resourceId
+ resourceId = (null != resourceId) ? resourceId : record.getAttributeAsInt("id");
+ StringBuilder sbResources = new StringBuilder();
+ String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM);
+ for (int i = 0; i < ancestryEntries.length; ++i) {
+ String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM);
+ int ancestorResourceId = Integer.valueOf(entryTokens[1]);
+ 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);
+ }
+
+ return sbResources.toString();
+ }
+
+ public static String getAncestryHoverHTML(ListGridRecord listGridRecord, int width) {
+ String ancestryHover = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY_HOVER);
+ if (null != ancestryHover) {
+ 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");
+ String resourceName = listGridRecord.getAttribute(RESOURCE_NAME);
+ // if not set assume the standard "name" attr is a resourceName
+ resourceName = (null != resourceName) ? resourceName : listGridRecord.getAttribute("name");
+ Map<Integer, ResourceType> types = ((MapWrapper) listGridRecord.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES))
+ .getMap();
+ Integer resourceTypeId = listGridRecord.getAttributeAsInt(RESOURCE_TYPE_ID);
+ ResourceType type = types.get(resourceTypeId);
+ String resourceLongName = getResourceLongName(resourceName, type);
+
+ 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(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(" ");
+ }
+ }
+ 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(" ");
+ }
+ sb.append(resourceLongName);
+
+ sb.append("</p>");
+
+ String result = sb.toString();
+ listGridRecord.setAttribute(RESOURCE_ANCESTRY_HOVER, result);
+ return result;
+ }
+
+ private static String getResourceLongName(String resourceName, ResourceType type) {
+ StringBuffer sb = new StringBuffer("<b>");
+
+ sb.append(resourceName);
+ sb.append("</b>");
+
+ if (type != null) {
+ sb.append(" [" + type.getPlugin() + " / ");
+ sb.append(type.getName());
+ sb.append("]");
+ }
+
+ return sb.toString();
+ }
+
/**
* Get a resource name that combines type and resource information. This is useful for when we want to
* use a single column for dispay of the resource "name". The name is wrapped in a navigable link.
@@ -111,23 +237,45 @@ public abstract class AncestryUtil {
*
* @return the long name for the resource
*/
- public static String getResourceLongName(int resourceId, String resourceName, ResourceType type) {
- StringBuilder sb = new StringBuilder();
- if (type != null) {
- if (type.getPlugin() != null) {
- sb.append(type.getPlugin());
- sb.append(" ");
- }
-
- sb.append(type.getName());
- sb.append(" ");
+ public static String getResourceHoverHTML(Record record, int width) {
+ String resourceHover = record.getAttributeAsString(RESOURCE_HOVER);
+ if (null != resourceHover) {
+ return resourceHover;
}
- String url = LinkManager.getResourceLink(resourceId);
- String suffix = String.valueOf(resourceId);
- sb.append(SeleniumUtility.getLocatableHref(url, resourceName, suffix));
+ String resourceName = record.getAttribute(RESOURCE_NAME);
+ // if not set assume the standard "name" attr is a resourceName
+ resourceName = (null != resourceName) ? resourceName : record.getAttribute("name");
+ Map<Integer, ResourceType> types = ((MapWrapper) record.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES)).getMap();
+ Integer resourceTypeId = record.getAttributeAsInt(RESOURCE_TYPE_ID);
+ ResourceType type = types.get(resourceTypeId);
+ width = (width <= 0) ? 500 : width;
- return sb.toString();
+ StringBuilder sb = new StringBuilder("<p style='width:");
+ sb.append(width);
+ sb.append("px'>");
+
+ sb.append(getResourceLongName(resourceName, type));
+
+ sb.append("</p>");
+
+ String result = sb.toString();
+ record.setAttribute(RESOURCE_HOVER, result);
+ return result;
+ }
+
+ // We do not want smargwt to see we are storing our map into an attribute because it barfs on our key/value pairs
+ // so instead we have to wrap it in a non-Map POJO Object so smartgwt just handles it as a java.lang.Object.
+ public static class MapWrapper {
+ private Map<Integer, ResourceType> map;
+
+ public MapWrapper(Map<Integer, ResourceType> map) {
+ this.map = map;
+ }
+
+ public Map<Integer, ResourceType> getMap() {
+ return this.map;
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
index 8a7d883..27f49f2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
@@ -1,6 +1,5 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.ANCESTRY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
@@ -110,6 +109,8 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
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) {
@@ -120,17 +121,12 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
record.setAttribute(TYPE.propertyName(), type.getName());
}
- // decode ancestry
- String ancestry = record.getAttributeAsString(ANCESTRY.propertyName());
- if (null == ancestry) {
- continue;
- }
- int resourceId = record.getAttributeAsInt("id");
- String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types);
- // Preserve the encoded ancestry for special-case formatting at higher levels. Set the
- // decoded strings as different attributes.
- record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]);
- record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]);
+ // 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
@@ -173,7 +169,6 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
record.setAttribute("resource", res);
record.setAttribute("id", res.getId());
record.setAttribute(NAME.propertyName(), res.getName());
- record.setAttribute(ANCESTRY.propertyName(), res.getAncestry());
record.setAttribute(DESCRIPTION.propertyName(), res.getDescription());
record.setAttribute(TYPE.propertyName(), res.getResourceType().getId());
record.setAttribute(PLUGIN.propertyName(), res.getResourceType().getPlugin());
@@ -183,7 +178,12 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
record.setAttribute(AVAILABILITY.propertyName(), ImageManager.getAvailabilityIconFromAvailType(res
.getCurrentAvailability().getAvailabilityType()));
- record.setAttribute("resourcePersmission", from.getResourcePermission());
+ record.setAttribute("resourcePermission", from.getResourcePermission());
+
+ // for ancestry handling
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, res.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, res.getResourceType().getId());
+
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
index cf11666..b689133 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java
@@ -39,9 +39,7 @@ public enum ResourceDataSourceField {
CATEGORY("resourceType.category", CoreGUI.getMessages().common_title_category()),
- AVAILABILITY("currentAvailability", CoreGUI.getMessages().common_title_availability()),
-
- ANCESTRY("ancestry", CoreGUI.getMessages().common_title_ancestry());
+ AVAILABILITY("currentAvailability", CoreGUI.getMessages().common_title_availability());
/**
* Corresponds to a property name of Resource (e.g. resourceType.name).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 7f7cb7e..9a10084 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.ANCESTRY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
@@ -62,10 +61,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
public static final String FILTER_GROUP_ID = "groupId";
- // a decoded resource ancestry for display, with
- public static final String ATTR_ANCESTRY_RESOURCES = ANCESTRY.name() + "Resources";
- public static final String ATTR_ANCESTRY_TYPES = ANCESTRY.name() + "Types";
-
private static ResourceDatasource INSTANCE;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -104,10 +99,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
nameDataField.setCanEdit(false);
fields.add(nameDataField);
- DataSourceTextField ancestryDataField = new DataSourceTextField(ANCESTRY.propertyName(), ANCESTRY.title(), 200);
- ancestryDataField.setCanEdit(false);
- fields.add(ancestryDataField);
-
DataSourceTextField descriptionDataField = new DataSourceTextField(DESCRIPTION.propertyName(), DESCRIPTION
.title());
descriptionDataField.setCanEdit(false);
@@ -159,14 +150,14 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
}
// In addition to the types of the result resources, get the types of their ancestry
- // NOTE: this may be too labor intensive in general, but since this is a singleton I couldn't
- // make it easily optional.
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) {
@@ -177,17 +168,12 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
record.setAttribute(TYPE.propertyName(), type.getName());
}
- // decode ancestry
- String ancestry = record.getAttributeAsString(ANCESTRY.propertyName());
- if (null == ancestry) {
- continue;
- }
- int resourceId = record.getAttributeAsInt("id");
- String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types);
- // Preserve the encoded ancestry for special-case formatting at higher levels. Set the
- // decoded strings as different attributes.
- record.setAttribute(ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]);
- record.setAttribute(ATTR_ANCESTRY_TYPES, decodedAncestry[1]);
+ // 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
@@ -236,7 +222,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
record.setAttribute("id", from.getId());
record.setAttribute("uuid", from.getUuid());
record.setAttribute(NAME.propertyName(), from.getName());
- record.setAttribute(ANCESTRY.propertyName(), from.getAncestry());
record.setAttribute(DESCRIPTION.propertyName(), from.getDescription());
record.setAttribute(TYPE.propertyName(), from.getResourceType().getId());
record.setAttribute(PLUGIN.propertyName(), from.getResourceType().getPlugin());
@@ -246,6 +231,9 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
record.setAttribute(AVAILABILITY.propertyName(), ImageManager.getAvailabilityIconFromAvailType(from
.getCurrentAvailability().getAvailabilityType()));
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceType().getId());
+
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index a4d2835..dc6b945 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.ANCESTRY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION;
@@ -153,19 +152,24 @@ public class ResourceSearchView extends Table {
return SeleniumUtility.getLocatableHref(url, o.toString(), null);
}
});
+ nameField.setShowHover(true);
+ nameField.setHoverCustomizer(new HoverCustomizer() {
- ListGridField ancestryField = new ListGridField(ANCESTRY.propertyName(), ANCESTRY.title());
+ 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());
ancestryField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES);
+ 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 "<p style='width:400px'>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>";
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
index 9ba7787..796c490 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
@@ -49,9 +49,6 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
public static abstract class Field extends AbstractOperationHistoryDataSource.Field {
public static final String RESOURCE = "resource";
- public static final String RESOURCE_ID = "resource.id";
- public static final String ANCESTRY = "resource.ancestry";
- public static final String TYPE = "resource.resourceType.id";
public static final String GROUP_OPERATION_HISTORY = "groupOperationHistory";
}
@@ -67,9 +64,6 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE);
fields.add(resourceField);
- DataSourceTextField ancestryField = new DataSourceTextField(Field.ANCESTRY);
- fields.add(ancestryField);
-
return fields;
}
@@ -123,30 +117,17 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
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) {
- // enhance resource name
- int resourceId = record.getAttributeAsInt(Field.RESOURCE_ID);
- int resourceTypeId = record.getAttributeAsInt(Field.TYPE);
- String resourceName = record.getAttributeAsString(Field.RESOURCE);
- ResourceType type = types.get(resourceTypeId);
- record.setAttribute(Field.RESOURCE, AncestryUtil
- .getResourceLongName(resourceId, resourceName, type));
-
- // decode ancestry
- String ancestry = record.getAttributeAsString(Field.ANCESTRY);
- if (null == ancestry) {
- continue;
- }
- String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types);
- // Preserve the encoded ancestry for special-case formatting at higher levels. Set the
- // decoded strings as different attributes.
- //record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]);
- //record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]);
- // TODO: If we elect to use a hover handler then we'll need ListGridFields set up
- // Until then we'll just set the Ancestry field.
- record.setAttribute(Field.ANCESTRY, decodedAncestry[0]);
+ // 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
@@ -160,10 +141,13 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
ListGridRecord record = super.copyValues(from);
record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.RESOURCE_ID, from.getResource().getId());
record.setAttribute(Field.RESOURCE, from.getResource().getName());
- record.setAttribute(Field.ANCESTRY, from.getResource().getAncestry());
- record.setAttribute(Field.TYPE, from.getResource().getResourceType().getId());
+
+ // for ancestry handling
+ record.setAttribute(AncestryUtil.RESOURCE_ID, from.getResource().getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResource().getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getResource().getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResource().getResourceType().getId());
return record;
}
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 6d76cb1..5632322 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
@@ -40,8 +40,8 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDetailsView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Ian Springer
@@ -108,8 +108,9 @@ public class ResourceOperationHistoryDetailsView extends AbstractOperationHistor
if (showResourceField) {
Resource resource = resourceOperationHistory.getResource();
- disambiguatedResourceName = AncestryUtil.getResourceLongName(resource.getId(), resource
- .getName(), resource.getResourceType());
+ String url = LinkManager.getResourceLink(resource.getId());
+ disambiguatedResourceName = SeleniumUtility.getLocatableHref(url, resource.getName(), String
+ .valueOf(resource.getId()));
}
displayDetails(resourceOperationHistory);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
index 94749e2..f310997 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
@@ -39,6 +39,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
+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.inventory.resource.type.ResourceTypePluginTreeDataSource;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -177,9 +178,7 @@ public class ResourceSelector extends AbstractSelector<Resource> {
protected HoverCustomizer getNameHoverCustomizer() {
return new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
- return "<p style='width:400px'>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>"
- + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>";
+ return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0);
}
};
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index db60b8c..42808cf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -44,7 +44,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
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;
@@ -60,17 +59,13 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
public enum Field {
- ANCESTRY("ancestry", MSG.common_title_ancestry()),
-
OPERATION("operationName", MSG.dataSource_operationSchedule_field_operationName()),
RESOURCE("resource", MSG.common_title_resource()),
STATUS("operationStatus", MSG.common_title_status()),
- TIME("operationStartTime", MSG.common_title_timestamp()),
-
- TYPE("typeId", MSG.common_title_type());
+ TIME("operationStartTime", MSG.common_title_timestamp());
/**
* Corresponds to a property name of Resource (e.g. resourceType.name).
@@ -127,10 +122,6 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE.propertyName, Field.RESOURCE.title);
fields.add(resourceField);
- DataSourceTextField ancestryField = new DataSourceTextField(Field.ANCESTRY.propertyName(), Field.ANCESTRY
- .title());
- fields.add(ancestryField);
-
DataSourceTextField operationField = new DataSourceTextField(Field.OPERATION.propertyName(), Field.OPERATION
.title());
fields.add(operationField);
@@ -207,27 +198,17 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
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) {
- // enhance resource name
- int resourceId = record.getAttributeAsInt("id");
- int resourceTypeId = record.getAttributeAsInt(Field.TYPE.propertyName);
- String resourceName = record.getAttributeAsString(Field.RESOURCE.propertyName);
- ResourceType type = types.get(resourceTypeId);
- record.setAttribute(Field.RESOURCE.propertyName, AncestryUtil.getResourceLongName(resourceId,
- resourceName, type));
-
- // decode ancestry
- String ancestry = record.getAttributeAsString(Field.ANCESTRY.propertyName());
- if (null == ancestry) {
- continue;
- }
- String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types);
- // Preserve the encoded ancestry for special-case formatting at higher levels. Set the
- // decoded strings as different attributes.
- record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]);
- record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]);
+ // 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
@@ -239,13 +220,16 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
@Override
public ListGridRecord copyValues(ResourceOperationLastCompletedComposite from) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute("id", from.getResourceId());
- record.setAttribute(Field.ANCESTRY.propertyName, from.getAncestry());
record.setAttribute(Field.OPERATION.propertyName, from.getOperationName());
record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName());
record.setAttribute(Field.STATUS.propertyName, getStatusIconLink(from));
record.setAttribute(Field.TIME.propertyName, new Date(from.getOperationStartTime()));
- record.setAttribute(Field.TYPE.propertyName, from.getResourceTypeId());
+
+ // for ancestry handling
+ record.setAttribute(AncestryUtil.RESOURCE_ID, from.getResourceId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResourceName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceTypeId());
record.setAttribute("entity", from);
return record;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index 0f509df..a835711 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -40,7 +40,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
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;
@@ -56,15 +55,11 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
public enum Field {
- ANCESTRY("ancestry", MSG.common_title_ancestry()),
-
OPERATION("operationName", MSG.dataSource_operationSchedule_field_operationName()),
RESOURCE("resource", MSG.common_title_resource()),
- TIME("operationNextFireTime", MSG.dataSource_operationSchedule_field_nextFireTime()),
-
- TYPE("typeId", MSG.common_title_type());
+ TIME("operationNextFireTime", MSG.dataSource_operationSchedule_field_nextFireTime());
/**
* Corresponds to a property name of Resource (e.g. resourceType.name).
@@ -120,10 +115,6 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE.propertyName, Field.RESOURCE.title);
fields.add(resourceField);
- DataSourceTextField ancestryField = new DataSourceTextField(Field.ANCESTRY.propertyName(), Field.ANCESTRY
- .title());
- fields.add(ancestryField);
-
DataSourceTextField operationField = new DataSourceTextField(Field.OPERATION.propertyName(), Field.OPERATION
.title());
fields.add(operationField);
@@ -196,27 +187,17 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
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) {
- // enhance resource name
- int resourceId = record.getAttributeAsInt("id");
- int resourceTypeId = record.getAttributeAsInt(Field.TYPE.propertyName);
- String resourceName = record.getAttributeAsString(Field.RESOURCE.propertyName);
- ResourceType type = types.get(resourceTypeId);
- record.setAttribute(Field.RESOURCE.propertyName, AncestryUtil.getResourceLongName(resourceId,
- resourceName, type));
-
- // decode ancestry
- String ancestry = record.getAttributeAsString(Field.ANCESTRY.propertyName());
- if (null == ancestry) {
- continue;
- }
- String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types);
- // Preserve the encoded ancestry for special-case formatting at higher levels. Set the
- // decoded strings as different attributes.
- record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]);
- record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]);
+ // 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
@@ -233,12 +214,15 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
@Override
public ListGridRecord copyValues(ResourceOperationScheduleComposite from) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute("id", from.getResourceId());
- record.setAttribute(Field.ANCESTRY.propertyName, from.getAncestry());
record.setAttribute(Field.OPERATION.propertyName, from.getOperationName());
record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName());
record.setAttribute(Field.TIME.propertyName, new Date(from.getOperationNextFireTime()));
- record.setAttribute(Field.TYPE.propertyName, from.getResourceTypeId());
+
+ // for ancestry handling
+ record.setAttribute(AncestryUtil.RESOURCE_ID, from.getResourceId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResourceName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceTypeId());
record.setAttribute("entity", from);
return record;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index d354bbd..756bc4a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -42,7 +42,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
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.ResourceDatasource;
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;
@@ -60,13 +59,9 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
ALERTS("numAlerts", MSG.dataSource_problemResources_field_alerts()),
- ANCESTRY("ancestry", MSG.common_title_ancestry()),
-
AVAILABILITY("availabilityType", MSG.common_title_availability()),
- RESOURCE("resource", MSG.common_title_resource()),
-
- TYPE("typeId", MSG.common_title_type());
+ RESOURCE("resource", MSG.common_title_resource());
/**
* Corresponds to a property name of Resource (e.g. resourceType.name).
@@ -122,10 +117,6 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
protected List<DataSourceField> addDataSourceFields() {
List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField ancestryField = new DataSourceTextField(Field.ANCESTRY.propertyName(), Field.ANCESTRY
- .title());
- fields.add(ancestryField);
-
DataSourceTextField alertsField = new DataSourceTextField(Field.ALERTS.propertyName, Field.ALERTS.title());
fields.add(alertsField);
@@ -196,27 +187,17 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
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) {
- // enhance resource name
- int resourceId = record.getAttributeAsInt("id");
- int resourceTypeId = record.getAttributeAsInt(Field.TYPE.propertyName);
- String resourceName = record.getAttributeAsString(Field.RESOURCE.propertyName);
- ResourceType type = types.get(resourceTypeId);
- record.setAttribute(Field.RESOURCE.propertyName, AncestryUtil.getResourceLongName(resourceId,
- resourceName, type));
-
- // decode ancestry
- String ancestry = record.getAttributeAsString(Field.ANCESTRY.propertyName());
- if (null == ancestry) {
- continue;
- }
- String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types);
- // Preserve the encoded ancestry for special-case formatting at higher levels. Set the
- // decoded strings as different attributes.
- record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]);
- record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]);
+ // 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
@@ -229,12 +210,15 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
public ListGridRecord copyValues(ProblemResourceComposite from) {
ListGridRecord record = new ListGridRecord();
record.setAttribute("id", from.getResourceId());
- record.setAttribute(Field.ANCESTRY.propertyName, from.getAncestry());
record.setAttribute(Field.ALERTS.propertyName, from.getNumAlerts());
record.setAttribute(Field.AVAILABILITY.propertyName, ImageManager.getAvailabilityIconFromAvailType(from
.getAvailabilityType()));
record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName());
- record.setAttribute(Field.TYPE.propertyName, from.getResourceTypeId());
+
+ // for ancestry handling
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResourceName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceTypeId());
record.setAttribute("entity", from);
return record;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
index 3072708..3ae0259 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java
@@ -18,9 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import java.util.ArrayList;
+import java.util.List;
+
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.AlertCriteria;
+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.AlertGWTService;
@@ -39,8 +43,15 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
public PageList<Alert> findAlertsByCriteria(AlertCriteria criteria) throws RuntimeException {
try {
- return SerialUtility.prepare(this.alertManager.findAlertsByCriteria(getSessionSubject(), criteria),
- "AlertService.findAlertsByCriteria");
+ PageList<Alert> result = this.alertManager.findAlertsByCriteria(getSessionSubject(), criteria);
+ if (!result.isEmpty()) {
+ List<Resource> resources = new ArrayList<Resource>(result.size());
+ for (Alert alert : result) {
+ resources.add(alert.getAlertDefinition().getResource());
+ }
+ ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet);
+ }
+ return SerialUtility.prepare(result, "AlertService.findAlertsByCriteria");
} catch (Throwable t) {
throw new RuntimeException(ThrowableUtil.getAllMessages(t));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index c903f13..0290135 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -67,7 +67,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
try {
PageList<ResourceOperationHistory> result = operationManager.findResourceOperationHistoriesByCriteria(
getSessionSubject(), criteria);
- if (result.size() > 0) {
+ if (!result.isEmpty()) {
List<Resource> resources = new ArrayList<Resource>(result.size());
for (ResourceOperationHistory history : result) {
resources.add(history.getResource());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 44bcb42..4c474c1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -107,7 +107,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
// "productVersion "}
"tags" };
- private static Set<String> importantFieldsSet = new HashSet<String>(Arrays.asList(importantFields));
+ public static Set<String> importantFieldsSet = new HashSet<String>(Arrays.asList(importantFields));
@Override
public void init(ServletConfig config) throws ServletException {
commit f1db65d15e64328a18c5ecb3ec10529db237e8af
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Mar 14 13:55:41 2011 -0400
fix bug that was preventing changing boolean property values within a map within a list (https://bugzilla.redhat.com/show_bug.cgi?id=661899)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 2bbf8bb..5f4c47e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -500,7 +500,7 @@ public class ConfigurationEditor extends LocatableVLayout {
if (propertyMap instanceof Configuration) {
this.topLevelPropertiesValuesManager.addMember(form);
}
- form.setValidateOnExit(true); // TODO: Remove this?
+ //form.setValidateOnExit(true); // TODO: Remove this?
form.setHiliteRequiredFields(true);
form.setNumCols(4);
form.setCellPadding(5);
@@ -1051,6 +1051,7 @@ public class ConfigurationEditor extends LocatableVLayout {
final DynamicForm listGrid = new DynamicForm();
vLayout.addMember(listGrid);
+ // TODO (ips, 03/14/11): Make this a ListGrid, rather than a SelectItem.
final SelectItem membersItem = new SelectItem(propertyList.getName());
membersItem.setShowTitle(false);
membersItem.setMultiple(true);
@@ -1114,11 +1115,12 @@ public class ConfigurationEditor extends LocatableVLayout {
}
});
- final IButton newButton = new LocatableIButton(extendLocatorId("New"), MSG.common_button_new());
+ final IButton newButton = new LocatableIButton(vLayout.extendLocatorId("New"), MSG.common_button_new());
newButton.setIcon(Window.getImgURL("[SKIN]/actions/add.png"));
newButton.setTooltip(MSG.view_configEdit_tooltip_2());
newButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
+ // TODO: selenium locators
final Window popup = new Window();
popup.setTitle(MSG.view_configEdit_addItem());
popup.setWidth(300);
@@ -1139,6 +1141,8 @@ public class ConfigurationEditor extends LocatableVLayout {
final PropertySimple newMemberPropertySimple = new PropertySimple(propertyName, null);
FormItem simpleField = buildSimpleField(memberPropertyDefinitionSimple, newMemberPropertySimple);
+ simpleField.setTitle(memberPropertyDefinitionSimple.getDisplayName());
+ simpleField.setShowTitle(true);
simpleField.setAlign(Alignment.CENTER);
simpleField.setDisabled(false);
simpleField.setRequired(true);
@@ -1433,9 +1437,6 @@ public class ConfigurationEditor extends LocatableVLayout {
lengthRangeValidator.setMax(PropertySimple.MAX_VALUE_LENGTH);
typeValidator = lengthRangeValidator;
break;
- case BOOLEAN:
- typeValidator = new IsBooleanValidator();
- break;
case INTEGER:
case LONG:
typeValidator = new IsIntegerValidator();
@@ -1510,6 +1511,7 @@ public class ConfigurationEditor extends LocatableVLayout {
final LocatableVLayout layout = new LocatableVLayout(popup.extendLocatorId("Layout"));
layout.setHeight100();
+ layout.setMargin(8);
final DynamicForm childForm = buildPropertiesForm(layout.extendLocatorId("Form"), memberDefinitions, workingMap);
childForm.setHeight100();
@@ -1525,6 +1527,10 @@ public class ConfigurationEditor extends LocatableVLayout {
}
okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
+ if (!childForm.validate()) {
+ okButton.disable();
+ return;
+ }
if (newRow) {
try {
list.add(workingMap);
@@ -1555,7 +1561,10 @@ public class ConfigurationEditor extends LocatableVLayout {
// Only enable the OK button if all properties are valid.
childForm.addItemChangedHandler(new ItemChangedHandler() {
public void onItemChanged(ItemChangedEvent itemChangedEvent) {
- okButton.setDisabled(!childForm.validate());
+ // TODO (ips, 03/14/11): Ideally, we would validate the form here, but it's preventing boolean prop
+ // radio buttons from being selectable, most likely due to a SmartGWT bug.
+ //okButton.setDisabled(!childForm.validate());
+ okButton.setDisabled(false);
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
index cca914c..f1bb986 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
@@ -76,9 +76,7 @@ public abstract class TestConfigurationFactory {
simplePropDef.setDisplayName(simplePropDef.getName());
addPropertyDefinition(configDef, simplePropDef, orderIndex++);
- simplePropDef = new PropertyDefinitionSimple("Boolean", "a required Boolean simple prop", true,
- PropertySimpleType.BOOLEAN);
- simplePropDef.setDisplayName(simplePropDef.getName());
+ simplePropDef = createBooleanPropDef();
addPropertyDefinition(configDef, simplePropDef, orderIndex++);
simplePropDef.setRequired(true);
@@ -118,6 +116,7 @@ public abstract class TestConfigurationFactory {
PropertyDefinitionMap mapPropDef = new PropertyDefinitionMap("MapOfSimples", "a map of simples", false);
mapPropDef.put(createStringPropDef1());
mapPropDef.put(createStringPropDef2());
+ mapPropDef.put(createBooleanPropDef());
mapPropDef.put(createIntegerPropDef());
mapPropDef.setDisplayName(mapPropDef.getName());
addPropertyDefinition(configDef, mapPropDef, orderIndex++);
@@ -143,6 +142,7 @@ public abstract class TestConfigurationFactory {
new PropertyDefinitionMap("MapOfSimplesInList", "a map of simples in a list", false);
mapInListPropDef.put(createStringPropDef1());
mapInListPropDef.put(createStringPropDef2());
+ mapInListPropDef.put(createBooleanPropDef());
mapInListPropDef.put(createIntegerPropDef());
mapInListPropDef.setDisplayName(mapInListPropDef.getName());
@@ -155,6 +155,7 @@ public abstract class TestConfigurationFactory {
new PropertyDefinitionMap("MapOfSimplesInReadOnlyList", "a map of simples in a list", false);
mapInReadOnlyListPropDef.put(createStringPropDef1());
mapInReadOnlyListPropDef.put(createStringPropDef2());
+ mapInReadOnlyListPropDef.put(createBooleanPropDef());
mapInReadOnlyListPropDef.put(createIntegerPropDef());
mapInReadOnlyListPropDef.setDisplayName(mapInReadOnlyListPropDef.getName());
@@ -234,6 +235,7 @@ public abstract class TestConfigurationFactory {
PropertyMap propMap1 = new PropertyMap("MapOfSimples");
propMap1.put(new PropertySimple("String1", "One"));
propMap1.put(new PropertySimple("String2", "Two"));
+ propMap1.put(new PropertySimple("Boolean", true));
propMap1.put(new PropertySimple("Integer", 11));
configuration.put(propMap1);
@@ -256,20 +258,24 @@ public abstract class TestConfigurationFactory {
PropertyMap propMap2 = new PropertyMap("MapOfSimplesInList");
propMap2.put(new PropertySimple("String1", "Uno"));
propMap2.put(new PropertySimple("String2", "Dos"));
+ propMap2.put(new PropertySimple("Boolean", true));
propMap2.put(new PropertySimple("Integer", Integer.MIN_VALUE));
PropertyMap propMap3 = new PropertyMap("MapOfSimplesInList");
propMap3.put(new PropertySimple("String1", "Un"));
propMap3.put(new PropertySimple("String2", "Deux"));
+ propMap3.put(new PropertySimple("Boolean", false));
propMap3.put(new PropertySimple("Integer", Integer.MAX_VALUE));
configuration.put(new PropertyList("ListOfMaps", propMap2, propMap3));
PropertyMap propMap4 = new PropertyMap("MapOfSimplesInReadOnlyList");
propMap4.put(new PropertySimple("String1", "A"));
propMap4.put(new PropertySimple("String2", "B"));
+ propMap4.put(new PropertySimple("Boolean", false));
propMap4.put(new PropertySimple("Integer", 999));
PropertyMap propMap5 = new PropertyMap("MapOfSimplesInReadOnlyList");
propMap5.put(new PropertySimple("String1", "a"));
propMap5.put(new PropertySimple("String2", "b"));
+ propMap5.put(new PropertySimple("Boolean", true));
propMap5.put(new PropertySimple("Integer", 0));
configuration.put(new PropertyList("ReadOnlyListOfMaps", propMap4, propMap5));
@@ -298,6 +304,15 @@ public abstract class TestConfigurationFactory {
return stringPropDef2;
}
+ private static PropertyDefinitionSimple createBooleanPropDef() {
+ PropertyDefinitionSimple propDef;
+ propDef = new PropertyDefinitionSimple("Boolean",
+ "a Boolean simple prop", false, PropertySimpleType.BOOLEAN);
+ propDef.setDisplayName(propDef.getName());
+ propDef.setSummary(true);
+ return propDef;
+ }
+
private static PropertyDefinitionSimple createIntegerPropDef() {
PropertyDefinitionSimple integerPropDef;
integerPropDef = new PropertyDefinitionSimple("Integer",
commit 4d0beca83fb74d943bbeb1e02dfbfbe7618adeee
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 14 13:32:18 2011 -0400
avoid cryptic array index out of bounds error when the hosts plugin can't find the hosts file (seen this on windows where /etc/hosts isn't valid path)
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
index 731e532..e0a2c46 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/helper/NonAugeasHostsConfigurationDelegate.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
import org.rhq.core.domain.configuration.Configuration;
@@ -37,8 +38,7 @@ import org.rhq.plugins.hosts.HostsComponent;
/**
* @author Ian Springer
*/
-public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet
-{
+public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet {
private HostsComponent hostsComponent;
public NonAugeasHostsConfigurationDelegate(HostsComponent hostsComponent) {
@@ -47,7 +47,11 @@ public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet
public Configuration loadResourceConfiguration() throws Exception {
Configuration resourceConfig = new Configuration();
- File hostsFile = (File)this.hostsComponent.getConfigurationFiles().get(0);
+ List configurationFiles = this.hostsComponent.getConfigurationFiles();
+ if (configurationFiles == null || configurationFiles.isEmpty()) {
+ throw new Exception("Cannot find the hosts file on this machine");
+ }
+ File hostsFile = (File) configurationFiles.get(0);
Hosts hosts = Hosts.load(hostsFile);
resourceConfig.setNotes("Loaded at " + new Date());
@@ -71,15 +75,15 @@ public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet
entryProp.put(new PropertySimple("alias", aliasPropValue));
}
- return resourceConfig;
+ return resourceConfig;
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- Configuration resourceConfig = report.getConfiguration();
+ Configuration resourceConfig = report.getConfiguration();
Hosts newHosts = new Hosts();
PropertyList entriesProp = resourceConfig.getList(".");
- for (Property entryProp: entriesProp.getList()) {
+ for (Property entryProp : entriesProp.getList()) {
PropertyMap entryPropMap = (PropertyMap) entryProp;
String ipAddress = entryPropMap.getSimple("ipaddr").getStringValue();
String canonicalName = entryPropMap.getSimple("canonical").getStringValue();
@@ -98,11 +102,10 @@ public class NonAugeasHostsConfigurationDelegate implements ConfigurationFacet
newHosts.addEntry(entry);
}
- File hostsFile = (File)this.hostsComponent.getConfigurationFiles().get(0);
+ File hostsFile = (File) this.hostsComponent.getConfigurationFiles().get(0);
try {
Hosts.store(newHosts, hostsFile);
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException("Failed to write hosts file [" + hostsFile + "].", e);
}
commit 32dcfe0e837bd7327997055683cd955e299ad863
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Mar 14 12:56:38 2011 -0400
BZ 684864 - fix enum array processing - the parsing was broken before.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
index bb26a03..64dc1a9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
@@ -147,12 +147,7 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
criteria.addFilterDetail((String) criteriaMap.get("details"));
if (criteriaMap.get("severities") != null) {
- String[] severityStrings = criteriaMap.get("severities").toString().split(",");
- EventSeverity[] severities = new EventSeverity[severityStrings.length];
- int i = 0;
- for (String nextSeverity : severityStrings) {
- severities[i++] = EventSeverity.valueOf(nextSeverity);
- }
+ EventSeverity[] severities = getArrayFilter(request, "severities", EventSeverity.class);
criteria.addFilterSeverities(severities);
}
commit c8c8b20035fe8097b24b389b8aa532f49a6facb7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Mar 14 12:32:33 2011 -0400
ambiguously named autogroup nodes in resource tree are now disambiguated by appending the plugin name (e.g. "JBossAS Servers (JBossAS5 plugin)")
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 0446b1e..2bbf8bb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -517,6 +517,7 @@ public class ConfigurationEditor extends LocatableVLayout {
private void addHeaderItems(List<FormItem> fields) {
final String CELL_STYLE = "configurationEditorHeaderCell";
+ // TODO: i18n
StaticTextItem nameHeader = new StaticTextItem();
nameHeader.setValue("Property");
nameHeader.setShowTitle(false);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
index 2da1ce5..336e12e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeDatasource.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -20,8 +20,10 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import com.allen_sauer.gwt.log.client.Log;
@@ -45,6 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementScheduleGWTService;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
@@ -58,7 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
*/
public class ResourceTreeDatasource extends DataSource {
- Messages MSG = CoreGUI.getMessages();
+ private static final Messages MSG = CoreGUI.getMessages();
private List<Resource> initialData;
private List<Resource> lockedData;
@@ -207,6 +210,10 @@ public class ResourceTreeDatasource extends DataSource {
// ensure a clean set.
Set<String> allNodeIds = new HashSet<String>(resourceNodes.size() * 2);
+ Map<String, Map<String, AutoGroupTreeNode>> parentNodeIdToAutoGroupsByName =
+ new HashMap<String, Map<String, AutoGroupTreeNode>>();
+ Set<AutoGroupTreeNode> ambiguouslyNamedAutoGroupNodes = new HashSet<AutoGroupTreeNode>();
+
for (ResourceTreeNode resourceNode : resourceNodes) {
if (allNodeIds.contains(resourceNode.getID())) {
Log.debug("Duplicate ResourceTreeNode - Skipping: " + resourceNode);
@@ -226,18 +233,30 @@ public class ResourceTreeDatasource extends DataSource {
// If the parent node is an autogroup node, make sure the autogroup node is in the
// tree prior to the resource node.
- if (!allNodeIds.contains(resourceNode.getParentID())) {
+ String autoGroupNodeID = resourceNode.getParentID();
+ if (!allNodeIds.contains(autoGroupNodeID)) {
AutoGroupTreeNode autogroupNode = new AutoGroupTreeNode(resource);
+ String parentID = autogroupNode.getParentID();
+ Map<String, AutoGroupTreeNode> autoGroupNodesByName = parentNodeIdToAutoGroupsByName.get(parentID);
+ if (autoGroupNodesByName == null) {
+ autoGroupNodesByName = new HashMap<String, AutoGroupTreeNode>();
+ parentNodeIdToAutoGroupsByName.put(parentID, autoGroupNodesByName);
+ } else {
+ AutoGroupTreeNode ambiguouslyNamedAutogroupNode = autoGroupNodesByName.get(autogroupNode.getName());
+ if (ambiguouslyNamedAutogroupNode != null) {
+ ambiguouslyNamedAutoGroupNodes.add(ambiguouslyNamedAutogroupNode);
+ ambiguouslyNamedAutoGroupNodes.add(autogroupNode);
+ }
+ }
+ autoGroupNodesByName.put(autogroupNode.getName(), autogroupNode);
if (autogroupNode.isParentSubcategory()) {
-
// If the parent node of the autogroup node is a subcategory node, make sure the subcategory
// node is in the tree prior to the autogroup node. Note that it could itself be a
// tree of subcategories.
addSubCategoryNodes(allNodes, allNodeIds, resource);
-
}
- allNodeIds.add(resourceNode.getParentID());
+ allNodeIds.add(autoGroupNodeID);
allNodes.add(autogroupNode);
}
}
@@ -246,6 +265,10 @@ public class ResourceTreeDatasource extends DataSource {
allNodes.add(resourceNode);
}
+ for (AutoGroupTreeNode autogroupNode : ambiguouslyNamedAutoGroupNodes) {
+ autogroupNode.disambiguateName();
+ }
+
return allNodes;
}
@@ -452,6 +475,13 @@ public class ResourceTreeDatasource extends DataSource {
public static String idOf(Resource parentResource, ResourceType resourceType) {
return (parentResource != null) ? "autogroup_" + resourceType.getId() + "_" + parentResource.getId() : null;
}
+
+ public void disambiguateName() {
+ String typeName = StringUtility.pluralize(this.resourceType.getName());
+ String name = typeName + " (" + this.resourceType.getPlugin() + " " + MSG.common_title_plugin().toLowerCase()
+ + ")";
+ setName(name);
+ }
}
}
13 years, 2 months
[rhq] modules/core
by Heiko W. Rupp
modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 8 ++++++++
1 file changed, 8 insertions(+)
New commits:
commit 2f4429f5551a38ba82a23024707a290419cf0cb6
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 22 21:29:35 2011 +0100
Introduce new command 'stdin' that allows to give control back to the user.
This way it is possible to have a script do some setup and then continue manually.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index cbf6dde..b6a1d30 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -160,6 +160,10 @@ public class StandaloneContainer {
break;
}
+ if (answer.equalsIgnoreCase(Command.STDIN.toString())) {
+ br = new BufferedReader(new InputStreamReader(System.in));
+ }
+
// Check for history commands
answer = handleHistory(answer);
@@ -350,6 +354,9 @@ public class StandaloneContainer {
case SET:
set(tokens);
break;
+ case STDIN:
+ // handled in the outer loop
+ break;
case WAIT:
Thread.sleep(Integer.valueOf(tokens[1]));
break;
@@ -779,6 +786,7 @@ public class StandaloneContainer {
RESOURCES("res", "", 0, "Shows the discovered resources"), //
SET("set", "'resource' N", 2,
"Sets the resource id to work with. N can be a number or '$r' as result of last find resource call"), //
+ STDIN("stdin","",0, "Stop reading the batch file and wait for commands on stdin"), //
WAIT("w", "milliseconds", 1, "Waits the given amount of time"),
P_CONFIG("pc", "", 0, "Shows the plugin configuration of the current resource."),
R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource.");
13 years, 2 months
[rhq] Branch 'as7plugin' - modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/pom.xml | 20 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 88 +++++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 29 ++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java | 2
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java | 107 +++++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java | 108 ++++++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java | 104 +++++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 39 ++-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Attribute.java | 86 +++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Domain.java | 53 ++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NetworkInterface.java | 45 ++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java | 80 +++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/SocketBindingGroup.java | 47 ++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java | 67 ++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Tuple.java | 35 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Type.java | 50 ++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/TypeModelValue.java | 39 +++
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 41 +++
18 files changed, 987 insertions(+), 53 deletions(-)
New commits:
commit 92fd80e33e8367ef8cf228e35c2209037c15dad3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 22 21:13:58 2011 +0100
Update the plugin to use the JSON interface.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index cf4c3ae..ef75ab7 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -22,6 +22,7 @@
<properties>
<scm.module.path>TODO</scm.module.path>
<json.version>${project.json.version}</json.version>
+ <jackson.version>1.7.4</jackson.version>
</properties>
<build>
@@ -45,11 +46,15 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>${json.version}</version>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>${jackson.version}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>${jackson.version}</version>
</artifactItem>
-
</artifactItems>
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
@@ -177,12 +182,11 @@
<dependencies>
<dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>${json.version}</version>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>${jackson.version}</version>
</dependency>
-
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index a28dc2e..6b64b7b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -19,6 +19,8 @@
package org.rhq.modules.plugins.jbossas7;
import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
@@ -26,8 +28,9 @@ import java.net.URLConnection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.json.JSONException;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.jetbrains.annotations.Nullable;
/**
* Provide connections to the AS and reading / writing date from/to it.
@@ -53,66 +56,103 @@ public class ASConnection {
}
}
+
+ JsonNode getLevelData(@Nullable String base, boolean recursive, boolean includeMetrics) throws Exception{
+ String ops = null;
+ if (recursive)
+ ops = "recursive";
+ if (includeMetrics)
+ ops += "&include-runtime=true";
+
+ return getLevelData(base,ops);
+}
+ /**
+ * Return the default data for base
+ * @param base
+ * @return
+ * @throws Exception
+ */
+ JsonNode getLevelData(@Nullable String base) throws Exception {
+ return getLevelData(base,"operation=resource-description&recursive&include-runtime=true");
+ }
+
/**
* Return the JSON-Ojbect for a certain path.
*
- *
* @param base Path to the object/subsystem. Can be null/"" for the base objects
- * @param recursive Shall lover levels be recursively obtained. May generate a lot of data.
- * @param includeMetrics Should metrice be requested as well?
+ * @param ops Operation to run on the api can be null
* @return A JSONObject encoding the level plus sub levels provided
* @throws Exception If anything goes wrong
*/
- JSONObject getLevelData(String base, boolean recursive, boolean includeMetrics) throws Exception {
+ JsonNode getLevelData(@Nullable String base, @Nullable String ops) throws Exception {
URL url2;
+ String spec;
if (base!=null && !base.isEmpty()) {
- String spec;
if (!base.startsWith("/")) {
spec = urlString + "/" + base;
}
else {
spec = urlString + base;
}
- if (recursive)
- spec += "?recursive";
- if (includeMetrics)
- spec += "?include-runtime=true"; // TODO this will change ?query-metrics=true for metrics only
+ if (ops!=null) {
+ if (!ops.startsWith("?"))
+ ops = "?" + ops;
+ spec += ops;
+ }
url2 = new URL(spec);
}
else
url2 = url;
+ JsonNode tree = null;
+
URLConnection conn = url2.openConnection();
+ InputStream inputStream = null;
+ try {
+ inputStream = conn.getInputStream();
+ } catch (IOException e) {
+ System.err.println(e.getMessage());
+ return tree;
+ }
BufferedReader in = new BufferedReader(new InputStreamReader(
- conn.getInputStream()));
+ inputStream));
+ try {
+ String line;
+ StringBuilder builder = new StringBuilder();
+ while ((line = in.readLine()) != null) {
+ builder.append(line);
+ }
- String line;
- StringBuilder builder = new StringBuilder();
- while ((line = in.readLine()) != null) {
- builder.append(line);
- }
+ ObjectMapper mapper = new ObjectMapper();
- JSONObject object = new JSONObject(builder.toString());
+ tree = mapper.readTree(builder.toString());
+
+ } catch (IOException ioe) {
+ System.err.println("for in put " + url2 + " : " + ioe.getMessage());
+ } finally {
+ in.close();
+ }
- in.close();
- return object;
+ return tree;
}
- boolean isErrorReply(JSONObject in) {
+ boolean isErrorReply(JsonNode in) {
if (in.has("outcome")) {
String outcome = null;
try {
- outcome = in.getString("outcome");
+ JsonNode outcomeNode = in.findValue("outcome");
+ outcome = outcomeNode.getTextValue();
if (outcome.equals("failed")) {
- String reason = in.getString("failure-description");
+ JsonNode reasonNode = in.findValue("failure-description");
+ String reason = reasonNode.getTextValue();
log.info(reason);
return true;
}
- } catch (JSONException e) {
+ } catch (Exception e) {
e.printStackTrace(); // TODO
return true;
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 04264b4..2f293d9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -1,8 +1,26 @@
+/*
+ * 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 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.modules.plugins.jbossas7;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -11,8 +29,6 @@ import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
@@ -30,7 +46,6 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
ResourceContext context;
Configuration conf;
String myServerName;
- private static final String[] INTERFACE_NAMES = new String[]{"loopback","external","public"};
ASConnection connection;
String path;
String key;
@@ -91,10 +106,11 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
*/
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
- JSONObject obj = connection.getLevelData(key,false,true);
+ JsonNode obj = connection.getLevelData(key,false,true);
for (MeasurementScheduleRequest req : metrics) {
if (obj.has(req.getName())) {
+/*
String val = obj.getString(req.getName());
if (req.getDataType()== DataType.MEASUREMENT) {
@@ -105,6 +121,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
MeasurementDataTrait data = new MeasurementDataTrait(req,val);
report.addData(data);
}
+*/
}
}
}
@@ -115,7 +132,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
}
-
+ protected String getPath() { return path; }
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
index 745dc2e..d756543 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
@@ -45,7 +45,7 @@ public class DatasourceDiscovery implements ResourceDiscoveryComponent<Subsystem
for (DataSource source : sources.getDataSource()) {
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- discoveryContext.getResourceType(), // Type
+ discoveryContext.getResourceType(), // DataType
source.getJndiName(), // Key
source.getJndiName(), // Name TODO improve
null, // version
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
new file mode 100644
index 0000000..021b10c
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
@@ -0,0 +1,107 @@
+/*
+ * 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 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.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Attribute;
+import org.rhq.modules.plugins.jbossas7.json.Domain;
+import org.rhq.modules.plugins.jbossas7.json.NetworkInterface;
+
+/**
+ * Discover subsystems
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class InterfaceDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
+
+ BaseComponent parentComponent = context.getParentResourceComponent();
+ ASConnection connection = parentComponent.getASConnection();
+
+
+
+ JsonNode json = connection.getLevelData(null, null);
+ if (!connection.isErrorReply(json)) {
+ Domain domain = mapper.readValue(json, new TypeReference<Domain>() {});
+
+ for (Map.Entry<String,String> entry: domain.interfaces.entrySet()) {
+
+ String key = entry.getKey();
+ String path = "/interface/" + key;
+ JsonNode subJson = connection.getLevelData(path);
+
+ NetworkInterface networkInterface = mapper.readValue(subJson, new TypeReference<NetworkInterface>() {});
+ networkInterface.name= key;
+ for (Map.Entry<String,Attribute> nentry : networkInterface.attributes.entrySet()) {
+ nentry.getValue().name = nentry.getKey();
+
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
+ Configuration config = context.getDefaultPluginConfiguration();
+
+ PropertySimple propertySimple = new PropertySimple("path",path);
+ config.put(propertySimple);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ path, // Key
+ name, // Name
+ null, // Version
+ networkInterface.description, // Description
+ config,
+ null);
+ details.add(detail);
+ }
+ }
+
+ return details;
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
new file mode 100644
index 0000000..c9b7a5e
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
@@ -0,0 +1,108 @@
+/*
+ * 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 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.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Domain;
+import org.rhq.modules.plugins.jbossas7.json.SocketBindingGroup;
+
+/**
+ * Discover single bindings in a socket binding group
+ *
+ * TODO: Is this better a resource-configuration on the parent?
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class SocketBindingDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
+
+ BaseComponent parentComponent = context.getParentResourceComponent();
+ ASConnection connection = parentComponent.getASConnection();
+
+ String path = parentComponent.getPath();
+
+
+ JsonNode json = connection.getLevelData(path,true,false);
+ if (!connection.isErrorReply(json)) {
+
+ SocketBindingGroup bindingGroup = mapper.readValue(json, new TypeReference<SocketBindingGroup>() {});
+ // TODO put bindingGroup. {name, default-interface, port-offset into parent
+
+
+ for (Map.Entry<String,SocketBindingGroup.Binding> entry: bindingGroup.bindings.entrySet()) {
+
+ String key = entry.getKey();
+ String cpath = path + "/socket-binding/" + key;
+
+
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
+ Configuration config = context.getDefaultPluginConfiguration();
+
+ PropertySimple propertySimple = new PropertySimple("path",cpath);
+ config.put(propertySimple);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ path, // Key
+ name, // Name
+ null, // Version
+ "Binding Group", // Description
+ config,
+ null);
+ details.add(detail);
+ log.info("Added " + detail);
+ }
+
+ return details;
+
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
new file mode 100644
index 0000000..4411f8c
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
@@ -0,0 +1,104 @@
+/*
+ * 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 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.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Attribute;
+import org.rhq.modules.plugins.jbossas7.json.Domain;
+import org.rhq.modules.plugins.jbossas7.json.SocketBindingGroup;
+
+/**
+ * Discover subsystems
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class SocketBindingGroupDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
+
+ BaseComponent parentComponent = context.getParentResourceComponent();
+ ASConnection connection = parentComponent.getASConnection();
+
+
+
+ JsonNode json = connection.getLevelData(null, null);
+ if (!connection.isErrorReply(json)) {
+ Domain domain = mapper.readValue(json, new TypeReference<Domain>() {});
+
+ for (Map.Entry<String,String> entry: domain.socketBindingGroup.entrySet()) {
+
+ String key = entry.getKey();
+ String path = "/socket-binding-group/" + key;
+ JsonNode subJson = connection.getLevelData(path);
+
+ SocketBindingGroup bindingGroup = mapper.readValue(subJson, new TypeReference<SocketBindingGroup>() {});
+ bindingGroup.name= key;
+
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
+ Configuration config = context.getDefaultPluginConfiguration();
+
+ PropertySimple propertySimple = new PropertySimple("path",path);
+ config.put(propertySimple);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ path, // Key
+ name, // Name
+ null, // Version
+ "SocketBinding Group", // Description
+ config,
+ null);
+ details.add(detail);
+ }
+
+ return details;
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 7833f67..75683cb 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -20,29 +20,40 @@ package org.rhq.modules.plugins.jbossas7;
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.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Subsystem;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
-import org.json.JSONObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
/**
* Discover subsystems
*
* @author Heiko W. Rupp
*/
+@SuppressWarnings("unused")
public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+ private final Log log = LogFactory.getLog(this.getClass());
+
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
- throws InvalidPluginConfigurationException, Exception {
+ throws Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
BaseComponent parentComponent = context.getParentResourceComponent();
ASConnection connection = parentComponent.getASConnection();
@@ -61,29 +72,31 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
path = cpath;
- JSONObject o = connection.getLevelData(path,recursive, false);
- if (!connection.isErrorReply(o)) {
+ JsonNode json = connection.getLevelData(path,recursive, false);
+ if (!connection.isErrorReply(json)) {
if (recursive) {
int i = path.lastIndexOf("/");
String subPath = path.substring(i+1);
- o = o.getJSONObject(subPath);
+ JsonNode subNode = json.findPath(subPath);
+
+ Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
- Iterator keyIter = o.keys() ;
- while (keyIter.hasNext()) {
+ for (Map.Entry<String,Subsystem> entry: subsystemMap.entrySet()) {
- String key = (String) keyIter.next();
+ String key = entry.getKey();
+ Subsystem subsystem = entry.getValue();
String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // Type
+ context.getResourceType(), // DataType
path + "/" + key, // Key
name, // Name
null, // Version
- path, // Description
+ subsystem.description, // Description
config,
null);
details.add(detail);
@@ -98,7 +111,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // Type
+ context.getResourceType(), // DataType
path, // Key
name, // Name
null, // Version
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Attribute.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Attribute.java
new file mode 100644
index 0000000..02dbb5d
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Attribute.java
@@ -0,0 +1,86 @@
+/*
+ * 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 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.modules.plugins.jbossas7.json;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class Attribute {
+
+ public String name;
+ public String description;
+ public boolean required;
+ public boolean nillable;
+ @JsonProperty("access-type")
+ public AccessType accessType;
+ public Storage storage;
+ public Type type;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Attribute");
+ sb.append("{name='").append(name).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append(", required=").append(required);
+ sb.append(", nillable=").append(nillable);
+ sb.append(", accessType='").append(accessType).append('\'');
+ sb.append(", storage='").append(storage).append('\'');
+ sb.append(", type=").append(type);
+ sb.append('}');
+ return sb.toString();
+ }
+
+
+ public enum AccessType {
+ METRIC("metric"),
+ READ_ONLY("read-only")
+ ;
+
+ String jsonName;
+
+ AccessType(String jsonName) {
+ this.jsonName = jsonName;
+ }
+
+ @Override
+ public String toString() {
+ return jsonName;
+ }
+ }
+
+ public enum Storage {
+ CONFIGURATION("configuration"),
+ RUNTIME("runtime")
+ ;
+
+ String jsonName;
+
+ Storage(String jsonName) {
+ this.jsonName =jsonName;
+ }
+
+ @Override
+ public String toString() {
+ return jsonName;
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Domain.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Domain.java
new file mode 100644
index 0000000..8600c15
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Domain.java
@@ -0,0 +1,53 @@
+/*
+ * 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 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.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class Domain {
+
+
+ public String name;
+ @JsonProperty("management-interfaces") Map<String,String> managementInterfaces;
+ @JsonProperty("profile-name") String profileName;
+ public Map<String,String> path;
+ public Map<String,String> subsystem;
+ @JsonProperty("interface")
+ public Map<String,String> interfaces;
+ @JsonProperty("socket-binding-group")
+ public Map<String,String> socketBindingGroup;
+
+ @Override
+ public String toString() {
+ return "Domain{" +
+ "name='" + name + '\'' +
+ ", managementInterfaces=" + managementInterfaces +
+ ", profileName='" + profileName + '\'' +
+ ", path=" + path +
+ ", subsystem=" + subsystem +
+ ", interfaces=" + interfaces +
+ ", socketBindingGroup=" + socketBindingGroup +
+ '}';
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NetworkInterface.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NetworkInterface.java
new file mode 100644
index 0000000..0af6ed1
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NetworkInterface.java
@@ -0,0 +1,45 @@
+/*
+ * 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 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.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class NetworkInterface {
+
+ public String name;
+ public String description;
+ @JsonProperty("attributes")
+ public
+ Map<String,Attribute> attributes;
+
+
+ @Override
+ public String toString() {
+ return "NetworkInterface{" +
+ "name='" + name + '\'' +
+ ", description='" + description + '\'' +
+ ", attributes=" + attributes +
+ '}';
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
new file mode 100644
index 0000000..f00c421
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -0,0 +1,80 @@
+/*
+ * 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.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class Operation {
+ @JsonProperty("operation-name")
+ public String operationName;
+ public String description;
+ @JsonProperty("request-properties")
+ public Map<String,As7RequestProperty> requestProperties;
+// @JsonProperty("reply-properties")
+// public ArrayList<As7ReplyProperty> replyProperties;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Operation");
+ sb.append("{operationName='").append(operationName).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append(", requestProperties=").append(requestProperties);
+// sb.append(", replyProperties=").append(replyProperties);
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public static class As7RequestProperty {
+ public String description;
+ public boolean required;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("As7RequestProperty");
+ sb.append("{description='").append(description).append('\'');
+ sb.append(", required=").append(required);
+ sb.append('}');
+ return sb.toString();
+ }
+ }
+
+ public static class As7ReplyProperty {
+ @JsonProperty("value-type")
+ public String valueType;
+ public String description;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("As7ReplyProperty");
+ sb.append("{valueType='").append(valueType).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/SocketBindingGroup.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/SocketBindingGroup.java
new file mode 100644
index 0000000..5d2b6ee
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/SocketBindingGroup.java
@@ -0,0 +1,47 @@
+/*
+ * 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 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.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * One Socket binding group of a domain
+ * @author Heiko W. Rupp
+ */
+public class SocketBindingGroup {
+
+
+ public String name;
+ @JsonProperty("default-interface") public String defaultInterface;
+ @JsonProperty("port-offset") public int portOffset;
+ @JsonProperty("socket-binding") public Map<String,Binding> bindings;
+
+
+ public static class Binding {
+ public String name;
+ @JsonProperty("interface") public String iFace;
+ public int port;
+ @JsonProperty("fixed-port") public Integer fixedPort;
+ @JsonProperty("multicast-address") public String mcastAddress;
+ @JsonProperty("multicast-port") public Integer mcastPort;
+
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
new file mode 100644
index 0000000..89b41a0
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
@@ -0,0 +1,67 @@
+/*
+ * 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 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.modules.plugins.jbossas7.json;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class Subsystem {
+
+ String subsystemName;
+
+ @JsonProperty("head-comment-allowed") boolean headCommentAllowed;
+ @JsonProperty("tail-comment-allowed") boolean tailCommentAllowed;
+// public DataType type;
+ public String description;
+ @JsonProperty("attributes") Map <String,Attribute> attributes;
+ @JsonProperty("model-description")
+ Subsystem modelDescription;
+ @JsonProperty("operations") Map<String,Operation> operations = new HashMap<String, Operation>();
+ public Map<String,Subsystem> children;
+
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Subsystem");
+ sb.append("{headCommentAllowed=").append(headCommentAllowed);
+ sb.append(", tailCommentAllowed=").append(tailCommentAllowed);
+// sb.append(", type=").append(type).append('\n');
+ sb.append(", description='").append(description).append('\'').append('\n');
+ sb.append(", attributes=\n");
+ if (attributes!=null) {
+ for (Map.Entry<String,Attribute> attr : attributes.entrySet())
+ sb.append(" ").append(attr).append('\n');
+ }
+ sb.append(", model-description=").append(modelDescription).append('\n');
+ sb.append("\n, operations=");
+ if (operations!=null) {
+ for (Map.Entry<String,Operation> ops : operations.entrySet())
+ sb.append(" ").append(ops).append('\n');
+ }
+ sb.append(", children=").append(children).append('\n');
+ sb.append("\n}");
+ return sb.toString();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Tuple.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Tuple.java
new file mode 100644
index 0000000..01e31d3
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Tuple.java
@@ -0,0 +1,35 @@
+/*
+ * 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 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.modules.plugins.jbossas7.json;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class Tuple {
+ String key;
+ String value;
+
+ @Override
+ public String toString() {
+ return "Tuple{" +
+ "key='" + key + '\'' +
+ ", value='" + value + '\'' +
+ '}';
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Type.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Type.java
new file mode 100644
index 0000000..0ad1fe8
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Type.java
@@ -0,0 +1,50 @@
+/*
+ * 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 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.modules.plugins.jbossas7.json;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class Type {
+
+ @JsonProperty("TYPE_MODEL_VALUE")
+ public DataType modelValue;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Type");
+ sb.append("{modelValue='").append(modelValue).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public enum DataType {
+ STRING,
+ INT,
+ BOOLEAN,
+ OBJECT,
+ LIST
+
+ ;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/TypeModelValue.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/TypeModelValue.java
new file mode 100644
index 0000000..6856adb
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/TypeModelValue.java
@@ -0,0 +1,39 @@
+/*
+ * 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 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.modules.plugins.jbossas7.json;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class TypeModelValue {
+
+ public String TYPE_MODEL_VALUE;
+ public String value;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("TypeModelValue");
+ sb.append("{TYPE_MODEL_VALUE='").append(TYPE_MODEL_VALUE).append('\'');
+ sb.append(", value='").append(value).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index e29d0d2..98a97d8 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -93,7 +93,7 @@
</server>
- <server name="JBossAS (Standalone)"
+ <server name="JBossAS7 (Standalone)"
discovery="BaseDiscovery"
class="BaseComponent"
>
@@ -178,8 +178,47 @@
</service>
+ <service name="VHost"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/web/virtual-server/*"/>
+ </plugin-configuration>
+
+
+ </service>
+
</server>
+
+ <service name="NetworkInterface"
+ discovery="InterfaceDiscovery"
+ class="BaseComponent"
+ description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/"/>
+ </plugin-configuration>
+ </service>
+
+ <service name="SocketBindingGroup"
+ discovery="SocketBindingGroupDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/socket-binding-group/"/>
+ </plugin-configuration>
+
+ <service name="SocketBinding"
+ discovery="SocketBindingDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true"/>
+ </plugin-configuration>
+
+ </service>
+ </service>
+
+
</server>
<server name="JBossAS (Managed)"
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 699657688e73a5f6649e9ebf6f26ceade1942e8a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 22 15:52:32 2011 -0400
BZ 556960 - provide a more descriptive confirmation message when uninventorying resources.
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 a07b4b6..678ba25 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
@@ -1581,7 +1581,7 @@ view_inventory_resource_loadFailed = Resource with id [{0}] does not exist or is
view_inventory_resources_deleteConfirm = Are you sure you want to delete the selected resources?
view_inventory_resources_deleteSuccessful = You have successfully deleted the selected resources
view_inventory_resources_deleteFailed = Failed to delete the selected resources
-view_inventory_resources_uninventoryConfirm = Are you sure you want to uninventory the selected resources?
+view_inventory_resources_uninventoryConfirm = Are you sure you want to uninventory the selected resources? Note that if a selected resource still exists, then it will get rediscovered during its agent''s next discovery scan.
view_inventory_resources_uninventorySuccessful = You have successfully uninventoried the selected resources
view_inventory_resources_uninventoryFailed = Failed to uninventory the selected resources
view_inventory_resources_loadFailed = Failed to load resource composite data
13 years, 2 months
[rhq] modules/plugins
by lkrejci
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 2
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 44 ++++++----
2 files changed, 30 insertions(+), 16 deletions(-)
New commits:
commit 81d73ed70f5a5bad8c1741b9116b6f991982a568
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Mar 22 19:39:44 2011 +0100
BZ 689833 - restoring the original behavior of getMainServerSampleAddress().
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index ee3e2ea..b43e156 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -502,7 +502,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostAddressStrings.length);
if (vhostAddressStrings.length == 1 && MAIN_SERVER_RESOURCE_KEY.equals(vhostAddressStrings[0])) {
- List<HttpdAddressUtility.Address> serverAddrs = parent.getAddressUtility().getAllMainServerAddresses(tree);
+ List<HttpdAddressUtility.Address> serverAddrs = parent.getAddressUtility().getAllMainServerAddresses(tree, true);
if (serverAddrs != null) {
vhostAddresses.addAll(serverAddrs);
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index 8ecdb7b..6b9e686 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -42,7 +42,7 @@ public enum HttpdAddressUtility {
APACHE_1_3 {
- public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag) {
+ public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag, boolean substituteWildcards) {
try {
List<ApacheDirective> ports = ag.search("/Port");
List<ApacheDirective> bindAddresses = ag.search("/BindAddress");
@@ -75,14 +75,14 @@ public enum HttpdAddressUtility {
}
for (Address address : addresses) {
- if (!address.isPortDefined() || address.isPortWildcard()) {
+
+ if (!address.isPortDefined()) {
address.port = 80;
}
- if (address.host == null || address.isHostDefault() || address.isHostWildcard()) {
- address = getLocalhost(address.port);
- }
- updateWithServerName(address, ag);
+ if (substituteWildcards) {
+ substituteWildcards(ag, address);
+ }
}
return addresses;
@@ -95,17 +95,16 @@ public enum HttpdAddressUtility {
},
APACHE_2_x {
- public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag) {
+ public List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag, boolean substituteWildcards) {
try {
List<Address> ret = new ArrayList<Address>();
for(ApacheDirective n : ag.search("/Listen")) {
Address addr = parseListen(n.getValues().get(0));
- if (addr.host == null || addr.isHostDefault() || addr.isHostWildcard()) {
- addr = getLocalhost(addr.port);
- }
- updateWithServerName(addr, ag);
+ if (substituteWildcards) {
+ substituteWildcards(ag, addr);
+ }
ret.add(addr);
}
@@ -283,9 +282,10 @@ public enum HttpdAddressUtility {
* This returns all the addresses the server listens on.
*
* @param ag the tree of the httpd configuration
+ * @param substituteWildcards true if wildcard substitution should be made on host and port specs
* @return the addresses or null on failure
*/
- public abstract List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag);
+ public abstract List<Address> getAllMainServerAddresses(ApacheDirectiveTree ag, boolean substituteWildcards);
/**
* This just constructs a first available address under which the server or one of its virtual hosts can be reached.
@@ -297,7 +297,7 @@ public enum HttpdAddressUtility {
* @return the address or null on failure
*/
public Address getMainServerSampleAddress(ApacheDirectiveTree ag, String limitToHost, int limitToPort) {
- List<Address> addressesToMatch = getAllMainServerAddresses(ag);
+ List<Address> addressesToMatch = getAllMainServerAddresses(ag, false);
if (addressesToMatch == null) {
return null;
@@ -305,6 +305,7 @@ public enum HttpdAddressUtility {
for (Address address : addressesToMatch) {
if (isAddressConforming(address, limitToHost, limitToPort, false)) {
+ substituteWildcards(ag, address);
return address;
}
}
@@ -362,6 +363,19 @@ public enum HttpdAddressUtility {
return ret;
}
+ private static void substituteWildcards(ApacheDirectiveTree ag, Address address) {
+ if (address.isPortWildcard()) {
+ address.port = 80;
+ }
+
+ if (address.host == null || address.isHostDefault() || address.isHostWildcard()) {
+ address = getLocalhost(address.port);
+ }
+
+ updateWithServerName(address, ag);
+
+ }
+
/**
* Checks that given address represents a possibly wildcarded limitingHost and limitingPort values.
*
@@ -417,7 +431,7 @@ public enum HttpdAddressUtility {
}
}
- private static void updateWithServerName(Address address, ApacheDirectiveTree config) throws UnknownHostException {
+ private static void updateWithServerName(Address address, ApacheDirectiveTree config) {
//check if there is a ServerName directive
List<ApacheDirective> serverNameNodes = config.search("/ServerName");
@@ -430,7 +444,7 @@ public enum HttpdAddressUtility {
}
}
- private static void updateWithServerName(Address address, String serverName) throws UnknownHostException {
+ private static void updateWithServerName(Address address, String serverName) {
//the configuration may be invalid and/or the hostname can be unresolvable.
//we try to match the address with the servername first by IP address
//but if that fails (i.e. the hostname couldn't be resolved to an IP)
13 years, 2 months
[rhq] modules/core
by mazz
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 40268c81269d521f62f0286322528b9200afe939
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 22 14:09:54 2011 -0400
the Configuration History reports view barfs when sorting on Resource column (and other ways).
The problem was the generated query has a bad ORDER BY clause.
some how this fix made a difference. Looks like the name of the addSortABC method needs to match the name of the override/data field member name.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
index e8c7cf6..d2e024c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceConfigurationUpdateCriteria.java
@@ -41,7 +41,7 @@ import org.rhq.core.domain.util.PageOrdering;
public class ResourceConfigurationUpdateCriteria extends AbstractResourceConfigurationUpdateCriteria {
private static final long serialVersionUID = 1L;
- public static final String SORT_FIELD_RESOURCE_NAME = "name";
+ public static final String SORT_FIELD_RESOURCE_NAME = "resourceName";
public static final String SORT_FIELD_RESOURCE_ID = "resourceId";
private Integer filterGroupConfigurationUpdateId; // required overrides
@@ -53,7 +53,7 @@ public class ResourceConfigurationUpdateCriteria extends AbstractResourceConfigu
private boolean fetchResource;
private boolean fetchGroupConfigurationUpdate;
- private PageOrdering sortName; // requires sort override
+ private PageOrdering sortResourceName; // requires sort override
private PageOrdering sortResourceId; // requires sort override
public ResourceConfigurationUpdateCriteria() {
@@ -107,7 +107,7 @@ public class ResourceConfigurationUpdateCriteria extends AbstractResourceConfigu
public void addSortResourceName(PageOrdering sortName) {
addSortField(SORT_FIELD_RESOURCE_NAME);
- this.sortName = sortName;
+ this.sortResourceName = sortName;
}
public void addSortResourceId(PageOrdering sortResourceId) {
13 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java | 47 ++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java | 17 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java | 7 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java | 7 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 10 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 9 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 38 ++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java | 33 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java | 30 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java | 55 +++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java | 36 +++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java | 35 +++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java | 36 +++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java | 13 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java | 6 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java | 28 ++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java | 12 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 31 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java | 34 +++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementDataTraitDataSource.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java | 12 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java | 25 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java | 56 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java | 8 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 8 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java | 8 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 15 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java | 20 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java | 19 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java | 18 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java | 19 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 7 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java | 42 ++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java | 13 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java | 30 ++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java | 26 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 7 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryDataSource.java | 33 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryDataSource.java | 32 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java | 20 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java | 38 +++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java | 31 ++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 12 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 12 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java | 29 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 11 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 37 ++++--
74 files changed, 743 insertions(+), 484 deletions(-)
New commits:
commit 76890a051997d03d425248a2bfb16b89b4df74b8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Mar 22 12:05:29 2011 -0400
BZ 682304 - change the RPCDataSource generic template to accept a Criteria type so we can implement a strongly typed getFetchCriteria on all datasources.
the main goal here is to ensure the pageControl is set,
and we do this by refactoring the creation of the criteria
out of the executeFetch so the subclass can get the fetch criteria
and perform some work on it (like setting page controls)
and then calling executeFetch.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
index 39c2e67..d3583ac 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
@@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Simeon Pinder
*/
-public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
+public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup, org.rhq.core.domain.criteria.Criteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
@@ -64,7 +64,7 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
public RoleLdapGroupSelector(String locatorId, ListGridRecord[] assignedRecords, boolean isReadOnly) {
super(locatorId, isReadOnly);
-
+
setAssigned(assignedRecords);
}
@@ -83,7 +83,7 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
}
@Override
- protected RPCDataSource<LdapGroup> getDataSource() {
+ protected RPCDataSource<LdapGroup, org.rhq.core.domain.criteria.Criteria> getDataSource() {
return new LdapGroupsDataSource();
}
@@ -104,7 +104,7 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
return MSG.common_title_ldapGroups();
}
- public static class LdapGroupsDataSource extends RPCDataSource<LdapGroup> {
+ public static class LdapGroupsDataSource extends RPCDataSource<LdapGroup, org.rhq.core.domain.criteria.Criteria> {
//cache ldap group data from external server
private Set<Map<String, String>> cachedLdapGroupsAvailable;
@@ -142,17 +142,24 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final org.rhq.core.domain.criteria.Criteria unused) {
//if not null then go through to initialize
if (cachedLdapGroupsAvailable == null) {
fetchLdapGroupsFromServerAsync(request, response);
} else {//use cached data and return correct response
//process cachedLdapGroupsAvailable based on criteria
PageList<LdapGroup> ldapGroups = filterCachedLdapGroups(request);
- sendSuccessResponse(request, response, ldapGroups);
+ sendSuccessResponse(request, response, ldapGroups);
}
}
+ @Override
+ protected org.rhq.core.domain.criteria.Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
private PageList<LdapGroup> filterCachedLdapGroups(DSRequest request) {
//populate the indexed map
if (cachedNameKeyedMap == null) {
@@ -181,27 +188,25 @@ public class RoleLdapGroupSelector extends AbstractSelector<LdapGroup> {
} else {//return full list .. as no filtering done.
locatedGroupMaps = cachedLdapGroupsAvailable;
}
- @SuppressWarnings({"UnnecessaryLocalVariable"})
+ @SuppressWarnings( { "UnnecessaryLocalVariable" })
PageList<LdapGroup> ldapGroups = convertToPageList(locatedGroupMaps);
return ldapGroups;
}
private void fetchLdapGroupsFromServerAsync(final DSRequest request, final DSResponse response) {
- GWTServiceLookup.getLdapService().findAvailableGroups(
- new AsyncCallback<Set<Map<String, String>>>() {
- public void onSuccess(Set<Map<String, String>> locatedGroupMaps) {
- Log.debug("Successfully located " + locatedGroupMaps.size() + " available LDAP groups.");
- cachedLdapGroupsAvailable = locatedGroupMaps;
- //all groups displayed initially
- PageList<LdapGroup> ldapGroups = convertToPageList(locatedGroupMaps);
- sendSuccessResponse(request, response, ldapGroups);
- }
+ GWTServiceLookup.getLdapService().findAvailableGroups(new AsyncCallback<Set<Map<String, String>>>() {
+ public void onSuccess(Set<Map<String, String>> locatedGroupMaps) {
+ Log.debug("Successfully located " + locatedGroupMaps.size() + " available LDAP groups.");
+ cachedLdapGroupsAvailable = locatedGroupMaps;
+ //all groups displayed initially
+ PageList<LdapGroup> ldapGroups = convertToPageList(locatedGroupMaps);
+ sendSuccessResponse(request, response, ldapGroups);
+ }
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError(MSG.view_adminRoles_failLdapGroupsRole(),
- throwable);
- }
- });//end of findAvailableGroups
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_adminRoles_failLdapGroupsRole(), throwable);
+ }
+ });//end of findAvailableGroups
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
index a7653e2..99e0dbf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleSubjectSelector.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersDataSource;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
@@ -38,18 +39,18 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class RoleSubjectSelector extends AbstractSelector<Subject> {
-
+public class RoleSubjectSelector extends AbstractSelector<Subject, SubjectCriteria> {
+
private static final String ITEM_ICON = "global/User_16.png";
public RoleSubjectSelector(String id, ListGridRecord[] subjectRecords, boolean isReadOnly) {
super(id, isReadOnly);
-
+
setAssigned(subjectRecords);
}
@Override
- protected RPCDataSource<Subject> getDataSource() {
+ protected RPCDataSource<Subject, SubjectCriteria> getDataSource() {
return new RoleUsersDataSource();
}
@@ -80,7 +81,7 @@ public class RoleSubjectSelector extends AbstractSelector<Subject> {
for (Record record : records) {
Integer id = record.getAttributeAsInt(Field.ID);
if (id.equals(ID_RHQADMIN)) {
- rhqAdminRecord = record;
+ rhqAdminRecord = record;
}
}
if (rhqAdminRecord != null) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
index 9fefcb3..3af67b6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesDataSource.java
@@ -52,7 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class RolesDataSource extends RPCDataSource<Role> {
+public class RolesDataSource extends RPCDataSource<Role, RoleCriteria> {
public static abstract class Field {
public static final String ID = "id";
@@ -124,9 +124,7 @@ public class RolesDataSource extends RPCDataSource<Role> {
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- RoleCriteria criteria = getFetchCriteria(request);
-
+ public void executeFetch(final DSRequest request, final DSResponse response, final RoleCriteria criteria) {
roleService.findRolesByCriteria(criteria, new AsyncCallback<PageList<Role>>() {
public void onFailure(Throwable caught) {
sendFailureResponse(request, response, MSG.view_adminRoles_failRoles(), caught);
@@ -142,7 +140,6 @@ public class RolesDataSource extends RPCDataSource<Role> {
protected void executeAdd(Record recordToAdd, final DSRequest request, final DSResponse response) {
Role roleToAdd = copyValues(recordToAdd);
- final String rolename = roleToAdd.getName();
roleService.createRole(roleToAdd, new AsyncCallback<Role>() {
public void onFailure(Throwable caught) {
throw new RuntimeException(caught);
@@ -235,8 +232,8 @@ public class RolesDataSource extends RPCDataSource<Role> {
if (cascade) {
Set<ResourceGroup> resourceGroups = sourceRole.getResourceGroups();
- ListGridRecord[] resourceGroupRecords = ResourceGroupsDataSource.getInstance().buildRecords(
- resourceGroups, false);
+ ListGridRecord[] resourceGroupRecords = ResourceGroupsDataSource.getInstance().buildRecords(resourceGroups,
+ false);
targetRecord.setAttribute(Field.RESOURCE_GROUPS, resourceGroupRecords);
Set<Subject> subjects = sourceRole.getSubjects();
@@ -244,8 +241,8 @@ public class RolesDataSource extends RPCDataSource<Role> {
targetRecord.setAttribute(Field.SUBJECTS, subjectRecords);
Set<LdapGroup> ldapGroups = sourceRole.getLdapGroups();
- ListGridRecord[] ldapGroupRecords = new RoleLdapGroupSelector.LdapGroupsDataSource().buildRecords(
- ldapGroups);
+ ListGridRecord[] ldapGroupRecords = new RoleLdapGroupSelector.LdapGroupsDataSource()
+ .buildRecords(ldapGroups);
targetRecord.setAttribute(Field.LDAP_GROUPS, ldapGroupRecords);
}
@@ -273,7 +270,7 @@ public class RolesDataSource extends RPCDataSource<Role> {
return permissionRecords;
}
- private RoleCriteria getFetchCriteria(DSRequest request) {
+ protected RoleCriteria getFetchCriteria(DSRequest request) {
RoleCriteria criteria = new RoleCriteria();
// Pagination
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
index f37c90a..63e49cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
@@ -23,7 +23,6 @@ import java.util.List;
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.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -64,12 +63,6 @@ public class TemplateSchedulesDataSource extends AbstractMeasurementScheduleComp
}
@Override
- protected void executeFetch(DSRequest request, DSResponse response) {
- super.executeFetch(request, response);
-
- }
-
- @Override
protected EntityContext getEntityContext(DSRequest request) {
Criteria requestCriteria = request.getCriteria();
Integer typeId = requestCriteria.getAttributeAsInt(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
index df5036c..1c27994 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/SubjectRoleSelector.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.criteria.RoleCriteria;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesDataSource;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -34,7 +35,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class SubjectRoleSelector extends AbstractSelector<Role> {
+public class SubjectRoleSelector extends AbstractSelector<Role, RoleCriteria> {
private static final String ITEM_ICON = "global/Role_16.png";
public SubjectRoleSelector(String locatorId, ListGridRecord[] roleRecords, boolean isReadOnly) {
@@ -48,7 +49,7 @@ public class SubjectRoleSelector extends AbstractSelector<Role> {
}
@Override
- protected RPCDataSource<Role> getDataSource() {
+ protected RPCDataSource<Role, RoleCriteria> getDataSource() {
return new RolesDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
index 5b76b5e..d6f536b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersDataSource.java
@@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
* @author Greg Hinkle
* @author Ian Springer
*/
-public class UsersDataSource extends RPCDataSource<Subject> {
+public class UsersDataSource extends RPCDataSource<Subject, SubjectCriteria> {
private static UsersDataSource INSTANCE;
@@ -162,8 +162,8 @@ public class UsersDataSource extends RPCDataSource<Subject> {
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- SubjectCriteria criteria = getFetchCriteria(request);
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, final SubjectCriteria criteria) {
subjectService.findSubjectsByCriteria(criteria, new AsyncCallback<PageList<Subject>>() {
public void onFailure(Throwable caught) {
@@ -329,6 +329,7 @@ public class UsersDataSource extends RPCDataSource<Subject> {
return to;
}
+ @Override
protected SubjectCriteria getFetchCriteria(DSRequest request) {
SubjectCriteria criteria = new SubjectCriteria();
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 ddc343f..5ca88d6 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
@@ -70,7 +70,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Joseph Marques
* @author John Mazzitelli
*/
-public class AlertDataSource extends RPCDataSource<Alert> {
+public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
private AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService();
private EntityContext entityContext;
@@ -214,11 +214,10 @@ public class AlertDataSource extends RPCDataSource<Alert> {
return fields;
}
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final AlertCriteria criteria) {
final long start = System.currentTimeMillis();
- AlertCriteria criteria = getCriteria(request);
-
this.alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
public void onFailure(Throwable caught) {
@@ -283,7 +282,8 @@ public class AlertDataSource extends RPCDataSource<Alert> {
});
}
- protected AlertCriteria getCriteria(DSRequest request) {
+ @Override
+ protected AlertCriteria getFetchCriteria(DSRequest request) {
AlertCriteria criteria = new AlertCriteria();
criteria.setPageControl(getPageControl(request));
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 ee50f73..afcb435 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
@@ -49,7 +49,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<AlertDefinition> {
+public abstract class AbstractAlertDefinitionsDataSource extends
+ RPCDataSource<AlertDefinition, AlertDefinitionCriteria> {
protected static final String FIELD_ID = "id";
protected static final String FIELD_NAME = "name";
@@ -184,8 +185,8 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- AlertDefinitionCriteria criteria = getCriteria(request);
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final AlertDefinitionCriteria criteria) {
GWTServiceLookup.getAlertDefinitionService().findAlertDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<AlertDefinition>>() {
public void onFailure(Throwable caught) {
@@ -207,8 +208,6 @@ public abstract class AbstractAlertDefinitionsDataSource extends RPCDataSource<A
processResponse(request.getRequestId(), response);
}
- protected abstract AlertDefinitionCriteria getCriteria(DSRequest request);
-
/**
* Returns a criteria that will query for all alerts, but only for the ID and name fields.
* @return criteria for an inexpensive query to obtain all alert defs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index aa6d838..9958d0c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -38,6 +38,7 @@ import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertCondition;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.alert.AlertFormatUtility;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
@@ -128,8 +129,9 @@ public class ConditionsEditor extends LocatableVLayout {
}
});
- NewConditionEditor newConditionEditor = new NewConditionEditor(extendLocatorId("newConditionEditor"),
- conditions, ConditionsEditor.this.resourceType, new Runnable() {
+ NewConditionEditor newConditionEditor = new NewConditionEditor(
+ extendLocatorId("newConditionEditor"), conditions, ConditionsEditor.this.resourceType,
+ new Runnable() {
@Override
public void run() {
winModal.markForDestroy();
@@ -139,23 +141,23 @@ public class ConditionsEditor extends LocatableVLayout {
winModal.addItem(newConditionEditor);
winModal.show();
}
- });
-
- table.addTableAction(this.extendLocatorId("delete"), MSG.common_button_delete(), MSG
- .view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- for (ListGridRecord record : selection) {
- AlertCondition cond = getDataSource().copyValues(record);
- conditions.remove(cond);
+ });
+
+ table.addTableAction(this.extendLocatorId("delete"), MSG.common_button_delete(), MSG
+ .view_alert_definitions_delete_confirm(), new AbstractTableAction(TableActionEnablement.ANY) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ for (ListGridRecord record : selection) {
+ AlertCondition cond = getDataSource().copyValues(record);
+ conditions.remove(cond);
+ }
+ refresh();
}
- refresh();
- }
- });
+ });
}
}
- private class ConditionDataSource extends RPCDataSource<AlertCondition> {
+ private class ConditionDataSource extends RPCDataSource<AlertCondition, Criteria> {
private static final String FIELD_OBJECT = "obj";
private static final String FIELD_CONDITION = "condition";
@@ -190,9 +192,15 @@ public class ConditionsEditor extends LocatableVLayout {
}
@Override
- protected void executeFetch(DSRequest request, DSResponse response) {
+ protected void executeFetch(DSRequest request, DSResponse response, Criteria unused) {
response.setData(buildRecords(conditions));
processResponse(request.getRequestId(), response);
}
+
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
index bb2cc71..f7d7081 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
@@ -45,7 +45,7 @@ public class GroupAlertDefinitionsDataSource extends AbstractAlertDefinitionsDat
}
@Override
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ protected AlertDefinitionCriteria getFetchCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
Criteria requestCriteria = request.getCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index 970fb66..ae0e673 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -44,6 +44,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
@@ -167,7 +168,7 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
}
}
- private class NotificationDataSource extends RPCDataSource<AlertNotification> {
+ private class NotificationDataSource extends RPCDataSource<AlertNotification, Criteria> {
public NotificationDataSource() {
super();
List<DataSourceField> fields = addDataSourceFields();
@@ -206,7 +207,13 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
final Record[] records = buildRecords(notifications); // partially builds the records, but we need to do another remote call to get the config preview
AlertNotification[] notifs = notifications.toArray(new AlertNotification[notifications.size()]);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index 1ac2862..de1ec1f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -120,7 +120,7 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
}
@Override
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ protected AlertDefinitionCriteria getFetchCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.fetchGroupAlertDefinition(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java
index faf8087..c4a7c51 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemRolesNotificationSenderForm.java
@@ -161,7 +161,7 @@ public class SystemRolesNotificationSenderForm extends AbstractNotificationSende
return builder.toString();
}
- private class RoleSelector extends AbstractSelector<Role> {
+ private class RoleSelector extends AbstractSelector<Role, RoleCriteria> {
public RoleSelector(String id, Collection<Role> roles) {
super(id);
if (roles != null) {
@@ -171,7 +171,7 @@ public class SystemRolesNotificationSenderForm extends AbstractNotificationSende
}
@Override
- protected RPCDataSource<Role> getDataSource() {
+ protected RPCDataSource<Role, RoleCriteria> getDataSource() {
return new RolesDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
index fd67e71..e7139a7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SystemUsersNotificationSenderForm.java
@@ -172,7 +172,7 @@ public class SystemUsersNotificationSenderForm extends AbstractNotificationSende
return builder.toString();
}
- private class SubjectSelector extends AbstractSelector<Subject> {
+ private class SubjectSelector extends AbstractSelector<Subject, SubjectCriteria> {
public SubjectSelector(String id, Collection<Subject> subjects) {
super(id);
if (subjects != null) {
@@ -182,7 +182,7 @@ public class SystemUsersNotificationSenderForm extends AbstractNotificationSende
}
@Override
- protected RPCDataSource<Subject> getDataSource() {
+ protected RPCDataSource<Subject, SubjectCriteria> getDataSource() {
return new UsersDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
index 15163f0..9e5590e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
@@ -45,7 +45,7 @@ public class TemplateAlertDefinitionsDataSource extends AbstractAlertDefinitions
}
@Override
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ protected AlertDefinitionCriteria getFetchCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
Criteria requestCriteria = request.getCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
index c4de0d7..fd1a659 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/BundleSelector.java
@@ -29,6 +29,7 @@ import com.smartgwt.client.widgets.form.fields.TextItem;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundlesDataSource;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
@@ -40,7 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Jay Shaughnessy
*/
-public class BundleSelector extends AbstractSelector<Bundle> {
+public class BundleSelector extends AbstractSelector<Bundle, BundleCriteria> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
@@ -73,7 +74,7 @@ public class BundleSelector extends AbstractSelector<Bundle> {
return availableFilterForm;
}
- protected RPCDataSource<Bundle> getDataSource() {
+ protected RPCDataSource<Bundle, BundleCriteria> getDataSource() {
return new BundlesDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java
index d04569b..1017215 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleStep.java
@@ -24,6 +24,7 @@ import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.enterprise.gui.coregui.client.bundle.BundleSelector;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
@@ -33,7 +34,7 @@ public class SelectBundleStep extends AbstractWizardStep {
private final BundleDeployWizard wizard;
- private AbstractSelector<Bundle> selector;
+ private AbstractSelector<Bundle, BundleCriteria> selector;
public SelectBundleStep(BundleDeployWizard wizard) {
this.wizard = wizard;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java
index f8ec6dc..49e373b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/selection/PlatformResourceGroupSelector.java
@@ -4,9 +4,7 @@ import com.smartgwt.client.data.DSRequest;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceGroupSelector;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public class PlatformResourceGroupSelector extends ResourceGroupSelector {
@@ -15,7 +13,7 @@ public class PlatformResourceGroupSelector extends ResourceGroupSelector {
}
@Override
- protected RPCDataSource<ResourceGroup> getDataSource() {
+ protected SelectedPlatformResourceGroupsDataSource getDataSource() {
return new SelectedPlatformResourceGroupsDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
index 917b13d..e523cad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
@@ -46,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment> {
+public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment, BundleDeploymentCriteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
@@ -97,7 +97,23 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final BundleDeploymentCriteria criteria) {
+ bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deploy_loadDeployFailure(), caught);
+ }
+
+ public void onSuccess(PageList<BundleDeployment> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ }
+
+ @Override
+ protected BundleDeploymentCriteria getFetchCriteria(final DSRequest request) {
BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
criteria.fetchBundleVersion(true);
@@ -126,18 +142,7 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
if (request.getCriteria().getValues().get("tagName") != null) {
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
- bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deploy_loadDeployFailure(), caught);
- }
-
- public void onSuccess(PageList<BundleDeployment> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
-
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
index 74e7feb..b99ab75 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
@@ -36,19 +36,17 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
-import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundleVersionDataSource;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleDeploymentListView extends Table<RPCDataSource<BundleDeployment>> {
+public class BundleDeploymentListView extends Table<BundleDeploymentDataSource> {
private final boolean canManageBundles;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
index 019794b..6b2be22 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/resource/BundleResourceDeploymentDataSource.java
@@ -44,7 +44,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleResourceDeployment> {
+public class BundleResourceDeploymentDataSource extends
+ RPCDataSource<BundleResourceDeployment, BundleResourceDeploymentCriteria> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
public BundleResourceDeploymentDataSource() {
@@ -71,18 +72,8 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- BundleResourceDeploymentCriteria criteria = new BundleResourceDeploymentCriteria();
- criteria.fetchResource(true);
- criteria.fetchBundleDeployment(true);
- criteria.fetchHistories(true);
-
- if (request.getCriteria().getValues().containsKey("bundleDeploymentId")) {
- criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute(
- "bundleDeploymentId")));
- }
-
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final BundleResourceDeploymentCriteria criteria) {
bundleService.findBundleResourceDeploymentsByCriteria(criteria,
new AsyncCallback<PageList<BundleResourceDeployment>>() {
public void onFailure(Throwable caught) {
@@ -94,7 +85,20 @@ public class BundleResourceDeploymentDataSource extends RPCDataSource<BundleReso
processResponse(request.getRequestId(), response);
}
});
+ }
+ @Override
+ protected BundleResourceDeploymentCriteria getFetchCriteria(final DSRequest request) {
+ BundleResourceDeploymentCriteria criteria = new BundleResourceDeploymentCriteria();
+ criteria.fetchResource(true);
+ criteria.fetchBundleDeployment(true);
+ criteria.fetchHistories(true);
+
+ if (request.getCriteria().getValues().containsKey("bundleDeploymentId")) {
+ criteria.addFilterBundleDeploymentId(Integer.parseInt(request.getCriteria().getAttribute(
+ "bundleDeploymentId")));
+ }
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
index 1a6f3dc..094571e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationDataSource.java
@@ -47,7 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleDestinationDataSource extends RPCDataSource<BundleDestination> {
+public class BundleDestinationDataSource extends RPCDataSource<BundleDestination, BundleDestinationCriteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
@@ -107,30 +107,8 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- BundleDestinationCriteria criteria = new BundleDestinationCriteria();
-
- if (request.getCriteria().getValues().containsKey(FIELD_BUNDLE_ID)) {
- criteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString(FIELD_BUNDLE_ID)));
- }
-
- if (request.getCriteria().getValues().get("tagNamespace") != null) {
- criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
- }
-
- if (request.getCriteria().getValues().get("tagSemantic") != null) {
- criteria.addFilterTagSemantic((String) request.getCriteria().getValues().get("tagSemantic"));
- }
-
- if (request.getCriteria().getValues().get("tagName") != null) {
- criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
- }
-
- criteria.fetchBundle(true);
- criteria.fetchDeployments(true);
- criteria.fetchGroup(true);
- criteria.fetchTags(true);
-
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final BundleDestinationCriteria criteria) {
GWTServiceLookup.getBundleService().findBundleDestinationsByCriteria(criteria,
new AsyncCallback<PageList<BundleDestination>>() {
public void onFailure(Throwable caught) {
@@ -169,6 +147,33 @@ public class BundleDestinationDataSource extends RPCDataSource<BundleDestination
}
@Override
+ protected BundleDestinationCriteria getFetchCriteria(final DSRequest request) {
+ BundleDestinationCriteria criteria = new BundleDestinationCriteria();
+
+ if (request.getCriteria().getValues().containsKey(FIELD_BUNDLE_ID)) {
+ criteria.addFilterBundleId(Integer.parseInt(request.getCriteria().getAttributeAsString(FIELD_BUNDLE_ID)));
+ }
+
+ if (request.getCriteria().getValues().get("tagNamespace") != null) {
+ criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
+ }
+
+ if (request.getCriteria().getValues().get("tagSemantic") != null) {
+ criteria.addFilterTagSemantic((String) request.getCriteria().getValues().get("tagSemantic"));
+ }
+
+ if (request.getCriteria().getValues().get("tagName") != null) {
+ criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
+ }
+
+ criteria.fetchBundle(true);
+ criteria.fetchDeployments(true);
+ criteria.fetchGroup(true);
+ criteria.fetchTags(true);
+ return criteria;
+ }
+
+ @Override
public BundleDestination copyValues(Record from) {
return (BundleDestination) from.getAttributeAsObject("object");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
index 00d25df..e95626c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
@@ -35,16 +35,14 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
-import org.rhq.core.domain.bundle.BundleDestination;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleDestinationListView extends Table<RPCDataSource<BundleDestination>> {
+public class BundleDestinationListView extends Table<BundleDestinationDataSource> {
public BundleDestinationListView(String locatorId) {
this(locatorId, null);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
index 11edfdf..5cfabd6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java
@@ -40,7 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author John Mazzitelli
*/
-public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
+public class BundleVersionDataSource extends RPCDataSource<BundleVersion, BundleVersionCriteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_BUNDLE_ID = "bundleId";
@@ -83,8 +83,24 @@ public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BundleVersionCriteria criteria) {
+ bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_bundleVersion_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ public void onSuccess(PageList<BundleVersion> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected BundleVersionCriteria getFetchCriteria(final DSRequest request) {
BundleVersionCriteria criteria = new BundleVersionCriteria();
criteria.fetchBundleFiles(true);
criteria.fetchBundle(true);
@@ -106,21 +122,7 @@ public class BundleVersionDataSource extends RPCDataSource<BundleVersion> {
if (request.getCriteria().getValues().get("tagName") != null) {
criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
}
-
- bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_bundleVersion_loadFailure(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<BundleVersion> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
-
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
index 4fe31e0..dd74999 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesDataSource.java
@@ -40,7 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundlesDataSource extends RPCDataSource<Bundle> {
+public class BundlesDataSource extends RPCDataSource<Bundle, BundleCriteria> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
@@ -71,8 +71,24 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BundleCriteria criteria) {
+ bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_bundle_loadFailed(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ public void onSuccess(PageList<Bundle> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected BundleCriteria getFetchCriteria(final DSRequest request) {
BundleCriteria criteria = new BundleCriteria();
criteria.setPageControl(getPageControl(request));
@@ -98,20 +114,7 @@ public class BundlesDataSource extends RPCDataSource<Bundle> {
// criteria.setSearchExpression(request.getCriteria().getValues().get("search").toString());
// }
- bundleService.findBundlesByCriteria(criteria, new AsyncCallback<PageList<Bundle>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.dataSource_bundle_loadFailed(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<Bundle> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
-
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
index ceb3c30..023fd1f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java
@@ -47,7 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablem
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
@@ -58,7 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public class BundlesListView extends Table<RPCDataSource<BundleWithLatestVersionComposite>> {
+public class BundlesListView extends Table<BundlesWithLatestVersionDataSource> {
private final Set<Permission> permissions;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
index 16b48c7..fc16c70 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesWithLatestVersionDataSource.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author John Mazzitelli
*/
-public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWithLatestVersionComposite> {
+public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWithLatestVersionComposite, BundleCriteria> {
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
@@ -57,22 +57,7 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- BundleCriteria criteria = new BundleCriteria();
- criteria.setPageControl(getPageControl(request));
- if (request.getCriteria().getValues().get("tagNamespace") != null) {
- criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
- }
-
- if (request.getCriteria().getValues().get("tagSemantic") != null) {
- criteria.addFilterTagSemantic((String) request.getCriteria().getValues().get("tagSemantic"));
- }
-
- if (request.getCriteria().getValues().get("tagName") != null) {
- criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
- }
-
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BundleCriteria criteria) {
bundleService.findBundlesWithLatestVersionCompositesByCriteria(criteria,
new AsyncCallback<PageList<BundleWithLatestVersionComposite>>() {
public void onFailure(Throwable caught) {
@@ -87,7 +72,24 @@ public class BundlesWithLatestVersionDataSource extends RPCDataSource<BundleWith
processResponse(request.getRequestId(), response);
}
});
+ }
+
+ @Override
+ protected BundleCriteria getFetchCriteria(final DSRequest request) {
+ BundleCriteria criteria = new BundleCriteria();
+ criteria.setPageControl(getPageControl(request));
+ if (request.getCriteria().getValues().get("tagNamespace") != null) {
+ criteria.addFilterTagNamespace((String) request.getCriteria().getValues().get("tagNamespace"));
+ }
+ if (request.getCriteria().getValues().get("tagSemantic") != null) {
+ criteria.addFilterTagSemantic((String) request.getCriteria().getValues().get("tagSemantic"));
+ }
+
+ if (request.getCriteria().getValues().get("tagName") != null) {
+ criteria.addFilterTagName((String) request.getCriteria().getValues().get("tagName"));
+ }
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index 61b29ce..039bc3e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -43,6 +43,7 @@ import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleDestinationCriteria;
import org.rhq.core.domain.criteria.BundleVersionCriteria;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
@@ -52,8 +53,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-@SuppressWarnings("unchecked")
-public class BundleTreeDataSource extends RPCDataSource {
+public class BundleTreeDataSource extends RPCDataSource<Object, Criteria> {
private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
private final boolean canManageBundles;
@@ -85,7 +85,7 @@ public class BundleTreeDataSource extends RPCDataSource {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
String p = request.getCriteria().getAttribute("parentId");
@@ -170,6 +170,13 @@ public class BundleTreeDataSource extends RPCDataSource {
}
@Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // our executeFetch will determine on its own what criteria to use based on what is to be fetched
+ // thus we don't return anything here and let the executeFetch do everything
+ return null;
+ }
+
+ @Override
public Object copyValues(Record from) {
return null; // don't need this method.
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java
index 247907a..10e1e43 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionListView.java
@@ -31,17 +31,15 @@ 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.bundle.BundleVersion;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundleVersionDataSource;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class BundleVersionListView extends Table<RPCDataSource<BundleVersion>> {
+public class BundleVersionListView extends Table<BundleVersionDataSource> {
public BundleVersionListView(String locatorId) {
this(locatorId, null);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index 457d13b..ad1b658 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -74,7 +74,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class AbstractSelector<T> extends LocatableVLayout {
+public abstract class AbstractSelector<T, C extends org.rhq.core.domain.criteria.Criteria> extends LocatableVLayout {
private static final String SELECTOR_KEY = "id";
@@ -84,7 +84,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
protected HLayout hlayout;
protected LocatableListGrid availableGrid;
protected LocatableListGrid assignedGrid;
- protected RPCDataSource<T> datasource;
+ protected RPCDataSource<T, C> datasource;
private Set<AssignedItemsChangedHandler> assignedItemsChangedHandlers = new HashSet<AssignedItemsChangedHandler>();
@@ -159,7 +159,7 @@ public abstract class AbstractSelector<T> extends LocatableVLayout {
protected abstract DynamicForm getAvailableFilterForm();
- protected abstract RPCDataSource<T> getDataSource();
+ protected abstract RPCDataSource<T, C> getDataSource();
protected abstract Criteria getLatestCriteria(DynamicForm availableFilterForm);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
index a1bd824..cc6db46 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tagging/TaggingDataSource.java
@@ -38,20 +38,11 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class TaggingDataSource extends RPCDataSource<Tag> {
+public class TaggingDataSource extends RPCDataSource<Tag, TagCriteria> {
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- // TagCriteria criteria = new TagCriteria();
-
- String search = (String) request.getCriteria().getValues().get("tag");
- if (search != null) {
- // todo
- // criteria.addFilter
- }
-
- GWTServiceLookup.getTagService().findTagsByCriteria(new TagCriteria(), new AsyncCallback<PageList<Tag>>() {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final TagCriteria criteria) {
+ GWTServiceLookup.getTagService().findTagsByCriteria(criteria, new AsyncCallback<PageList<Tag>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_tags_error_1(), caught);
response.setStatus(DSResponse.STATUS_FAILURE);
@@ -63,7 +54,20 @@ public class TaggingDataSource extends RPCDataSource<Tag> {
processResponse(request.getRequestId(), response);
}
});
+ }
+
+ @Override
+ protected TagCriteria getFetchCriteria(DSRequest request) {
+ TagCriteria criteria = new TagCriteria();
+
+ /* TODO: add search filter
+ String search = (String) request.getCriteria().getValues().get("tag");
+ if (search != null) {
+ // criteria.addFilter
+ }
+ */
+ return criteria;
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
index ab2f634..5e9cf08 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/content/repository/tree/ContentRepositoryTreeDataSource.java
@@ -44,7 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
+public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo, RepoCriteria> {
private RepoGWTServiceAsync repoService = GWTServiceLookup.getRepoService();
@@ -75,10 +75,7 @@ public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- RepoCriteria criteria = new RepoCriteria();
-
+ protected void executeFetch(final DSRequest request, final DSResponse response, final RepoCriteria criteria) {
repoService.findReposByCriteria(criteria, new AsyncCallback<PageList<Repo>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.dataSource_ContentRepoTree_error_load(), caught);
@@ -89,7 +86,12 @@ public class ContentRepositoryTreeDataSource extends RPCDataSource<Repo> {
processResponse(request.getRequestId(), response);
}
});
+ }
+ @Override
+ protected RepoCriteria getFetchCriteria(final DSRequest request) {
+ RepoCriteria criteria = new RepoCriteria();
+ return criteria;
}
@Override
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 9c2be45..37813ac 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
@@ -403,7 +403,23 @@ class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource
private Configuration portletConfig;
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupOperationHistoryCriteria criteria) {
+ 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);
+ }
+ });
+ }
+
+ @Override
+ protected GroupOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
//initialize criteria
GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
@@ -493,17 +509,6 @@ class GroupOperationsCriteriaDataSource extends GroupOperationHistoryDataSource
}
}
}
-
- 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);
- }
- });
+ return criteria;
}
}
\ 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
index f2a0ab4..c584aaa 100644
--- 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
@@ -204,7 +204,8 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
*
* @author spinder
*/
-class ResourceOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView {
+class ResourceOperationsCriteriaHistoryListView extends
+ AbstractOperationHistoryListView<ResourceOperationsCriteriaDataSource> {
private ResourceOperationsCriteriaDataSource datasource;
@@ -266,7 +267,23 @@ class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataS
private Configuration portletConfig;
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceOperationHistoryCriteria criteria) {
+ 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);
+ }
+ });
+ }
+
+ @Override
+ protected ResourceOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
@@ -357,17 +374,6 @@ class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataS
}
}
}
-
- 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);
- }
- });
+ return criteria;
}
}
\ No newline at end of file
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 d87097a..25088bc 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
@@ -47,7 +47,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*
* @author Ian Springer
*/
-public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSource<MeasurementDataTrait> {
+public abstract class AbstractMeasurementDataTraitDataSource extends
+ RPCDataSource<MeasurementDataTrait, MeasurementDataTraitCriteria> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementDataTraitDataSource() {
@@ -87,11 +88,10 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
return fields;
}
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final MeasurementDataTraitCriteria criteria) {
final long startTime = System.currentTimeMillis();
- final MeasurementDataTraitCriteria criteria = getCriteria(request);
-
this.measurementService.findTraitsByCriteria(criteria, new AsyncCallback<PageList<MeasurementDataTrait>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.dataSource_traits_failFetch(criteria.toString()), caught);
@@ -116,7 +116,8 @@ public abstract class AbstractMeasurementDataTraitDataSource extends RPCDataSour
processResponse(request.getRequestId(), response);
}
- protected MeasurementDataTraitCriteria getCriteria(DSRequest request) {
+ @Override
+ protected MeasurementDataTraitCriteria getFetchCriteria(DSRequest request) {
MeasurementDataTraitCriteria criteria = new MeasurementDataTraitCriteria();
Criteria requestCriteria = request.getCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
index 8d2de00..dfc951c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java
@@ -34,6 +34,7 @@ import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite;
@@ -49,7 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Ian Springer
*/
public abstract class AbstractMeasurementScheduleCompositeDataSource extends
- RPCDataSource<MeasurementScheduleComposite> {
+ RPCDataSource<MeasurementScheduleComposite, Criteria> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementScheduleCompositeDataSource() {
@@ -94,7 +95,14 @@ public abstract class AbstractMeasurementScheduleCompositeDataSource extends
return fields;
}
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
final EntityContext entityContext = getEntityContext(request);
this.measurementService.getMeasurementScheduleCompositesByContext(entityContext,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
index 6e63435..657f2b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java
@@ -53,7 +53,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Ian Springer
*/
@Deprecated
-public abstract class AbstractMeasurementScheduleDataSource extends RPCDataSource<MeasurementSchedule> {
+public abstract class AbstractMeasurementScheduleDataSource extends
+ RPCDataSource<MeasurementSchedule, MeasurementScheduleCriteria> {
private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
protected AbstractMeasurementScheduleDataSource() {
@@ -97,11 +98,10 @@ public abstract class AbstractMeasurementScheduleDataSource extends RPCDataSourc
return fields;
}
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final MeasurementScheduleCriteria criteria) {
final long startTime = System.currentTimeMillis();
- final MeasurementScheduleCriteria criteria = getCriteria(request);
-
this.measurementService.findMeasurementSchedulesByCriteria(criteria,
new AsyncCallback<PageList<MeasurementSchedule>>() {
public void onFailure(Throwable caught) {
@@ -124,7 +124,8 @@ public abstract class AbstractMeasurementScheduleDataSource extends RPCDataSourc
});
}
- protected MeasurementScheduleCriteria getCriteria(DSRequest request) {
+ @Override
+ protected MeasurementScheduleCriteria getFetchCriteria(DSRequest request) {
MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
criteria.fetchDefinition(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java
index c4f64a3..15606f2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDataSource.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -27,18 +29,19 @@ import com.smartgwt.client.data.fields.DataSourceDateTimeField;
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.OperationHistoryCriteria;
import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import java.util.List;
-
/**
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class AbstractOperationHistoryDataSource<T extends OperationHistory> extends RPCDataSource<T> {
+public abstract class AbstractOperationHistoryDataSource<T extends OperationHistory, C extends OperationHistoryCriteria>
+ extends RPCDataSource<T, C> {
private T currentOperationHistory;
@@ -86,23 +89,23 @@ public abstract class AbstractOperationHistoryDataSource<T extends OperationHist
idField.setPrimaryKey(true);
fields.add(idField);
- DataSourceTextField nameField = new DataSourceTextField(Field.OPERATION_NAME,
- MSG.dataSource_operationHistory_field_operationName());
+ DataSourceTextField nameField = new DataSourceTextField(Field.OPERATION_NAME, MSG
+ .dataSource_operationHistory_field_operationName());
fields.add(nameField);
DataSourceTextField statusField = new DataSourceTextField(Field.STATUS, MSG.common_title_status());
fields.add(statusField);
- DataSourceDateTimeField createdTimeField = new DataSourceDateTimeField(Field.CREATED_TIME,
- MSG.dataSource_operationHistory_field_createdTime());
+ DataSourceDateTimeField createdTimeField = new DataSourceDateTimeField(Field.CREATED_TIME, MSG
+ .dataSource_operationHistory_field_createdTime());
fields.add(createdTimeField);
- DataSourceDateTimeField startedTimeField = new DataSourceDateTimeField(Field.STARTED_TIME,
- MSG.dataSource_operationHistory_field_startedTime());
+ DataSourceDateTimeField startedTimeField = new DataSourceDateTimeField(Field.STARTED_TIME, MSG
+ .dataSource_operationHistory_field_startedTime());
fields.add(startedTimeField);
- DataSourceTextField subjectField = new DataSourceTextField(Field.SUBJECT,
- MSG.dataSource_operationHistory_field_subject());
+ DataSourceTextField subjectField = new DataSourceTextField(Field.SUBJECT, MSG
+ .dataSource_operationHistory_field_subject());
fields.add(subjectField);
return fields;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java
index 041c7db..7ee12ad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDataSource.java
@@ -37,6 +37,7 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.bean.OperationSchedule;
import org.rhq.core.domain.resource.ResourceType;
@@ -49,7 +50,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RecordUtility;
/**
* @author Ian Springer
*/
-public abstract class AbstractOperationScheduleDataSource<T extends OperationSchedule> extends RPCDataSource<T> {
+public abstract class AbstractOperationScheduleDataSource<T extends OperationSchedule> extends
+ RPCDataSource<T, Criteria> {
public static abstract class Field {
public static final String ID = "id";
@@ -92,14 +94,14 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
protected List<DataSourceField> addDataSourceFields() {
List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID,
- MSG.dataSource_operationSchedule_field_id());
+ DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID, MSG
+ .dataSource_operationSchedule_field_id());
idField.setPrimaryKey(true);
idField.setCanEdit(false);
- fields.add(idField);
+ fields.add(idField);
- DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME,
- MSG.dataSource_operationSchedule_field_operationName(), null, 100, true);
+ DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME, MSG
+ .dataSource_operationSchedule_field_operationName(), null, 100, true);
Set<OperationDefinition> operationDefinitions = this.resourceType.getOperationDefinitions();
LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
for (OperationDefinition operationDefinition : operationDefinitions) {
@@ -108,26 +110,26 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
operationNameField.setValueMap(valueMap);
fields.add(operationNameField);
- DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME,
- MSG.dataSource_operationSchedule_field_operationDisplayName(), null, 100, true);
+ DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, MSG
+ .dataSource_operationSchedule_field_operationDisplayName(), null, 100, true);
fields.add(operationDisplayNameField);
- DataSourceField subjectField = new DataSourceField(Field.SUBJECT, FieldType.ANY,
- MSG.dataSource_operationSchedule_field_subject());
+ DataSourceField subjectField = new DataSourceField(Field.SUBJECT, FieldType.ANY, MSG
+ .dataSource_operationSchedule_field_subject());
subjectField.setCanEdit(false);
fields.add(subjectField);
- DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION,
- MSG.dataSource_operationSchedule_field_description(), null, 100, false);
+ DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION, MSG
+ .dataSource_operationSchedule_field_description(), null, 100, false);
fields.add(descriptionField);
- DataSourceDateTimeField nextFireTimeField = new DataSourceDateTimeField(Field.NEXT_FIRE_TIME,
- MSG.dataSource_operationSchedule_field_nextFireTime());
+ DataSourceDateTimeField nextFireTimeField = new DataSourceDateTimeField(Field.NEXT_FIRE_TIME, MSG
+ .dataSource_operationSchedule_field_nextFireTime());
nextFireTimeField.setCanEdit(false);
fields.add(nextFireTimeField);
- DataSourceIntegerField timeoutField = createIntegerField(Field.TIMEOUT,
- MSG.dataSource_operationSchedule_field_timeout(), 30, null, false);
+ DataSourceIntegerField timeoutField = createIntegerField(Field.TIMEOUT, MSG
+ .dataSource_operationSchedule_field_timeout(), 30, null, false);
fields.add(timeoutField);
return fields;
@@ -140,7 +142,7 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
T to = createOperationSchedule();
to.setId(from.getAttributeAsInt(Field.ID));
- to.setJobName(from.getAttribute(Field.JOB_NAME));
+ to.setJobName(from.getAttribute(Field.JOB_NAME));
to.setJobGroup(from.getAttribute(Field.JOB_GROUP));
SubjectRecord subjectRecord = (SubjectRecord) from.getAttributeAsRecord(Field.SUBJECT);
to.setSubject(subjectRecord.toSubject());
@@ -174,11 +176,11 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
Configuration parameters = from.getParameters();
to.setAttribute(Field.PARAMETERS, parameters);
to.setAttribute(Field.OPERATION_NAME, from.getOperationName());
- to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
+ to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
to.setAttribute(Field.DESCRIPTION, from.getDescription());
to.setAttribute(Field.NEXT_FIRE_TIME, from.getNextFireTime());
- to.setAttribute(Field.TIMEOUT, (parameters != null) ?
- parameters.getSimpleValue(OperationDefinition.TIMEOUT_PARAM_NAME, null) : null);
+ to.setAttribute(Field.TIMEOUT, (parameters != null) ? parameters.getSimpleValue(
+ OperationDefinition.TIMEOUT_PARAM_NAME, null) : null);
JobTrigger jobTrigger = from.getJobTrigger();
Record jobTriggerRecord = new ListGridRecord();
@@ -201,7 +203,7 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
} else {
// calendar mode
Date startTime = jobTriggerRecord.getAttributeAsDate(Field.START_TIME);
- Long repeatInterval = (Long)jobTriggerRecord.getAttributeAsObject(Field.REPEAT_INTERVAL);
+ Long repeatInterval = (Long) jobTriggerRecord.getAttributeAsObject(Field.REPEAT_INTERVAL);
Integer repeatCount = jobTriggerRecord.getAttributeAsInt(Field.REPEAT_COUNT);
Date endTime = jobTriggerRecord.getAttributeAsDate(Field.END_TIME);
@@ -243,10 +245,20 @@ public abstract class AbstractOperationScheduleDataSource<T extends OperationSch
}
protected void addRequestPropertiesToRecord(DSRequest request, Record record) {
- Configuration parameters = (Configuration) request.getAttributeAsObject(GroupOperationScheduleDataSource.RequestProperty.PARAMETERS);
+ Configuration parameters = (Configuration) request
+ .getAttributeAsObject(GroupOperationScheduleDataSource.RequestProperty.PARAMETERS);
record.setAttribute(GroupOperationScheduleDataSource.Field.PARAMETERS, parameters);
}
+ /**
+ * All data sources extending this type do not use the normal criteria object to query.
+ * So this just returns null.
+ */
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ return null;
+ }
+
public static class SubjectRecord extends ListGridRecord {
static final String FIELD_ID = "id";
static final String FIELD_NAME = "name";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
index 64dc1a9..e7f93e4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeDatasource.java
@@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Joseph Marques
*/
-public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
+public class EventCompositeDatasource extends RPCDataSource<EventComposite, EventCriteria> {
private EntityContext entityContext;
@@ -108,9 +108,7 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- EventCriteria criteria = getFetchCriteria(request);
-
+ protected void executeFetch(final DSRequest request, final DSResponse response, final EventCriteria criteria) {
GWTServiceLookup.getEventService().findEventCompositesByCriteria(criteria,
new AsyncCallback<PageList<EventComposite>>() {
public void onFailure(Throwable caught) {
@@ -128,7 +126,7 @@ public class EventCompositeDatasource extends RPCDataSource<EventComposite> {
});
}
- @SuppressWarnings("unchecked")
+ @Override
protected EventCriteria getFetchCriteria(final DSRequest request) {
EventCriteria criteria = new EventCriteria();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
index e81a82e..ab30354 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
@@ -51,7 +51,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Joseph Marques
*/
-public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGroupComposite> {
+public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGroupComposite, ResourceGroupCriteria> {
ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
@@ -100,9 +100,8 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceGroupCriteria criteria = getFetchCriteria(request);
-
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, ResourceGroupCriteria criteria) {
groupService.findResourceGroupCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceGroupComposite>>() {
public void onFailure(Throwable caught) {
@@ -119,6 +118,7 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
});
}
+ @Override
protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
index a1a1578..83c356f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupsDataSource.java
@@ -49,7 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
+public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup, ResourceGroupCriteria> {
private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
@@ -95,9 +95,8 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceGroupCriteria criteria = getFetchCriteria(request);
-
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, final ResourceGroupCriteria criteria) {
groupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.dataSource_resourceGroups_loadFailed(), caught);
@@ -113,6 +112,7 @@ public class ResourceGroupsDataSource extends RPCDataSource<ResourceGroup> {
});
}
+ @Override
protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
index 1c21763..cef860a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
@@ -45,7 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
* @author Greg Hinkle
* @author Joseph Marques
*/
-public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
+public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition, ResourceGroupDefinitionCriteria> {
private ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
@@ -98,10 +98,8 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceGroupDefinitionCriteria criteria = new ResourceGroupDefinitionCriteria();
- criteria.setPageControl(getPageControl(request));
-
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceGroupDefinitionCriteria criteria) {
groupService.findGroupDefinitionsByCriteria(criteria, new AsyncCallback<PageList<GroupDefinition>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_definitionLoadFailure(), caught);
@@ -117,6 +115,13 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition> {
}
@Override
+ protected ResourceGroupDefinitionCriteria getFetchCriteria(final DSRequest request) {
+ ResourceGroupDefinitionCriteria criteria = new ResourceGroupDefinitionCriteria();
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+
+ @Override
protected void executeAdd(Record recordToAdd, final DSRequest request, final DSResponse response) {
final GroupDefinition newGroupDefinition = copyValues(recordToAdd);
final String name = newGroupDefinition.getName();
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 8ea5782..9071b94 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
@@ -214,7 +214,8 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
return html;
}
- private class DataSource extends RPCDataSource<ResourceConfigurationUpdate> {
+ private class DataSource extends
+ RPCDataSource<ResourceConfigurationUpdate, ResourceConfigurationUpdateCriteria> {
public class Field {
public static final String ID = "id";
@@ -253,14 +254,10 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceConfigurationUpdateCriteria criteria) {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
- criteria
- .addFilterGroupConfigurationUpdateId(HistoryGroupResourceConfigurationMembers.this.groupUpdateId);
- criteria.fetchResource(true);
-
configurationService.findResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
@@ -312,6 +309,15 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout {
}
});
}
+
+ @Override
+ protected ResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
+ criteria
+ .addFilterGroupConfigurationUpdateId(HistoryGroupResourceConfigurationMembers.this.groupUpdateId);
+ criteria.fetchResource(true);
+ return criteria;
+ }
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
index 38174c8..d6da7d0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java
@@ -214,7 +214,7 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
return html;
}
- class DataSource extends RPCDataSource<GroupResourceConfigurationUpdate> {
+ class DataSource extends RPCDataSource<GroupResourceConfigurationUpdate, GroupResourceConfigurationUpdateCriteria> {
public class Field {
public static final String ID = "id";
@@ -246,14 +246,10 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupResourceConfigurationUpdateCriteria criteria) {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
- ArrayList<Integer> groupList = new ArrayList<Integer>(1);
- groupList.add(HistoryGroupResourceConfigurationTable.this.group.getId());
- criteria.addFilterResourceGroupIds(groupList);
-
configurationService.findGroupResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>() {
@@ -272,5 +268,14 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe
}
});
}
+
+ @Override
+ protected GroupResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ GroupResourceConfigurationUpdateCriteria criteria = new GroupResourceConfigurationUpdateCriteria();
+ ArrayList<Integer> groupList = new ArrayList<Integer>(1);
+ groupList.add(HistoryGroupResourceConfigurationTable.this.group.getId());
+ criteria.addFilterResourceGroupIds(groupList);
+ return criteria;
+ }
}
}
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 ae76963..ec590c0 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
@@ -213,7 +213,7 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
return html;
}
- private class DataSource extends RPCDataSource<PluginConfigurationUpdate> {
+ private class DataSource extends RPCDataSource<PluginConfigurationUpdate, PluginConfigurationUpdateCriteria> {
public class Field {
public static final String ID = "id";
@@ -252,12 +252,10 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final PluginConfigurationUpdateCriteria criteria) {
- PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
- criteria.addFilterGroupConfigurationUpdateId(HistoryGroupPluginConfigurationMembers.this.groupUpdateId);
- criteria.fetchResource(true);
+ ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
configurationService.findPluginConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
@@ -310,6 +308,14 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout {
}
});
}
+
+ @Override
+ protected PluginConfigurationUpdateCriteria getFetchCriteria(DSRequest request) {
+ PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
+ criteria.addFilterGroupConfigurationUpdateId(HistoryGroupPluginConfigurationMembers.this.groupUpdateId);
+ criteria.fetchResource(true);
+ return criteria;
+ }
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
index fe975f2..1c36f7c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java
@@ -214,7 +214,7 @@ public class HistoryGroupPluginConfigurationTable extends Table<HistoryGroupPlug
return html;
}
- class DataSource extends RPCDataSource<GroupPluginConfigurationUpdate> {
+ class DataSource extends RPCDataSource<GroupPluginConfigurationUpdate, GroupPluginConfigurationUpdateCriteria> {
public class Field {
public static final String ID = "id";
@@ -246,14 +246,10 @@ public class HistoryGroupPluginConfigurationTable extends Table<HistoryGroupPlug
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupPluginConfigurationUpdateCriteria criteria) {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
- GroupPluginConfigurationUpdateCriteria criteria = new GroupPluginConfigurationUpdateCriteria();
- ArrayList<Integer> groupList = new ArrayList<Integer>(1);
- groupList.add(HistoryGroupPluginConfigurationTable.this.group.getId());
- criteria.addFilterResourceGroupIds(groupList);
-
configurationService.findGroupPluginConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<GroupPluginConfigurationUpdate>>() {
@@ -272,5 +268,14 @@ public class HistoryGroupPluginConfigurationTable extends Table<HistoryGroupPlug
}
});
}
+
+ @Override
+ protected GroupPluginConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ GroupPluginConfigurationUpdateCriteria criteria = new GroupPluginConfigurationUpdateCriteria();
+ ArrayList<Integer> groupList = new ArrayList<Integer>(1);
+ groupList.add(HistoryGroupPluginConfigurationTable.this.group.getId());
+ criteria.addFilterResourceGroupIds(groupList);
+ return criteria;
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
index 902efa7..1f4d491 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
@@ -23,7 +23,6 @@ import java.util.List;
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.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -65,12 +64,6 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
@Override
- protected void executeFetch(DSRequest request, DSResponse response) {
- super.executeFetch(request, response);
-
- }
-
- @Override
protected EntityContext getEntityContext(DSRequest request) {
Criteria requestCriteria = request.getCriteria();
Integer groupId = requestCriteria.getAttributeAsInt(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
index ff90336..b9b78ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryDataSource.java
@@ -19,22 +19,24 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history;
+import java.util.Arrays;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
-import java.util.Arrays;
-
/**
* @author Ian Springer
*/
-public class GroupOperationHistoryDataSource extends AbstractOperationHistoryDataSource<GroupOperationHistory> {
+public class GroupOperationHistoryDataSource extends
+ AbstractOperationHistoryDataSource<GroupOperationHistory, GroupOperationHistoryCriteria> {
public static abstract class Field extends AbstractOperationHistoryDataSource.Field {
public static final String GROUP = "group";
@@ -45,28 +47,32 @@ public class GroupOperationHistoryDataSource extends AbstractOperationHistoryDat
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final GroupOperationHistoryCriteria criteria) {
+ 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);
+ }
+ });
+ }
+
+ @Override
+ protected GroupOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_ID)) {
- int groupId = Integer.parseInt((String)request.getCriteria().getValues().get(
- CriteriaField.GROUP_ID));
+ int groupId = Integer.parseInt((String) request.getCriteria().getValues().get(CriteriaField.GROUP_ID));
criteria.addFilterResourceGroupIds(Arrays.asList(groupId));
}
criteria.setPageControl(getPageControl(request));
-
- 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);
- }
- });
+ return criteria;
}
@Override
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 7edf2ab..8ad3170 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
@@ -28,7 +28,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.h
/**
* @author Ian Springer
*/
-public class GroupOperationHistoryListView extends AbstractOperationHistoryListView {
+public class GroupOperationHistoryListView extends AbstractOperationHistoryListView<GroupOperationHistoryDataSource> {
private ResourceGroupComposite groupComposite;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
index f41333a..56ba89e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
@@ -19,19 +19,20 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+import java.util.List;
+
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.Configuration;
+
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDataSource;
-import java.util.List;
-
/**
* A DataSource for {@link org.rhq.core.domain.operation.bean.GroupOperationSchedule}s for a given
* {@link org.rhq.core.domain.resource.group.ResourceGroup}.
@@ -64,17 +65,17 @@ public class GroupOperationScheduleDataSource extends AbstractOperationScheduleD
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
final Integer scheduleId = request.getCriteria().getAttributeAsInt(Field.ID);
if (scheduleId != null) {
- operationService.getGroupOperationSchedule(scheduleId, new AsyncCallback<GroupOperationSchedule>() {
+ operationService.getGroupOperationSchedule(scheduleId, new AsyncCallback<GroupOperationSchedule>() {
public void onSuccess(GroupOperationSchedule result) {
sendSuccessResponse(request, response, result);
}
public void onFailure(Throwable caught) {
sendFailureResponse(request, response, "Failed to fetch GroupOperationSchedule with id "
- + scheduleId + ".", caught);
+ + scheduleId + ".", caught);
}
});
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
index 27f49f2..24eb534 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
@@ -1,3 +1,26 @@
+/*
+ * 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.enterprise.gui.coregui.client.inventory.resource;
import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY;
@@ -42,7 +65,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
*
* @author Jay Shaughnessy
*/
-public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite> {
+public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite, ResourceCriteria> {
private static ResourceCompositeDataSource INSTANCE;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -68,9 +91,7 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
return ResourceDatasource.addResourceDatasourceFields(fields);
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria criteria = getFetchCriteria(request);
-
+ public void executeFetch(final DSRequest request, final DSResponse response, final ResourceCriteria criteria) {
getResourceService().findResourceCompositesByCriteria(criteria,
new AsyncCallback<PageList<ResourceComposite>>() {
public void onFailure(Throwable caught) {
@@ -135,6 +156,7 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
});
}
+ @Override
protected ResourceCriteria getFetchCriteria(final DSRequest request) {
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
index 192beae..097383e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeSearchView.java
@@ -1,3 +1,26 @@
+/*
+ * 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.enterprise.gui.coregui.client.inventory.resource;
import java.util.LinkedHashMap;
@@ -44,7 +67,8 @@ public class ResourceCompositeSearchView extends ResourceSearchView {
this(locatorId, null, criteria, title, headerIcons);
}
- protected RPCDataSource<?> getDataSourceInstance() {
+ @Override
+ protected RPCDataSource getDataSourceInstance() {
return ResourceCompositeDataSource.getInstance();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 9a10084..eb948c8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -57,7 +57,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ResourceDatasource extends RPCDataSource<Resource> {
+public class ResourceDatasource extends RPCDataSource<Resource, ResourceCriteria> {
public static final String FILTER_GROUP_ID = "groupId";
@@ -122,9 +122,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
return fields;
}
- public void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceCriteria criteria = getFetchCriteria(request);
-
+ public void executeFetch(final DSRequest request, final DSResponse response, final ResourceCriteria criteria) {
resourceService.findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_loadFailed(), caught);
@@ -182,6 +180,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
});
}
+ @Override
protected ResourceCriteria getFetchCriteria(final DSRequest request) {
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index dc6b945..7d46996 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -60,7 +60,6 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
*/
-@SuppressWarnings("unchecked")
public class ResourceSearchView extends Table {
private static final String DEFAULT_TITLE = MSG.view_inventory_resources_title();
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 4420169..bd8c430 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
@@ -39,6 +39,7 @@ import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.configuration.AbstractConfigurationUpdate;
import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.criteria.AbstractResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
@@ -55,8 +56,8 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractResourceConfigurationUpdate> extends
- RPCDataSource<T> {
+public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractResourceConfigurationUpdate, C extends AbstractResourceConfigurationUpdateCriteria>
+ extends RPCDataSource<T, C> {
public static abstract class Field {
public static final String ID = "id";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
index c8041fe..0804cbf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryView.java
@@ -29,6 +29,7 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
+import org.rhq.core.domain.criteria.AbstractResourceConfigurationUpdateCriteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationComparisonView;
@@ -45,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class AbstractConfigurationHistoryView<T extends AbstractConfigurationHistoryDataSource<? extends AbstractResourceConfigurationUpdate>>
+public abstract class AbstractConfigurationHistoryView<T extends AbstractConfigurationHistoryDataSource<? extends AbstractResourceConfigurationUpdate, ? extends AbstractResourceConfigurationUpdateCriteria>>
extends TableSection<T> {
private Integer resourceId;
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 3a28dcc..d7556d7 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
@@ -48,7 +48,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public class ConfigurationHistoryDataSource extends AbstractConfigurationHistoryDataSource<ResourceConfigurationUpdate> {
+public class ConfigurationHistoryDataSource extends
+ AbstractConfigurationHistoryDataSource<ResourceConfigurationUpdate, ResourceConfigurationUpdateCriteria> {
public ConfigurationHistoryDataSource() {
super();
@@ -65,20 +66,10 @@ public class ConfigurationHistoryDataSource extends AbstractConfigurationHistory
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
- criteria.fetchConfiguration(true);
- criteria.fetchResource(true);
- criteria.fetchGroupConfigurationUpdate(true);
-
- criteria.setPageControl(getPageControl(request));
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceConfigurationUpdateCriteria criteria) {
final Integer resourceId = (Integer) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
- if (resourceId != null) {
- criteria.addFilterResourceIds(resourceId);
- }
-
getConfigurationService().findResourceConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
public void onFailure(Throwable caught) {
@@ -162,4 +153,20 @@ public class ConfigurationHistoryDataSource extends AbstractConfigurationHistory
}
});
}
+
+ @Override
+ protected ResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
+ criteria.fetchConfiguration(true);
+ criteria.fetchResource(true);
+ criteria.fetchGroupConfigurationUpdate(true);
+
+ criteria.setPageControl(getPageControl(request));
+
+ final Integer resourceId = (Integer) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
+ if (resourceId != null) {
+ criteria.addFilterResourceIds(resourceId);
+ }
+ return criteria;
+ }
}
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 4918dff..3e4e1d2 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
@@ -49,7 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
* @author John Mazzitelli
*/
public class PluginConfigurationHistoryDataSource extends
- AbstractConfigurationHistoryDataSource<PluginConfigurationUpdate> {
+ AbstractConfigurationHistoryDataSource<PluginConfigurationUpdate, PluginConfigurationUpdateCriteria> {
public PluginConfigurationHistoryDataSource() {
super();
@@ -66,20 +66,10 @@ public class PluginConfigurationHistoryDataSource extends
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
- criteria.fetchConfiguration(true);
- criteria.fetchResource(true);
- criteria.fetchGroupConfigurationUpdate(true);
-
- criteria.setPageControl(getPageControl(request));
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final PluginConfigurationUpdateCriteria criteria) {
final Integer resourceId = (Integer) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
- if (resourceId != null) {
- criteria.addFilterResourceIds(resourceId);
- }
-
getConfigurationService().findPluginConfigurationUpdatesByCriteria(criteria,
new AsyncCallback<PageList<PluginConfigurationUpdate>>() {
public void onFailure(Throwable caught) {
@@ -162,4 +152,20 @@ public class PluginConfigurationHistoryDataSource extends
}
});
}
+
+ @Override
+ protected PluginConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
+ PluginConfigurationUpdateCriteria criteria = new PluginConfigurationUpdateCriteria();
+ criteria.fetchConfiguration(true);
+ criteria.fetchResource(true);
+ criteria.fetchGroupConfigurationUpdate(true);
+
+ criteria.setPageControl(getPageControl(request));
+
+ final Integer resourceId = (Integer) request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID);
+ if (resourceId != null) {
+ criteria.addFilterResourceIds(resourceId);
+ }
+ return criteria;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
index f2a92ce..e7589ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
@@ -33,6 +33,7 @@ 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.Criteria;
import org.rhq.core.domain.criteria.MeasurementDefinitionCriteria;
import org.rhq.core.domain.criteria.MeasurementScheduleCriteria;
import org.rhq.core.domain.measurement.DataType;
@@ -46,7 +47,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class ResourceScheduledMetricDatasource extends RPCDataSource<MeasurementDefinition> {
+public class ResourceScheduledMetricDatasource extends RPCDataSource<MeasurementDefinition, Criteria> {
public ResourceScheduledMetricDatasource() {
List<DataSourceField> fields = addDataSourceFields();
@@ -83,12 +84,16 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
+ // due to the conditional below which determines what kind of criteria to use, this datasource
+ // doesn't rely on getFetchCriteria and the passed in criteria object. It is up to this method to
+ // correctly prepare the criteria we build here (e.g. set the page control properly).
if (request.getCriteria().getValues().containsKey("id")) {
MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
-
criteria.addFilterId(request.getCriteria().getAttributeAsInt("id"));
+ criteria.setPageControl(getPageControl(request));
+
GWTServiceLookup.getMeasurementDataService().findMeasurementDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<MeasurementDefinition>>() {
public void onFailure(Throwable caught) {
@@ -104,8 +109,8 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
} else if (request.getCriteria().getValues().containsKey("resourceId")) {
MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
criteria.fetchDefinition(true);
-
criteria.addFilterResourceId(request.getCriteria().getAttributeAsInt("resourceId"));
+ criteria.setPageControl(getPageControl(request));
GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria,
new AsyncCallback<PageList<MeasurementSchedule>>() {
@@ -142,6 +147,13 @@ public class ResourceScheduledMetricDatasource extends RPCDataSource<Measurement
}
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // our executeFetch does some special conditional checking to determine what kind of criteria to use.
+ // because of this, we don't explicitly use this method to get the criteria for this datasource, just return null
+ return null;
+ }
+
private ListGridRecord[] buildRecords(PageList<MeasurementSchedule> list) {
PageList<MeasurementDefinition> definitions = new PageList<MeasurementDefinition>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
index 85bf0f0..b6acfa1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/calltime/CallTimeDataSource.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -40,7 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
+public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite, Criteria> {
private double maxMaximum;
@@ -74,7 +75,7 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
int scheduleId = Integer.parseInt((String) request.getCriteria().getValues().get("scheduleId"));
long now = System.currentTimeMillis();
long eightHoursAgo = now - (1000L * 60 * 60 * 8);
@@ -98,6 +99,12 @@ public class CallTimeDataSource extends RPCDataSource<CallTimeDataComposite> {
}
@Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
public CallTimeDataComposite copyValues(Record from) {
throw new UnsupportedOperationException(MSG.view_resource_monitor_calltime_editFailed());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java
index e140b2f..8228061 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableDataSource.java
@@ -9,6 +9,7 @@ import com.smartgwt.client.data.Record;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
@@ -29,7 +30,7 @@ import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
*
* @author John Mazzitelli
*/
-public class MeasurementTableDataSource extends RPCDataSource<MetricDisplaySummary> {
+public class MeasurementTableDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
public static final String FIELD_METRIC_LABEL = "label";
public static final String FIELD_ALERT_COUNT = "alertCount";
@@ -116,7 +117,13 @@ public class MeasurementTableDataSource extends RPCDataSource<MetricDisplaySumma
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
// see MetricsTableUIBean for the old JSF class to see where this came from
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
index 796c490..e2ab1d2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
@@ -45,7 +45,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
/**
* @author Ian Springer
*/
-public class ResourceOperationHistoryDataSource extends AbstractOperationHistoryDataSource<ResourceOperationHistory> {
+public class ResourceOperationHistoryDataSource extends
+ AbstractOperationHistoryDataSource<ResourceOperationHistory, ResourceOperationHistoryCriteria> {
public static abstract class Field extends AbstractOperationHistoryDataSource.Field {
public static final String RESOURCE = "resource";
@@ -68,21 +69,8 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
-
- if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
- int resourceId = getFilter(request, CriteriaField.RESOURCE_ID, Integer.class);
- criteria.addFilterResourceIds(resourceId);
- }
-
- if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_OPERATION_HISTORY_ID)) {
- int groupOperationHistoryId = getFilter(request, CriteriaField.GROUP_OPERATION_HISTORY_ID, Integer.class);
- criteria.addFilterGroupOperationHistoryId(groupOperationHistoryId);
- }
-
- criteria.setPageControl(getPageControl(request));
-
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceOperationHistoryCriteria criteria) {
operationService.findResourceOperationHistoriesByCriteria(criteria,
new AsyncCallback<PageList<ResourceOperationHistory>>() {
public void onFailure(Throwable caught) {
@@ -98,6 +86,24 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
});
}
+ @Override
+ protected ResourceOperationHistoryCriteria getFetchCriteria(final DSRequest request) {
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
+ int resourceId = getFilter(request, CriteriaField.RESOURCE_ID, Integer.class);
+ criteria.addFilterResourceIds(resourceId);
+ }
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_OPERATION_HISTORY_ID)) {
+ int groupOperationHistoryId = getFilter(request, CriteriaField.GROUP_OPERATION_HISTORY_ID, Integer.class);
+ criteria.addFilterGroupOperationHistoryId(groupOperationHistoryId);
+ }
+
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+
protected void dataRetrieved(final PageList<ResourceOperationHistory> result, final DSResponse response,
final DSRequest request) {
HashSet<Integer> typesSet = new HashSet<Integer>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
index 5bc58d7..a2513a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
@@ -26,6 +26,7 @@ import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceComposite;
@@ -53,33 +54,33 @@ public class ResourceOperationScheduleDataSource extends AbstractOperationSchedu
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
final Integer scheduleId = request.getCriteria().getAttributeAsInt(Field.ID);
if (scheduleId != null) {
- operationService.getResourceOperationSchedule(scheduleId, new AsyncCallback<ResourceOperationSchedule>() {
+ operationService.getResourceOperationSchedule(scheduleId, new AsyncCallback<ResourceOperationSchedule>() {
public void onSuccess(ResourceOperationSchedule result) {
sendSuccessResponse(request, response, result);
}
public void onFailure(Throwable caught) {
sendFailureResponse(request, response, "Failed to fetch ResourceOperationSchedule with id "
- + scheduleId + ".", caught);
+ + scheduleId + ".", caught);
}
});
} else {
operationService.findScheduledResourceOperations(this.resourceComposite.getResource().getId(),
- new AsyncCallback<List<ResourceOperationSchedule>>() {
- public void onSuccess(List<ResourceOperationSchedule> result) {
- Record[] records = buildRecords(result);
- response.setData(records);
- processResponse(request.getRequestId(), response);
- }
-
- public void onFailure(Throwable caught) {
- throw new RuntimeException("Failed to find scheduled operations for "
- + resourceComposite.getResource() + ".", caught);
- }
- });
+ new AsyncCallback<List<ResourceOperationSchedule>>() {
+ public void onSuccess(List<ResourceOperationSchedule> result) {
+ Record[] records = buildRecords(result);
+ response.setData(records);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to find scheduled operations for "
+ + resourceComposite.getResource() + ".", caught);
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
index d69b433..5999e14 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
@@ -34,6 +34,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -45,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Lukas Krejci
* @author Simeon Pinder
*/
-public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
+public class ResourceErrorsDataSource extends RPCDataSource<ResourceError, Criteria> {
public static abstract class Field {
public static final String SUMMARY = "summary";
@@ -87,7 +88,7 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
* @see org.rhq.enterprise.gui.coregui.client.util.RPCDataSource#executeFetch(com.smartgwt.client.data.DSRequest, com.smartgwt.client.data.DSResponse)
*/
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
resourceService.findResourceErrors(resourceId, new AsyncCallback<List<ResourceError>>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
@@ -103,6 +104,12 @@ public class ResourceErrorsDataSource extends RPCDataSource<ResourceError> {
});
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
public ResourceError copyValues(Record from) {
//This is read-only datasource, so no need to implement this.
return null;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
index 320e341..7bb5bb5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
*/
-public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
+public class ResourceGroupSelector extends AbstractSelector<ResourceGroup, ResourceGroupCriteria> {
private static LinkedHashMap<String, String> CATEGORY_VALUE_MAP = new LinkedHashMap<String, String>();
@@ -92,7 +92,7 @@ public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
return availableFilterForm;
}
- protected RPCDataSource<ResourceGroup> getDataSource() {
+ protected RPCDataSource<ResourceGroup, ResourceGroupCriteria> getDataSource() {
return new SelectedResourceGroupsDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
index f310997..853e8d0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
@@ -48,7 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
*/
-public class ResourceSelector extends AbstractSelector<Resource> {
+public class ResourceSelector extends AbstractSelector<Resource, ResourceCriteria> {
private ResourceType resourceTypeFilter;
private boolean forceResourceTypeFilter;
@@ -108,7 +108,7 @@ public class ResourceSelector extends AbstractSelector<Resource> {
return valueMap;
}
- protected RPCDataSource<Resource> getDataSource() {
+ protected RPCDataSource<Resource, ResourceCriteria> getDataSource() {
if (null == datasource) {
datasource = new SelectedResourceDataSource();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index 42808cf..cf93986 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
import org.rhq.core.domain.resource.ResourceType;
@@ -55,7 +56,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Simeon Pinder
* @author Jay Shaughnessy
*/
-public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationLastCompletedComposite> {
+public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationLastCompletedComposite, Criteria> {
public enum Field {
@@ -140,7 +141,8 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
* @param request incoming request
* @param response outgoing response
*/
- public void executeFetch(final DSRequest request, final DSResponse response) {
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
PageControl pageControl = new PageControl();
//retrieve current portlet display settings
if ((this.portlet != null) && (this.portlet instanceof OperationsPortlet)) {
@@ -180,6 +182,12 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
});
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
protected void dataRetrieved(final PageList<ResourceOperationLastCompletedComposite> result,
final DSResponse response, final DSRequest request) {
HashSet<Integer> typesSet = new HashSet<Integer>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index a835711..e9ee1c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -32,6 +32,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
@@ -51,7 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Simeon Pinder
* @author Jay Shaughnessy
*/
-public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperationScheduleComposite> {
+public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperationScheduleComposite, Criteria> {
public enum Field {
@@ -130,7 +131,8 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
* @param request incoming request
* @param response outgoing response
*/
- public void executeFetch(final DSRequest request, final DSResponse response) {
+ @Override
+ public void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
int pageSize = -1;
//retrieve current portlet display settings
@@ -169,6 +171,12 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
});
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
protected void dataRetrieved(final PageList<ResourceOperationScheduleComposite> result, final DSResponse response,
final DSRequest request) {
HashSet<Integer> typesSet = new HashSet<Integer>();
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 fcd9279..18f59cf 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
@@ -80,7 +80,7 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
private static final String FIELD_RESOURCE = "resource";
@Override
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ protected AlertDefinitionCriteria getFetchCriteria(DSRequest request) {
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.addFilterResourceOnly(true); // guarantees that all alert defs we get will have a non-null Resource object
criteria.setPageControl(getPageControl(request));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java
index 442fefd..0eb0057 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java
@@ -190,7 +190,7 @@ public class ResourceInstallReport extends LocatableVLayout implements Bookmarka
return url;
}
- class DataSource extends RPCDataSource<ResourceInstallCount> {
+ class DataSource extends RPCDataSource<ResourceInstallCount, org.rhq.core.domain.criteria.Criteria> {
public class Field {
public static final String COUNT = "count"; // long that we convert to int
@@ -224,7 +224,14 @@ public class ResourceInstallReport extends LocatableVLayout implements Bookmarka
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected org.rhq.core.domain.criteria.Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final org.rhq.core.domain.criteria.Criteria unused) {
ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
resourceService.findResourceInstallCounts(true, new AsyncCallback<List<ResourceInstallCount>>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
index 4e93b45..9fb110c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBDataSource.java
@@ -34,6 +34,7 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -45,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Greg Hinkle
*/
-public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBComposite> {
+public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBComposite, Criteria> {
private int maximumFactor = 0;
@@ -58,22 +59,28 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
protected List<DataSourceField> addDataSourceFields() {
List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField metricField = new DataSourceTextField("scheduleName", MSG.dataSource_measurementOob_field_scheduleName());
+ DataSourceTextField metricField = new DataSourceTextField("scheduleName", MSG
+ .dataSource_measurementOob_field_scheduleName());
fields.add(metricField);
- DataSourceTextField resourceField = new DataSourceTextField("resourceName", MSG.dataSource_measurementOob_field_resourceName());
+ DataSourceTextField resourceField = new DataSourceTextField("resourceName", MSG
+ .dataSource_measurementOob_field_resourceName());
fields.add(resourceField);
- DataSourceTextField parentField = new DataSourceTextField("parentName", MSG.dataSource_measurementOob_field_parentName());
+ DataSourceTextField parentField = new DataSourceTextField("parentName", MSG
+ .dataSource_measurementOob_field_parentName());
fields.add(parentField);
- DataSourceTextField bandField = new DataSourceTextField("formattedBaseband", MSG.dataSource_measurementOob_field_formattedBaseband());
+ DataSourceTextField bandField = new DataSourceTextField("formattedBaseband", MSG
+ .dataSource_measurementOob_field_formattedBaseband());
fields.add(bandField);
- DataSourceTextField outlierField = new DataSourceTextField("formattedOutlier", MSG.dataSource_measurementOob_field_formattedOutlier());
+ DataSourceTextField outlierField = new DataSourceTextField("formattedOutlier", MSG
+ .dataSource_measurementOob_field_formattedOutlier());
fields.add(outlierField);
- DataSourceTextField factorField = new DataSourceTextField("factor", MSG.dataSource_measurementOob_field_factor());
+ DataSourceTextField factorField = new DataSourceTextField("factor", MSG
+ .dataSource_measurementOob_field_factor());
fields.add(factorField);
return fields;
@@ -81,7 +88,7 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
PageControl pc = getPageControl(request);
@@ -101,6 +108,12 @@ public class MeasurementOOBDataSource extends RPCDataSource<MeasurementOOBCompos
}
@Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
public MeasurementOOBComposite copyValues(Record from) {
throw new UnsupportedOperationException("OOBs Read only");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 756bc4a..ac4318a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -33,6 +33,7 @@ import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.util.PageList;
@@ -53,7 +54,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author Simeon Pinder
* @author Jay Shaughnessy
*/
-public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceComposite> {
+public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceComposite, Criteria> {
public enum Field {
@@ -128,12 +129,18 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
return fields;
}
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ return null;
+ }
+
/** Fetch the ProblemResource data, and populate the response object appropriately.
*
* @param request incoming request
* @param response outgoing response
*/
- public void executeFetch(final DSRequest request, final DSResponse response) {
+ public void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
long ctime = -1;
int maxItems = -1;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index b87345e..3fa0171 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -23,8 +23,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -50,11 +48,9 @@ import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.hibernate.validator.RangeValidator;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
@@ -66,11 +62,14 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* Base GWT-RPC oriented DataSource class.
+ *
+ * The <T> type is the entity POJO type that represents a record retrieved by the data source
+ * The <C> type is the criteria type that is used to fetch data from the data source
*
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class RPCDataSource<T> extends DataSource {
+public abstract class RPCDataSource<T, C extends org.rhq.core.domain.criteria.Criteria> extends DataSource {
protected static final Messages MSG = CoreGUI.getMessages();
@@ -111,7 +110,16 @@ public abstract class RPCDataSource<T> extends DataSource {
switch (request.getOperationType()) {
case FETCH:
- executeFetch(request, response);
+ C criteria = getFetchCriteria(request);
+ if (criteria != null) {
+ // unsure if this is the right thing to do - we are always going to supply a PageControl, but reading
+ // the javadoc for setPageControl, it says this overrides addSortField, which is used by our criteria objects.
+ // I still think this is OK, but if you are reading this as part of debugging a problem, investigate this.
+ if (criteria.getPageControlOverrides() == null) {
+ criteria.setPageControl(getPageControl(request));
+ }
+ }
+ executeFetch(request, response, criteria);
break;
case ADD:
ListGridRecord newRecord = getDataObject(request);
@@ -302,7 +310,6 @@ public abstract class RPCDataSource<T> extends DataSource {
}
Set<T> results = new LinkedHashSet<T>(records.length);
- int i = 0;
for (Record record : records) {
results.add(copyValues(record));
}
@@ -341,6 +348,15 @@ public abstract class RPCDataSource<T> extends DataSource {
}
/**
+ * Given a request, this returns a criteria object that should be used to fetch data that the request
+ * is asking for. If a particular data source subclass does not use criteria, this can return <code>null</code>.
+ *
+ * @param request the request being made for data
+ * @return a criteria object that is to be used when fetching for the requested data, or <code>null</code> if not used
+ */
+ protected abstract C getFetchCriteria(final DSRequest request);
+
+ /**
* Extensions should implement this method to retrieve data. Paging solutions should use
* {@link #getPageControl(com.smartgwt.client.data.DSRequest)}. All implementations should call processResponse()
* whether they fail or succeed. Data should be set on the request via setData. Implementations can use
@@ -348,8 +364,9 @@ public abstract class RPCDataSource<T> extends DataSource {
*
* @param request
* @param response
+ * @param criteria can be used by the method to perform queries in order to fetch the required data
*/
- protected abstract void executeFetch(final DSRequest request, final DSResponse response);
+ protected abstract void executeFetch(final DSRequest request, final DSResponse response, final C criteria);
public abstract T copyValues(Record from);
@@ -509,8 +526,8 @@ public abstract class RPCDataSource<T> extends DataSource {
@SuppressWarnings("unchecked")
public static <S> S getFilter(DSRequest request, String paramName, Class<S> type) {
Criteria criteria = request.getCriteria();
- Map<String, Object> criteriaMap = (criteria != null) ? criteria.getValues() :
- Collections.<String, Object>emptyMap();
+ Map<String, Object> criteriaMap = (criteria != null) ? criteria.getValues() : Collections
+ .<String, Object> emptyMap();
S result = null;
13 years, 2 months