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;
+ }
+
+}