modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationLastCompletedComposite.java
| 64 +--
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java
| 57 +-
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
| 58 +-
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
| 58 +-
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
| 35 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
| 21 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
| 122 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
| 97 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
| 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
| 208 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
| 175 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
| 183 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/disambiguation/ReportDecorator.java
| 97 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
| 87 +++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
| 50 ++
18 files changed, 1195 insertions(+), 147 deletions(-)
New commits:
commit 4472eb027f3bc43d08b8e061f4091dacf5c9711d
Merge: 98280b9... dd2948a...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Aug 26 12:08:55 2010 -0400
Operations and Problem Resources portlets. Needed to add default constructors of a few
base classes for gwt serialization
diff --cc
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index 76babb0,83af987..d9cefe5
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@@ -289,15 -291,16 +291,17 @@@ public class DashboardsView extends Loc
public void renderView(ViewPath viewPath) {
if (!viewPath.isEnd()) {
selectedTab = viewPath.getCurrent().getPath();
- System.out.println("#################:" + selectedTab +
":tabset:" + tabSet);
- // if (tabSet != null) {
- for (Tab tab : tabSet.getTabs()) {
- // if (selectedTab.equals(tab.getTitle())) {
- if (tab.getTitle().equals(selectedTab)) {
- tabSet.selectTab(tab);
++
+ //added to avoid NPE in gwt debug window.
+ if (tabSet != null) {
+ for (Tab tab : tabSet.getTabs()) {
+ if (tab.getTitle().equals(selectedTab)) {
+ tabSet.selectTab(tab);
+ }
}
+ } else {
+ System.out.println("WARN: While rendering DashboardsView tabSet is
null.");
}
- // }
}
}
diff --cc
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
index 0000000,502189a..438f870
mode 000000,100644..100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@@ -1,0 -1,112 +1,122 @@@
+ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+ /*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+ import com.google.gwt.core.client.GWT;
+ import com.smartgwt.client.widgets.Canvas;
+ import com.smartgwt.client.widgets.HTMLFlow;
+ import com.smartgwt.client.widgets.form.DynamicForm;
+ import com.smartgwt.client.widgets.grid.HeaderSpan;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.layout.VLayout;
+
+ import org.rhq.core.domain.dashboard.DashboardPortlet;
+ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+ import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
+ import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
++import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
++import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+ /**
+ * A view that displays a live table of completed Operations and scheduled operations.
+ *
+ * @author Simeon Pinder
+ */
-public class OperationsPortlet extends VLayout implements Portlet {
++public class OperationsPortlet extends LocatableVLayout implements Portlet {
+
+ public static final String KEY = "Operations";
+ private static final String TITLE = KEY;
+ private static String recentOperations = "Recent Operations";
+ private static String scheduledOperations = "Scheduled Operations";
+
- public OperationsPortlet() {
++ //no args for serialization
++ private OperationsPortlet() {
++ }
++
++ public OperationsPortlet(String locatorId) {
++ super(locatorId);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ //set title for larger container
+ setTitle(TITLE);
+
+ // Add the list table as the top half of the view.
- ListGrid recentOperationsGrid = new ListGrid();
++ LocatableListGrid recentOperationsGrid = new
LocatableListGrid(recentOperations);
+ recentOperationsGrid.setDataSource(new RecentOperationsDataSource());
+ recentOperationsGrid.setAutoFetchData(true);
+ String[] allRows = new String[] { RecentOperationsDataSource.location,
RecentOperationsDataSource.operation,
+ RecentOperationsDataSource.resource, RecentOperationsDataSource.status,
RecentOperationsDataSource.time };
+ recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, allRows));
+ recentOperationsGrid.setHeaderSpanHeight(new Integer(20));
+ recentOperationsGrid.setHeaderHeight(40);
+ recentOperationsGrid.setResizeFieldsInRealTime(true);
+ addMember(recentOperationsGrid);
+
+ // Add the list table as the top half of the view.
- ListGrid scheduledOperationsGrid = new ListGrid();
++ LocatableListGrid scheduledOperationsGrid = new
LocatableListGrid(scheduledOperations);
+ scheduledOperationsGrid.setDataSource(new ScheduledOperationsDataSource());
+ scheduledOperationsGrid.setAutoFetchData(true);
+ String[] allRows2 = new String[] { ScheduledOperationsDataSource.location,
+ ScheduledOperationsDataSource.operation,
ScheduledOperationsDataSource.resource,
+ ScheduledOperationsDataSource.time };
+ scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations,
allRows2));
+ scheduledOperationsGrid.setHeaderSpanHeight(new Integer(20));
+ scheduledOperationsGrid.setHeaderHeight(40);
+
+ scheduledOperationsGrid.setTitle(scheduledOperations);
+ scheduledOperationsGrid.setResizeFieldsInRealTime(true);
+
+ addMember(scheduledOperationsGrid);
+
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet)
{
+ // TODO implement this.
+
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays both operations that have
occurred and are scheduled to occur.");
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance() {
+ return GWT.create(OperationsPortlet.class);
+ }
++
++ public final Portlet getInstance(String locatorId) {
++ return new OperationsPortlet(locatorId);
++ }
++
+ }
+
+ }
diff --cc
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
index 0000000,ca5ce12..b2c9524
mode 000000,100644..100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@@ -1,0 -1,88 +1,97 @@@
+ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems;
+
+ /*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+ import com.google.gwt.core.client.GWT;
+ import com.smartgwt.client.types.Autofit;
+ import com.smartgwt.client.widgets.Canvas;
+ import com.smartgwt.client.widgets.HTMLFlow;
+ import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.layout.VLayout;
+
+ import org.rhq.core.domain.dashboard.DashboardPortlet;
+ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+ import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
++import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
++import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+ /**
+ * A view that displays a paginated table of Resoruces with alerts,
+ * and/or Resources reported unavailable.
+ *
+ * @author Simeon Pinder
+ */
-public class ProblemResourcesPortlet extends VLayout implements Portlet {
++public class ProblemResourcesPortlet extends LocatableVLayout implements Portlet {
+
+ public static final String KEY = "Has Alerts or Currently Unavailable";
+ private static final String TITLE = KEY;
+
- public ProblemResourcesPortlet() {
++ //no args constructor for serialization
++ private ProblemResourcesPortlet() {
++ }
++
++ public ProblemResourcesPortlet(String locatorId) {
++ super(locatorId);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // Add the list table as the top half of the view.
- ListGrid listGrid = new ListGrid();
++ LocatableListGrid listGrid = new LocatableListGrid("Problem
Resources");
+ listGrid.setDataSource(new ProblemResourcesDataSource());
+ listGrid.setAutoFetchData(true);
+ listGrid.setTitle(TITLE);
+ listGrid.setResizeFieldsInRealTime(true);
+ listGrid.setCellHeight(40);
+ listGrid.setAutoFitData(Autofit.BOTH);
+ addMember(listGrid);
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet)
{
+ // TODO implement this.
+
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays resources that have reported
alerts or Down availability.");
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance() {
+ return GWT.create(ProblemResourcesPortlet.class);
+ }
++
++ public Portlet getInstance(String locatorId) {
++ return new ProblemResourcesPortlet(locatorId);
++ }
+ }
+
+ }
diff --cc
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index 0000000,7995f46..b48b4c3
mode 000000,100644..100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@@ -1,0 -1,177 +1,208 @@@
+ package org.rhq.enterprise.gui.coregui.client.operation;
+
+ /*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+ import java.util.Date;
+ 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.DataSource;
+ import com.smartgwt.client.data.Record;
+ import com.smartgwt.client.data.fields.DataSourceDateTimeField;
+ import com.smartgwt.client.data.fields.DataSourceTextField;
+ import com.smartgwt.client.types.DSDataFormat;
+ import com.smartgwt.client.types.DSProtocol;
+ import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+ import org.rhq.core.domain.criteria.ResourceCriteria;
+ import org.rhq.core.domain.operation.OperationRequestStatus;
+ import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+ import org.rhq.core.domain.resource.composite.DisambiguationReport;
+ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+ import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
++import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+ /** Responsible for defining and populating the Smart GWT datasource details and
+ * translating the deserialized content into specific record entries for display
+ *
- * @author spinder
++ * @author Simeon Pinder
+ */
-public class RecentOperationsDataSource extends DataSource {
++public class RecentOperationsDataSource extends
++
RPCDataSource<DisambiguationReport<ResourceOperationLastCompletedComposite>>
{
+ public static final String resource = "resource";
+ public static final String location = "location";
+ public static final String operation = "operation";
+ public static final String time = "time";
+ public static final String status = "status";
+
+ /** Build list of fields for the datasource and then adds them to it.
+ */
+ public RecentOperationsDataSource() {
+ setClientOnly(false);
+ setDataProtocol(DSProtocol.CLIENTCUSTOM);
+ setDataFormat(DSDataFormat.CUSTOM);
+
+ DataSourceTextField resourceField = new DataSourceTextField(resource,
"Resource");
+ resourceField.setPrimaryKey(true);
+
+ DataSourceTextField locationField = new DataSourceTextField(location,
"Location", 200);
+
+ DataSourceTextField operationField = new DataSourceTextField(operation,
"Operation");
+
+ DataSourceDateTimeField timeField = new DataSourceDateTimeField(time,
"Date/Time");
+
+ // DataSourceImageField statusField = new DataSourceImageField(status,
"Status");
+ DataSourceTextField statusField = new DataSourceTextField(status,
"Status");
+
+ setFields(resourceField, locationField, operationField, timeField,
statusField);
+ }
+
+ /* Intercept DSRequest object to pipe into custom fetch request.
+ * (non-Javadoc)
+ * @see
com.smartgwt.client.data.DataSource#transformRequest(com.smartgwt.client.data.DSRequest)
+ */
+ protected Object transformRequest(DSRequest request) {
+ DSResponse response = new DSResponse();
+ response.setAttribute("clientContext",
request.getAttributeAsObject("clientContext"));
+ // Assume success
+ response.setStatus(0);
+ switch (request.getOperationType()) {
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
+ }
+
+ return request.getData();
+ }
+
+ /** Fetch the ProblemResource data, and populate the response object appropriately.
+ *
+ * @param request incoming request
+ * @param response outgoing response
+ */
+ public void executeFetch(final DSRequest request, final DSResponse response) {
+
+ ResourceCriteria c = new ResourceCriteria();
+ GWTServiceLookup.getOperationService().findRecentCompletedOperations(c,
+ new
AsyncCallback<List<DisambiguationReport<ResourceOperationLastCompletedComposite>>>()
{
+
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load recently
completed operations.", throwable);
+ }
+
+ public void onSuccess(
+
List<DisambiguationReport<ResourceOperationLastCompletedComposite>>
recentOperationsList) {
+
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(recentOperationsList));
+ //entry count
+ if (null != recentOperationsList) {
+ response.setTotalRows(recentOperationsList.size());
+ } else {
+ response.setTotalRows(0);
+ }
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ /** Translates the DisambiguationReport of ResourceOperationLastCompletedComposites
into specific
+ * and ordered record values.
+ *
+ * @param list DisambiguationReport of entries.
+ * @return Record[] ordered record entries.
+ */
+ protected Record[]
buildList(List<DisambiguationReport<ResourceOperationLastCompletedComposite>>
list) {
+
+ ListGridRecord[] dataValues = null;
+ if (list != null) {
+ dataValues = new ListGridRecord[list.size()];
+ int indx = 0;
+
+ for (DisambiguationReport<ResourceOperationLastCompletedComposite>
report : list) {
+ ListGridRecord record = new ListGridRecord();
+ //disambiguated Resource name, decorated with html anchors to problem
resources
+ record.setAttribute(resource,
ReportDecorator.decorateResourceName(ReportDecorator.GWT_RESOURCE_URL,
+ report.getResourceType(), report.getOriginal().getResourceName(),
report.getOriginal()
+ .getResourceId()));
+ //disambiguated resource lineage, decorated with html anchors
+ record.setAttribute(location,
ReportDecorator.decorateResourceLineage(report.getParents()));
+ //operation name.
+ record.setAttribute(operation,
report.getOriginal().getOperationName());
+ //timestamp.
+ record.setAttribute(time, new
Date(report.getOriginal().getOperationStartTime()));
- //populate status icon .
/rhq/resource/operation/resourceOperationHistoryDetails-plain.xhtml?id=10001&opId=10001
- // String link = "<a href='" +
ReportDecorator.GWT_RECENT_OPERATION_URL
- String link = "<a href='" +
"/rhq/resource/operation/resourceOperationHistoryDetails-plain.xhtml?id="
- + report.getOriginal().getResourceId() + "&opId=" +
report.getOriginal().getResourceId() + "'>";
- String img = "<img alt='" +
report.getOriginal().getOperationStatus() + "' title='"
- + report.getOriginal().getOperationStatus() + "'
src='/images/icons/";
- if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.SUCCESS) == 0)
{
- img += "availability_green_16.png'";
- } else if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.FAILURE) == 0)
{
- img += "availability_red_16.png";
- } else if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.CANCELED) ==
0) {
- img += "availability_yellow_16.png";
- } else {
- img += "availability_grey_16.png";
- }
- link = link + img + "'></img></a>";
++ String link = generateResourceOperationStatusLink(report);
+ record.setAttribute(status, link);
+
+ dataValues[indx++] = record;
+ }
+ }
+ return dataValues;
+ }
++
++ /** Generates the ResourceOperationHistory status link from DisambiguationReport
passed in.
++ *
++ * @param report
++ * @return html string for display in table.
++ */
++ private String generateResourceOperationStatusLink(
++ DisambiguationReport<ResourceOperationLastCompletedComposite> report) {
++ //TODO: refactor this out for more general case
++ String link = "<a href='" +
"/rhq/resource/operation/resourceOperationHistoryDetails-plain.xhtml?id="
++ + report.getOriginal().getResourceId() + "&opId=" +
report.getOriginal().getResourceId() + "'>";
++ String img = "<img alt='" +
report.getOriginal().getOperationStatus() + "' title='"
++ + report.getOriginal().getOperationStatus() + "'
src='/images/icons/";
++ if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.SUCCESS) == 0)
{
++ img += "availability_green_16.png'";
++ } else if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.FAILURE) == 0)
{
++ img += "availability_red_16.png";
++ } else if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.CANCELED) ==
0) {
++ img += "availability_yellow_16.png";
++ } else {
++ img += "availability_grey_16.png";
++ }
++ link = link + img + "'></img></a>";
++ return link;
++ }
++
++ @Override
++ public DisambiguationReport<ResourceOperationLastCompletedComposite>
copyValues(ListGridRecord from) {
++ throw new UnsupportedOperationException("ResourceOperations data is read
only");
++ }
++
++ @Override
++ public ListGridRecord
copyValues(DisambiguationReport<ResourceOperationLastCompletedComposite> from) {
++ ListGridRecord record = new ListGridRecord();
++ record.setAttribute(resource,
ReportDecorator.decorateResourceName(ReportDecorator.GWT_RESOURCE_URL, from
++ .getResourceType(), from.getOriginal().getResourceName(),
from.getOriginal().getResourceId()));
++ record.setAttribute(location,
ReportDecorator.decorateResourceLineage(from.getParents()));
++ record.setAttribute(operation, from.getOriginal().getOperationName());
++ record.setAttribute(time, from.getOriginal().getOperationStartTime());
++ record.setAttribute(status, generateResourceOperationStatusLink(from));
++
++ record.setAttribute("entity", from);
++
++ return record;
++ }
+ }
diff --cc
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index 0000000,a1fa3f4..22ec638
mode 000000,100644..100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@@ -1,0 -1,154 +1,175 @@@
+ package org.rhq.enterprise.gui.coregui.client.operation;
+
+ /*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+ import java.util.Date;
+ 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.DataSource;
+ import com.smartgwt.client.data.Record;
+ import com.smartgwt.client.data.fields.DataSourceTextField;
+ import com.smartgwt.client.types.DSDataFormat;
+ import com.smartgwt.client.types.DSProtocol;
+ import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+ import org.rhq.core.domain.criteria.ResourceCriteria;
+ import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite;
+ import org.rhq.core.domain.resource.composite.DisambiguationReport;
+ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+ import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
++import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+ /** Responsible for defining and populating the Smart GWT datasource details and
+ * translating the deserialized content into specific record entries for display
+ *
- * @author spinder
++ * @author Simeon Pinder
+ */
-public class ScheduledOperationsDataSource extends DataSource {
++public class ScheduledOperationsDataSource extends
++ RPCDataSource<DisambiguationReport<ResourceOperationScheduleComposite>>
{
+ public static final String resource = "resource";
+ public static final String location = "location";
+ public static final String operation = "operation";
+ public static final String time = "time";
+
+ /** Build list of fields for the datasource and then adds them to it.
+ */
+ public ScheduledOperationsDataSource() {
+ setClientOnly(false);
+ setDataProtocol(DSProtocol.CLIENTCUSTOM);
+ setDataFormat(DSDataFormat.CUSTOM);
+
+ DataSourceTextField resourceField = new DataSourceTextField(resource,
"Resource");
+ resourceField.setPrimaryKey(true);
+
+ DataSourceTextField locationField = new DataSourceTextField(location,
"Location");
+
+ DataSourceTextField operationField = new DataSourceTextField(operation,
"Operation");
+
+ DataSourceTextField timeField = new DataSourceTextField(operation,
"Date/Time");
+
+ setFields(resourceField, locationField, operationField, timeField);
+ }
+
+ /* Intercept DSRequest object to pipe into custom fetch request.
+ * (non-Javadoc)
+ * @see
com.smartgwt.client.data.DataSource#transformRequest(com.smartgwt.client.data.DSRequest)
+ */
+ protected Object transformRequest(DSRequest request) {
+ DSResponse response = new DSResponse();
+ response.setAttribute("clientContext",
request.getAttributeAsObject("clientContext"));
+ // Assume success
+ response.setStatus(0);
+ switch (request.getOperationType()) {
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
+ }
+
+ return request.getData();
+ }
+
+ /** Fetch the ProblemResource data, and populate the response object appropriately.
+ *
+ * @param request incoming request
+ * @param response outgoing response
+ */
+ public void executeFetch(final DSRequest request, final DSResponse response) {
+
+ ResourceCriteria c = new ResourceCriteria();
+ GWTServiceLookup.getOperationService().findScheduledOperations(c,
+ new
AsyncCallback<List<DisambiguationReport<ResourceOperationScheduleComposite>>>()
{
+
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load scheduled
operations.", throwable);
+ }
+
+ public void
onSuccess(List<DisambiguationReport<ResourceOperationScheduleComposite>>
scheduledOpsList) {
+
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(scheduledOpsList));
+ //entry count
+ if (null != scheduledOpsList) {
+ response.setTotalRows(scheduledOpsList.size());
+ } else {
+ response.setTotalRows(0);
+ }
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ /** Translates the DisambiguationReport of ProblemResourceComposites into specific
+ * and ordered record values.
+ *
+ * @param list DisambiguationReport of entries.
+ * @return Record[] ordered record entries.
+ */
+ protected Record[]
buildList(List<DisambiguationReport<ResourceOperationScheduleComposite>> list)
{
+
+ ListGridRecord[] dataValues = null;
+ if (list != null) {
+ dataValues = new ListGridRecord[list.size()];
+ int indx = 0;
+
+ for (DisambiguationReport<ResourceOperationScheduleComposite> report :
list) {
+ ListGridRecord record = new ListGridRecord();
+
+ //disambiguated Resource name, decorated with html anchors to problem
resources
+ record.setAttribute(resource,
ReportDecorator.decorateResourceName(ReportDecorator.GWT_RESOURCE_URL,
+ report.getResourceType(), report.getOriginal().getResourceName(),
report.getOriginal()
+ .getResourceId()));
+ //disambiguated resource lineage, decorated with html anchors
+ record.setAttribute(location,
ReportDecorator.decorateResourceLineage(report.getParents()));
+ //operation name.
+ record.setAttribute(operation,
report.getOriginal().getOperationName());
+ //timestamp.
+ record.setAttribute(time, new
Date(report.getOriginal().getOperationNextFireTime()));
+
+ dataValues[indx++] = record;
+ }
+ }
+ return dataValues;
+ }
++
++ @Override
++ public DisambiguationReport<ResourceOperationScheduleComposite>
copyValues(ListGridRecord from) {
++ throw new UnsupportedOperationException("ResourceOperations data is read
only");
++ }
++
++ @Override
++ public ListGridRecord
copyValues(DisambiguationReport<ResourceOperationScheduleComposite> from) {
++ ListGridRecord record = new ListGridRecord();
++ record.setAttribute(resource,
ReportDecorator.decorateResourceName(ReportDecorator.GWT_RESOURCE_URL, from
++ .getResourceType(), from.getOriginal().getResourceName(),
from.getOriginal().getResourceId()));
++ record.setAttribute(location,
ReportDecorator.decorateResourceLineage(from.getParents()));
++ record.setAttribute(operation, from.getOriginal().getOperationName());
++ record.setAttribute(time, from.getOriginal().getOperationNextFireTime());
++
++ record.setAttribute("entity", from);
++
++ return record;
++
++ }
+ }
diff --cc
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 1d5c079,387314a..5f2b5ee
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@@ -1,13 -1,31 +1,31 @@@
package org.rhq.enterprise.gui.coregui.client.resource;
- import java.util.ArrayList;
+ /*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
++
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.DataSource;
import com.smartgwt.client.data.Record;
+ import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
@@@ -18,12 -37,18 +37,19 @@@ import
org.rhq.core.domain.resource.com
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-
- public class ProblemResourcesDataSource extends DataSource {
- public final String resource = "resource";
- public final String location = "location";
- public final String alerts = "alerts";
- public final String available = "available";
+ import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
++import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+ /** Responsible for defining and populating the Smart GWT datasource details and
+ * translating the deserialized content into specific record entries for display
+ *
- * @author spinder
++ * @author Simeon Pinder
+ */
-public class ProblemResourcesDataSource extends DataSource {
++public class ProblemResourcesDataSource extends
RPCDataSource<DisambiguationReport<ProblemResourceComposite>> {
+ public static final String resource = "resource";
+ public static final String location = "location";
+ public static final String alerts = "alerts";
+ public static final String available = "available";
/** Build list of fields for the datasource and then adds them to it.
*/
@@@ -72,30 -97,25 +98,26 @@@
public void executeFetch(final DSRequest request, final DSResponse response) {
ResourceCriteria c = new ResourceCriteria();
- c.addFilterCurrentAvailability(AvailabilityType.DOWN);
+
- // GWTServiceLookup.getResourceService().findRecentlyAddedResources(0,
100,
GWTServiceLookup.getResourceService().findProblemResources(c,
- // new
AsyncCallback<List<RecentlyAddedResourceComposite>>() {
- new AsyncCallback<List<ProblemResourceComposite>>() {
+ new
AsyncCallback<List<DisambiguationReport<ProblemResourceComposite>>>() {
+
public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to load
unavailable resources", throwable);
+ CoreGUI.getErrorHandler().handleError("Failed to load resources
with alerts/unavailability.",
+ throwable);
}
- // public void
onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) {
- public void onSuccess(List<ProblemResourceComposite>
problemResourcesList) {
- // List<RecentlyAddedResourceComposite>
list = new ArrayList<RecentlyAddedResourceComposite>();
- List<ProblemResourceComposite> list = new
ArrayList<ProblemResourceComposite>();
+ public void
onSuccess(List<DisambiguationReport<ProblemResourceComposite>>
problemResourcesList) {
- // for (RecentlyAddedResourceComposite
recentlyAdded : problemResourcesList) {
- for (ProblemResourceComposite problemResource :
problemResourcesList) {
- list.add(problemResource);
- //
list.addAll(problemResource.getChildren());
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(problemResourcesList));
+ //entry count
+ if (null != problemResourcesList) {
+ response.setTotalRows(problemResourcesList.size());
+ } else {
+ response.setTotalRows(0);
}
-
- // response.setData(buildNodes(list));
- response.setData(buildList(list));
- response.setTotalRows(list.size());
+ //pass off for processing
processResponse(request.getRequestId(), response);
}
});
@@@ -141,5 -156,4 +158,26 @@@
}
return dataValues;
}
+
++ @Override
++ public ListGridRecord
copyValues(DisambiguationReport<ProblemResourceComposite> from) {
++ ListGridRecord record = new ListGridRecord();
++ record.setAttribute(resource,
ReportDecorator.decorateResourceName(ReportDecorator.GWT_RESOURCE_URL, from
++ .getResourceType(), from.getOriginal().getResourceName(),
from.getOriginal().getResourceId()));
++ record.setAttribute(location,
ReportDecorator.decorateResourceLineage(from.getParents()));
++ record.setAttribute(alerts, from.getOriginal().getNumAlerts());
++ if (from.getOriginal().getAvailabilityType().compareTo(AvailabilityType.DOWN) ==
0) {
++ record.setAttribute(available,
"/images/icons/availability_red_16.png");
++ } else {
++ record.setAttribute(available,
"/images/icons/availability_green_16.png");
++ }
++
++ record.setAttribute("entity", from);
++ return record;
++ }
++
++ @Override
++ public DisambiguationReport<ProblemResourceComposite>
copyValues(ListGridRecord from) {
++ throw new UnsupportedOperationException("ProblemResource data is read
only");
++ }
}
commit 98280b9a2d8be10061d9a0f00c70c8b9f745f4bf
Merge: 94f59f5... 2817b52...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Aug 26 08:41:06 2010 -0400
Merge branch 'master' of ssh://spinder@git.fedorahosted.org/git/rhq/rhq
commit dd2948a07d2b5674159eb6bfc42dff009a4cac85
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Aug 26 08:36:35 2010 -0400
added OpererationsPortlet and modified composites for serialization.
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationLastCompletedComposite.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationLastCompletedComposite.java
index f6fb61e..4722f6a 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationLastCompletedComposite.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationLastCompletedComposite.java
@@ -1,40 +1,48 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.core.domain.operation.composite;
+import java.io.Serializable;
+
import org.rhq.core.domain.operation.OperationHistory;
import org.rhq.core.domain.operation.OperationRequestStatus;
-import java.io.Serializable;
-
public abstract class OperationLastCompletedComposite implements Serializable {
private static final long serialVersionUID = 1L;
- private final int operationHistoryId;
- private final String operationName;
- private final long operationStartTime;
- private final OperationRequestStatus operationStatus;
+ private int operationHistoryId;
+ private String operationName;
+ private long operationStartTime;
+ private OperationRequestStatus operationStatus;
+
+ //default no args constructor for java bean/serialization. Not to be used.
+ protected OperationLastCompletedComposite() {
+ this.operationHistoryId = 0;
+ this.operationName = "(unitialized)";
+ this.operationStartTime = -1;
+ this.operationStatus = OperationRequestStatus.FAILURE;
+ }
public OperationLastCompletedComposite(int operationHistoryId, String operationName,
long operationStartTime,
OperationRequestStatus operationStatus) {
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java
index 708ed11..dc99113 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java
@@ -1,29 +1,29 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.core.domain.operation.composite;
-import java.util.Date;
import java.io.Serializable;
+import java.util.Date;
import org.rhq.core.domain.operation.ScheduleJobId;
@@ -31,9 +31,16 @@ public abstract class OperationScheduleComposite implements
Serializable {
private static final long serialVersionUID = 1L;
- private final ScheduleJobId operationJobId;
+ private ScheduleJobId operationJobId;
private String operationName;
- private final long operationNextFireTime;
+ private long operationNextFireTime;
+
+ //no args constructor for serialization purposes not to be used.
+ protected OperationScheduleComposite() {
+ this.operationNextFireTime = -1;
+ this.operationJobId = null;
+ this.operationName = "(uninitialized)";
+ }
public OperationScheduleComposite(ScheduleJobId operationJobId, String operationName,
long operationNextFireTime) {
this.operationJobId = operationJobId;
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
index 95d13cf..5add81b 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationLastCompletedComposite.java
@@ -1,33 +1,41 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.core.domain.operation.composite;
import org.rhq.core.domain.operation.OperationRequestStatus;
public class ResourceOperationLastCompletedComposite extends
OperationLastCompletedComposite {
- private final int resourceId;
- private final String resourceName;
- private final String resourceTypeName;
+ private int resourceId;
+ private String resourceName;
+ private String resourceTypeName;
+
+ //no args constructor. Not to be used. java bean/serialization requirement
+ private ResourceOperationLastCompletedComposite() {
+ super();
+ this.resourceTypeName = "(unitialized type)";
+ this.resourceName = "(unitialized)";
+ this.resourceId = 0;
+ }
public ResourceOperationLastCompletedComposite(int operationId, String operationName,
long operationStartTime,
OperationRequestStatus operationStatus, int resourceId, String resourceName,
String resourceTypeName) {
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
index 99e45b6..4185035 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
@@ -1,33 +1,41 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.core.domain.operation.composite;
import org.rhq.core.domain.operation.ScheduleJobId;
public class ResourceOperationScheduleComposite extends OperationScheduleComposite {
- private final int resourceId;
- private final String resourceName;
- private final String resourceTypeName;
+ private int resourceId;
+ private String resourceName;
+ private String resourceTypeName;
+
+ //private no args constructor for serialization. Not to be used.
+ private ResourceOperationScheduleComposite() {
+ super();
+ this.resourceTypeName = "(unitialized type)";
+ this.resourceName = "(uninitialized)";
+ this.resourceId = 0;
+ }
public ResourceOperationScheduleComposite(String jobName, String jobGroup, String
operationName,
long operationNextFireTime, int resourceId, String resourceName, String
resourceTypeName) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index d4deaca..83af987 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -48,9 +48,10 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.ProblemResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedView;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryView;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.TagCloudPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MashupPortlet;
@@ -225,12 +226,12 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
DashboardPortlet recentlyAdded = new DashboardPortlet("Recently Added
Resources", RecentlyAddedView.KEY, 250);
dashboard.addPortlet(recentlyAdded, 1, 4);
- // DashboardPortlet operations = new
DashboardPortlet("Operations", RecentlyAddedView.KEY, 250);
- // dashboard.addPortlet(operations, 1, 5);
+ DashboardPortlet operations = new DashboardPortlet("Operations",
OperationsPortlet.KEY, 250);
+ dashboard.addPortlet(operations, 1, 5);
DashboardPortlet hasAlertsCurrentlyUnavailable = new DashboardPortlet("Has
Alerts or Currently Unavailable",
ProblemResourcesPortlet.KEY, 250);
- dashboard.addPortlet(hasAlertsCurrentlyUnavailable, 1, 5);
+ dashboard.addPortlet(hasAlertsCurrentlyUnavailable, 1, 6);
return dashboard;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index a676bae..cb87235 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -32,8 +32,9 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resour
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.ProblemResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedView;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryView;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.TagCloudPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MashupPortlet;
@@ -66,6 +67,7 @@ public class PortletFactory {
registeredPortlets.put(MashupPortlet.KEY, MashupPortlet.Factory.INSTANCE);
registeredPortlets.put(MessagePortlet.KEY, MessagePortlet.Factory.INSTANCE);
registeredPortlets.put(ProblemResourcesPortlet.KEY,
ProblemResourcesPortlet.Factory.INSTANCE);
+ registeredPortlets.put(OperationsPortlet.KEY,
OperationsPortlet.Factory.INSTANCE);
}
public static Portlet buildPortlet(PortletWindow portletWindow, DashboardPortlet
storedPortlet) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/ProblemResourcesPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/ProblemResourcesPortlet.java
deleted file mode 100644
index 2d7ad0e..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/ProblemResourcesPortlet.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
-
-/*
- * RHQ Management Platform
- * Copyright (C) 2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-import com.google.gwt.core.client.GWT;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
-
-/**
- * A view that displays a paginated table of fired {@link org.rhq.core.domain.alert.Alert
alert}s,
- * and Resources reported unavailable.
- *
- * @author Simeon Pinder
- */
-public class ProblemResourcesPortlet extends VLayout implements Portlet {
-
- public static final String KEY = "Has Alerts or Currently Unavailable";
- private static final String TITLE = KEY;
-
- public ProblemResourcesPortlet() {
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- // Add the list table as the top half of the view.
- ListGrid listGrid = new ListGrid();
- listGrid.setDataSource(new ProblemResourcesDataSource());
- listGrid.setAutoFetchData(true);
- listGrid.setTitle(TITLE);
- listGrid.setResizeFieldsInRealTime(true);
- addMember(listGrid);
- }
-
- @Override
- public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
- // TODO implement this.
-
- }
-
- @Override
- public Canvas getHelpCanvas() {
- return new HTMLFlow("This portlet displays resources that have reported
alerts or Down availability.");
- }
-
- public DynamicForm getCustomSettingsForm() {
- return null;
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
-
- public final Portlet getInstance() {
- return GWT.create(ProblemResourcesPortlet.class);
- }
- }
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
new file mode 100644
index 0000000..502189a
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
@@ -0,0 +1,112 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.grid.HeaderSpan;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
+import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
+
+/**
+ * A view that displays a live table of completed Operations and scheduled operations.
+ *
+ * @author Simeon Pinder
+ */
+public class OperationsPortlet extends VLayout implements Portlet {
+
+ public static final String KEY = "Operations";
+ private static final String TITLE = KEY;
+ private static String recentOperations = "Recent Operations";
+ private static String scheduledOperations = "Scheduled Operations";
+
+ public OperationsPortlet() {
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ //set title for larger container
+ setTitle(TITLE);
+
+ // Add the list table as the top half of the view.
+ ListGrid recentOperationsGrid = new ListGrid();
+ recentOperationsGrid.setDataSource(new RecentOperationsDataSource());
+ recentOperationsGrid.setAutoFetchData(true);
+ String[] allRows = new String[] { RecentOperationsDataSource.location,
RecentOperationsDataSource.operation,
+ RecentOperationsDataSource.resource, RecentOperationsDataSource.status,
RecentOperationsDataSource.time };
+ recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, allRows));
+ recentOperationsGrid.setHeaderSpanHeight(new Integer(20));
+ recentOperationsGrid.setHeaderHeight(40);
+ recentOperationsGrid.setResizeFieldsInRealTime(true);
+ addMember(recentOperationsGrid);
+
+ // Add the list table as the top half of the view.
+ ListGrid scheduledOperationsGrid = new ListGrid();
+ scheduledOperationsGrid.setDataSource(new ScheduledOperationsDataSource());
+ scheduledOperationsGrid.setAutoFetchData(true);
+ String[] allRows2 = new String[] { ScheduledOperationsDataSource.location,
+ ScheduledOperationsDataSource.operation,
ScheduledOperationsDataSource.resource,
+ ScheduledOperationsDataSource.time };
+ scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations,
allRows2));
+ scheduledOperationsGrid.setHeaderSpanHeight(new Integer(20));
+ scheduledOperationsGrid.setHeaderHeight(40);
+
+ scheduledOperationsGrid.setTitle(scheduledOperations);
+ scheduledOperationsGrid.setResizeFieldsInRealTime(true);
+
+ addMember(scheduledOperationsGrid);
+
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ // TODO implement this.
+
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays both operations that have
occurred and are scheduled to occur.");
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance() {
+ return GWT.create(OperationsPortlet.class);
+ }
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/ScheduledOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/ScheduledOperationsPortlet.java
new file mode 100644
index 0000000..ab24763
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/ScheduledOperationsPortlet.java
@@ -0,0 +1,87 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.types.GroupStartOpen;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
+
+/**
+ * A view that displays a live table of completed Operations and scheduled operations.
+ *
+ * @author Simeon Pinder
+ */
+public class ScheduledOperationsPortlet extends VLayout implements Portlet {
+
+ public static final String KEY = "Operations";
+ private static final String TITLE = KEY;
+
+ public ScheduledOperationsPortlet() {
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // Add the list table as the top half of the view.
+ ListGrid listGrid = new ListGrid();
+ listGrid.setDataSource(new RecentOperationsDataSource());
+ listGrid.setGroupStartOpen(GroupStartOpen.ALL);
+ listGrid.setGroupByField("continent");
+ listGrid.setAutoFetchData(true);
+ listGrid.setTitle(TITLE);
+ listGrid.setResizeFieldsInRealTime(true);
+ addMember(listGrid);
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ // TODO implement this.
+
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays both operations that have
occurred and are scheduled to occur.");
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance() {
+ return GWT.create(ScheduledOperationsPortlet.class);
+ }
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
new file mode 100644
index 0000000..ca5ce12
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java
@@ -0,0 +1,88 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.types.Autofit;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
+
+/**
+ * A view that displays a paginated table of Resoruces with alerts,
+ * and/or Resources reported unavailable.
+ *
+ * @author Simeon Pinder
+ */
+public class ProblemResourcesPortlet extends VLayout implements Portlet {
+
+ public static final String KEY = "Has Alerts or Currently Unavailable";
+ private static final String TITLE = KEY;
+
+ public ProblemResourcesPortlet() {
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // Add the list table as the top half of the view.
+ ListGrid listGrid = new ListGrid();
+ listGrid.setDataSource(new ProblemResourcesDataSource());
+ listGrid.setAutoFetchData(true);
+ listGrid.setTitle(TITLE);
+ listGrid.setResizeFieldsInRealTime(true);
+ listGrid.setCellHeight(40);
+ listGrid.setAutoFitData(Autofit.BOTH);
+ addMember(listGrid);
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ // TODO implement this.
+
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays resources that have reported
alerts or Down availability.");
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance() {
+ return GWT.create(ProblemResourcesPortlet.class);
+ }
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
index 2ba537f..72f2fb9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/OperationGWTService.java
@@ -18,13 +18,19 @@
*/
package org.rhq.enterprise.gui.coregui.client.gwt;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.util.PageList;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.ExecutionSchedule;
@@ -33,13 +39,17 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation
*/
public interface OperationGWTService extends RemoteService {
-
- PageList<ResourceOperationHistory>
findResourceOperationHistoriesByCriteria(ResourceOperationHistoryCriteria criteria);
+ PageList<ResourceOperationHistory> findResourceOperationHistoriesByCriteria(
+ ResourceOperationHistoryCriteria criteria);
PageList<GroupOperationHistory>
findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria);
- void scheduleResourceOperation(
- int resourceId, String operationName, Configuration parameters,
ExecutionSchedule schedule, String description, int timeout)
- throws RuntimeException;
+ List<DisambiguationReport<ResourceOperationLastCompletedComposite>>
findRecentCompletedOperations(
+ ResourceCriteria criteria);
+
+ List<DisambiguationReport<ResourceOperationScheduleComposite>>
findScheduledOperations(ResourceCriteria criteria);
+
+ void scheduleResourceOperation(int resourceId, String operationName, Configuration
parameters,
+ ExecutionSchedule schedule, String description, int timeout) throws
RuntimeException;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
new file mode 100644
index 0000000..7995f46
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -0,0 +1,177 @@
+package org.rhq.enterprise.gui.coregui.client.operation;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+import java.util.Date;
+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.DataSource;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceDateTimeField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.DSDataFormat;
+import com.smartgwt.client.types.DSProtocol;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+
+/** Responsible for defining and populating the Smart GWT datasource details and
+ * translating the deserialized content into specific record entries for display
+ *
+ * @author spinder
+ */
+public class RecentOperationsDataSource extends DataSource {
+ public static final String resource = "resource";
+ public static final String location = "location";
+ public static final String operation = "operation";
+ public static final String time = "time";
+ public static final String status = "status";
+
+ /** Build list of fields for the datasource and then adds them to it.
+ */
+ public RecentOperationsDataSource() {
+ setClientOnly(false);
+ setDataProtocol(DSProtocol.CLIENTCUSTOM);
+ setDataFormat(DSDataFormat.CUSTOM);
+
+ DataSourceTextField resourceField = new DataSourceTextField(resource,
"Resource");
+ resourceField.setPrimaryKey(true);
+
+ DataSourceTextField locationField = new DataSourceTextField(location,
"Location", 200);
+
+ DataSourceTextField operationField = new DataSourceTextField(operation,
"Operation");
+
+ DataSourceDateTimeField timeField = new DataSourceDateTimeField(time,
"Date/Time");
+
+ // DataSourceImageField statusField = new DataSourceImageField(status,
"Status");
+ DataSourceTextField statusField = new DataSourceTextField(status,
"Status");
+
+ setFields(resourceField, locationField, operationField, timeField, statusField);
+ }
+
+ /* Intercept DSRequest object to pipe into custom fetch request.
+ * (non-Javadoc)
+ * @see
com.smartgwt.client.data.DataSource#transformRequest(com.smartgwt.client.data.DSRequest)
+ */
+ protected Object transformRequest(DSRequest request) {
+ DSResponse response = new DSResponse();
+ response.setAttribute("clientContext",
request.getAttributeAsObject("clientContext"));
+ // Assume success
+ response.setStatus(0);
+ switch (request.getOperationType()) {
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
+ }
+
+ return request.getData();
+ }
+
+ /** Fetch the ProblemResource data, and populate the response object appropriately.
+ *
+ * @param request incoming request
+ * @param response outgoing response
+ */
+ public void executeFetch(final DSRequest request, final DSResponse response) {
+
+ ResourceCriteria c = new ResourceCriteria();
+ GWTServiceLookup.getOperationService().findRecentCompletedOperations(c,
+ new
AsyncCallback<List<DisambiguationReport<ResourceOperationLastCompletedComposite>>>()
{
+
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load recently
completed operations.", throwable);
+ }
+
+ public void onSuccess(
+
List<DisambiguationReport<ResourceOperationLastCompletedComposite>>
recentOperationsList) {
+
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(recentOperationsList));
+ //entry count
+ if (null != recentOperationsList) {
+ response.setTotalRows(recentOperationsList.size());
+ } else {
+ response.setTotalRows(0);
+ }
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ /** Translates the DisambiguationReport of ResourceOperationLastCompletedComposites
into specific
+ * and ordered record values.
+ *
+ * @param list DisambiguationReport of entries.
+ * @return Record[] ordered record entries.
+ */
+ protected Record[]
buildList(List<DisambiguationReport<ResourceOperationLastCompletedComposite>>
list) {
+
+ ListGridRecord[] dataValues = null;
+ if (list != null) {
+ dataValues = new ListGridRecord[list.size()];
+ int indx = 0;
+
+ for (DisambiguationReport<ResourceOperationLastCompletedComposite>
report : list) {
+ ListGridRecord record = new ListGridRecord();
+ //disambiguated Resource name, decorated with html anchors to problem
resources
+ record.setAttribute(resource,
ReportDecorator.decorateResourceName(ReportDecorator.GWT_RESOURCE_URL,
+ report.getResourceType(), report.getOriginal().getResourceName(),
report.getOriginal()
+ .getResourceId()));
+ //disambiguated resource lineage, decorated with html anchors
+ record.setAttribute(location,
ReportDecorator.decorateResourceLineage(report.getParents()));
+ //operation name.
+ record.setAttribute(operation, report.getOriginal().getOperationName());
+ //timestamp.
+ record.setAttribute(time, new
Date(report.getOriginal().getOperationStartTime()));
+ //populate status icon .
/rhq/resource/operation/resourceOperationHistoryDetails-plain.xhtml?id=10001&opId=10001
+ // String link = "<a href='" +
ReportDecorator.GWT_RECENT_OPERATION_URL
+ String link = "<a href='" +
"/rhq/resource/operation/resourceOperationHistoryDetails-plain.xhtml?id="
+ + report.getOriginal().getResourceId() + "&opId=" +
report.getOriginal().getResourceId() + "'>";
+ String img = "<img alt='" +
report.getOriginal().getOperationStatus() + "' title='"
+ + report.getOriginal().getOperationStatus() + "'
src='/images/icons/";
+ if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.SUCCESS) == 0)
{
+ img += "availability_green_16.png'";
+ } else if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.FAILURE) == 0)
{
+ img += "availability_red_16.png";
+ } else if
(report.getOriginal().getOperationStatus().compareTo(OperationRequestStatus.CANCELED) ==
0) {
+ img += "availability_yellow_16.png";
+ } else {
+ img += "availability_grey_16.png";
+ }
+ link = link + img + "'></img></a>";
+ record.setAttribute(status, link);
+
+ dataValues[indx++] = record;
+ }
+ }
+ return dataValues;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
new file mode 100644
index 0000000..a1fa3f4
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -0,0 +1,154 @@
+package org.rhq.enterprise.gui.coregui.client.operation;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+import java.util.Date;
+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.DataSource;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.DSDataFormat;
+import com.smartgwt.client.types.DSProtocol;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+
+/** Responsible for defining and populating the Smart GWT datasource details and
+ * translating the deserialized content into specific record entries for display
+ *
+ * @author spinder
+ */
+public class ScheduledOperationsDataSource extends DataSource {
+ public static final String resource = "resource";
+ public static final String location = "location";
+ public static final String operation = "operation";
+ public static final String time = "time";
+
+ /** Build list of fields for the datasource and then adds them to it.
+ */
+ public ScheduledOperationsDataSource() {
+ setClientOnly(false);
+ setDataProtocol(DSProtocol.CLIENTCUSTOM);
+ setDataFormat(DSDataFormat.CUSTOM);
+
+ DataSourceTextField resourceField = new DataSourceTextField(resource,
"Resource");
+ resourceField.setPrimaryKey(true);
+
+ DataSourceTextField locationField = new DataSourceTextField(location,
"Location");
+
+ DataSourceTextField operationField = new DataSourceTextField(operation,
"Operation");
+
+ DataSourceTextField timeField = new DataSourceTextField(operation,
"Date/Time");
+
+ setFields(resourceField, locationField, operationField, timeField);
+ }
+
+ /* Intercept DSRequest object to pipe into custom fetch request.
+ * (non-Javadoc)
+ * @see
com.smartgwt.client.data.DataSource#transformRequest(com.smartgwt.client.data.DSRequest)
+ */
+ protected Object transformRequest(DSRequest request) {
+ DSResponse response = new DSResponse();
+ response.setAttribute("clientContext",
request.getAttributeAsObject("clientContext"));
+ // Assume success
+ response.setStatus(0);
+ switch (request.getOperationType()) {
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
+ }
+
+ return request.getData();
+ }
+
+ /** Fetch the ProblemResource data, and populate the response object appropriately.
+ *
+ * @param request incoming request
+ * @param response outgoing response
+ */
+ public void executeFetch(final DSRequest request, final DSResponse response) {
+
+ ResourceCriteria c = new ResourceCriteria();
+ GWTServiceLookup.getOperationService().findScheduledOperations(c,
+ new
AsyncCallback<List<DisambiguationReport<ResourceOperationScheduleComposite>>>()
{
+
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load scheduled
operations.", throwable);
+ }
+
+ public void
onSuccess(List<DisambiguationReport<ResourceOperationScheduleComposite>>
scheduledOpsList) {
+
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(scheduledOpsList));
+ //entry count
+ if (null != scheduledOpsList) {
+ response.setTotalRows(scheduledOpsList.size());
+ } else {
+ response.setTotalRows(0);
+ }
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ /** Translates the DisambiguationReport of ProblemResourceComposites into specific
+ * and ordered record values.
+ *
+ * @param list DisambiguationReport of entries.
+ * @return Record[] ordered record entries.
+ */
+ protected Record[]
buildList(List<DisambiguationReport<ResourceOperationScheduleComposite>> list)
{
+
+ ListGridRecord[] dataValues = null;
+ if (list != null) {
+ dataValues = new ListGridRecord[list.size()];
+ int indx = 0;
+
+ for (DisambiguationReport<ResourceOperationScheduleComposite> report :
list) {
+ ListGridRecord record = new ListGridRecord();
+
+ //disambiguated Resource name, decorated with html anchors to problem
resources
+ record.setAttribute(resource,
ReportDecorator.decorateResourceName(ReportDecorator.GWT_RESOURCE_URL,
+ report.getResourceType(), report.getOriginal().getResourceName(),
report.getOriginal()
+ .getResourceId()));
+ //disambiguated resource lineage, decorated with html anchors
+ record.setAttribute(location,
ReportDecorator.decorateResourceLineage(report.getParents()));
+ //operation name.
+ record.setAttribute(operation, report.getOriginal().getOperationName());
+ //timestamp.
+ record.setAttribute(time, new
Date(report.getOriginal().getOperationNextFireTime()));
+
+ dataValues[indx++] = record;
+ }
+ }
+ return dataValues;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index ccc620a..387314a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -137,8 +137,9 @@ public class ProblemResourcesDataSource extends DataSource {
for (DisambiguationReport<ProblemResourceComposite> report : list) {
ListGridRecord record = new ListGridRecord();
//disambiguated Resource name, decorated with html anchors to problem
resources
- record.setAttribute(resource,
ReportDecorator.decorateResourceName(report.getResourceType(), report
- .getOriginal().getResourceName(),
report.getOriginal().getResourceId()));
+ record.setAttribute(resource,
ReportDecorator.decorateResourceName(ReportDecorator.GWT_RESOURCE_URL,
+ report.getResourceType(), report.getOriginal().getResourceName(),
report.getOriginal()
+ .getResourceId()));
//disambiguated resource lineage, decorated with html anchors
record.setAttribute(location,
ReportDecorator.decorateResourceLineage(report.getParents()));
//alert cnt.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/disambiguation/ReportDecorator.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/disambiguation/ReportDecorator.java
index ff50f1f..d2c7a4a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/disambiguation/ReportDecorator.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/disambiguation/ReportDecorator.java
@@ -19,6 +19,7 @@ public class ReportDecorator {
//TODO: pull value from more bookmarking/history definition
public final static String GWT_RESOURCE_URL =
"/coregui/CoreGUI.html#Resource/";
+ public final static String GWT_RECENT_OPERATION_URL =
"/coregui/CoreGUI.html#Operation/";
public static final String DEFAULT_SEPARATOR = " > ";
/** Generates HTML label from DisambiguationReport data.
@@ -28,12 +29,13 @@ public class ReportDecorator {
* @param resourceId Id for resource
* @return String of generated html for a ResourceName.
*/
- public static String decorateResourceName(ResourceType type, String resourceName, int
resourceId) {
+ public static String decorateResourceName(String specificUrl, ResourceType type,
String resourceName, int resourceId) {
String decorated = "";
if (type != null) {
decorated += type.getName();
}
- decorated += " <a href=\"" + GWT_RESOURCE_URL + resourceId +
"\">" + resourceName + "</a>";
+ // decorated += " <a href=\"" + GWT_RESOURCE_URL +
resourceId + "\">" + resourceName + "</a>";
+ decorated += " <a href=\"" + specificUrl + resourceId +
"\">" + resourceName + "</a>";
return decorated;
}
@@ -49,13 +51,14 @@ public class ReportDecorator {
Iterator<DisambiguationReport.Resource> it = parents.iterator();
DisambiguationReport.Resource parent = it.next();
//generate first link
- String parentUrl = ReportDecorator.decorateResourceName(null,
parent.getName(), parent.getId());
+ String parentUrl = ReportDecorator.decorateResourceName(GWT_RESOURCE_URL,
null, parent.getName(), parent
+ .getId());
decorated = writeResource(decorated, parentUrl, parent.getName(),
parent.getType());
while (it.hasNext()) {
decorated.append(DEFAULT_SEPARATOR);
parent = it.next();
- decorated = writeResource(decorated,
ReportDecorator.decorateResourceName(null, parent.getName(),
- parent.getId()), parent.getName(), parent.getType());
+ decorated = writeResource(decorated,
ReportDecorator.decorateResourceName(GWT_RESOURCE_URL, null,
+ parent.getName(), parent.getId()), parent.getName(),
parent.getType());
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index 0519a0b..e44c086 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -18,19 +18,29 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import java.util.List;
+
import org.quartz.CronTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.operation.GroupOperationHistory;
import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
+import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.IntExtractor;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTService;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.ExecutionSchedule;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.operation.ResourceOperationSchedule;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import
org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -39,40 +49,87 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements
OperationGWTService {
private OperationManagerLocal operationManager = LookupUtil.getOperationManager();
+ private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
- public PageList<ResourceOperationHistory>
findResourceOperationHistoriesByCriteria(ResourceOperationHistoryCriteria criteria) {
- return
SerialUtility.prepare(operationManager.findResourceOperationHistoriesByCriteria(getSessionSubject(),
criteria),
- "OperationService.findResourceOperationHistoriesByCriteria");
+ public PageList<ResourceOperationHistory>
findResourceOperationHistoriesByCriteria(
+ ResourceOperationHistoryCriteria criteria) {
+ return
SerialUtility.prepare(operationManager.findResourceOperationHistoriesByCriteria(getSessionSubject(),
+ criteria),
"OperationService.findResourceOperationHistoriesByCriteria");
}
public PageList<GroupOperationHistory>
findGroupOperationHistoriesByCriteria(GroupOperationHistoryCriteria criteria) {
- return
SerialUtility.prepare(operationManager.findGroupOperationHistoriesByCriteria(getSessionSubject(),
criteria),
- "OperationService.findGroupOperationHistoriesByCriteria");
+ return
SerialUtility.prepare(operationManager.findGroupOperationHistoriesByCriteria(getSessionSubject(),
+ criteria),
"OperationService.findGroupOperationHistoriesByCriteria");
}
-
- public void scheduleResourceOperation(
- int resourceId, String operationName, Configuration parameters,
ExecutionSchedule schedule, String description, int timeout)
- throws RuntimeException {
+ public void scheduleResourceOperation(int resourceId, String operationName,
Configuration parameters,
+ ExecutionSchedule schedule, String description, int timeout) throws
RuntimeException {
ResourceOperationSchedule opSchedule;
try {
if (schedule.getStart() == ExecutionSchedule.Start.Immediately) {
- opSchedule =
operationManager.scheduleResourceOperation(getSessionSubject(), resourceId, operationName,
0, 0, 0, 0, parameters, description);
+ opSchedule =
operationManager.scheduleResourceOperation(getSessionSubject(), resourceId,
operationName,
+ 0, 0, 0, 0, parameters, description);
} else {
- CronTrigger ct = new CronTrigger(
- "resource " + resourceId + "_" +
operationName,
- "group",
- schedule.getCronString());
+ CronTrigger ct = new CronTrigger("resource " + resourceId +
"_" + operationName, "group", schedule
+ .getCronString());
- opSchedule =
operationManager.scheduleResourceOperation(getSessionSubject(), resourceId, operationName,
parameters, ct, description);
+ opSchedule =
operationManager.scheduleResourceOperation(getSessionSubject(), resourceId,
operationName,
+ parameters, ct, description);
}
} catch (Exception e) {
throw new RuntimeException("Unabled to schedule operation
execution" + e.getMessage());
}
}
+ /** Find recently completed operations, disambiguate them and return that list.
+ *
+ */
+ public
List<DisambiguationReport<ResourceOperationLastCompletedComposite>>
findRecentCompletedOperations(
+ ResourceCriteria criteria) {
+
+ PageControl pageControl = new PageControl(0, -1);
+ PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps
= operationManager
+ .findRecentlyCompletedResourceOperations(getSessionSubject(), null,
pageControl);
+
+ //translate the returned problem resources to disambiguated links
+ List<DisambiguationReport<ResourceOperationLastCompletedComposite>>
disambiguatedLastCompletedResourceOps = resourceManager
+ .disambiguate(lastCompletedResourceOps,
RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR,
+ DefaultDisambiguationUpdateStrategies.getDefault());
+
+ return disambiguatedLastCompletedResourceOps;
+ }
+
+ /** Find scheduled operations, disambiguate them and return that list.
+ *
+ */
+ public List<DisambiguationReport<ResourceOperationScheduleComposite>>
findScheduledOperations(
+ ResourceCriteria criteria) {
+
+ PageControl pageControl = new PageControl(0, -1);
+ PageList<ResourceOperationScheduleComposite> scheduledResourceOps =
operationManager
+ .findCurrentlyScheduledResourceOperations(getSessionSubject(), pageControl);
+
+ //translate the returned problem resources to disambiguated links
+ List<DisambiguationReport<ResourceOperationScheduleComposite>>
disambiguatedNextScheduledResourceOps = resourceManager
+ .disambiguate(scheduledResourceOps,
RESOURCE_OPERATION_SCHEDULE_RESOURCE_ID_EXTRACTOR,
+ DefaultDisambiguationUpdateStrategies.getDefault());
+
+ return disambiguatedNextScheduledResourceOps;
+ }
+
+ private static final IntExtractor<ResourceOperationLastCompletedComposite>
RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR = new
IntExtractor<ResourceOperationLastCompletedComposite>() {
+ public int extract(ResourceOperationLastCompletedComposite object) {
+ return object.getResourceId();
+ }
+ };
+
+ private static final IntExtractor<ResourceOperationScheduleComposite>
RESOURCE_OPERATION_SCHEDULE_RESOURCE_ID_EXTRACTOR = new
IntExtractor<ResourceOperationScheduleComposite>() {
+ public int extract(ResourceOperationScheduleComposite object) {
+ return object.getResourceId();
+ }
+ };
}
commit 94f59f5b446b8440a138ebeea39785727991dc2f
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Aug 19 15:57:09 2010 -0400
UnavailibilityPortlet start
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index 90b795e..33d32b3 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -60,7 +60,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
public class AlertDataSource extends RPCDataSource<Alert> {
private AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService();
- protected AlertDataSource() {
+ public AlertDataSource() {
super();
setCanMultiSort(true);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index a82393c..30811cd 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -75,7 +75,6 @@ public class DashboardsView extends VLayout implements BookmarkableView
{
private DashboardGWTServiceAsync dashboardService =
GWTServiceLookup.getDashboardService();
-
private String selectedTab;
public DashboardsView() {
@@ -108,7 +107,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
removeMembers(getMembers());
this.dashboards = dashboards;
-
tabSet = new TabSet();
tabSet.setWidth100();
@@ -116,7 +114,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
tabSet.setCanCloseTabs(true);
-
editButton = new IButton(editMode ? "View Mode" : "Edit
Mode");
editButton.setAutoFit(true);
editButton.addClickHandler(new ClickHandler() {
@@ -127,7 +124,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
}
});
-
final IButton newDashboardButton = new IButton("New Dashboard");
newDashboardButton.setAutoFit(true);
newDashboardButton.addClickHandler(new ClickHandler() {
@@ -142,7 +138,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
tabSet.setTabBarControls(buttons);
-
tabSet.addTabSelectedHandler(new TabSelectedHandler() {
public void onTabSelected(TabSelectedEvent tabSelectedEvent) {
History.newItem("Dashboard/" +
tabSelectedEvent.getTab().getTitle(), false);
@@ -159,7 +154,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
tab.setPane(dashboardView);
tab.setCanClose(true);
-
tabSet.addTab(tab);
if (dashboard.getName().equals(selectedTab)) {
tabSet.selectTab(tab);
@@ -169,15 +163,16 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
tabSet.addCloseClickHandler(new CloseClickHandler() {
public void onCloseClick(final TabCloseClickEvent tabCloseClickEvent) {
final DashboardView dashboardView = (DashboardView)
tabCloseClickEvent.getTab().getPane();
- SC.ask("Are you sure you want to delete [" +
tabCloseClickEvent.getTab().getTitle() + "]?", new BooleanCallback() {
- public void execute(Boolean aBoolean) {
- if (aBoolean) {
- dashboardView.delete();
- } else {
- tabCloseClickEvent.cancel();
+ SC.ask("Are you sure you want to delete [" +
tabCloseClickEvent.getTab().getTitle() + "]?",
+ new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ dashboardView.delete();
+ } else {
+ tabCloseClickEvent.cancel();
+ }
}
- }
- });
+ });
}
});
@@ -185,7 +180,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
}
-
protected Dashboard getDefaultDashboard() {
Dashboard dashboard = new Dashboard();
@@ -194,7 +188,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
dashboard.setColumnWidths("32%", "68%");
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
-
DashboardPortlet summary = new DashboardPortlet("Inventory Summary",
InventorySummaryView.KEY, 230);
dashboard.addPortlet(summary, 0, 0);
@@ -202,40 +195,46 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
dashboard.addPortlet(tagCloud, 0, 1);
// Experimental
-// StoredPortlet platformSummary = new StoredPortlet("Platform Summary",
PlatformPortletView.KEY, 300);
-// col2.add(platformSummary);
-
+ // StoredPortlet platformSummary = new StoredPortlet("Platform
Summary", PlatformPortletView.KEY, 300);
+ // col2.add(platformSummary);
DashboardPortlet welcome = new DashboardPortlet("Welcome To RHQ",
MessagePortlet.KEY, 180);
- welcome.getConfiguration().put(new PropertySimple("message",
"<h1>Welcome to RHQ</h1>\n" +
- "<p>The RHQ project is an abstraction and plug-in based
systems management suite that provides " +
- "extensible and integrated systems management for multiple products
and platforms across a set " +
- "of core features. The project is designed with layered modules that
provide a flexible " +
- "architecture for deployment. It delivers a core user interface that
delivers audited and " +
- "historical management across an entire enterprise. A Server/Agent
architecture provides " +
- "remote management and plugins implement all specific support for
managed products.</p>\n" +
- "<p>This default dashboard can be edited by clicking the
\"edit mode\" button above.</p>"));
+ welcome.getConfiguration().put(
+ new PropertySimple("message", "<h1>Welcome to
RHQ</h1>\n"
+ + "<p>The RHQ project is an abstraction and plug-in based
systems management suite that provides "
+ + "extensible and integrated systems management for multiple
products and platforms across a set "
+ + "of core features. The project is designed with layered modules
that provide a flexible "
+ + "architecture for deployment. It delivers a core user interface
that delivers audited and "
+ + "historical management across an entire enterprise. A Server/Agent
architecture provides "
+ + "remote management and plugins implement all specific support for
managed products.</p>\n"
+ + "<p>This default dashboard can be edited by clicking the
\"edit mode\" button above.</p>"));
dashboard.addPortlet(welcome, 1, 0);
DashboardPortlet news = new DashboardPortlet("RHQ News",
MashupPortlet.KEY, 320);
- news.getConfiguration().put(new PropertySimple("address",
"http://rhq-project.org/display/RHQ/RHQ+News?decorator=popup"));
+ news.getConfiguration().put(
+ new PropertySimple("address",
"http://rhq-project.org/display/RHQ/RHQ+News?decorator=popup"));
dashboard.addPortlet(news, 1, 1);
-//
+ //
DashboardPortlet discoveryQueue = new DashboardPortlet("Discovery
Queue", AutodiscoveryPortlet.KEY, 250);
dashboard.addPortlet(discoveryQueue, 1, 2);
-
DashboardPortlet recentAlerts = new DashboardPortlet("Recent Alerts",
RecentAlertsPortlet.KEY, 250);
dashboard.addPortlet(recentAlerts, 1, 3);
DashboardPortlet recentlyAdded = new DashboardPortlet("Recently Added
Resources", RecentlyAddedView.KEY, 250);
dashboard.addPortlet(recentlyAdded, 1, 4);
+ // DashboardPortlet operations = new
DashboardPortlet("Operations", RecentlyAddedView.KEY, 250);
+ // dashboard.addPortlet(operations, 1, 5);
+
+ // DashboardPortlet hasAlertsCurrentlyUnavailable = new
DashboardPortlet("Has Alerts or Currently Unavailable",
+ // UnavailabilityPortlet.KEY, 250);
+ // dashboard.addPortlet(hasAlertsCurrentlyUnavailable, 1, 5);
+
return dashboard;
}
-
public void addNewDashboard() {
Dashboard dashboard = new Dashboard();
@@ -276,7 +275,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
editButton.setTitle(editMode ? "View Mode" : "Edit
Mode");
dashboardView.setEditMode(editMode);
-
}
});
}
@@ -288,15 +286,18 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
}
}
-
public void renderView(ViewPath viewPath) {
if (!viewPath.isEnd()) {
selectedTab = viewPath.getCurrent().getPath();
+ System.out.println("#################:" + selectedTab +
":tabset:" + tabSet);
+ // if (tabSet != null) {
for (Tab tab : tabSet.getTabs()) {
- if (selectedTab.equals(tab.getTitle())) {
+ // if (selectedTab.equals(tab.getTitle())) {
+ if (tab.getTitle().equals(selectedTab)) {
tabSet.selectTab(tab);
}
}
+ // }
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
new file mode 100644
index 0000000..e694c5c
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
@@ -0,0 +1,91 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
+
+/**
+ * A view that displays a paginated table of fired {@link org.rhq.core.domain.alert.Alert
alert}s,
+ * and Resources reported unavailable.
+ *
+ * @author Simeon Pinder
+ */
+public class UnavailabilityPortlet extends VLayout implements Portlet {
+
+ public static final String KEY = "Currently Unavailable";
+ private static final String TITLE = KEY;
+
+ public UnavailabilityPortlet() {
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // Add the list table as the top half of the view.
+ ListGrid listGrid = new ListGrid();
+ listGrid.setDataSource(new ProblemResourcesDataSource());
+ listGrid.setAutoFetchData(true);
+ listGrid.setTitle(TITLE);
+ listGrid.setResizeFieldsInRealTime(true);
+ // listGrid.getField("resourceName").setCellFormatter(new
CellFormatter() {
+ // public String format(Object o, ListGridRecord listGridRecord, int
i, int i1) {
+ // return "<a href=\"#Resource/" +
listGridRecord.getAttribute("resourceId") + "\">" + o +
"</a>";
+ // }
+ // });
+ addMember(listGrid);
+
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ // TODO implement this.
+
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays resources that have reported Down
availability.");
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance() {
+ return GWT.create(UnavailabilityPortlet.class);
+ }
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index f92e7d5..4c7fce5 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -28,6 +28,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageControl;
@@ -48,6 +49,8 @@ public interface ResourceGWTService extends RemoteService {
List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int
maxItems);
+ List<ProblemResourceComposite> findProblemResources(ResourceCriteria
criteria);
+
Resource getPlatformForResource(int resourceId);
List<Integer> uninventoryResources(int[] resourceIds);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
new file mode 100644
index 0000000..1d5c079
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -0,0 +1,145 @@
+package org.rhq.enterprise.gui.coregui.client.resource;
+
+import java.util.ArrayList;
+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.DataSource;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.DSDataFormat;
+import com.smartgwt.client.types.DSProtocol;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
+public class ProblemResourcesDataSource extends DataSource {
+ public final String resource = "resource";
+ public final String location = "location";
+ public final String alerts = "alerts";
+ public final String available = "available";
+
+ /** Build list of fields for the datasource and then adds them to it.
+ */
+ public ProblemResourcesDataSource() {
+ setClientOnly(false);
+ setDataProtocol(DSProtocol.CLIENTCUSTOM);
+ setDataFormat(DSDataFormat.CUSTOM);
+
+ DataSourceTextField resourceField = new DataSourceTextField(resource,
"Resource");
+ resourceField.setPrimaryKey(true);
+
+ DataSourceTextField locationField = new DataSourceTextField(location,
"Location");
+
+ DataSourceTextField alertsField = new DataSourceTextField(alerts,
"Alerts");
+
+ DataSourceTextField availablilityField = new DataSourceTextField(available,
"Current Availability");
+
+ setFields(resourceField, locationField, alertsField, availablilityField);
+ }
+
+ /* Intercept DSRequest object to pipe into custom fetch request.
+ * (non-Javadoc)
+ * @see
com.smartgwt.client.data.DataSource#transformRequest(com.smartgwt.client.data.DSRequest)
+ */
+ protected Object transformRequest(DSRequest request) {
+ DSResponse response = new DSResponse();
+ response.setAttribute("clientContext",
request.getAttributeAsObject("clientContext"));
+ // Assume success
+ response.setStatus(0);
+ switch (request.getOperationType()) {
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
+ }
+
+ return request.getData();
+ }
+
+ /** Fetch the ProblemResource data, and populate the response object appropriately.
+ *
+ * @param request incoming request
+ * @param response outgoing response
+ */
+ public void executeFetch(final DSRequest request, final DSResponse response) {
+
+ ResourceCriteria c = new ResourceCriteria();
+ c.addFilterCurrentAvailability(AvailabilityType.DOWN);
+
+ // GWTServiceLookup.getResourceService().findRecentlyAddedResources(0,
100,
+ GWTServiceLookup.getResourceService().findProblemResources(c,
+ // new
AsyncCallback<List<RecentlyAddedResourceComposite>>() {
+ new AsyncCallback<List<ProblemResourceComposite>>() {
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load
unavailable resources", throwable);
+ }
+
+ // public void
onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) {
+ public void onSuccess(List<ProblemResourceComposite>
problemResourcesList) {
+ // List<RecentlyAddedResourceComposite> list
= new ArrayList<RecentlyAddedResourceComposite>();
+ List<ProblemResourceComposite> list = new
ArrayList<ProblemResourceComposite>();
+
+ // for (RecentlyAddedResourceComposite
recentlyAdded : problemResourcesList) {
+ for (ProblemResourceComposite problemResource : problemResourcesList)
{
+ list.add(problemResource);
+ //
list.addAll(problemResource.getChildren());
+ }
+
+ // response.setData(buildNodes(list));
+ response.setData(buildList(list));
+ response.setTotalRows(list.size());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ //
+ // GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new
AsyncCallback<PageList<Resource>>() {
+ // public void onFailure(Throwable caught) {
+ // CoreGUI.getErrorHandler().handleError("Failed to load
recently added resources data",caught);
+ // response.setStatus(DSResponse.STATUS_FAILURE);
+ // processResponse(request.getRequestId(), response);
+ // }
+ //
+ // public void onSuccess(PageList<Resource> result) {
+ // PageList<Resource> all = new PageList<Resource>();
+ //
+ // for (Resource root : result) {
+ // all.add(root);
+ // if (root.getChildResources() != null)
+ // all.addAll(root.getChildResources());
+ // }
+ //
+ //
+ // response.setData(buildNodes(all));
+ // response.setTotalRows(all.getTotalSize());
+ // processResponse(request.getRequestId(), response);
+ // }
+ // });
+ }
+
+ protected Record[] buildList(List<ProblemResourceComposite> list) {
+ ListGridRecord[] dataValues = null;
+ if (list != null) {
+ dataValues = new ListGridRecord[list.size()];
+ int indx = 0;
+ for (ProblemResourceComposite prc : list) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(resource, prc.getResourceId());
+ record.setAttribute(location, prc.getResourceName());
+ record.setAttribute(alerts, prc.getNumAlerts());
+ // record.setAttribute(available,
DateTimeFormat.getMediumDateTimeFormat().format(dateAdded));
+ record.setAttribute(available, prc.getAvailabilityType().getName());
+ dataValues[indx++] = record;
+ }
+ }
+ return dataValues;
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index c10254e..07388ea 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -35,6 +35,7 @@ import
org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageControl;
@@ -124,7 +125,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
public PageList<ResourceComposite>
findResourceCompositesByCriteria(ResourceCriteria criteria) {
try {
PageList<ResourceComposite> result =
resourceManager.findResourceCompositesByCriteria(getSessionSubject(),
- criteria);
+ criteria);
List<Resource> resources = new
ArrayList<Resource>(result.size());
if (resources.size() > 1) {
@@ -138,6 +139,19 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
}
}
+ public List<ProblemResourceComposite> findProblemResources(ResourceCriteria
criteria) {
+ List<ProblemResourceComposite> located = new
ArrayList<ProblemResourceComposite>();
+ PageList<ResourceComposite> pageList =
findResourceCompositesByCriteria(criteria);
+ if (!pageList.isEmpty()) {
+ for (ResourceComposite rc : pageList) {
+ ProblemResourceComposite prc = new
ProblemResourceComposite(rc.getResource().getId(), rc.getResource()
+ .getName(), rc.getAvailability(), 0);
+ //TODO: spinder: replace last argument with alert count for this
resource.
+ }
+ }
+ return located;
+ }
+
public List<Resource> getResourceLineage(int resourceId) {
return SerialUtility.prepare(resourceManager.getResourceLineage(resourceId),
"ResourceService.getResourceLineage");
@@ -166,6 +180,15 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
return platforms;
}
+ // @Override
+ // public List<ProblemResourceComposite> findProblemResources(long ctime,
int maxItems) {
+ // List<ProblemResourceComposite> problems =
+ // resourceManager.findResourceCompositesByCriteria(getSessionSubject(),
criteria)(
+ // getSessionSubject(), ctime, maxItems);
+ //
+ // return problems;
+ // }
+
public List<Integer> uninventoryResources(int[] resourceIds) {
return
SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(),
resourceIds),
"ResourceService.uninventoryResources");
@@ -195,12 +218,8 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
}
public Map<Resource, List<Resource>>
getQueuedPlatformsAndServers(HashSet<InventoryStatus> statuses, PageControl pc) {
- return SerialUtility.prepare(
- discoveryBoss.getQueuedPlatformsAndServers(
- getSessionSubject(),
- EnumSet.copyOf(statuses),
- pc),
- "ResourceService.getQueuedPlatformsAndServers");
+ return
SerialUtility.prepare(discoveryBoss.getQueuedPlatformsAndServers(getSessionSubject(),
EnumSet
+ .copyOf(statuses), pc),
"ResourceService.getQueuedPlatformsAndServers");
}
public void importResources(Integer[] resourceIds) {
@@ -214,5 +233,5 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
public void unignoreResources(Integer[] resourceIds) {
discoveryBoss.unignoreResources(getSessionSubject(), resourceIds);
}
-
+
}
\ No newline at end of file
commit 3affb98c0a1620a0b4dc68db31208fb8a8d0cfdb
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Aug 24 13:13:43 2010 -0400
Unavailability portlet with Datasource and including Disambiguation.
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
index 197378d..a83d1f8 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java
@@ -24,7 +24,6 @@
package org.rhq.core.domain.resource.composite;
import java.io.Serializable;
-import java.util.Collections;
import java.util.List;
/**
@@ -34,7 +33,7 @@ import java.util.List;
*/
public class DisambiguationReport<T> implements Serializable {
private static final long serialVersionUID = 1L;
-
+
private T original;
private List<Resource> parents;
private ResourceType resourceType;
@@ -45,7 +44,11 @@ public class DisambiguationReport<T> implements Serializable {
private String name;
private String plugin;
private boolean singleton;
-
+
+ //no args
+ public ResourceType() {
+ }
+
/**
* @param name
* @param plugin
@@ -57,11 +60,11 @@ public class DisambiguationReport<T> implements Serializable {
this.plugin = plugin;
this.singleton = singleton;
}
-
+
public String getName() {
return name;
}
-
+
/**
* @return the plugin that defines this type or null if such information
* isn't needed to disambiguate this type.
@@ -73,19 +76,22 @@ public class DisambiguationReport<T> implements Serializable {
public boolean isSingleton() {
return singleton;
}
-
+
public String toString() {
return "ResourceType[name='" + name + "',
plugin='" + plugin + "'" + "]";
}
}
public static class Resource implements Serializable {
+ //no args
+ public Resource() {
+ }
private static final long serialVersionUID = 1L;
private int id;
private String name;
private ResourceType type;
-
+
/**
* @param id
* @param name
@@ -112,22 +118,27 @@ public class DisambiguationReport<T> implements Serializable
{
public ResourceType getType() {
return type;
}
-
+
public String toString() {
return "Resource[id=" + id + ", name='" + name +
"', type=" + type + "]";
}
}
-
+
+ public DisambiguationReport() {
+ }
+
public DisambiguationReport(T original, List<Resource> parents, ResourceType
resourceType) {
this.original = original;
- this.parents = Collections.unmodifiableList(parents);
+ // this.parents = Collections.unmodifiableList(parents);
+ //spinder: the returned type is not Serializable and causes GWT serialization
errors.
+ this.parents = parents;
this.resourceType = resourceType;
}
public T getOriginal() {
return original;
}
-
+
/**
* @return the list of parents to disambiguate the original. Empty if no
disambiguation using
* parents is needed.
@@ -143,7 +154,7 @@ public class DisambiguationReport<T> implements Serializable {
public ResourceType getResourceType() {
return resourceType;
}
-
+
public String toString() {
return "DisambiguationReport(type=" + resourceType + ",
parents=" + parents + ", original=" + original + ")";
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index 30811cd..d4deaca 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -48,6 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.ProblemResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedView;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryView;
@@ -227,9 +228,9 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
// DashboardPortlet operations = new
DashboardPortlet("Operations", RecentlyAddedView.KEY, 250);
// dashboard.addPortlet(operations, 1, 5);
- // DashboardPortlet hasAlertsCurrentlyUnavailable = new
DashboardPortlet("Has Alerts or Currently Unavailable",
- // UnavailabilityPortlet.KEY, 250);
- // dashboard.addPortlet(hasAlertsCurrentlyUnavailable, 1, 5);
+ DashboardPortlet hasAlertsCurrentlyUnavailable = new DashboardPortlet("Has
Alerts or Currently Unavailable",
+ ProblemResourcesPortlet.KEY, 250);
+ dashboard.addPortlet(hasAlertsCurrentlyUnavailable, 1, 5);
return dashboard;
@@ -289,15 +290,16 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
public void renderView(ViewPath viewPath) {
if (!viewPath.isEnd()) {
selectedTab = viewPath.getCurrent().getPath();
- System.out.println("#################:" + selectedTab +
":tabset:" + tabSet);
- // if (tabSet != null) {
- for (Tab tab : tabSet.getTabs()) {
- // if (selectedTab.equals(tab.getTitle())) {
- if (tab.getTitle().equals(selectedTab)) {
- tabSet.selectTab(tab);
+ //added to avoid NPE in gwt debug window.
+ if (tabSet != null) {
+ for (Tab tab : tabSet.getTabs()) {
+ if (tab.getTitle().equals(selectedTab)) {
+ tabSet.selectTab(tab);
+ }
}
+ } else {
+ System.out.println("WARN: While rendering DashboardsView tabSet is
null.");
}
- // }
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 7d208f1..a676bae 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -30,9 +30,10 @@ import org.rhq.core.domain.dashboard.DashboardPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.FavoriteResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.ProblemResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedView;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformPortletView;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryView;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.TagCloudPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MashupPortlet;
@@ -43,13 +44,11 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePort
*/
public class PortletFactory {
-
private static Map<String, PortletViewFactory> registeredPortlets;
static {
registeredPortlets = new HashMap<String, PortletViewFactory>();
-
registeredPortlets.put(InventorySummaryView.KEY,
InventorySummaryView.Factory.INSTANCE);
registeredPortlets.put(RecentlyAddedView.KEY,
RecentlyAddedView.Factory.INSTANCE);
registeredPortlets.put(PlatformPortletView.KEY,
PlatformPortletView.Factory.INSTANCE);
@@ -66,11 +65,11 @@ public class PortletFactory {
registeredPortlets.put(MashupPortlet.KEY, MashupPortlet.Factory.INSTANCE);
registeredPortlets.put(MessagePortlet.KEY, MessagePortlet.Factory.INSTANCE);
+ registeredPortlets.put(ProblemResourcesPortlet.KEY,
ProblemResourcesPortlet.Factory.INSTANCE);
}
public static Portlet buildPortlet(PortletWindow portletWindow, DashboardPortlet
storedPortlet) {
-
PortletViewFactory viewFactory =
registeredPortlets.get(storedPortlet.getPortletKey());
Canvas canvas = null;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/ProblemResourcesPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/ProblemResourcesPortlet.java
new file mode 100644
index 0000000..2d7ad0e
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/ProblemResourcesPortlet.java
@@ -0,0 +1,85 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
+
+/**
+ * A view that displays a paginated table of fired {@link org.rhq.core.domain.alert.Alert
alert}s,
+ * and Resources reported unavailable.
+ *
+ * @author Simeon Pinder
+ */
+public class ProblemResourcesPortlet extends VLayout implements Portlet {
+
+ public static final String KEY = "Has Alerts or Currently Unavailable";
+ private static final String TITLE = KEY;
+
+ public ProblemResourcesPortlet() {
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // Add the list table as the top half of the view.
+ ListGrid listGrid = new ListGrid();
+ listGrid.setDataSource(new ProblemResourcesDataSource());
+ listGrid.setAutoFetchData(true);
+ listGrid.setTitle(TITLE);
+ listGrid.setResizeFieldsInRealTime(true);
+ addMember(listGrid);
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ // TODO implement this.
+
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays resources that have reported
alerts or Down availability.");
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance() {
+ return GWT.create(ProblemResourcesPortlet.class);
+ }
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
deleted file mode 100644
index 12cd480..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
-
-/*
- * RHQ Management Platform
- * Copyright (C) 2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-import com.google.gwt.core.client.GWT;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
-
-/**
- * A view that displays a paginated table of fired {@link org.rhq.core.domain.alert.Alert
alert}s,
- * and Resources reported unavailable.
- *
- * @author Simeon Pinder
- */
-public class UnavailabilityPortlet extends VLayout implements Portlet {
-
- public static final String KEY = "Currently Unavailable";
- private static final String TITLE = KEY;
-
- public UnavailabilityPortlet() {
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- // Add the list table as the top half of the view.
- ListGrid listGrid = new ListGrid();
- listGrid.setDataSource(new ProblemResourcesDataSource());
- listGrid.setAutoFetchData(true);
- listGrid.setTitle(TITLE);
- listGrid.setResizeFieldsInRealTime(true);
- // listGrid.getField("resourceName").setCellFormatter(new
CellFormatter() {
- // public String format(Object o, ListGridRecord listGridRecord, int
i, int i1) {
- // return "<a href=\"#Resource/" +
listGridRecord.getAttribute("resourceId") + "\">" + o +
"</a>";
- // }
- // });
- addMember(listGrid);
-
- }
-
- @Override
- public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
- // TODO implement this.
-
- }
-
- @Override
- public Canvas getHelpCanvas() {
- return new HTMLFlow("This portlet displays resources that have reported Down
availability.");
- }
-
- public DynamicForm getCustomSettingsForm() {
- return null;
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
-
- public final Portlet getInstance() {
- return GWT.create(UnavailabilityPortlet.class);
- }
- }
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index 4c7fce5..fefa85f 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -28,6 +28,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceComposite;
@@ -49,7 +50,7 @@ public interface ResourceGWTService extends RemoteService {
List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int
maxItems);
- List<ProblemResourceComposite> findProblemResources(ResourceCriteria
criteria);
+ List<DisambiguationReport<ProblemResourceComposite>>
findProblemResources(ResourceCriteria criteria);
Resource getPlatformForResource(int resourceId);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 470faf1..ccc620a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -1,6 +1,23 @@
package org.rhq.enterprise.gui.coregui.client.resource;
-import java.util.ArrayList;
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -8,6 +25,7 @@ import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
@@ -15,15 +33,22 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+/** Responsible for defining and populating the Smart GWT datasource details and
+ * translating the deserialized content into specific record entries for display
+ *
+ * @author spinder
+ */
public class ProblemResourcesDataSource extends DataSource {
- public final String resource = "resource";
- public final String location = "location";
- public final String alerts = "alerts";
- public final String available = "available";
+ public static final String resource = "resource";
+ public static final String location = "location";
+ public static final String alerts = "alerts";
+ public static final String available = "available";
/** Build list of fields for the datasource and then adds them to it.
*/
@@ -39,7 +64,7 @@ public class ProblemResourcesDataSource extends DataSource {
DataSourceTextField alertsField = new DataSourceTextField(alerts,
"Alerts");
- DataSourceTextField availablilityField = new DataSourceTextField(available,
"Current Availability");
+ DataSourceImageField availablilityField = new DataSourceImageField(available,
"Current Availability");
setFields(resourceField, locationField, alertsField, availablilityField);
}
@@ -72,74 +97,62 @@ public class ProblemResourcesDataSource extends DataSource {
public void executeFetch(final DSRequest request, final DSResponse response) {
ResourceCriteria c = new ResourceCriteria();
- c.addFilterCurrentAvailability(AvailabilityType.DOWN);
-
- // GWTServiceLookup.getResourceService().findRecentlyAddedResources(0,
100,
GWTServiceLookup.getResourceService().findProblemResources(c,
- // new
AsyncCallback<List<RecentlyAddedResourceComposite>>() {
- new AsyncCallback<List<ProblemResourceComposite>>() {
+ new
AsyncCallback<List<DisambiguationReport<ProblemResourceComposite>>>() {
+
public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to load
unavailable resources", throwable);
+ CoreGUI.getErrorHandler().handleError("Failed to load resources
with alerts/unavailability.",
+ throwable);
}
- // public void
onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) {
- public void onSuccess(List<ProblemResourceComposite>
problemResourcesList) {
- // List<RecentlyAddedResourceComposite> list
= new ArrayList<RecentlyAddedResourceComposite>();
- List<ProblemResourceComposite> list = new
ArrayList<ProblemResourceComposite>();
+ public void
onSuccess(List<DisambiguationReport<ProblemResourceComposite>>
problemResourcesList) {
- // for (RecentlyAddedResourceComposite
recentlyAdded : problemResourcesList) {
- for (ProblemResourceComposite problemResource : problemResourcesList)
{
- list.add(problemResource);
- //
list.addAll(problemResource.getChildren());
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(problemResourcesList));
+ //entry count
+ if (null != problemResourcesList) {
+ response.setTotalRows(problemResourcesList.size());
+ } else {
+ response.setTotalRows(0);
}
-
- // response.setData(buildNodes(list));
- response.setData(buildList(list));
- response.setTotalRows(list.size());
+ //pass off for processing
processResponse(request.getRequestId(), response);
}
});
- //
- // GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new
AsyncCallback<PageList<Resource>>() {
- // public void onFailure(Throwable caught) {
- // CoreGUI.getErrorHandler().handleError("Failed to load
recently added resources data",caught);
- // response.setStatus(DSResponse.STATUS_FAILURE);
- // processResponse(request.getRequestId(), response);
- // }
- //
- // public void onSuccess(PageList<Resource> result) {
- // PageList<Resource> all = new PageList<Resource>();
- //
- // for (Resource root : result) {
- // all.add(root);
- // if (root.getChildResources() != null)
- // all.addAll(root.getChildResources());
- // }
- //
- //
- // response.setData(buildNodes(all));
- // response.setTotalRows(all.getTotalSize());
- // processResponse(request.getRequestId(), response);
- // }
- // });
}
- protected Record[] buildList(List<ProblemResourceComposite> list) {
+ /** Translates the DisambiguationReport of ProblemResourceComposites into specific
+ * and ordered record values.
+ *
+ * @param list DisambiguationReport of entries.
+ * @return Record[] ordered record entries.
+ */
+ protected Record[]
buildList(List<DisambiguationReport<ProblemResourceComposite>> list) {
+
ListGridRecord[] dataValues = null;
if (list != null) {
dataValues = new ListGridRecord[list.size()];
int indx = 0;
- for (ProblemResourceComposite prc : list) {
+
+ for (DisambiguationReport<ProblemResourceComposite> report : list) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute(resource, prc.getResourceId());
- record.setAttribute(location, prc.getResourceName());
- record.setAttribute(alerts, prc.getNumAlerts());
- // record.setAttribute(available,
DateTimeFormat.getMediumDateTimeFormat().format(dateAdded));
- record.setAttribute(available, prc.getAvailabilityType().getName());
+ //disambiguated Resource name, decorated with html anchors to problem
resources
+ record.setAttribute(resource,
ReportDecorator.decorateResourceName(report.getResourceType(), report
+ .getOriginal().getResourceName(),
report.getOriginal().getResourceId()));
+ //disambiguated resource lineage, decorated with html anchors
+ record.setAttribute(location,
ReportDecorator.decorateResourceLineage(report.getParents()));
+ //alert cnt.
+ record.setAttribute(alerts, report.getOriginal().getNumAlerts());
+ //populate availability icon
+ if
(report.getOriginal().getAvailabilityType().compareTo(AvailabilityType.DOWN) == 0) {
+ record.setAttribute(available,
"/images/icons/availability_red_16.png");
+ } else {
+ record.setAttribute(available,
"/images/icons/availability_green_16.png");
+ }
+
dataValues[indx++] = record;
}
}
return dataValues;
}
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/disambiguation/ReportDecorator.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/disambiguation/ReportDecorator.java
new file mode 100644
index 0000000..ff50f1f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/disambiguation/ReportDecorator.java
@@ -0,0 +1,94 @@
+package org.rhq.enterprise.gui.coregui.client.resource.disambiguation;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
+import org.rhq.core.domain.resource.composite.DisambiguationReport.Resource;
+import org.rhq.core.domain.resource.composite.DisambiguationReport.ResourceType;
+
+/**
+ * Class handles some of the data decoration that used to be done for legacy struts
+ * tags. See
org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceLineageDecorator and
+ * org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceLineageTag
+ * for original functionality.
+ *
+ * @author Simeon Pinder
+ */
+public class ReportDecorator {
+
+ //TODO: pull value from more bookmarking/history definition
+ public final static String GWT_RESOURCE_URL =
"/coregui/CoreGUI.html#Resource/";
+ public static final String DEFAULT_SEPARATOR = " > ";
+
+ /** Generates HTML label from DisambiguationReport data.
+ *
+ * @param ResourceType type. If !null, the ResourceType name is prepended to
result.
+ * @param resourceName Name of the element from report
+ * @param resourceId Id for resource
+ * @return String of generated html for a ResourceName.
+ */
+ public static String decorateResourceName(ResourceType type, String resourceName, int
resourceId) {
+ String decorated = "";
+ if (type != null) {
+ decorated += type.getName();
+ }
+ decorated += " <a href=\"" + GWT_RESOURCE_URL + resourceId +
"\">" + resourceName + "</a>";
+ return decorated;
+ }
+
+ /** Generates Html label of Resource Lineage for disambiguation.
+ *
+ * @param parents ResourceLineage provided by DisambiguationReport.
+ * @return String of generated html for ResourceLineage.
+ */
+ public static String decorateResourceLineage(List<Resource> parents) {
+ StringBuffer decorated = new StringBuffer();
+ if (parents != null && parents.size() > 0) {
+
+ Iterator<DisambiguationReport.Resource> it = parents.iterator();
+ DisambiguationReport.Resource parent = it.next();
+ //generate first link
+ String parentUrl = ReportDecorator.decorateResourceName(null,
parent.getName(), parent.getId());
+ decorated = writeResource(decorated, parentUrl, parent.getName(),
parent.getType());
+ while (it.hasNext()) {
+ decorated.append(DEFAULT_SEPARATOR);
+ parent = it.next();
+ decorated = writeResource(decorated,
ReportDecorator.decorateResourceName(null, parent.getName(),
+ parent.getId()), parent.getName(), parent.getType());
+
+ }
+ }
+ return decorated.toString();
+ }
+
+ /** Appends resource lineage details with html anchors.
+ *
+ * @param existing
+ * @param url
+ * @param resourceName
+ * @param resourceType
+ * @return
+ */
+ private static StringBuffer writeResource(StringBuffer existing, String url, String
resourceName,
+ DisambiguationReport.ResourceType resourceType) {
+ if (!resourceType.isSingleton()) {
+
+ existing.append(resourceType.getName()).append(" ");
+
+ if (resourceType.getPlugin() != null) {
+
existing.append("(").append(resourceType.getPlugin()).append(" plugin)
");
+ }
+ }
+
+ if (url != null) {
+ existing.append(url);
+ }
+
+ if (resourceType.isSingleton() && resourceType.getPlugin() != null) {
+ existing.append("
(").append(resourceType.getPlugin()).append(" plugin)");
+ }
+ return existing;
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
index aa2c7dd..cc144f8 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/selenium/LocatableVLayout.java
@@ -18,7 +18,7 @@ public class LocatableVLayout extends VLayout {
public LocatableVLayout(String id) {
super();
String locatorId = this.getScClassName() + "-" + id;
- setID(SeleniumUtility.getSafeId(locatorId, locatorId));
+ // setID(SeleniumUtility.getSafeId(locatorId, locatorId));
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index c9196db..240e523 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -35,16 +35,20 @@ import
org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.DisambiguationReport;
import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.IntExtractor;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
+import org.rhq.enterprise.server.measurement.MeasurementProblemManagerLocal;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import
org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -139,19 +143,30 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
}
}
- public List<ProblemResourceComposite> findProblemResources(ResourceCriteria
criteria) {
+ /** Locate ProblemResourcesComposites and generate the disambiguation reports for
them.
+ * Criteria passed in not currently used.
+ */
+ public List<DisambiguationReport<ProblemResourceComposite>>
findProblemResources(ResourceCriteria criteria) {
+
List<ProblemResourceComposite> located = new
ArrayList<ProblemResourceComposite>();
- PageList<ResourceComposite> pageList =
findResourceCompositesByCriteria(criteria);
- if (!pageList.isEmpty()) {
- for (ResourceComposite rc : pageList) {
- ProblemResourceComposite prc = new
ProblemResourceComposite(rc.getResource().getId(), rc.getResource()
- .getName(), rc.getAvailability(), 0);
- //TODO: spinder: replace last argument with alert count for this
resource.
- }
- }
- return located;
+ MeasurementProblemManagerLocal problemManager =
LookupUtil.getMeasurementProblemManager();
+ ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+
+ //retrieve list of discovered problem resources. Grab all, live scrolling data
+ located = problemManager.findProblemResources(getSessionSubject(), 0, new
PageControl(0, -1));
+
+ //translate the returned problem resources to disambiguated links
+ List<DisambiguationReport<ProblemResourceComposite>> translated =
resourceManager.disambiguate(located,
+ RESOURCE_ID_EXTRACTOR, DefaultDisambiguationUpdateStrategies.getDefault());
+ return translated;
}
+ private static final IntExtractor<ProblemResourceComposite>
RESOURCE_ID_EXTRACTOR = new IntExtractor<ProblemResourceComposite>() {
+ public int extract(ProblemResourceComposite object) {
+ return object.getResourceId();
+ }
+ };
+
public List<Resource> getResourceLineage(int resourceId) {
return SerialUtility.prepare(resourceManager.getResourceLineage(resourceId),
"ResourceService.getResourceLineage");
@@ -180,15 +195,6 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
return platforms;
}
- // @Override
- // public List<ProblemResourceComposite> findProblemResources(long ctime,
int maxItems) {
- // List<ProblemResourceComposite> problems =
- // resourceManager.findResourceCompositesByCriteria(getSessionSubject(),
criteria)(
- // getSessionSubject(), ctime, maxItems);
- //
- // return problems;
- // }
-
public List<Integer> uninventoryResources(int[] resourceIds) {
return
SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(),
resourceIds),
"ResourceService.uninventoryResources");
commit 3aa4bd2d096eb3195d846646cae3f2b292c814d2
Merge: 4bd7b73... 66234db...
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Aug 24 05:23:19 2010 -0400
Merge branch 'master' of ssh://spinder@git.fedorahosted.org/git/rhq/rhq into
spinder-track
diff --cc
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index c5effa7,90b795e..33d32b3
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@@ -60,11 -58,9 +58,9 @@@ import org.rhq.enterprise.gui.coregui.c
* @author Ian Springer
*/
public class AlertDataSource extends RPCDataSource<Alert> {
- private static final DateTimeFormat DATE_TIME_FORMAT =
DateTimeFormat.getMediumDateTimeFormat();
-
private AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService();
- protected AlertDataSource() {
+ public AlertDataSource() {
super();
setCanMultiSort(true);
commit 4bd7b730b2362d96f126e36bec397eec987d2c15
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Aug 19 15:57:09 2010 -0400
UnavailibilityPortlet start
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index 3369352..c5effa7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -64,7 +64,7 @@ public class AlertDataSource extends RPCDataSource<Alert> {
private AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService();
- protected AlertDataSource() {
+ public AlertDataSource() {
super();
setCanMultiSort(true);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index a82393c..30811cd 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -75,7 +75,6 @@ public class DashboardsView extends VLayout implements BookmarkableView
{
private DashboardGWTServiceAsync dashboardService =
GWTServiceLookup.getDashboardService();
-
private String selectedTab;
public DashboardsView() {
@@ -108,7 +107,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
removeMembers(getMembers());
this.dashboards = dashboards;
-
tabSet = new TabSet();
tabSet.setWidth100();
@@ -116,7 +114,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
tabSet.setCanCloseTabs(true);
-
editButton = new IButton(editMode ? "View Mode" : "Edit
Mode");
editButton.setAutoFit(true);
editButton.addClickHandler(new ClickHandler() {
@@ -127,7 +124,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
}
});
-
final IButton newDashboardButton = new IButton("New Dashboard");
newDashboardButton.setAutoFit(true);
newDashboardButton.addClickHandler(new ClickHandler() {
@@ -142,7 +138,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
tabSet.setTabBarControls(buttons);
-
tabSet.addTabSelectedHandler(new TabSelectedHandler() {
public void onTabSelected(TabSelectedEvent tabSelectedEvent) {
History.newItem("Dashboard/" +
tabSelectedEvent.getTab().getTitle(), false);
@@ -159,7 +154,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
tab.setPane(dashboardView);
tab.setCanClose(true);
-
tabSet.addTab(tab);
if (dashboard.getName().equals(selectedTab)) {
tabSet.selectTab(tab);
@@ -169,15 +163,16 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
tabSet.addCloseClickHandler(new CloseClickHandler() {
public void onCloseClick(final TabCloseClickEvent tabCloseClickEvent) {
final DashboardView dashboardView = (DashboardView)
tabCloseClickEvent.getTab().getPane();
- SC.ask("Are you sure you want to delete [" +
tabCloseClickEvent.getTab().getTitle() + "]?", new BooleanCallback() {
- public void execute(Boolean aBoolean) {
- if (aBoolean) {
- dashboardView.delete();
- } else {
- tabCloseClickEvent.cancel();
+ SC.ask("Are you sure you want to delete [" +
tabCloseClickEvent.getTab().getTitle() + "]?",
+ new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ dashboardView.delete();
+ } else {
+ tabCloseClickEvent.cancel();
+ }
}
- }
- });
+ });
}
});
@@ -185,7 +180,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
}
-
protected Dashboard getDefaultDashboard() {
Dashboard dashboard = new Dashboard();
@@ -194,7 +188,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
dashboard.setColumnWidths("32%", "68%");
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
-
DashboardPortlet summary = new DashboardPortlet("Inventory Summary",
InventorySummaryView.KEY, 230);
dashboard.addPortlet(summary, 0, 0);
@@ -202,40 +195,46 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
dashboard.addPortlet(tagCloud, 0, 1);
// Experimental
-// StoredPortlet platformSummary = new StoredPortlet("Platform Summary",
PlatformPortletView.KEY, 300);
-// col2.add(platformSummary);
-
+ // StoredPortlet platformSummary = new StoredPortlet("Platform
Summary", PlatformPortletView.KEY, 300);
+ // col2.add(platformSummary);
DashboardPortlet welcome = new DashboardPortlet("Welcome To RHQ",
MessagePortlet.KEY, 180);
- welcome.getConfiguration().put(new PropertySimple("message",
"<h1>Welcome to RHQ</h1>\n" +
- "<p>The RHQ project is an abstraction and plug-in based
systems management suite that provides " +
- "extensible and integrated systems management for multiple products
and platforms across a set " +
- "of core features. The project is designed with layered modules that
provide a flexible " +
- "architecture for deployment. It delivers a core user interface that
delivers audited and " +
- "historical management across an entire enterprise. A Server/Agent
architecture provides " +
- "remote management and plugins implement all specific support for
managed products.</p>\n" +
- "<p>This default dashboard can be edited by clicking the
\"edit mode\" button above.</p>"));
+ welcome.getConfiguration().put(
+ new PropertySimple("message", "<h1>Welcome to
RHQ</h1>\n"
+ + "<p>The RHQ project is an abstraction and plug-in based
systems management suite that provides "
+ + "extensible and integrated systems management for multiple
products and platforms across a set "
+ + "of core features. The project is designed with layered modules
that provide a flexible "
+ + "architecture for deployment. It delivers a core user interface
that delivers audited and "
+ + "historical management across an entire enterprise. A Server/Agent
architecture provides "
+ + "remote management and plugins implement all specific support for
managed products.</p>\n"
+ + "<p>This default dashboard can be edited by clicking the
\"edit mode\" button above.</p>"));
dashboard.addPortlet(welcome, 1, 0);
DashboardPortlet news = new DashboardPortlet("RHQ News",
MashupPortlet.KEY, 320);
- news.getConfiguration().put(new PropertySimple("address",
"http://rhq-project.org/display/RHQ/RHQ+News?decorator=popup"));
+ news.getConfiguration().put(
+ new PropertySimple("address",
"http://rhq-project.org/display/RHQ/RHQ+News?decorator=popup"));
dashboard.addPortlet(news, 1, 1);
-//
+ //
DashboardPortlet discoveryQueue = new DashboardPortlet("Discovery
Queue", AutodiscoveryPortlet.KEY, 250);
dashboard.addPortlet(discoveryQueue, 1, 2);
-
DashboardPortlet recentAlerts = new DashboardPortlet("Recent Alerts",
RecentAlertsPortlet.KEY, 250);
dashboard.addPortlet(recentAlerts, 1, 3);
DashboardPortlet recentlyAdded = new DashboardPortlet("Recently Added
Resources", RecentlyAddedView.KEY, 250);
dashboard.addPortlet(recentlyAdded, 1, 4);
+ // DashboardPortlet operations = new
DashboardPortlet("Operations", RecentlyAddedView.KEY, 250);
+ // dashboard.addPortlet(operations, 1, 5);
+
+ // DashboardPortlet hasAlertsCurrentlyUnavailable = new
DashboardPortlet("Has Alerts or Currently Unavailable",
+ // UnavailabilityPortlet.KEY, 250);
+ // dashboard.addPortlet(hasAlertsCurrentlyUnavailable, 1, 5);
+
return dashboard;
}
-
public void addNewDashboard() {
Dashboard dashboard = new Dashboard();
@@ -276,7 +275,6 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
editButton.setTitle(editMode ? "View Mode" : "Edit
Mode");
dashboardView.setEditMode(editMode);
-
}
});
}
@@ -288,15 +286,18 @@ public class DashboardsView extends VLayout implements
BookmarkableView {
}
}
-
public void renderView(ViewPath viewPath) {
if (!viewPath.isEnd()) {
selectedTab = viewPath.getCurrent().getPath();
+ System.out.println("#################:" + selectedTab +
":tabset:" + tabSet);
+ // if (tabSet != null) {
for (Tab tab : tabSet.getTabs()) {
- if (selectedTab.equals(tab.getTitle())) {
+ // if (selectedTab.equals(tab.getTitle())) {
+ if (tab.getTitle().equals(selectedTab)) {
tabSet.selectTab(tab);
}
}
+ // }
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
new file mode 100644
index 0000000..12cd480
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/UnavailabilityPortlet.java
@@ -0,0 +1,91 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+import com.google.gwt.core.client.GWT;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource;
+
+/**
+ * A view that displays a paginated table of fired {@link org.rhq.core.domain.alert.Alert
alert}s,
+ * and Resources reported unavailable.
+ *
+ * @author Simeon Pinder
+ */
+public class UnavailabilityPortlet extends VLayout implements Portlet {
+
+ public static final String KEY = "Currently Unavailable";
+ private static final String TITLE = KEY;
+
+ public UnavailabilityPortlet() {
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // Add the list table as the top half of the view.
+ ListGrid listGrid = new ListGrid();
+ listGrid.setDataSource(new ProblemResourcesDataSource());
+ listGrid.setAutoFetchData(true);
+ listGrid.setTitle(TITLE);
+ listGrid.setResizeFieldsInRealTime(true);
+ // listGrid.getField("resourceName").setCellFormatter(new
CellFormatter() {
+ // public String format(Object o, ListGridRecord listGridRecord, int
i, int i1) {
+ // return "<a href=\"#Resource/" +
listGridRecord.getAttribute("resourceId") + "\">" + o +
"</a>";
+ // }
+ // });
+ addMember(listGrid);
+
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ // TODO implement this.
+
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow("This portlet displays resources that have reported Down
availability.");
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ return null;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance() {
+ return GWT.create(UnavailabilityPortlet.class);
+ }
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index f92e7d5..4c7fce5 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -28,6 +28,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageControl;
@@ -48,6 +49,8 @@ public interface ResourceGWTService extends RemoteService {
List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int
maxItems);
+ List<ProblemResourceComposite> findProblemResources(ResourceCriteria
criteria);
+
Resource getPlatformForResource(int resourceId);
List<Integer> uninventoryResources(int[] resourceIds);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
new file mode 100644
index 0000000..470faf1
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -0,0 +1,145 @@
+package org.rhq.enterprise.gui.coregui.client.resource;
+
+import java.util.ArrayList;
+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.DataSource;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.types.DSDataFormat;
+import com.smartgwt.client.types.DSProtocol;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
+public class ProblemResourcesDataSource extends DataSource {
+ public final String resource = "resource";
+ public final String location = "location";
+ public final String alerts = "alerts";
+ public final String available = "available";
+
+ /** Build list of fields for the datasource and then adds them to it.
+ */
+ public ProblemResourcesDataSource() {
+ setClientOnly(false);
+ setDataProtocol(DSProtocol.CLIENTCUSTOM);
+ setDataFormat(DSDataFormat.CUSTOM);
+
+ DataSourceTextField resourceField = new DataSourceTextField(resource,
"Resource");
+ resourceField.setPrimaryKey(true);
+
+ DataSourceTextField locationField = new DataSourceTextField(location,
"Location");
+
+ DataSourceTextField alertsField = new DataSourceTextField(alerts,
"Alerts");
+
+ DataSourceTextField availablilityField = new DataSourceTextField(available,
"Current Availability");
+
+ setFields(resourceField, locationField, alertsField, availablilityField);
+ }
+
+ /* Intercept DSRequest object to pipe into custom fetch request.
+ * (non-Javadoc)
+ * @see
com.smartgwt.client.data.DataSource#transformRequest(com.smartgwt.client.data.DSRequest)
+ */
+ protected Object transformRequest(DSRequest request) {
+ DSResponse response = new DSResponse();
+ response.setAttribute("clientContext",
request.getAttributeAsObject("clientContext"));
+ // Assume success
+ response.setStatus(0);
+ switch (request.getOperationType()) {
+ case FETCH:
+ executeFetch(request, response);
+ break;
+ default:
+ break;
+ }
+
+ return request.getData();
+ }
+
+ /** Fetch the ProblemResource data, and populate the response object appropriately.
+ *
+ * @param request incoming request
+ * @param response outgoing response
+ */
+ public void executeFetch(final DSRequest request, final DSResponse response) {
+
+ ResourceCriteria c = new ResourceCriteria();
+ c.addFilterCurrentAvailability(AvailabilityType.DOWN);
+
+ // GWTServiceLookup.getResourceService().findRecentlyAddedResources(0,
100,
+ GWTServiceLookup.getResourceService().findProblemResources(c,
+ // new
AsyncCallback<List<RecentlyAddedResourceComposite>>() {
+ new AsyncCallback<List<ProblemResourceComposite>>() {
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load
unavailable resources", throwable);
+ }
+
+ // public void
onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) {
+ public void onSuccess(List<ProblemResourceComposite>
problemResourcesList) {
+ // List<RecentlyAddedResourceComposite> list
= new ArrayList<RecentlyAddedResourceComposite>();
+ List<ProblemResourceComposite> list = new
ArrayList<ProblemResourceComposite>();
+
+ // for (RecentlyAddedResourceComposite
recentlyAdded : problemResourcesList) {
+ for (ProblemResourceComposite problemResource : problemResourcesList)
{
+ list.add(problemResource);
+ //
list.addAll(problemResource.getChildren());
+ }
+
+ // response.setData(buildNodes(list));
+ response.setData(buildList(list));
+ response.setTotalRows(list.size());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ //
+ // GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new
AsyncCallback<PageList<Resource>>() {
+ // public void onFailure(Throwable caught) {
+ // CoreGUI.getErrorHandler().handleError("Failed to load
recently added resources data",caught);
+ // response.setStatus(DSResponse.STATUS_FAILURE);
+ // processResponse(request.getRequestId(), response);
+ // }
+ //
+ // public void onSuccess(PageList<Resource> result) {
+ // PageList<Resource> all = new PageList<Resource>();
+ //
+ // for (Resource root : result) {
+ // all.add(root);
+ // if (root.getChildResources() != null)
+ // all.addAll(root.getChildResources());
+ // }
+ //
+ //
+ // response.setData(buildNodes(all));
+ // response.setTotalRows(all.getTotalSize());
+ // processResponse(request.getRequestId(), response);
+ // }
+ // });
+ }
+
+ protected Record[] buildList(List<ProblemResourceComposite> list) {
+ ListGridRecord[] dataValues = null;
+ if (list != null) {
+ dataValues = new ListGridRecord[list.size()];
+ int indx = 0;
+ for (ProblemResourceComposite prc : list) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(resource, prc.getResourceId());
+ record.setAttribute(location, prc.getResourceName());
+ record.setAttribute(alerts, prc.getNumAlerts());
+ // record.setAttribute(available,
DateTimeFormat.getMediumDateTimeFormat().format(dateAdded));
+ record.setAttribute(available, prc.getAvailabilityType().getName());
+ dataValues[indx++] = record;
+ }
+ }
+ return dataValues;
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index c10254e..c9196db 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -35,6 +35,7 @@ import
org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ProblemResourceComposite;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageControl;
@@ -124,7 +125,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
public PageList<ResourceComposite>
findResourceCompositesByCriteria(ResourceCriteria criteria) {
try {
PageList<ResourceComposite> result =
resourceManager.findResourceCompositesByCriteria(getSessionSubject(),
- criteria);
+ criteria);
List<Resource> resources = new
ArrayList<Resource>(result.size());
if (resources.size() > 1) {
@@ -138,6 +139,19 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
}
}
+ public List<ProblemResourceComposite> findProblemResources(ResourceCriteria
criteria) {
+ List<ProblemResourceComposite> located = new
ArrayList<ProblemResourceComposite>();
+ PageList<ResourceComposite> pageList =
findResourceCompositesByCriteria(criteria);
+ if (!pageList.isEmpty()) {
+ for (ResourceComposite rc : pageList) {
+ ProblemResourceComposite prc = new
ProblemResourceComposite(rc.getResource().getId(), rc.getResource()
+ .getName(), rc.getAvailability(), 0);
+ //TODO: spinder: replace last argument with alert count for this
resource.
+ }
+ }
+ return located;
+ }
+
public List<Resource> getResourceLineage(int resourceId) {
return SerialUtility.prepare(resourceManager.getResourceLineage(resourceId),
"ResourceService.getResourceLineage");
@@ -166,6 +180,15 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
return platforms;
}
+ // @Override
+ // public List<ProblemResourceComposite> findProblemResources(long ctime,
int maxItems) {
+ // List<ProblemResourceComposite> problems =
+ // resourceManager.findResourceCompositesByCriteria(getSessionSubject(),
criteria)(
+ // getSessionSubject(), ctime, maxItems);
+ //
+ // return problems;
+ // }
+
public List<Integer> uninventoryResources(int[] resourceIds) {
return
SerialUtility.prepare(resourceManager.uninventoryResources(getSessionSubject(),
resourceIds),
"ResourceService.uninventoryResources");
@@ -195,12 +218,8 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
}
public Map<Resource, List<Resource>>
getQueuedPlatformsAndServers(HashSet<InventoryStatus> statuses, PageControl pc) {
- return SerialUtility.prepare(
- discoveryBoss.getQueuedPlatformsAndServers(
- getSessionSubject(),
- EnumSet.copyOf(statuses),
- pc),
- "ResourceService.getQueuedPlatformsAndServers");
+ return
SerialUtility.prepare(discoveryBoss.getQueuedPlatformsAndServers(getSessionSubject(),
EnumSet
+ .copyOf(statuses), pc),
"ResourceService.getQueuedPlatformsAndServers");
}
public void importResources(Integer[] resourceIds) {
@@ -214,5 +233,5 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
public void unignoreResources(Integer[] resourceIds) {
discoveryBoss.unignoreResources(getSessionSubject(), resourceIds);
}
-
+
}
\ No newline at end of file