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) {
- }
- }
- }
}