[rhq] modules/enterprise
by ips
modules/enterprise/gui/portal-war/src/main/webapp/admin/config/GeneralPropertiesConfigForm.jsp | 121 ++++++++++
1 file changed, 121 insertions(+)
New commits:
commit 57d628569b292363733e835dc0134072090f2555
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Oct 12 18:51:37 2010 -0400
replace missing Config properties file.
(cherry picked from commit 7158ea3bfd76b3041ed656660c57e206eb6148f2)
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/GeneralPropertiesConfigForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/GeneralPropertiesConfigForm.jsp
new file mode 100644
index 0000000..2c8a8a2
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/GeneralPropertiesConfigForm.jsp
@@ -0,0 +1,121 @@
+<%@ page language="java" %>
+<%@ page errorPage="/common/Error.jsp" %>
+
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/WEB-INF/tld/hq.tld" prefix="hq" %>
+
+<script src="<html:rewrite page="/js/"/>functions.js" type="text/javascript"></script>
+<link rel=stylesheet href="<html:rewrite page="/css/"/>win.css" type="text/css">
+
+<hq:constant
+ classname="org.rhq.enterprise.gui.legacy.Constants"
+ symbol="MINUTES_LABEL" var="CONST_MINUTES" />
+<hq:constant
+ classname="org.rhq.enterprise.gui.legacy.Constants"
+ symbol="HOURS_LABEL" var="CONST_HOURS" />
+<hq:constant
+ classname="org.rhq.enterprise.gui.legacy.Constants"
+ symbol="DAYS_LABEL" var="CONST_DAYS" />
+
+<!-- BASE SERVER CONFIG TITLE -->
+<tiles:insert definition=".header.tab">
+ <tiles:put name="tabKey" value="admin.settings.BaseConfigTab"/>
+</tiles:insert>
+<!-- / -->
+
+<!-- BASE SERVER CONFIG CONTENTS -->
+<table width="100%" cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td width="45%" class="BlockLabel"><fmt:message key="admin.settings.BaseURL"/></td>
+ <td width="55%" class="BlockContent"><html:text size="31" property="baseUrl" /></td>
+ </tr>
+ <tr>
+ <td class="BlockLabel"><fmt:message key="admin.settings.AgentMaxQuietTimeAllowed"/></td>
+ <td class="BlockContent">
+ <table width="100%" cellpadding="0" cellspacing="0" border="0">
+ <tr>
+<logic:messagesPresent property="agentMaxQuietTimeAllowedVal">
+ <td class="ErrorField">
+ <html:text size="2" property="agentMaxQuietTimeAllowedVal" />
+ </td>
+ <td class="ErrorField" width="100%">
+ <html:select property="agentMaxQuietTimeAllowed">
+ <html:option value="${CONST_MINUTES}"><fmt:message key="admin.settings.Minutes"/></html:option>
+ </html:select>
+ </td>
+</logic:messagesPresent>
+<logic:messagesNotPresent property="agentMaxQuietTimeAllowedVal">
+ <td class="BlockContent">
+ <html:text size="2" property="agentMaxQuietTimeAllowedVal" />
+ </td>
+ <td class="BlockContent" width="100%">
+ <html:select property="agentMaxQuietTimeAllowed">
+ <html:option value="${CONST_MINUTES}"><fmt:message key="admin.settings.Minutes"/></html:option>
+ </html:select>
+ </td>
+</logic:messagesNotPresent>
+ </tr>
+<logic:messagesPresent property="agentMaxQuietTimeAllowedVal">
+ <tr>
+ <td class="ErrorField" colspan="2">
+ <span class="ErrorFieldContent"> <html:errors property="agentMaxQuietTimeAllowedVal"/></span>
+ </td>
+ </tr>
+</logic:messagesPresent>
+<logic:messagesNotPresent property="agentMaxQuietTimeAllowedVal">
+ <tr>
+ <td class="BlockContent" colspan="2">
+ </td>
+ </tr>
+</logic:messagesNotPresent>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td class="BlockLabel"><fmt:message key="admin.settings.EnableAgentAutoUpdate"/></td>
+ <td class="BlockContent">
+ <table cellpadding="0" cellspacing="4" border="0">
+ <tr>
+ <td align="left"><html:radio property="enableAgentAutoUpdate" value="true"/><fmt:message key="yesno.true"/></td>
+ <td align="left"><html:radio property="enableAgentAutoUpdate" value="false"/><fmt:message key="yesno.false"/></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+<hq:authorization permission="superuser">
+ <tr>
+ <td class="BlockLabel"><fmt:message key="admin.settings.EnableDebugMode"/></td>
+ <td class="BlockContent">
+ <table cellpadding="0" cellspacing="4" border="0">
+ <tr>
+ <td align="left"><html:radio property="enableDebugMode" value="true"/><fmt:message key="yesno.true"/></td>
+ <td align="left"><html:radio property="enableDebugMode" value="false"/><fmt:message key="yesno.false"/></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</hq:authorization>
+
+<fmt:message var="productName" key="product.shortName" />
+<c:if test="${productName eq 'RHQ'}">
+<hq:authorization permission="superuser">
+ <tr>
+ <td class="BlockLabel"><fmt:message key="admin.settings.EnableExperimentalFeatures"/></td>
+ <td class="BlockContent">
+ <table cellpadding="0" cellspacing="4" border="0">
+ <tr>
+ <td align="left"><html:radio property="enableExperimentalFeatures" value="true"/><fmt:message key="yesno.true"/></td>
+ <td align="left"><html:radio property="enableExperimentalFeatures" value="false"/><fmt:message key="yesno.false"/></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</hq:authorization>
+</c:if>
+
+</table>
13 years, 6 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 55 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/InitializableView.java | 29
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java | 341 ++-------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java | 47 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java | 370 +++-------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java | 311 --------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java | 133 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java | 142 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 90 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java | 311 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java | 133 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java | 142 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java | 1
17 files changed, 1027 insertions(+), 1110 deletions(-)
New commits:
commit a943bf97ac60d3e8158b549d0e7abe19373e6e6f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Oct 28 13:51:16 2010 -0400
refactor AdministrationView and InventoryView to extend the new AbstractSectionedLeftNavigationView base class; add a new Test top view for lumping together various test views
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index dccab2c..a8bdeba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -27,6 +27,7 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window.Location;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.types.Overflow;
@@ -47,8 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceT
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
-import org.rhq.enterprise.gui.coregui.client.test.TestConfigurationView;
-import org.rhq.enterprise.gui.coregui.client.test.TestGroupConfigurationView;
+import org.rhq.enterprise.gui.coregui.client.test.TestTopView;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.WidgetUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageBar;
@@ -56,6 +56,8 @@ import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
+ * The GWT {@link EntryPoint entry point} to the RHQ GUI.
+ *
* @author Greg Hinkle
* @author Ian Springer
*/
@@ -192,11 +194,11 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
Canvas canvas;
if (breadcrumbName.equals(AdministrationView.VIEW_ID)) {
- canvas = new AdministrationView("Admin");
+ canvas = new AdministrationView();
} else if (breadcrumbName.equals(DemoCanvas.VIEW_ID)) {
canvas = new DemoCanvas();
} else if (breadcrumbName.equals(InventoryView.VIEW_ID)) {
- canvas = new InventoryView("Inventory");
+ canvas = new InventoryView();
} else if (breadcrumbName.equals(ResourceTopView.VIEW_ID)) {
canvas = new ResourceTopView("Resource");
} else if (breadcrumbName.equals(ResourceGroupTopView.VIEW_ID)) {
@@ -215,11 +217,9 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
} else if (breadcrumbName.equals("Subsystems")) {
canvas = new AlertHistoryView("Alert");
} else if (breadcrumbName.equals(ReportTopView.VIEW_ID)) {
- canvas = new ReportTopView("Report");
- } else if (breadcrumbName.equals(TestConfigurationView.VIEW_ID)) {
- canvas = new TestConfigurationView("TestConfig");
- } else if (breadcrumbName.equals(TestGroupConfigurationView.VIEW_ID)) {
- canvas = new TestGroupConfigurationView("TestGroupConfig");
+ canvas = new ReportTopView();
+ } else if (breadcrumbName.equals(TestTopView.VIEW_ID)) {
+ canvas = new TestTopView();
} else {
canvas = null;
}
@@ -306,7 +306,7 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
setHeight100();
}
- public void renderView(ViewPath viewPath) {
+ public void renderView(final ViewPath viewPath) {
if (viewPath.isEnd()) {
// default view
History.newItem(DEFAULT_VIEW_PATH);
@@ -321,19 +321,32 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
}
if (this.currentCanvas instanceof BookmarkableView) {
- ((BookmarkableView) this.currentCanvas).renderView(viewPath.next());
+ if (this.currentCanvas instanceof InitializableView) {
+ final InitializableView initializableView = (InitializableView)this.currentCanvas;
+ final long startTime = System.currentTimeMillis();
+ final Timer timer = new Timer() {
+ public void run() {
+ if (initializableView.isInitialized()) {
+ ((BookmarkableView)currentCanvas).renderView(viewPath.next());
+ } else {
+ long elapsedMillis = System.currentTimeMillis() - startTime;
+ if (elapsedMillis < 5000) {
+ // Reschedule the timer.
+ schedule(100);
+ }
+ }
+ }
+ };
+ if (initializableView.isInitialized()) {
+ ((BookmarkableView)currentCanvas).renderView(viewPath.next());
+ } else {
+ timer.schedule(100);
+ }
+ } else {
+ ((BookmarkableView)currentCanvas).renderView(viewPath.next());
+ }
}
- // reverting this is as it breaks rendering of single-element paths (like "#Bundles or
- // #Reports. the BookmarkableView's renderView needs to be invoked.
- //
- //if (this.currentCanvas instanceof BookmarkableView) {
- // viewPath.next();
- // if (!viewPath.isEnd()) {
- // ((BookmarkableView) this.currentCanvas).renderView(viewPath);
- // }
- //}
-
refreshBreadCrumbTrail();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/InitializableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/InitializableView.java
new file mode 100644
index 0000000..2420649
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/InitializableView.java
@@ -0,0 +1,29 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client;
+
+/**
+ * The SmartGWT BaseWidget class provides no way to check if the widget has completed its init()/onInit(), so
+ * components that wish to provide that information can implement this interface.
+ *
+ * @author Ian Springer
+ */
+public interface InitializableView {
+ boolean isInitialized();
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
index f622596..dcd6aea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/AdministrationView.java
@@ -18,39 +18,29 @@
*/
package org.rhq.enterprise.gui.coregui.client.admin;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
-import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.grid.events.CellClickEvent;
-import com.smartgwt.client.widgets.grid.events.CellClickHandler;
-import com.smartgwt.client.widgets.layout.SectionStack;
-import com.smartgwt.client.widgets.layout.SectionStackSection;
-import com.smartgwt.client.widgets.tree.Tree;
-import com.smartgwt.client.widgets.tree.TreeGrid;
-import com.smartgwt.client.widgets.tree.TreeNode;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ViewId;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.admin.agent.install.RemoteAgentInstallView;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
import org.rhq.enterprise.gui.coregui.client.admin.templates.ResourceTypeTreeView;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
-import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
+import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLeftNavigationView;
+import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem;
+import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
/**
+ * The Administration top-level view.
+ *
* @author Greg Hinkle
+ * @author Ian Springer
*/
-// TODO (ips, 10/28/10): Refactor this class to extend AbstractSectionedLeftNavigationView.
-public class AdministrationView extends LocatableHLayout implements BookmarkableView {
+public class AdministrationView extends AbstractSectionedLeftNavigationView {
public static final String VIEW_ID = "Administration";
private static final String SECTION_SECURITY_VIEW_ID = "Security";
@@ -69,258 +59,137 @@ public class AdministrationView extends LocatableHLayout implements Bookmarkable
private static final String PAGE_LICENSE_VIEW_ID = "License";
private static final String PAGE_PLUGINS_VIEW_ID = "Plugins";
- private ViewId currentSectionViewId;
- private ViewId currentPageViewId;
-
- private SectionStack sectionStack;
-
- private Canvas contentCanvas;
- private Canvas currentContent;
- private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>();
-
- public AdministrationView(String locatorId) {
- super(locatorId);
+ public AdministrationView() {
+ // This is a top level view, so our locator id can simply be our view id.
+ super(VIEW_ID);
}
@Override
- protected void onInit() {
- super.onInit();
+ protected List<NavigationSection> getNavigationSections() {
+ List<NavigationSection> sections = new ArrayList<NavigationSection>();
- setWidth100();
- setHeight100();
+ NavigationSection securitySection = buildSecuritySection();
+ sections.add(securitySection);
- contentCanvas = new Canvas();
- contentCanvas.setWidth("*");
- contentCanvas.setHeight100();
+ NavigationSection topologySection = buildTopologySection();
+ sections.add(topologySection);
- sectionStack = new LocatableSectionStack(this.getLocatorId());
- sectionStack.setShowResizeBar(true);
- sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
- sectionStack.setWidth(250);
- sectionStack.setHeight100();
+ NavigationSection configurationSection = buildConfigurationSection();
+ sections.add(configurationSection);
- addSection(buildSecuritySection());
- addSection(buildSystemConfigurationSection());
- addSection(buildTopologySection());
-
- addMember(sectionStack);
- addMember(contentCanvas);
+ return sections;
}
- private void addSection(final TreeGrid treeGrid) {
- final String sectionName = treeGrid.getTree().getRoot().getName();
- this.treeGrids.put(sectionName, treeGrid);
-
- treeGrid.addCellClickHandler(new CellClickHandler() {
- @Override
- public void onCellClick(CellClickEvent event) {
- // we use cell click as opposed to selected changed handler
- // because we want to be able to refresh even if clicking
- // on an already selected node
- TreeNode selectedRecord = (TreeNode) treeGrid.getSelectedRecord();
- if (selectedRecord != null) {
- String pageName = selectedRecord.getName();
- String viewPath = AdministrationView.VIEW_ID + "/" + sectionName + "/" + pageName;
- CoreGUI.goToView(viewPath);
- }
- }
- });
-
- SectionStackSection section = new SectionStackSection(sectionName);
- section.setExpanded(true);
- section.addItem(treeGrid);
-
- this.sectionStack.addSection(section);
- }
-
- private HTMLFlow defaultView() {
+ protected HTMLFlow defaultView() {
String contents = "<h1>Administration</h1>\n"
+ "From this section, the RHQ global settings can be administered. This includes configuring \n"
- + "<a href=\"\">Security</a>, setting up <a href=\"\">Plugins</a> and other stuff.";
+ + "<a href=\"\">Security</a>, setting up <a href=\"\">Plugins</a> and various other stuff.";
HTMLFlow flow = new HTMLFlow(contents);
flow.setPadding(20);
return flow;
}
- private TreeGrid buildSecuritySection() {
-
- final TreeGrid securityTreeGrid = new LocatableTreeGrid(SECTION_SECURITY_VIEW_ID);
- securityTreeGrid.setLeaveScrollbarGap(false);
- securityTreeGrid.setShowHeader(false);
-
- Tree tree = new Tree();
- final TreeNode manageUsersNode = new EnhancedTreeNode(UsersView.VIEW_ID);
- manageUsersNode.setIcon("global/User_16.png");
-
- final TreeNode manageRolesNode = new EnhancedTreeNode(RolesView.VIEW_ID);
- manageRolesNode.setIcon("global/Role_16.png");
-
- final TreeNode remoteAgentInstall = new EnhancedTreeNode(RemoteAgentInstallView.VIEW_ID);
- remoteAgentInstall.setIcon("global/Agent_16.png");
-
- TreeNode rootNode = new EnhancedTreeNode(SECTION_SECURITY_VIEW_ID, manageUsersNode, manageRolesNode,
- remoteAgentInstall);
- tree.setRoot(rootNode);
-
- securityTreeGrid.setData(tree);
-
- return securityTreeGrid;
- }
-
- private TreeGrid buildTopologySection() {
-
- final TreeGrid mgmtClusterTreeGrid = new LocatableTreeGrid(SECTION_TOPOLOGY_VIEW_ID);
- mgmtClusterTreeGrid.setLeaveScrollbarGap(false);
- mgmtClusterTreeGrid.setShowHeader(false);
-
- Tree tree = new Tree();
- final TreeNode manageServersNode = new EnhancedTreeNode(PAGE_SERVERS_VIEW_ID);
- final TreeNode manageAgentsNode = new EnhancedTreeNode(PAGE_AGENTS_VIEW_ID);
- final TreeNode manageAffinityGroupsNode = new EnhancedTreeNode(PAGE_AFFINITY_GROUPS_VIEW_ID);
- final TreeNode managePartitionEventsNode = new EnhancedTreeNode(PAGE_PARTITION_EVENTS_VIEW_ID);
-
- TreeNode rootNode = new EnhancedTreeNode(SECTION_TOPOLOGY_VIEW_ID, manageServersNode, manageAgentsNode,
- manageAffinityGroupsNode, managePartitionEventsNode);
- tree.setRoot(rootNode);
+ private NavigationSection buildSecuritySection() {
+ NavigationItem usersItem = new NavigationItem(UsersView.VIEW_ID, "global/User_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new UsersView(extendLocatorId("Users"));
+ }
+ });
- mgmtClusterTreeGrid.setData(tree);
+ NavigationItem rolesItem = new NavigationItem(RolesView.VIEW_ID, "global/Role_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new RolesView(extendLocatorId("Roles"));
+ }
+ });
- return mgmtClusterTreeGrid;
+ return new NavigationSection(SECTION_SECURITY_VIEW_ID, usersItem, rolesItem);
}
- private TreeGrid buildSystemConfigurationSection() {
-
- final TreeGrid systemConfigTreeGrid = new LocatableTreeGrid(SECTION_CONFIGURATION_VIEW_ID);
- systemConfigTreeGrid.setLeaveScrollbarGap(false);
- systemConfigTreeGrid.setShowHeader(false);
-
- Tree tree = new Tree();
- final TreeNode manageSettings = new EnhancedTreeNode(PAGE_SYSTEM_SETTINGS_VIEW_ID);
- final TreeNode manageTemplates = new EnhancedTreeNode(PAGE_TEMPLATES_VIEW_ID);
- final TreeNode manageDownloads = new EnhancedTreeNode(PAGE_DOWNLOADS_VIEW_ID);
- final TreeNode manageLicense = new EnhancedTreeNode(PAGE_LICENSE_VIEW_ID);
- final TreeNode managePlugins = new EnhancedTreeNode(PAGE_PLUGINS_VIEW_ID);
-
- TreeNode rootNode = new EnhancedTreeNode(SECTION_CONFIGURATION_VIEW_ID, manageSettings, manageTemplates,
- manageDownloads, manageLicense, managePlugins);
- tree.setRoot(rootNode);
+ private NavigationSection buildTopologySection() {
+ NavigationItem serversItem = new NavigationItem(PAGE_SERVERS_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_SERVERS_VIEW_ID), "/rhq/ha/listServers-plain.xhtml?nomenu=true");
+ }
+ });
- systemConfigTreeGrid.setData(tree);
+ NavigationItem agentsItem = new NavigationItem(PAGE_AGENTS_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_AGENTS_VIEW_ID), "/rhq/ha/listAgents-plain.xhtml?nomenu=true");
+ }
+ });
- return systemConfigTreeGrid;
- }
+ NavigationItem affinityGroupsItem = new NavigationItem(PAGE_AFFINITY_GROUPS_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_AFFINITY_GROUPS_VIEW_ID),
+ "/rhq/ha/listAffinityGroups-plain.xhtml?nomenu=true");
+ }
+ });
- public void setContent(Canvas newContent) {
+ NavigationItem partitionEventsItem = new NavigationItem(PAGE_PARTITION_EVENTS_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_PARTITION_EVENTS_VIEW_ID),
+ "/rhq/ha/listPartitionEvents-plain.xhtml?nomenu=true");
+ }
+ });
- // A call to destroy (e.g. certain IFrames/FullHTMLPane) can actually remove multiple children of the
- // contentCanvas. As such, we need to query for the children after each destroy to ensure only valid children
- // are in the array.
- Canvas[] children;
- while ((children = contentCanvas.getChildren()).length > 0) {
- children[0].destroy();
- }
+ NavigationItem remoteAgentInstallItem = new NavigationItem(RemoteAgentInstallView.VIEW_ID, "global/Agent_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new RemoteAgentInstallView(extendLocatorId("RemoteAgentInstall"));
+ }
+ });
- contentCanvas.addChild(newContent);
- contentCanvas.markForRedraw();
- currentContent = newContent;
+ return new NavigationSection(SECTION_TOPOLOGY_VIEW_ID, serversItem, agentsItem, affinityGroupsItem,
+ partitionEventsItem, remoteAgentInstallItem);
}
- private void renderContentView(ViewPath viewPath) {
- currentSectionViewId = viewPath.getCurrent();
- currentPageViewId = viewPath.getNext();
-
- String sectionName = currentSectionViewId.getPath();
- String pageName = currentPageViewId.getPath();
-
- Canvas content = null;
- if (SECTION_SECURITY_VIEW_ID.equals(sectionName)) {
-
- if (UsersView.VIEW_ID.equals(pageName)) {
- content = new UsersView(this.extendLocatorId("Users"));
- } else if (RolesView.VIEW_ID.equals(pageName)) {
- content = new RolesView(this.extendLocatorId("Roles"));
- } else if (RemoteAgentInstallView.VIEW_ID.equals(pageName)) {
- content = new RemoteAgentInstallView(this.extendLocatorId("RemoteAgentInstall"));
- }
- } else if (SECTION_CONFIGURATION_VIEW_ID.equals(sectionName)) {
- String url = null;
- if (PAGE_SYSTEM_SETTINGS_VIEW_ID.equals(pageName)) {
- url = "/admin/config/Config.do?mode=edit";
- } else if (PAGE_TEMPLATES_VIEW_ID.equals(pageName)) {
- content = new ResourceTypeTreeView(this.extendLocatorId("Templates"));
- currentPageViewId = null; // we always want to refresh, even if we renavigate back
- } else if (PAGE_DOWNLOADS_VIEW_ID.equals(pageName)) {
- url = "/rhq/admin/downloads-body.xhtml";
- } else if (PAGE_LICENSE_VIEW_ID.equals(pageName)) {
- url = "/admin/license/LicenseAdmin.do?mode=view";
- } else if (PAGE_PLUGINS_VIEW_ID.equals(pageName)) {
- url = "/rhq/admin/plugin/plugin-list-plain.xhtml";
- }
- if (url != null) {
- url = addQueryStringParam(url, "nomenu=true");
- content = new FullHTMLPane(this.extendLocatorId(pageName), url);
+ private NavigationSection buildConfigurationSection() {
+ NavigationItem systemSettingsItem = new NavigationItem(PAGE_SYSTEM_SETTINGS_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_SYSTEM_SETTINGS_VIEW_ID),
+ "/admin/config/Config.do?mode=edit&nomenu=true");
}
+ });
- } else if (SECTION_TOPOLOGY_VIEW_ID.equals(sectionName)) {
- String url = null;
- if (PAGE_SERVERS_VIEW_ID.equals(pageName)) {
- url = "/rhq/ha/listServers-plain.xhtml";
- } else if (PAGE_AGENTS_VIEW_ID.equals(pageName)) {
- url = "/rhq/ha/listAgents-plain.xhtml";
- } else if (PAGE_AFFINITY_GROUPS_VIEW_ID.equals(pageName)) {
- url = "/rhq/ha/listAffinityGroups-plain.xhtml";
- } else if (PAGE_PARTITION_EVENTS_VIEW_ID.equals(pageName)) {
- url = "/rhq/ha/listPartitionEvents-plain.xhtml";
+ NavigationItem templatesItem = new NavigationItem(PAGE_TEMPLATES_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceTypeTreeView(extendLocatorId(PAGE_TEMPLATES_VIEW_ID));
}
- content = new FullHTMLPane(this.extendLocatorId(pageName), url);
- }
-
- // when changing sections make sure the previous section's selection is deselected
- selectSectionPageTreeGridNode(sectionName, pageName);
-
- // ignore clicks on subsection folder nodes
- if (null != content) {
- setContent(content);
+ });
- if (content instanceof BookmarkableView) {
- ((BookmarkableView) content).renderView(viewPath.next().next());
+ NavigationItem downloadsItem = new NavigationItem(PAGE_DOWNLOADS_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_DOWNLOADS_VIEW_ID),
+ "/rhq/admin/downloads-body.xhtml?nomenu=true");
}
- }
- }
+ });
- public void renderView(ViewPath viewPath) {
- if (!viewPath.isCurrent(currentSectionViewId) || !viewPath.isNext(currentPageViewId)) {
- if (viewPath.isEnd()) {
- // Display default view
- setContent(defaultView());
- } else {
- renderContentView(viewPath);
+ NavigationItem licenseItem = new NavigationItem(PAGE_LICENSE_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_LICENSE_VIEW_ID),
+ "/admin/license/LicenseAdmin.do?mode=view&nomenu=true");
}
- } else {
- if (this.currentContent instanceof BookmarkableView) {
- ((BookmarkableView) this.currentContent).renderView(viewPath.next().next());
- }
- }
- }
+ });
- private void selectSectionPageTreeGridNode(String sectionName, String pageName) {
- for (String name : treeGrids.keySet()) {
- TreeGrid treeGrid = treeGrids.get(name);
- if (!name.equals(sectionName)) {
- treeGrid.deselectAllRecords();
- } else {
- TreeNode node = treeGrid.getTree().find(pageName);
- if (node != null) {
- treeGrid.selectSingleRecord(node);
- } else {
- CoreGUI.getErrorHandler().handleError("Unknown page name - URL is incorrect");
- }
+ NavigationItem pluginsItem = new NavigationItem(PAGE_PLUGINS_VIEW_ID, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new FullHTMLPane(extendLocatorId(PAGE_PLUGINS_VIEW_ID),
+ "/rhq/admin/plugin/plugin-list-plain.xhtml?nomenu=true");
}
- }
- }
+ });
- private static String addQueryStringParam(String url, String param) {
- char separatorChar = (url.indexOf('?') == -1) ? '?' : '&';
- return url + separatorChar + param;
+ return new NavigationSection(SECTION_CONFIGURATION_VIEW_ID, systemSettingsItem, templatesItem, downloadsItem,
+ licenseItem, pluginsItem);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java
index 94b957f..74861c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/AbstractSectionedLeftNavigationView.java
@@ -35,6 +35,7 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.InitializableView;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
@@ -50,8 +51,10 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
* @author Ian Springer
* @author Jay Shaughnessy
*/
-public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayout implements BookmarkableView {
+public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayout implements BookmarkableView,
+ InitializableView {
private String viewId;
+ private boolean initialized;
private ViewId currentSectionViewId;
private ViewId currentPageViewId;
@@ -62,12 +65,8 @@ public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayo
private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>();
private Map<String, NavigationSection> sectionsByName;
- public AbstractSectionedLeftNavigationView(String locatorId) {
- this(locatorId, locatorId);
- }
-
- public AbstractSectionedLeftNavigationView(String locatorId, String viewId) {
- super(locatorId);
+ public AbstractSectionedLeftNavigationView(String viewId) {
+ super(viewId);
this.viewId = viewId;
}
@@ -93,11 +92,19 @@ public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayo
for (NavigationSection section : sections) {
TreeGrid treeGrid = buildTreeGridForSection(section);
addSection(treeGrid);
+ treeGrid.getTree().openAll();
this.sectionsByName.put(section.getName(), section);
}
addMember(sectionStack);
addMember(contentCanvas);
+
+ this.initialized = true;
+ }
+
+ @Override
+ public boolean isInitialized() {
+ return this.initialized;
}
protected abstract Canvas defaultView();
@@ -115,6 +122,7 @@ public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayo
NavigationItem item = navigationItems.get(i);
final TreeNode treeNode = new EnhancedTreeNode(item.getName());
treeNode.setIcon(item.getIcon());
+ treeNode.setEnabled(item.isEnabled());
treeNodes[i] = treeNode;
}
@@ -167,23 +175,28 @@ public abstract class AbstractSectionedLeftNavigationView extends LocatableHLayo
}
private void renderContentView(ViewPath viewPath) {
- currentSectionViewId = viewPath.getCurrent();
- currentPageViewId = viewPath.getNext();
+ this.currentSectionViewId = viewPath.getCurrent();
+ this.currentPageViewId = viewPath.getNext();
- String sectionName = currentSectionViewId.getPath();
- String pageName = currentPageViewId.getPath();
+ String sectionName = this.currentSectionViewId.getPath();
+ String pageName = this.currentPageViewId.getPath();
NavigationSection section = this.sectionsByName.get(sectionName);
+ if (section == null) {
+ throw new IllegalStateException("Invalid section: " + sectionName);
+ }
NavigationItem item = section.getNavigationItem(pageName);
- // TODO: null checks for section and item.
- ViewFactory viewFactory = item.getViewFactory();
- Canvas content = viewFactory.createView();
+ if (item == null) {
+ throw new IllegalStateException("Invalid page: " + pageName);
+ }
- // When changing sections make sure the previous section's selection is deselected.
+ // When changing sections, make sure the previous section's selection is deselected.
selectSectionPageTreeGridNode(sectionName, pageName);
- // Ignore clicks on subsection folder nodes.
- if (null != content) {
+ // Only update the content pane if the item has an associated view factory.
+ ViewFactory viewFactory = item.getViewFactory();
+ Canvas content = (viewFactory != null) ? viewFactory.createView() : null;
+ if (content != null) {
setContent(content);
if (content instanceof BookmarkableView) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java
index ee64e84..24e04ff 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/view/NavigationItem.java
@@ -26,11 +26,17 @@ public class NavigationItem {
private String name;
private String icon;
private ViewFactory viewFactory;
+ private boolean enabled;
public NavigationItem(String name, String icon, ViewFactory viewFactory) {
+ this(name, icon, viewFactory, true);
+ }
+
+ public NavigationItem(String name, String icon, ViewFactory viewFactory, boolean enabled) {
this.icon = icon;
this.name = name;
this.viewFactory = viewFactory;
+ this.enabled = enabled;
}
public String getName() {
@@ -44,4 +50,8 @@ public class NavigationItem {
public ViewFactory getViewFactory() {
return viewFactory;
}
+
+ public boolean isEnabled() {
+ return enabled;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java
index ca23a16..ac2890d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java
@@ -18,33 +18,25 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory;
+import java.util.ArrayList;
import java.util.EnumSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.List;
import java.util.Set;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
-import com.smartgwt.client.widgets.grid.events.SelectionEvent;
-import com.smartgwt.client.widgets.layout.SectionStack;
-import com.smartgwt.client.widgets.layout.SectionStackSection;
-import com.smartgwt.client.widgets.tree.Tree;
-import com.smartgwt.client.widgets.tree.TreeGrid;
-import com.smartgwt.client.widgets.tree.TreeNode;
+import com.smartgwt.client.widgets.HTMLFlow;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.group.GroupCategory;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ViewId;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
+import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLeftNavigationView;
+import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem;
+import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
@@ -52,293 +44,189 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions.GroupD
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
+ * The Inventory top-level view.
+ *
* @author Greg Hinkle
* @author Joseph Marques
+ * @author Ian Springer
*/
-// TODO (ips, 10/28/10): Refactor this class to extend AbstractSectionedLeftNavigationView.
-public class InventoryView extends LocatableHLayout implements BookmarkableView {
+public class InventoryView extends AbstractSectionedLeftNavigationView {
public static final String VIEW_ID = "Inventory";
- private static final String GROUPS_SECTION_VIEW_ID = "Groups";
+ // view IDs for Resources section
private static final String RESOURCES_SECTION_VIEW_ID = "Resources";
- private static final String SUBSECTION_RESOURCE_INVENTORY = "Resources";
- private static final String SUBSECTION_GROUP_INVENTORY = "Groups";
- private static final String SUBSECTION_SAVED_SEARCHES = "SavedSearches";
-
- private static final String PAGE_ADQ = "DiscoveryManager";
- private static final String PAGE_COMPATIBLE_GROUPS = "CompatibleGroups";
- private static final String PAGE_DOWN = "DownServers";
- private static final String PAGE_GROUPS = "AllGroups";
- private static final String PAGE_GROUP_DEFINITIONS = "DynagroupManager";
- private static final String PAGE_MIXED_GROUPS = "MixedGroups";
+ private static final String PAGE_AUTODISCOVERY_QUEUE = "AutodiscoveryQueue";
+ private static final String PAGE_ALL_RESOURCES = "AllResources";
private static final String PAGE_PLATFORMS = "Platforms";
- private static final String PAGE_PROBLEM_GROUPS = "ProblemGroups";
- private static final String PAGE_RESOURCES = "AllResources";
private static final String PAGE_SERVERS = "Servers";
private static final String PAGE_SERVICES = "Services";
+ private static final String PAGE_DOWN_SERVERS = "DownServers";
- private ViewId currentSectionViewId;
- private ViewId currentPageViewId;
+ // view IDs for Groups section
+ private static final String GROUPS_SECTION_VIEW_ID = "Groups";
- private Canvas contentCanvas;
- private Canvas currentContent;
- private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>();
+ private static final String PAGE_DYNAGROUP_DEFINITIONS = "DynagroupDefinitions";
+ private static final String PAGE_ALL_GROUPS = "AllGroups";
+ private static final String PAGE_COMPATIBLE_GROUPS = "CompatibleGroups";
+ private static final String PAGE_MIXED_GROUPS = "MixedGroups";
+ private static final String PAGE_PROBLEM_GROUPS = "ProblemGroups";
- private SectionStack sectionStack;
+ private Set<Permission> globalPermissions;
- public InventoryView(String locatorId) {
- super(locatorId);
+ public InventoryView() {
+ // This is a top level view, so our locator id can simply be our view id.
+ super(VIEW_ID);
}
@Override
protected void onInit() {
- super.onInit();
-
- setWidth100();
- setHeight100();
-
- contentCanvas = new Canvas();
- contentCanvas.setWidth("*");
- contentCanvas.setHeight100();
-
- sectionStack = new LocatableSectionStack(getLocatorId());
- sectionStack.setShowResizeBar(true);
- sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
- sectionStack.setWidth(250);
- sectionStack.setHeight100();
-
GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new AsyncCallback<Set<Permission>>() {
@Override
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError("Could not determine user's global permissions - assuming none.",
caught);
- finishOnInit(EnumSet.noneOf(Permission.class));
+ globalPermissions = EnumSet.noneOf(Permission.class);
+ InventoryView.super.onInit();
}
@Override
public void onSuccess(Set<Permission> result) {
- finishOnInit(result);
- }
- });
- }
-
- private void finishOnInit(Set<Permission> globalPermissions) {
- addSection(buildResourcesSection(globalPermissions));
- addSection(buildGroupsSection(globalPermissions));
-
- addMember(sectionStack);
- addMember(contentCanvas);
- }
-
- private void addSection(TreeGrid treeGrid) {
- final String sectionName = treeGrid.getTree().getRoot().getName();
- this.treeGrids.put(sectionName, treeGrid);
-
- treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- TreeNode node = (TreeNode) selectionEvent.getRecord();
- String pageName = node.getName();
- String viewPath = InventoryView.VIEW_ID + "/" + sectionName + "/" + pageName;
- String currentViewPath = History.getToken();
- if (!currentViewPath.startsWith(viewPath)) {
- CoreGUI.goToView(viewPath);
- }
- }
+ globalPermissions = result;
+ InventoryView.super.onInit();
}
});
-
- SectionStackSection section = new SectionStackSection(sectionName);
- section.setExpanded(true);
- section.addItem(treeGrid);
-
- this.sectionStack.addSection(section);
}
- private TreeGrid buildResourcesSection(Set<Permission> globalPermissions) {
- final TreeNode discoveryQueue = new EnhancedTreeNode(PAGE_ADQ);
- discoveryQueue.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY));
- discoveryQueue.setIcon("global/Recent_16.png");
-
- final TreeNode onlyPlatforms = new EnhancedTreeNode(PAGE_PLATFORMS);
- onlyPlatforms.setIcon("types/Platform_up_16.png");
-
- final TreeNode onlyServers = new EnhancedTreeNode(PAGE_SERVERS);
- onlyServers.setIcon("types/Server_up_16.png");
-
- final TreeNode onlyServices = new EnhancedTreeNode(PAGE_SERVICES);
- onlyServices.setIcon("types/Service_up_16.png");
-
- final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_RESOURCE_INVENTORY, onlyPlatforms, onlyServers,
- onlyServices);
-
- final TreeNode downServers = new EnhancedTreeNode(PAGE_DOWN);
- downServers.setIcon("types/Server_down_16.png");
-
- final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES, downServers);
-
- TreeGrid treeGrid = new LocatableTreeGrid(RESOURCES_SECTION_VIEW_ID);
- treeGrid.setShowHeader(false);
- Tree tree = new Tree();
- TreeNode rootNode = new TreeNode(RESOURCES_SECTION_VIEW_ID, discoveryQueue, inventory, savedSearches);
- tree.setRoot(rootNode);
- treeGrid.setData(tree);
-
- treeGrid.getTree().openAll();
- treeGrids.put(RESOURCES_SECTION_VIEW_ID, treeGrid);
-
- return treeGrid;
+ protected Canvas defaultView() {
+ String contents = "<h1>Inventory</h1>\n"
+ + "From this section, newly discovered Resources, inventoried Resources, and Groups can be viewed and managed.";
+ HTMLFlow flow = new HTMLFlow(contents);
+ flow.setPadding(20);
+ return flow;
}
- private TreeGrid buildGroupsSection(Set<Permission> globalPermissions) {
- final TreeNode groupGroupDefinitions = new EnhancedTreeNode(PAGE_GROUP_DEFINITIONS);
- groupGroupDefinitions.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY));
- groupGroupDefinitions.setIcon("types/GroupDefinition_16.png");
-
- final TreeNode onlyCompatible = new EnhancedTreeNode(PAGE_COMPATIBLE_GROUPS);
- onlyCompatible.setIcon("types/Cluster_up_16.png");
- final TreeNode onlyMixed = new EnhancedTreeNode(PAGE_MIXED_GROUPS);
- onlyMixed.setIcon("types/Group_up_16.png");
-
- final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_GROUP_INVENTORY, onlyCompatible, onlyMixed);
-
- final TreeNode problemGroups = new EnhancedTreeNode(PAGE_PROBLEM_GROUPS);
- problemGroups.setIcon("types/Cluster_down_16.png");
- final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES, problemGroups);
+ @Override
+ protected List<NavigationSection> getNavigationSections() {
+ List<NavigationSection> sections = new ArrayList<NavigationSection>();
- TreeGrid treeGrid = new LocatableTreeGrid(GROUPS_SECTION_VIEW_ID);
- treeGrid.setShowHeader(false);
- Tree tree = new Tree();
- TreeNode rootNode = new EnhancedTreeNode(GROUPS_SECTION_VIEW_ID, groupGroupDefinitions, inventory,
- savedSearches);
- tree.setRoot(rootNode);
- treeGrid.setData(tree);
+ NavigationSection resourcesSection = buildResourcesSection();
+ sections.add(resourcesSection);
- treeGrid.getTree().openAll();
- treeGrids.put(GROUPS_SECTION_VIEW_ID, treeGrid);
+ NavigationSection groupsSection = buildGroupsSection();
+ sections.add(groupsSection);
- return treeGrid;
+ return sections;
}
- public void setContent(Canvas newContent) {
- for (Canvas child : this.contentCanvas.getChildren()) {
- child.destroy();
- }
- this.contentCanvas.addChild(newContent);
- this.contentCanvas.markForRedraw();
- this.currentContent = newContent;
- }
- private void renderContentView(ViewPath viewPath) {
- currentSectionViewId = viewPath.getCurrent();
- currentPageViewId = viewPath.getNext();
+ private NavigationSection buildResourcesSection() {
+ NavigationItem autodiscoveryQueueItem = new NavigationItem(PAGE_AUTODISCOVERY_QUEUE, "global/Recent_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceAutodiscoveryView(extendLocatorId(PAGE_AUTODISCOVERY_QUEUE));
+ }
+ }, this.globalPermissions.contains(Permission.MANAGE_INVENTORY));
- String sectionName = currentSectionViewId.getPath();
- String pageName = currentPageViewId.getPath();
+ // TODO: Specify an icon for this item.
+ NavigationItem allResourcesItem = new NavigationItem(PAGE_ALL_RESOURCES, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceSearchView(extendLocatorId(PAGE_ALL_RESOURCES), null, PAGE_ALL_RESOURCES,
+ "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png");
+ }
+ });
- Canvas content = null;
- if (RESOURCES_SECTION_VIEW_ID.equals(sectionName)) {
- if (PAGE_PLATFORMS.equals(pageName)) {
- content = new ResourceSearchView(extendLocatorId("Platforms"), new Criteria(
+ NavigationItem platformsItem = new NavigationItem(PAGE_PLATFORMS, "types/Platform_up_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceSearchView(extendLocatorId(PAGE_PLATFORMS), new Criteria(
ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS,
"types/Platform_up_24.png");
- } else if (PAGE_SERVERS.equals(pageName)) {
- content = new ResourceSearchView(extendLocatorId("Servers"), new Criteria(
+ }
+ });
+
+ NavigationItem serversItem = new NavigationItem(PAGE_SERVERS, "types/Server_up_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceSearchView(extendLocatorId(PAGE_SERVERS), new Criteria(
ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()), PAGE_SERVERS,
"types/Server_up_24.png");
- } else if (PAGE_SERVICES.equals(pageName)) {
- content = new ResourceSearchView(extendLocatorId("Services"), new Criteria(
+ }
+ });
+
+ NavigationItem servicesItem = new NavigationItem(PAGE_SERVICES, "types/Service_up_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceSearchView(extendLocatorId(PAGE_SERVICES), new Criteria(
ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVICE.name()), PAGE_SERVICES,
"types/Service_up_24.png");
- } else if (PAGE_ADQ.equals(pageName)) {
- content = new ResourceAutodiscoveryView(this.extendLocatorId("ADQ"));
- } else if (PAGE_DOWN.equals(pageName)) {
+ }
+ });
+
+ NavigationItem downServersItem = new NavigationItem(PAGE_DOWN_SERVERS, "types/Server_down_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
Criteria criteria = new Criteria(ResourceDataSourceField.AVAILABILITY.propertyName(),
AvailabilityType.DOWN.name());
criteria.addCriteria(ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name());
- content = new ResourceSearchView(extendLocatorId("DownResources"), criteria, PAGE_DOWN);
- } else { // selected the Inventory node itself
- content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES,
- "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png");
- }
- } else if (GROUPS_SECTION_VIEW_ID.equals(sectionName)) {
- if (PAGE_COMPATIBLE_GROUPS.equals(pageName)) {
- content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria(
- ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.COMPATIBLE.name()),
- "Compatible Groups", "types/Cluster_up_24.png");
- } else if (PAGE_MIXED_GROUPS.equals(pageName)) {
- content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria(
- ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.MIXED.name()), "Mixed Groups",
- "types/Group_up_24.png");
- } else if (PAGE_GROUP_DEFINITIONS.equals(pageName)) {
- content = new GroupDefinitionListView(extendLocatorId("Definitions"), "types/GroupDefinition_16.png");
- } else if (PAGE_PROBLEM_GROUPS.equals(pageName)) {
- //TODO - there is no underlying support for this criteria. Also, there should not be an active
- // new button on this page.
- content = new ResourceGroupListView(extendLocatorId("DownGroups"),
- new Criteria("availability", "down"), "Problem Groups", "types/Cluster_down_16.png");
- } else { // selected the Inventory node itself
- content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, "All Groups",
- "types/Cluster_up_24.png", "types/Group_up_24.png");
+ // TODO (ips, 10/28/10): Should we include down platforms too?
+ return new ResourceSearchView(extendLocatorId(PAGE_DOWN_SERVERS), criteria, "Down Servers");
}
- }
+ });
- // when changing sections make sure the previous section's selection is deselected
- selectSectionPageTreeGridNode(sectionName, pageName);
+ return new NavigationSection(RESOURCES_SECTION_VIEW_ID, autodiscoveryQueueItem, allResourcesItem, platformsItem,
+ serversItem, servicesItem, downServersItem);
+ }
- // ignore clicks on subsection folder nodes
- if (null != content) {
- setContent(content);
+ private NavigationSection buildGroupsSection() {
+ NavigationItem dynagroupDefinitionsItem = new NavigationItem(PAGE_DYNAGROUP_DEFINITIONS, "types/GroupDefinition_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ // TODO: Do we have a 24x24 groupdef icon?
+ return new GroupDefinitionListView(extendLocatorId(PAGE_DYNAGROUP_DEFINITIONS), "types/GroupDefinition_16.png");
+ }
+ }, this.globalPermissions.contains(Permission.MANAGE_INVENTORY));
- if (content instanceof BookmarkableView) {
- ((BookmarkableView) content).renderView(viewPath.next().next());
+ NavigationItem allGroupsItem = new NavigationItem(PAGE_ALL_GROUPS, "types/Group_up_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceGroupListView(extendLocatorId(PAGE_ALL_GROUPS), null, "All Groups",
+ "types/Cluster_up_24.png", "types/Group_up_24.png");
}
- }
- }
+ });
- private void selectSectionPageTreeGridNode(String sectionName, String pageName) {
- // TODO this method works, however, its getting invoked prior to treeGrids getting populated due to async authz check. need to fix that
- for (String name : treeGrids.keySet()) {
- TreeGrid treeGrid = treeGrids.get(name);
- if (!name.equals(sectionName)) {
- treeGrid.deselectAllRecords();
- } else {
- boolean gotIt = false;
- for (TreeNode node : treeGrid.getTree().getAllNodes()) {
- if (node.getName().equals(pageName)) {
- treeGrid.selectSingleRecord(node);
- gotIt = true;
- break;
- }
- }
- if (!gotIt) {
- CoreGUI.getErrorHandler().handleError("Unknown page name - URL is incorrect");
- }
+ NavigationItem compatibleGroupsItem = new NavigationItem(PAGE_COMPATIBLE_GROUPS, "types/Cluster_up_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceGroupListView(extendLocatorId(PAGE_COMPATIBLE_GROUPS), new Criteria(
+ ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.COMPATIBLE.name()),
+ "Compatible Groups", "types/Cluster_up_24.png");
}
- }
- }
+ });
- public void renderView(ViewPath viewPath) {
- if (!viewPath.isCurrent(currentSectionViewId) || !viewPath.isNext(currentPageViewId)) {
- if (viewPath.isEnd()) {
- // i.e. "Inventory"
- // Currently, leave content empty until the user selects something from section stack. To default
- // to platform list uncomment following line.
- // History.newItem("Inventory/Resources/Platforms", true);
- } else {
- // e.g. Inventory/Administration"
- renderContentView(viewPath);
+ NavigationItem mixedGroupsItem = new NavigationItem(PAGE_MIXED_GROUPS, "types/Group_up_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ return new ResourceGroupListView(extendLocatorId(PAGE_MIXED_GROUPS), new Criteria(
+ ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.MIXED.name()), "Mixed Groups",
+ "types/Group_up_24.png");
}
- } else {
- if (this.currentContent instanceof BookmarkableView) {
- ((BookmarkableView) this.currentContent).renderView(viewPath.next().next());
+ });
+
+ NavigationItem problemGroupsItem = new NavigationItem(PAGE_PROBLEM_GROUPS, "types/Cluster_down_16.png",
+ new ViewFactory() {
+ public Canvas createView() {
+ // TODO: There is no underlying support for this criteria. Also, there should not be an active New
+ // button on this page.
+ return new ResourceGroupListView(extendLocatorId(PAGE_PROBLEM_GROUPS),
+ new Criteria("availability", "down"), "Problem Groups", "types/Cluster_down_16.png");
}
- }
+ });
+
+ return new NavigationSection(GROUPS_SECTION_VIEW_ID, dynagroupDefinitionsItem, allGroupsItem,
+ compatibleGroupsItem, mixedGroupsItem, problemGroupsItem);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
index f7c37ee..ea2eb8c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
@@ -45,9 +45,10 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
* @author Joseph Marques
*/
public class GroupDefinitionListView extends TableSection {
+ private static final String TITLE = "Dynagroup Definitions";
public GroupDefinitionListView(String locatorId, String headerIcon) {
- super(locatorId, "Dynamic Group Definitions");
+ super(locatorId, TITLE);
setHeaderIcon(headerIcon);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 70126e3..0b954fc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -59,12 +59,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Greg Hinkle
*/
public class ResourceAutodiscoveryView extends LocatableVLayout {
+ private static final String TITLE = "Autodiscovery Queue";
+ private static final String HEADER_ICON = "global/Recent_16.png";
- private boolean simple = false;
+ private boolean simple;
private TreeGrid treeGrid;
private ToolStrip footer;
- private DataSource dataSource = null;
- private String headerIcon = "global/Recent_16.png";
+ private DataSource dataSource;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
@@ -85,13 +86,13 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
super.onInit();
if (!simple) {
- Img img = new Img(headerIcon, 24, 24);
+ Img img = new Img(HEADER_ICON, 24, 24);
img.setPadding(4);
HTMLFlow title = new HTMLFlow();
title.setWidth100();
title.setHeight(35);
- title.setContents("Discovery Manager");
+ title.setContents(TITLE);
title.setPadding(4);
title.setStyleName("HeaderLabel");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index d5cd465..6828ef8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -41,7 +41,10 @@ import org.rhq.enterprise.gui.coregui.client.report.measurement.MeasurementOOBVi
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
/**
+ * The Reports top-level view.
+ *
* @author Greg Hinkle
+ * @author Ian Springer
*/
public class ReportTopView extends AbstractSectionedLeftNavigationView {
public static final String VIEW_ID = "Reports";
@@ -49,8 +52,9 @@ public class ReportTopView extends AbstractSectionedLeftNavigationView {
private static final String SUBSYSTEMS_SECTION_VIEW_ID = "Subsystems";
private static final String INVENTORY_SECTION_VIEW_ID = "Inventory";
- public ReportTopView(String locatorId) {
- super(locatorId, VIEW_ID);
+ public ReportTopView() {
+ // This is a top level view, so our locator id can simply be our view id.
+ super(VIEW_ID);
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java
deleted file mode 100644
index 89d7d53..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationFactory.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
-import org.rhq.core.domain.configuration.definition.PropertyDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
-
-/**
- * A utility class that provides methods for creating a test {@link ConfigurationDefinition} and a
- * {@link Configuration} that conforms to that definition.
- *
- * @author Ian Springer
- */
-public abstract class TestConfigurationFactory {
- public static ConfigurationDefinition createConfigurationDefinition() {
- ConfigurationDefinition configDef = new ConfigurationDefinition("TestConfig", "a test config");
-
- ConfigurationTemplate defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME, "default template");
- configDef.putTemplate(defaultTemplate);
- Configuration defaultConfiguration = new Configuration();
- defaultTemplate.setConfiguration(defaultConfiguration);
-
- Map<String, PropertyDefinition> propertyDefinitions = new HashMap<String, PropertyDefinition>();
- configDef.setPropertyDefinitions(propertyDefinitions);
-
- int orderIndex = 0;
-
- PropertyDefinitionSimple simplePropDef;
-
- simplePropDef = createStringPropDef1();
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
-
- simplePropDef = createStringPropDef2();
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
-
- simplePropDef = new PropertyDefinitionSimple("LongString", "a Long String simple prop", false,
- PropertySimpleType.LONG_STRING);
- simplePropDef.setDisplayName(simplePropDef.getName());
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
-
- simplePropDef = new PropertyDefinitionSimple("Password", "a Password simple prop", false,
- PropertySimpleType.PASSWORD);
- simplePropDef.setDisplayName(simplePropDef.getName());
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
-
- simplePropDef = new PropertyDefinitionSimple("Boolean", "a required Boolean simple prop", true,
- PropertySimpleType.BOOLEAN);
- simplePropDef.setDisplayName(simplePropDef.getName());
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
- simplePropDef.setRequired(true);
-
- simplePropDef = createIntegerPropDef();
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
-
- simplePropDef = new PropertyDefinitionSimple("Float", "a Float simple prop", false, PropertySimpleType.FLOAT);
- simplePropDef.setDisplayName(simplePropDef.getName());
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
-
- simplePropDef = new PropertyDefinitionSimple("StringEnum1",
- "a String enum prop with <=5 items - should be rendered as radio buttons", false,
- PropertySimpleType.STRING);
- simplePropDef.setDisplayName(simplePropDef.getName());
- defaultConfiguration.put(new PropertySimple("StringEnum1", "NJ"));
- ArrayList<PropertyDefinitionEnumeration> propDefEnums = new ArrayList<PropertyDefinitionEnumeration>();
- propDefEnums.add(new PropertyDefinitionEnumeration("NY", "NY"));
- propDefEnums.add(new PropertyDefinitionEnumeration("NJ", "NJ"));
- propDefEnums.add(new PropertyDefinitionEnumeration("PA", "PA"));
- simplePropDef.setEnumeratedValues(propDefEnums, false);
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
-
- simplePropDef = new PropertyDefinitionSimple("StringEnum2",
- "a String enum prop with >5 items - should be rendered as a popup menu", false, PropertySimpleType.STRING);
- simplePropDef.setDisplayName(simplePropDef.getName());
- defaultConfiguration.put(new PropertySimple("StringEnum2", "blue"));
- propDefEnums = new ArrayList<PropertyDefinitionEnumeration>();
- propDefEnums.add(new PropertyDefinitionEnumeration("red", "red"));
- propDefEnums.add(new PropertyDefinitionEnumeration("orange", "orange"));
- propDefEnums.add(new PropertyDefinitionEnumeration("yellow", "yellow"));
- propDefEnums.add(new PropertyDefinitionEnumeration("green", "green"));
- propDefEnums.add(new PropertyDefinitionEnumeration("blue", "blue"));
- propDefEnums.add(new PropertyDefinitionEnumeration("purple", "purple"));
- simplePropDef.setEnumeratedValues(propDefEnums, false);
- addPropertyDefinition(configDef, simplePropDef, orderIndex++);
-
- PropertyDefinitionMap mapPropDef = new PropertyDefinitionMap("MapOfSimples", "a map of simples", false);
- mapPropDef.put(createStringPropDef1());
- mapPropDef.put(createStringPropDef2());
- mapPropDef.put(createIntegerPropDef());
- mapPropDef.setDisplayName(mapPropDef.getName());
- addPropertyDefinition(configDef, mapPropDef, orderIndex++);
-
- PropertyDefinitionMap openMapPropDef = new PropertyDefinitionMap("OpenMapOfSimples", "an open map of simples",
- false);
- openMapPropDef.setDisplayName(openMapPropDef.getName());
- addPropertyDefinition(configDef, openMapPropDef, orderIndex++);
-
- PropertyDefinitionMap readOnlyOpenMapPropDef = new PropertyDefinitionMap("ReadOnlyOpenMapOfSimples",
- "a read-only open map of simples", false);
- readOnlyOpenMapPropDef.setDisplayName(readOnlyOpenMapPropDef.getName());
- readOnlyOpenMapPropDef.setReadOnly(true);
- addPropertyDefinition(configDef, readOnlyOpenMapPropDef, orderIndex++);
-
- PropertyDefinitionList listOfSimplesPropDef = new PropertyDefinitionList("ListOfSimples",
- "a list of Integer simples", true, new PropertyDefinitionSimple("integer", "an integer", false,
- PropertySimpleType.INTEGER));
- listOfSimplesPropDef.setDisplayName(listOfSimplesPropDef.getName());
- addPropertyDefinition(configDef, listOfSimplesPropDef, orderIndex++);
-
- PropertyDefinitionMap mapInListPropDef =
- new PropertyDefinitionMap("MapOfSimplesInList", "a map of simples in a list", false);
- mapInListPropDef.put(createStringPropDef1());
- mapInListPropDef.put(createStringPropDef2());
- mapInListPropDef.put(createIntegerPropDef());
- mapInListPropDef.setDisplayName(mapInListPropDef.getName());
-
- PropertyDefinitionList listPropDef = new PropertyDefinitionList("ListOfMaps", "a list of maps", true,
- mapInListPropDef);
- listPropDef.setDisplayName(listPropDef.getName());
- addPropertyDefinition(configDef, listPropDef, orderIndex++);
-
- PropertyDefinitionMap mapInReadOnlyListPropDef =
- new PropertyDefinitionMap("MapOfSimplesInReadOnlyList", "a map of simples in a list", false);
- mapInReadOnlyListPropDef.put(createStringPropDef1());
- mapInReadOnlyListPropDef.put(createStringPropDef2());
- mapInReadOnlyListPropDef.put(createIntegerPropDef());
- mapInReadOnlyListPropDef.setDisplayName(mapInReadOnlyListPropDef.getName());
-
- PropertyDefinitionList readOnlyListPropDef = new PropertyDefinitionList("ReadOnlyListOfMaps",
- "a read-only list of maps", true, mapInReadOnlyListPropDef);
- readOnlyListPropDef.setDisplayName(readOnlyListPropDef.getName());
- readOnlyListPropDef.setReadOnly(true);
- addPropertyDefinition(configDef, readOnlyListPropDef, orderIndex++);
-
- PropertyGroupDefinition propertyGroupDefinition = new PropertyGroupDefinition("myGroup");
- propertyGroupDefinition.setDisplayName(propertyGroupDefinition.getName());
- propertyGroupDefinition.setDescription("this is an example group");
-
- PropertyDefinitionSimple myString = new PropertyDefinitionSimple("myString1", "my little string", true,
- PropertySimpleType.STRING);
- myString.setDisplayName(myString.getName());
- myString.setSummary(true);
- addPropertyDefinition(configDef, myString, orderIndex++);
- myString.setPropertyGroupDefinition(propertyGroupDefinition);
-
- PropertyDefinitionSimple myString2 = new PropertyDefinitionSimple("myString2", "my other little string", true,
- PropertySimpleType.STRING);
- myString2.setDisplayName(myString2.getName());
- myString2.setSummary(true);
- addPropertyDefinition(configDef, myString2, orderIndex++);
- myString2.setPropertyGroupDefinition(propertyGroupDefinition);
-
- PropertyGroupDefinition propertyGroupDefinition2 = new PropertyGroupDefinition("myGroup2");
- propertyGroupDefinition2.setDisplayName(propertyGroupDefinition2.getName());
- propertyGroupDefinition2.setDescription("this is another example group");
-
- PropertyDefinitionSimple myString3 = new PropertyDefinitionSimple("myString3", "my third string", true,
- PropertySimpleType.STRING);
- myString3.setDisplayName((myString3.getName()));
- myString3.setSummary(true);
- addPropertyDefinition(configDef, myString3, orderIndex++);
- myString3.setPropertyGroupDefinition(propertyGroupDefinition2);
-
- PropertyDefinitionSimple enumExample = new PropertyDefinitionSimple("myEnum",
- "a grouped enum prop with <=5 items", false, PropertySimpleType.STRING);
- enumExample.setDisplayName(enumExample.getName());
- defaultConfiguration.put(new PropertySimple("myEnum", "Burlington"));
- ArrayList<PropertyDefinitionEnumeration> myEnums = new ArrayList<PropertyDefinitionEnumeration>();
- myEnums.add(new PropertyDefinitionEnumeration("Burlington", "Burlington"));
- myEnums.add(new PropertyDefinitionEnumeration("Camden", "Camden"));
- myEnums.add(new PropertyDefinitionEnumeration("Gloucester", "Gloucester"));
- enumExample.setEnumeratedValues(myEnums, false);
- addPropertyDefinition(configDef, enumExample, orderIndex++);
- enumExample.setPropertyGroupDefinition(propertyGroupDefinition2);
-
- return configDef;
- }
-
- private static void addPropertyDefinition(ConfigurationDefinition configDef,
- PropertyDefinition propDef, int orderIndex) {
- propDef.setOrder(orderIndex);
- configDef.put(propDef);
- }
-
- public static Configuration createConfiguration() {
- Configuration configuration = new Configuration();
- configuration.setNotes("a test config");
- configuration.setVersion(1);
-
- configuration.put(new PropertySimple("String1", "blah"));
- configuration.put(new PropertySimple("String2",
- "a really, really, really, really, really long value that won't fit in the text input box"));
- configuration.put(new PropertySimple("LongString", "blah blah blah\nblah blah blah"));
- configuration.put(new PropertySimple("Password", null));
- configuration.put(new PropertySimple("Boolean", false));
- configuration.put(new PropertySimple("Integer", 666));
- configuration.put(new PropertySimple("Float", Math.PI));
-
- configuration.put(new PropertySimple("StringEnum1", "PA"));
- configuration.put(new PropertySimple("StringEnum2", "blue"));
-
- PropertyMap propMap1 = new PropertyMap("MapOfSimples");
- propMap1.put(new PropertySimple("String1", "One"));
- propMap1.put(new PropertySimple("String2", "Two"));
- propMap1.put(new PropertySimple("Integer", 11));
- configuration.put(propMap1);
-
- PropertyMap openPropMap1 = new PropertyMap("OpenMapOfSimples");
- openPropMap1.put(new PropertySimple("PROCESSOR_ARCHITECTURE", "x86"));
- openPropMap1.put(new PropertySimple("PROCESSOR_IDENTIFIER", "x86 Family 6 Model 15 Stepping 6, GenuineIntel"));
- openPropMap1.put(new PropertySimple("PROCESSOR_LEVEL", "6"));
- openPropMap1.put(new PropertySimple("PROCESSOR_REVISION", "0f06"));
- configuration.put(openPropMap1);
-
- PropertyMap openPropMap2 = new PropertyMap("ReadOnlyOpenMapOfSimples");
- openPropMap2.put(new PropertySimple("ANT_HOME", "C:\\opt\\ant-1.6.5"));
- openPropMap2.put(new PropertySimple("ANT_OPTS", "-Xms128M -Xmx256M"));
- configuration.put(openPropMap2);
-
- configuration.put(new PropertyList("ListOfSimples", new PropertySimple("integer", "18"), new PropertySimple(
- "integer", "127"), new PropertySimple("integer", "311"), new PropertySimple("integer", "2"), new PropertySimple(
- "integer", "301"), new PropertySimple("integer", "79"), new PropertySimple("integer", "62")));
-
- PropertyMap propMap2 = new PropertyMap("MapOfSimplesInList");
- propMap2.put(new PropertySimple("String1", "Uno"));
- propMap2.put(new PropertySimple("String2", "Dos"));
- propMap2.put(new PropertySimple("Integer", Integer.MIN_VALUE));
- PropertyMap propMap3 = new PropertyMap("MapOfSimplesInList");
- propMap3.put(new PropertySimple("String1", "Un"));
- propMap3.put(new PropertySimple("String2", "Deux"));
- propMap3.put(new PropertySimple("Integer", Integer.MAX_VALUE));
- configuration.put(new PropertyList("ListOfMaps", propMap2, propMap3));
-
- PropertyMap propMap4 = new PropertyMap("MapOfSimplesInReadOnlyList");
- propMap4.put(new PropertySimple("String1", "A"));
- propMap4.put(new PropertySimple("String2", "B"));
- propMap4.put(new PropertySimple("Integer", 999));
- PropertyMap propMap5 = new PropertyMap("MapOfSimplesInReadOnlyList");
- propMap5.put(new PropertySimple("String1", "a"));
- propMap5.put(new PropertySimple("String2", "b"));
- propMap5.put(new PropertySimple("Integer", 0));
- configuration.put(new PropertyList("ReadOnlyListOfMaps", propMap4, propMap5));
-
- configuration.put(new PropertySimple("myString1", "grouped String 1"));
- configuration.put(new PropertySimple("myString2", "grouped String 2"));
- configuration.put(new PropertySimple("myString3", "strings are cool"));
- configuration.put(new PropertySimple("myEnum", "Burlington"));
-
- return configuration;
- }
-
- private static PropertyDefinitionSimple createStringPropDef1() {
- PropertyDefinitionSimple stringPropDef1;
- stringPropDef1 = new PropertyDefinitionSimple("String1",
- "an optional String simple prop", false, PropertySimpleType.STRING);
- stringPropDef1.setDisplayName(stringPropDef1.getName());
- return stringPropDef1;
- }
-
- private static PropertyDefinitionSimple createStringPropDef2() {
- PropertyDefinitionSimple stringPropDef2;
- stringPropDef2 = new PropertyDefinitionSimple("String2",
- "a read-only String simple prop", false, PropertySimpleType.STRING);
- stringPropDef2.setDisplayName(stringPropDef2.getName());
- stringPropDef2.setReadOnly(true);
- return stringPropDef2;
- }
-
- private static PropertyDefinitionSimple createIntegerPropDef() {
- PropertyDefinitionSimple integerPropDef;
- integerPropDef = new PropertyDefinitionSimple("Integer",
- "a required summary Integer simple prop", true, PropertySimpleType.INTEGER);
- integerPropDef.setDisplayName(integerPropDef.getName());
- integerPropDef.setSummary(true);
- return integerPropDef;
- }
-
- private TestConfigurationFactory() {
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java
deleted file mode 100644
index 9d94650..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestConfigurationView.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.test;
-
-import java.util.EnumSet;
-import java.util.Set;
-
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.layout.LayoutSpacer;
-import com.smartgwt.client.widgets.toolbar.ToolStrip;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * @author Ian Springer
- */
-public class TestConfigurationView
- extends LocatableVLayout implements PropertyValueChangeListener {
- public static final String VIEW_ID = "TestConfig";
-
- private ConfigurationEditor editor;
- private LocatableIButton saveButton;
- private ConfigurationDefinition configurationDefinition;
- private Configuration configuration;
-
- public TestConfigurationView(String locatorId) {
- super(locatorId);
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
- build();
- }
-
- public void build() {
- setWidth100();
- setHeight100();
-
- ToolStrip toolStrip = new ToolStrip();
- toolStrip.setWidth100();
-
- toolStrip.addMember(new LayoutSpacer());
-
- this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
- this.saveButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- save();
- }
- });
- this.saveButton.disable();
- toolStrip.addMember(this.saveButton);
-
- addMember(toolStrip);
-
- this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
- this.configuration = TestConfigurationFactory.createConfiguration();
-
- reloadConfiguration();
- }
-
- @Override
- public void propertyValueChanged(PropertyValueChangeEvent event) {
- MessageCenter messageCenter = CoreGUI.getMessageCenter();
- Message message;
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
- if (invalidPropertyNames.isEmpty()) {
- this.saveButton.enable();
- message = new Message("All properties now have valid values, so the configuration can now be saved.",
- Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
- }
- else {
- this.saveButton.disable();
- message = new Message(
- "The following properties have invalid values: " + invalidPropertyNames
- + " - the values must be corrected before the configuration can be saved.",
- Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
- }
- messageCenter.notify(message);
- }
- else {
- this.saveButton.enable();
- }
- }
-
- private void reloadConfiguration() {
- this.saveButton.disable();
- if (editor != null) {
- editor.destroy();
- removeMember(editor);
- }
-
- editor = new ConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition, this.configuration);
- editor.setOverflow(Overflow.AUTO);
- editor.addPropertyValueChangeListener(this);
- addMember(editor);
- }
-
- private void save() {
- CoreGUI.getMessageCenter().notify(
- new Message("Configuration updated.", "Test configuration updated."));
- reloadConfiguration();
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java
deleted file mode 100644
index f54bb01..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestGroupConfigurationView.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.test;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Set;
-
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.layout.LayoutSpacer;
-import com.smartgwt.client.widgets.toolbar.ToolStrip;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupMemberConfiguration;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * @author Ian Springer
- */
-public class TestGroupConfigurationView
- extends LocatableVLayout implements PropertyValueChangeListener {
- public static final String VIEW_ID = "TestGroupConfig";
-
- private static final int GROUP_SIZE = 2;
-
- private ConfigurationEditor editor;
- private LocatableIButton saveButton;
- private ConfigurationDefinition configurationDefinition;
- private List<GroupMemberConfiguration> memberConfigurations;
-
- public TestGroupConfigurationView(String locatorId) {
- super(locatorId);
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
-
- setWidth100();
- setHeight100();
-
- ToolStrip toolStrip = new ToolStrip();
- toolStrip.setWidth100();
-
- toolStrip.addMember(new LayoutSpacer());
-
- this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
- this.saveButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- save();
- }
- });
- this.saveButton.disable();
- toolStrip.addMember(this.saveButton);
-
- addMember(toolStrip);
-
- this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
- this.memberConfigurations = new ArrayList<GroupMemberConfiguration>(GROUP_SIZE);
- for (int i = 0; i < GROUP_SIZE; i++) {
- Configuration configuration = TestConfigurationFactory.createConfiguration();
- GroupMemberConfiguration memberConfiguration = new GroupMemberConfiguration(i, "Member #" + i,
- configuration);
- this.memberConfigurations.add(memberConfiguration);
- }
-
- reloadConfiguration();
- }
-
- @Override
- public void propertyValueChanged(PropertyValueChangeEvent event) {
- MessageCenter messageCenter = CoreGUI.getMessageCenter();
- Message message;
- if (event.isValidationStateChanged()) {
- Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
- if (invalidPropertyNames.isEmpty()) {
- this.saveButton.enable();
- message = new Message("All properties now have valid values, so the configuration can now be saved.",
- Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
- }
- else {
- this.saveButton.disable();
- message = new Message(
- "The following properties have invalid values: " + invalidPropertyNames
- + " - the values must be corrected before the configuration can be saved.",
- Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
- }
- messageCenter.notify(message);
- } else {
- this.saveButton.enable();
- }
- }
-
- private void reloadConfiguration() {
- this.saveButton.disable();
- if (editor != null) {
- editor.destroy();
- removeMember(editor);
- }
-
- editor = new GroupConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition,
- this.memberConfigurations);
- editor.setOverflow(Overflow.AUTO);
- editor.addPropertyValueChangeListener(this);
- addMember(editor);
- }
-
- private void save() {
- CoreGUI.getMessageCenter().notify(
- new Message("Member configurations updated.", "Member configurations updated."));
- reloadConfiguration();
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
new file mode 100644
index 0000000..fa345bf
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
@@ -0,0 +1,90 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+
+import org.rhq.enterprise.gui.coregui.client.components.view.AbstractSectionedLeftNavigationView;
+import org.rhq.enterprise.gui.coregui.client.components.view.NavigationItem;
+import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
+import org.rhq.enterprise.gui.coregui.client.test.configuration.TestConfigurationView;
+import org.rhq.enterprise.gui.coregui.client.test.configuration.TestGroupConfigurationView;
+
+/**
+ * The Test top-level view. This view is "hidden", i.e. there are no links to it, so the user must go to the URL
+ * directly using their browser.
+ *
+ * @author Ian Springer
+ */
+public class TestTopView extends AbstractSectionedLeftNavigationView {
+ public static final String VIEW_ID = "Test";
+
+ // view IDs for Configuration section
+ private static final String CONFIGURATION_SECTION_VIEW_ID = "Configuration";
+
+ private static final String PAGE_CONFIG_EDITOR = "ConfigEditor";
+ private static final String PAGE_GROUP_CONFIG_EDITOR = "GroupConfigEditor";
+
+ public TestTopView() {
+ // This is a top level view, so our locator id can simply be our view id.
+ super(VIEW_ID);
+ }
+
+ protected Canvas defaultView() {
+ String contents = "<h1>Test</h1>\n"
+ + "This section contains pages for testing various GUI components.";
+ HTMLFlow flow = new HTMLFlow(contents);
+ flow.setPadding(20);
+ return flow;
+ }
+
+ @Override
+ protected List<NavigationSection> getNavigationSections() {
+ List<NavigationSection> sections = new ArrayList<NavigationSection>();
+
+ NavigationSection configurationSection = buildConfigurationSection();
+ sections.add(configurationSection);
+
+ return sections;
+ }
+
+
+ private NavigationSection buildConfigurationSection() {
+ NavigationItem configEditorItem = new NavigationItem(PAGE_CONFIG_EDITOR, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new TestConfigurationView(extendLocatorId(PAGE_CONFIG_EDITOR));
+ }
+ });
+
+ NavigationItem groupConfigEditorItem = new NavigationItem(PAGE_GROUP_CONFIG_EDITOR, null,
+ new ViewFactory() {
+ public Canvas createView() {
+ return new TestGroupConfigurationView(extendLocatorId(PAGE_GROUP_CONFIG_EDITOR));
+ }
+ });
+
+ return new NavigationSection(CONFIGURATION_SECTION_VIEW_ID, configEditorItem, groupConfigEditorItem);
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
new file mode 100644
index 0000000..e786a36
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
@@ -0,0 +1,311 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.test.configuration;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+
+/**
+ * A utility class that provides methods for creating a test {@link ConfigurationDefinition} and a
+ * {@link Configuration} that conforms to that definition.
+ *
+ * @author Ian Springer
+ */
+public abstract class TestConfigurationFactory {
+ public static ConfigurationDefinition createConfigurationDefinition() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("TestConfig", "a test config");
+
+ ConfigurationTemplate defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME, "default template");
+ configDef.putTemplate(defaultTemplate);
+ Configuration defaultConfiguration = new Configuration();
+ defaultTemplate.setConfiguration(defaultConfiguration);
+
+ Map<String, PropertyDefinition> propertyDefinitions = new HashMap<String, PropertyDefinition>();
+ configDef.setPropertyDefinitions(propertyDefinitions);
+
+ int orderIndex = 0;
+
+ PropertyDefinitionSimple simplePropDef;
+
+ simplePropDef = createStringPropDef1();
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+
+ simplePropDef = createStringPropDef2();
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+
+ simplePropDef = new PropertyDefinitionSimple("LongString", "a Long String simple prop", false,
+ PropertySimpleType.LONG_STRING);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+
+ simplePropDef = new PropertyDefinitionSimple("Password", "a Password simple prop", false,
+ PropertySimpleType.PASSWORD);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+
+ simplePropDef = new PropertyDefinitionSimple("Boolean", "a required Boolean simple prop", true,
+ PropertySimpleType.BOOLEAN);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+ simplePropDef.setRequired(true);
+
+ simplePropDef = createIntegerPropDef();
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+
+ simplePropDef = new PropertyDefinitionSimple("Float", "a Float simple prop", false, PropertySimpleType.FLOAT);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+
+ simplePropDef = new PropertyDefinitionSimple("StringEnum1",
+ "a String enum prop with <=5 items - should be rendered as radio buttons", false,
+ PropertySimpleType.STRING);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ defaultConfiguration.put(new PropertySimple("StringEnum1", "NJ"));
+ ArrayList<PropertyDefinitionEnumeration> propDefEnums = new ArrayList<PropertyDefinitionEnumeration>();
+ propDefEnums.add(new PropertyDefinitionEnumeration("NY", "NY"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("NJ", "NJ"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("PA", "PA"));
+ simplePropDef.setEnumeratedValues(propDefEnums, false);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+
+ simplePropDef = new PropertyDefinitionSimple("StringEnum2",
+ "a String enum prop with >5 items - should be rendered as a popup menu", false, PropertySimpleType.STRING);
+ simplePropDef.setDisplayName(simplePropDef.getName());
+ defaultConfiguration.put(new PropertySimple("StringEnum2", "blue"));
+ propDefEnums = new ArrayList<PropertyDefinitionEnumeration>();
+ propDefEnums.add(new PropertyDefinitionEnumeration("red", "red"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("orange", "orange"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("yellow", "yellow"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("green", "green"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("blue", "blue"));
+ propDefEnums.add(new PropertyDefinitionEnumeration("purple", "purple"));
+ simplePropDef.setEnumeratedValues(propDefEnums, false);
+ addPropertyDefinition(configDef, simplePropDef, orderIndex++);
+
+ PropertyDefinitionMap mapPropDef = new PropertyDefinitionMap("MapOfSimples", "a map of simples", false);
+ mapPropDef.put(createStringPropDef1());
+ mapPropDef.put(createStringPropDef2());
+ mapPropDef.put(createIntegerPropDef());
+ mapPropDef.setDisplayName(mapPropDef.getName());
+ addPropertyDefinition(configDef, mapPropDef, orderIndex++);
+
+ PropertyDefinitionMap openMapPropDef = new PropertyDefinitionMap("OpenMapOfSimples", "an open map of simples",
+ false);
+ openMapPropDef.setDisplayName(openMapPropDef.getName());
+ addPropertyDefinition(configDef, openMapPropDef, orderIndex++);
+
+ PropertyDefinitionMap readOnlyOpenMapPropDef = new PropertyDefinitionMap("ReadOnlyOpenMapOfSimples",
+ "a read-only open map of simples", false);
+ readOnlyOpenMapPropDef.setDisplayName(readOnlyOpenMapPropDef.getName());
+ readOnlyOpenMapPropDef.setReadOnly(true);
+ addPropertyDefinition(configDef, readOnlyOpenMapPropDef, orderIndex++);
+
+ PropertyDefinitionList listOfSimplesPropDef = new PropertyDefinitionList("ListOfSimples",
+ "a list of Integer simples", true, new PropertyDefinitionSimple("integer", "an integer", false,
+ PropertySimpleType.INTEGER));
+ listOfSimplesPropDef.setDisplayName(listOfSimplesPropDef.getName());
+ addPropertyDefinition(configDef, listOfSimplesPropDef, orderIndex++);
+
+ PropertyDefinitionMap mapInListPropDef =
+ new PropertyDefinitionMap("MapOfSimplesInList", "a map of simples in a list", false);
+ mapInListPropDef.put(createStringPropDef1());
+ mapInListPropDef.put(createStringPropDef2());
+ mapInListPropDef.put(createIntegerPropDef());
+ mapInListPropDef.setDisplayName(mapInListPropDef.getName());
+
+ PropertyDefinitionList listPropDef = new PropertyDefinitionList("ListOfMaps", "a list of maps", true,
+ mapInListPropDef);
+ listPropDef.setDisplayName(listPropDef.getName());
+ addPropertyDefinition(configDef, listPropDef, orderIndex++);
+
+ PropertyDefinitionMap mapInReadOnlyListPropDef =
+ new PropertyDefinitionMap("MapOfSimplesInReadOnlyList", "a map of simples in a list", false);
+ mapInReadOnlyListPropDef.put(createStringPropDef1());
+ mapInReadOnlyListPropDef.put(createStringPropDef2());
+ mapInReadOnlyListPropDef.put(createIntegerPropDef());
+ mapInReadOnlyListPropDef.setDisplayName(mapInReadOnlyListPropDef.getName());
+
+ PropertyDefinitionList readOnlyListPropDef = new PropertyDefinitionList("ReadOnlyListOfMaps",
+ "a read-only list of maps", true, mapInReadOnlyListPropDef);
+ readOnlyListPropDef.setDisplayName(readOnlyListPropDef.getName());
+ readOnlyListPropDef.setReadOnly(true);
+ addPropertyDefinition(configDef, readOnlyListPropDef, orderIndex++);
+
+ PropertyGroupDefinition propertyGroupDefinition = new PropertyGroupDefinition("myGroup");
+ propertyGroupDefinition.setDisplayName(propertyGroupDefinition.getName());
+ propertyGroupDefinition.setDescription("this is an example group");
+
+ PropertyDefinitionSimple myString = new PropertyDefinitionSimple("myString1", "my little string", true,
+ PropertySimpleType.STRING);
+ myString.setDisplayName(myString.getName());
+ myString.setSummary(true);
+ addPropertyDefinition(configDef, myString, orderIndex++);
+ myString.setPropertyGroupDefinition(propertyGroupDefinition);
+
+ PropertyDefinitionSimple myString2 = new PropertyDefinitionSimple("myString2", "my other little string", true,
+ PropertySimpleType.STRING);
+ myString2.setDisplayName(myString2.getName());
+ myString2.setSummary(true);
+ addPropertyDefinition(configDef, myString2, orderIndex++);
+ myString2.setPropertyGroupDefinition(propertyGroupDefinition);
+
+ PropertyGroupDefinition propertyGroupDefinition2 = new PropertyGroupDefinition("myGroup2");
+ propertyGroupDefinition2.setDisplayName(propertyGroupDefinition2.getName());
+ propertyGroupDefinition2.setDescription("this is another example group");
+
+ PropertyDefinitionSimple myString3 = new PropertyDefinitionSimple("myString3", "my third string", true,
+ PropertySimpleType.STRING);
+ myString3.setDisplayName((myString3.getName()));
+ myString3.setSummary(true);
+ addPropertyDefinition(configDef, myString3, orderIndex++);
+ myString3.setPropertyGroupDefinition(propertyGroupDefinition2);
+
+ PropertyDefinitionSimple enumExample = new PropertyDefinitionSimple("myEnum",
+ "a grouped enum prop with <=5 items", false, PropertySimpleType.STRING);
+ enumExample.setDisplayName(enumExample.getName());
+ defaultConfiguration.put(new PropertySimple("myEnum", "Burlington"));
+ ArrayList<PropertyDefinitionEnumeration> myEnums = new ArrayList<PropertyDefinitionEnumeration>();
+ myEnums.add(new PropertyDefinitionEnumeration("Burlington", "Burlington"));
+ myEnums.add(new PropertyDefinitionEnumeration("Camden", "Camden"));
+ myEnums.add(new PropertyDefinitionEnumeration("Gloucester", "Gloucester"));
+ enumExample.setEnumeratedValues(myEnums, false);
+ addPropertyDefinition(configDef, enumExample, orderIndex++);
+ enumExample.setPropertyGroupDefinition(propertyGroupDefinition2);
+
+ return configDef;
+ }
+
+ private static void addPropertyDefinition(ConfigurationDefinition configDef,
+ PropertyDefinition propDef, int orderIndex) {
+ propDef.setOrder(orderIndex);
+ configDef.put(propDef);
+ }
+
+ public static Configuration createConfiguration() {
+ Configuration configuration = new Configuration();
+ configuration.setNotes("a test config");
+ configuration.setVersion(1);
+
+ configuration.put(new PropertySimple("String1", "blah"));
+ configuration.put(new PropertySimple("String2",
+ "a really, really, really, really, really long value that won't fit in the text input box"));
+ configuration.put(new PropertySimple("LongString", "blah blah blah\nblah blah blah"));
+ configuration.put(new PropertySimple("Password", null));
+ configuration.put(new PropertySimple("Boolean", false));
+ configuration.put(new PropertySimple("Integer", 666));
+ configuration.put(new PropertySimple("Float", Math.PI));
+
+ configuration.put(new PropertySimple("StringEnum1", "PA"));
+ configuration.put(new PropertySimple("StringEnum2", "blue"));
+
+ PropertyMap propMap1 = new PropertyMap("MapOfSimples");
+ propMap1.put(new PropertySimple("String1", "One"));
+ propMap1.put(new PropertySimple("String2", "Two"));
+ propMap1.put(new PropertySimple("Integer", 11));
+ configuration.put(propMap1);
+
+ PropertyMap openPropMap1 = new PropertyMap("OpenMapOfSimples");
+ openPropMap1.put(new PropertySimple("PROCESSOR_ARCHITECTURE", "x86"));
+ openPropMap1.put(new PropertySimple("PROCESSOR_IDENTIFIER", "x86 Family 6 Model 15 Stepping 6, GenuineIntel"));
+ openPropMap1.put(new PropertySimple("PROCESSOR_LEVEL", "6"));
+ openPropMap1.put(new PropertySimple("PROCESSOR_REVISION", "0f06"));
+ configuration.put(openPropMap1);
+
+ PropertyMap openPropMap2 = new PropertyMap("ReadOnlyOpenMapOfSimples");
+ openPropMap2.put(new PropertySimple("ANT_HOME", "C:\\opt\\ant-1.6.5"));
+ openPropMap2.put(new PropertySimple("ANT_OPTS", "-Xms128M -Xmx256M"));
+ configuration.put(openPropMap2);
+
+ configuration.put(new PropertyList("ListOfSimples", new PropertySimple("integer", "18"), new PropertySimple(
+ "integer", "127"), new PropertySimple("integer", "311"), new PropertySimple("integer", "2"), new PropertySimple(
+ "integer", "301"), new PropertySimple("integer", "79"), new PropertySimple("integer", "62")));
+
+ PropertyMap propMap2 = new PropertyMap("MapOfSimplesInList");
+ propMap2.put(new PropertySimple("String1", "Uno"));
+ propMap2.put(new PropertySimple("String2", "Dos"));
+ propMap2.put(new PropertySimple("Integer", Integer.MIN_VALUE));
+ PropertyMap propMap3 = new PropertyMap("MapOfSimplesInList");
+ propMap3.put(new PropertySimple("String1", "Un"));
+ propMap3.put(new PropertySimple("String2", "Deux"));
+ propMap3.put(new PropertySimple("Integer", Integer.MAX_VALUE));
+ configuration.put(new PropertyList("ListOfMaps", propMap2, propMap3));
+
+ PropertyMap propMap4 = new PropertyMap("MapOfSimplesInReadOnlyList");
+ propMap4.put(new PropertySimple("String1", "A"));
+ propMap4.put(new PropertySimple("String2", "B"));
+ propMap4.put(new PropertySimple("Integer", 999));
+ PropertyMap propMap5 = new PropertyMap("MapOfSimplesInReadOnlyList");
+ propMap5.put(new PropertySimple("String1", "a"));
+ propMap5.put(new PropertySimple("String2", "b"));
+ propMap5.put(new PropertySimple("Integer", 0));
+ configuration.put(new PropertyList("ReadOnlyListOfMaps", propMap4, propMap5));
+
+ configuration.put(new PropertySimple("myString1", "grouped String 1"));
+ configuration.put(new PropertySimple("myString2", "grouped String 2"));
+ configuration.put(new PropertySimple("myString3", "strings are cool"));
+ configuration.put(new PropertySimple("myEnum", "Burlington"));
+
+ return configuration;
+ }
+
+ private static PropertyDefinitionSimple createStringPropDef1() {
+ PropertyDefinitionSimple stringPropDef1;
+ stringPropDef1 = new PropertyDefinitionSimple("String1",
+ "an optional String simple prop", false, PropertySimpleType.STRING);
+ stringPropDef1.setDisplayName(stringPropDef1.getName());
+ return stringPropDef1;
+ }
+
+ private static PropertyDefinitionSimple createStringPropDef2() {
+ PropertyDefinitionSimple stringPropDef2;
+ stringPropDef2 = new PropertyDefinitionSimple("String2",
+ "a read-only String simple prop", false, PropertySimpleType.STRING);
+ stringPropDef2.setDisplayName(stringPropDef2.getName());
+ stringPropDef2.setReadOnly(true);
+ return stringPropDef2;
+ }
+
+ private static PropertyDefinitionSimple createIntegerPropDef() {
+ PropertyDefinitionSimple integerPropDef;
+ integerPropDef = new PropertyDefinitionSimple("Integer",
+ "a required summary Integer simple prop", true, PropertySimpleType.INTEGER);
+ integerPropDef.setDisplayName(integerPropDef.getName());
+ integerPropDef.setSummary(true);
+ return integerPropDef;
+ }
+
+ private TestConfigurationFactory() {
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
new file mode 100644
index 0000000..1f7ccaf
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationView.java
@@ -0,0 +1,133 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.test.configuration;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Ian Springer
+ */
+public class TestConfigurationView
+ extends LocatableVLayout implements PropertyValueChangeListener {
+ public static final String VIEW_ID = "TestConfig";
+
+ private ConfigurationEditor editor;
+ private LocatableIButton saveButton;
+ private ConfigurationDefinition configurationDefinition;
+ private Configuration configuration;
+
+ public TestConfigurationView(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ build();
+ }
+
+ public void build() {
+ setWidth100();
+ setHeight100();
+
+ ToolStrip toolStrip = new ToolStrip();
+ toolStrip.setWidth100();
+
+ toolStrip.addMember(new LayoutSpacer());
+
+ this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
+ this.saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+ this.saveButton.disable();
+ toolStrip.addMember(this.saveButton);
+
+ addMember(toolStrip);
+
+ this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
+ this.configuration = TestConfigurationFactory.createConfiguration();
+
+ reloadConfiguration();
+ }
+
+ @Override
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
+ MessageCenter messageCenter = CoreGUI.getMessageCenter();
+ Message message;
+ if (event.isValidationStateChanged()) {
+ Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (invalidPropertyNames.isEmpty()) {
+ this.saveButton.enable();
+ message = new Message("All properties now have valid values, so the configuration can now be saved.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ else {
+ this.saveButton.disable();
+ message = new Message(
+ "The following properties have invalid values: " + invalidPropertyNames
+ + " - the values must be corrected before the configuration can be saved.",
+ Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
+ }
+ else {
+ this.saveButton.enable();
+ }
+ }
+
+ private void reloadConfiguration() {
+ this.saveButton.disable();
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+
+ editor = new ConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition, this.configuration);
+ editor.setOverflow(Overflow.AUTO);
+ editor.addPropertyValueChangeListener(this);
+ addMember(editor);
+ }
+
+ private void save() {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Configuration updated.", "Test configuration updated."));
+ reloadConfiguration();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java
new file mode 100644
index 0000000..1a8b304
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestGroupConfigurationView.java
@@ -0,0 +1,142 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.test.configuration;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.GroupMemberConfiguration;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Ian Springer
+ */
+public class TestGroupConfigurationView
+ extends LocatableVLayout implements PropertyValueChangeListener {
+ public static final String VIEW_ID = "TestGroupConfig";
+
+ private static final int GROUP_SIZE = 2;
+
+ private ConfigurationEditor editor;
+ private LocatableIButton saveButton;
+ private ConfigurationDefinition configurationDefinition;
+ private List<GroupMemberConfiguration> memberConfigurations;
+
+ public TestGroupConfigurationView(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ setWidth100();
+ setHeight100();
+
+ ToolStrip toolStrip = new ToolStrip();
+ toolStrip.setWidth100();
+
+ toolStrip.addMember(new LayoutSpacer());
+
+ this.saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
+ this.saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+ this.saveButton.disable();
+ toolStrip.addMember(this.saveButton);
+
+ addMember(toolStrip);
+
+ this.configurationDefinition = TestConfigurationFactory.createConfigurationDefinition();
+ this.memberConfigurations = new ArrayList<GroupMemberConfiguration>(GROUP_SIZE);
+ for (int i = 0; i < GROUP_SIZE; i++) {
+ Configuration configuration = TestConfigurationFactory.createConfiguration();
+ GroupMemberConfiguration memberConfiguration = new GroupMemberConfiguration(i, "Member #" + i,
+ configuration);
+ this.memberConfigurations.add(memberConfiguration);
+ }
+
+ reloadConfiguration();
+ }
+
+ @Override
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
+ MessageCenter messageCenter = CoreGUI.getMessageCenter();
+ Message message;
+ if (event.isValidationStateChanged()) {
+ Set<String> invalidPropertyNames = event.getInvalidPropertyNames();
+ if (invalidPropertyNames.isEmpty()) {
+ this.saveButton.enable();
+ message = new Message("All properties now have valid values, so the configuration can now be saved.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ else {
+ this.saveButton.disable();
+ message = new Message(
+ "The following properties have invalid values: " + invalidPropertyNames
+ + " - the values must be corrected before the configuration can be saved.",
+ Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
+ } else {
+ this.saveButton.enable();
+ }
+ }
+
+ private void reloadConfiguration() {
+ this.saveButton.disable();
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+
+ editor = new GroupConfigurationEditor(extendLocatorId("Editor"), this.configurationDefinition,
+ this.memberConfigurations);
+ editor.setOverflow(Overflow.AUTO);
+ editor.addPropertyValueChangeListener(this);
+ addMember(editor);
+ }
+
+ private void save() {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Member configurations updated.", "Member configurations updated."));
+ reloadConfiguration();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index 1f95a24..f0c901d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -96,7 +96,6 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
private void clearMessage(boolean clearSticky) {
if (this.label != null) {
this.label.destroy();
- removeMember(this.label);
markForRedraw();
}
if (clearSticky) {
13 years, 6 months
[rhq] Branch 'delete-agent-plugin' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy | 29 ++++++++++
1 file changed, 29 insertions(+)
New commits:
commit 64a04708aefba1b125660ea2ae0531f1beb1700c
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Oct 28 13:35:46 2010 -0400
Adding tests to verify process scans and subcategories get deleted
diff --git a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
index fec1ef4..3500b87 100644
--- a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
+++ b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
@@ -275,6 +275,17 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
<server name="ServerC" description="Server C description">
+
+ <subcategories>
+ <subcategory name="ServerC.Category1">
+ <subcategory name="ServerC.NestedCategory1"/>
+ </subcategory>
+ <subcategory name="ServerC.Category2"/>
+ </subcategories>
+
+ <process-scan name="scan1" query="process|basename|match=^java.*,arg|org.rhq.serverC1|match=.*"/>
+ <process-scan name="scan2" query="process|basename|match=^java.*,arg|org.rhq.serverC2|match=.*"/>
+
<operation name="run">
<parameters>
<c:simple-property name="script"/>
@@ -361,7 +372,25 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
@Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
void deleteProcessScans() {
+ def processScans = entityManager.createQuery("from ProcessScan p where p.name = :name1 or p.name = :name2")
+ .setParameter("name1", "scan1")
+ .setParameter("name2", "scan2")
+ .getResultList()
+
+ assertEquals "The process scans should have been deleted", 0, processScans.size()
+ }
+
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
+ void deleteSubcategories() {
+ def subcategories = entityManager.createQuery("""
+ from ResourceSubCategory r
+ where r.name = :name1 or r.name = :name2 or r.name = :name3""")
+ .setParameter("name1", "ServerC.Category1")
+ .setParameter("name2", "ServerC.Category2")
+ .setParameter("name3", "ServerC.NestedCategory1")
+ .getResultList()
+ assertEquals "The subcategories should have been deleted", 0, subcategories.size()
}
/**
13 years, 6 months
[rhq] Branch 'delete-agent-plugin' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy | 183 +++++-----
1 file changed, 93 insertions(+), 90 deletions(-)
New commits:
commit f773e4907c08d62fc485c00b92209ad887955897
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Oct 28 12:21:19 2010 -0400
Clean up database after tests have run
The tests in ResourceMetadataManagerBeanTest have to commit changes to
the db and leaving plugins in the database in the RHQ_PLUGINS table is
causing subsequent failures in DatabaseAndFilePluginDeploymentTest. I
have added logic to remove all plugins added to the database during
test runs in ResourceMetadataManagerBeanTest.
Also adding some more tests for verifying behavior when resource types
are removed.
diff --git a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
index dd0ef01..fec1ef4 100644
--- a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
+++ b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
@@ -14,9 +14,25 @@ import org.rhq.core.domain.resource.ResourceType
import org.rhq.test.AssertUtils
import org.rhq.core.domain.criteria.ResourceTypeCriteria
import org.rhq.core.domain.criteria.OperationDefinitionCriteria
+import org.testng.annotations.AfterClass
+import org.hibernate.Session
class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
+ def plugins = []
+
+ @AfterClass
+ void removePluginsFromDB() {
+ transactionManager.begin()
+ // using direct hibernate query here because JPA 1.0 lacks support for the IN clause
+ // where you can directly specify a collection for the parameter value used in an IN
+ // clause
+ Session session = entityManager.getDelegate()
+ session.createQuery("delete from Plugin p where p.name in (:plugins)").setParameterList("plugins", plugins)
+ .executeUpdate()
+ transactionManager.commit()
+ }
+
@Test(groups = ['NewPlugin'])
void registerPlugin() {
def pluginDescriptor =
@@ -25,11 +41,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
- <server name="ServerA"
- description="Server A description"
- class="org.rhq.plugins.test.ServerA"
- discovery="org.rhq.plugins.test.ServerADiscoveryComponent">
-
+ <server name="ServerA" description="Server A description">
<subcategories>
<subcategory name="Resources" description="Resources subcategory"/>
<subcategory name="Applications" description="Applications subcategory"/>
@@ -66,55 +78,15 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
<event name="logAEntry" description="an entry was appended to a log file"/>
<event name="logBEntry" description="an entry was appended to a log file"/>
- <service name="Child1"
- description="Child 1 description"
- class="org.rhq.plugins.test.Child1"
- discovery="org.rhq.plugins.test.Child1ServiceDiscoveryComponent"/>
- <service name="Child2"
- description="Child 2 description"
- class="org.rhq.plugins.test.Child2"
- discovery="org.rhq.plugins.test.Child2ServiceDiscoveryComponent"/>
- </server>
-
- <server name="ServerB"
- description="Server B description"
- class="org.rhq.plugins.test.ServerB"
- discovery="org.rhq.plugins.test.ServerBDiscoveryComponent"/>
-
- <server name="ServerC"
- description="Server C description"
- class="org.rhq.plugins.test.ServerC"
- discovery="org.rhq.plugins.test.ServerCDiscoveryComponent">
-
- <operation name="run">
- <parameters>
- <c:simple-property name="script"/>
- </parameters>
- <results>
- <c:simple-property name="errors"/>
- </results>
- </operation>
-
- <event name="serverCEvent" description="an entry was appended to a log file"/>
+ <service name="Child1" description="Child 1 description"/>
+ <service name="Child2" description="Child 2 description"/>
</server>
- <server name="ServerD">
- <service name="ServerD.Child1">
- <service name="ServerD.GrandChild1"/>
- </service>
- </server>
+ <server name="ServerB" description="Server B description"/>
</plugin>
"""
- def args = createPlugin("test-plugin", pluginDescriptor, "1.0")
- Assert.assertNotNull args.plugin
- Assert.assertNotNull args.pluginFile
- Assert.assertNotNull args.pluginDescriptor
-
- def subjectMgr = LookupUtil.subjectManager
- def resourceMetadataMgr = LookupUtil.resourceMetadataManager
-
- resourceMetadataMgr.registerPlugin(subjectMgr.overlord, args.plugin, args.pluginDescriptor, args.pluginFile, false)
+ createPlugin("test-plugin", "1.0", pluginDescriptor)
}
@Test(dependsOnMethods = ['registerPlugin'], groups = ['NewPlugin'])
@@ -189,10 +161,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
- <server name="ServerA"
- description="Server A description"
- class="org.rhq.plugins.test.ServerA"
- discovery="org.rhq.plugins.test.ServerADiscoveryComponent">
+ <server name="ServerA" description="Server A description">
<subcategories>
<subcategory name="Resources" description="Resources subcategory"/>
@@ -240,41 +209,17 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
<event name="logAEntry" description="an entry was appended to a log file"/>
<event name="logCEntry" description="an entry was appended to a log file"/>
- <service name="Child1"
- description="Child 1 description"
- class="org.rhq.plugins.test.Child1"
- discovery="org.rhq.plugins.test.Child1ServiceDiscoveryComponent"/>
-
- <service name="Child3"
- description="Child 3 description"
- class="org.rhq.plugins.test.Child3"
- discovery="org.rhq.plugins.test.Child3ServiceDiscoveryComponent"/>
- </server>
- <server name="ServerB"
- description="Server B description"
- class="org.rhq.plugins.test.ServerB"
- discovery="org.rhq.plugins.test.ServerBDiscoveryComponent">
- <service name="Child2"
- description="Child 2 description"
- class="org.rhq.plugins.test.Child2"
- discovery="org.rhq.plugins.test.Child2ServiceDiscoveryComponent"/>
+ <service name="Child1"/>
+ <service name="Child3"/>
</server>
- <server name="ServerD">
- <service name="ServerD.GrandChild1"/>
+ <server name="ServerB" description="Server B description">
+ <service name="Child2"/>
</server>
</plugin>
"""
- def args = createPlugin("test-plugin", pluginDescriptor, "2.0")
- Assert.assertNotNull args.plugin
- Assert.assertNotNull args.pluginFile
- Assert.assertNotNull args.pluginDescriptor
-
- def subjectMgr = LookupUtil.subjectManager
- def resourceMetadataMgr = LookupUtil.resourceMetadataManager
-
- resourceMetadataMgr.registerPlugin(subjectMgr.overlord, args.plugin, args.pluginDescriptor, args.pluginFile, true)
+ createPlugin("test-plugin", "2.0", pluginDescriptor)
}
@Test(dependsOnMethods = ['upgradePlugin'], groups = ['UpgradePlugin'])
@@ -296,7 +241,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
}
@Test(dependsOnMethods = ['upgradePlugin'], groups = ['UpgradePlugin'])
- void upgradeParentTypeWhenTypeChangesParents() {
+ void upgradeParentTypeOfChild() {
assertAssociationEquals(
'ServerB',
'childResourceTypes',
@@ -322,7 +267,51 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
)
}
- @Test(dependsOnMethods = ['upgradePlugin'], groups = ['UpgradePlugin'])
+ @Test(groups = ['RemoveTypes'], dependsOnGroups = ['UpgradePlugin'])
+ void upgradePluginWithTypesRemoved() {
+ def originalDescriptor = """
+ <plugin name="RemoveTypesPlugin" displayName="Remove Types Plugin" package="org.rhq.plugins.test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+ <server name="ServerC" description="Server C description">
+ <operation name="run">
+ <parameters>
+ <c:simple-property name="script"/>
+ </parameters>
+ <results>
+ <c:simple-property name="errors"/>
+ </results>
+ </operation>
+
+ <event name="serverCEvent" description="an entry was appended to a log file"/>
+ </server>
+
+ <server name="ServerD">
+ <service name="ServerD.Child1">
+ <service name="ServerD.GrandChild1"/>
+ </service>
+ </server>
+ </plugin>
+ """
+
+ createPlugin 'remove-types-plugin', '1.0', originalDescriptor
+
+ def updatedDescriptor = """
+ <plugin name="RemoveTypesPlugin" displayName="Remove Types Plugin" package="org.rhq.plugins.test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+ <server name="ServerD">
+ <service name="ServerD.GrandChild1"/>
+ </server>
+ </plugin>
+ """
+
+ createPlugin 'remove-types-plugin', '2.0', updatedDescriptor
+ }
+
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
void deleteOperationDefsForRemovedType() {
def operationMgr = LookupUtil.operationManager
def subjectMgr = LookupUtil.subjectManager
@@ -336,7 +325,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
assertEquals "The operation definition should have been deleted", 0, operationDefs.size()
}
- @Test(dependsOnMethods = ['upgradePlugin'], groups = ['UpgradePlugin'])
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
void deleteEventDefsForRemovedType() {
def results = entityManager.createQuery(
"from EventDefinition e where e.name = :ename and e.resourceType.name = :rname")
@@ -347,14 +336,14 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
assertEquals "The event definition(s) should have been deleted", 0, results.size()
}
- @Test(dependsOnMethods = ['upgradePlugin'], groups = ['UpgradePlugin'])
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
void deleteParent() {
def subjectMgr = LookupUtil.subjectManager
def resourceTypeMgr = LookupUtil.resourceTypeManager
def criteria = new ResourceTypeCriteria()
- criteria.addFilterName "GrandChild1"
- criteria.addFilterPluginName "TestPlugin"
+ criteria.addFilterName "ServerD.GrandChild1"
+ criteria.addFilterPluginName "RemoveTypesPlugin"
criteria.fetchParentResourceTypes true
def types = resourceTypeMgr.findResourceTypesByCriteria(subjectMgr.overlord, criteria)
@@ -370,6 +359,11 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
assertNotNull "Expected to find 'ServerD' as the parent, but found, $type.parentResourceTypes", parentType
}
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
+ void deleteProcessScans() {
+
+ }
+
/**
* This method creates the plugin-related artifacts that are need to call
* ResourceMetadataManager.registerPlugin. It creates the PluginDescriptor object, and
@@ -387,7 +381,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
* @return A map containing the generated artifacts. The maps keys are pluginDescriptor,
* pluginFile, and plugin
*/
- def createPlugin(String pluginFileName, String descriptor, String version) {
+ def createPlugin(String pluginFileName, String version, String descriptor) {
def pluginDescriptor = toPluginDescriptor(descriptor)
def pluginFilePath = "$currentWorkingDir/${pluginFileName}.jar"
@@ -414,7 +408,16 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
plugin.version = pluginDescriptor.version
plugin.MD5 = MessageDigestGenerator.getDigestString(pluginFile)
- return [pluginDescriptor: pluginDescriptor, pluginFile: pluginFile, plugin: plugin]
+ Assert.assertNotNull plugin
+ Assert.assertTrue pluginFile.exists()
+ Assert.assertNotNull pluginDescriptor
+
+ def subjectMgr = LookupUtil.subjectManager
+ def resourceMetadataMgr = LookupUtil.resourceMetadataManager
+
+ resourceMetadataMgr.registerPlugin(subjectMgr.overlord, plugin, pluginDescriptor, pluginFile, true)
+
+ plugins << plugin.name
}
String getPluginWorkDir() {
13 years, 6 months
[rhq] Branch 'delete-agent-plugin' - modules/core modules/enterprise
by John Sanda
modules/core/domain-test-utils/pom.xml | 36
modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/BuilderException.java | 49 -
modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/ResourceBuilder.java | 413 ---------
modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/ResourceTypeBuilder.java | 139 ---
modules/core/domain/pom.xml | 17
modules/core/domain/src/test/java/org/rhq/core/domain/shared/BuilderException.java | 49 +
modules/core/domain/src/test/java/org/rhq/core/domain/shared/ResourceBuilder.java | 417 ++++++++++
modules/core/domain/src/test/java/org/rhq/core/domain/shared/ResourceTypeBuilder.java | 142 +++
modules/core/pom.xml | 1
modules/enterprise/remoting/cli/pom.xml | 4
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java | 2
modules/enterprise/server/jar/mvn.out | 1
modules/enterprise/server/jar/pom.xml | 3
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java | 7
14 files changed, 634 insertions(+), 646 deletions(-)
New commits:
commit 15611a63e0fdf9e8aea9e133c37644d964c5df38
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Oct 28 10:43:03 2010 -0400
Removing domain-test-utils module to avoid potential circular dependencies
domain-test-utils had a depdendency on core/domain, tests in core/domain
might very well want to use the classes in domain-test-utils which would
result in a circular dependency. The classes in domain-test-utils have
been moved into core/domain and are made available to other modules as a
test jar.
diff --git a/modules/core/domain-test-utils/pom.xml b/modules/core/domain-test-utils/pom.xml
deleted file mode 100644
index 97cb509..0000000
--- a/modules/core/domain-test-utils/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain-test-utils</artifactId>
- <name>RHQ Domain Model Test Utils</name>
-
- <dependencies>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <type>ejb</type>
- </dependency>
- <dependency>
- <groupId>hibernate-annotations</groupId>
- <artifactId>hibernate-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>hibernate-entitymanager</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/BuilderException.java b/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/BuilderException.java
deleted file mode 100644
index 7277c3c..0000000
--- a/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/BuilderException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.resource;
-
-/**
- * A builder will throw this exception if it is unable to build the target object. For example, if example if all
- * required properites of the target object do not have non-null values, then the builder will throw this exception.
- *
- * @author John Sanda
- */
-public class BuilderException extends RuntimeException {
-
- public BuilderException() {
- super();
- }
-
- public BuilderException(String message) {
- super(message);
- }
-
- public BuilderException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public BuilderException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/ResourceBuilder.java b/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/ResourceBuilder.java
deleted file mode 100644
index c065d1f..0000000
--- a/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/ResourceBuilder.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * 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.resource;
-
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.ResourceAvailability;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * ResoureBuilder is a builder object that creates Resource objects. The builder ensures that a Resource is created
- * in a valid state, specifically, fields that are not nullable are required to have non-null values. Using a builder
- * should help make the intent of tests clearer and more self-documenting.
- * <br/><br/>
- * Note that this class currently does not yet provide support for all Resource fields/properties.
- *
- * @author John Sanda
- */
-public class ResourceBuilder {
-
- private ResourceBuilder parentBuilder;
-
- private Resource resource;
-
- private Random random;
-
- private boolean useDefaultResourceType;
-
- private ResourceCategory category;
-
- private List<ResourceBuilder> childBuilders = new ArrayList<ResourceBuilder>();
-
- public static class AssociationBuilder {
- private ResourceBuilder resourceBuilder;
-
- private int count;
-
- AssociationBuilder(ResourceBuilder builder, int count) {
- resourceBuilder = builder;
- this.count = count;
- }
-
- public ResourceBuilder randomChildServers() {
- for (int i = 0; i < count; ++i) {
- ResourceBuilder childBuilder = new ResourceBuilder(ResourceCategory.SERVER, resourceBuilder);
- resourceBuilder.childBuilders.add(childBuilder.createRandomServer());
- }
- return resourceBuilder;
- }
-
- public ResourceBuilder randomChildServices() {
- for (int i = 0; i < count; ++i) {
- ResourceBuilder childBuilder = new ResourceBuilder(ResourceCategory.SERVICE, resourceBuilder);
- resourceBuilder.childBuilders.add(childBuilder.createRandomService());
- }
- return resourceBuilder;
- }
- }
-
- public static class ChildrenResourceBuilder {
- private ResourceBuilder parentBuilder;
-
- ChildrenResourceBuilder(ResourceBuilder builder, ResourceCategory category, int numChildren) {
- parentBuilder = builder;
- parentBuilder.childBuilders = new ArrayList<ResourceBuilder>(numChildren);
- for (int i = 0; i < numChildren; ++i) {
- parentBuilder.childBuilders.add(new ResourceBuilder(category, parentBuilder).createResource());
- }
- }
-
- public ChildrenResourceBuilder inInventory() {
- for (ResourceBuilder childBuilder : parentBuilder.childBuilders) {
- childBuilder.inInventory();
- }
- return this;
- }
-
- public ChildrenResourceBuilder notInInventory() {
- for (ResourceBuilder childBuilder : parentBuilder.childBuilders) {
- childBuilder.notInInventory();
- }
- return this;
- }
-
- public ResourceBuilder included() {
- return parentBuilder;
- }
- }
-
-
- public ResourceBuilder() {
- }
-
- private ResourceBuilder(ResourceCategory category, ResourceBuilder parentBuilder) {
- this.category = category;
- this.parentBuilder = parentBuilder;
- }
-
- public ResourceBuilder createResource() {
- resource = new Resource();
- random = new Random();
- return this;
- }
-
- public ResourceBuilder createPlatform() {
- category = ResourceCategory.PLATFORM;
- return createResource();
- }
-
- public ResourceBuilder createServer() {
- category = ResourceCategory.SERVER;
- return createResource();
- }
-
- public ResourceBuilder createRandomServer() {
- category = ResourceCategory.SERVER;
- createResource();
- withRandomId();
- withRandomName("server:");
- withRandomResourceKey("server:");
- withRandomUuid("server:");
- withDefaultServerResourceType();
-
- return this;
- }
-
- public ResourceBuilder createService() {
- category = ResourceCategory.SERVICE;
- return createResource();
- }
-
- public ResourceBuilder createRandomService() {
- category = ResourceCategory.SERVICE;
- createResource();
- withRandomId();
- withRandomName("service:");
- withRandomResourceKey("service:");
- withRandomUuid("service:");
- withDefaultServiceResourceType();
-
- return this;
- }
-
- /**
- * Using a default resource type results in <code>Resource.resourceType</code> being assigned to a new
- * ResourceType object that has some default values applied to it. If the Resource being created is a platform, then
- * the ResourceType will be a platform. More specifically, <code>ResourceType.category</code> will be assigned a
- * value of {@link ResourceCategory#PLATFORM}. Likewise, if the Resource being created is a server, then its
- * ResourceType object will have a category of {@link ResourceCategory#SERVER}. And if the Resource is a service,
- * then the ResourceType category will be {@link ResourceCategory#SERVICE}.
- * <br/><br/>
- * The resource type name defaults to the name of resource. And the plugin name (as specified by
- * ResourceType.plugin) defaults to <code>Resource.name + " Plugin"</code>
- * <br/><br/>
- * When using a default resource type, the resource must be created using one of {@link #createPlatform()},
- * {@link #createServer()}, or {@link #createService()}; otherwise, an exception will be thrown since the builder
- * will not have sufficient information to create the resource type.
- * <br/><br/>
- * Lastly, if you specify that a default resource type by calling this method and also specify the resource tye
- * with {@link #withResourceType(ResourceType)}, the latter will be overwritten regardless of when it is called. The
- * default will be used instead.
- *
- * @return The builder
- *
- */
- public ResourceBuilder usingDefaultResourceType() {
- useDefaultResourceType = true;
- return this;
- }
-
- public ResourceBuilder withId(int id) {
- resource.setId(id);
- return this;
- }
-
- public ResourceBuilder withRandomId() {
- resource.setId(random.nextInt());
- return this;
- }
-
- public ResourceBuilder withResourceKey(String key) {
- resource.setResourceKey(key);
- return this;
- }
-
- public ResourceBuilder withRandomResourceKey(String prefix) {
- resource.setResourceKey(prefix + randomString());
- return this;
- }
-
- public ResourceBuilder withRandomResourceKey() {
- return withRandomResourceKey("");
- }
-
- public ResourceBuilder withName(String name) {
- resource.setName(name);
- return this;
- }
-
- public ResourceBuilder withRandomName(String prefix) {
- resource.setName(prefix + randomString());
- return this;
- }
-
- public ResourceBuilder withRandomName() {
- return withRandomName("");
- }
-
- public ResourceBuilder withResourceType(ResourceType resourceType) {
- resource.setResourceType(resourceType);
- return this;
- }
-
- public ResourceBuilder withUuid(String uuid) {
- resource.setUuid(uuid);
- return this;
- }
-
- public ResourceBuilder withRandomUuid(String prefix) {
- resource.setUuid(prefix + randomString());
- return this;
- }
-
- public ResourceBuilder withRandomUuid() {
- return withRandomUuid("");
- }
-
- public ResourceBuilder withVersion(String version) {
- resource.setVersion(version);
- return this;
- }
-
- public ResourceBuilder withCurrentAvailability(AvailabilityType availabilityType) {
- ResourceAvailability availability = new ResourceAvailability(resource, availabilityType);
- resource.setCurrentAvailability(availability);
- return this;
- }
-
- public ResourceBuilder withInventoryStatus(InventoryStatus inventoryStatus) {
- resource.setInventoryStatus(inventoryStatus);
- return this;
- }
-
- /**
- * Set the <code>inventoryStatus</code> to {@link InventoryStatus#COMMITTED}
- *
- * @return The builder
- */
- public ResourceBuilder inInventory() {
- resource.setInventoryStatus(InventoryStatus.COMMITTED);
- return this;
- }
-
- /**
- * Set the <code>inventoryStatus</code> to {@link InventoryStatus#NEW}
- *
- * @return The builder
- */
- public ResourceBuilder notInInventory() {
- resource.setInventoryStatus(InventoryStatus.NEW);
- return this;
- }
-
- public AssociationBuilder with(int count) {
- return new AssociationBuilder(this, count);
- }
-
- public ResourceBuilder withChildService() {
- ResourceBuilder childBuilder = new ResourceBuilder(ResourceCategory.SERVICE, this);
- childBuilders.add(childBuilder.createService());
- return childBuilder;
- }
-
- public ResourceBuilder included() {
- return this.parentBuilder;
- }
-
- public Resource build() {
- String errors = validate();
- if (errors != null) {
- throw new BuilderException(errors);
- }
-
- if (useDefaultResourceType) {
- withDefaultResourceType();
- }
-
- for (ResourceBuilder childBuilder : childBuilders) {
- resource.addChildResource(childBuilder.build());
- }
-
- return resource;
- }
-
- private String validate() {
- StringBuilder errors = new StringBuilder();
-
- if (resource.getUuid() == null) {
- // Making uuid required since it is used in equals/hashCode
- errors.append("uuid is a required property\n");
- }
-
- if (resource.getName() == null) {
- errors.append("name is a required property\n");
- }
-
- if (useDefaultResourceType && category == null) {
- errors.append("When using default resource type, the resource must be created with one of " +
- "createPlatform(), createServer(), or createService()\n");
- }
-
- // We only care that resourceType is set if we are not using a default type. If we are using a default,
- // then the resourceType property will be set after validation, assuming there are no validation errors.
- if (!useDefaultResourceType && resource.getResourceType() == null) {
- errors.append("resourceType is a required property\n");
- }
-
- for (ResourceBuilder childBuilder : childBuilders) {
- String childErrors = childBuilder.validate();
- if (childErrors != null) {
- errors.append("The following child resource errors were found:\n" + childErrors);
- }
- }
-
- if (errors.length() == 0) {
- return null;
- }
-
- return "Unable to build Resource instance due to the following validation errors:\n" + errors;
- }
-
- private ResourceBuilder withDefaultResourceType() {
- switch (category) {
- case PLATFORM: return withDefaultPlatformResourceType();
- case SERVER: return withDefaultServerResourceType();
- default: return withDefaultServiceResourceType();
- }
- }
-
- /**
- * The default platform resource type is as its name implies a platform type whose name defaults to the resource
- * name and the plugin name (i.e., ResourceType.plugin property) defaults to resource name + 'Plugin'.
- *
- * @return The builder
- */
- private ResourceBuilder withDefaultPlatformResourceType() {
- resource.setResourceType(new ResourceTypeBuilder().createPlatformResourceType()
- .withName(resource.getName())
- .withPlugin(resource.getName() + " Plugin")
- .withParentResourceType(resource.getResourceType())
- .build());
- return this;
- }
-
- /**
- * The default server resource type is as its name implies a server type whose name defaults to the resource name
- * and the plugin name (i.e., ResourceType.plugin property) defaults to resource name + 'Plugin'
- *
- * @return The builder
- */
- private ResourceBuilder withDefaultServerResourceType() {
- resource.setResourceType(new ResourceTypeBuilder().createServerResourceType()
- .withName(resource.getName())
- .withPlugin(resource.getName() + " Plugin")
- .withParentResourceType(resource.getResourceType())
- .build());
- return this;
- }
-
- /**
- * The default service resource type is as its name implies a service type whose name defaults to the resource name
- * and the plugin name (i.e., ResourceType.plugin property) defaults to resource name + 'Plugin'
- *
- * @return The builder
- */
- private ResourceBuilder withDefaultServiceResourceType() {
- resource.setResourceType(new ResourceTypeBuilder().createServerResourceType()
- .withName(resource.getName())
- .withPlugin(resource.getName() + " Plugin")
- .withParentResourceType(resource.getResourceType())
- .build());
- return this;
- }
-
- private String randomString() {
- return new BigInteger(16, random).toString(32);
- }
-
-}
diff --git a/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/ResourceTypeBuilder.java b/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/ResourceTypeBuilder.java
deleted file mode 100644
index 2e83fd3..0000000
--- a/modules/core/domain-test-utils/src/main/java/org/rhq/core/domain/resource/ResourceTypeBuilder.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.resource;
-
-import java.util.HashSet;
-
-/**
- * ResourceTypeBuilder is a builder that creates ResourceType objects. The builder ensures that the ResourceType is
- * created in a valid state, specifically fields that are not nullable are required to have non-null values. Using the
- * builder should help make the intent of tests clearer and more self-documenting.
- * <br/><br/>
- * Note that this class currently does not yet provide support for all ResourceType fields/properties.
- *
- * @author John Sanda
- */
-public class ResourceTypeBuilder {
-
- private ResourceType resourceType;
-
- public ResourceTypeBuilder createResourceType() {
- resourceType = new ResourceType();
- resourceType.setParentResourceTypes(new HashSet<ResourceType>());
- resourceType.setChildResourceTypes(new HashSet<ResourceType>());
-
- return this;
- }
-
- public ResourceTypeBuilder createPlatformResourceType() {
- return createResourceType().withCategory(ResourceCategory.PLATFORM);
- }
-
- public ResourceTypeBuilder createServerResourceType() {
- return createResourceType().withCategory(ResourceCategory.SERVER);
- }
-
- public ResourceTypeBuilder createServiceResourceType() {
- return createResourceType().withCategory(ResourceCategory.SERVICE);
- }
-
- public ResourceTypeBuilder withId(int id) {
- resourceType.setId(id);
- return this;
- }
-
- public ResourceTypeBuilder withName(String name) {
- resourceType.setName(name);
- return this;
- }
-
- public ResourceTypeBuilder withPlugin(String plugin) {
- resourceType.setPlugin(plugin);
- return this;
- }
-
- public ResourceTypeBuilder withCategory(ResourceCategory category) {
- resourceType.setCategory(category);
- return this;
- }
-
- public ResourceTypeBuilder thatIsDeleted() {
- resourceType.setDeleted(true);
- return this;
- }
-
- public ResourceTypeBuilder withParentResourceType(ResourceType parentResourceType) {
- if (parentResourceType != null) {
- resourceType.addParentResourceType(parentResourceType);
- }
- return this;
- }
-
- public ResourceTypeBuilder withParentResourceTypes(ResourceType... parentResourceTypes) {
- for (ResourceType parent : parentResourceTypes) {
- resourceType.addParentResourceType(parent);
- }
- return this;
- }
-
- public ResourceType build() {
- String errors = valdiate();
- if (errors != null) {
- throw new BuilderException(errors);
- }
-
- return resourceType;
- }
-
- private String valdiate() {
- StringBuilder errors = new StringBuilder();
-
- if (resourceType.getName() == null) {
- errors.append("name is a required property\n");
- }
-
- if (resourceType.getCategory() == null) {
- errors.append("category is a required property\n");
- }
-
- if (resourceType.getCreationDataType() == null) {
- errors.append("creationDate is a required property\n");
- }
-
- if (resourceType.getCreateDeletePolicy() == null) {
- errors.append("createDeletePolicy is a required property\n");
- }
-
- if (resourceType.getPlugin() == null) {
- errors.append("plugin is a required property\n");
- }
-
- if (errors.length() == 0) {
- return null;
- }
-
- return "Unable to build ResourceType instance due to the following validation errors:\n" + errors;
- }
-
-}
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index c7cca99..0fd6b98 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -288,6 +288,23 @@
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>org/rhq/core/domain/shared/**</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/shared/BuilderException.java b/modules/core/domain/src/test/java/org/rhq/core/domain/shared/BuilderException.java
new file mode 100644
index 0000000..9b0dcea
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/shared/BuilderException.java
@@ -0,0 +1,49 @@
+/*
+ * 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.shared;
+
+/**
+ * A builder will throw this exception if it is unable to build the target object. For example, if example if all
+ * required properites of the target object do not have non-null values, then the builder will throw this exception.
+ *
+ * @author John Sanda
+ */
+public class BuilderException extends RuntimeException {
+
+ public BuilderException() {
+ super();
+ }
+
+ public BuilderException(String message) {
+ super(message);
+ }
+
+ public BuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/shared/ResourceBuilder.java b/modules/core/domain/src/test/java/org/rhq/core/domain/shared/ResourceBuilder.java
new file mode 100644
index 0000000..d60749d
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/shared/ResourceBuilder.java
@@ -0,0 +1,417 @@
+/*
+ * 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.shared;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.ResourceAvailability;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+/**
+ * ResoureBuilder is a builder object that creates Resource objects. The builder ensures that a Resource is created
+ * in a valid state, specifically, fields that are not nullable are required to have non-null values. Using a builder
+ * should help make the intent of tests clearer and more self-documenting.
+ * <br/><br/>
+ * Note that this class currently does not yet provide support for all Resource fields/properties.
+ *
+ * @author John Sanda
+ */
+public class ResourceBuilder {
+
+ private ResourceBuilder parentBuilder;
+
+ private Resource resource;
+
+ private Random random;
+
+ private boolean useDefaultResourceType;
+
+ private ResourceCategory category;
+
+ private List<ResourceBuilder> childBuilders = new ArrayList<ResourceBuilder>();
+
+ public static class AssociationBuilder {
+ private ResourceBuilder resourceBuilder;
+
+ private int count;
+
+ AssociationBuilder(ResourceBuilder builder, int count) {
+ resourceBuilder = builder;
+ this.count = count;
+ }
+
+ public ResourceBuilder randomChildServers() {
+ for (int i = 0; i < count; ++i) {
+ ResourceBuilder childBuilder = new ResourceBuilder(ResourceCategory.SERVER, resourceBuilder);
+ resourceBuilder.childBuilders.add(childBuilder.createRandomServer());
+ }
+ return resourceBuilder;
+ }
+
+ public ResourceBuilder randomChildServices() {
+ for (int i = 0; i < count; ++i) {
+ ResourceBuilder childBuilder = new ResourceBuilder(ResourceCategory.SERVICE, resourceBuilder);
+ resourceBuilder.childBuilders.add(childBuilder.createRandomService());
+ }
+ return resourceBuilder;
+ }
+ }
+
+ public static class ChildrenResourceBuilder {
+ private ResourceBuilder parentBuilder;
+
+ ChildrenResourceBuilder(ResourceBuilder builder, ResourceCategory category, int numChildren) {
+ parentBuilder = builder;
+ parentBuilder.childBuilders = new ArrayList<ResourceBuilder>(numChildren);
+ for (int i = 0; i < numChildren; ++i) {
+ parentBuilder.childBuilders.add(new ResourceBuilder(category, parentBuilder).createResource());
+ }
+ }
+
+ public ChildrenResourceBuilder inInventory() {
+ for (ResourceBuilder childBuilder : parentBuilder.childBuilders) {
+ childBuilder.inInventory();
+ }
+ return this;
+ }
+
+ public ChildrenResourceBuilder notInInventory() {
+ for (ResourceBuilder childBuilder : parentBuilder.childBuilders) {
+ childBuilder.notInInventory();
+ }
+ return this;
+ }
+
+ public ResourceBuilder included() {
+ return parentBuilder;
+ }
+ }
+
+
+ public ResourceBuilder() {
+ }
+
+ private ResourceBuilder(ResourceCategory category, ResourceBuilder parentBuilder) {
+ this.category = category;
+ this.parentBuilder = parentBuilder;
+ }
+
+ public ResourceBuilder createResource() {
+ resource = new Resource();
+ random = new Random();
+ return this;
+ }
+
+ public ResourceBuilder createPlatform() {
+ category = ResourceCategory.PLATFORM;
+ return createResource();
+ }
+
+ public ResourceBuilder createServer() {
+ category = ResourceCategory.SERVER;
+ return createResource();
+ }
+
+ public ResourceBuilder createRandomServer() {
+ category = ResourceCategory.SERVER;
+ createResource();
+ withRandomId();
+ withRandomName("server:");
+ withRandomResourceKey("server:");
+ withRandomUuid("server:");
+ withDefaultServerResourceType();
+
+ return this;
+ }
+
+ public ResourceBuilder createService() {
+ category = ResourceCategory.SERVICE;
+ return createResource();
+ }
+
+ public ResourceBuilder createRandomService() {
+ category = ResourceCategory.SERVICE;
+ createResource();
+ withRandomId();
+ withRandomName("service:");
+ withRandomResourceKey("service:");
+ withRandomUuid("service:");
+ withDefaultServiceResourceType();
+
+ return this;
+ }
+
+ /**
+ * Using a default resource type results in <code>Resource.resourceType</code> being assigned to a new
+ * ResourceType object that has some default values applied to it. If the Resource being created is a platform, then
+ * the ResourceType will be a platform. More specifically, <code>ResourceType.category</code> will be assigned a
+ * value of {@link ResourceCategory#PLATFORM}. Likewise, if the Resource being created is a server, then its
+ * ResourceType object will have a category of {@link ResourceCategory#SERVER}. And if the Resource is a service,
+ * then the ResourceType category will be {@link ResourceCategory#SERVICE}.
+ * <br/><br/>
+ * The resource type name defaults to the name of resource. And the plugin name (as specified by
+ * ResourceType.plugin) defaults to <code>Resource.name + " Plugin"</code>
+ * <br/><br/>
+ * When using a default resource type, the resource must be created using one of {@link #createPlatform()},
+ * {@link #createServer()}, or {@link #createService()}; otherwise, an exception will be thrown since the builder
+ * will not have sufficient information to create the resource type.
+ * <br/><br/>
+ * Lastly, if you specify that a default resource type by calling this method and also specify the resource tye
+ * with {@link #withResourceType(org.rhq.core.domain.resource.ResourceType)}, the latter will be overwritten regardless of when it is called. The
+ * default will be used instead.
+ *
+ * @return The builder
+ *
+ */
+ public ResourceBuilder usingDefaultResourceType() {
+ useDefaultResourceType = true;
+ return this;
+ }
+
+ public ResourceBuilder withId(int id) {
+ resource.setId(id);
+ return this;
+ }
+
+ public ResourceBuilder withRandomId() {
+ resource.setId(random.nextInt());
+ return this;
+ }
+
+ public ResourceBuilder withResourceKey(String key) {
+ resource.setResourceKey(key);
+ return this;
+ }
+
+ public ResourceBuilder withRandomResourceKey(String prefix) {
+ resource.setResourceKey(prefix + randomString());
+ return this;
+ }
+
+ public ResourceBuilder withRandomResourceKey() {
+ return withRandomResourceKey("");
+ }
+
+ public ResourceBuilder withName(String name) {
+ resource.setName(name);
+ return this;
+ }
+
+ public ResourceBuilder withRandomName(String prefix) {
+ resource.setName(prefix + randomString());
+ return this;
+ }
+
+ public ResourceBuilder withRandomName() {
+ return withRandomName("");
+ }
+
+ public ResourceBuilder withResourceType(ResourceType resourceType) {
+ resource.setResourceType(resourceType);
+ return this;
+ }
+
+ public ResourceBuilder withUuid(String uuid) {
+ resource.setUuid(uuid);
+ return this;
+ }
+
+ public ResourceBuilder withRandomUuid(String prefix) {
+ resource.setUuid(prefix + randomString());
+ return this;
+ }
+
+ public ResourceBuilder withRandomUuid() {
+ return withRandomUuid("");
+ }
+
+ public ResourceBuilder withVersion(String version) {
+ resource.setVersion(version);
+ return this;
+ }
+
+ public ResourceBuilder withCurrentAvailability(AvailabilityType availabilityType) {
+ ResourceAvailability availability = new ResourceAvailability(resource, availabilityType);
+ resource.setCurrentAvailability(availability);
+ return this;
+ }
+
+ public ResourceBuilder withInventoryStatus(InventoryStatus inventoryStatus) {
+ resource.setInventoryStatus(inventoryStatus);
+ return this;
+ }
+
+ /**
+ * Set the <code>inventoryStatus</code> to {@link InventoryStatus#COMMITTED}
+ *
+ * @return The builder
+ */
+ public ResourceBuilder inInventory() {
+ resource.setInventoryStatus(InventoryStatus.COMMITTED);
+ return this;
+ }
+
+ /**
+ * Set the <code>inventoryStatus</code> to {@link InventoryStatus#NEW}
+ *
+ * @return The builder
+ */
+ public ResourceBuilder notInInventory() {
+ resource.setInventoryStatus(InventoryStatus.NEW);
+ return this;
+ }
+
+ public AssociationBuilder with(int count) {
+ return new AssociationBuilder(this, count);
+ }
+
+ public ResourceBuilder withChildService() {
+ ResourceBuilder childBuilder = new ResourceBuilder(ResourceCategory.SERVICE, this);
+ childBuilders.add(childBuilder.createService());
+ return childBuilder;
+ }
+
+ public ResourceBuilder included() {
+ return this.parentBuilder;
+ }
+
+ public Resource build() {
+ String errors = validate();
+ if (errors != null) {
+ throw new BuilderException(errors);
+ }
+
+ if (useDefaultResourceType) {
+ withDefaultResourceType();
+ }
+
+ for (ResourceBuilder childBuilder : childBuilders) {
+ resource.addChildResource(childBuilder.build());
+ }
+
+ return resource;
+ }
+
+ private String validate() {
+ StringBuilder errors = new StringBuilder();
+
+ if (resource.getUuid() == null) {
+ // Making uuid required since it is used in equals/hashCode
+ errors.append("uuid is a required property\n");
+ }
+
+ if (resource.getName() == null) {
+ errors.append("name is a required property\n");
+ }
+
+ if (useDefaultResourceType && category == null) {
+ errors.append("When using default resource type, the resource must be created with one of " +
+ "createPlatform(), createServer(), or createService()\n");
+ }
+
+ // We only care that resourceType is set if we are not using a default type. If we are using a default,
+ // then the resourceType property will be set after validation, assuming there are no validation errors.
+ if (!useDefaultResourceType && resource.getResourceType() == null) {
+ errors.append("resourceType is a required property\n");
+ }
+
+ for (ResourceBuilder childBuilder : childBuilders) {
+ String childErrors = childBuilder.validate();
+ if (childErrors != null) {
+ errors.append("The following child resource errors were found:\n" + childErrors);
+ }
+ }
+
+ if (errors.length() == 0) {
+ return null;
+ }
+
+ return "Unable to build Resource instance due to the following validation errors:\n" + errors;
+ }
+
+ private ResourceBuilder withDefaultResourceType() {
+ switch (category) {
+ case PLATFORM: return withDefaultPlatformResourceType();
+ case SERVER: return withDefaultServerResourceType();
+ default: return withDefaultServiceResourceType();
+ }
+ }
+
+ /**
+ * The default platform resource type is as its name implies a platform type whose name defaults to the resource
+ * name and the plugin name (i.e., ResourceType.plugin property) defaults to resource name + 'Plugin'.
+ *
+ * @return The builder
+ */
+ private ResourceBuilder withDefaultPlatformResourceType() {
+ resource.setResourceType(new ResourceTypeBuilder().createPlatformResourceType()
+ .withName(resource.getName())
+ .withPlugin(resource.getName() + " Plugin")
+ .withParentResourceType(resource.getResourceType())
+ .build());
+ return this;
+ }
+
+ /**
+ * The default server resource type is as its name implies a server type whose name defaults to the resource name
+ * and the plugin name (i.e., ResourceType.plugin property) defaults to resource name + 'Plugin'
+ *
+ * @return The builder
+ */
+ private ResourceBuilder withDefaultServerResourceType() {
+ resource.setResourceType(new ResourceTypeBuilder().createServerResourceType()
+ .withName(resource.getName())
+ .withPlugin(resource.getName() + " Plugin")
+ .withParentResourceType(resource.getResourceType())
+ .build());
+ return this;
+ }
+
+ /**
+ * The default service resource type is as its name implies a service type whose name defaults to the resource name
+ * and the plugin name (i.e., ResourceType.plugin property) defaults to resource name + 'Plugin'
+ *
+ * @return The builder
+ */
+ private ResourceBuilder withDefaultServiceResourceType() {
+ resource.setResourceType(new ResourceTypeBuilder().createServerResourceType()
+ .withName(resource.getName())
+ .withPlugin(resource.getName() + " Plugin")
+ .withParentResourceType(resource.getResourceType())
+ .build());
+ return this;
+ }
+
+ private String randomString() {
+ return new BigInteger(16, random).toString(32);
+ }
+
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/shared/ResourceTypeBuilder.java b/modules/core/domain/src/test/java/org/rhq/core/domain/shared/ResourceTypeBuilder.java
new file mode 100644
index 0000000..f6e55de
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/shared/ResourceTypeBuilder.java
@@ -0,0 +1,142 @@
+/*
+ * 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.shared;
+
+import java.util.HashSet;
+
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ * ResourceTypeBuilder is a builder that creates ResourceType objects. The builder ensures that the ResourceType is
+ * created in a valid state, specifically fields that are not nullable are required to have non-null values. Using the
+ * builder should help make the intent of tests clearer and more self-documenting.
+ * <br/><br/>
+ * Note that this class currently does not yet provide support for all ResourceType fields/properties.
+ *
+ * @author John Sanda
+ */
+public class ResourceTypeBuilder {
+
+ private ResourceType resourceType;
+
+ public ResourceTypeBuilder createResourceType() {
+ resourceType = new ResourceType();
+ resourceType.setParentResourceTypes(new HashSet<ResourceType>());
+ resourceType.setChildResourceTypes(new HashSet<ResourceType>());
+
+ return this;
+ }
+
+ public ResourceTypeBuilder createPlatformResourceType() {
+ return createResourceType().withCategory(ResourceCategory.PLATFORM);
+ }
+
+ public ResourceTypeBuilder createServerResourceType() {
+ return createResourceType().withCategory(ResourceCategory.SERVER);
+ }
+
+ public ResourceTypeBuilder createServiceResourceType() {
+ return createResourceType().withCategory(ResourceCategory.SERVICE);
+ }
+
+ public ResourceTypeBuilder withId(int id) {
+ resourceType.setId(id);
+ return this;
+ }
+
+ public ResourceTypeBuilder withName(String name) {
+ resourceType.setName(name);
+ return this;
+ }
+
+ public ResourceTypeBuilder withPlugin(String plugin) {
+ resourceType.setPlugin(plugin);
+ return this;
+ }
+
+ public ResourceTypeBuilder withCategory(ResourceCategory category) {
+ resourceType.setCategory(category);
+ return this;
+ }
+
+ public ResourceTypeBuilder thatIsDeleted() {
+ resourceType.setDeleted(true);
+ return this;
+ }
+
+ public ResourceTypeBuilder withParentResourceType(ResourceType parentResourceType) {
+ if (parentResourceType != null) {
+ resourceType.addParentResourceType(parentResourceType);
+ }
+ return this;
+ }
+
+ public ResourceTypeBuilder withParentResourceTypes(ResourceType... parentResourceTypes) {
+ for (ResourceType parent : parentResourceTypes) {
+ resourceType.addParentResourceType(parent);
+ }
+ return this;
+ }
+
+ public ResourceType build() {
+ String errors = valdiate();
+ if (errors != null) {
+ throw new BuilderException(errors);
+ }
+
+ return resourceType;
+ }
+
+ private String valdiate() {
+ StringBuilder errors = new StringBuilder();
+
+ if (resourceType.getName() == null) {
+ errors.append("name is a required property\n");
+ }
+
+ if (resourceType.getCategory() == null) {
+ errors.append("category is a required property\n");
+ }
+
+ if (resourceType.getCreationDataType() == null) {
+ errors.append("creationDate is a required property\n");
+ }
+
+ if (resourceType.getCreateDeletePolicy() == null) {
+ errors.append("createDeletePolicy is a required property\n");
+ }
+
+ if (resourceType.getPlugin() == null) {
+ errors.append("plugin is a required property\n");
+ }
+
+ if (errors.length() == 0) {
+ return null;
+ }
+
+ return "Unable to build ResourceType instance due to the following validation errors:\n" + errors;
+ }
+
+}
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index b936f26..f6f8289 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -47,7 +47,6 @@
<module>comm-api</module>
<module>dbutils</module>
<module>domain</module>
- <module>domain-test-utils</module>
<module>plugin-api</module>
<module>client-api</module>
<module>plugin-container</module>
diff --git a/modules/enterprise/remoting/cli/pom.xml b/modules/enterprise/remoting/cli/pom.xml
index d2c0f16..d67c325 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -35,8 +35,10 @@
<dependency>
<groupId>${groupId}</groupId>
- <artifactId>rhq-core-domain-test-utils</artifactId>
+ <artifactId>rhq-core-domain</artifactId>
<version>${version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
</dependency>
<dependency>
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java
index c9d8bb6..665abf0 100644
--- a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java
+++ b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/TabularWriterTest.java
@@ -26,7 +26,7 @@ package org.rhq.enterprise.client;
import static org.testng.Assert.*;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceBuilder;
+import org.rhq.core.domain.shared.ResourceBuilder;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
diff --git a/modules/enterprise/server/jar/mvn.out b/modules/enterprise/server/jar/mvn.out
new file mode 100644
index 0000000..2b43846
--- /dev/null
+++ b/modules/enterprise/server/jar/mvn.out
@@ -0,0 +1 @@
+[INFO] Scanning for projects...
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index ac041f1..e33e006 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -85,8 +85,9 @@
<dependency>
<groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain-test-utils</artifactId>
+ <artifactId>rhq-core-domain</artifactId>
<version>${project.version}</version>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java
index 13de583..a3cdcd2 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DeletedResourceTypeFilterTest.java
@@ -1,7 +1,5 @@
package org.rhq.enterprise.server.discovery;
-import java.util.List;
-
import org.jmock.Expectations;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -10,10 +8,9 @@ import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.resource.Agent;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceBuilder;
+import org.rhq.core.domain.shared.ResourceBuilder;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.ResourceTypeBuilder;
+import org.rhq.core.domain.shared.ResourceTypeBuilder;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
13 years, 6 months
[rhq] Branch 'delete-agent-plugin' - modules/core modules/enterprise
by John Sanda
modules/core/client-api-test-utils/pom.xml | 44 ---
modules/core/client-api-test-utils/src/main/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java | 144 ----------
modules/core/client-api/pom.xml | 32 +-
modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy | 10
modules/core/client-api/src/test/java/org/rhq/core/clientapi/shared/PluginDescriptorUtil.java | 144 ++++++++++
modules/core/pom.xml | 1
modules/enterprise/server/jar/pom.xml | 3
modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy | 43 ++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java | 70 ----
10 files changed, 205 insertions(+), 291 deletions(-)
New commits:
commit c06974d2297ded0d3bcafe99e5d4a254aca6e55e
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Oct 28 10:13:19 2010 -0400
Removing circular dependency that was caused by client-api-test-utils
client-api-test-utils was introduced as a shared, test helper module
that is used both by client-api and by server/jar (so far). The problem
is that client-api-test-utils also depends on client-api, creating a
circular dependency. I have moved the single class in
client-api-test-utils into client-api. We are now generating a test jar
that other modules can consume.
diff --git a/modules/core/client-api-test-utils/pom.xml b/modules/core/client-api-test-utils/pom.xml
deleted file mode 100644
index a7ba0a3..0000000
--- a/modules/core/client-api-test-utils/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-client-api-test-utils</artifactId>
-
- <name>RHQ Client API Test Utils</name>
- <description>Provides a test utility library for client API classes</description>
-
- <dependencies>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${rhq.groupId}</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-jxpath</groupId>
- <artifactId>commons-jxpath</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>jboss.jboss-embeddable-ejb3</groupId>
- <artifactId>hibernate-all</artifactId>
- <version>1.0.0.Alpha9</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/modules/core/client-api-test-utils/src/main/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java b/modules/core/client-api-test-utils/src/main/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
deleted file mode 100644
index b67d904..0000000
--- a/modules/core/client-api-test-utils/src/main/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.rhq.enterprise.server.configuration.metadata;
-
-import java.io.FileNotFoundException;
-import java.io.StringReader;
-import java.net.URL;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.util.ValidationEventCollector;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.commons.jxpath.JXPathContext;
-
-import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
-import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
-import org.rhq.core.clientapi.descriptor.DescriptorPackages;
-import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
-import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-
-public class PluginDescriptorUtil {
-
- /**
- * Loads the plugin descriptor from the specified file. The file path specified should
- * be a class path relative path. For example, if the descriptor file is located at
- * org.rhq.enterprise.server.configuration.my-descriptor.xml, then you should specify
- * /org/rhq/enterprise/server/configuration/my-descriptor.xml.
- *
- * @param file The class path relative path of the descriptor file
- * @return The {@link PluginDescriptor}
- */
- public static PluginDescriptor loadPluginDescriptor(String file) {
- try {
- URL pluginDescriptorURL = PluginDescriptorUtil.class.getResource(file);
- if (pluginDescriptorURL == null) {
- throw new FileNotFoundException("File " + file + " not found");
- }
-
- JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
- URL pluginSchemaURL = PluginDescriptorUtil.class.getClassLoader().getResource("rhq-plugin.xsd");
- Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
- pluginSchemaURL);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- unmarshaller.setEventHandler(vec);
- unmarshaller.setSchema(pluginSchema);
-
- return (PluginDescriptor) unmarshaller.unmarshal(pluginDescriptorURL.openStream());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Transforms the given string into a plugin descriptor object.
- *
- * @param string The plugin descriptor specified as a string
- * @return The {@link PluginDescriptor}
- */
- public static PluginDescriptor toPluginDescriptor(String string) {
- try {
- JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
- URL pluginSchemaURL = PluginMetadataParser.class.getClassLoader().getResource("rhq-plugin.xsd");
- Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(pluginSchemaURL);
-
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- unmarshaller.setEventHandler(vec);
- unmarshaller.setSchema(pluginSchema);
-
- StringReader reader = new StringReader(string);
-
- return (PluginDescriptor) unmarshaller.unmarshal(reader);
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Searches for and returns the matching descriptor element (or elements) from the plugin
- * descriptor. <code>path</code> should be an XPath-like expression. See
- * http://commons.apache.org/jxpath/users-guide.html for more information on supported syntax.
- *
- * @param descriptor The plugin descriptor
- * @param path The XPath-ish search expression
- * @return The matching element or elements from the descriptor
- */
- public static Object find(PluginDescriptor descriptor, String path) {
- JXPathContext context = JXPathContext.newContext(descriptor);
- return context.getValue(path);
- }
-
- /**
- * This method does a few things. It first searches the descriptor with the specified
- * <code>path</code>. When a matching element is found, which is presumably either a
- * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
- * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its plugin
- * configuration is retrieved. It then gets parsed and the resulting
- * {@link ConfigurationDefinition} is returned.
- *
- * @param descriptor The plugin descriptor
- * @param path The XPath-ish expression that specifies the path to the element from which
- * the plugin configuration should be loaded
- * @param configName A name to give the configuration definition
- * @return The parsed {@link ConfigurationDefinition}
- */
- public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor descriptor, String path,
- String configName) {
- try {
- ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
- return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getPluginConfiguration());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * This method does a few things. It first searches the descriptor with the specified
- * <code>path</code>. When a matching element is found, which is presumably either a
- * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
- * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its resource
- * configuration is retrieved. It then gets parsed and the resulting
- * {@link ConfigurationDefinition} is returned.
- *
- * @param descriptor The plugin descriptor
- * @param path The XPath-ish expression that specifies the path to the element from which
- * the resource configuration should be loaded
- * @param configName A name to give the configuration definition
- * @return The parsed {@link ConfigurationDefinition}
- */
- public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor descriptor, String path,
- String configName) {
- try {
- ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
- return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getResourceConfiguration());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-}
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index 80dda55..568f98b 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -63,18 +63,17 @@
</dependency>
<dependency>
- <groupId>${groupId}</groupId>
- <artifactId>rhq-core-client-api-test-utils</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<scope>test</scope>
</dependency>
-
+
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -116,6 +115,23 @@
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <include>org/rhq/core/clientapi/shared/**</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy b/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
index 2b28537..6b76a78 100644
--- a/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
+++ b/modules/core/client-api/src/test/groovy/org/rhq/core/clientapi/agent/metadata/PluginMetadataParserTest.groovy
@@ -20,18 +20,10 @@ package org.rhq.core.clientapi.agent.metadata
import static org.testng.Assert.*
-import javax.xml.XMLConstants
-import javax.xml.bind.JAXBContext
-import javax.xml.bind.Unmarshaller
-import javax.xml.bind.util.ValidationEventCollector
-import javax.xml.validation.Schema
-import javax.xml.validation.SchemaFactory
-import org.rhq.core.clientapi.descriptor.DescriptorPackages
-import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor
import org.testng.annotations.Test
import org.rhq.core.domain.configuration.definition.ConfigurationFormat
-import static org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.toPluginDescriptor
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.toPluginDescriptor
class PluginMetadataParserTest {
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/shared/PluginDescriptorUtil.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/shared/PluginDescriptorUtil.java
new file mode 100644
index 0000000..279ff34
--- /dev/null
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/shared/PluginDescriptorUtil.java
@@ -0,0 +1,144 @@
+package org.rhq.core.clientapi.shared;
+
+import java.io.FileNotFoundException;
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.util.ValidationEventCollector;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.commons.jxpath.JXPathContext;
+
+import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
+import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
+import org.rhq.core.clientapi.descriptor.DescriptorPackages;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+
+public class PluginDescriptorUtil {
+
+ /**
+ * Loads the plugin descriptor from the specified file. The file path specified should
+ * be a class path relative path. For example, if the descriptor file is located at
+ * org.rhq.enterprise.server.configuration.my-descriptor.xml, then you should specify
+ * /org/rhq/enterprise/server/configuration/my-descriptor.xml.
+ *
+ * @param file The class path relative path of the descriptor file
+ * @return The {@link PluginDescriptor}
+ */
+ public static PluginDescriptor loadPluginDescriptor(String file) {
+ try {
+ URL pluginDescriptorURL = PluginDescriptorUtil.class.getResource(file);
+ if (pluginDescriptorURL == null) {
+ throw new FileNotFoundException("File " + file + " not found");
+ }
+
+ JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
+ URL pluginSchemaURL = PluginDescriptorUtil.class.getClassLoader().getResource("rhq-plugin.xsd");
+ Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
+ pluginSchemaURL);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ unmarshaller.setEventHandler(vec);
+ unmarshaller.setSchema(pluginSchema);
+
+ return (PluginDescriptor) unmarshaller.unmarshal(pluginDescriptorURL.openStream());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Transforms the given string into a plugin descriptor object.
+ *
+ * @param string The plugin descriptor specified as a string
+ * @return The {@link PluginDescriptor}
+ */
+ public static PluginDescriptor toPluginDescriptor(String string) {
+ try {
+ JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
+ URL pluginSchemaURL = PluginMetadataParser.class.getClassLoader().getResource("rhq-plugin.xsd");
+ Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(pluginSchemaURL);
+
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ unmarshaller.setEventHandler(vec);
+ unmarshaller.setSchema(pluginSchema);
+
+ StringReader reader = new StringReader(string);
+
+ return (PluginDescriptor) unmarshaller.unmarshal(reader);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Searches for and returns the matching descriptor element (or elements) from the plugin
+ * descriptor. <code>path</code> should be an XPath-like expression. See
+ * http://commons.apache.org/jxpath/users-guide.html for more information on supported syntax.
+ *
+ * @param descriptor The plugin descriptor
+ * @param path The XPath-ish search expression
+ * @return The matching element or elements from the descriptor
+ */
+ public static Object find(PluginDescriptor descriptor, String path) {
+ JXPathContext context = JXPathContext.newContext(descriptor);
+ return context.getValue(path);
+ }
+
+ /**
+ * This method does a few things. It first searches the descriptor with the specified
+ * <code>path</code>. When a matching element is found, which is presumably either a
+ * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
+ * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its plugin
+ * configuration is retrieved. It then gets parsed and the resulting
+ * {@link ConfigurationDefinition} is returned.
+ *
+ * @param descriptor The plugin descriptor
+ * @param path The XPath-ish expression that specifies the path to the element from which
+ * the plugin configuration should be loaded
+ * @param configName A name to give the configuration definition
+ * @return The parsed {@link ConfigurationDefinition}
+ */
+ public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor descriptor, String path,
+ String configName) {
+ try {
+ ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
+ return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getPluginConfiguration());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * This method does a few things. It first searches the descriptor with the specified
+ * <code>path</code>. When a matching element is found, which is presumably either a
+ * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor} or a
+ * {@link org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor}, its resource
+ * configuration is retrieved. It then gets parsed and the resulting
+ * {@link ConfigurationDefinition} is returned.
+ *
+ * @param descriptor The plugin descriptor
+ * @param path The XPath-ish expression that specifies the path to the element from which
+ * the resource configuration should be loaded
+ * @param configName A name to give the configuration definition
+ * @return The parsed {@link ConfigurationDefinition}
+ */
+ public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor descriptor, String path,
+ String configName) {
+ try {
+ ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
+ return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getResourceConfiguration());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 8797e32..b936f26 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -50,7 +50,6 @@
<module>domain-test-utils</module>
<module>plugin-api</module>
<module>client-api</module>
- <module>client-api-test-utils</module>
<module>plugin-container</module>
<module>gui</module>
<module>plugindoc</module>
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 123d42e..ac041f1 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -353,8 +353,9 @@
<dependency>
<groupId>${groupId}</groupId>
- <artifactId>rhq-core-client-api-test-utils</artifactId>
+ <artifactId>rhq-core-client-api</artifactId>
<version>${version}</version>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
diff --git a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
index f7ea824..dd0ef01 100644
--- a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
+++ b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
@@ -3,7 +3,7 @@ package org.rhq.enterprise.server.resource.metadata
import org.testng.annotations.Test
import org.testng.Assert
-import static org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.toPluginDescriptor
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.toPluginDescriptor
import org.rhq.core.domain.plugin.Plugin
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor
import org.apache.maven.artifact.versioning.ComparableVersion
@@ -97,6 +97,12 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
<event name="serverCEvent" description="an entry was appended to a log file"/>
</server>
+
+ <server name="ServerD">
+ <service name="ServerD.Child1">
+ <service name="ServerD.GrandChild1"/>
+ </service>
+ </server>
</plugin>
"""
@@ -252,7 +258,11 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
description="Child 2 description"
class="org.rhq.plugins.test.Child2"
discovery="org.rhq.plugins.test.Child2ServiceDiscoveryComponent"/>
- </server>
+ </server>
+
+ <server name="ServerD">
+ <service name="ServerD.GrandChild1"/>
+ </server>
</plugin>
"""
@@ -286,7 +296,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
}
@Test(dependsOnMethods = ['upgradePlugin'], groups = ['UpgradePlugin'])
- void upgradeParentType() {
+ void upgradeParentTypeWhenTypeChangesParents() {
assertAssociationEquals(
'ServerB',
'childResourceTypes',
@@ -337,16 +347,27 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
assertEquals "The event definition(s) should have been deleted", 0, results.size()
}
- def buildPlugin(String pluginFileName, String version, String descriptor) {
- def args = createPlugin("test-plugin", pluginDescriptor, "2.0")
- Assert.assertNotNull args.plugin
- Assert.assertNotNull args.pluginFile
- Assert.assertNotNull args.pluginDescriptor
-
+ @Test(dependsOnMethods = ['upgradePlugin'], groups = ['UpgradePlugin'])
+ void deleteParent() {
def subjectMgr = LookupUtil.subjectManager
- def resourceMetadataMgr = LookupUtil.resourceMetadataManager
+ def resourceTypeMgr = LookupUtil.resourceTypeManager
- resourceMetadataMgr.registerPlugin(subjectMgr.overlord, args.plugin, args.pluginDescriptor, args.pluginFile, true)
+ def criteria = new ResourceTypeCriteria()
+ criteria.addFilterName "GrandChild1"
+ criteria.addFilterPluginName "TestPlugin"
+ criteria.fetchParentResourceTypes true
+
+ def types = resourceTypeMgr.findResourceTypesByCriteria(subjectMgr.overlord, criteria)
+
+ assertEquals "Expected to get back one resource type", 1, types.size()
+
+ def type = types[0]
+
+ assertEquals "Expected to find one parent type", 1, type.parentResourceTypes.size()
+
+ def parentType = type.parentResourceTypes.find { it.name == "ServerD" }
+
+ assertNotNull "Expected to find 'ServerD' as the parent, but found, $type.parentResourceTypes", parentType
}
/**
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
index 1f72c06..3b1d3e7 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBeanTest.java
@@ -32,7 +32,6 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
-import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
@@ -44,8 +43,8 @@ import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.test.AssertUtils;
-import static org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.loadPluginConfigDefFor;
-import static org.rhq.enterprise.server.configuration.metadata.PluginDescriptorUtil.loadPluginDescriptor;
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginConfigDefFor;
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginDescriptor;
import static java.util.Arrays.asList;
/**
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
deleted file mode 100644
index 8eb4632..0000000
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/metadata/PluginDescriptorUtil.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.rhq.enterprise.server.configuration.metadata;
-
-import java.io.FileNotFoundException;
-import java.net.URL;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.util.ValidationEventCollector;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.commons.jxpath.JXPathContext;
-
-import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
-import org.rhq.core.clientapi.descriptor.DescriptorPackages;
-import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
-import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-
-public class PluginDescriptorUtil {
-
- public static PluginDescriptor loadPluginDescriptor(String file) {
- try {
- URL pluginDescriptorURL = PluginDescriptorUtil.class.getResource(file);
- if (pluginDescriptorURL == null) {
- throw new FileNotFoundException("File " + file + " not found");
- }
-
- JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
- URL pluginSchemaURL = PluginDescriptorUtil.class.getClassLoader().getResource("rhq-plugin.xsd");
- Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
- pluginSchemaURL);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- unmarshaller.setEventHandler(vec);
- unmarshaller.setSchema(pluginSchema);
-
- return (PluginDescriptor) unmarshaller.unmarshal(pluginDescriptorURL.openStream());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static Object find(PluginDescriptor descriptor, String path) {
- JXPathContext context = JXPathContext.newContext(descriptor);
- return context.getValue(path);
- }
-
- public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor descriptor, String path,
- String configName) {
- try {
- ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
- return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getPluginConfiguration());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor descriptor, String path,
- String configName) {
- try {
- ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
- return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getResourceConfiguration());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-}
13 years, 6 months
[rhq] 2 commits - modules/enterprise modules/helpers
by Heiko W. Rupp
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java | 2 +-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java | 2 +-
modules/enterprise/server/jar/src/test/resources/perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip |binary
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java | 3 ++-
4 files changed, 4 insertions(+), 3 deletions(-)
New commits:
commit ca25d496072ebaff5e7c79329eef950e647a40ea
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 28 15:59:12 2010 +0200
Bump requested DB version and provide an updated data file, which adds the new column and a row for a call time metric.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
index 1c35c5f..9bb6f0b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
@@ -60,7 +60,7 @@ import org.testng.annotations.Test;
@Test(groups = "PERF" )
@Listeners({ DatabaseSetupInterceptor.class })
@PerformanceReporting(exporter=ExcelExporter.class)
-@DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94")
+@DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.101")
public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
ResourceManagerLocal resourceManager;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java
index 1b62820..0dcba79 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java
@@ -60,7 +60,7 @@ import java.util.Set;
@Test(groups = "PERF")
@Listeners({ DatabaseSetupInterceptor.class })
@PerformanceReporting(exporter=ExcelExporter.class)
-@DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94")
+@DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.101")
public class EventsInsertPurgeTest extends AbstractEJB3PerformanceTest {
private static final int ROUNDS = 20000;
diff --git a/modules/enterprise/server/jar/src/test/resources/perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip b/modules/enterprise/server/jar/src/test/resources/perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip
index 811c952..70bd0ce 100644
Binary files a/modules/enterprise/server/jar/src/test/resources/perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip and b/modules/enterprise/server/jar/src/test/resources/perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip differ
commit d1b7036d96028993dcc9f49ffbb191a7e92b70bf
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 28 15:33:31 2010 +0200
Be less verbose, but print the used database.
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
index 0dc7266..594627a 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
@@ -84,6 +84,7 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
InputStreamProvider streamProvider = getInputStreamProvider(state.url(), state.storage(), method);
IDatabaseConnection connection = new DatabaseDataSourceConnection(new InitialContext(),
"java:/RHQDS");
+ System.out.println("Using database at " + connection.getConnection().getMetaData().getURL());
setDatabaseType(connection);
@@ -162,7 +163,7 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
// Filter out methods that are marked as setup/tear down
Annotation[] annots = javaMethod.getAnnotations();
for (Annotation an : annots) {
- System.out.println(" : " + an.toString());
+// System.out.println(" : " + an.toString());
if (an.annotationType().equals(BeforeMethod.class) || an.annotationType().equals(AfterMethod.class) ||
an.annotationType().equals(BeforeSuite.class) || an.annotationType().equals(AfterSuite.class) ||
an.annotationType().equals(BeforeTest.class) || an.annotationType().equals(AfterTest.class)
13 years, 6 months
[rhq] modules/enterprise modules/helpers
by Heiko W. Rupp
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java | 1 -
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java | 6 +++---
2 files changed, 3 insertions(+), 4 deletions(-)
New commits:
commit 6ed2a798c32a4db6b47aaa100ec2257a8ac600c9
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 28 11:14:41 2010 +0200
Be less verbose.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java
index b38d934..f17ca60 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3PerformanceTest.java
@@ -129,7 +129,6 @@ public class AbstractEJB3PerformanceTest extends AbstractEJB3Test {
@BeforeMethod
protected void setupTimings(Method meth) {
Date now = new Date();
- System.out.println(">>> before " + meth.getName() + " (AbstraceEJB3PerformanceTest) === " + now.getTime());
timings = new HashMap<String, Long>();
startTime = new HashMap<String, Long>();
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
index 9efbdff..0dc7266 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
@@ -155,7 +155,7 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
DatabaseState annotation = javaMethod.getAnnotation(DatabaseState.class);
if (annotation==null) {
- System.out.println("Method : " + javaMethod.getName());
+// System.out.println("Method : " + javaMethod.getName());
boolean skip = false;
@@ -172,8 +172,8 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
if (!skip)
annotation = javaMethod.getDeclaringClass().getAnnotation(DatabaseState.class);
- else
- System.out.println(" ..... Skipped");
+// else
+// System.out.println(" ..... Skipped");
}
return annotation;
13 years, 6 months
[rhq] 2 commits - modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/pom.xml | 1 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
New commits:
commit 7d7c1a02ef9164940d3e6eb695293f520d9d923c
Merge: 7b27318... b3ac18a...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 28 10:31:28 2010 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 7b2731889909ed988916ad0c4daed4333cfc7610
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 28 10:29:47 2010 +0200
Allow to specify included groups as opposed to only excluding. The abstract ejb3 test is needed for integration and perf group.
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 2abdae5..d444d67 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -499,6 +499,7 @@ Build-OS-Version=${os.version}
<exclude>com/**/*.java</exclude>
</excludes>
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <groups>${rhq.testng.includedGroups}</groups>
<systemPropertyVariables>
<embeddedDeployment>true</embeddedDeployment>
<deploymentDirectory>target/classes</deploymentDirectory>
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index 2609861..1bd4600 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -63,7 +63,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
* @author Greg Hinkle
*/
public abstract class AbstractEJB3Test extends AssertJUnit {
- @BeforeSuite(groups = "integration.ejb3")
+ @BeforeSuite(groups = {"integration.ejb3","PERF"})
public static void startupEmbeddedJboss() throws Exception {
// Setting content location to the tmp dir
System.setProperty(ContentSourceManagerBean.FILESYSTEM_PROPERTY, System.getProperty("java.io.tmpdir"));
@@ -150,7 +150,7 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
public static Connection getConnection() throws SQLException {
return LookupUtil.getDataSource().getConnection();
}
-
+
@AfterMethod
public static void endTest() {
//System.out.println("Connections used: " + (stats.getQueryExecutionCount() - start));
13 years, 6 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java | 344 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java | 342 ---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 2
4 files changed, 346 insertions(+), 344 deletions(-)
New commits:
commit b3ac18a6683892135af6301ac1d3af81c1a0b1ac
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Oct 28 01:17:43 2010 -0400
move InventoryView class to more logical package
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 143045c..dccab2c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -42,7 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.bundle.BundleTopView;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardsView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupTopView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
+import org.rhq.enterprise.gui.coregui.client.inventory.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTopView;
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java
new file mode 100644
index 0000000..ca23a16
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/InventoryView.java
@@ -0,0 +1,344 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory;
+
+import java.util.EnumSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.VisibilityMode;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionEvent;
+import com.smartgwt.client.widgets.layout.SectionStack;
+import com.smartgwt.client.widgets.layout.SectionStackSection;
+import com.smartgwt.client.widgets.tree.Tree;
+import com.smartgwt.client.widgets.tree.TreeGrid;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions.GroupDefinitionListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
+
+/**
+ * @author Greg Hinkle
+ * @author Joseph Marques
+ */
+// TODO (ips, 10/28/10): Refactor this class to extend AbstractSectionedLeftNavigationView.
+public class InventoryView extends LocatableHLayout implements BookmarkableView {
+ public static final String VIEW_ID = "Inventory";
+
+ private static final String GROUPS_SECTION_VIEW_ID = "Groups";
+ private static final String RESOURCES_SECTION_VIEW_ID = "Resources";
+
+ private static final String SUBSECTION_RESOURCE_INVENTORY = "Resources";
+ private static final String SUBSECTION_GROUP_INVENTORY = "Groups";
+ private static final String SUBSECTION_SAVED_SEARCHES = "SavedSearches";
+
+ private static final String PAGE_ADQ = "DiscoveryManager";
+ private static final String PAGE_COMPATIBLE_GROUPS = "CompatibleGroups";
+ private static final String PAGE_DOWN = "DownServers";
+ private static final String PAGE_GROUPS = "AllGroups";
+ private static final String PAGE_GROUP_DEFINITIONS = "DynagroupManager";
+ private static final String PAGE_MIXED_GROUPS = "MixedGroups";
+ private static final String PAGE_PLATFORMS = "Platforms";
+ private static final String PAGE_PROBLEM_GROUPS = "ProblemGroups";
+ private static final String PAGE_RESOURCES = "AllResources";
+ private static final String PAGE_SERVERS = "Servers";
+ private static final String PAGE_SERVICES = "Services";
+
+ private ViewId currentSectionViewId;
+ private ViewId currentPageViewId;
+
+ private Canvas contentCanvas;
+ private Canvas currentContent;
+ private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>();
+
+ private SectionStack sectionStack;
+
+ public InventoryView(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ setWidth100();
+ setHeight100();
+
+ contentCanvas = new Canvas();
+ contentCanvas.setWidth("*");
+ contentCanvas.setHeight100();
+
+ sectionStack = new LocatableSectionStack(getLocatorId());
+ sectionStack.setShowResizeBar(true);
+ sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
+ sectionStack.setWidth(250);
+ sectionStack.setHeight100();
+
+ GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new AsyncCallback<Set<Permission>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Could not determine user's global permissions - assuming none.",
+ caught);
+ finishOnInit(EnumSet.noneOf(Permission.class));
+ }
+
+ @Override
+ public void onSuccess(Set<Permission> result) {
+ finishOnInit(result);
+ }
+ });
+ }
+
+ private void finishOnInit(Set<Permission> globalPermissions) {
+ addSection(buildResourcesSection(globalPermissions));
+ addSection(buildGroupsSection(globalPermissions));
+
+ addMember(sectionStack);
+ addMember(contentCanvas);
+ }
+
+ private void addSection(TreeGrid treeGrid) {
+ final String sectionName = treeGrid.getTree().getRoot().getName();
+ this.treeGrids.put(sectionName, treeGrid);
+
+ treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ if (selectionEvent.getState()) {
+ TreeNode node = (TreeNode) selectionEvent.getRecord();
+ String pageName = node.getName();
+ String viewPath = InventoryView.VIEW_ID + "/" + sectionName + "/" + pageName;
+ String currentViewPath = History.getToken();
+ if (!currentViewPath.startsWith(viewPath)) {
+ CoreGUI.goToView(viewPath);
+ }
+ }
+ }
+ });
+
+ SectionStackSection section = new SectionStackSection(sectionName);
+ section.setExpanded(true);
+ section.addItem(treeGrid);
+
+ this.sectionStack.addSection(section);
+ }
+
+ private TreeGrid buildResourcesSection(Set<Permission> globalPermissions) {
+ final TreeNode discoveryQueue = new EnhancedTreeNode(PAGE_ADQ);
+ discoveryQueue.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY));
+ discoveryQueue.setIcon("global/Recent_16.png");
+
+ final TreeNode onlyPlatforms = new EnhancedTreeNode(PAGE_PLATFORMS);
+ onlyPlatforms.setIcon("types/Platform_up_16.png");
+
+ final TreeNode onlyServers = new EnhancedTreeNode(PAGE_SERVERS);
+ onlyServers.setIcon("types/Server_up_16.png");
+
+ final TreeNode onlyServices = new EnhancedTreeNode(PAGE_SERVICES);
+ onlyServices.setIcon("types/Service_up_16.png");
+
+ final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_RESOURCE_INVENTORY, onlyPlatforms, onlyServers,
+ onlyServices);
+
+ final TreeNode downServers = new EnhancedTreeNode(PAGE_DOWN);
+ downServers.setIcon("types/Server_down_16.png");
+
+ final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES, downServers);
+
+ TreeGrid treeGrid = new LocatableTreeGrid(RESOURCES_SECTION_VIEW_ID);
+ treeGrid.setShowHeader(false);
+ Tree tree = new Tree();
+ TreeNode rootNode = new TreeNode(RESOURCES_SECTION_VIEW_ID, discoveryQueue, inventory, savedSearches);
+ tree.setRoot(rootNode);
+ treeGrid.setData(tree);
+
+ treeGrid.getTree().openAll();
+ treeGrids.put(RESOURCES_SECTION_VIEW_ID, treeGrid);
+
+ return treeGrid;
+ }
+
+ private TreeGrid buildGroupsSection(Set<Permission> globalPermissions) {
+ final TreeNode groupGroupDefinitions = new EnhancedTreeNode(PAGE_GROUP_DEFINITIONS);
+ groupGroupDefinitions.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY));
+ groupGroupDefinitions.setIcon("types/GroupDefinition_16.png");
+
+ final TreeNode onlyCompatible = new EnhancedTreeNode(PAGE_COMPATIBLE_GROUPS);
+ onlyCompatible.setIcon("types/Cluster_up_16.png");
+ final TreeNode onlyMixed = new EnhancedTreeNode(PAGE_MIXED_GROUPS);
+ onlyMixed.setIcon("types/Group_up_16.png");
+
+ final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_GROUP_INVENTORY, onlyCompatible, onlyMixed);
+
+ final TreeNode problemGroups = new EnhancedTreeNode(PAGE_PROBLEM_GROUPS);
+ problemGroups.setIcon("types/Cluster_down_16.png");
+ final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES, problemGroups);
+
+ TreeGrid treeGrid = new LocatableTreeGrid(GROUPS_SECTION_VIEW_ID);
+ treeGrid.setShowHeader(false);
+ Tree tree = new Tree();
+ TreeNode rootNode = new EnhancedTreeNode(GROUPS_SECTION_VIEW_ID, groupGroupDefinitions, inventory,
+ savedSearches);
+ tree.setRoot(rootNode);
+ treeGrid.setData(tree);
+
+ treeGrid.getTree().openAll();
+ treeGrids.put(GROUPS_SECTION_VIEW_ID, treeGrid);
+
+ return treeGrid;
+ }
+
+ public void setContent(Canvas newContent) {
+ for (Canvas child : this.contentCanvas.getChildren()) {
+ child.destroy();
+ }
+ this.contentCanvas.addChild(newContent);
+ this.contentCanvas.markForRedraw();
+ this.currentContent = newContent;
+ }
+
+ private void renderContentView(ViewPath viewPath) {
+ currentSectionViewId = viewPath.getCurrent();
+ currentPageViewId = viewPath.getNext();
+
+ String sectionName = currentSectionViewId.getPath();
+ String pageName = currentPageViewId.getPath();
+
+ Canvas content = null;
+ if (RESOURCES_SECTION_VIEW_ID.equals(sectionName)) {
+ if (PAGE_PLATFORMS.equals(pageName)) {
+ content = new ResourceSearchView(extendLocatorId("Platforms"), new Criteria(
+ ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS,
+ "types/Platform_up_24.png");
+ } else if (PAGE_SERVERS.equals(pageName)) {
+ content = new ResourceSearchView(extendLocatorId("Servers"), new Criteria(
+ ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()), PAGE_SERVERS,
+ "types/Server_up_24.png");
+ } else if (PAGE_SERVICES.equals(pageName)) {
+ content = new ResourceSearchView(extendLocatorId("Services"), new Criteria(
+ ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVICE.name()), PAGE_SERVICES,
+ "types/Service_up_24.png");
+ } else if (PAGE_ADQ.equals(pageName)) {
+ content = new ResourceAutodiscoveryView(this.extendLocatorId("ADQ"));
+ } else if (PAGE_DOWN.equals(pageName)) {
+ Criteria criteria = new Criteria(ResourceDataSourceField.AVAILABILITY.propertyName(),
+ AvailabilityType.DOWN.name());
+ criteria.addCriteria(ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name());
+ content = new ResourceSearchView(extendLocatorId("DownResources"), criteria, PAGE_DOWN);
+ } else { // selected the Inventory node itself
+ content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES,
+ "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png");
+ }
+ } else if (GROUPS_SECTION_VIEW_ID.equals(sectionName)) {
+ if (PAGE_COMPATIBLE_GROUPS.equals(pageName)) {
+ content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria(
+ ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.COMPATIBLE.name()),
+ "Compatible Groups", "types/Cluster_up_24.png");
+ } else if (PAGE_MIXED_GROUPS.equals(pageName)) {
+ content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria(
+ ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.MIXED.name()), "Mixed Groups",
+ "types/Group_up_24.png");
+ } else if (PAGE_GROUP_DEFINITIONS.equals(pageName)) {
+ content = new GroupDefinitionListView(extendLocatorId("Definitions"), "types/GroupDefinition_16.png");
+ } else if (PAGE_PROBLEM_GROUPS.equals(pageName)) {
+ //TODO - there is no underlying support for this criteria. Also, there should not be an active
+ // new button on this page.
+ content = new ResourceGroupListView(extendLocatorId("DownGroups"),
+ new Criteria("availability", "down"), "Problem Groups", "types/Cluster_down_16.png");
+ } else { // selected the Inventory node itself
+ content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, "All Groups",
+ "types/Cluster_up_24.png", "types/Group_up_24.png");
+ }
+ }
+
+ // when changing sections make sure the previous section's selection is deselected
+ selectSectionPageTreeGridNode(sectionName, pageName);
+
+ // ignore clicks on subsection folder nodes
+ if (null != content) {
+ setContent(content);
+
+ if (content instanceof BookmarkableView) {
+ ((BookmarkableView) content).renderView(viewPath.next().next());
+ }
+ }
+ }
+
+ private void selectSectionPageTreeGridNode(String sectionName, String pageName) {
+ // TODO this method works, however, its getting invoked prior to treeGrids getting populated due to async authz check. need to fix that
+ for (String name : treeGrids.keySet()) {
+ TreeGrid treeGrid = treeGrids.get(name);
+ if (!name.equals(sectionName)) {
+ treeGrid.deselectAllRecords();
+ } else {
+ boolean gotIt = false;
+ for (TreeNode node : treeGrid.getTree().getAllNodes()) {
+ if (node.getName().equals(pageName)) {
+ treeGrid.selectSingleRecord(node);
+ gotIt = true;
+ break;
+ }
+ }
+ if (!gotIt) {
+ CoreGUI.getErrorHandler().handleError("Unknown page name - URL is incorrect");
+ }
+ }
+ }
+ }
+
+ public void renderView(ViewPath viewPath) {
+ if (!viewPath.isCurrent(currentSectionViewId) || !viewPath.isNext(currentPageViewId)) {
+ if (viewPath.isEnd()) {
+ // i.e. "Inventory"
+ // Currently, leave content empty until the user selects something from section stack. To default
+ // to platform list uncomment following line.
+ // History.newItem("Inventory/Resources/Platforms", true);
+ } else {
+ // e.g. Inventory/Administration"
+ renderContentView(viewPath);
+ }
+ } else {
+ if (this.currentContent instanceof BookmarkableView) {
+ ((BookmarkableView) this.currentContent).renderView(viewPath.next().next());
+ }
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
deleted file mode 100644
index 3145c05..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-
-import java.util.EnumSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.VisibilityMode;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
-import com.smartgwt.client.widgets.grid.events.SelectionEvent;
-import com.smartgwt.client.widgets.layout.SectionStack;
-import com.smartgwt.client.widgets.layout.SectionStackSection;
-import com.smartgwt.client.widgets.tree.Tree;
-import com.smartgwt.client.widgets.tree.TreeGrid;
-import com.smartgwt.client.widgets.tree.TreeNode;
-
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.group.GroupCategory;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ViewId;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions.GroupDefinitionListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.discovery.ResourceAutodiscoveryView;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableSectionStack;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
-
-/**
- * @author Greg Hinkle
- * @author Joseph Marques
- */
-// TODO (ips, 10/28/10): Refactor this class to extend AbstractSectionedLeftNavigationView.
-public class InventoryView extends LocatableHLayout implements BookmarkableView {
- public static final String VIEW_ID = "Inventory";
-
- private static final String GROUPS_SECTION_VIEW_ID = "Groups";
- private static final String RESOURCES_SECTION_VIEW_ID = "Resources";
-
- private static final String SUBSECTION_RESOURCE_INVENTORY = "Resources";
- private static final String SUBSECTION_GROUP_INVENTORY = "Groups";
- private static final String SUBSECTION_SAVED_SEARCHES = "SavedSearches";
-
- private static final String PAGE_ADQ = "DiscoveryManager";
- private static final String PAGE_COMPATIBLE_GROUPS = "CompatibleGroups";
- private static final String PAGE_DOWN = "DownServers";
- private static final String PAGE_GROUPS = "AllGroups";
- private static final String PAGE_GROUP_DEFINITIONS = "DynagroupManager";
- private static final String PAGE_MIXED_GROUPS = "MixedGroups";
- private static final String PAGE_PLATFORMS = "Platforms";
- private static final String PAGE_PROBLEM_GROUPS = "ProblemGroups";
- private static final String PAGE_RESOURCES = "AllResources";
- private static final String PAGE_SERVERS = "Servers";
- private static final String PAGE_SERVICES = "Services";
-
- private ViewId currentSectionViewId;
- private ViewId currentPageViewId;
-
- private Canvas contentCanvas;
- private Canvas currentContent;
- private Map<String, TreeGrid> treeGrids = new LinkedHashMap<String, TreeGrid>();
-
- private SectionStack sectionStack;
-
- public InventoryView(String locatorId) {
- super(locatorId);
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- setWidth100();
- setHeight100();
-
- contentCanvas = new Canvas();
- contentCanvas.setWidth("*");
- contentCanvas.setHeight100();
-
- sectionStack = new LocatableSectionStack(getLocatorId());
- sectionStack.setShowResizeBar(true);
- sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
- sectionStack.setWidth(250);
- sectionStack.setHeight100();
-
- GWTServiceLookup.getAuthorizationService().getExplicitGlobalPermissions(new AsyncCallback<Set<Permission>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Could not determine user's global permissions - assuming none.",
- caught);
- finishOnInit(EnumSet.noneOf(Permission.class));
- }
-
- @Override
- public void onSuccess(Set<Permission> result) {
- finishOnInit(result);
- }
- });
- }
-
- private void finishOnInit(Set<Permission> globalPermissions) {
- addSection(buildResourcesSection(globalPermissions));
- addSection(buildGroupsSection(globalPermissions));
-
- addMember(sectionStack);
- addMember(contentCanvas);
- }
-
- private void addSection(TreeGrid treeGrid) {
- final String sectionName = treeGrid.getTree().getRoot().getName();
- this.treeGrids.put(sectionName, treeGrid);
-
- treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- if (selectionEvent.getState()) {
- TreeNode node = (TreeNode) selectionEvent.getRecord();
- String pageName = node.getName();
- String viewPath = InventoryView.VIEW_ID + "/" + sectionName + "/" + pageName;
- String currentViewPath = History.getToken();
- if (!currentViewPath.startsWith(viewPath)) {
- CoreGUI.goToView(viewPath);
- }
- }
- }
- });
-
- SectionStackSection section = new SectionStackSection(sectionName);
- section.setExpanded(true);
- section.addItem(treeGrid);
-
- this.sectionStack.addSection(section);
- }
-
- private TreeGrid buildResourcesSection(Set<Permission> globalPermissions) {
- final TreeNode discoveryQueue = new EnhancedTreeNode(PAGE_ADQ);
- discoveryQueue.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY));
- discoveryQueue.setIcon("global/Recent_16.png");
-
- final TreeNode onlyPlatforms = new EnhancedTreeNode(PAGE_PLATFORMS);
- onlyPlatforms.setIcon("types/Platform_up_16.png");
-
- final TreeNode onlyServers = new EnhancedTreeNode(PAGE_SERVERS);
- onlyServers.setIcon("types/Server_up_16.png");
-
- final TreeNode onlyServices = new EnhancedTreeNode(PAGE_SERVICES);
- onlyServices.setIcon("types/Service_up_16.png");
-
- final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_RESOURCE_INVENTORY, onlyPlatforms, onlyServers,
- onlyServices);
-
- final TreeNode downServers = new EnhancedTreeNode(PAGE_DOWN);
- downServers.setIcon("types/Server_down_16.png");
-
- final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES, downServers);
-
- TreeGrid treeGrid = new LocatableTreeGrid(RESOURCES_SECTION_VIEW_ID);
- treeGrid.setShowHeader(false);
- Tree tree = new Tree();
- TreeNode rootNode = new TreeNode(RESOURCES_SECTION_VIEW_ID, discoveryQueue, inventory, savedSearches);
- tree.setRoot(rootNode);
- treeGrid.setData(tree);
-
- treeGrid.getTree().openAll();
- treeGrids.put(RESOURCES_SECTION_VIEW_ID, treeGrid);
-
- return treeGrid;
- }
-
- private TreeGrid buildGroupsSection(Set<Permission> globalPermissions) {
- final TreeNode groupGroupDefinitions = new EnhancedTreeNode(PAGE_GROUP_DEFINITIONS);
- groupGroupDefinitions.setEnabled(globalPermissions.contains(Permission.MANAGE_INVENTORY));
- groupGroupDefinitions.setIcon("types/GroupDefinition_16.png");
-
- final TreeNode onlyCompatible = new EnhancedTreeNode(PAGE_COMPATIBLE_GROUPS);
- onlyCompatible.setIcon("types/Cluster_up_16.png");
- final TreeNode onlyMixed = new EnhancedTreeNode(PAGE_MIXED_GROUPS);
- onlyMixed.setIcon("types/Group_up_16.png");
-
- final TreeNode inventory = new EnhancedTreeNode(SUBSECTION_GROUP_INVENTORY, onlyCompatible, onlyMixed);
-
- final TreeNode problemGroups = new EnhancedTreeNode(PAGE_PROBLEM_GROUPS);
- problemGroups.setIcon("types/Cluster_down_16.png");
- final TreeNode savedSearches = new EnhancedTreeNode(SUBSECTION_SAVED_SEARCHES, problemGroups);
-
- TreeGrid treeGrid = new LocatableTreeGrid(GROUPS_SECTION_VIEW_ID);
- treeGrid.setShowHeader(false);
- Tree tree = new Tree();
- TreeNode rootNode = new EnhancedTreeNode(GROUPS_SECTION_VIEW_ID, groupGroupDefinitions, inventory,
- savedSearches);
- tree.setRoot(rootNode);
- treeGrid.setData(tree);
-
- treeGrid.getTree().openAll();
- treeGrids.put(GROUPS_SECTION_VIEW_ID, treeGrid);
-
- return treeGrid;
- }
-
- public void setContent(Canvas newContent) {
- for (Canvas child : this.contentCanvas.getChildren()) {
- child.destroy();
- }
- this.contentCanvas.addChild(newContent);
- this.contentCanvas.markForRedraw();
- this.currentContent = newContent;
- }
-
- private void renderContentView(ViewPath viewPath) {
- currentSectionViewId = viewPath.getCurrent();
- currentPageViewId = viewPath.getNext();
-
- String sectionName = currentSectionViewId.getPath();
- String pageName = currentPageViewId.getPath();
-
- Canvas content = null;
- if (RESOURCES_SECTION_VIEW_ID.equals(sectionName)) {
- if (PAGE_PLATFORMS.equals(pageName)) {
- content = new ResourceSearchView(extendLocatorId("Platforms"), new Criteria(
- ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.PLATFORM.name()), PAGE_PLATFORMS,
- "types/Platform_up_24.png");
- } else if (PAGE_SERVERS.equals(pageName)) {
- content = new ResourceSearchView(extendLocatorId("Servers"), new Criteria(
- ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name()), PAGE_SERVERS,
- "types/Server_up_24.png");
- } else if (PAGE_SERVICES.equals(pageName)) {
- content = new ResourceSearchView(extendLocatorId("Services"), new Criteria(
- ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVICE.name()), PAGE_SERVICES,
- "types/Service_up_24.png");
- } else if (PAGE_ADQ.equals(pageName)) {
- content = new ResourceAutodiscoveryView(this.extendLocatorId("ADQ"));
- } else if (PAGE_DOWN.equals(pageName)) {
- Criteria criteria = new Criteria(ResourceDataSourceField.AVAILABILITY.propertyName(),
- AvailabilityType.DOWN.name());
- criteria.addCriteria(ResourceDataSourceField.CATEGORY.propertyName(), ResourceCategory.SERVER.name());
- content = new ResourceSearchView(extendLocatorId("DownResources"), criteria, PAGE_DOWN);
- } else { // selected the Inventory node itself
- content = new ResourceSearchView(extendLocatorId("AllResources"), null, PAGE_RESOURCES,
- "types/Platform_up_24.png", "types/Server_up_24.png", "types/Service_up_24.png");
- }
- } else if (GROUPS_SECTION_VIEW_ID.equals(sectionName)) {
- if (PAGE_COMPATIBLE_GROUPS.equals(pageName)) {
- content = new ResourceGroupListView(extendLocatorId("Compatible"), new Criteria(
- ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.COMPATIBLE.name()),
- "Compatible Groups", "types/Cluster_up_24.png");
- } else if (PAGE_MIXED_GROUPS.equals(pageName)) {
- content = new ResourceGroupListView(extendLocatorId("Mixed"), new Criteria(
- ResourceGroupDataSourceField.CATEGORY.propertyName(), GroupCategory.MIXED.name()), "Mixed Groups",
- "types/Group_up_24.png");
- } else if (PAGE_GROUP_DEFINITIONS.equals(pageName)) {
- content = new GroupDefinitionListView(extendLocatorId("Definitions"), "types/GroupDefinition_16.png");
- } else if (PAGE_PROBLEM_GROUPS.equals(pageName)) {
- //TODO - there is no underlying support for this criteria. Also, there should not be an active
- // new button on this page.
- content = new ResourceGroupListView(extendLocatorId("DownGroups"),
- new Criteria("availability", "down"), "Problem Groups", "types/Cluster_down_16.png");
- } else { // selected the Inventory node itself
- content = new ResourceGroupListView(extendLocatorId("AllGroups"), null, "All Groups",
- "types/Cluster_up_24.png", "types/Group_up_24.png");
- }
- }
-
- // when changing sections make sure the previous section's selection is deselected
- selectSectionPageTreeGridNode(sectionName, pageName);
-
- // ignore clicks on subsection folder nodes
- if (null != content) {
- setContent(content);
-
- if (content instanceof BookmarkableView) {
- ((BookmarkableView) content).renderView(viewPath.next().next());
- }
- }
- }
-
- private void selectSectionPageTreeGridNode(String sectionName, String pageName) {
- // TODO this method works, however, its getting invoked prior to treeGrids getting populated due to async authz check. need to fix that
- for (String name : treeGrids.keySet()) {
- TreeGrid treeGrid = treeGrids.get(name);
- if (!name.equals(sectionName)) {
- treeGrid.deselectAllRecords();
- } else {
- boolean gotIt = false;
- for (TreeNode node : treeGrid.getTree().getAllNodes()) {
- if (node.getName().equals(pageName)) {
- treeGrid.selectSingleRecord(node);
- gotIt = true;
- break;
- }
- }
- if (!gotIt) {
- CoreGUI.getErrorHandler().handleError("Unknown page name - URL is incorrect");
- }
- }
- }
- }
-
- public void renderView(ViewPath viewPath) {
- if (!viewPath.isCurrent(currentSectionViewId) || !viewPath.isNext(currentPageViewId)) {
- if (viewPath.isEnd()) {
- // i.e. "Inventory"
- // Currently, leave content empty until the user selects something from section stack. To default
- // to platform list uncomment following line.
- // History.newItem("Inventory/Resources/Platforms", true);
- } else {
- // e.g. Inventory/Administration"
- renderContentView(viewPath);
- }
- } else {
- if (this.currentContent instanceof BookmarkableView) {
- ((BookmarkableView) this.currentContent).renderView(viewPath.next().next());
- }
- }
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 517c105..7cb57f3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -48,7 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
+import org.rhq.enterprise.gui.coregui.client.inventory.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ResourceConfigurationEditView;
13 years, 6 months