[rhq] Branch 'feature/export-reports' - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java | 22 +++-------
1 file changed, 8 insertions(+), 14 deletions(-)
New commits:
commit f0d00eca59496fd3a827e830f12ffb1090d4ca08
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Mar 28 15:00:45 2012 -0700
[BZ 800453] Export Csv Reports. Fix bugs after rebase/merge where classes/packages have changed.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java
index 62dedfb..bbd00de 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java
@@ -21,10 +21,6 @@
package org.rhq.enterprise.gui.coregui.client.report.inventory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
import com.smartgwt.client.types.ListGridEditEvent;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.events.DoubleClickEvent;
@@ -32,20 +28,19 @@ import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.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.*;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.ReportExporter;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.report.ExportChangeHandler;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
/**
* @author jsanda
*/
@@ -193,9 +188,8 @@ public class InventorySummaryReportTable extends Table<InventorySummaryDataSourc
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createExportWindowForInventorySummary(
- getReportNameForDownloadURL(), exportAll, exportChangeHandler.getResourceTypeIds());
- exportModalWindow.show();
+ ReportExporter exportModalWindow = ReportExporter.createExporterForInventorySummary(getReportNameForDownloadURL(), exportAll, exportChangeHandler.getResourceTypeIds());
+ exportModalWindow.export();
refreshTableInfo();
}
});
12 years, 1 month
[rhq] modules/plugins
by ips
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 17 +++++-----
1 file changed, 9 insertions(+), 8 deletions(-)
New commits:
commit 11e7474de60d30533b9e339014ad5d035fa6a0b4
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Mar 28 17:49:37 2012 -0400
fix bug where wrong path was being used for mgmt-users.properties file
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
index 6139dc1..8641df1 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
@@ -255,7 +255,7 @@ public class AbstractBaseDiscovery {
return realm;
}
- String getSecurityPropertyFileFromHostXml(String baseDir, AS7Mode mode, String realm) {
+ String getSecurityPropertyFileFromHostXml(File baseDir, AS7Mode mode, String realm) {
if (hostXml == null)
throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST);
@@ -270,14 +270,15 @@ public class AbstractBaseDiscovery {
else
dmode = "domain";
- String fullName;
- if (relDir.equals("jboss." + dmode + ".config.dir"))
- fullName = baseDir + File.separator + mode.getBaseDir() + File.separator + "configuration" + File.separator
- + fileName;
- else
- fullName = relDir + File.separator + fileName;
+ File configDir;
+ if (relDir.equals("jboss." + dmode + ".config.dir")) {
+ configDir = new File(baseDir, "configuration");
+ } else {
+ configDir = new File(relDir);
+ }
+ File securityPropertyFile = new File(configDir, fileName);
- return fullName;
+ return securityPropertyFile.getPath();
}
protected File getHomeDir(ProcessInfo processInfo) {
12 years, 1 month
[rhq] Branch 'feature/export-reports' - 3 commits - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ExportModalWindow.java | 290 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java | 199 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/SubsystemResourceDriftView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/alert/SubsystemRecentAlertsView.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/configuration/SubsystemConfigurationHistoryListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java | 7
10 files changed, 231 insertions(+), 322 deletions(-)
New commits:
commit 5e16d57beaaae9ff46cbb3227f43c397677b3c7c
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Mar 28 14:00:41 2012 -0700
[BZ 800453] Export Csv Reports. Removal of ExportModalWindow and replace with non-visual ReportExporter to call streaming RESTful reports from backend.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ExportModalWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ExportModalWindow.java
deleted file mode 100644
index 86dbc025..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ExportModalWindow.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- *
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 Red Hat, Inc.
- * * All rights reserved.
- * *
- * * This program is free software; you can redistribute it and/or modify
- * * it under the terms of the GNU General Public License as published by
- * * the Free Software Foundation version 2 of the License.
- * *
- * * This program is distributed in the hope that it will be useful,
- * * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * * GNU General Public License for more details.
- * *
- * * You should have received a copy of the GNU General Public License
- * * along with this program; if not, write to the Free Software
- * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-package org.rhq.enterprise.gui.coregui.client.components;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.Window;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.Messages;
-
-import java.util.Set;
-
-/**
- * Build a custom Export window based for particular export screens.
- *
- * @author Mike Thompson
- */
-public class ExportModalWindow {
-
- private static final Messages MSG = CoreGUI.getMessages();
-
- private static final String BASE_URL = GWT.getHostPageBaseURL().replace("coregui/","")+"rest/1/reports/";
- private static final String FORMAT = "csv"; //CSV is all we need right now
-
- //private static final String FORMAT_FIELD = "format";
- //private static final String DETAILS_FIELD = "details";
- //private static final String DATE_RANGE_FIELD = "dri";
-
- private String reportUrl;
-
- private boolean showAllDetail;
-
- // optional Fields
-
- /**
- * For recent Alerts.
- */
- String[] alertPriorityFilters;
- /**
- * For Recent Operations.
- */
- String[] operationRequestStatuses;
-
- Set<Integer> resourceTypeIds;
-
- // for Recent Drift Report
- String driftDefinition;
- String driftSnapshot;
- String[] driftCategories;
- String driftPath;
-
-
- /**
- * Private constructors to force use of static factory creation pattern.
- * @param reportUrl
- */
- private ExportModalWindow(String reportUrl) {
-
- this.reportUrl = reportUrl;
- }
-
-
- private ExportModalWindow(String reportUrl, boolean showDetail, Set<Integer> resourceTypeIds) {
- this.reportUrl = reportUrl;
- this.showAllDetail = showDetail;
- this.resourceTypeIds = resourceTypeIds;
- }
-
- public static ExportModalWindow createStandardExportWindow(String reportUrl) {
- return new ExportModalWindow(reportUrl);
- }
-
- public static ExportModalWindow createExportWindowForRecentDrift(String reportUrl, String definition,
- String snapshot, String[] driftCategories, String path) {
- ExportModalWindow newExportDialog = new ExportModalWindow(reportUrl);
- newExportDialog.setDriftCategories(driftCategories);
- newExportDialog.setDriftDefinition(definition);
- newExportDialog.setDriftPath(path);
- newExportDialog.setDriftSnapshot(snapshot);
- return newExportDialog;
- }
-
- public static ExportModalWindow createExportWindowForRecentAlerts(String reportUrl, String[] alertPriorityList) {
- ExportModalWindow newExportDialog = new ExportModalWindow(reportUrl);
- newExportDialog.setAlertPriorityFilters(alertPriorityList);
- return newExportDialog;
- }
-
- public static ExportModalWindow createExportWindowForRecentOperations(String reportUrl, String[] operationRequestStatuses ) {
- ExportModalWindow newExportDialog = new ExportModalWindow(reportUrl);
- newExportDialog.setOperationRequestStatusList(operationRequestStatuses);
- return newExportDialog;
- }
-
- public static ExportModalWindow createExportWindowForInventorySummary(String reportUrl, boolean showAllDetails,
- Set<Integer> resourceTypeIdsForExport) {
- return new ExportModalWindow(reportUrl, showAllDetails, resourceTypeIdsForExport);
- }
-
-// private void createDialogWindow() {
-// exportWindow = new PopupWindow("exportSettings", null);
-// exportWindow.setTitle("Export Dialog");
-//
-// VLayout dialogLayout = new VLayout();
-//
-// HLayout headerLayout = new HLayout();
-// headerLayout.setHeight(25);
-// headerLayout.setAlign(Alignment.CENTER);
-// TitleBar titleBar = new TitleBar(exportWindow, "Export Settings", IconEnum.REPORT.getIcon24x24Path());
-// headerLayout.addMember(titleBar);
-// dialogLayout.addMember(headerLayout);
-//
-// HLayout formLayout = new HLayout();
-// formLayout.setAlign(VerticalAlignment.TOP);
-//
-// final DynamicForm form = new DynamicForm();
-//
-// final SelectItem formatsList = new SelectItem(FORMAT_FIELD, "Format");
-// LinkedHashMap<String, String> formats = new LinkedHashMap<String, String>();
-// formats.put("csv", "CSV");
-// formats.put("xml", "XML");
-// formatsList.setValueMap(formats);
-// formatsList.setDefaultValue("csv");
-//
-// CheckboxItem detailCheckboxItem = new CheckboxItem(DETAILS_FIELD, "Show Detail");
-// detailCheckboxItem.setVisible(showAllDetail);
-// detailCheckboxItem.setValue(false);
-//
-// DateRangeItem dateRangeItem = new DateRangeItem(DATE_RANGE_FIELD, "Date Range");
-// dateRangeItem.setAllowRelativeDates(true);
-// DateRange dateRange = new DateRange();
-// dateRange.setRelativeStartDate(new RelativeDate("-1m"));
-// dateRange.setRelativeEndDate(RelativeDate.TODAY);
-// dateRangeItem.setValue(dateRange);
-//
-//
-// form.setItems(new SpacerItem(),formatsList, detailCheckboxItem, new SpacerItem(),new SpacerItem(), dateRangeItem);
-// formLayout.addMember(form);
-// dialogLayout.addMember(formLayout);
-//
-// ToolStrip buttonBar = new ToolStrip();
-// buttonBar.setAlign(Alignment.RIGHT);
-// buttonBar.setPadding(5);
-// buttonBar.setMembersMargin(10);
-//
-// IButton cancelButton = new IButton("Cancel", new ClickHandler() {
-// @Override
-// public void onClick(ClickEvent clickEvent) {
-// exportWindow.hide();
-// }
-// });
-// buttonBar.addMember(cancelButton);
-//
-// IButton finishButton = new IButton("Export", new ClickHandler() {
-// @Override
-// public void onClick(ClickEvent clickEvent) {
-// exportWindow.hide();
-// Window.open(calculateUrl(form), "download", null);
-// }
-// });
-// buttonBar.addMember(finishButton);
-//
-// dialogLayout.addMember(buttonBar);
-//
-// exportWindow.addItem(dialogLayout);
-// }
-
- public void setAlertPriorityFilters(String[] alertPriorityFilters) {
- this.alertPriorityFilters = alertPriorityFilters;
- }
-
- public void setOperationRequestStatusList(String[] operationRequestStatuses) {
- this.operationRequestStatuses = operationRequestStatuses;
- }
-
- public String determineUrl() {
- StringBuilder queryString = new StringBuilder();
-
-// if (showAllDetail) {
-// queryString.append("details=").append(form.getValueAsString(DETAILS_FIELD));
-// }
- if(!isEmpty(operationRequestStatuses)){
- StringBuilder operationRequestStatusBuffer = new StringBuilder();
- for (String operationRequestStatus : operationRequestStatuses) {
- operationRequestStatusBuffer.append(operationRequestStatus);
- operationRequestStatusBuffer.append(",");
- }
-
- queryString.append("operationRequestStatus=").append(operationRequestStatusBuffer.toString());
- }
- if(!isEmpty(alertPriorityFilters)){
- StringBuilder alertsPriorityBuffer = new StringBuilder();
- for (String alertPriority : alertPriorityFilters) {
- alertsPriorityBuffer.append(alertPriority);
- alertsPriorityBuffer.append(",");
- }
- queryString.append("alertPriority=").append(alertsPriorityBuffer.toString());
- }
-
- // Drift Related
- if(!isEmpty(driftCategories)){
- StringBuilder driftCategoriesBuffer = new StringBuilder();
- for (String category : driftCategories) {
- driftCategoriesBuffer.append(category).append(",");
- }
- queryString.append("categories=").append(driftCategoriesBuffer.toString());
- }
- if (driftDefinition != null) {
- queryString.append("definition=").append(driftDefinition);
- }
- if (driftPath != null) {
- queryString.append("path=").append(driftDefinition);
- }
- if (driftSnapshot != null) {
- queryString.append("snapshot=").append(driftSnapshot);
- }
-
-
- return URL.encode(BASE_URL + reportUrl + "." + FORMAT + "?"+queryString);
- }
-
- private boolean isEmpty(String[] array) {
- return array == null || array.length == 0;
- }
-
- public boolean isShowAllDetail(){
- return showAllDetail;
- }
-
- public void setDriftDefinition(String driftDefinition) {
- this.driftDefinition = driftDefinition;
- }
-
- public void setDriftSnapshot(String driftSnapshot) {
- this.driftSnapshot = driftSnapshot;
- }
-
- public void setDriftCategories(String[] driftCategories) {
- this.driftCategories = driftCategories;
- }
-
- public void setDriftPath(String driftPath) {
- this.driftPath = driftPath;
- }
-
- public void show(){
- Window.open(determineUrl(), "download", null);
-
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java
new file mode 100644
index 0000000..4ed3c5c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ReportExporter.java
@@ -0,0 +1,199 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 Red Hat, Inc.
+ * * All rights reserved.
+ * *
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License as published by
+ * * the Free Software Foundation version 2 of the License.
+ * *
+ * * This program is distributed in the hope that it will be useful,
+ * * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * * GNU General Public License for more details.
+ * *
+ * * You should have received a copy of the GNU General Public License
+ * * along with this program; if not, write to the Free Software
+ * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+package org.rhq.enterprise.gui.coregui.client.components;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.http.client.URL;
+import com.google.gwt.user.client.Window;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.Messages;
+
+import java.util.Set;
+
+/**
+ * Exporter for building urls to reports (csv).
+ * The reports are RESTful urls opened up in a new window.
+ *
+ * @author Mike Thompson
+ */
+public class ReportExporter {
+
+ private static final Messages MSG = CoreGUI.getMessages();
+
+ private static final String BASE_URL = GWT.getHostPageBaseURL().replace("coregui/","")+"rest/1/reports/";
+ private static final String FORMAT = "csv"; //CSV is all we need right now
+
+ private String reportUrl;
+
+ private boolean showAllDetail;
+
+ // optional Fields
+
+ /**
+ * For recent Alerts.
+ */
+ String[] alertPriorityFilters;
+ /**
+ * For Recent Operations.
+ */
+ String[] operationRequestStatuses;
+
+ Set<Integer> resourceTypeIds;
+
+ // for Recent Drift Report
+ String driftDefinition;
+ String driftSnapshot;
+ String[] driftCategories;
+ String driftPath;
+
+
+ /**
+ * Private constructors to force use of static factory creation pattern.
+ * @param reportUrl
+ */
+ private ReportExporter(String reportUrl) {
+
+ this.reportUrl = reportUrl;
+ }
+
+
+ private ReportExporter(String reportUrl, boolean showDetail, Set<Integer> resourceTypeIds) {
+ this.reportUrl = reportUrl;
+ this.showAllDetail = showDetail;
+ this.resourceTypeIds = resourceTypeIds;
+ }
+
+ public static ReportExporter createStandardExporter(String reportUrl) {
+ return new ReportExporter(reportUrl);
+ }
+
+ public static ReportExporter createExporterForRecentDrift(String reportUrl, String definition,
+ String snapshot, String[] driftCategories, String path) {
+ ReportExporter newExportDialog = new ReportExporter(reportUrl);
+ newExportDialog.setDriftCategories(driftCategories);
+ newExportDialog.setDriftDefinition(definition);
+ newExportDialog.setDriftPath(path);
+ newExportDialog.setDriftSnapshot(snapshot);
+ return newExportDialog;
+ }
+
+ public static ReportExporter createExporterForRecentAlerts(String reportUrl, String[] alertPriorityList) {
+ ReportExporter newExportDialog = new ReportExporter(reportUrl);
+ newExportDialog.setAlertPriorityFilters(alertPriorityList);
+ return newExportDialog;
+ }
+
+ public static ReportExporter createExporterForRecentOperations(String reportUrl, String[] operationRequestStatuses) {
+ ReportExporter newExportDialog = new ReportExporter(reportUrl);
+ newExportDialog.setOperationRequestStatusList(operationRequestStatuses);
+ return newExportDialog;
+ }
+
+ public static ReportExporter createExporterForInventorySummary(String reportUrl, boolean showAllDetails,
+ Set<Integer> resourceTypeIdsForExport) {
+ return new ReportExporter(reportUrl, showAllDetails, resourceTypeIdsForExport);
+ }
+
+
+ public void setAlertPriorityFilters(String[] alertPriorityFilters) {
+ this.alertPriorityFilters = alertPriorityFilters;
+ }
+
+ public void setOperationRequestStatusList(String[] operationRequestStatuses) {
+ this.operationRequestStatuses = operationRequestStatuses;
+ }
+
+ public String determineUrl() {
+ StringBuilder queryString = new StringBuilder();
+
+// if (showAllDetail) {
+// queryString.append("details=").append(form.getValueAsString(DETAILS_FIELD));
+// }
+ if(!isEmpty(operationRequestStatuses)){
+ StringBuilder operationRequestStatusBuffer = new StringBuilder();
+ for (String operationRequestStatus : operationRequestStatuses) {
+ operationRequestStatusBuffer.append(operationRequestStatus);
+ operationRequestStatusBuffer.append(",");
+ }
+
+ queryString.append("operationRequestStatus=").append(operationRequestStatusBuffer.toString());
+ }
+ if(!isEmpty(alertPriorityFilters)){
+ StringBuilder alertsPriorityBuffer = new StringBuilder();
+ for (String alertPriority : alertPriorityFilters) {
+ alertsPriorityBuffer.append(alertPriority);
+ alertsPriorityBuffer.append(",");
+ }
+ queryString.append("alertPriority=").append(alertsPriorityBuffer.toString());
+ }
+
+ // Drift Related
+ if(!isEmpty(driftCategories)){
+ StringBuilder driftCategoriesBuffer = new StringBuilder();
+ for (String category : driftCategories) {
+ driftCategoriesBuffer.append(category).append(",");
+ }
+ queryString.append("categories=").append(driftCategoriesBuffer.toString());
+ }
+ if (driftDefinition != null) {
+ queryString.append("definition=").append(driftDefinition);
+ }
+ if (driftPath != null) {
+ queryString.append("path=").append(driftDefinition);
+ }
+ if (driftSnapshot != null) {
+ queryString.append("snapshot=").append(driftSnapshot);
+ }
+
+
+ return URL.encode(BASE_URL + reportUrl + "." + FORMAT + "?"+queryString);
+ }
+
+ private boolean isEmpty(String[] array) {
+ return array == null || array.length == 0;
+ }
+
+ public boolean isShowAllDetail(){
+ return showAllDetail;
+ }
+
+ public void setDriftDefinition(String driftDefinition) {
+ this.driftDefinition = driftDefinition;
+ }
+
+ public void setDriftSnapshot(String driftSnapshot) {
+ this.driftSnapshot = driftSnapshot;
+ }
+
+ public void setDriftCategories(String[] driftCategories) {
+ this.driftCategories = driftCategories;
+ }
+
+ public void setDriftPath(String driftPath) {
+ this.driftPath = driftPath;
+ }
+
+ public void export(){
+ Window.open(determineUrl(), "download", null);
+
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
index 52b8fa6..0b56395 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
@@ -27,13 +27,12 @@ import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.HLayout;
-
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.enterprise.gui.coregui.client.IconEnum;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.ReportExporter;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
@@ -45,9 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSour
import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
-import static org.rhq.core.domain.resource.composite.PlatformMetricsSummary.CPUMetric;
-import static org.rhq.core.domain.resource.composite.PlatformMetricsSummary.MemoryMetric;
-import static org.rhq.core.domain.resource.composite.PlatformMetricsSummary.SwapMetric;
+import static org.rhq.core.domain.resource.composite.PlatformMetricsSummary.*;
public class PlatformSummaryPortlet extends Table<PlatformMetricDataSource> implements Portlet, HasViewName {
@@ -123,8 +120,8 @@ public class PlatformSummaryPortlet extends Table<PlatformMetricDataSource> impl
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createStandardExportWindow("platformUtilization");
- exportModalWindow.show();
+ ReportExporter exporter = ReportExporter.createStandardExporter("platformUtilization");
+ exporter.export();
refreshTableInfo();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/SubsystemResourceDriftView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/SubsystemResourceDriftView.java
index 73bed2b..76938f4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/SubsystemResourceDriftView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/SubsystemResourceDriftView.java
@@ -24,7 +24,7 @@ package org.rhq.enterprise.gui.coregui.client.drift;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.ReportExporter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
public class SubsystemResourceDriftView extends DriftHistoryView {
@@ -47,8 +47,8 @@ public class SubsystemResourceDriftView extends DriftHistoryView {
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createExportWindowForRecentDrift("recentDrift",definitionFilter.getValueAsString(),changeSetFilter.getValueAsString(),categoryFilter.getValues(),pathFilter.getValueAsString());
- exportModalWindow.show();
+ ReportExporter exporter = ReportExporter.createExporterForRecentDrift("recentDrift", definitionFilter.getValueAsString(), changeSetFilter.getValueAsString(), categoryFilter.getValues(), pathFilter.getValueAsString());
+ exporter.export();
refreshTableInfo();
}
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 36f64d4..2af348f 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
@@ -46,7 +46,7 @@ import org.rhq.enterprise.gui.coregui.client.IconEnum;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.admin.templates.AlertDefinitionTemplateTypeView;
import org.rhq.enterprise.gui.coregui.client.alert.definitions.AbstractAlertDefinitionsDataSource;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.ReportExporter;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
@@ -114,8 +114,8 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createStandardExportWindow("alertDefinitions");
- exportModalWindow.show();
+ ReportExporter exporter = ReportExporter.createStandardExporter("alertDefinitions");
+ exporter.export();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/alert/SubsystemRecentAlertsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/alert/SubsystemRecentAlertsView.java
index 6ee27d9..bb5beb3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/alert/SubsystemRecentAlertsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/alert/SubsystemRecentAlertsView.java
@@ -1,15 +1,14 @@
package org.rhq.enterprise.gui.coregui.client.report.alert;
-import java.util.ArrayList;
-import java.util.List;
-
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.enterprise.gui.coregui.client.alert.SubsystemResourceAlertView;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.ReportExporter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import java.util.ArrayList;
+import java.util.List;
+
public class SubsystemRecentAlertsView extends SubsystemResourceAlertView {
public SubsystemRecentAlertsView(String locatorId, boolean hasWriteAccess) {
@@ -43,9 +42,9 @@ public class SubsystemRecentAlertsView extends SubsystemResourceAlertView {
alertPriorityList.add(AlertPriority.LOW);
}
}
- ExportModalWindow exportModalWindow = ExportModalWindow.createExportWindowForRecentAlerts(
- "recentAlerts", alertPriorityList.toArray(new String[alertPriorityList.size()]));
- exportModalWindow.show();
+ ReportExporter exporter = ReportExporter.createExporterForRecentAlerts(
+ "recentAlerts", alertPriorityList.toArray(new String[alertPriorityList.size()]));
+ exporter.export();
refreshTableInfo();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/configuration/SubsystemConfigurationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/configuration/SubsystemConfigurationHistoryListView.java
index 4119557..4785776 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/configuration/SubsystemConfigurationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/configuration/SubsystemConfigurationHistoryListView.java
@@ -1,7 +1,7 @@
package org.rhq.enterprise.gui.coregui.client.report.configuration;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.ReportExporter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationHistoryListView;
@@ -27,8 +27,8 @@ public class SubsystemConfigurationHistoryListView extends ResourceConfiguration
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createStandardExportWindow("configurationHistory");
- exportModalWindow.show();
+ ReportExporter exporter = ReportExporter.createStandardExporter("configurationHistory");
+ exporter.export();
refreshTableInfo();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java
index 8905945..1836d4a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/measurement/MeasurementOOBView.java
@@ -25,9 +25,8 @@ package org.rhq.enterprise.gui.coregui.client.report.measurement;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
import org.rhq.enterprise.gui.coregui.client.IconEnum;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.ReportExporter;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
@@ -71,8 +70,8 @@ public class MeasurementOOBView extends Table<MeasurementOOBDataSource> implemen
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createStandardExportWindow("suspectMetrics");
- exportModalWindow.show();
+ ReportExporter exporter = ReportExporter.createStandardExporter("suspectMetrics");
+ exporter.export();
refreshTableInfo();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
index f587c50..f4da7b8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
@@ -21,7 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.report.operation;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.ReportExporter;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
@@ -53,8 +53,8 @@ public class SubsystemOperationHistoryListView extends OperationHistoryView {
@Override
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createExportWindowForRecentOperations("recentOperations",statusFilter.getValues());
- exportModalWindow.show();
+ ReportExporter exporter = ReportExporter.createExporterForRecentOperations("recentOperations", statusFilter.getValues());
+ exporter.export();
refreshTableInfo();
}
commit df80caa441d07dae74772d9f4c26f2516d4c63df
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Mar 28 13:02:36 2012 -0700
[BZ 800453] Export Csv Reports. Remove export window and replace with direct calling of reports (in new window).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ExportModalWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ExportModalWindow.java
index f572495..86dbc025 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ExportModalWindow.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/ExportModalWindow.java
@@ -20,32 +20,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.components;
-import java.util.LinkedHashMap;
-import java.util.Set;
-
import com.google.gwt.core.client.GWT;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.Window;
-import com.smartgwt.client.data.DateRange;
-import com.smartgwt.client.data.RelativeDate;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.types.VerticalAlignment;
-import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.DateRangeItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.layout.HLayout;
-import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.toolbar.ToolStrip;
-
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.IconEnum;
import org.rhq.enterprise.gui.coregui.client.Messages;
-import org.rhq.enterprise.gui.coregui.client.PopupWindow;
+
+import java.util.Set;
/**
* Build a custom Export window based for particular export screens.
@@ -57,15 +38,14 @@ public class ExportModalWindow {
private static final Messages MSG = CoreGUI.getMessages();
private static final String BASE_URL = GWT.getHostPageBaseURL().replace("coregui/","")+"rest/1/reports/";
+ private static final String FORMAT = "csv"; //CSV is all we need right now
- private static final String FORMAT_FIELD = "format";
- private static final String DETAILS_FIELD = "details";
- private static final String DATE_RANGE_FIELD = "dri";
+ //private static final String FORMAT_FIELD = "format";
+ //private static final String DETAILS_FIELD = "details";
+ //private static final String DATE_RANGE_FIELD = "dri";
private String reportUrl;
- private PopupWindow exportWindow;
-
private boolean showAllDetail;
// optional Fields
@@ -88,20 +68,24 @@ public class ExportModalWindow {
String driftPath;
+ /**
+ * Private constructors to force use of static factory creation pattern.
+ * @param reportUrl
+ */
private ExportModalWindow(String reportUrl) {
+
this.reportUrl = reportUrl;
- createDialogWindow();
}
+
+
private ExportModalWindow(String reportUrl, boolean showDetail, Set<Integer> resourceTypeIds) {
this.reportUrl = reportUrl;
this.showAllDetail = showDetail;
this.resourceTypeIds = resourceTypeIds;
- createDialogWindow();
}
public static ExportModalWindow createStandardExportWindow(String reportUrl) {
- ExportModalWindow newExportDialog = new ExportModalWindow(reportUrl);
- return newExportDialog;
+ return new ExportModalWindow(reportUrl);
}
public static ExportModalWindow createExportWindowForRecentDrift(String reportUrl, String definition,
@@ -128,77 +112,76 @@ public class ExportModalWindow {
public static ExportModalWindow createExportWindowForInventorySummary(String reportUrl, boolean showAllDetails,
Set<Integer> resourceTypeIdsForExport) {
- ExportModalWindow newExportDialog = new ExportModalWindow(reportUrl, showAllDetails, resourceTypeIdsForExport);
- return newExportDialog;
+ return new ExportModalWindow(reportUrl, showAllDetails, resourceTypeIdsForExport);
}
- private void createDialogWindow() {
- exportWindow = new PopupWindow("exportSettings", null);
- exportWindow.setTitle("Export Dialog");
-
- VLayout dialogLayout = new VLayout();
-
- HLayout headerLayout = new HLayout();
- headerLayout.setHeight(25);
- headerLayout.setAlign(Alignment.CENTER);
- TitleBar titleBar = new TitleBar(exportWindow, "Export Settings", IconEnum.REPORT.getIcon24x24Path());
- headerLayout.addMember(titleBar);
- dialogLayout.addMember(headerLayout);
-
- HLayout formLayout = new HLayout();
- formLayout.setAlign(VerticalAlignment.TOP);
-
- final DynamicForm form = new DynamicForm();
-
- final SelectItem formatsList = new SelectItem(FORMAT_FIELD, "Format");
- LinkedHashMap<String, String> formats = new LinkedHashMap<String, String>();
- formats.put("csv", "CSV");
- formats.put("xml", "XML");
- formatsList.setValueMap(formats);
- formatsList.setDefaultValue("csv");
-
- CheckboxItem detailCheckboxItem = new CheckboxItem(DETAILS_FIELD, "Show Detail");
- detailCheckboxItem.setVisible(showAllDetail);
- detailCheckboxItem.setValue(false);
-
- DateRangeItem dateRangeItem = new DateRangeItem(DATE_RANGE_FIELD, "Date Range");
- dateRangeItem.setAllowRelativeDates(true);
- DateRange dateRange = new DateRange();
- dateRange.setRelativeStartDate(new RelativeDate("-1m"));
- dateRange.setRelativeEndDate(RelativeDate.TODAY);
- dateRangeItem.setValue(dateRange);
-
-
- form.setItems(new SpacerItem(),formatsList, detailCheckboxItem, new SpacerItem(),new SpacerItem(), dateRangeItem);
- formLayout.addMember(form);
- dialogLayout.addMember(formLayout);
-
- ToolStrip buttonBar = new ToolStrip();
- buttonBar.setAlign(Alignment.RIGHT);
- buttonBar.setPadding(5);
- buttonBar.setMembersMargin(10);
-
- IButton cancelButton = new IButton("Cancel", new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- exportWindow.hide();
- }
- });
- buttonBar.addMember(cancelButton);
-
- IButton finishButton = new IButton("Export", new ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- exportWindow.hide();
- Window.open(calculateUrl(form), "download", null);
- }
- });
- buttonBar.addMember(finishButton);
-
- dialogLayout.addMember(buttonBar);
-
- exportWindow.addItem(dialogLayout);
- }
+// private void createDialogWindow() {
+// exportWindow = new PopupWindow("exportSettings", null);
+// exportWindow.setTitle("Export Dialog");
+//
+// VLayout dialogLayout = new VLayout();
+//
+// HLayout headerLayout = new HLayout();
+// headerLayout.setHeight(25);
+// headerLayout.setAlign(Alignment.CENTER);
+// TitleBar titleBar = new TitleBar(exportWindow, "Export Settings", IconEnum.REPORT.getIcon24x24Path());
+// headerLayout.addMember(titleBar);
+// dialogLayout.addMember(headerLayout);
+//
+// HLayout formLayout = new HLayout();
+// formLayout.setAlign(VerticalAlignment.TOP);
+//
+// final DynamicForm form = new DynamicForm();
+//
+// final SelectItem formatsList = new SelectItem(FORMAT_FIELD, "Format");
+// LinkedHashMap<String, String> formats = new LinkedHashMap<String, String>();
+// formats.put("csv", "CSV");
+// formats.put("xml", "XML");
+// formatsList.setValueMap(formats);
+// formatsList.setDefaultValue("csv");
+//
+// CheckboxItem detailCheckboxItem = new CheckboxItem(DETAILS_FIELD, "Show Detail");
+// detailCheckboxItem.setVisible(showAllDetail);
+// detailCheckboxItem.setValue(false);
+//
+// DateRangeItem dateRangeItem = new DateRangeItem(DATE_RANGE_FIELD, "Date Range");
+// dateRangeItem.setAllowRelativeDates(true);
+// DateRange dateRange = new DateRange();
+// dateRange.setRelativeStartDate(new RelativeDate("-1m"));
+// dateRange.setRelativeEndDate(RelativeDate.TODAY);
+// dateRangeItem.setValue(dateRange);
+//
+//
+// form.setItems(new SpacerItem(),formatsList, detailCheckboxItem, new SpacerItem(),new SpacerItem(), dateRangeItem);
+// formLayout.addMember(form);
+// dialogLayout.addMember(formLayout);
+//
+// ToolStrip buttonBar = new ToolStrip();
+// buttonBar.setAlign(Alignment.RIGHT);
+// buttonBar.setPadding(5);
+// buttonBar.setMembersMargin(10);
+//
+// IButton cancelButton = new IButton("Cancel", new ClickHandler() {
+// @Override
+// public void onClick(ClickEvent clickEvent) {
+// exportWindow.hide();
+// }
+// });
+// buttonBar.addMember(cancelButton);
+//
+// IButton finishButton = new IButton("Export", new ClickHandler() {
+// @Override
+// public void onClick(ClickEvent clickEvent) {
+// exportWindow.hide();
+// Window.open(calculateUrl(form), "download", null);
+// }
+// });
+// buttonBar.addMember(finishButton);
+//
+// dialogLayout.addMember(buttonBar);
+//
+// exportWindow.addItem(dialogLayout);
+// }
public void setAlertPriorityFilters(String[] alertPriorityFilters) {
this.alertPriorityFilters = alertPriorityFilters;
@@ -208,13 +191,12 @@ public class ExportModalWindow {
this.operationRequestStatuses = operationRequestStatuses;
}
- public String calculateUrl(DynamicForm form) {
- String format = form.getValueAsString(FORMAT_FIELD);
+ public String determineUrl() {
StringBuilder queryString = new StringBuilder();
- if (showAllDetail) {
- queryString.append("details=").append(form.getValueAsString(DETAILS_FIELD));
- }
+// if (showAllDetail) {
+// queryString.append("details=").append(form.getValueAsString(DETAILS_FIELD));
+// }
if(!isEmpty(operationRequestStatuses)){
StringBuilder operationRequestStatusBuffer = new StringBuilder();
for (String operationRequestStatus : operationRequestStatuses) {
@@ -252,7 +234,7 @@ public class ExportModalWindow {
}
- return URL.encode(BASE_URL + reportUrl + "." + format + "?"+queryString);
+ return URL.encode(BASE_URL + reportUrl + "." + FORMAT + "?"+queryString);
}
private boolean isEmpty(String[] array) {
@@ -263,10 +245,6 @@ public class ExportModalWindow {
return showAllDetail;
}
- public void setShowAllDetail(boolean showAllDetail) {
- this.showAllDetail = showAllDetail;
- }
-
public void setDriftDefinition(String driftDefinition) {
this.driftDefinition = driftDefinition;
}
@@ -283,8 +261,9 @@ public class ExportModalWindow {
this.driftPath = driftPath;
}
- public void show() {
- exportWindow.show();
+ public void show(){
+ Window.open(determineUrl(), "download", null);
+
}
}
commit 5d2098e58f1ddb3e2fafe2b39de0df527baaf5c5
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Mar 28 07:52:28 2012 -0700
[BZ 800453] Export Csv Reports. Add path and snapshot filters to REST Api.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java
index 2e65214..6a56fb9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/reporting/RecentDriftHandler.java
@@ -58,8 +58,13 @@ public class RecentDriftHandler extends AbstractRestBean implements RecentDriftL
log.info("Drift Snapshot version Filter set for: " + snapshot);
criteria.addFilterChangeSetEndVersion(snapshot);
}
+ if(path != null){
+ log.info("Drift Path Filter set for: " + path);
+ criteria.addFilterPath(path);
+ }
if(definition != null){
- //@todo: drift definition search
+ log.info("Drift Definition Filter set for: " + definition);
+ criteria.addFilterId(path);
}
List<DriftCategory> driftCategoryList = new ArrayList<DriftCategory>(10);
12 years, 1 month
[rhq] 2 commits - modules/core modules/plugins
by ips
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java | 24 ++++------
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 15 +++++-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java | 8 ++-
3 files changed, 28 insertions(+), 19 deletions(-)
New commits:
commit c26cd5c8284e5d1aef243dde12477067df719d3b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Mar 28 17:26:57 2012 -0400
improve error handling
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 06371c6..f6dc975 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -72,16 +72,21 @@ public abstract class BaseProcessDiscovery extends AbstractBaseDiscovery
discoveredResources.add(details);
log.info("Discovered new " + discoveryContext.getResourceType().getName() + " Resource with key ["
+ details.getResourceKey() + "].");
- } catch (Exception e) {
+ } catch (RuntimeException e) {
+ // Only barf a stack trace for runtime exceptions.
log.error("Discovery of a " + discoveryContext.getResourceType().getName()
+ " Resource failed for " + processScanResult.getProcessInfo() + ".", e);
+ } catch (Exception e) {
+ log.error("Discovery of a " + discoveryContext.getResourceType().getName()
+ + " Resource failed for " + processScanResult.getProcessInfo() + " - cause: " + e);
}
}
return discoveredResources;
}
- protected DiscoveredResourceDetails buildResourceDetails(ResourceDiscoveryContext discoveryContext, ProcessScanResult psr) {
+ protected DiscoveredResourceDetails buildResourceDetails(ResourceDiscoveryContext discoveryContext,
+ ProcessScanResult psr) throws Exception {
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
// IF SE, then look at domain/configuration/host.xml <management interface="default" port="9990
// for management port
@@ -97,7 +102,11 @@ public abstract class BaseProcessDiscovery extends AbstractBaseDiscovery
String configName = baseDir.getName();
String key = baseDir.getPath();
File configDir = getConfigDir(process, baseDir);
- readStandaloneOrHostXmlFromFile(getHostXmlFile(process, configDir).getPath()); // this sets this.hostXml
+ File hostXmlFile = getHostXmlFile(process, configDir);
+ if (!hostXmlFile.exists()) {
+ throw new Exception("Server configuration file not found at the expected location (" + hostXmlFile + ").");
+ }
+ readStandaloneOrHostXmlFromFile(hostXmlFile.getPath()); // this sets this.hostXml
HostPort hostPort = getHostPortFromHostXml();
String name = buildDefaultResourceName(hostPort, configName, productType);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
index 1c49aaa..3f5efdb 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
@@ -113,8 +113,12 @@ public class ManagedASComponent extends BaseComponent {
// We need to deduct the domain host from the path, as it is not encoded in the resource itself.
String serverPath = path;
- serverPath = serverPath.substring(0,serverPath.indexOf(","));
- serverPath = serverPath.substring(serverPath.indexOf("=")+1);
+ try {
+ serverPath = serverPath.substring(0,serverPath.indexOf(","));
+ serverPath = serverPath.substring(serverPath.indexOf("=")+1);
+ } catch (RuntimeException e) {
+ throw new Exception("Failed to extract hostname from server path [" + serverPath + "].", e);
+ }
configuration.put(new PropertySimple("hostname",serverPath));
Operation op = new ReadResource(getAddress());
commit c03837e0bfc1b545809fe9728498848ea1d32a67
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Mar 28 17:21:22 2012 -0400
improve logging
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
index 6138dcf..4447b9f 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2012 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,6 @@ package org.rhq.core.pc.configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.agent.PluginContainerException;
-import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.clientapi.server.configuration.ConfigurationServerService;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -35,8 +34,6 @@ import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import java.util.HashSet;
-import java.util.Set;
import java.util.List;
import java.util.concurrent.Callable;
@@ -44,6 +41,7 @@ import java.util.concurrent.Callable;
* @author Greg Hinkle
*/
public class ConfigurationCheckExecutor implements Runnable, Callable {
+
private Log log = LogFactory.getLog(ConfigurationCheckExecutor.class);
private ConfigurationManager configurationManager;
@@ -62,7 +60,7 @@ public class ConfigurationCheckExecutor implements Runnable, Callable {
}
public Object call() {
- log.info("Starting configuration update check");
+ log.info("Starting configuration update check...");
long start = System.currentTimeMillis();
checkConfigurations(this.inventoryManager.getPlatform(), true);
@@ -87,20 +85,16 @@ public class ConfigurationCheckExecutor implements Runnable, Callable {
// Expecting when the resource does not support configuration management
}
-
if (resourceComponent != null) {
// Only report availability for committed resources; don't bother with new, ignored or deleted resources.
if (resource.getInventoryStatus() == InventoryStatus.COMMITTED
&& resourceType.getResourceConfigurationDefinition() != null) {
- if (log.isErrorEnabled())
- log.debug("Checking for updated resource configuration on: " + resource);
-
- ConfigurationUpdateRequest request =
- new ConfigurationUpdateRequest(0, resource.getResourceConfiguration(), resource.getId());
+ if (log.isDebugEnabled()) {
+ log.debug("Checking for updated Resource configuration for " + resource + "...");
+ }
try {
-
Configuration liveConfiguration = resourceComponent.loadResourceConfiguration();
if (liveConfiguration != null) {
@@ -123,7 +117,8 @@ public class ConfigurationCheckExecutor implements Runnable, Callable {
}
}
} catch (Throwable t) {
- log.warn("Unable to check for updated configuration", t);
+ log.warn("An error occurred while checking for an updated Resource configuration for " +
+ resource + ".", t);
}
}
}
@@ -131,7 +126,7 @@ public class ConfigurationCheckExecutor implements Runnable, Callable {
if (checkChildren) {
for (Resource child : resource.getChildResources()) {
try {
- checkConfigurations(child, true);
+ checkConfigurations(child, true);
} catch (Exception e) {
e.printStackTrace();
}
@@ -139,4 +134,5 @@ public class ConfigurationCheckExecutor implements Runnable, Callable {
}
}
}
+
}
12 years, 1 month
[rhq] Branch 'feature/export-reports' - modules/enterprise
by John Sanda
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceDataSource.java | 89 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java | 112 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReportTable.java | 73 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryDataSource.java | 132 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryReportTable.java | 248 ---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java | 112 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceDataSource.java | 89 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceReport.java | 113 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceReportTable.java | 73 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryDataSource.java | 130 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java | 249 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/ResourceInstallReport.java | 112 ++++
13 files changed, 768 insertions(+), 766 deletions(-)
New commits:
commit bcdb861c866b2fbc2f4a28f1b85ee58f423c17b9
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Mar 28 17:04:32 2012 -0400
[BZ 802544] more refactoring of inventory summary and drift compliance reports
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceDataSource.java
deleted file mode 100644
index 2d9ce8e..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceDataSource.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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.report;
-
-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.DataSourceField;
-import com.smartgwt.client.data.fields.DataSourceBooleanField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.Criteria;
-import org.rhq.core.domain.resource.composite.ResourceInstallCount;
-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;
-
-/**
- * @author jsanda
- */
-public class DriftComplianceDataSource extends InventorySummaryDataSource {
-
- public static final String IN_COMPLIANCE = "inCompliance";
-
- @Override
- public DataSourceField[] getFields() {
- DataSourceField[] fields = super.getFields();
- DataSourceField[] newFields = new DataSourceField[fields.length + 1];
-
- for (int i = 0; i < fields.length - 1; ++i) {
- newFields[i] = fields[i];
- }
- newFields[newFields.length - 2] = new DataSourceBooleanField(IN_COMPLIANCE);
- newFields[newFields.length - 1] = fields[fields.length -1];
-
- return newFields;
- }
-
- @Override
- public ListGridRecord copyValues(ResourceInstallCount from) {
- ListGridRecord record = super.copyValues(from);
- if (from.getNumDriftTemplates() > 0) {
- record.setAttribute(IN_COMPLIANCE, Boolean.toString(from.isInCompliance()));
- }
- return record;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response, Criteria unused) {
- ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
-
- resourceService.findResourceComplianceCounts(new AsyncCallback<List<ResourceInstallCount>>() {
- @Override
- public void onSuccess(List<ResourceInstallCount> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_reports_inventorySummary_failFetch(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java
deleted file mode 100644
index be10040..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 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.report;
-
-import com.smartgwt.client.data.Criteria;
-
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.IconEnum;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
-import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * A tweaked version of the InventorySummary report that narrows the relevant types to those that support Drift
- * monitoring, and shows the compliance state of each type.
- *
- * @author Jay Shaughnessy
- */
-public class DriftComplianceReport extends LocatableVLayout implements BookmarkableView, HasViewName {
-
- public static final ViewName VIEW_ID = new ViewName("DriftCompliance", MSG.view_reports_driftCompliance(),
- IconEnum.DRIFT_COMPLIANCE);
-
- private ResourceSearchView resourceList;
-
- public DriftComplianceReport(String locatorId ) {
- super(locatorId);
- setHeight100();
- setWidth100();
- }
-
- @Override
- public void renderView(ViewPath viewPath) {
- if (!viewPath.isEnd()) {
- int resourceTypeId = Integer.parseInt(viewPath.getCurrent().getPath());
- viewPath.next();
- Criteria criteria;
- if (!viewPath.isEnd()) {
- String resourceVersion = viewPath.getCurrent().getPath();
- criteria = createResourceSearchViewCriteria(resourceTypeId, resourceVersion);
- } else {
- criteria = createResourceSearchViewCriteria(resourceTypeId);
- }
- showResourceList(criteria);
- } else {
- hideResourceList();
- }
- }
-
- @Override
- protected void onInit() {
- super.onInit();
- addMember(new DriftComplianceReportTable(extendLocatorId("table")));
- }
-
- protected Criteria createResourceSearchViewCriteria(int resourceTypeId) {
- Criteria criteria = new Criteria();
- criteria.addCriteria(ResourceDataSourceField.TYPE.propertyName(), resourceTypeId);
- return criteria;
- }
-
- protected Criteria createResourceSearchViewCriteria(int resourceTypeId, String resourceVersion) {
- Criteria criteria = new Criteria();
- criteria.addCriteria(ResourceDataSourceField.TYPE.propertyName(), resourceTypeId);
- criteria.addCriteria("version", resourceVersion);
- return criteria;
- }
-
- private void showResourceList(Criteria criteria) {
- hideResourceList();
- resourceList = new DriftComplianceReportResourceSearchView(extendLocatorId("resourceList"), criteria);
- addMember(resourceList);
- markForRedraw();
- }
-
- private void hideResourceList() {
- if (resourceList != null) {
- removeMember(resourceList);
- resourceList.destroy();
- resourceList = null;
- }
- markForRedraw();
- }
-
- @Override
- public ViewName getViewName() {
- return VIEW_ID;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReportTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReportTable.java
deleted file mode 100644
index 18fdaea..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReportTable.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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.report;
-
-import java.util.HashMap;
-import java.util.List;
-
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.widgets.grid.ListGridField;
-
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-
-/**
- * @author jsanda
- */
-public class DriftComplianceReportTable extends InventorySummaryReportTable {
-
- public DriftComplianceReportTable(String locatorId) {
- super(locatorId);
- setDataSource(new DriftComplianceDataSource());
- }
-
- @Override
- protected List<ListGridField> createListGridFields() {
- List<ListGridField> fields = super.createListGridFields();
- fields.add(fields.size() - 1, createInComplianceField());
-
- return fields;
- }
-
- protected ListGridField createInComplianceField() {
- ListGridField field = new ListGridField(DriftComplianceDataSource.IN_COMPLIANCE, MSG
- .common_title_in_compliance());
- HashMap<String, String> complianceIcons = new HashMap<String, String>();
- complianceIcons.put("true", ImageManager.getAvailabilityIcon(true));
- complianceIcons.put("false", ImageManager.getAvailabilityIcon(false));
- field.setValueIcons(complianceIcons);
- field.setType(ListGridFieldType.ICON);
- field.setCanSortClientOnly(true);
- field.setWidth(100);
-
- return field;
- }
-
- @Override
- protected String getReportNameForResourceTypeURL() {
- return "DriftCompliance";
- }
-
- @Override
- protected String getReportNameForDownloadURL() {
- return "driftCompliance";
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryDataSource.java
deleted file mode 100644
index fb88265..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryDataSource.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- *
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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.report;
-
-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.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceBooleanField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
-import com.smartgwt.client.data.fields.DataSourceLinkField;
-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.resource.composite.ResourceInstallCount;
-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.util.RPCDataSource;
-
-/**
- * @author jsanda
- */
-public class InventorySummaryDataSource extends RPCDataSource<ResourceInstallCount, Criteria> {
-
- public class Field {
- public static final String COUNT = "count"; // long that we convert to int
- public static final String TYPENAME = "typeName"; // String
- public static final String TYPEPLUGIN = "typePlugin"; // String
- public static final String CATEGORY = "category"; // ResourceCategory
- public static final String TYPEID = "typeId"; // int
- public static final String VERSION = "version"; // String
- public static final String OBJECT = "object";
- public static final String EXPORT = "exportDetails";
- }
-
- public InventorySummaryDataSource() {
- setFields(getFields());
- }
-
- @Override
- public ResourceInstallCount copyValues(Record from) {
- return null;
- }
-
- @Override
- public ListGridRecord copyValues(ResourceInstallCount from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute(Field.COUNT,
- Long.valueOf(from.getCount()).intValue()); // we'll never have over Integer.MAX_VALUE, overflow not a worry
- record.setAttribute(Field.TYPENAME, from.getTypeName());
- record.setAttribute(Field.TYPEPLUGIN, from.getTypePlugin());
- record.setAttribute(Field.CATEGORY, from.getCategory().name());
- record.setAttribute(Field.TYPEID, from.getTypeId());
- record.setAttribute(Field.VERSION, from.getVersion());
- record.setAttribute(Field.OBJECT, from);
- record.setAttribute(Field.EXPORT, false);
-
- return record;
- }
-
- @Override
- public DataSourceField[] getFields() {
- return new DataSourceField[] {
- new DataSourceLinkField(Field.TYPENAME),
- new DataSourceTextField(Field.TYPEPLUGIN),
- new DataSourceImageField(Field.CATEGORY),
- new DataSourceTextField(Field.VERSION),
- new DataSourceIntegerField(Field.COUNT),
- new DataSourceBooleanField(Field.EXPORT)
- };
- }
-
- @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) {
- ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
-
- resourceService.findResourceInstallCounts(true, new AsyncCallback<List<ResourceInstallCount>>() {
-
- @Override
- public void onSuccess(List<ResourceInstallCount> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_reports_inventorySummary_failFetch(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected void executeUpdate(Record editedRecord, Record oldRecord, DSRequest request,
- DSResponse response) {
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryReportTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryReportTable.java
deleted file mode 100644
index 1fea9a9..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryReportTable.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- *
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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.report;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import com.smartgwt.client.types.ListGridEditEvent;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.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.ResourceCategory;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
-
-/**
-* @author jsanda
-*/
-public class InventorySummaryReportTable extends Table<InventorySummaryDataSource> {
-
- private boolean exportAll;
-
- private ExportChangeHandler exportChangeHandler;
-
- public InventorySummaryReportTable(String locatorId) {
- super(locatorId);
- setDataSource(new InventorySummaryDataSource());
- }
-
- @Override
- protected void configureTable() {
- exportChangeHandler = new ExportChangeHandler(getListGrid(), InventorySummaryDataSource.Field.TYPEID,
- InventorySummaryDataSource.Field.EXPORT);
-
- List<ListGridField> fields = createListGridFields();
-
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid lg = (ListGrid) event.getSource();
- ListGridRecord selected = lg.getSelectedRecord();
- String url = getResourceTypeTableUrl(selected);
- if (url != null) {
- CoreGUI.goToView(url);
- }
- }
- });
-
- setListGridFields(fields.toArray(new ListGridField[fields.size()]));
- getListGrid().setEditEvent(ListGridEditEvent.CLICK);
- getListGrid().setEditByCell(true);
- addExportAction();
- }
-
- protected List<ListGridField> createListGridFields() {
- List<ListGridField> fields = new ArrayList<ListGridField>();
- fields.add(createNameField());
- fields.add(createPluginField());
- fields.add(createCategoryField());
- fields.add(createVersionField());
- fields.add(createCountField());
- fields.add(createExportField());
-
- // TODO (ips, 11/11/11): The groupBy functionality is very buggy in SmartGWT 2.4. Once they fix it
- // uncomment these lines to allow grouping by the plugin or category fields.
- /*getListGrid().setCanGroupBy(true);
- fieldTypeName.setCanGroupBy(false);
- fieldVersion.setCanGroupBy(false);
- fieldCount.setCanGroupBy(false); */
-
- return fields;
- }
-
- protected ListGridField createNameField() {
- ListGridField field = new ListGridField(InventorySummaryDataSource.Field.TYPENAME,
- MSG.common_title_resource_type());
- field.setWidth("35%");
-
- field.setCellFormatter(new CellFormatter() {
- @Override
- public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- String url = getResourceTypeTableUrl(record);
- if (url == null) {
- return value.toString();
- }
-
- return "<a href=\"" + url + "\">" + value.toString() + "</a>";
- }
- });
-
- return field;
- }
-
- protected ListGridField createPluginField() {
- ListGridField field = new ListGridField(InventorySummaryDataSource.Field.TYPEPLUGIN, MSG.common_title_plugin());
- field.setWidth("10%");
- return field;
- }
-
- protected ListGridField createCategoryField() {
- ListGridField field = new ListGridField(InventorySummaryDataSource.Field.CATEGORY,
- MSG.common_title_category());
-
- field.setWidth(70);
- field.setType(ListGridFieldType.ICON);
- field.setShowValueIconOnly(true);
- HashMap<String, String> categoryIcons = new HashMap<String, String>(3);
- categoryIcons
- .put(ResourceCategory.PLATFORM.name(), ImageManager.getResourceIcon(ResourceCategory.PLATFORM));
- categoryIcons.put(ResourceCategory.SERVER.name(), ImageManager.getResourceIcon(ResourceCategory.SERVER));
- categoryIcons.put(ResourceCategory.SERVICE.name(), ImageManager.getResourceIcon(ResourceCategory.SERVICE));
- field.setValueIcons(categoryIcons);
- field.setShowHover(true);
- field.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- String cat = record.getAttribute(InventorySummaryDataSource.Field.CATEGORY);
- if (ResourceCategory.PLATFORM.name().equals(cat)) {
- return MSG.common_title_platform();
- } else if (ResourceCategory.SERVER.name().equals(cat)) {
- return MSG.common_title_server();
- } else if (ResourceCategory.SERVICE.name().equals(cat)) {
- return MSG.common_title_service();
- }
- return "";
- }
- });
-
- return field;
- }
-
- protected ListGridField createVersionField() {
- ListGridField field = new ListGridField(InventorySummaryDataSource.Field.VERSION, MSG.common_title_version());
- field.setWidth("*");
- return field;
- }
-
- protected ListGridField createCountField() {
- ListGridField field = new ListGridField(InventorySummaryDataSource.Field.COUNT, MSG.common_title_count());
- field.setWidth(60);
- return field;
- }
-
- protected ListGridField createExportField() {
- ListGridField field = new ListGridField("exportDetails", "Export Details");
-
- field.setCanToggle(true);
- field.setCanEdit(true);
- field.addChangedHandler(exportChangeHandler);
-
- return field;
- }
-
- private void addExportAction() {
- addTableAction("Export", "Export", new TableAction() {
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return true;
- }
-
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createExportWindowForInventorySummary(
- getReportNameForDownloadURL(), exportAll, exportChangeHandler.getResourceTypeIds());
- exportModalWindow.show();
- refreshTableInfo();
- }
- });
- }
-
- @Override
- protected void configureTableFilters() {
- CheckboxItem exportAllDetails = new CheckboxItem("exportAllDetails", "Export All Details");
- exportAllDetails.setLabelAsTitle(true);
-
- setShowFilterForm(true);
- setFilterFormItems(exportAllDetails);
-
- exportAllDetails.addChangedHandler(new ChangedHandler() {
- @Override
- public void onChanged(ChangedEvent event) {
- exportAll = !exportAll;
- ListGrid table = getListGrid();
- int numColumns = table.getFields().length;
- int row = 0;
- for (ListGridRecord record : table.getRecords()) {
- record.setAttribute(InventorySummaryDataSource.Field.EXPORT, exportAll);
- table.refreshCell(row++, numColumns - 1);
- }
- }
- });
- }
-
- private String getResourceTypeTableUrl(ListGridRecord selected) {
- String url = null;
- if (selected != null) {
- int resourceTypeId = selected.getAttributeAsInt(InventorySummaryDataSource.Field.TYPEID);
- String version = selected.getAttribute(InventorySummaryDataSource.Field.VERSION);
- if (version == null) {
- url = "#Reports/Inventory/" + getReportNameForResourceTypeURL() + "/" + resourceTypeId;
- } else {
- url = "#Reports/Inventory/" + getReportNameForResourceTypeURL() + "/" + resourceTypeId + "/" + version;
- }
- }
- return url;
- }
-
- protected String getReportNameForResourceTypeURL() {
- return "InventorySummary";
- }
-
- protected String getReportNameForDownloadURL() {
- return "inventorySummary";
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index 9df2a6c..acb8219 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -46,6 +46,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configura
import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
import org.rhq.enterprise.gui.coregui.client.report.alert.SubsystemRecentAlertsView;
import org.rhq.enterprise.gui.coregui.client.report.configuration.SubsystemConfigurationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.report.inventory.DriftComplianceReport;
+import org.rhq.enterprise.gui.coregui.client.report.inventory.ResourceInstallReport;
import org.rhq.enterprise.gui.coregui.client.report.measurement.MeasurementOOBView;
import org.rhq.enterprise.gui.coregui.client.report.operation.SubsystemOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
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
deleted file mode 100644
index ff843f9..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 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.report;
-
-import com.smartgwt.client.data.Criteria;
-
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.IconEnum;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
-import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * A tabular report that shows the types of resources are installed and how many
- * of them are installed.
- *
- * @author John Mazzitelli
- */
-public class ResourceInstallReport extends LocatableVLayout implements BookmarkableView, HasViewName {
-
- public static final ViewName VIEW_ID = new ViewName("InventorySummary", MSG.common_title_inventorySummary(), IconEnum.INVENTORY_SUMMARY);
-
- private ResourceSearchView resourceList;
-
- public ResourceInstallReport(String locatorId ) {
- super(locatorId);
- setHeight100();
- setWidth100();
- }
-
- @Override
- public void renderView(ViewPath viewPath) {
- if (!viewPath.isEnd()) {
- int resourceTypeId = Integer.parseInt(viewPath.getCurrent().getPath());
- viewPath.next();
- Criteria criteria;
- if (!viewPath.isEnd()) {
- String resourceVersion = viewPath.getCurrent().getPath();
- criteria = createResourceSearchViewCriteria(resourceTypeId, resourceVersion);
- } else {
- criteria = createResourceSearchViewCriteria(resourceTypeId);
- }
- showResourceList(criteria);
- } else {
- hideResourceList();
- }
- }
-
- @Override
- protected void onInit() {
- super.onInit();
- addMember(new InventorySummaryReportTable(extendLocatorId("table")));
- }
-
- protected Criteria createResourceSearchViewCriteria(int resourceTypeId) {
- Criteria criteria = new Criteria();
- criteria.addCriteria(ResourceDataSourceField.TYPE.propertyName(), resourceTypeId);
- return criteria;
- }
-
- protected Criteria createResourceSearchViewCriteria(int resourceTypeId, String resourceVersion) {
- Criteria criteria = new Criteria();
- criteria.addCriteria(ResourceDataSourceField.TYPE.propertyName(), resourceTypeId);
- criteria.addCriteria("version", resourceVersion);
- return criteria;
- }
-
- private void showResourceList(Criteria criteria) {
- hideResourceList();
- resourceList = new ResourceSearchView(extendLocatorId("resourceList"), criteria);
- addMember(resourceList);
- markForRedraw();
- }
-
- private void hideResourceList() {
- if (resourceList != null) {
- removeMember(resourceList);
- resourceList.destroy();
- resourceList = null;
- }
- markForRedraw();
- }
-
- @Override
- public ViewName getViewName() {
- return VIEW_ID;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceDataSource.java
new file mode 100644
index 0000000..c3e9e7c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceDataSource.java
@@ -0,0 +1,89 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.report.inventory;
+
+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.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceBooleanField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.resource.composite.ResourceInstallCount;
+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;
+
+/**
+ * @author jsanda
+ */
+public class DriftComplianceDataSource extends InventorySummaryDataSource {
+
+ public static final String IN_COMPLIANCE = "inCompliance";
+
+ @Override
+ public DataSourceField[] getFields() {
+ DataSourceField[] fields = super.getFields();
+ DataSourceField[] newFields = new DataSourceField[fields.length + 1];
+
+ for (int i = 0; i < fields.length - 1; ++i) {
+ newFields[i] = fields[i];
+ }
+ newFields[newFields.length - 2] = new DataSourceBooleanField(IN_COMPLIANCE);
+ newFields[newFields.length - 1] = fields[fields.length -1];
+
+ return newFields;
+ }
+
+ @Override
+ public ListGridRecord copyValues(ResourceInstallCount from) {
+ ListGridRecord record = super.copyValues(from);
+ if (from.getNumDriftTemplates() > 0) {
+ record.setAttribute(IN_COMPLIANCE, Boolean.toString(from.isInCompliance()));
+ }
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, Criteria unused) {
+ ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ resourceService.findResourceComplianceCounts(new AsyncCallback<List<ResourceInstallCount>>() {
+ @Override
+ public void onSuccess(List<ResourceInstallCount> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_reports_inventorySummary_failFetch(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceReport.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceReport.java
new file mode 100644
index 0000000..e74fa5f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceReport.java
@@ -0,0 +1,113 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.report.inventory;
+
+import com.smartgwt.client.data.Criteria;
+
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.IconEnum;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
+import org.rhq.enterprise.gui.coregui.client.report.DriftComplianceReportResourceSearchView;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A tweaked version of the InventorySummary report that narrows the relevant types to those that support Drift
+ * monitoring, and shows the compliance state of each type.
+ *
+ * @author Jay Shaughnessy
+ */
+public class DriftComplianceReport extends LocatableVLayout implements BookmarkableView, HasViewName {
+
+ public static final ViewName VIEW_ID = new ViewName("DriftCompliance", MSG.view_reports_driftCompliance(),
+ IconEnum.DRIFT_COMPLIANCE);
+
+ private ResourceSearchView resourceList;
+
+ public DriftComplianceReport(String locatorId ) {
+ super(locatorId);
+ setHeight100();
+ setWidth100();
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ if (!viewPath.isEnd()) {
+ int resourceTypeId = Integer.parseInt(viewPath.getCurrent().getPath());
+ viewPath.next();
+ Criteria criteria;
+ if (!viewPath.isEnd()) {
+ String resourceVersion = viewPath.getCurrent().getPath();
+ criteria = createResourceSearchViewCriteria(resourceTypeId, resourceVersion);
+ } else {
+ criteria = createResourceSearchViewCriteria(resourceTypeId);
+ }
+ showResourceList(criteria);
+ } else {
+ hideResourceList();
+ }
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ addMember(new DriftComplianceReportTable(extendLocatorId("table")));
+ }
+
+ protected Criteria createResourceSearchViewCriteria(int resourceTypeId) {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria(ResourceDataSourceField.TYPE.propertyName(), resourceTypeId);
+ return criteria;
+ }
+
+ protected Criteria createResourceSearchViewCriteria(int resourceTypeId, String resourceVersion) {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria(ResourceDataSourceField.TYPE.propertyName(), resourceTypeId);
+ criteria.addCriteria("version", resourceVersion);
+ return criteria;
+ }
+
+ private void showResourceList(Criteria criteria) {
+ hideResourceList();
+ resourceList = new DriftComplianceReportResourceSearchView(extendLocatorId("resourceList"), criteria);
+ addMember(resourceList);
+ markForRedraw();
+ }
+
+ private void hideResourceList() {
+ if (resourceList != null) {
+ removeMember(resourceList);
+ resourceList.destroy();
+ resourceList = null;
+ }
+ markForRedraw();
+ }
+
+ @Override
+ public ViewName getViewName() {
+ return VIEW_ID;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceReportTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceReportTable.java
new file mode 100644
index 0000000..e9b933c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/DriftComplianceReportTable.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.report.inventory;
+
+import java.util.HashMap;
+import java.util.List;
+
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.grid.ListGridField;
+
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+
+/**
+ * @author jsanda
+ */
+public class DriftComplianceReportTable extends InventorySummaryReportTable {
+
+ public DriftComplianceReportTable(String locatorId) {
+ super(locatorId);
+ setDataSource(new DriftComplianceDataSource());
+ }
+
+ @Override
+ protected List<ListGridField> createListGridFields() {
+ List<ListGridField> fields = super.createListGridFields();
+ fields.add(fields.size() - 1, createInComplianceField());
+
+ return fields;
+ }
+
+ protected ListGridField createInComplianceField() {
+ ListGridField field = new ListGridField(DriftComplianceDataSource.IN_COMPLIANCE, MSG
+ .common_title_in_compliance());
+ HashMap<String, String> complianceIcons = new HashMap<String, String>();
+ complianceIcons.put("true", ImageManager.getAvailabilityIcon(true));
+ complianceIcons.put("false", ImageManager.getAvailabilityIcon(false));
+ field.setValueIcons(complianceIcons);
+ field.setType(ListGridFieldType.ICON);
+ field.setCanSortClientOnly(true);
+ field.setWidth(100);
+
+ return field;
+ }
+
+ @Override
+ protected String getReportNameForResourceTypeURL() {
+ return "DriftCompliance";
+ }
+
+ @Override
+ protected String getReportNameForDownloadURL() {
+ return "driftCompliance";
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryDataSource.java
new file mode 100644
index 0000000..374e8ab
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryDataSource.java
@@ -0,0 +1,130 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.report.inventory;
+
+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.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceBooleanField;
+import com.smartgwt.client.data.fields.DataSourceImageField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceLinkField;
+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.resource.composite.ResourceInstallCount;
+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.util.RPCDataSource;
+
+/**
+ * @author jsanda
+ */
+public class InventorySummaryDataSource extends RPCDataSource<ResourceInstallCount, Criteria> {
+
+ public static final String COUNT = "count"; // long that we convert to int
+ public static final String TYPENAME = "typeName"; // String
+ public static final String TYPEPLUGIN = "typePlugin"; // String
+ public static final String CATEGORY = "category"; // ResourceCategory
+ public static final String TYPEID = "typeId"; // int
+ public static final String VERSION = "version"; // String
+ public static final String OBJECT = "object";
+ public static final String EXPORT = "exportDetails";
+
+ public InventorySummaryDataSource() {
+ setFields(getFields());
+ }
+
+ @Override
+ public ResourceInstallCount copyValues(Record from) {
+ return null;
+ }
+
+ @Override
+ public ListGridRecord copyValues(ResourceInstallCount from) {
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(COUNT,
+ Long.valueOf(from.getCount()).intValue()); // we'll never have over Integer.MAX_VALUE, overflow not a worry
+ record.setAttribute(TYPENAME, from.getTypeName());
+ record.setAttribute(TYPEPLUGIN, from.getTypePlugin());
+ record.setAttribute(CATEGORY, from.getCategory().name());
+ record.setAttribute(TYPEID, from.getTypeId());
+ record.setAttribute(VERSION, from.getVersion());
+ record.setAttribute(OBJECT, from);
+ record.setAttribute(EXPORT, false);
+
+ return record;
+ }
+
+ @Override
+ public DataSourceField[] getFields() {
+ return new DataSourceField[] {
+ new DataSourceLinkField(TYPENAME),
+ new DataSourceTextField(TYPEPLUGIN),
+ new DataSourceImageField(CATEGORY),
+ new DataSourceTextField(VERSION),
+ new DataSourceIntegerField(COUNT),
+ new DataSourceBooleanField(EXPORT)
+ };
+ }
+
+ @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) {
+ ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ resourceService.findResourceInstallCounts(true, new AsyncCallback<List<ResourceInstallCount>>() {
+
+ @Override
+ public void onSuccess(List<ResourceInstallCount> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_reports_inventorySummary_failFetch(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected void executeUpdate(Record editedRecord, Record oldRecord, DSRequest request,
+ DSResponse response) {
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java
new file mode 100644
index 0000000..62dedfb
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/InventorySummaryReportTable.java
@@ -0,0 +1,249 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.report.inventory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.smartgwt.client.types.ListGridEditEvent;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.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.ResourceCategory;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.report.ExportChangeHandler;
+
+/**
+* @author jsanda
+*/
+public class InventorySummaryReportTable extends Table<InventorySummaryDataSource> {
+
+ private boolean exportAll;
+
+ private ExportChangeHandler exportChangeHandler;
+
+ public InventorySummaryReportTable(String locatorId) {
+ super(locatorId);
+ setDataSource(new InventorySummaryDataSource());
+ }
+
+ @Override
+ protected void configureTable() {
+ exportChangeHandler = new ExportChangeHandler(getListGrid(), InventorySummaryDataSource.TYPEID,
+ InventorySummaryDataSource.EXPORT);
+
+ List<ListGridField> fields = createListGridFields();
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid lg = (ListGrid) event.getSource();
+ ListGridRecord selected = lg.getSelectedRecord();
+ String url = getResourceTypeTableUrl(selected);
+ if (url != null) {
+ CoreGUI.goToView(url);
+ }
+ }
+ });
+
+ setListGridFields(fields.toArray(new ListGridField[fields.size()]));
+ getListGrid().setEditEvent(ListGridEditEvent.CLICK);
+ getListGrid().setEditByCell(true);
+ addExportAction();
+ }
+
+ protected List<ListGridField> createListGridFields() {
+ List<ListGridField> fields = new ArrayList<ListGridField>();
+ fields.add(createNameField());
+ fields.add(createPluginField());
+ fields.add(createCategoryField());
+ fields.add(createVersionField());
+ fields.add(createCountField());
+ fields.add(createExportField());
+
+ // TODO (ips, 11/11/11): The groupBy functionality is very buggy in SmartGWT 2.4. Once they fix it
+ // uncomment these lines to allow grouping by the plugin or category fields.
+ /*getListGrid().setCanGroupBy(true);
+ fieldTypeName.setCanGroupBy(false);
+ fieldVersion.setCanGroupBy(false);
+ fieldCount.setCanGroupBy(false); */
+
+ return fields;
+ }
+
+ protected ListGridField createNameField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.TYPENAME,
+ MSG.common_title_resource_type());
+ field.setWidth("35%");
+
+ field.setCellFormatter(new CellFormatter() {
+ @Override
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String url = getResourceTypeTableUrl(record);
+ if (url == null) {
+ return value.toString();
+ }
+
+ return "<a href=\"" + url + "\">" + value.toString() + "</a>";
+ }
+ });
+
+ return field;
+ }
+
+ protected ListGridField createPluginField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.TYPEPLUGIN, MSG.common_title_plugin());
+ field.setWidth("10%");
+ return field;
+ }
+
+ protected ListGridField createCategoryField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.CATEGORY,
+ MSG.common_title_category());
+
+ field.setWidth(70);
+ field.setType(ListGridFieldType.ICON);
+ field.setShowValueIconOnly(true);
+ HashMap<String, String> categoryIcons = new HashMap<String, String>(3);
+ categoryIcons
+ .put(ResourceCategory.PLATFORM.name(), ImageManager.getResourceIcon(ResourceCategory.PLATFORM));
+ categoryIcons.put(ResourceCategory.SERVER.name(), ImageManager.getResourceIcon(ResourceCategory.SERVER));
+ categoryIcons.put(ResourceCategory.SERVICE.name(), ImageManager.getResourceIcon(ResourceCategory.SERVICE));
+ field.setValueIcons(categoryIcons);
+ field.setShowHover(true);
+ field.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String cat = record.getAttribute(InventorySummaryDataSource.CATEGORY);
+ if (ResourceCategory.PLATFORM.name().equals(cat)) {
+ return MSG.common_title_platform();
+ } else if (ResourceCategory.SERVER.name().equals(cat)) {
+ return MSG.common_title_server();
+ } else if (ResourceCategory.SERVICE.name().equals(cat)) {
+ return MSG.common_title_service();
+ }
+ return "";
+ }
+ });
+
+ return field;
+ }
+
+ protected ListGridField createVersionField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.VERSION, MSG.common_title_version());
+ field.setWidth("*");
+ return field;
+ }
+
+ protected ListGridField createCountField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.COUNT, MSG.common_title_count());
+ field.setWidth(60);
+ return field;
+ }
+
+ protected ListGridField createExportField() {
+ ListGridField field = new ListGridField("exportDetails", "Export Details");
+
+ field.setCanToggle(true);
+ field.setCanEdit(true);
+ field.addChangedHandler(exportChangeHandler);
+
+ return field;
+ }
+
+ private void addExportAction() {
+ addTableAction("Export", "Export", new TableAction() {
+ @Override
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return true;
+ }
+
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ ExportModalWindow exportModalWindow = ExportModalWindow.createExportWindowForInventorySummary(
+ getReportNameForDownloadURL(), exportAll, exportChangeHandler.getResourceTypeIds());
+ exportModalWindow.show();
+ refreshTableInfo();
+ }
+ });
+ }
+
+ @Override
+ protected void configureTableFilters() {
+ CheckboxItem exportAllDetails = new CheckboxItem("exportAllDetails", "Export All Details");
+ exportAllDetails.setLabelAsTitle(true);
+
+ setShowFilterForm(true);
+ setFilterFormItems(exportAllDetails);
+
+ exportAllDetails.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ exportAll = !exportAll;
+ ListGrid table = getListGrid();
+ int numColumns = table.getFields().length;
+ int row = 0;
+ for (ListGridRecord record : table.getRecords()) {
+ record.setAttribute(InventorySummaryDataSource.EXPORT, exportAll);
+ table.refreshCell(row++, numColumns - 1);
+ }
+ }
+ });
+ }
+
+ private String getResourceTypeTableUrl(ListGridRecord selected) {
+ String url = null;
+ if (selected != null) {
+ int resourceTypeId = selected.getAttributeAsInt(InventorySummaryDataSource.TYPEID);
+ String version = selected.getAttribute(InventorySummaryDataSource.VERSION);
+ if (version == null) {
+ url = "#Reports/Inventory/" + getReportNameForResourceTypeURL() + "/" + resourceTypeId;
+ } else {
+ url = "#Reports/Inventory/" + getReportNameForResourceTypeURL() + "/" + resourceTypeId + "/" + version;
+ }
+ }
+ return url;
+ }
+
+ protected String getReportNameForResourceTypeURL() {
+ return "InventorySummary";
+ }
+
+ protected String getReportNameForDownloadURL() {
+ return "inventorySummary";
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/ResourceInstallReport.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/ResourceInstallReport.java
new file mode 100644
index 0000000..acba358
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/inventory/ResourceInstallReport.java
@@ -0,0 +1,112 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.report.inventory;
+
+import com.smartgwt.client.data.Criteria;
+
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.IconEnum;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A tabular report that shows the types of resources are installed and how many
+ * of them are installed.
+ *
+ * @author John Mazzitelli
+ */
+public class ResourceInstallReport extends LocatableVLayout implements BookmarkableView, HasViewName {
+
+ public static final ViewName VIEW_ID = new ViewName("InventorySummary", MSG.common_title_inventorySummary(), IconEnum.INVENTORY_SUMMARY);
+
+ private ResourceSearchView resourceList;
+
+ public ResourceInstallReport(String locatorId ) {
+ super(locatorId);
+ setHeight100();
+ setWidth100();
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ if (!viewPath.isEnd()) {
+ int resourceTypeId = Integer.parseInt(viewPath.getCurrent().getPath());
+ viewPath.next();
+ Criteria criteria;
+ if (!viewPath.isEnd()) {
+ String resourceVersion = viewPath.getCurrent().getPath();
+ criteria = createResourceSearchViewCriteria(resourceTypeId, resourceVersion);
+ } else {
+ criteria = createResourceSearchViewCriteria(resourceTypeId);
+ }
+ showResourceList(criteria);
+ } else {
+ hideResourceList();
+ }
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ addMember(new InventorySummaryReportTable(extendLocatorId("table")));
+ }
+
+ protected Criteria createResourceSearchViewCriteria(int resourceTypeId) {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria(ResourceDataSourceField.TYPE.propertyName(), resourceTypeId);
+ return criteria;
+ }
+
+ protected Criteria createResourceSearchViewCriteria(int resourceTypeId, String resourceVersion) {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria(ResourceDataSourceField.TYPE.propertyName(), resourceTypeId);
+ criteria.addCriteria("version", resourceVersion);
+ return criteria;
+ }
+
+ private void showResourceList(Criteria criteria) {
+ hideResourceList();
+ resourceList = new ResourceSearchView(extendLocatorId("resourceList"), criteria);
+ addMember(resourceList);
+ markForRedraw();
+ }
+
+ private void hideResourceList() {
+ if (resourceList != null) {
+ removeMember(resourceList);
+ resourceList.destroy();
+ resourceList = null;
+ }
+ markForRedraw();
+ }
+
+ @Override
+ public ViewName getViewName() {
+ return VIEW_ID;
+ }
+
+}
12 years, 1 month
[rhq] Branch 'feature/export-reports' - modules/enterprise
by John Sanda
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceDataSource.java | 89 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java | 255 ---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReportTable.java | 73 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryDataSource.java | 132 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryReportTable.java | 248 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java | 263 ----------
6 files changed, 545 insertions(+), 515 deletions(-)
New commits:
commit 07e5b5304772eb7907609c460b1ac73217648596
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Mar 28 16:49:13 2012 -0400
[BZ 802544] Refactorig inventory summary and drift compliance reports code
The inventory summary and drift compliance reports are nearly the same.
The drift compliance report limits the resource types to those that
support drift. It also adds an "in compliance" column. Since more
functionality needs to be added to these reports in support of exporting
details, I have decided to refactor the table and data source code into
common, shared classes so as to avoid having to duplicate the new logic.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceDataSource.java
new file mode 100644
index 0000000..2d9ce8e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceDataSource.java
@@ -0,0 +1,89 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.report;
+
+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.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceBooleanField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.resource.composite.ResourceInstallCount;
+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;
+
+/**
+ * @author jsanda
+ */
+public class DriftComplianceDataSource extends InventorySummaryDataSource {
+
+ public static final String IN_COMPLIANCE = "inCompliance";
+
+ @Override
+ public DataSourceField[] getFields() {
+ DataSourceField[] fields = super.getFields();
+ DataSourceField[] newFields = new DataSourceField[fields.length + 1];
+
+ for (int i = 0; i < fields.length - 1; ++i) {
+ newFields[i] = fields[i];
+ }
+ newFields[newFields.length - 2] = new DataSourceBooleanField(IN_COMPLIANCE);
+ newFields[newFields.length - 1] = fields[fields.length -1];
+
+ return newFields;
+ }
+
+ @Override
+ public ListGridRecord copyValues(ResourceInstallCount from) {
+ ListGridRecord record = super.copyValues(from);
+ if (from.getNumDriftTemplates() > 0) {
+ record.setAttribute(IN_COMPLIANCE, Boolean.toString(from.isInCompliance()));
+ }
+ return record;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, Criteria unused) {
+ ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ resourceService.findResourceComplianceCounts(new AsyncCallback<List<ResourceInstallCount>>() {
+ @Override
+ public void onSuccess(List<ResourceInstallCount> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_reports_inventorySummary_failFetch(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java
index 05dc91a..be10040 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReport.java
@@ -22,46 +22,15 @@
*/
package org.rhq.enterprise.gui.coregui.client.report;
-import java.util.HashMap;
-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.Record;
-import com.smartgwt.client.data.fields.DataSourceBooleanField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
-import com.smartgwt.client.data.fields.DataSourceLinkField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.types.ListGridEditEvent;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-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.ResourceCategory;
-import org.rhq.core.domain.resource.composite.ResourceInstallCount;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.IconEnum;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
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.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -72,7 +41,8 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class DriftComplianceReport extends LocatableVLayout implements BookmarkableView, HasViewName {
- public static final ViewName VIEW_ID = new ViewName("DriftCompliance", MSG.view_reports_driftCompliance(), IconEnum.DRIFT_COMPLIANCE);
+ public static final ViewName VIEW_ID = new ViewName("DriftCompliance", MSG.view_reports_driftCompliance(),
+ IconEnum.DRIFT_COMPLIANCE);
private ResourceSearchView resourceList;
@@ -139,225 +109,4 @@ public class DriftComplianceReport extends LocatableVLayout implements Bookmarka
public ViewName getViewName() {
return VIEW_ID;
}
-
- class DriftComplianceReportTable extends Table<DriftComplianceReportTable.DataSource> {
-
- public DriftComplianceReportTable(String locatorId) {
- super(locatorId);
- setDataSource(new DataSource());
- }
-
- @Override
- protected void configureTable() {
- super.configureTable();
-
- ListGridField fieldTypeName = new ListGridField(DataSource.Field.TYPENAME, MSG.common_title_resource_type());
- ListGridField fieldPlugin = new ListGridField(DataSource.Field.TYPEPLUGIN, MSG.common_title_plugin());
- ListGridField fieldCategory = new ListGridField(DataSource.Field.CATEGORY, MSG.common_title_category());
- ListGridField fieldVersion = new ListGridField(DataSource.Field.VERSION, MSG.common_title_version());
- ListGridField fieldCount = new ListGridField(DataSource.Field.COUNT, MSG.common_title_count());
- ListGridField fieldExport = new ListGridField("exportDetails", "Export Details");
-
- ExportChangeHandler exportChangeHandler = new ExportChangeHandler(getListGrid(), DataSource.Field.TYPEID,
- DataSource.Field.EXPORT);
- fieldExport.setCanToggle(true);
- fieldExport.setCanEdit(true);
- fieldExport.addChangedHandler(exportChangeHandler);
-
- ListGridField fieldInCompliance = new ListGridField(DataSource.Field.IN_COMPLIANCE, MSG
- .common_title_in_compliance());
- HashMap<String, String> complianceIcons = new HashMap<String, String>();
- complianceIcons.put("true", ImageManager.getAvailabilityIcon(true));
- complianceIcons.put("false", ImageManager.getAvailabilityIcon(false));
- fieldInCompliance.setValueIcons(complianceIcons);
- fieldInCompliance.setType(ListGridFieldType.ICON);
- fieldInCompliance.setCanSortClientOnly(true);
-
- fieldTypeName.setWidth("35%");
- fieldPlugin.setWidth("10%");
- fieldCategory.setWidth(70);
- fieldVersion.setWidth("*");
- fieldCount.setWidth(60);
- fieldInCompliance.setWidth(100);
-
- // TODO (ips, 11/11/11): The groupBy functionality is very buggy in SmartGWT 2.4. Once they fix it
- // uncomment these lines to allow grouping by the plugin or category fields.
- /*getListGrid().setCanGroupBy(true);
- fieldTypeName.setCanGroupBy(false);
- fieldVersion.setCanGroupBy(false);
- fieldCount.setCanGroupBy(false);
- fieldInCompliance.setCanGroupBy(false);*/
-
- fieldTypeName.setCellFormatter(new CellFormatter() {
- @Override
- public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- String url = getResourceTypeTableUrl(record);
- if (url == null) {
- return value.toString();
- }
-
- return "<a href=\"" + url + "\">" + value.toString() + "</a>";
- }
- });
-
- fieldCategory.setType(ListGridFieldType.ICON);
- fieldCategory.setShowValueIconOnly(true);
- HashMap<String, String> categoryIcons = new HashMap<String, String>(3);
- categoryIcons
- .put(ResourceCategory.PLATFORM.name(), ImageManager.getResourceIcon(ResourceCategory.PLATFORM));
- categoryIcons.put(ResourceCategory.SERVER.name(), ImageManager.getResourceIcon(ResourceCategory.SERVER));
- categoryIcons.put(ResourceCategory.SERVICE.name(), ImageManager.getResourceIcon(ResourceCategory.SERVICE));
- fieldCategory.setValueIcons(categoryIcons);
- fieldCategory.setShowHover(true);
- fieldCategory.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- String cat = record.getAttribute(DataSource.Field.CATEGORY);
- if (ResourceCategory.PLATFORM.name().equals(cat)) {
- return MSG.common_title_platform();
- } else if (ResourceCategory.SERVER.name().equals(cat)) {
- return MSG.common_title_server();
- } else if (ResourceCategory.SERVICE.name().equals(cat)) {
- return MSG.common_title_service();
- }
- return "";
- }
- });
-
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid lg = (ListGrid) event.getSource();
- ListGridRecord selected = lg.getSelectedRecord();
- String url = getResourceTypeTableUrl(selected);
- if (url != null) {
- CoreGUI.goToView(url);
- }
- }
- });
-
- setListGridFields(fieldTypeName, fieldPlugin, fieldCategory, fieldVersion, fieldCount, fieldInCompliance,
- fieldExport);
- getListGrid().setEditEvent(ListGridEditEvent.CLICK);
- getListGrid().setEditByCell(true);
- addExportAction();
- }
-
- private void addExportAction() {
- addTableAction("Export", "Export", new TableAction() {
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return true;
- }
-
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow =
- ExportModalWindow.createExportWindowForInventorySummary("driftCompliance", false, null);
- exportModalWindow.show();
- refreshTableInfo();
- }
- });
- }
-
- private String getResourceTypeTableUrl(ListGridRecord selected) {
- String url = null;
- if (selected != null) {
- int resourceTypeId = selected.getAttributeAsInt(DataSource.Field.TYPEID);
- String version = selected.getAttribute(DataSource.Field.VERSION);
- if (version == null) {
- url = "#Reports/Inventory/DriftCompliance/" + resourceTypeId;
- } else {
- url = "#Reports/Inventory/DriftCompliance/" + resourceTypeId + "/" + version;
- }
- }
- return url;
- }
-
- 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
- public static final String TYPENAME = "typeName"; // String
- public static final String TYPEPLUGIN = "typePlugin"; // String
- public static final String CATEGORY = "category"; // ResourceCategory
- public static final String TYPEID = "typeId"; // int
- public static final String VERSION = "version"; // String
- public static final String OBJECT = "object";
- public static final String IN_COMPLIANCE = "inCompliance";
- public static final String EXPORT = "exportDetails";
- }
-
- public DataSource() {
- DataSourceLinkField name = new DataSourceLinkField(Field.TYPENAME);
- DataSourceTextField plugin = new DataSourceTextField(Field.TYPEPLUGIN);
- DataSourceImageField category = new DataSourceImageField(Field.CATEGORY);
- DataSourceTextField version = new DataSourceTextField(Field.VERSION);
- DataSourceIntegerField count = new DataSourceIntegerField(Field.COUNT);
- DataSourceBooleanField inCompliance = new DataSourceBooleanField(Field.IN_COMPLIANCE);
- DataSourceBooleanField export = new DataSourceBooleanField(Field.EXPORT);
-
- setFields(name, plugin, category, version, count, inCompliance, export);
- }
-
- @Override
- public ResourceInstallCount copyValues(Record from) {
- return (ResourceInstallCount) from.getAttributeAsObject(DataSource.Field.OBJECT);
- }
-
- @Override
- public ListGridRecord copyValues(ResourceInstallCount from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute(Field.COUNT, Long.valueOf(from.getCount()).intValue()); // we'll never have over Integer.MAX_VALUE, overflow not a worry
- record.setAttribute(Field.TYPENAME, from.getTypeName());
- record.setAttribute(Field.TYPEPLUGIN, from.getTypePlugin());
- record.setAttribute(Field.CATEGORY, from.getCategory().name());
- record.setAttribute(Field.TYPEID, from.getTypeId());
- record.setAttribute(Field.VERSION, from.getVersion());
- record.setAttribute(Field.OBJECT, from);
- record.setAttribute(Field.EXPORT, false);
-
- if (from.getNumDriftTemplates() > 0) {
- record.setAttribute(Field.IN_COMPLIANCE, Boolean.toString(from.isInCompliance()));
- }
-
- return record;
- }
-
- @Override
- 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.findResourceComplianceCounts(new AsyncCallback<List<ResourceInstallCount>>() {
-
- @Override
- public void onSuccess(List<ResourceInstallCount> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_reports_inventorySummary_failFetch(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected void executeUpdate(Record editedRecord, Record oldRecord, DSRequest request,
- DSResponse response) {
- }
- }
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReportTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReportTable.java
new file mode 100644
index 0000000..18fdaea
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/DriftComplianceReportTable.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.report;
+
+import java.util.HashMap;
+import java.util.List;
+
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.grid.ListGridField;
+
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+
+/**
+ * @author jsanda
+ */
+public class DriftComplianceReportTable extends InventorySummaryReportTable {
+
+ public DriftComplianceReportTable(String locatorId) {
+ super(locatorId);
+ setDataSource(new DriftComplianceDataSource());
+ }
+
+ @Override
+ protected List<ListGridField> createListGridFields() {
+ List<ListGridField> fields = super.createListGridFields();
+ fields.add(fields.size() - 1, createInComplianceField());
+
+ return fields;
+ }
+
+ protected ListGridField createInComplianceField() {
+ ListGridField field = new ListGridField(DriftComplianceDataSource.IN_COMPLIANCE, MSG
+ .common_title_in_compliance());
+ HashMap<String, String> complianceIcons = new HashMap<String, String>();
+ complianceIcons.put("true", ImageManager.getAvailabilityIcon(true));
+ complianceIcons.put("false", ImageManager.getAvailabilityIcon(false));
+ field.setValueIcons(complianceIcons);
+ field.setType(ListGridFieldType.ICON);
+ field.setCanSortClientOnly(true);
+ field.setWidth(100);
+
+ return field;
+ }
+
+ @Override
+ protected String getReportNameForResourceTypeURL() {
+ return "DriftCompliance";
+ }
+
+ @Override
+ protected String getReportNameForDownloadURL() {
+ return "driftCompliance";
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryDataSource.java
new file mode 100644
index 0000000..fb88265
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryDataSource.java
@@ -0,0 +1,132 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.report;
+
+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.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceBooleanField;
+import com.smartgwt.client.data.fields.DataSourceImageField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceLinkField;
+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.resource.composite.ResourceInstallCount;
+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.util.RPCDataSource;
+
+/**
+ * @author jsanda
+ */
+public class InventorySummaryDataSource extends RPCDataSource<ResourceInstallCount, Criteria> {
+
+ public class Field {
+ public static final String COUNT = "count"; // long that we convert to int
+ public static final String TYPENAME = "typeName"; // String
+ public static final String TYPEPLUGIN = "typePlugin"; // String
+ public static final String CATEGORY = "category"; // ResourceCategory
+ public static final String TYPEID = "typeId"; // int
+ public static final String VERSION = "version"; // String
+ public static final String OBJECT = "object";
+ public static final String EXPORT = "exportDetails";
+ }
+
+ public InventorySummaryDataSource() {
+ setFields(getFields());
+ }
+
+ @Override
+ public ResourceInstallCount copyValues(Record from) {
+ return null;
+ }
+
+ @Override
+ public ListGridRecord copyValues(ResourceInstallCount from) {
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(Field.COUNT,
+ Long.valueOf(from.getCount()).intValue()); // we'll never have over Integer.MAX_VALUE, overflow not a worry
+ record.setAttribute(Field.TYPENAME, from.getTypeName());
+ record.setAttribute(Field.TYPEPLUGIN, from.getTypePlugin());
+ record.setAttribute(Field.CATEGORY, from.getCategory().name());
+ record.setAttribute(Field.TYPEID, from.getTypeId());
+ record.setAttribute(Field.VERSION, from.getVersion());
+ record.setAttribute(Field.OBJECT, from);
+ record.setAttribute(Field.EXPORT, false);
+
+ return record;
+ }
+
+ @Override
+ public DataSourceField[] getFields() {
+ return new DataSourceField[] {
+ new DataSourceLinkField(Field.TYPENAME),
+ new DataSourceTextField(Field.TYPEPLUGIN),
+ new DataSourceImageField(Field.CATEGORY),
+ new DataSourceTextField(Field.VERSION),
+ new DataSourceIntegerField(Field.COUNT),
+ new DataSourceBooleanField(Field.EXPORT)
+ };
+ }
+
+ @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) {
+ ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ resourceService.findResourceInstallCounts(true, new AsyncCallback<List<ResourceInstallCount>>() {
+
+ @Override
+ public void onSuccess(List<ResourceInstallCount> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_reports_inventorySummary_failFetch(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected void executeUpdate(Record editedRecord, Record oldRecord, DSRequest request,
+ DSResponse response) {
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryReportTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryReportTable.java
new file mode 100644
index 0000000..1fea9a9
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/InventorySummaryReportTable.java
@@ -0,0 +1,248 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.report;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.smartgwt.client.types.ListGridEditEvent;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.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.ResourceCategory;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+
+/**
+* @author jsanda
+*/
+public class InventorySummaryReportTable extends Table<InventorySummaryDataSource> {
+
+ private boolean exportAll;
+
+ private ExportChangeHandler exportChangeHandler;
+
+ public InventorySummaryReportTable(String locatorId) {
+ super(locatorId);
+ setDataSource(new InventorySummaryDataSource());
+ }
+
+ @Override
+ protected void configureTable() {
+ exportChangeHandler = new ExportChangeHandler(getListGrid(), InventorySummaryDataSource.Field.TYPEID,
+ InventorySummaryDataSource.Field.EXPORT);
+
+ List<ListGridField> fields = createListGridFields();
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid lg = (ListGrid) event.getSource();
+ ListGridRecord selected = lg.getSelectedRecord();
+ String url = getResourceTypeTableUrl(selected);
+ if (url != null) {
+ CoreGUI.goToView(url);
+ }
+ }
+ });
+
+ setListGridFields(fields.toArray(new ListGridField[fields.size()]));
+ getListGrid().setEditEvent(ListGridEditEvent.CLICK);
+ getListGrid().setEditByCell(true);
+ addExportAction();
+ }
+
+ protected List<ListGridField> createListGridFields() {
+ List<ListGridField> fields = new ArrayList<ListGridField>();
+ fields.add(createNameField());
+ fields.add(createPluginField());
+ fields.add(createCategoryField());
+ fields.add(createVersionField());
+ fields.add(createCountField());
+ fields.add(createExportField());
+
+ // TODO (ips, 11/11/11): The groupBy functionality is very buggy in SmartGWT 2.4. Once they fix it
+ // uncomment these lines to allow grouping by the plugin or category fields.
+ /*getListGrid().setCanGroupBy(true);
+ fieldTypeName.setCanGroupBy(false);
+ fieldVersion.setCanGroupBy(false);
+ fieldCount.setCanGroupBy(false); */
+
+ return fields;
+ }
+
+ protected ListGridField createNameField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.Field.TYPENAME,
+ MSG.common_title_resource_type());
+ field.setWidth("35%");
+
+ field.setCellFormatter(new CellFormatter() {
+ @Override
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String url = getResourceTypeTableUrl(record);
+ if (url == null) {
+ return value.toString();
+ }
+
+ return "<a href=\"" + url + "\">" + value.toString() + "</a>";
+ }
+ });
+
+ return field;
+ }
+
+ protected ListGridField createPluginField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.Field.TYPEPLUGIN, MSG.common_title_plugin());
+ field.setWidth("10%");
+ return field;
+ }
+
+ protected ListGridField createCategoryField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.Field.CATEGORY,
+ MSG.common_title_category());
+
+ field.setWidth(70);
+ field.setType(ListGridFieldType.ICON);
+ field.setShowValueIconOnly(true);
+ HashMap<String, String> categoryIcons = new HashMap<String, String>(3);
+ categoryIcons
+ .put(ResourceCategory.PLATFORM.name(), ImageManager.getResourceIcon(ResourceCategory.PLATFORM));
+ categoryIcons.put(ResourceCategory.SERVER.name(), ImageManager.getResourceIcon(ResourceCategory.SERVER));
+ categoryIcons.put(ResourceCategory.SERVICE.name(), ImageManager.getResourceIcon(ResourceCategory.SERVICE));
+ field.setValueIcons(categoryIcons);
+ field.setShowHover(true);
+ field.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String cat = record.getAttribute(InventorySummaryDataSource.Field.CATEGORY);
+ if (ResourceCategory.PLATFORM.name().equals(cat)) {
+ return MSG.common_title_platform();
+ } else if (ResourceCategory.SERVER.name().equals(cat)) {
+ return MSG.common_title_server();
+ } else if (ResourceCategory.SERVICE.name().equals(cat)) {
+ return MSG.common_title_service();
+ }
+ return "";
+ }
+ });
+
+ return field;
+ }
+
+ protected ListGridField createVersionField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.Field.VERSION, MSG.common_title_version());
+ field.setWidth("*");
+ return field;
+ }
+
+ protected ListGridField createCountField() {
+ ListGridField field = new ListGridField(InventorySummaryDataSource.Field.COUNT, MSG.common_title_count());
+ field.setWidth(60);
+ return field;
+ }
+
+ protected ListGridField createExportField() {
+ ListGridField field = new ListGridField("exportDetails", "Export Details");
+
+ field.setCanToggle(true);
+ field.setCanEdit(true);
+ field.addChangedHandler(exportChangeHandler);
+
+ return field;
+ }
+
+ private void addExportAction() {
+ addTableAction("Export", "Export", new TableAction() {
+ @Override
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return true;
+ }
+
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ ExportModalWindow exportModalWindow = ExportModalWindow.createExportWindowForInventorySummary(
+ getReportNameForDownloadURL(), exportAll, exportChangeHandler.getResourceTypeIds());
+ exportModalWindow.show();
+ refreshTableInfo();
+ }
+ });
+ }
+
+ @Override
+ protected void configureTableFilters() {
+ CheckboxItem exportAllDetails = new CheckboxItem("exportAllDetails", "Export All Details");
+ exportAllDetails.setLabelAsTitle(true);
+
+ setShowFilterForm(true);
+ setFilterFormItems(exportAllDetails);
+
+ exportAllDetails.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ exportAll = !exportAll;
+ ListGrid table = getListGrid();
+ int numColumns = table.getFields().length;
+ int row = 0;
+ for (ListGridRecord record : table.getRecords()) {
+ record.setAttribute(InventorySummaryDataSource.Field.EXPORT, exportAll);
+ table.refreshCell(row++, numColumns - 1);
+ }
+ }
+ });
+ }
+
+ private String getResourceTypeTableUrl(ListGridRecord selected) {
+ String url = null;
+ if (selected != null) {
+ int resourceTypeId = selected.getAttributeAsInt(InventorySummaryDataSource.Field.TYPEID);
+ String version = selected.getAttribute(InventorySummaryDataSource.Field.VERSION);
+ if (version == null) {
+ url = "#Reports/Inventory/" + getReportNameForResourceTypeURL() + "/" + resourceTypeId;
+ } else {
+ url = "#Reports/Inventory/" + getReportNameForResourceTypeURL() + "/" + resourceTypeId + "/" + version;
+ }
+ }
+ return url;
+ }
+
+ protected String getReportNameForResourceTypeURL() {
+ return "InventorySummary";
+ }
+
+ protected String getReportNameForDownloadURL() {
+ return "inventorySummary";
+ }
+
+}
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 f6b84b9..ff843f9 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
@@ -22,49 +22,15 @@
*/
package org.rhq.enterprise.gui.coregui.client.report;
-import java.util.HashMap;
-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.Record;
-import com.smartgwt.client.data.fields.DataSourceBooleanField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
-import com.smartgwt.client.data.fields.DataSourceLinkField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.types.ListGridEditEvent;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.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.ResourceCategory;
-import org.rhq.core.domain.resource.composite.ResourceInstallCount;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.IconEnum;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.ExportModalWindow;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.view.HasViewName;
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.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -79,8 +45,6 @@ public class ResourceInstallReport extends LocatableVLayout implements Bookmarka
private ResourceSearchView resourceList;
- private boolean exportAll;
-
public ResourceInstallReport(String locatorId ) {
super(locatorId);
setHeight100();
@@ -108,7 +72,7 @@ public class ResourceInstallReport extends LocatableVLayout implements Bookmarka
@Override
protected void onInit() {
super.onInit();
- addMember(new ResourceInstallReportTable(extendLocatorId("table")));
+ addMember(new InventorySummaryReportTable(extendLocatorId("table")));
}
protected Criteria createResourceSearchViewCriteria(int resourceTypeId) {
@@ -145,229 +109,4 @@ public class ResourceInstallReport extends LocatableVLayout implements Bookmarka
return VIEW_ID;
}
- class ResourceInstallReportTable extends Table<ResourceInstallReportTable.DataSource> {
-
- private ExportChangeHandler exportChangeHandler;
-
- public ResourceInstallReportTable(String locatorId) {
- super(locatorId);
- setDataSource(new DataSource());
- }
-
- @Override
- protected void configureTable() {
- ListGridField fieldTypeName = new ListGridField(DataSource.Field.TYPENAME, MSG.common_title_resource_type());
- ListGridField fieldPlugin = new ListGridField(DataSource.Field.TYPEPLUGIN, MSG.common_title_plugin());
- ListGridField fieldCategory = new ListGridField(DataSource.Field.CATEGORY, MSG.common_title_category());
- ListGridField fieldVersion = new ListGridField(DataSource.Field.VERSION, MSG.common_title_version());
- ListGridField fieldCount = new ListGridField(DataSource.Field.COUNT, MSG.common_title_count());
- ListGridField fieldExport = new ListGridField("exportDetails", "Export Details");
-
- exportChangeHandler = new ExportChangeHandler(getListGrid(), DataSource.Field.TYPEID,
- DataSource.Field.EXPORT);
-
- fieldExport.setCanToggle(true);
- fieldExport.setCanEdit(true);
- fieldExport.addChangedHandler(exportChangeHandler);
-
- fieldTypeName.setWidth("35%");
- fieldPlugin.setWidth("10%");
- fieldCategory.setWidth(70);
- fieldVersion.setWidth("*");
- fieldCount.setWidth(60);
-
- // TODO (ips, 11/11/11): The groupBy functionality is very buggy in SmartGWT 2.4. Once they fix it
- // uncomment these lines to allow grouping by the plugin or category fields.
- /*getListGrid().setCanGroupBy(true);
- fieldTypeName.setCanGroupBy(false);
- fieldVersion.setCanGroupBy(false);
- fieldCount.setCanGroupBy(false); */
-
- fieldTypeName.setCellFormatter(new CellFormatter() {
- @Override
- public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- String url = getResourceTypeTableUrl(record);
- if (url == null) {
- return value.toString();
- }
-
- return "<a href=\"" + url + "\">" + value.toString() + "</a>";
- }
- });
-
- fieldCategory.setType(ListGridFieldType.ICON);
- fieldCategory.setShowValueIconOnly(true);
- HashMap<String, String> categoryIcons = new HashMap<String, String>(3);
- categoryIcons
- .put(ResourceCategory.PLATFORM.name(), ImageManager.getResourceIcon(ResourceCategory.PLATFORM));
- categoryIcons.put(ResourceCategory.SERVER.name(), ImageManager.getResourceIcon(ResourceCategory.SERVER));
- categoryIcons.put(ResourceCategory.SERVICE.name(), ImageManager.getResourceIcon(ResourceCategory.SERVICE));
- fieldCategory.setValueIcons(categoryIcons);
- fieldCategory.setShowHover(true);
- fieldCategory.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- String cat = record.getAttribute(DataSource.Field.CATEGORY);
- if (ResourceCategory.PLATFORM.name().equals(cat)) {
- return MSG.common_title_platform();
- } else if (ResourceCategory.SERVER.name().equals(cat)) {
- return MSG.common_title_server();
- } else if (ResourceCategory.SERVICE.name().equals(cat)) {
- return MSG.common_title_service();
- }
- return "";
- }
- });
-
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid lg = (ListGrid) event.getSource();
- ListGridRecord selected = lg.getSelectedRecord();
- String url = getResourceTypeTableUrl(selected);
- if (url != null) {
- CoreGUI.goToView(url);
- }
- }
- });
-
- setListGridFields(fieldTypeName, fieldPlugin, fieldCategory, fieldVersion, fieldCount, fieldExport);
- getListGrid().setEditEvent(ListGridEditEvent.CLICK);
- getListGrid().setEditByCell(true);
- addExportAction();
- }
-
- private void addExportAction() {
- addTableAction("Export", "Export", new TableAction() {
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return true;
- }
-
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- ExportModalWindow exportModalWindow = ExportModalWindow.createExportWindowForInventorySummary(
- "inventorySummary", exportAll, exportChangeHandler.getResourceTypeIds());
- exportModalWindow.show();
- refreshTableInfo();
- }
- });
- }
-
- @Override
- protected void configureTableFilters() {
- CheckboxItem exportAllDetails = new CheckboxItem("exportAllDetails", "Export All Details");
- exportAllDetails.setLabelAsTitle(true);
-
- setShowFilterForm(true);
- setFilterFormItems(exportAllDetails);
-
- exportAllDetails.addChangedHandler(new ChangedHandler() {
- @Override
- public void onChanged(ChangedEvent event) {
- exportAll = !exportAll;
- ListGrid table = getListGrid();
- int row = 0;
- for (ListGridRecord record : table.getRecords()) {
- record.setAttribute(DataSource.Field.EXPORT, exportAll);
- table.refreshCell(row++, 5);
- }
- }
- });
- }
-
- private String getResourceTypeTableUrl(ListGridRecord selected) {
- String url = null;
- if (selected != null) {
- int resourceTypeId = selected.getAttributeAsInt(DataSource.Field.TYPEID);
- String version = selected.getAttribute(DataSource.Field.VERSION);
- if (version == null) {
- url = "#Reports/Inventory/InventorySummary/" + resourceTypeId;
- } else {
- url = "#Reports/Inventory/InventorySummary/" + resourceTypeId + "/" + version;
- }
- }
- return url;
- }
-
- 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
- public static final String TYPENAME = "typeName"; // String
- public static final String TYPEPLUGIN = "typePlugin"; // String
- public static final String CATEGORY = "category"; // ResourceCategory
- public static final String TYPEID = "typeId"; // int
- public static final String VERSION = "version"; // String
- public static final String OBJECT = "object";
- public static final String EXPORT = "exportDetails";
- }
-
- public DataSource() {
- DataSourceLinkField name = new DataSourceLinkField(Field.TYPENAME);
- DataSourceTextField plugin = new DataSourceTextField(Field.TYPEPLUGIN);
- DataSourceImageField category = new DataSourceImageField(Field.CATEGORY);
- DataSourceTextField version = new DataSourceTextField(Field.VERSION);
- DataSourceIntegerField count = new DataSourceIntegerField(Field.COUNT);
- DataSourceBooleanField export = new DataSourceBooleanField(Field.EXPORT);
-
- setFields(name, plugin, category, version, count, export);
- }
-
- @Override
- public ResourceInstallCount copyValues(Record from) {
- return null;
- }
-
- @Override
- public ListGridRecord copyValues(ResourceInstallCount from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute(Field.COUNT, Long.valueOf(from.getCount()).intValue()); // we'll never have over Integer.MAX_VALUE, overflow not a worry
- record.setAttribute(Field.TYPENAME, from.getTypeName());
- record.setAttribute(Field.TYPEPLUGIN, from.getTypePlugin());
- record.setAttribute(Field.CATEGORY, from.getCategory().name());
- record.setAttribute(Field.TYPEID, from.getTypeId());
- record.setAttribute(Field.VERSION, from.getVersion());
- record.setAttribute(Field.OBJECT, from);
- record.setAttribute(Field.EXPORT, false);
-
- return record;
- }
-
- @Override
- 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>>() {
-
- @Override
- public void onSuccess(List<ResourceInstallCount> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_reports_inventorySummary_failFetch(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected void executeUpdate(Record editedRecord, Record oldRecord, DSRequest request,
- DSResponse response) {
- }
- }
- }
}
12 years, 1 month
[rhq] etc/scripts
by ips
etc/scripts/jboss-as-spawn.sh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
New commits:
commit fdbb5c2d3eaf73e044d97064be42db85718ef03a
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Mar 28 16:45:01 2012 -0400
add an 'rhqadmin' management user to each cloned AS7 config, so the instances can be connected to by RHQ without any
manual intervention; fix a regression
diff --git a/etc/scripts/jboss-as-spawn.sh b/etc/scripts/jboss-as-spawn.sh
index c1fe8ef..4bdbf30 100755
--- a/etc/scripts/jboss-as-spawn.sh
+++ b/etc/scripts/jboss-as-spawn.sh
@@ -10,7 +10,7 @@
#JBOSS_CONFIG=standalone
# the number of instances to start
-#JBOSS_INSTANCES=1
+#JBOSS_INSTANCES=2
# options to pass to the JBoss AS JVM
#JAVA_OPTS="-Xms200M -Xmx400M -XX:MaxPermSize=150M -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true -Djava.net.preferIPv4Stack=true"
@@ -70,17 +70,19 @@ if [ -n "${AS7}" ]; then
echo "AS7 config file not found." >&2
exit 1
fi
+ AS7_ENCODED_PASSWORD=`echo -n "rhqadmin:ManagementRealm:rhqadmin" | md5sum | awk '{printf $1}'`
fi
-for (( i = 1 ; i <= ${INSTANCES}; i++ )); do
+for (( i = 1 ; i <= ${JBOSS_INSTANCES}; i++ )); do
CONFIG_DIR_NAME="${JBOSS_CONFIG}${i}"
CONFIG_DIR="${SERVER_BASE_DIR}/${CONFIG_DIR_NAME}"
if [ ! -d "${CONFIG_DIR}" ]; then
echo "Creating new config dir '${CONFIG_DIR}'..."
- cp -pr "${SERVER_BASE_DIR}/${JBOSS_CONFIG}" "${CONFIG_DIR}"
+ cp -pr "${JBOSS_CONFIG_DIR}" "${CONFIG_DIR}"
( cd "${CONFIG_DIR}" ; rm -rf data log tmp work )
if [ -n "${AS7}" ]; then
sed -in '{s/<inet-address /<loopback-address /}' "${CONFIG_FILE}"
+ echo "rhqadmin=${AS7_ENCODED_PASSWORD}" >"${CONFIG_DIR}/configuration/mgmt-users.properties"
fi
fi
BIND_ADDRESS="127.${OCTET}.0.${i}"
12 years, 1 month
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginDetailView.java | 136 +++++++---
1 file changed, 98 insertions(+), 38 deletions(-)
New commits:
commit 390d77685e376a39ea51a1cba4f3bd392cc3b290
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 28 16:31:18 2012 -0400
[Bug 802780 - Configuration editor in server plugin details is not stretching vertically]
I apologize for making more edits here than were probably necessary. I was
concerned that the async building of the section stack was a problem, which
it may have been, I'm not sure. Anyway, I think it's in decent shape now and
now waits to present the view until it's fully built.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginDetailView.java
index b9e70e4..5e6f717 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/ServerPluginDetailView.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Map;
+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.types.VisibilityMode;
@@ -35,6 +36,7 @@ import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -52,11 +54,9 @@ import org.rhq.enterprise.gui.coregui.client.gwt.PluginGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
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.LocatableHStack;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVStack;
/**
* Shows details of a server plugin.
@@ -68,31 +68,32 @@ public class ServerPluginDetailView extends LocatableVLayout {
private final PluginGWTServiceAsync pluginManager = GWTServiceLookup.getPluginService();
private final int pluginId;
- private int DETAILS_POSITION = 0;
- private int HELP_POSITION = 1;
- private int CONTROLS_POSITION = 2;
- private int PLUGINCONFIG_POSITION = 3;
- private int SCHEDULEDJOBS_POSITION = 4;
+ private final LocatableSectionStack sectionStack;
+ private SectionStackSection detailsSection = null;
+ private SectionStackSection helpSection = null;
+ private SectionStackSection controlsSection = null;
+ private SectionStackSection pluginConfigSection = null;
+ private SectionStackSection scheduledJobsSection = null;
+ private int initSectionCount = 0;
public ServerPluginDetailView(String locatorId, int pluginId) {
super(locatorId);
this.pluginId = pluginId;
setHeight100();
setWidth100();
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
-
- final LocatableSectionStack sectionStack;
+ setOverflow(Overflow.AUTO);
sectionStack = new LocatableSectionStack(extendLocatorId("stack"));
sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
sectionStack.setWidth100();
sectionStack.setHeight100();
sectionStack.setMargin(5);
- sectionStack.setOverflow(Overflow.AUTO);
+ sectionStack.setOverflow(Overflow.VISIBLE);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
pluginManager.getServerPlugin(this.pluginId, true, new AsyncCallback<ServerPlugin>() {
public void onSuccess(ServerPlugin plugin) {
@@ -107,8 +108,52 @@ public class ServerPluginDetailView extends LocatableVLayout {
CoreGUI.getErrorHandler().handleError(MSG.view_admin_plugins_loadFailure(), caught);
}
});
+ }
- addMember(sectionStack);
+ public boolean isInitialized() {
+ return initSectionCount >= 5;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ // wait until we have all of the sections before we show them. We don't use InitializableView because,
+ // it seems they are not supported (in the applicable renderView()) at this level.
+ new Timer() {
+ final long startTime = System.currentTimeMillis();
+
+ public void run() {
+ if (isInitialized()) {
+ if (null != detailsSection) {
+ sectionStack.addSection(detailsSection);
+ }
+ if (null != helpSection) {
+ sectionStack.addSection(helpSection);
+ }
+ if (null != controlsSection) {
+ sectionStack.addSection(controlsSection);
+ }
+ if (null != pluginConfigSection) {
+ sectionStack.addSection(pluginConfigSection);
+ }
+ if (null != scheduledJobsSection) {
+ sectionStack.addSection(scheduledJobsSection);
+ }
+
+ addMember(sectionStack);
+ markForRedraw();
+
+ } else {
+ // don't wait forever, give up after 20s and show what we have
+ long elapsedMillis = System.currentTimeMillis() - startTime;
+ if (elapsedMillis > 20000) {
+ initSectionCount = 5;
+ }
+ schedule(100); // Reschedule the timer.
+ }
+ }
+ }.run(); // fire the timer immediately
}
private void prepareControlsSection(final SectionStack stack, final ServerPlugin plugin) {
@@ -121,8 +166,10 @@ public class ServerPluginDetailView extends LocatableVLayout {
SectionStackSection section = new SectionStackSection(MSG.view_admin_plugins_serverControls());
section.setExpanded(false);
section.addItem(new ServerPluginControlView(extendLocatorId("controlView"), plugin, result));
- stack.addSection(section, CONTROLS_POSITION);
+
+ controlsSection = section;
}
+ ++initSectionCount;
}
public void onFailure(Throwable caught) {
@@ -137,26 +184,23 @@ public class ServerPluginDetailView extends LocatableVLayout {
pluginManager.getServerPluginConfigurationDefinition(pluginKey, new AsyncCallback<ConfigurationDefinition>() {
public void onSuccess(ConfigurationDefinition def) {
if (def != null) {
- LocatableVStack layout = new LocatableVStack(extendLocatorId("pcEditorLayout"));
- layout.setMargin(5);
- layout.setMembersMargin(5);
- layout.setAutoHeight();
+ LocatableVLayout layout = new LocatableVLayout(extendLocatorId("pcEditorLayout"));
- LocatableHStack buttons = new LocatableHStack(extendLocatorId("pcButtonsLayout"));
+ ToolStrip buttons = new ToolStrip();
+ buttons.setWidth100();
+ buttons.setExtraSpace(10);
buttons.setMembersMargin(5);
- buttons.setAutoHeight();
- layout.addMember(buttons);
+ buttons.setLayoutMargin(5);
final IButton saveButtonPC = new LocatableIButton(extendLocatorId("pcSave"), MSG
.common_button_save());
- buttons.addMember(saveButtonPC);
final IButton resetButtonPC = new LocatableIButton(extendLocatorId("pcRest"), MSG
.common_button_reset());
- buttons.addMember(resetButtonPC);
Configuration config = plugin.getPluginConfiguration();
final ConfigurationEditor editorPC = new ConfigurationEditor(extendLocatorId("pcEdit"), def, config);
+ editorPC.setOverflow(Overflow.AUTO);
editorPC.addPropertyValueChangeListener(new PropertyValueChangeListener() {
public void propertyValueChanged(PropertyValueChangeEvent event) {
if (event.isInvalidPropertySetChanged()) {
@@ -169,7 +213,6 @@ public class ServerPluginDetailView extends LocatableVLayout {
}
}
});
- layout.addMember(editorPC);
resetButtonPC.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
@@ -200,11 +243,19 @@ public class ServerPluginDetailView extends LocatableVLayout {
}
});
+ buttons.addMember(saveButtonPC);
+ buttons.addMember(resetButtonPC);
+ layout.addMember(buttons);
+ layout.addMember(editorPC);
+
SectionStackSection section = new SectionStackSection(MSG.view_admin_plugins_serverConfig());
section.setExpanded(false);
section.setItems(layout);
- stack.addSection(section, PLUGINCONFIG_POSITION);
+
+ pluginConfigSection = section;
}
+
+ ++initSectionCount;
}
@Override
@@ -222,14 +273,12 @@ public class ServerPluginDetailView extends LocatableVLayout {
public void onSuccess(ConfigurationDefinition def) {
if (def != null) {
LocatableVLayout layout = new LocatableVLayout(extendLocatorId("sjEditorLayout"));
- layout.setMargin(5);
- layout.setMembersMargin(5);
- layout.setAutoHeight();
- LocatableHStack buttons = new LocatableHStack(extendLocatorId("sjButtonsLayout"));
+ ToolStrip buttons = new ToolStrip();
+ buttons.setWidth100();
+ buttons.setExtraSpace(10);
buttons.setMembersMargin(5);
- buttons.setAutoHeight();
- layout.addMember(buttons);
+ buttons.setLayoutMargin(5);
final IButton saveButtonSJ = new LocatableIButton(extendLocatorId("sjSave"), MSG
.common_button_save());
@@ -241,6 +290,7 @@ public class ServerPluginDetailView extends LocatableVLayout {
Configuration config = plugin.getScheduledJobsConfiguration();
final ConfigurationEditor editorSJ = new ConfigurationEditor(extendLocatorId("sjEdit"), def, config);
+ editorSJ.setOverflow(Overflow.AUTO);
editorSJ.addPropertyValueChangeListener(new PropertyValueChangeListener() {
public void propertyValueChanged(PropertyValueChangeEvent event) {
if (event.isInvalidPropertySetChanged()) {
@@ -253,7 +303,6 @@ public class ServerPluginDetailView extends LocatableVLayout {
}
}
});
- layout.addMember(editorSJ);
resetButtonSJ.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
@@ -284,11 +333,17 @@ public class ServerPluginDetailView extends LocatableVLayout {
}
});
+ layout.addMember(buttons);
+ layout.addMember(editorSJ);
+
SectionStackSection section = new SectionStackSection(MSG.view_admin_plugins_serverScheduleJobs());
section.setExpanded(false);
section.setItems(layout);
- stack.addSection(section, SCHEDULEDJOBS_POSITION);
+
+ scheduledJobsSection = section;
}
+
+ ++initSectionCount;
}
@Override
@@ -305,8 +360,11 @@ public class ServerPluginDetailView extends LocatableVLayout {
section.setExpanded(true);
Label help = new Label(plugin.getHelp());
section.setItems(help);
- stack.addSection(section, HELP_POSITION);
+
+ helpSection = section;
}
+
+ ++initSectionCount;
return;
}
@@ -365,7 +423,9 @@ public class ServerPluginDetailView extends LocatableVLayout {
SectionStackSection section = new SectionStackSection(MSG.common_title_details());
section.setExpanded(true);
section.setItems(form);
- stack.addSection(section, DETAILS_POSITION);
+
+ detailsSection = section;
+ ++initSectionCount;
return;
}
12 years, 1 month
[rhq] 2 commits - modules/enterprise modules/plugins
by Heiko W. Rupp
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java | 6
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java | 212 ++++++++++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java | 48 +-
3 files changed, 248 insertions(+), 18 deletions(-)
New commits:
commit 7aa4e443f237edac35209bb68e0ac289bc2ebb90
Author: Denis Krusko <kruskod(a)gmail.com>
Date: Wed Mar 28 22:15:51 2012 +0200
BZ 796795 Add separator after type label in type tooltip.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
index 54ac526..ff25487 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
@@ -143,8 +143,8 @@ public class OverviewForm extends EnhancedDynamicForm {
// Type
StaticTextItem typeItem = new StaticTextItem("type", MSG.view_summaryOverviewForm_field_type());
- typeItem.setTooltip(MSG.view_summaryOverviewForm_label_plugin() + type.getPlugin() + "\n<br>"
- + MSG.common_title_type() + type.getName());
+ typeItem.setTooltip(MSG.common_title_plugin() + ": " + type.getPlugin() + "\n<br>"
+ + MSG.common_title_type() + ": " + type.getName());
typeItem.setValue(AncestryUtil.getFormattedType(type));
formItems.add(typeItem);
@@ -347,7 +347,7 @@ public class OverviewForm extends EnhancedDynamicForm {
}
public void loadData() {
- // TODO: Reload the ResourceComposite too.
+ // TODO: Reload the ResourceComposite too.
loadTraitValues();
markForRedraw();
}
commit 1513f7dc395ddc7a10c99a955a91c4e8bf6f2798
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 28 21:57:50 2012 +0200
Add test for domain mode and apply fixes to the standalone one.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
new file mode 100644
index 0000000..f222224
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainSocketBindingTest.java
@@ -0,0 +1,212 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 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.itest.domain;
+
+import java.util.Iterator;
+
+import org.jetbrains.annotations.NotNull;
+import org.testng.annotations.Test;
+
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest;
+import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.inventory.InventoryManager;
+import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest;
+import org.rhq.test.arquillian.RunDiscovery;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+/**
+ * Test stuff around socket bindings.
+ * This could actually also run for domain mode
+ * @author Heiko W. Rupp
+ */
+@Test(groups = {"integration", "pc", "domain"}, singleThreaded = true)
+public class DomainSocketBindingTest extends AbstractJBossAS7PluginTest {
+
+ public static final ResourceType RESOURCE_TYPE = new ResourceType("SocketBindingGroup", PLUGIN_NAME, ResourceCategory.SERVICE, null);
+ private static final String RESOURCE_KEY = "socket-binding-group=standard-sockets";
+
+ @Test(priority = 10,groups = "discovery")
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void runDiscovery() throws Exception {
+ Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
+
+ Thread.sleep(10*1000L); // delay so that PC gets a chance to scan for resources
+
+ assertNotNull(platform);
+ assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
+
+ Thread.sleep(20*1000L); // delay so that PC gets a chance to scan for resources
+ }
+
+
+ @Test(priority = 11)
+ public void loadBindings() throws Exception {
+
+ loadConfig();
+ }
+
+ @Test(priority = 11)
+ public void addBinding() throws Exception {
+
+ Configuration configuration = loadConfig();
+ PropertyMap map = new PropertyMap("binding");
+ PropertySimple ps = new PropertySimple("name","bla");
+ map.put(ps);
+ ps = new PropertySimple("port:expr",12345);
+ map.put(ps);
+ ps = new PropertySimple("fixed-port",false);
+ map.put(ps);
+ ps = new PropertySimple("multicast-port:expr","${foo.bar.baz:12346}");
+ map.put(ps);
+ PropertyList pl = (PropertyList) configuration.get("*");
+ int count = pl.getList().size();
+ pl.add(map);
+
+ ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1,configuration,getResource().getId());
+ ConfigurationUpdateResponse response = pluginContainer.getConfigurationManager().executeUpdateResourceConfigurationImmediately(request);
+ assert response!=null;
+ assert response.getErrorMessage()==null: "Config add resulted in this error: " + response.getErrorMessage();
+
+ configuration = loadConfig();
+ pl = (PropertyList) configuration.get("*");
+ assert pl.getList().size() == count+1;
+ }
+
+ @Test(priority = 11)
+ public void addModifyBinding() throws Exception {
+
+ Configuration configuration = loadConfig();
+ PropertyMap map = new PropertyMap("binding");
+ PropertySimple ps = new PropertySimple("name","bla2");
+ map.put(ps);
+ ps = new PropertySimple("port:expr",12355);
+ map.put(ps);
+ ps = new PropertySimple("fixed-port",false);
+ map.put(ps);
+ ps = new PropertySimple("multicast-port:expr","${foo.bar.baz:12356}");
+ map.put(ps);
+ PropertyList pl = (PropertyList) configuration.get("*");
+ pl.add(map);
+
+ ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1,configuration,getResource().getId());
+ ConfigurationUpdateResponse response = pluginContainer.getConfigurationManager().executeUpdateResourceConfigurationImmediately(request);
+ assert response!=null;
+ assert response.getErrorMessage()==null: "Config add resulted in this error: " + response.getErrorMessage();
+
+ configuration = loadConfig();
+ map=null;
+ pl = (PropertyList) configuration.get("*");
+ for (Property prop: pl.getList()) {
+ PropertyMap pm = (PropertyMap) prop;
+ PropertySimple ps2 = pm.getSimple("name");
+ if (!ps2.getStringValue().equals("bla2"))
+ continue;
+
+ map = pm;
+ }
+ assert map != null : "Did not find 'bla2' in the returned config";
+ map.put(new PropertySimple("port:expr",22355));
+ map.put(new PropertySimple("fixed-port",true));
+ request = new ConfigurationUpdateRequest(2,configuration,getResource().getId());
+ response = pluginContainer.getConfigurationManager().executeUpdateResourceConfigurationImmediately(request);
+ assert response!=null;
+ assert response.getErrorMessage()==null: "Config update resulted in this error: " + response.getErrorMessage();
+
+ }
+
+ @Test(priority = 11)
+ public void addRemoveBinding() throws Exception {
+
+ Configuration configuration = loadConfig();
+ PropertyMap map = new PropertyMap("binding");
+ PropertySimple ps = new PropertySimple("name","bla3");
+ map.put(ps);
+ ps = new PropertySimple("port:expr",12365);
+ map.put(ps);
+ ps = new PropertySimple("fixed-port",false);
+ map.put(ps);
+ ps = new PropertySimple("multicast-port:expr","${foo.bar.baz:12366}");
+ map.put(ps);
+ PropertyList pl = (PropertyList) configuration.get("*");
+ int count = pl.getList().size();
+ pl.add(map);
+
+ ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1,configuration,getResource().getId());
+ ConfigurationUpdateResponse response = pluginContainer.getConfigurationManager().executeUpdateResourceConfigurationImmediately(request);
+ assert response!=null;
+ assert response.getErrorMessage()==null: "Config add resulted in this error: " + response.getErrorMessage();
+
+ configuration = loadConfig();
+ pl = (PropertyList) configuration.get("*");
+ assert pl.getList().size() == count+1;
+
+ Iterator<Property> iter = pl.getList().iterator();
+ while (iter.hasNext()) {
+ Property prop = iter.next();
+ PropertyMap pm = (PropertyMap) prop;
+ if (pm.getSimpleValue("name","xxx").equals("bla3")) {
+ iter.remove();
+ break;
+ }
+ }
+ assert pl.getList().size() == count;
+
+ request = new ConfigurationUpdateRequest(3,configuration,getResource().getId());
+ response = pluginContainer.getConfigurationManager().executeUpdateResourceConfigurationImmediately(request);
+ assert response!=null;
+ assert response.getErrorMessage()==null: "Property removal resulted in this error: " + response.getErrorMessage();
+ }
+
+
+
+
+ @NotNull
+ private Configuration loadConfig() throws PluginContainerException {
+ Configuration config = pluginContainer.getConfigurationManager().loadResourceConfiguration(getResource().getId());
+ assert config != null;
+ assert !config.getProperties().isEmpty();
+ return config;
+ }
+
+ private Resource getResource() {
+
+ InventoryManager im = pluginContainer.getInventoryManager();
+ Resource platform = im.getPlatform();
+ assert platform != null : "Did not find a platform";
+ Resource server = getResourceByTypeAndKey(platform,DomainServerComponentTest.RESOURCE_TYPE,DomainServerComponentTest.RESOURCE_KEY);
+ assert server != null : "Did not find the domain server";
+ Resource bindings = getResourceByTypeAndKey(server,RESOURCE_TYPE,RESOURCE_KEY);
+ assert bindings != null : "Did not find " + RESOURCE_KEY;
+ return bindings;
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
index 6b90fd8..8cd26d6 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/SocketBindingTest.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
@@ -40,6 +41,9 @@ import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest;
import org.rhq.test.arquillian.RunDiscovery;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
/**
* Test stuff around socket bindings.
* This could actually also run for domain mode
@@ -51,20 +55,27 @@ public class SocketBindingTest extends AbstractJBossAS7PluginTest {
public static final ResourceType RESOURCE_TYPE = new ResourceType("SocketBindingGroup", PLUGIN_NAME, ResourceCategory.SERVICE, null);
private static final String RESOURCE_KEY = "socket-binding-group=standard-sockets";
- @BeforeClass
- @RunDiscovery(discoverServices = true)
- public void doSomeDiscovery() throws Exception {
+ @Test(priority = 10,groups = "discovery")
+ @RunDiscovery(discoverServices = true, discoverServers = true) public void doSomeDiscovery() throws Exception {
+ Resource platform = this.pluginContainer.getInventoryManager().getPlatform();
+ assertNotNull(platform);
+ assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
+
+ Thread.sleep(20*1000L); // delay so that PC gets a chance to scan for resources
+
}
+ @Test(priority = 11)
public void loadBindings() throws Exception {
loadConfig();
}
+ @Test(priority = 11)
public void addBinding() throws Exception {
Configuration configuration = loadConfig();
- PropertyMap map = new PropertyMap("socket-binding=bla");
+ PropertyMap map = new PropertyMap("binding");
PropertySimple ps = new PropertySimple("name","bla");
map.put(ps);
ps = new PropertySimple("port",12345);
@@ -87,17 +98,18 @@ public class SocketBindingTest extends AbstractJBossAS7PluginTest {
assert pl.getList().size() == count+1;
}
+ @Test(priority = 11)
public void addModifyBinding() throws Exception {
Configuration configuration = loadConfig();
- PropertyMap map = new PropertyMap("bla2");
+ PropertyMap map = new PropertyMap("binding");
PropertySimple ps = new PropertySimple("name","bla2");
map.put(ps);
- ps = new PropertySimple("port",12355);
+ ps = new PropertySimple("port:expr",12355);
map.put(ps);
ps = new PropertySimple("fixed-port",false);
map.put(ps);
- ps = new PropertySimple("multicast-port","${foo.bar.baz:12356}");
+ ps = new PropertySimple("multicast-port:expr","${foo.bar.baz:12356}");
map.put(ps);
PropertyList pl = (PropertyList) configuration.get("*");
pl.add(map);
@@ -110,14 +122,16 @@ public class SocketBindingTest extends AbstractJBossAS7PluginTest {
configuration = loadConfig();
map=null;
pl = (PropertyList) configuration.get("*");
- for (Property prop: pl.getList()) {
- if (!prop.getName().equals("bla2"))
+ for (Property prop : pl.getList()) {
+ PropertyMap pm = (PropertyMap) prop;
+ PropertySimple ps2 = pm.getSimple("name");
+ if (!ps2.getStringValue().equals("bla2"))
continue;
- map = (PropertyMap) prop;
+ map = pm;
}
assert map != null : "Did not find 'bla2' in the returned config";
- map.put(new PropertySimple("port",22355));
+ map.put(new PropertySimple("port:expr",22355));
map.put(new PropertySimple("fixed-port",true));
request = new ConfigurationUpdateRequest(2,configuration,getResource().getId());
response = pluginContainer.getConfigurationManager().executeUpdateResourceConfigurationImmediately(request);
@@ -126,17 +140,18 @@ public class SocketBindingTest extends AbstractJBossAS7PluginTest {
}
+ @Test(priority = 11)
public void addRemoveBinding() throws Exception {
Configuration configuration = loadConfig();
- PropertyMap map = new PropertyMap("bla3");
+ PropertyMap map = new PropertyMap("binding");
PropertySimple ps = new PropertySimple("name","bla3");
map.put(ps);
- ps = new PropertySimple("port",12365);
+ ps = new PropertySimple("port:expr",12365);
map.put(ps);
ps = new PropertySimple("fixed-port",false);
map.put(ps);
- ps = new PropertySimple("multicast-port","${foo.bar.baz:12366}");
+ ps = new PropertySimple("multicast-port:expr","${foo.bar.baz:12366}");
map.put(ps);
PropertyList pl = (PropertyList) configuration.get("*");
int count = pl.getList().size();
@@ -154,11 +169,13 @@ public class SocketBindingTest extends AbstractJBossAS7PluginTest {
Iterator<Property> iter = pl.getList().iterator();
while (iter.hasNext()) {
Property prop = iter.next();
- if (prop.getName().equals("bla3")) {
+ PropertyMap pm = (PropertyMap) prop;
+ if (pm.getSimpleValue("name","xxx").equals("bla3")) {
iter.remove();
break;
}
}
+ assert pl.getList().size() == count;
request = new ConfigurationUpdateRequest(3,configuration,getResource().getId());
response = pluginContainer.getConfigurationManager().executeUpdateResourceConfigurationImmediately(request);
@@ -167,6 +184,7 @@ public class SocketBindingTest extends AbstractJBossAS7PluginTest {
}
/** THIS ONE WILL NOT WORK IN DOMAIN MODE */
+ @Test(priority = 11)
public void changePortOffset() throws Exception {
Configuration configuration = loadConfig();
12 years, 1 month
[rhq] Changes to 'Branch_docs-example-script'
by Ella Lackey
New branch 'Branch_docs-example-script' available with the following commits:
commit df523a65572995a60976a1149b00e8b5f33a6e9d
Author: elladeon <deon(a)deonlackey.com>
Date: Wed Mar 28 11:45:47 2012 -0500
adding example group control wrapper and scripts, based on the doc example
12 years, 1 month