[rhq] 4 commits - modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/AbstractSearchBar.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java | 55 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java | 31 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java | 5
modules/enterprise/gui/coregui/src/main/webapp/css/search.css | 11 --
5 files changed, 4 insertions(+), 100 deletions(-)
New commits:
commit 2a8710a5d7c0a1780ec77208d1d71afb5630b4c7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Sun Dec 19 22:52:26 2010 -0500
remove offset so SearchBar sits in line properly
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/css/search.css b/modules/enterprise/gui/coregui/src/main/webapp/css/search.css
index 2f96535..45b13f3 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/css/search.css
+++ b/modules/enterprise/gui/coregui/src/main/webapp/css/search.css
@@ -59,7 +59,6 @@ div {
/*
- *
* search container elements
*/
@@ -74,8 +73,6 @@ div {
.searchBarBackgroundContainer {
position: absolute;
- top: 5px;
- left: 5px;
background-color: white;
border-style: inset;
border-color: gray;
commit 38b76483415e7644a0fa7b4a7e3c4f4180358d9c
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Dec 16 02:54:13 2010 -0500
fix SearchBar styling to eliminate JSF-style color border and correct inset
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/css/search.css b/modules/enterprise/gui/coregui/src/main/webapp/css/search.css
index cd75fbc..2f96535 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/css/search.css
+++ b/modules/enterprise/gui/coregui/src/main/webapp/css/search.css
@@ -61,13 +61,12 @@ div {
/*
*
* search container elements
- *
*/
.searchBarContainer {
width: 800px;
position: relative;
- background-color: rgb(233, 230, 225);
+ background-color: white;
height: 34px;
vertical-align: bottom;
z-index: 999999;
@@ -79,10 +78,7 @@ div {
left: 5px;
background-color: white;
border-style: inset;
- border-top-color: rgb(222, 222, 222);
- border-left-color: rgb(222, 222, 222);
- border-bottom-color: white;
- border-right-color: white;
+ border-color: gray;
border-width: 1px 1px 1px 1px;
padding: 0;
width: 785px;
commit cbeb637f476b69ba543bc283246f60bdbc6fd517
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Dec 16 02:28:27 2010 -0500
get rid of unused methods
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
index 23d9626..9e3e6eb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
@@ -193,11 +193,6 @@ public class FlexSearchBar extends AbstractSearchBar {
// presume the enclosing page logic loads results without a button click
}
- public static native String getUserAgent()
- /*-{
- return navigator.userAgent.toLowerCase();
- }-*/;
-
public SavedSearchManager getSavedSearchManager() {
return savedSearchManager;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
index 9ce630b..b421132 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
@@ -184,11 +184,6 @@ public class SearchBar extends AbstractSearchBar {
// presume the enclosing page logic loads results without a button click
}
- public static native String getUserAgent()
- /*-{
- return navigator.userAgent.toLowerCase();
- }-*/;
-
public SavedSearchManager getSavedSearchManager() {
return savedSearchManager;
}
commit c69e48b06bd5ba26ba91aeb4be8b3be726cb1564
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Dec 16 02:26:14 2010 -0500
welcome msg redundant with SearchBar label, delete it and accompanying logic
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/AbstractSearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/AbstractSearchBar.java
index ac4a874..a0d44db 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/AbstractSearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/AbstractSearchBar.java
@@ -32,8 +32,6 @@ public abstract class AbstractSearchBar extends Composite {
public abstract SearchSubsystem getSearchSubsystem();
- public abstract String getWelcomeMessage();
-
public abstract String getSelectedTab();
public abstract void activateSavedSearch(String savedSearchName);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
index 172bd13..23d9626 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/FlexSearchBar.java
@@ -62,8 +62,6 @@ public class FlexSearchBar extends AbstractSearchBar {
private static final Messages MSG = CoreGUI.getMessages();
- public String welcomeMessage;
-
public static final String DEFAULT_PATTERN_NAME = MSG.view_searchBar_defaultPattern();
private static final String IMAGE_DIR = "/coregui/images/search/";
@@ -106,7 +104,7 @@ public class FlexSearchBar extends AbstractSearchBar {
if (event.getNativeEvent().getEventTarget().equals(searchButton)
&& event.getTypeInt() == Event.ONMOUSEDOWN) {
- prepareSearchExecution();
+ //prepareSearchExecution();
}
}
}
@@ -150,20 +148,6 @@ public class FlexSearchBar extends AbstractSearchBar {
savedSearchManager = new SavedSearchManager(this);
}
- private Element createDiv(Element parentDiv, String className, String id) {
- Element div = DOM.createDiv();
- if (parentDiv != null) {
- parentDiv.appendChild(div);
- }
- if (className != null) {
- div.addClassName(className);
- }
- if (id != null) {
- div.setId(id);
- }
- return div;
- }
-
private HorizontalPanel createHPanel(Panel parent, String className, String id) {
HorizontalPanel panel = new HorizontalPanel();
if (parent != null) {
@@ -179,15 +163,6 @@ public class FlexSearchBar extends AbstractSearchBar {
}
public void onSavedSearchManagerLoaded() {
- /*
- RootPanel.get("patternFieldContainer").add(autoCompletePatternField);
- RootPanel.get("patternNameFieldContainer").add(patternNameField);
- RootPanel.get("patternNameLabelContainer").add(patternNameLabel);
- RootPanel.get("starImageContainer").add(starImage);
- RootPanel.get("arrowImageContainer").add(arrowImage);
- RootPanel.get("savedSearchesContainer").add(savedSearchesPanel);
- */
-
sbc_sbbgc_sbcc_sbclhs_pfc.add(autoCompletePatternField);
sbc_sbbgc_sbcc_sbcrhs_pnfc.add(patternNameField);
sbc_sbbgc_sbcc_sbcrhs_pnlc.add(patternNameLabel);
@@ -202,7 +177,6 @@ public class FlexSearchBar extends AbstractSearchBar {
setupArrowImage();
setupSavedSearches();
- //
if (defaultSearchText != null) {
this.autoCompletePatternField.setText(defaultSearchText);
click(searchButton); // execute the search with this default search expression
@@ -230,10 +204,6 @@ public class FlexSearchBar extends AbstractSearchBar {
public void setSearchSubsystem(SearchSubsystem searchSubsystem) {
this.searchSubsystem = searchSubsystem;
-
- this.welcomeMessage = MSG.view_searchBar_welcomeMessage(this.searchSubsystem.getName());
-
- this.autoCompletePatternField.setText(welcomeMessage);
}
public SearchSubsystem getSearchSubsystem() {
@@ -264,17 +234,6 @@ public class FlexSearchBar extends AbstractSearchBar {
return defaultSavedSearchPatternId;
}
- public String getWelcomeMessage() {
- return welcomeMessage;
- }
-
- public void prepareSearchExecution() {
- String searchTerms = autoCompletePatternField.getText().toLowerCase().trim();
- if (searchTerms.equals(welcomeMessage)) {
- autoCompletePatternField.setText("");
- }
- }
-
private void setupAutoCompletingPatternField() {
autoCompletePatternField.getElement().setId("patternField");
autoCompletePatternField.setStyleName("patternField");
@@ -397,18 +356,11 @@ public class FlexSearchBar extends AbstractSearchBar {
}
public void onFocus(FocusEvent event) {
- // clear default search text if necessary
- if (autoCompletePatternField.getText().equals(welcomeMessage)) {
- autoCompletePatternField.setValue("", true);
- }
autoCompletePatternField.showSuggestionList();
savedSearchesPanel.hide();
}
public void onBlur(BlurEvent event) {
- if (autoCompletePatternField.getText().equals("")) {
- autoCompletePatternField.setValue(welcomeMessage, true);
- }
savedSearchesPanel.hide();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
index 8be4f47..9ce630b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/SearchBar.java
@@ -61,8 +61,6 @@ public class SearchBar extends AbstractSearchBar {
private static final Messages MSG = CoreGUI.getMessages();
- public String welcomeMessage;
-
public static final String DEFAULT_PATTERN_NAME = MSG.view_searchBar_defaultPattern();
private static final String IMAGE_DIR = "/coregui/images/search/";
@@ -118,7 +116,7 @@ public class SearchBar extends AbstractSearchBar {
if (event.getNativeEvent().getEventTarget().equals(searchButton)
&& event.getTypeInt() == Event.ONMOUSEDOWN) {
- prepareSearchExecution();
+ //prepareSearchExecution();
}
}
}
@@ -197,10 +195,6 @@ public class SearchBar extends AbstractSearchBar {
public void setSearchSubsystem(SearchSubsystem searchSubsystem) {
this.searchSubsystem = searchSubsystem;
-
- this.welcomeMessage = MSG.view_searchBar_welcomeMessage(this.searchSubsystem.getName());
-
- this.autoCompletePatternField.setText(welcomeMessage);
}
public SearchSubsystem getSearchSubsystem() {
@@ -235,17 +229,6 @@ public class SearchBar extends AbstractSearchBar {
return defaultSavedSearchPatternId;
}
- public String getWelcomeMessage() {
- return welcomeMessage;
- }
-
- public void prepareSearchExecution() {
- String searchTerms = autoCompletePatternField.getText().toLowerCase().trim();
- if (searchTerms.equals(welcomeMessage)) {
- autoCompletePatternField.setText("");
- }
- }
-
private void setupAutoCompletingPatternField() {
autoCompletePatternField.getElement().setId("patternField");
autoCompletePatternField.setStyleName("patternField");
@@ -368,18 +351,11 @@ public class SearchBar extends AbstractSearchBar {
}
public void onFocus(FocusEvent event) {
- // clear default search text if necessary
- if (autoCompletePatternField.getText().equals(welcomeMessage)) {
- autoCompletePatternField.setValue("", true);
- }
autoCompletePatternField.showSuggestionList();
savedSearchesPanel.hide();
}
public void onBlur(BlurEvent event) {
- if (autoCompletePatternField.getText().equals("")) {
- autoCompletePatternField.setValue(welcomeMessage, true);
- }
savedSearchesPanel.hide();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java
index f2dab2f..454b8a1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java
@@ -700,11 +700,6 @@ public class SuggestTextBox_v3 extends Composite implements HasText, HasAllFocus
SearchSuggestion searchSuggestion = extraSearchSuggestion(suggestion);
String currentText = getText().toLowerCase();
- if (searchBar.getWelcomeMessage().equals(currentText)) {
- setValue("", true);
- return;
- }
-
if (searchSuggestion.getKind() == SearchSuggestion.Kind.GlobalSavedSearch
|| searchSuggestion.getKind() == SearchSuggestion.Kind.UserSavedSearch) {
// execute saved searches immediately, since they presumably constitute complete expressions
13 years, 5 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java | 14 ++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
New commits:
commit 0e90bc94eb626e05b55fd5f2f1a2eeaac7e25c4e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Dec 19 18:42:38 2010 -0500
BZ 625198 the bundle deploy wizard needs to show the default values for the config properties if defaults have been set in the recipe
this code is agnostic to the kind of bundle type it is.
checked in fixes to both filetemplate and ant bundle types (file template now supports setting default values in configdef command)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java
index a28845c..5c31961 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java
@@ -23,6 +23,7 @@ import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
@@ -57,8 +58,17 @@ public class GetDeploymentConfigStep extends AbstractWizardStep {
editor.addMember(label);
} else {
// otherwise, pop up the config editor to get the needed config
- Configuration startingConfig = (null == wizard.getLiveDeployment()) ? new Configuration()
- : getNormalizedLiveConfig(configDef);
+ Configuration startingConfig;
+ if (wizard.getLiveDeployment() == null) {
+ ConfigurationTemplate defaultTemplate = configDef.getDefaultTemplate();
+ if (defaultTemplate == null) {
+ startingConfig = new Configuration();
+ } else {
+ startingConfig = defaultTemplate.getConfiguration();
+ }
+ } else {
+ startingConfig = getNormalizedLiveConfig(configDef);
+ }
editor = new ConfigurationEditor("BundleDeploymentConfig", configDef, startingConfig);
}
}
13 years, 5 months
[rhq] 6 commits - modules/common modules/core modules/enterprise
by mazz
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java | 48 -
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java | 14
modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java | 34 +
modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java | 14
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java | 161 ++++-
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java | 322 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java | 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java | 27
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java | 79 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java | 16
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16_Disabled.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16_Disabled.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16_Disabled.png |binary
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java | 16
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 67 +-
modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java | 1
23 files changed, 747 insertions(+), 103 deletions(-)
New commits:
commit 2c87326ad0fa9449ef0e351e0f241d36ec4566da
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Dec 19 18:40:53 2010 -0500
BZ 625198 the bundle deploy wizard needs to show the default values for the config properties if defaults have been set in the recipe
this code is agnostic to the kind of bundle type it is.
checked in fixes to both filetemplate and ant bundle types (file template now supports setting default values in configdef command)
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java
index 2b44a3a..070f02c 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/InputPropertyType.java
@@ -19,6 +19,7 @@ package org.rhq.bundle.ant.type;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -48,7 +49,8 @@ public class InputPropertyType extends AbstractBundleType {
ConfigurationDefinition configDef = getProject().getConfigurationDefinition();
PropertySimpleType propType = PropertySimpleType.fromXmlName(this.type);
PropertyDefinitionSimple propDef = new PropertyDefinitionSimple(this.name, this.description, this.required,
- propType);
+ propType);
+ propDef.setDefaultValue(this.defaultValue);
configDef.put(propDef);
String value = getProject().getProperty(this.name);
@@ -61,7 +63,7 @@ public class InputPropertyType extends AbstractBundleType {
if (!parseOnly) {
if (value == null && this.required) {
throw new BuildException("No value was specified for required input property '" + this.name
- + "', and no default is defined for the property.");
+ + "', and no default is defined for the property.");
}
validateValue(value, propType);
String valueString = (value != null) ? "'" + value + "'" : "<null>";
@@ -74,7 +76,7 @@ public class InputPropertyType extends AbstractBundleType {
return;
}
-
+
public String getDescription() {
return description;
}
@@ -145,7 +147,7 @@ public class InputPropertyType extends AbstractBundleType {
validateValue(this.defaultValue, propType);
} catch (RuntimeException e) {
throw new BuildException("Default value '" + this.defaultValue
- + "' is not valid according to 'type' attribute: " + this.type, e);
+ + "' is not valid according to 'type' attribute: " + this.type, e);
}
}
}
@@ -154,28 +156,28 @@ public class InputPropertyType extends AbstractBundleType {
if (value != null) {
try {
switch (propType) {
- case BOOLEAN:
- if (!value.equals(Boolean.TRUE.toString()) && !value.equals(Boolean.FALSE.toString())) {
- throw new RuntimeException("Illegal value for boolean property - value must be 'true' or 'false'."
- + value);
- }
- break;
- case DOUBLE:
- Double.valueOf(value);
- break;
- case FLOAT:
- Float.valueOf(value);
- break;
- case INTEGER:
- Integer.valueOf(value);
- break;
- case LONG:
- Long.valueOf(value);
- break;
+ case BOOLEAN:
+ if (!value.equals(Boolean.TRUE.toString()) && !value.equals(Boolean.FALSE.toString())) {
+ throw new RuntimeException(
+ "Illegal value for boolean property - value must be 'true' or 'false'." + value);
+ }
+ break;
+ case DOUBLE:
+ Double.valueOf(value);
+ break;
+ case FLOAT:
+ Float.valueOf(value);
+ break;
+ case INTEGER:
+ Integer.valueOf(value);
+ break;
+ case LONG:
+ Long.valueOf(value);
+ break;
}
} catch (RuntimeException e) {
throw new BuildException("'" + value + "' is not a legal value for input property '" + this.name
- + "', which has type '" + this.type + "'.", e);
+ + "', which has type '" + this.type + "'.", e);
}
}
}
diff --git a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java
index 54f297c..59a0984 100644
--- a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java
+++ b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/ConfigDefRecipeCommand.java
@@ -36,10 +36,12 @@ public class ConfigDefRecipeCommand implements RecipeCommand {
}
public void parse(RecipeParser parser, RecipeContext context, String[] args) {
- String sopts = ":n:";
- LongOpt[] lopts = { new LongOpt("name", LongOpt.REQUIRED_ARGUMENT, null, 'n') };
+ String sopts = ":n:d:";
+ LongOpt[] lopts = { new LongOpt("default", LongOpt.REQUIRED_ARGUMENT, null, 'd'),
+ new LongOpt("name", LongOpt.REQUIRED_ARGUMENT, null, 'n') };
String replacementVariableName = null;
+ String defaultValue = null;
Getopt getopt = new Getopt(getName(), args, sopts, lopts);
int code;
@@ -60,6 +62,11 @@ public class ConfigDefRecipeCommand implements RecipeCommand {
break;
}
+ case 'd': {
+ defaultValue = getopt.getOptarg();
+ break;
+ }
+
default: {
throw new IllegalArgumentException("Unexpected error in recipe command");
}
@@ -75,6 +82,9 @@ public class ConfigDefRecipeCommand implements RecipeCommand {
Set<String> replacementVariableNames = new HashSet<String>(1);
replacementVariableNames.add(replacementVariableName);
context.addReplacementVariables(replacementVariableNames);
+ if (defaultValue != null) {
+ context.assignDefaultValueToReplacementVariable(replacementVariableName, defaultValue);
+ }
return;
}
diff --git a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
index e147e45..f6824a1 100644
--- a/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
+++ b/modules/common/filetemplate-bundle/src/main/java/org/rhq/bundle/filetemplate/recipe/RecipeContext.java
@@ -49,6 +49,7 @@ public class RecipeContext {
private final Map<String, String> files;
private final Set<String> realizedFiles;
private final Set<String> replacementVariables;
+ private final Map<String, String> replacementVariableDefaultValues;
private Configuration replacementVariableValues;
private final List<Script> scripts;
private final List<Command> commands;
@@ -62,6 +63,7 @@ public class RecipeContext {
this.files = new HashMap<String, String>();
this.realizedFiles = new HashSet<String>();
this.replacementVariables = new HashSet<String>();
+ this.replacementVariableDefaultValues = new HashMap<String, String>();
this.scripts = new ArrayList<Script>();
this.commands = new ArrayList<Command>();
this.deploymentProperties = new DeploymentProperties();
@@ -172,6 +174,29 @@ public class RecipeContext {
}
/**
+ * If a replacement varaible is known to have a default value, call this
+ * to set that default value.
+ *
+ * @param replacementVariable the variable whose default is being set
+ * @param defaultValue the value of the default for the given replacement variable
+ */
+ public void assignDefaultValueToReplacementVariable(String replacementVariable, String defaultValue) {
+ this.replacementVariableDefaultValues.put(replacementVariable, defaultValue);
+ }
+
+ /**
+ * Returns a map keyed on replacement variables whose values are the default
+ * values for the replacement variables. Note that not all replacement variables
+ * found in {@link #getReplacementVariables()} will have an associated entry
+ * in the returned map (that is, not all variables have a default value).
+ *
+ * @return the map of all known default values for replacement variables
+ */
+ public Map<String, String> getReplacementVariableDefaultValues() {
+ return this.replacementVariableDefaultValues;
+ }
+
+ /**
* If known, the returned value will contain values that are to be used to replace
* replacement variables found in the recipe.
*
@@ -287,6 +312,15 @@ public class RecipeContext {
}
str.append("\n");
+ str.append("Replacement Default Values: ");
+ Map<String, String> defaults = getReplacementVariableDefaultValues();
+ if (defaults == null) {
+ str.append("<none>");
+ } else {
+ str.append(defaults);
+ }
+ str.append("\n");
+
str.append("Script Files: ").append(getScriptFiles()).append("\n");
for (Script script : this.scripts) {
str.append("* ").append(script.getExecutable()).append(" ").append(script.getArguments()).append("\n");
diff --git a/modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java b/modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java
index 16054e0..cc277f1 100644
--- a/modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java
+++ b/modules/common/filetemplate-bundle/src/test/java/org/rhq/bundle/filetemplate/recipe/RecipeParserTest.java
@@ -156,6 +156,20 @@ public class RecipeParserTest {
assert vars.size() == 2 : vars;
assert vars.contains("my.first.property");
assert vars.contains("custom.prop");
+ assert context.getReplacementVariableDefaultValues().isEmpty();
+
+ cleanRecipe();
+ addRecipeCommand("configdef -n custom.prop -d 8080");
+ addRecipeCommand("configdef --name another.prop --default some.default.value");
+ parser = new RecipeParser();
+ context = new RecipeContext(getRecipe());
+ parser.parseRecipe(context);
+ vars = context.getReplacementVariables();
+ assert vars.size() == 2 : vars;
+ assert vars.contains("custom.prop");
+ assert vars.contains("another.prop");
+ assert context.getReplacementVariableDefaultValues().containsKey("another.prop");
+ assert context.getReplacementVariableDefaultValues().get("another.prop").equals("some.default.value");
}
public void testRealizeRecipe() throws Exception {
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
index 74a864e..62b5377 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
@@ -1,30 +1,31 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.core.clientapi.agent.configuration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -36,6 +37,7 @@ 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.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
@@ -47,6 +49,57 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
* @author Ian Springer
*/
public abstract class ConfigurationUtility {
+
+ /**
+ * This will populate the given configuration definition with a default template.
+ * A default template will only be created if one or more properties are required
+ * or have default values. If no property definition is required or has a default value,
+ * the default template will remain <code>null</code> in the given config definition.
+ *
+ * Note that if the given configuration definition already has a default template defined
+ * for it, this method is a no-op and will return immediately.
+ *
+ * @param configDef the configuration definition whose default template is to be created and set
+ */
+ public static void initializeDefaultTemplate(ConfigurationDefinition configDef) {
+ ConfigurationTemplate defaultTemplate = configDef.getDefaultTemplate();
+ if (defaultTemplate == null) {
+ Configuration defaultConfig = createDefaultConfiguration(configDef);
+ // not everything should have a default template - only stuff that has default values
+ if (!defaultConfig.getProperties().isEmpty()) {
+ defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME,
+ ConfigurationTemplate.DEFAULT_TEMPLATE_NAME);
+ defaultTemplate.setDefault(true);
+ defaultTemplate.setConfiguration(defaultConfig);
+ configDef.putTemplate(defaultTemplate);
+ }
+ }
+ return;
+ }
+
+ /**
+ * Given a configuration definition, this will build and return a "default configuration" that
+ * can be validated with the definition. All required properties are set and all properties
+ * that define a default value are also set. If a required property does not have a default
+ * value defined in the definition, the property value will be set to <code>null</code>.
+ *
+ * Use this to help create the definition's default template.
+ *
+ * @param configurationDefinition the configuration definition whose default configuration is to be created
+ * @return configuration the default configuration
+ */
+ public static Configuration createDefaultConfiguration(ConfigurationDefinition configurationDefinition) {
+ if (configurationDefinition == null) {
+ throw new IllegalArgumentException("configurationDefinition == null");
+ }
+ Configuration defaultConfig = new Configuration();
+ Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ createDefaultProperty(childPropertyDefinition, defaultConfig);
+ }
+ return defaultConfig;
+ }
+
/**
* "Normalize" the given configuration according to the given configuration definition. That is, for any optional
* properties that are not defined in the top-level configuration Map or any sub-Maps, set them. Simple properties
@@ -55,9 +108,8 @@ public abstract class ConfigurationUtility {
* @param configuration the configuration to be normalized
* @param configurationDefinition the configuration definition to normalize the configuration against
*/
- public static void normalizeConfiguration(@NotNull
- Configuration configuration, @Nullable
- ConfigurationDefinition configurationDefinition) {
+ public static void normalizeConfiguration(@NotNull Configuration configuration,
+ @Nullable ConfigurationDefinition configurationDefinition) {
//noinspection ConstantConditions
if (configuration == null) {
throw new IllegalArgumentException("Configuration parameter is null.");
@@ -82,9 +134,8 @@ public abstract class ConfigurationUtility {
* @return a list of messages describing any errors that were found
*/
@NotNull
- public static List<String> validateConfiguration(@NotNull
- Configuration configuration, @Nullable
- ConfigurationDefinition configurationDefinition) {
+ public static List<String> validateConfiguration(@NotNull Configuration configuration,
+ @Nullable ConfigurationDefinition configurationDefinition) {
List<String> errorMessages = new ArrayList<String>();
if (configurationDefinition != null) {
Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
@@ -95,6 +146,60 @@ public abstract class ConfigurationUtility {
return errorMessages;
}
+ private static void createDefaultProperty(PropertyDefinition propertyDefinition,
+ AbstractPropertyMap parentPropertyMap) {
+
+ Property property = null;
+
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ String defaultValue = ((PropertyDefinitionSimple) propertyDefinition).getDefaultValue();
+ if (defaultValue != null || propertyDefinition.isRequired()) {
+ property = new PropertySimple(propertyDefinition.getName(), defaultValue);
+ }
+ } else if (propertyDefinition.isRequired()) {
+ if (propertyDefinition instanceof PropertyDefinitionMap) {
+ property = new PropertyMap(propertyDefinition.getName());
+ Map<String, PropertyDefinition> childPropertyDefinitions = ((PropertyDefinitionMap) propertyDefinition)
+ .getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ createDefaultProperty(childPropertyDefinition, (PropertyMap) property);
+ }
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ property = new PropertyList(propertyDefinition.getName());
+ PropertyDefinition listMemberPropertyDefinition = ((PropertyDefinitionList) propertyDefinition)
+ .getMemberDefinition();
+ if (listMemberPropertyDefinition.isRequired()) {
+ if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
+ // member property is a list-o-maps, create a default child map if appropriate
+ PropertyDefinitionMap listMemberDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
+ PropertyMap listMap = new PropertyMap(listMemberDefinitionMap.getName());
+ createDefaultProperty(listMemberDefinitionMap, listMap);
+ ((PropertyList) property).add(listMap);
+ } else if (listMemberPropertyDefinition instanceof PropertyDefinitionSimple) {
+ // member property is a simple, create a single list entry as its default if appropriate
+ PropertyDefinitionSimple listMemberDefinitionSimple = (PropertyDefinitionSimple) listMemberPropertyDefinition;
+ String defaultValue = listMemberDefinitionSimple.getDefaultValue();
+ if (defaultValue != null || listMemberDefinitionSimple.isRequired()) {
+ PropertySimple listSimple = new PropertySimple(listMemberDefinitionSimple.getName(),
+ defaultValue);
+ ((PropertyList) property).add(listSimple);
+ }
+ }
+ }
+ } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
+ // Dynamic property values should simply be stored as simple
+ property = new PropertySimple(propertyDefinition.getName(), null);
+ } else {
+ throw new IllegalStateException("Unsupported PropertyDefinition subclass: "
+ + propertyDefinition.getClass().getName());
+ }
+ }
+
+ if (property != null) {
+ parentPropertyMap.put(property);
+ }
+ }
+
private static void normalizeProperty(PropertyDefinition propertyDefinition, AbstractPropertyMap parentPropertyMap) {
if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName())) // property is already set
{
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
new file mode 100644
index 0000000..3f3dccd
--- /dev/null
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
@@ -0,0 +1,322 @@
+/*
+ * 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, 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.clientapi.agent.configuration;
+
+import org.testng.annotations.Test;
+
+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.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+
+@Test
+public class ConfigurationUtilityTest {
+ public void testCreateDefaultNone() {
+ // no defaults, no required props - returned config should be empty
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionMap map = new PropertyDefinitionMap("map", null, false, simple);
+ PropertyDefinitionList list = new PropertyDefinitionList("list", null, false, simple);
+
+ configDef.put(simple);
+ configDef.put(map);
+ configDef.put(list);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 0;
+ }
+
+ public void testCreateDefaultSimple() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequired = new PropertyDefinitionSimple("simpleRequired", null, true,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleDefault = new PropertyDefinitionSimple("simpleDefault", null, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequiredDefault = new PropertyDefinitionSimple("simpleRequiredDefault", null,
+ true, PropertySimpleType.STRING);
+
+ simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
+ simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
+
+ configDef.put(simple);
+ configDef.put(simpleRequired);
+ configDef.put(simpleDefault);
+ configDef.put(simpleRequiredDefault);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 3; // simple is not required with no default - its not in the config
+ assert config.getSimple(simple.getName()) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");
+ }
+
+ public void testCreateDefaultMap() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ // a=not required, no default; c=not required, has default; d=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null, false, a, b, c);
+ PropertyDefinitionMap mapRequired1 = new PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault1 = new PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
+ c);
+
+ configDef.put(map1);
+ configDef.put(mapRequired1);
+ configDef.put(mapRequiredDefault1);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 2; // map is not required with no default - its not in the config
+ assert config.getMap(map1.getName()) == null;
+
+ // the two required maps have the same definitions - a,b,c as above. since a isn't required with no default, its not there
+ PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
+
+ mapProp1 = config.getMap(mapRequiredDefault1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
+ }
+
+ public void testCreateDefaultList() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ // a=not required, no default, b=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionList list1 = new PropertyDefinitionList("list1", null, false, a);
+ PropertyDefinitionList listRequired1 = new PropertyDefinitionList("listRequired1", null, true, a);
+ PropertyDefinitionList listRequiredDefault1 = new PropertyDefinitionList("listRequiredDefault1", null, true, c);
+
+ configDef.put(list1);
+ configDef.put(listRequired1);
+ configDef.put(listRequiredDefault1);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 2; // list is not required with no default - its not in the config
+ assert config.getList(list1.getName()) == null;
+
+ PropertyList listProp1 = config.getList(listRequired1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().isEmpty(); // has "a" definition, which is not required and has no default
+
+ listProp1 = config.getList(listRequiredDefault1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().get(0).getName().equals(c.getName());
+ assert ((PropertySimple) listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");
+ }
+
+ public void testCreateDefaultListOMaps() {
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ // a=not required, no default; c=not required, has default; d=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null, false, a, b, c);
+ PropertyDefinitionMap mapRequired2 = new PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault2 = new PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
+ c);
+
+ PropertyDefinitionList listX = new PropertyDefinitionList("listX", null, true, map2);
+ PropertyDefinitionList listY = new PropertyDefinitionList("listY", null, true, mapRequired2);
+ PropertyDefinitionList listZ = new PropertyDefinitionList("listZ", null, true, mapRequiredDefault2);
+
+ configDef.put(listX);
+ configDef.put(listY);
+ configDef.put(listZ);
+
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+
+ assert config != null;
+ assert config.getProperties().size() == 3;
+
+ PropertyList listPropTest = config.getList(listX.getName());
+ assert listPropTest != null;
+ assert listPropTest.getList().isEmpty();
+
+ listPropTest = config.getList(listY.getName());
+ assert listPropTest != null;
+ PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);
+
+ listPropTest = config.getList(listZ.getName());
+ assert listPropTest != null;
+ PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);
+
+ assert childMap2.getName().equals(mapRequired2.getName());
+ assert childMap3.getName().equals(mapRequiredDefault2.getName());
+ }
+
+ public void testCreateDefaultAllSimpleMapList() {
+ // tests a big config def that has simples, lists, maps - combination of the other individual tests
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+
+ // SETUP SIMPLE
+
+ PropertyDefinitionSimple simple = new PropertyDefinitionSimple("simple", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequired = new PropertyDefinitionSimple("simpleRequired", null, true,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleDefault = new PropertyDefinitionSimple("simpleDefault", null, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple simpleRequiredDefault = new PropertyDefinitionSimple("simpleRequiredDefault", null,
+ true, PropertySimpleType.STRING);
+
+ simpleDefault.setDefaultValue("!!simpleDefaultValue!!");
+ simpleRequiredDefault.setDefaultValue("!!simpleRequiredDefaultValue!!");
+
+ configDef.put(simple);
+ configDef.put(simpleRequired);
+ configDef.put(simpleDefault);
+ configDef.put(simpleRequiredDefault);
+
+ // SETUP MAP
+
+ // a=not required, no default; c=not required, has default; d=required, has default
+ PropertyDefinitionSimple a = new PropertyDefinitionSimple("a", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple b = new PropertyDefinitionSimple("b", null, false, PropertySimpleType.STRING);
+ PropertyDefinitionSimple c = new PropertyDefinitionSimple("c", null, true, PropertySimpleType.STRING);
+ b.setDefaultValue("!!bDefaultValue!!");
+ c.setDefaultValue("!!cDefaultValue!!");
+
+ PropertyDefinitionMap map1 = new PropertyDefinitionMap("map1", null, false, a, b, c);
+ PropertyDefinitionMap mapRequired1 = new PropertyDefinitionMap("mapRequired1", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault1 = new PropertyDefinitionMap("mapRequiredDefault1", null, true, a, b,
+ c);
+
+ configDef.put(map1);
+ configDef.put(mapRequired1);
+ configDef.put(mapRequiredDefault1);
+
+ // SETUP LIST
+
+ PropertyDefinitionList list1 = new PropertyDefinitionList("list1", null, false, a);
+ PropertyDefinitionList listRequired1 = new PropertyDefinitionList("listRequired1", null, true, a);
+ PropertyDefinitionList listRequiredDefault1 = new PropertyDefinitionList("listRequiredDefault1", null, true, c);
+
+ configDef.put(list1);
+ configDef.put(listRequired1);
+ configDef.put(listRequiredDefault1);
+
+ // SETUP LIST-O-MAPS
+
+ PropertyDefinitionMap map2 = new PropertyDefinitionMap("map2", null, false, a, b, c);
+ PropertyDefinitionMap mapRequired2 = new PropertyDefinitionMap("mapRequired2", null, true, a, b, c);
+ PropertyDefinitionMap mapRequiredDefault2 = new PropertyDefinitionMap("mapRequiredDefault2", null, true, a, b,
+ c);
+
+ PropertyDefinitionList listX = new PropertyDefinitionList("listX", null, true, map2);
+ PropertyDefinitionList listY = new PropertyDefinitionList("listY", null, true, mapRequired2);
+ PropertyDefinitionList listZ = new PropertyDefinitionList("listZ", null, true, mapRequiredDefault2);
+
+ configDef.put(listX);
+ configDef.put(listY);
+ configDef.put(listZ);
+
+ // get the default config
+ Configuration config = ConfigurationUtility.createDefaultConfiguration(configDef);
+ assert config != null;
+ assert config.getProperties().size() == 10;
+
+ // ASSERT SIMPLE
+
+ assert config.getSimple(simple.getName()) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");
+
+ // ASSERT MAP
+
+ assert config.getMap(map1.getName()) == null;
+
+ // the two required maps have the same definitions - a,b,c as above. since a isn't required with no default, its not there
+ PropertyMap mapProp1 = config.getMap(mapRequired1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
+
+ mapProp1 = config.getMap(mapRequiredDefault1.getName());
+ assert mapProp1 != null;
+ assert mapProp1.getSimple(a.getName()) == null;
+ assert mapProp1.getSimpleValue(b.getName(), null).equals("!!bDefaultValue!!");
+ assert mapProp1.getSimpleValue(c.getName(), null).equals("!!cDefaultValue!!");
+
+ // ASSERT LIST
+
+ assert config.getList(list1.getName()) == null;
+
+ PropertyList listProp1 = config.getList(listRequired1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().isEmpty(); // has "a" definition, which is not required and has no default
+
+ listProp1 = config.getList(listRequiredDefault1.getName());
+ assert listProp1 != null;
+ assert listProp1.getList().get(0).getName().equals(c.getName());
+ assert ((PropertySimple) listProp1.getList().get(0)).getStringValue().equals("!!cDefaultValue!!");
+
+ // ASSERT LIST-O-MAPS
+
+ PropertyList listPropTest = config.getList(listX.getName());
+ assert listPropTest != null;
+ assert listPropTest.getList().isEmpty();
+
+ listPropTest = config.getList(listY.getName());
+ assert listPropTest != null;
+ PropertyMap childMap2 = (PropertyMap) listPropTest.getList().get(0);
+
+ listPropTest = config.getList(listZ.getName());
+ assert listPropTest != null;
+ PropertyMap childMap3 = (PropertyMap) listPropTest.getList().get(0);
+
+ assert childMap2.getName().equals(mapRequired2.getName());
+ assert childMap3.getName().equals(mapRequiredDefault2.getName());
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
index 174aa8e..b77b4e6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
@@ -83,10 +83,11 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
* This property's default value. This field should have a non-null value for properties whose
* {@link PropertyDefinition#required} field is <code>false</code> (i.e. for optional properties). Conversely, this
* field should be null for properties whose {@link PropertyDefinition#required} field is <code>true</code> (i.e. for
- * required properties).
- * @deprecated Use the (default) template instead
+ * required properties).
+ *
+ * This field is mainly used to help build default templates. You usually do not want to use this
+ * default value member variable directly - consider using the configuration definition's default template.
*/
- @Deprecated
@Column(name = "DEFAULT_VALUE", length = 2000)
private String defaultValue;
@@ -201,12 +202,29 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
this.allowCustomEnumeratedValue = allowCustomEnumValue;
}
- @Deprecated
+ /**
+ * Returns the default value that this property definition defines for its
+ * value. Note, however, you rarely want to use this directly. Under most
+ * circumstances, you should be using the configuration definition's
+ * {@link ConfigurationDefinition#getDefaultTemplate() default template}.
+ *
+ * For an example of where this method is useful, see
+ * org.rhq.core.clientapi.agent.configuration.ConfigurationUtility.initializeDefaultTemplate(ConfigurationDefinition)
+ *
+ * @return property default value
+ */
public String getDefaultValue() {
return defaultValue;
}
- @Deprecated
+ /**
+ * Sets the default value for this property. Note that you normally call this
+ * only at times when you plan on building default templates with this
+ * property definition later. See {@link #getDefaultValue()} for more details
+ * on this default value.
+ *
+ * @param defaultValue
+ */
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
index 108c097..5c42f9b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/RecipeParseResults.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@ package org.rhq.enterprise.server.bundle;
import java.util.Set;
+import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.util.updater.DeploymentProperties;
@@ -28,7 +29,8 @@ import org.rhq.core.util.updater.DeploymentProperties;
* This class is general to all Bundle handling server side plugins. It is returned by the SSP when parsing
* a bundle's recipe and contains all of the information neded to create a bundle version.
*
- * @author jay shaughnessy
+ * @author Jay Shaughnessy
+ * @author John Mazzitelli
*/
public class RecipeParseResults {
@@ -43,9 +45,9 @@ public class RecipeParseResults {
public RecipeParseResults(DeploymentProperties bundleMetadata, ConfigurationDefinition configDef,
Set<String> bundleFileNames) {
- this.bundleMetadata = bundleMetadata;
- this.configDef = configDef;
- this.bundleFileNames = bundleFileNames;
+ setBundleMetadata(bundleMetadata);
+ setConfigurationDefinition(configDef);
+ setBundleFiles(bundleFileNames);
}
public DeploymentProperties getBundleMetadata() {
@@ -60,8 +62,9 @@ public class RecipeParseResults {
return configDef;
}
- public void setConfigDef(ConfigurationDefinition configDef) {
+ public void setConfigurationDefinition(ConfigurationDefinition configDef) {
this.configDef = configDef;
+ ConfigurationUtility.initializeDefaultTemplate(this.configDef);
}
public Set<String> getBundleFileNames() {
@@ -71,5 +74,4 @@ public class RecipeParseResults {
public void setBundleFiles(Set<String> bundleFileNames) {
this.bundleFileNames = bundleFileNames;
}
-
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index ab55bac..968d5cd 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -57,6 +57,7 @@ import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
import org.rhq.core.domain.configuration.Configuration;
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.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.content.Architecture;
@@ -300,9 +301,30 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
bundleDescription);
ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
- String propName = "prop1";
- String propDescription = "prop1desc";
- configDef.put(new PropertyDefinitionSimple(propName, propDescription, true, PropertySimpleType.INTEGER));
+ int propDefaultValue1 = 998877;
+ String propDefaultValue4 = "this.is.the.default";
+ String propName1 = "prop1requiredWithDefault";
+ String propName2 = "prop2";
+ String propName3 = "prop3requiredWithNoDefault";
+ String propName4 = "prop4notRequiredWithDefault";
+ String propDesc1 = "prop1desc";
+ String propDesc2 = "prop2desc";
+ String propDesc3 = "prop3desc";
+ String propDesc4 = "prop4desc";
+ PropertyDefinitionSimple propdef1requiredWithDefault = new PropertyDefinitionSimple(propName1, propDesc1,
+ true, PropertySimpleType.INTEGER);
+ PropertyDefinitionSimple propdef2 = new PropertyDefinitionSimple(propName2, propDesc2, false,
+ PropertySimpleType.STRING);
+ PropertyDefinitionSimple propdef3requiredWithNoDefault = new PropertyDefinitionSimple(propName3, propDesc3,
+ true, PropertySimpleType.STRING);
+ PropertyDefinitionSimple propdef4notRequiredWithDefault = new PropertyDefinitionSimple(propName4,
+ propDesc4, false, PropertySimpleType.STRING);
+ propdef1requiredWithDefault.setDefaultValue(String.valueOf(propDefaultValue1));
+ propdef4notRequiredWithDefault.setDefaultValue(propDefaultValue4);
+ configDef.put(propdef1requiredWithDefault);
+ configDef.put(propdef2);
+ configDef.put(propdef3requiredWithNoDefault);
+ configDef.put(propdef4notRequiredWithDefault);
Map<String, File> bundleFiles = new HashMap<String, File>(3);
bundleFiles.put(bundleFile1, new File(tmpDir, bundleFile1));
@@ -358,12 +380,41 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assert bundleFileNames.contains(bundleFile2) : bv;
assert bundleFileNames.contains(bundleFile3) : bv;
assert bv.getBundleDeployments().isEmpty() : bv;
- assert bv.getConfigurationDefinition().getPropertyDefinitions().size() == 1;
- assert bv.getConfigurationDefinition().get(propName) != null;
- assert bv.getConfigurationDefinition().get(propName).getDescription().equals(propDescription);
- assert bv.getConfigurationDefinition().get(propName).isRequired();
- assert bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName).getType() == PropertySimpleType.INTEGER;
+ assert bv.getConfigurationDefinition().getPropertyDefinitions().size() == 4;
+ assert bv.getConfigurationDefinition().get(propName1) != null;
+ assert bv.getConfigurationDefinition().get(propName1).getDescription().equals(propDesc1);
+ assert bv.getConfigurationDefinition().get(propName1).isRequired() == true;
+ assert bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName1).getType() == PropertySimpleType.INTEGER;
+ assert bv.getConfigurationDefinition().get(propName2) != null;
+ assert bv.getConfigurationDefinition().get(propName2).getDescription().equals(propDesc2);
+ assert bv.getConfigurationDefinition().get(propName2).isRequired() == false;
+ assert bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName2).getType() == PropertySimpleType.STRING;
+ assert bv.getConfigurationDefinition().get(propName3) != null;
+ assert bv.getConfigurationDefinition().get(propName3).getDescription().equals(propDesc3);
+ assert bv.getConfigurationDefinition().get(propName3).isRequired() == true;
+ assert bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName3).getType() == PropertySimpleType.STRING;
+ assert bv.getConfigurationDefinition().get(propName4) != null;
+ assert bv.getConfigurationDefinition().get(propName4).getDescription().equals(propDesc4);
+ assert bv.getConfigurationDefinition().get(propName4).isRequired() == false;
+ assert bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName4).getType() == PropertySimpleType.STRING;
assert bv.getRecipe().equals(recipe);
+
+ // make sure the default template is correct
+ ConfigurationTemplate defaultTemplate = bv.getConfigurationDefinition().getDefaultTemplate();
+ Configuration defaultConfig = defaultTemplate.getConfiguration();
+ assert defaultConfig.getProperties().size() == 3; // prop2 is not required and has no default, thus is missing
+ PropertySimple prop1 = defaultConfig.getSimple(propName1);
+ PropertySimple prop2 = defaultConfig.getSimple(propName2);
+ PropertySimple prop3 = defaultConfig.getSimple(propName3);
+ PropertySimple prop4 = defaultConfig.getSimple(propName4);
+ assert prop1 != null;
+ assert prop2 == null : "prop2 was not required and has no default, it should not be in the default template config";
+ assert prop3 != null;
+ assert prop4 != null;
+ assert prop1.getIntegerValue() != null;
+ assert prop1.getIntegerValue().intValue() == propDefaultValue1;
+ assert prop3.getStringValue() == null : "prop3 was required but had no default, its template value should have been null";
+ assert prop4.getStringValue().equals(propDefaultValue4);
}
} finally {
FileUtil.purge(tmpDir, true);
diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
index 4db9de9..cdb855a 100644
--- a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
@@ -111,6 +111,7 @@ public class BundleServerPluginComponent implements ServerPluginComponent, Bundl
PropertyDefinitionSimple prop = new PropertyDefinitionSimple(replacementVar,
"Needed by bundle recipe.", false, PropertySimpleType.STRING);
prop.setDisplayName(replacementVar);
+ prop.setDefaultValue(recipeContext.getReplacementVariableDefaultValues().get(replacementVar));
configDef.put(prop);
}
}
commit ebbeac6c225768c858efeb2a6c95037e67ef3d72
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 16:03:34 2010 -0500
support deleting bundle versions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index 2d40a23..ec1ca5e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -111,6 +111,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
form.setWidth100();
form.setColWidths("20%", "40%", "40%");
form.setNumCols(3);
+ form.setAutoHeight();
form.setWrapItemTitles(false);
form.setExtraSpace(10);
form.setIsGroup(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index e0bd7e9..e4ff4d3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -168,6 +168,7 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
form.setWidth100();
form.setColWidths("20%", "40%", "40%");
form.setNumCols(3);
+ form.setAutoHeight();
form.setWrapItemTitles(false);
form.setExtraSpace(10);
form.setIsGroup(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
index 284ef3c..cf4ab17 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
@@ -26,7 +26,13 @@ import java.util.HashSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.util.BooleanCallback;
+import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
@@ -49,9 +55,11 @@ import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
+import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTab;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -61,6 +69,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public class BundleVersionView extends LocatableVLayout implements BookmarkableView {
+ private BundleGWTServiceAsync bundleManager = GWTServiceLookup.getBundleService();
private BundleVersion version;
private boolean canManageBundles = false;
@@ -111,16 +120,24 @@ public class BundleVersionView extends LocatableVLayout implements BookmarkableV
}
private LocatableDynamicForm createSummaryForm() {
+
LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("Summary"));
form.setWidth100();
+ form.setColWidths("20%", "40%", "40%");
+ form.setNumCols(3);
form.setAutoHeight();
- form.setNumCols(2);
form.setWrapItemTitles(false);
form.setExtraSpace(10);
form.setIsGroup(true);
form.setGroupTitle(MSG.common_title_summary());
form.setPadding(5);
+ CanvasItem actionItem = new CanvasItem("actions");
+ actionItem.setColSpan(1);
+ actionItem.setRowSpan(4);
+ actionItem.setShowTitle(false);
+ actionItem.setCanvas(getActionLayout(form.extendLocatorId("actions")));
+
StaticTextItem versionItem = new StaticTextItem("version", MSG.common_title_version());
versionItem.setValue(version.getVersion());
@@ -133,10 +150,47 @@ public class BundleVersionView extends LocatableVLayout implements BookmarkableV
StaticTextItem descriptionItem = new StaticTextItem("description", MSG.common_title_description());
descriptionItem.setValue(version.getDescription());
- form.setFields(versionItem, liveDeploymentsItem, filesItems, descriptionItem);
+ form.setFields(versionItem, actionItem, liveDeploymentsItem, filesItems, descriptionItem);
return form;
}
+ private Canvas getActionLayout(String locatorId) {
+ LocatableVLayout actionLayout = new LocatableVLayout(locatorId, 10);
+ IButton deleteButton = new LocatableIButton(extendLocatorId("Delete"), MSG.common_button_delete());
+ deleteButton.setIcon("subsystems/bundle/BundleVersionAction_Delete_16.png");
+ deleteButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ SC.ask(MSG.view_bundle_version_deleteConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ bundleManager.deleteBundleVersion(version.getId(), false, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_bundle_version_deleteFailure(version.getVersion()), caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_bundle_version_deleteSuccessful(version.getVersion()),
+ Message.Severity.Info));
+ // Bundle version is deleted, go back to main bundle view
+ CoreGUI.goToView(LinkManager.getBundleLink(version.getBundle().getId()));
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ actionLayout.addMember(deleteButton);
+
+ if (!canManageBundles) {
+ deleteButton.setDisabled(true);
+ }
+
+ return actionLayout;
+ }
+
private TagEditorView createTagEditor() {
boolean readOnly = !this.canManageBundles;
TagEditorView tagEditor = new TagEditorView(extendLocatorId("Tags"), version.getTags(), readOnly,
@@ -213,17 +267,16 @@ public class BundleVersionView extends LocatableVLayout implements BookmarkableV
criteria.fetchConfigurationDefinition(true);
criteria.fetchTags(true);
- GWTServiceLookup.getBundleService().findBundleVersionsByCriteria(criteria,
- new AsyncCallback<PageList<BundleVersion>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_bundle_version_loadFailure(), caught);
- }
+ bundleManager.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_bundle_version_loadFailure(), caught);
+ }
- public void onSuccess(PageList<BundleVersion> result) {
- BundleVersion version = result.get(0);
- ViewId nextPath = viewPath.next().getCurrent();
- viewBundleVersion(version, nextPath);
- }
- });
+ public void onSuccess(PageList<BundleVersion> result) {
+ BundleVersion version = result.get(0);
+ ViewId nextPath = viewPath.next().getCurrent();
+ viewBundleVersion(version, nextPath);
+ }
+ });
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 0009db8..d98386e 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -908,6 +908,9 @@ view_bundle_fileListView_loadFailure = Failed to load bundle file data
view_bundle_version_backToBundle = Back to Bundle
view_bundle_version_bundleVersionTagUpdateFailure = Failed to update bundle version tags
view_bundle_version_bundleVersionTagUpdateSuccessful = You have successfully updated the bundle version tags
+view_bundle_version_deleteConfirm = Are you sure you want to delete this bundle version?
+view_bundle_version_deleteFailure = Failed to delete the bundle version [{0}]
+view_bundle_version_deleteSuccessful = You successfully deleted the bundle version [{0}]
view_bundle_version_loadFailure = Failed to load bundle version
view_bundle_tree_loadFailure = Failed to load bundle data
view_bundle_revertWizard_title = Bundle Revert
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16.png
new file mode 100644
index 0000000..f4d69d8
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16_Disabled.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16_Disabled.png
new file mode 100644
index 0000000..c8b5750
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDeploymentAction_Delete_16_Disabled.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16.png
new file mode 100644
index 0000000..7c528ef
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16_Disabled.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16_Disabled.png
new file mode 100644
index 0000000..b76504b
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleDestinationAction_Delete_16_Disabled.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16.png
new file mode 100644
index 0000000..3f5cce4
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16_Disabled.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16_Disabled.png
new file mode 100644
index 0000000..049b3c1
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/bundle/BundleVersionAction_Delete_16_Disabled.png differ
commit 504bd1c6af214f3bacd3a7c894a0f1926bcc9fdb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 12:41:27 2010 -0500
add todo - need to remember this is where the selection fails if tree is not loaded
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
index 74c78ad..272841f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
@@ -64,9 +64,9 @@ public class BundleTreeView extends LocatableTreeGrid {
}
public void selectPath(ViewPath viewPath) {
-
Tree theTree = getTree();
+ // TODO: how do we get the tree to load its nodes if they aren't loaded yet?
if (viewPath.viewsLeft() > 0) {
String key = "";
for (ViewId view : viewPath.getViewPath().subList(2, viewPath.getViewPath().size())) {
@@ -89,7 +89,6 @@ public class BundleTreeView extends LocatableTreeGrid {
final String finalKey = key;
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable reason) {
-
}
public void onSuccess() {
commit 95b92ea3d6b6b8640761ca3081d63c3e50b8606e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 12:34:07 2010 -0500
I'm always confused what these do. adding javadoc so I can remember in the future
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
index 81f9882..122f032 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
@@ -61,7 +61,21 @@ public class Message {
};
public enum Option {
- Transient, Sticky, BackgroundJobResult
+ /**
+ * The message will not be persisted in the message center list.
+ */
+ Transient,
+
+ /**
+ * The message will not auto-clear after a delay - it remains on the screen until you navigate away.
+ */
+ Sticky,
+
+ /**
+ * The message will be persisted in the message center list,
+ * but will not show up in the main screen message area.
+ */
+ BackgroundJobResult
};
public Message(String conciseMessage) {
commit 529f4c4431f6a315b8721e11d36a8185d00e6312
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 11:22:53 2010 -0500
make sure the tree folders are open when selected. this only partially works. if the tree is not loaded yet, it won't load on its own
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index 4bad6b9..dadace4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -226,40 +226,45 @@ public class BundleTreeDataSource extends RPCDataSource {
}
public ListGridRecord copyValuesForKnownBundle(Object from, Integer bundleId) {
+ String parentID;
TreeNode node = new TreeNode();
if (from instanceof Bundle) {
Bundle bundle = (Bundle) from;
+ node.setIsFolder(true);
+ node.setIcon("subsystems/bundle/Bundle_16.png");
node.setID(String.valueOf(bundle.getId()));
node.setName(bundle.getName());
- node.setIcon("subsystems/bundle/Bundle_16.png");
} else if (from instanceof BundleVersion) {
BundleVersion version = (BundleVersion) from;
- node.setName(version.getVersion());
- node.setID(version.getBundle().getId() + "_versions_" + version.getId());
- node.setParentID(version.getBundle().getId() + "_versions");
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleVersion_16.png");
+ parentID = version.getBundle().getId() + "_versions";
+ node.setParentID(parentID);
+ node.setID(parentID + '_' + version.getId());
+ node.setName(version.getVersion());
} else if (from instanceof BundleDeployment) {
BundleDeployment deployment = (BundleDeployment) from;
+ node.setIsFolder(false);
+ node.setIcon("subsystems/bundle/BundleDeployment_16.png");
+ parentID = bundleId + "_destinations_" + deployment.getDestination().getId();
+ node.setParentID(parentID);
+ node.setID(bundleId + "_deployments_" + deployment.getId());
if (deployment.isLive()) {
node.setName("<span style=\"color: green; font-weight: bold\">(live)</span> " + deployment.getName());
} else {
node.setName(deployment.getName());
}
- node.setID(bundleId + "_deployments_" + deployment.getId());
- node.setParentID(bundleId + "_destinations_" + deployment.getDestination().getId());
- node.setIsFolder(false);
- node.setIcon("subsystems/bundle/BundleDeployment_16.png");
} else if (from instanceof BundleDestination) {
BundleDestination destination = (BundleDestination) from;
- node.setName(destination.getName());
- node.setID(destination.getBundle().getId() + "_destinations_" + destination.getId());
- node.setParentID(destination.getBundle().getId() + "_destinations");
node.setIsFolder(true);
node.setIcon("subsystems/bundle/BundleDestination_16.png");
+ parentID = destination.getBundle().getId() + "_destinations";
+ node.setParentID(parentID);
+ node.setID(parentID + '_' + destination.getId());
+ node.setName(destination.getName());
}
return node;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
index 9f3a5be..74c78ad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
@@ -26,6 +26,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.user.client.History;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
import com.smartgwt.client.widgets.tree.events.NodeClickEvent;
import com.smartgwt.client.widgets.tree.events.NodeClickHandler;
@@ -55,7 +56,8 @@ public class BundleTreeView extends LocatableTreeGrid {
addNodeClickHandler(new NodeClickHandler() {
public void onNodeClick(NodeClickEvent event) {
- String path = event.getNode().getAttribute("id").replaceAll("_", "/");
+ TreeNode node = event.getNode();
+ String path = node.getAttribute("id").replaceAll("_", "/");
History.newItem("Bundles/Bundle/" + path);
}
});
@@ -63,6 +65,8 @@ public class BundleTreeView extends LocatableTreeGrid {
public void selectPath(ViewPath viewPath) {
+ Tree theTree = getTree();
+
if (viewPath.viewsLeft() > 0) {
String key = "";
for (ViewId view : viewPath.getViewPath().subList(2, viewPath.getViewPath().size())) {
@@ -71,9 +75,14 @@ public class BundleTreeView extends LocatableTreeGrid {
key += view.getPath();
- TreeNode node = getTree().findById(key);
+ TreeNode node = theTree.findById(key);
if (node != null) {
- getTree().openFolder(node);
+ // make sure all its parents are open as well as itself
+ TreeNode parentNode = node; // prime the pump
+ while (parentNode != null) {
+ theTree.openFolder(parentNode);
+ parentNode = theTree.getParent(parentNode);
+ }
}
}
commit 3a351ac8dd9d8657b04ac024d379db4dec90af49
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 10:13:00 2010 -0500
the separator for our custom keys is underscore, not colon
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
index 12b8e23..9f3a5be 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeView.java
@@ -67,7 +67,7 @@ public class BundleTreeView extends LocatableTreeGrid {
String key = "";
for (ViewId view : viewPath.getViewPath().subList(2, viewPath.getViewPath().size())) {
if (key.length() > 0)
- key += ":";
+ key += "_";
key += view.getPath();
13 years, 5 months
[rhq] 2 commits - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java | 20 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java | 88 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java | 53 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java | 8
4 files changed, 106 insertions(+), 63 deletions(-)
New commits:
commit 7f771252b7e95536c474bad025d458d0ed5bd438
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 07:32:49 2010 -0500
add a third tree level - under destinations, you can now see all deployments made to that dest.
if the deployment is live, you'll see a green, bold string "(live)" next to the name of the deployment
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index f90d8b3..e0bd7e9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -312,7 +312,11 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
}
} else if (viewPath.getCurrent().getPath().equals("deployments")) {
if (viewPath.isEnd()) {
- // TODO: where to go? I don't think this is a valid url right now
+ // today we do not have an uber-view showing all deployments for a bundle.
+ // if we did, it would show all deployments to all destinations for all bundle versions.
+ // because that would be a very large list with a lot of stuff to show, it was deemed
+ // too complex to be useful for users. thus, we have no uber-deployments view. If we did,
+ // we would render it here.
} else {
// a specific deployment
//removeMembers(getMembers());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
index 7dd1e65..4bad6b9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/tree/BundleTreeDataSource.java
@@ -86,10 +86,11 @@ public class BundleTreeDataSource extends RPCDataSource {
protected void executeFetch(final DSRequest request, final DSResponse response) {
String p = request.getCriteria().getAttribute("parentId");
- // load the bundles
if (p == null) {
+ // there is no parent - we are at the root of the tree
+ // get the top nodes (the bundles)
BundleCriteria criteria = new BundleCriteria();
criteria.fetchDestinations(true);
criteria.setPageControl(getPageControl(request));
@@ -107,7 +108,10 @@ public class BundleTreeDataSource extends RPCDataSource {
processResponse(request.getRequestId(), response);
}
});
+
} else {
+
+ // we are at an inner node, being asked to get the children of it
if (p.endsWith("_versions")) {
int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleVersionCriteria criteria = new BundleVersionCriteria();
@@ -125,6 +129,7 @@ public class BundleTreeDataSource extends RPCDataSource {
processResponse(request.getRequestId(), response);
}
});
+
} else if (p.endsWith("_deployments")) {
int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
@@ -141,10 +146,12 @@ public class BundleTreeDataSource extends RPCDataSource {
processResponse(request.getRequestId(), response);
}
});
+
} else if (p.endsWith("_destinations")) {
- int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
+ final int bundleId = Integer.parseInt(p.substring(0, p.indexOf("_")));
BundleDestinationCriteria criteria = new BundleDestinationCriteria();
criteria.addFilterBundleId(bundleId);
+ criteria.fetchDeployments(true);
bundleService.findBundleDestinationsByCriteria(criteria,
new AsyncCallback<PageList<BundleDestination>>() {
public void onFailure(Throwable caught) {
@@ -152,7 +159,7 @@ public class BundleTreeDataSource extends RPCDataSource {
}
public void onSuccess(PageList<BundleDestination> result) {
- response.setData(buildRecords(result));
+ response.setData(buildRecordsForKnownBundle(result, bundleId));
processResponse(request.getRequestId(), response);
}
});
@@ -162,22 +169,31 @@ public class BundleTreeDataSource extends RPCDataSource {
@Override
public Object copyValues(Record from) {
- return null; // TODO: Implement this method.
+ return null; // don't need this method.
}
@Override
public ListGridRecord[] buildRecords(Collection dataObjects) {
+ return buildRecordsForKnownBundle(dataObjects, null);
+ }
+
+ public ListGridRecord[] buildRecordsForKnownBundle(Collection dataObjects, Integer bundleId) {
if (dataObjects == null) {
return null;
}
- List<ListGridRecord> records = new ArrayList<ListGridRecord>();
+ final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
for (Object item : dataObjects) {
+
+ // the resultant item is a direct node to build
records.add(copyValues(item));
+
+ // now build the children of the node
if (item instanceof Bundle) {
Bundle bundle = (Bundle) item;
+ // each bundle has two direct children - the versions and destinations folders
TreeNode versionNode = new TreeNode(MSG.view_bundle_versions());
versionNode.setID(bundle.getId() + "_versions");
versionNode.setParentID(String.valueOf(bundle.getId()));
@@ -190,6 +206,15 @@ public class BundleTreeDataSource extends RPCDataSource {
deploymentsNode.setParentID(String.valueOf(bundle.getId()));
deploymentsNode.setName(MSG.view_bundle_destinations());
records.add(deploymentsNode);
+ } else if (item instanceof BundleDestination) {
+ BundleDestination dest = (BundleDestination) item;
+
+ // each destination has 0, 1 or more deployments
+ if (dest.getDeployments() != null) {
+ for (BundleDeployment deploy : dest.getDeployments()) {
+ records.add(copyValuesForKnownBundle(deploy, bundleId));
+ }
+ }
}
}
return records.toArray(new ListGridRecord[records.size()]);
@@ -197,6 +222,10 @@ public class BundleTreeDataSource extends RPCDataSource {
@Override
public ListGridRecord copyValues(Object from) {
+ return copyValuesForKnownBundle(from, null);
+ }
+
+ public ListGridRecord copyValuesForKnownBundle(Object from, Integer bundleId) {
TreeNode node = new TreeNode();
if (from instanceof Bundle) {
Bundle bundle = (Bundle) from;
@@ -214,19 +243,25 @@ public class BundleTreeDataSource extends RPCDataSource {
} else if (from instanceof BundleDeployment) {
BundleDeployment deployment = (BundleDeployment) from;
- node.setName(deployment.getName() + " (" + deployment.getBundleVersion().getVersion() + ")");
- node.setID(deployment.getBundleVersion().getBundle().getId() + "_deployments_" + deployment.getId());
- node.setParentID(deployment.getBundleVersion().getBundle().getId() + "_deployments");
+ if (deployment.isLive()) {
+ node.setName("<span style=\"color: green; font-weight: bold\">(live)</span> " + deployment.getName());
+ } else {
+ node.setName(deployment.getName());
+ }
+ node.setID(bundleId + "_deployments_" + deployment.getId());
+ node.setParentID(bundleId + "_destinations_" + deployment.getDestination().getId());
node.setIsFolder(false);
node.setIcon("subsystems/bundle/BundleDeployment_16.png");
+
} else if (from instanceof BundleDestination) {
BundleDestination destination = (BundleDestination) from;
node.setName(destination.getName());
node.setID(destination.getBundle().getId() + "_destinations_" + destination.getId());
node.setParentID(destination.getBundle().getId() + "_destinations");
- node.setIsFolder(false);
+ node.setIsFolder(true);
node.setIcon("subsystems/bundle/BundleDestination_16.png");
}
+
return node;
}
}
commit f97b16484480fee641d73e80e1b9b9b711651cb4
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sat Dec 18 06:15:58 2010 -0500
add description, rearrange buttons and description field to be consistent across pages.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index 548037b..2d40a23 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -42,6 +42,7 @@ import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.bundle.deploy.BundleDeployWizard;
@@ -118,13 +119,13 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
LinkItem bundleName = new LinkItem("bundle");
bundleName.setTitle(MSG.view_bundle_bundle());
- bundleName.setValue("#Bundles/Bundle/" + bundle.getId());
+ bundleName.setValue(LinkManager.getBundleLink(bundle.getId()));
bundleName.setLinkTitle(bundle.getName());
bundleName.setTarget("_self");
CanvasItem actionItem = new CanvasItem("actions");
actionItem.setColSpan(1);
- actionItem.setRowSpan(4);
+ actionItem.setRowSpan(5);
actionItem.setShowTitle(false);
actionItem.setCanvas(getActionLayout(form.extendLocatorId("actions")));
@@ -133,14 +134,17 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
LinkItem destinationGroup = new LinkItem("group");
destinationGroup.setTitle(MSG.view_bundle_dest_group());
- destinationGroup.setValue("#ResourceGroup/" + destination.getGroup().getId());
+ destinationGroup.setValue(LinkManager.getResourceGroupLink(destination.getGroup().getId()));
destinationGroup.setLinkTitle(destination.getGroup().getName());
destinationGroup.setTarget("_self");
StaticTextItem path = new StaticTextItem("path", MSG.view_bundle_dest_deployDir());
path.setValue(destination.getDeployDir());
- form.setFields(bundleName, actionItem, created, destinationGroup, path);
+ StaticTextItem description = new StaticTextItem("description", MSG.common_title_description());
+ description.setValue(destination.getDescription());
+
+ form.setFields(bundleName, actionItem, created, destinationGroup, path, description);
return form;
}
@@ -176,9 +180,6 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
new BundleDeployWizard(destination).startWizard();
}
});
- if (!canManageBundles) {
- deployButton.setDisabled(true);
- }
actionLayout.addMember(deployButton);
IButton revertButton = new LocatableIButton(actionLayout.extendLocatorId("Revert"), MSG.view_bundle_revert());
@@ -188,10 +189,13 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
new BundleRevertWizard(destination).startWizard();
}
});
+ actionLayout.addMember(revertButton);
+
if (!canManageBundles) {
+ deployButton.setDisabled(true);
revertButton.setDisabled(true);
}
- actionLayout.addMember(revertButton);
+
return actionLayout;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index 1c9dc47..f90d8b3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -27,6 +27,7 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
@@ -173,8 +174,11 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
form.setGroupTitle(MSG.common_title_summary());
form.setPadding(5);
- StaticTextItem descriptionItem = new StaticTextItem("description", MSG.common_title_description());
- descriptionItem.setValue(bundle.getDescription());
+ CanvasItem actionItem = new CanvasItem("actions");
+ actionItem.setColSpan(1);
+ actionItem.setRowSpan(3);
+ actionItem.setShowTitle(false);
+ actionItem.setCanvas(getActionCanvas());
StaticTextItem versionCountItem = new StaticTextItem("versionCount", MSG.view_bundle_list_versionsCount());
versionCountItem.setValue(bundle.getBundleVersions() != null ? bundle.getBundleVersions().size() : 0);
@@ -183,40 +187,17 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
.view_bundle_list_destinationsCount());
destinationsCountItem.setValue(bundle.getDestinations() != null ? bundle.getDestinations().size() : 0);
- form.setFields(descriptionItem, getActionItem(), versionCountItem, destinationsCountItem);
+ StaticTextItem descriptionItem = new StaticTextItem("description", MSG.common_title_description());
+ descriptionItem.setValue(bundle.getDescription());
+
+ form.setFields(versionCountItem, actionItem, destinationsCountItem, descriptionItem);
return form;
}
- private CanvasItem getActionItem() {
+ private Canvas getActionCanvas() {
VLayout layout = new LocatableVLayout(form.extendLocatorId("Actions"), 10);
- IButton deleteButton = new LocatableIButton(form.extendLocatorId("Delete"), MSG.common_button_delete());
- deleteButton.setIcon("subsystems/bundle/BundleAction_Delete_16.png");
- deleteButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- SC.ask(MSG.view_bundle_list_deleteConfirm(), new BooleanCallback() {
- public void execute(Boolean aBoolean) {
- if (aBoolean) {
- bundleManager.deleteBundle(bundleBeingViewed, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_bundle_list_deleteFailure(bundle.getName()), caught);
- }
-
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_bundle_list_deleteSuccessful(bundle.getName()),
- Message.Severity.Info));
- History.newItem("Bundles"); // Bundle is deleted, go back to all bundles view
- }
- });
- }
- }
- });
- }
- });
-
IButton deployButton = new LocatableIButton(form.extendLocatorId("Deploy"), MSG.view_bundle_deploy());
deployButton.setIcon("subsystems/bundle/BundleAction_Deploy_16.png");
deployButton.addClickHandler(new ClickHandler() {
@@ -244,21 +225,41 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
});
}
});
+ layout.addMember(deployButton);
+
+ IButton deleteButton = new LocatableIButton(form.extendLocatorId("Delete"), MSG.common_button_delete());
+ deleteButton.setIcon("subsystems/bundle/BundleAction_Delete_16.png");
+ deleteButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ SC.ask(MSG.view_bundle_list_deleteConfirm(), new BooleanCallback() {
+ public void execute(Boolean aBoolean) {
+ if (aBoolean) {
+ bundleManager.deleteBundle(bundleBeingViewed, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_bundle_list_deleteFailure(bundle.getName()), caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_bundle_list_deleteSuccessful(bundle.getName()),
+ Message.Severity.Info));
+ History.newItem("Bundles"); // Bundle is deleted, go back to all bundles view
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ layout.addMember(deleteButton);
if (!canManageBundles) {
- deleteButton.setDisabled(true);
deployButton.setDisabled(true);
+ deleteButton.setDisabled(true);
}
- layout.addMember(deleteButton);
- layout.addMember(deployButton);
-
- CanvasItem actionItem = new CanvasItem("actions");
- actionItem.setColSpan(1);
- actionItem.setRowSpan(3);
- actionItem.setShowTitle(false);
- actionItem.setCanvas(layout);
- return actionItem;
+ return layout;
}
public void renderView(final ViewPath viewPath) {
@@ -311,8 +312,7 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
}
} else if (viewPath.getCurrent().getPath().equals("deployments")) {
if (viewPath.isEnd()) {
- // TODO: go to deployments tab for the bundle
- // deployments list screen
+ // TODO: where to go? I don't think this is a valid url right now
} else {
// a specific deployment
//removeMembers(getMembers());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
index 2985f06..284ef3c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/version/BundleVersionView.java
@@ -124,16 +124,16 @@ public class BundleVersionView extends LocatableVLayout implements BookmarkableV
StaticTextItem versionItem = new StaticTextItem("version", MSG.common_title_version());
versionItem.setValue(version.getVersion());
- StaticTextItem descriptionItem = new StaticTextItem("description", MSG.common_title_description());
- descriptionItem.setValue(version.getDescription());
-
StaticTextItem liveDeploymentsItem = new StaticTextItem("deployments", MSG.view_bundle_deployments());
liveDeploymentsItem.setValue(version.getBundleDeployments().size());
StaticTextItem filesItems = new StaticTextItem("files", MSG.view_bundle_files());
filesItems.setValue(version.getBundleFiles().size());
- form.setFields(versionItem, descriptionItem, liveDeploymentsItem, filesItems);
+ StaticTextItem descriptionItem = new StaticTextItem("description", MSG.common_title_description());
+ descriptionItem.setValue(version.getDescription());
+
+ form.setFields(versionItem, liveDeploymentsItem, filesItems, descriptionItem);
return form;
}
13 years, 5 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java | 9 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java | 24 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java | 72 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java | 14 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java | 9 -
7 files changed, 116 insertions(+), 18 deletions(-)
New commits:
commit 930cd482ebf00702f399b8faa10b504b5ce4a35a
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Dec 17 18:08:58 2010 -0500
start of details view for Resource operation schedules (view and new modes)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java
index e30a6bb..199ca19 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/EnhancedDynamicForm.java
@@ -74,8 +74,12 @@ public class EnhancedDynamicForm extends LocatableDynamicForm {
setWrapItemTitles(false);
// Other Display Settings
- setHiliteRequiredFields(true);
- setRequiredTitleSuffix(" <span class='requiredFieldMarker'>*</span> :");
+ if (readOnly) {
+ setHiliteRequiredFields(false);
+ } else {
+ setHiliteRequiredFields(true);
+ setRequiredTitleSuffix(" <span class='requiredFieldMarker'>*</span> :");
+ }
// DataSource Settings
setUseAllDataSourceFields(false);
@@ -106,6 +110,7 @@ public class EnhancedDynamicForm extends LocatableDynamicForm {
StaticTextItem staticItem = new StaticTextItem(item.getName(), item.getTitle());
staticItem.setTooltip(item.getTooltip());
staticItem.setValue(item.getValue());
+ staticItem.setColSpan(item.getAttribute("colSpan"));
// TODO: Any other fields we should copy? icons?
if (item instanceof BooleanItem) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
index 06e68e5..1e0d4a8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
@@ -19,7 +19,9 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Set;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
@@ -30,7 +32,9 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.bean.OperationSchedule;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -38,7 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
* @author Ian Springer
*/
-public abstract class OperationScheduleDataSource<T extends OperationSchedule> extends RPCDataSource<T> {
+public abstract class OperationScheduleDataSource<T extends OperationSchedule> extends RPCDataSource<T> {
public static abstract class Field {
public static final String ID = "id";
@@ -54,8 +58,11 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
- public OperationScheduleDataSource() {
+ private ResourceType resourceType;
+
+ public OperationScheduleDataSource(ResourceType resourceType) {
super();
+ this.resourceType = resourceType;
List<DataSourceField> fields = addDataSourceFields();
addFields(fields);
}
@@ -70,13 +77,24 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
idField.setCanEdit(false);
fields.add(idField);
+ DataSourceTextField operationNameField = createTextField(Field.OPERATION_NAME, "Operation", null, 100, true);
+ fields.add(operationNameField);
+
DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, "Operation", null, 100, true);
fields.add(operationDisplayNameField);
+ Set<OperationDefinition> operationDefinitions = this.resourceType.getOperationDefinitions();
+ LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>();
+ for (OperationDefinition operationDefinition : operationDefinitions) {
+ valueMap.put(operationDefinition.getName(), operationDefinition.getDisplayName());
+ }
+ operationNameField.setValueMap(valueMap);
+
DataSourceTextField subjectField = createTextField(Field.SUBJECT, "Owner", null, 100, true);
+ subjectField.setCanEdit(false);
fields.add(subjectField);
- DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION, "Description", null, 100, true);
+ DataSourceTextField descriptionField = createTextField(Field.DESCRIPTION, "Notes", null, 100, false);
fields.add(descriptionField);
DataSourceTextField jobTriggerField = createTextField(Field.JOB_TRIGGER, "Schedule", null, 100, true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
index d658acc..d615316 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
@@ -58,7 +58,7 @@ public abstract class OperationScheduleListView extends TableSection<OperationSc
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
- // TODO: wizard or details view
+ newDetails();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
new file mode 100644
index 0000000..12df23e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
@@ -0,0 +1,72 @@
+/*
+ * 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.inventory.common.detail.operation.schedule;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.form.AbstractRecordEditor;
+import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
+
+ public ResourceOperationScheduleDetailsView(String locatorId, ResourceComposite resourceComposite, int scheduleId) {
+ super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite), scheduleId, "Scheduled Operation", null);
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ super.renderView(viewPath);
+
+ // Existing schedules are not editable. This may change in the future.
+ boolean isReadOnly = (getRecordId() != 0);
+ init(isReadOnly);
+ }
+
+ @Override
+ protected List<FormItem> createFormItems(EnhancedDynamicForm form) {
+ List<FormItem> items = new ArrayList<FormItem>();
+
+ SelectItem operationNameItem = new SelectItem(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
+ items.add(operationNameItem);
+
+ TextAreaItem descriptionItem = new TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
+ descriptionItem.setColSpan(form.getNumCols());
+ items.add(descriptionItem);
+
+ return items;
+ }
+
+ @Override
+ protected String getTitleFieldName() {
+ return ResourceOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
+ }
+
+}
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 9cbf3e2..ffc4ca5 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
@@ -347,8 +347,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.operationsTab, this.operationsHistory, new ResourceOperationHistoryListView(operationsTab
.extendLocatorId("HistoryView"), this.resourceComposite), true, true);
- updateSubTab(this.operationsTab, this.operationsSchedule,new ResourceOperationScheduleListView(operationsTab.extendLocatorId("SchedulesView"), this.resourceComposite),
- true, true);
+ updateSubTab(this.operationsTab, this.operationsSchedule,new ResourceOperationScheduleListView(
+ operationsTab.extendLocatorId("SchedulesView"), this.resourceComposite), true, true);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
index e044f51..6e9c744 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDataSource.java
@@ -28,6 +28,7 @@ import com.smartgwt.client.data.Record;
import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
/**
@@ -37,10 +38,11 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.s
*/
public class ResourceOperationScheduleDataSource extends OperationScheduleDataSource<ResourceOperationSchedule> {
- private int resourceId;
+ private ResourceComposite resourceComposite;
- public ResourceOperationScheduleDataSource(int resourceId) {
- this.resourceId = resourceId;
+ public ResourceOperationScheduleDataSource(ResourceComposite resourceComposite) {
+ super(resourceComposite.getResource().getResourceType());
+ this.resourceComposite = resourceComposite;
}
@Override
@@ -50,7 +52,7 @@ public class ResourceOperationScheduleDataSource extends OperationScheduleDataSo
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
- operationService.findScheduledResourceOperations(this.resourceId,
+ operationService.findScheduledResourceOperations(this.resourceComposite.getResource().getId(),
new AsyncCallback<List<ResourceOperationSchedule>>() {
public void onSuccess(List<ResourceOperationSchedule> result) {
Record[] records = buildRecords(result);
@@ -59,8 +61,8 @@ public class ResourceOperationScheduleDataSource extends OperationScheduleDataSo
}
public void onFailure(Throwable caught) {
- throw new RuntimeException("Failed to find scheduled operations for Resource with id ["
- + resourceId + "].", caught);
+ throw new RuntimeException("Failed to find scheduled operations for "
+ + resourceComposite.getResource() + ".", caught);
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
index 03de2a6..14bb294 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
@@ -22,8 +22,8 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operatio
import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.ResourceOperationScheduleDetailsView;
/**
* @author Ian Springer
@@ -35,7 +35,7 @@ public class ResourceOperationScheduleListView extends OperationScheduleListView
private ResourceComposite resourceComposite;
public ResourceOperationScheduleListView(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite.getResource().getId()), TITLE);
+ super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite), TITLE);
this.resourceComposite = resourceComposite;
}
@@ -45,8 +45,9 @@ public class ResourceOperationScheduleListView extends OperationScheduleListView
}
@Override
- public Canvas getDetailsView(int id) {
- return new Canvas(); // TODO
+ public Canvas getDetailsView(int scheduleId) {
+ return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"),
+ this.resourceComposite, scheduleId);
}
}
13 years, 5 months
[rhq] modules/core modules/enterprise
by ips
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/OperationScheduleIdSetterUpgradeTask.java | 60 ++++++++++
modules/core/dbutils/src/main/scripts/dbsetup/operation-schema.xml | 19 +--
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 19 +++
modules/core/domain/src/main/java/org/rhq/core/domain/operation/GroupOperationScheduleEntity.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java | 31 ++++-
modules/core/domain/src/main/java/org/rhq/core/domain/operation/ResourceOperationScheduleEntity.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/operation/ScheduleJobId.java | 6 -
modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java | 9 +
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java | 8 -
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java | 24 ++--
modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java | 8 -
modules/core/domain/src/test/java/org/rhq/core/domain/operation/test/JobIdTest.java | 7 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java | 23 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationJob.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 50 +++++++-
16 files changed, 220 insertions(+), 55 deletions(-)
New commits:
commit 28b070f78cac12c2c2f58194361133d3cc0b2e2d
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Dec 17 15:52:12 2010 -0500
add ID field to RHQ_OPERATION_SCHEDULE and make it the primary key
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index c6bdebd..2d8d1fc 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.101</db.schema.version>
+ <db.schema.version>2.102</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/OperationScheduleIdSetterUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/OperationScheduleIdSetterUpgradeTask.java
new file mode 100644
index 0000000..58692c9
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/OperationScheduleIdSetterUpgradeTask.java
@@ -0,0 +1,60 @@
+/*
+ * 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.core.db.upgrade;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.rhq.core.db.DatabaseType;
+
+/**
+ * Sets values on the id column for all rows in RHQ_OPERATION_SCHEDULE. The id's are set, starting at 10001, in the
+ * order that the rows were created. This is done by parsing the value of the JOB_NAME column, which includes the
+ * creation time.
+ *
+ * @author Ian Springer
+ */
+public class OperationScheduleIdSetterUpgradeTask implements DatabaseUpgradeTask {
+
+ @Override
+ public void execute(DatabaseType databaseType, Connection connection) throws SQLException {
+ String selectSQL = "SELECT job_name FROM rhq_operation_schedule;";
+ System.out.println("Executing: " + selectSQL);
+ List<Object[]> results = databaseType.executeSelectSql(connection, selectSQL);
+ Map<Long, String> sortedJobNames = new TreeMap<Long, String>();
+ for (Object[] result : results) {
+ String jobName = (String)result[0]; // e.g.: rhq-resource-10001--121207376-1292542028679
+ // last portion is the job's creation time, e.g.: 1292542028679
+ Long ctime = Long.valueOf(jobName.substring(jobName.lastIndexOf('-') + 1));
+ sortedJobNames.put(ctime, jobName);
+ }
+ int id = 10001;
+ for (String jobName : sortedJobNames.values()) {
+ String updateSQL = "UPDATE rhq_operation_schedule SET id = " + (id++) + " WHERE job_name = '" + jobName +
+ "';";
+ System.out.println("Executing: " + updateSQL);
+ databaseType.executeSql(connection, updateSQL);
+ }
+ }
+
+}
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/operation-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/operation-schema.xml
index 2e34094..68b3274 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/operation-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/operation-schema.xml
@@ -71,6 +71,8 @@
code special conditions into the session bean, we'll allow a short-lived NULL next fire time row.
-->
<table name="RHQ_OPERATION_SCHEDULE">
+ <column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
+
<column name="JOB_NAME" type="VARCHAR2" required="true" size="100"/>
<column name="JOB_GROUP" type="VARCHAR2" required="true" size="100"/>
<column name="DTYPE" type="VARCHAR2" required="true" size="8"/>
@@ -83,16 +85,15 @@
<column name="GROUP_ID" type="INTEGER" required="false" references="RHQ_RESOURCE_GROUP"/>
<!--
- Note that this is the same primary key that Quartz uses for its schedules (RHQ_qrtz_job_details).
- We do not need to add DTYPE to the key, because we ensure the name/group are unique
- across resource/group schedules
+ Note, this is the same as the primary key that Quartz uses for its schedules (RHQ_QRTZ_JOB_DETAILS).
+ We do not need to add DTYPE to the key, because we ensure the name/group are unique across resource/group
+ schedules
-->
- <constraint name="RHQ_OPERATION_SCHEDULE_KEY">
- <primaryKey>
- <field ref="JOB_NAME"/>
- <field ref="JOB_GROUP"/>
- </primaryKey>
- </constraint>
+ <!-- === business key (JOB_NAME + JOB_GROUP) === -->
+ <index name="RHQ_OPERATION_SCHEDULE_KEY_IDX" unique="true">
+ <field ref="JOB_NAME"/>
+ <field ref="JOB_GROUP"/>
+ </index>
</table>
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index d9f63c0..975c778 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3277,6 +3277,25 @@
</schema-directSQL>
<schema-alterColumn table="RHQ_RESOURCE_TYPE" column="DELETED" nullable="FALSE" />
</schemaSpec>
+
+ <schemaSpec version="2.102">
+ <!-- Create the ID column nullable. -->
+ <schema-addColumn table="RHQ_OPERATION_SCHEDULE" column="ID" columnType="INTEGER" />
+ <!-- Set values for ID column on all existing rows. -->
+ <schema-javaTask className="OperationScheduleIdSetterUpgradeTask" />
+ <!-- Now that all existing rows have IDs, switch the column to non-nullable. -->
+ <schema-alterColumn table="RHQ_OPERATION_SCHEDULE" column="ID" nullable="FALSE" />
+ <!-- Finally, make ID the primary key, rather than (JOB_NAME, JOB_GROUP), and make
+ (JOB_NAME, JOB_GROUP) a unique index instead. -->
+ <schema-directSQL>
+ <statement desc="Changing primary key of RHQ_OPERATION_SCHEDULE to ID...">
+ ALTER TABLE RHQ_OPERATION_SCHEDULE DROP CONSTRAINT RHQ_OPERATION_SCHEDULE_KEY;
+ ALTER TABLE RHQ_OPERATION_SCHEDULE ADD PRIMARY KEY (ID);
+ CREATE UNIQUE INDEX RHQ_OPERATION_SCHEDULE_KEY_IDX ON RHQ_OPERATION_SCHEDULE (JOB_NAME, JOB_GROUP);
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/GroupOperationScheduleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/GroupOperationScheduleEntity.java
index 39f85d2..3f545bd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/GroupOperationScheduleEntity.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/GroupOperationScheduleEntity.java
@@ -36,6 +36,7 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
@NamedQueries( { @NamedQuery(name = GroupOperationScheduleEntity.QUERY_FIND_BY_GROUP_ID, query = "SELECT s "
+ " FROM GroupOperationScheduleEntity s " + " WHERE s.group.id = :groupId ") })
public class GroupOperationScheduleEntity extends OperationScheduleEntity {
+
public static final String QUERY_FIND_BY_GROUP_ID = "GroupOperationScheduleEntity.findByGroupId";
private static final long serialVersionUID = 1L;
@@ -68,4 +69,5 @@ public class GroupOperationScheduleEntity extends OperationScheduleEntity {
str.append("]");
return str.toString();
}
+
}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java
index 7da39d1..6eea462 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java
@@ -28,12 +28,14 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.IdClass;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
/**
@@ -45,10 +47,8 @@ import javax.persistence.Table;
*
* @author John Mazzitelli
*/
-
@DiscriminatorColumn(name = "DTYPE")
@Entity
-(a)IdClass(ScheduleJobId.class)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQueries( {
@NamedQuery(name = OperationScheduleEntity.QUERY_FIND_BY_JOB_ID, query = "" //
@@ -58,6 +58,7 @@ import javax.persistence.Table;
+ " AND s.jobGroup = :jobGroup "),
@NamedQuery(name = OperationScheduleEntity.QUERY_GET_SCHEDULE_RESOURCE_ADMIN, query = "" //
+ "SELECT DISTINCT new org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite( "
+ + " ro.id, " //
+ " ro.jobName, " //
+ " ro.jobGroup, " //
+ " '', " //
@@ -69,6 +70,7 @@ import javax.persistence.Table;
+ " WHERE ro.nextFireTime IS NOT NULL "), //
@NamedQuery(name = OperationScheduleEntity.QUERY_GET_SCHEDULE_RESOURCE, query = "" //
+ "SELECT DISTINCT new org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite( "
+ + " ro.id, " //
+ " ro.jobName, " //
+ " ro.jobGroup, " //
+ " '', " //
@@ -84,6 +86,7 @@ import javax.persistence.Table;
+ " AND s = :subject "), //
@NamedQuery(name = OperationScheduleEntity.QUERY_GET_SCHEDULE_GROUP_ADMIN, query = "" //
+ "SELECT DISTINCT new org.rhq.core.domain.operation.composite.GroupOperationScheduleComposite( "
+ + " go.id, " //
+ " go.jobName, " //
+ " go.jobGroup, " //
+ " '', " //
@@ -95,6 +98,7 @@ import javax.persistence.Table;
+ " WHERE go.nextFireTime IS NOT NULL "), //
@NamedQuery(name = OperationScheduleEntity.QUERY_GET_SCHEDULE_GROUP, query = "" //
+ "SELECT DISTINCT new org.rhq.core.domain.operation.composite.GroupOperationScheduleComposite( "
+ + " go.id, " //
+ " go.jobName, " //
+ " go.jobGroup, " //
+ " '', " //
@@ -108,8 +112,10 @@ import javax.persistence.Table;
+ " JOIN r.subjects s " //
+ " WHERE go.nextFireTime IS NOT NULL " //
+ " AND s = :subject ") })
+@SequenceGenerator(name = "id", sequenceName = "RHQ_OPERATION_SCHEDULE_ID_SEQ")
@Table(name = "RHQ_OPERATION_SCHEDULE")
public abstract class OperationScheduleEntity implements Serializable {
+
public static final String QUERY_FIND_BY_JOB_ID = "OperationScheduleEntity.findByJobId";
public static final String QUERY_GET_SCHEDULE_RESOURCE = "OperationScheduleEntity.getScheduleResource";
public static final String QUERY_GET_SCHEDULE_RESOURCE_ADMIN = "OperationScheduleEntity.getScheduleResource_admin";
@@ -118,10 +124,15 @@ public abstract class OperationScheduleEntity implements Serializable {
private static final long serialVersionUID = 1L;
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
@Id
+ private int id;
+
+ @Column(name = "JOB_NAME", nullable = false)
private String jobName;
- @Id
+ @Column(name = "JOB_GROUP", nullable = false)
private String jobGroup;
@Column(name = "NEXT_FIRE_TIME", nullable = true)
@@ -136,6 +147,10 @@ public abstract class OperationScheduleEntity implements Serializable {
this.nextFireTime = (nextFireTime == null) ? null : nextFireTime.getTime();
}
+ public int getId() {
+ return id;
+ }
+
/**
* The single job ID which identifies this specific schedule. It can later be parsed via
* {@link ScheduleJobId#ScheduleJobId(String)}.
@@ -184,9 +199,10 @@ public abstract class OperationScheduleEntity implements Serializable {
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
- buf.append("job-name=[" + jobName);
- buf.append("], job-group=[" + jobGroup);
- buf.append("], next-fire-time=[" + ((nextFireTime == null) ? "never" : new Date(nextFireTime)));
+ buf.append("id=" + id);
+ buf.append(", jobName=" + jobName);
+ buf.append(", jobGroup=" + jobGroup);
+ buf.append(", nextFireTime=" + ((nextFireTime == null) ? "never" : new Date(nextFireTime)));
return buf.toString();
}
@@ -210,4 +226,5 @@ public abstract class OperationScheduleEntity implements Serializable {
return this.getJobId().equals(other.getJobId());
}
+
}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/ResourceOperationScheduleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/ResourceOperationScheduleEntity.java
index b7be10a..46dc63e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/ResourceOperationScheduleEntity.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/ResourceOperationScheduleEntity.java
@@ -34,11 +34,10 @@ import javax.persistence.NamedQuery;
import org.rhq.core.domain.resource.Resource;
/**
- * Information on a specific operation schedule on a particular resource.
+ * Information on a specific operation schedule on a particular Resource.
*
* @author John Mazzitelli
*/
-
@DiscriminatorValue("resource")
@Entity
@NamedQueries( {
@@ -47,6 +46,7 @@ import org.rhq.core.domain.resource.Resource;
@NamedQuery(name = ResourceOperationScheduleEntity.QUERY_DELETE_BY_RESOURCES, query = "DELETE FROM ResourceOperationScheduleEntity s "
+ " WHERE s.resource.id IN ( :resourceIds ) )") })
public class ResourceOperationScheduleEntity extends OperationScheduleEntity {
+
public static final String QUERY_DELETE_BY_RESOURCES = "ResourceOperationScheduleEntity.QUERY_DELETE_BY_RESOURCES";
public static final String QUERY_FIND_BY_RESOURCE_ID = "ResourceOperationScheduleEntity.findByResourceId";
@@ -80,4 +80,5 @@ public class ResourceOperationScheduleEntity extends OperationScheduleEntity {
str.append("]");
return str.toString();
}
+
}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/ScheduleJobId.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/ScheduleJobId.java
index 0d29a76..bc6641b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/ScheduleJobId.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/ScheduleJobId.java
@@ -23,8 +23,10 @@
package org.rhq.core.domain.operation;
/**
- * This class is a mutable version of {@link JobId} and is used as the primary key to the
- * {@link OperationScheduleEntity} entities.
+ * This class is a mutable version of {@link JobId}, which represents the unique identifier of the Quartz job
+ * for a scheduled RHQ operation.
+ *
+ * NOTE: It is no longer used as the primary key to the {@link OperationScheduleEntity} entities.
*
* @author John Mazzitelli
*/
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java
index c638b31..70f6a36 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/bean/OperationSchedule.java
@@ -41,6 +41,7 @@ import org.rhq.core.domain.operation.JobId;
public abstract class OperationSchedule implements Serializable {
private static final long serialVersionUID = 1L;
+ private int id;
private String jobName;
private String jobGroup;
private String operationName;
@@ -53,6 +54,14 @@ public abstract class OperationSchedule implements Serializable {
public OperationSchedule() {
}
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
public String getJobGroup() {
return jobGroup;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java
index b5fba55..1107b06 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/GroupOperationScheduleComposite.java
@@ -22,8 +22,6 @@
*/
package org.rhq.core.domain.operation.composite;
-import org.rhq.core.domain.operation.ScheduleJobId;
-
/**
* Provides some information on a compatible group's scheduled operation.
*
@@ -31,15 +29,15 @@ import org.rhq.core.domain.operation.ScheduleJobId;
*/
public class GroupOperationScheduleComposite extends OperationScheduleComposite {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2L;
private final int groupId;
private final String groupName;
private final String groupResourceTypeName;
- public GroupOperationScheduleComposite(String jobName, String jobGroup, String operationName,
+ public GroupOperationScheduleComposite(int id, String jobName, String jobGroup, String operationName,
long operationNextFireTime, int groupId, String groupName, String groupResourceTypeName) {
- super(new ScheduleJobId(jobName, jobGroup), operationName, operationNextFireTime);
+ super(id, jobName, jobGroup, operationName, operationNextFireTime);
this.groupId = groupId;
this.groupName = groupName;
this.groupResourceTypeName = groupResourceTypeName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java
index dc99113..f80811a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/OperationScheduleComposite.java
@@ -25,31 +25,37 @@ package org.rhq.core.domain.operation.composite;
import java.io.Serializable;
import java.util.Date;
-import org.rhq.core.domain.operation.ScheduleJobId;
+import org.rhq.core.domain.operation.JobId;
public abstract class OperationScheduleComposite implements Serializable {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2L;
- private ScheduleJobId operationJobId;
+ private int id;
+ private JobId jobId;
private String operationName;
private long operationNextFireTime;
//no args constructor for serialization purposes not to be used.
protected OperationScheduleComposite() {
this.operationNextFireTime = -1;
- this.operationJobId = null;
+ this.id = 0;
this.operationName = "(uninitialized)";
}
- public OperationScheduleComposite(ScheduleJobId operationJobId, String operationName, long operationNextFireTime) {
- this.operationJobId = operationJobId;
+ public OperationScheduleComposite(int id, String jobName, String jobGroup, String operationName, long operationNextFireTime) {
+ this.id = id;
+ this.jobId = new JobId(jobName, jobGroup);
this.operationName = operationName;
this.operationNextFireTime = operationNextFireTime;
}
- public ScheduleJobId getOperationJobId() {
- return operationJobId;
+ public int getId() {
+ return id;
+ }
+
+ public JobId getJobId() {
+ return jobId;
}
public String getOperationName() {
@@ -72,7 +78,7 @@ public abstract class OperationScheduleComposite implements Serializable {
@Override
public String toString() {
StringBuilder str = new StringBuilder();
- str.append("operation-job-id=[" + operationJobId);
+ str.append("operation-job-id=[" + id);
str.append("], operation-name=[" + operationName);
str.append("], operation-next-fire-time=[" + new Date(operationNextFireTime));
str.append("]");
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
index a0996a7..7ddd0d1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/composite/ResourceOperationScheduleComposite.java
@@ -22,11 +22,9 @@
*/
package org.rhq.core.domain.operation.composite;
-import org.rhq.core.domain.operation.ScheduleJobId;
-
public class ResourceOperationScheduleComposite extends OperationScheduleComposite {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 2L;
private int resourceId;
private String resourceName;
@@ -40,9 +38,9 @@ public class ResourceOperationScheduleComposite extends OperationScheduleComposi
this.resourceId = 0;
}
- public ResourceOperationScheduleComposite(String jobName, String jobGroup, String operationName,
+ public ResourceOperationScheduleComposite(int id, String jobName, String jobGroup, String operationName,
long operationNextFireTime, int resourceId, String resourceName, String resourceTypeName) {
- super(new ScheduleJobId(jobName, jobGroup), operationName, operationNextFireTime);
+ super(id, jobName, jobGroup, operationName, operationNextFireTime);
this.resourceId = resourceId;
this.resourceName = resourceName;
this.resourceTypeName = resourceTypeName;
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/operation/test/JobIdTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/operation/test/JobIdTest.java
index 48ff284..8cb8ca7 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/operation/test/JobIdTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/operation/test/JobIdTest.java
@@ -22,13 +22,17 @@
*/
package org.rhq.core.domain.operation.test;
+import org.rhq.core.domain.operation.ScheduleJobId;
import org.testng.annotations.Test;
import org.rhq.core.domain.operation.HistoryJobId;
import org.rhq.core.domain.operation.JobId;
-import org.rhq.core.domain.operation.ScheduleJobId;
+ /**
+ * Test the equals() and hashCode() methods on {@link JobId}, {@link HistoryJobId}, and {@link ScheduleJobId}.
+ */
@Test
public class JobIdTest {
+
public void testJobIdEquals() {
JobId one;
JobId two;
@@ -170,4 +174,5 @@ public class JobIdTest {
assert !one.equals(two);
assert one.hashCode() != two.hashCode();
}
+
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
index 65fe51f..06e68e5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
@@ -23,6 +23,7 @@ import java.util.List;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -40,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
public abstract class OperationScheduleDataSource<T extends OperationSchedule> extends RPCDataSource<T> {
public static abstract class Field {
+ public static final String ID = "id";
public static final String JOB_NAME = "jobName";
public static final String JOB_GROUP = "jobGroup";
public static final String OPERATION_NAME = "operationName";
@@ -63,6 +65,11 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
protected List<DataSourceField> addDataSourceFields() {
List<DataSourceField> fields = super.addDataSourceFields();
+ DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID, "ID");
+ idField.setPrimaryKey(true);
+ idField.setCanEdit(false);
+ fields.add(idField);
+
DataSourceTextField operationDisplayNameField = createTextField(Field.OPERATION_DISPLAY_NAME, "Operation", null, 100, true);
fields.add(operationDisplayNameField);
@@ -84,14 +91,15 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
public T copyValues(Record from) {
T to = createOperationSchedule();
+ to.setId(from.getAttributeAsInt(Field.ID));
to.setJobName(from.getAttribute(Field.JOB_NAME));
to.setJobGroup(from.getAttribute(Field.JOB_GROUP));
to.setJobTrigger((JobTrigger)from.getAttributeAsObject(Field.JOB_TRIGGER));
- to.setDescription(from.getAttribute(Field.DESCRIPTION));
- to.setOperationDisplayName(from.getAttribute(Field.OPERATION_DISPLAY_NAME));
- to.setOperationName(from.getAttribute(Field.OPERATION_NAME));
- to.setParameters((Configuration)from.getAttributeAsObject(Field.PARAMETERS));
to.setSubject((Subject)from.getAttributeAsObject(Field.SUBJECT));
+ to.setParameters((Configuration)from.getAttributeAsObject(Field.PARAMETERS));
+ to.setOperationName(from.getAttribute(Field.OPERATION_NAME));
+ to.setOperationDisplayName(from.getAttribute(Field.OPERATION_DISPLAY_NAME));
+ to.setDescription(from.getAttribute(Field.DESCRIPTION));
return to;
}
@@ -100,14 +108,15 @@ public abstract class OperationScheduleDataSource<T extends OperationSchedule> e
public ListGridRecord copyValues(T from) {
ListGridRecord to = new ListGridRecord();
+ to.setAttribute(Field.ID, from.getId());
to.setAttribute(Field.JOB_NAME, from.getJobName());
to.setAttribute(Field.JOB_GROUP, from.getJobGroup());
to.setAttribute(Field.JOB_TRIGGER, from.getJobTrigger());
- to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
- to.setAttribute(Field.OPERATION_NAME, from.getOperationName());
to.setAttribute(Field.SUBJECT, from.getSubject());
- to.setAttribute(Field.DESCRIPTION, from.getDescription());
to.setAttribute(Field.PARAMETERS, from.getParameters());
+ to.setAttribute(Field.OPERATION_NAME, from.getOperationName());
+ to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
+ to.setAttribute(Field.DESCRIPTION, from.getDescription());
return to;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationJob.java
index f5988e3..db58484 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationJob.java
@@ -39,6 +39,8 @@ public abstract class OperationJob implements Job {
public static final String DATAMAP_STRING_OPERATION_DISPLAY_NAME = "operationDisplayName";
public static final String DATAMAP_INT_PARAMETERS_ID = "parametersId"; // the configuration ID
public static final String DATAMAP_INT_SUBJECT_ID = "subjectId";
+ // id of the associated OperationScheduleEntity - may be null for jobs created prior to upgrading to RHQ 4.0
+ public static final String DATAMAP_INT_ENTITY_ID = "entityId";
/**
* For security purposes, we need to provide a subject with a valid login session. This creates such a subject by
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
index a1fc704..5d62695 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
@@ -203,13 +203,16 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
trigger.setJobName(jobDetail.getName());
trigger.setJobGroup(jobDetail.getGroup());
- // we need to create our own schedule tracking entity
+ // We need to create our own schedule tracking entity.
ResourceOperationScheduleEntity schedule;
schedule = new ResourceOperationScheduleEntity(jobDetail.getName(), jobDetail.getGroup(), trigger
.getStartTime(), resource);
entityManager.persist(schedule);
- // now actually schedule it
+ // Add the id of the entity bean, so we can easily map the Quartz job to the associated entity bean.
+ jobDataMap.put(ResourceOperationJob.DATAMAP_INT_ENTITY_ID, String.valueOf(schedule.getId()));
+
+ // Now actually schedule it.
Date next = scheduler.scheduleJob(jobDetail, trigger);
ResourceOperationSchedule newSchedule = getResourceOperationSchedule(subject, jobDetail);
@@ -283,6 +286,9 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
group);
entityManager.persist(schedule);
+ // Add the id of the entity bean, so we can easily map the Quartz job to the associated entity bean.
+ jobDataMap.put(ResourceOperationJob.DATAMAP_INT_ENTITY_ID, String.valueOf(schedule.getId()));
+
// now actually schedule it
Date next = scheduler.scheduleJob(jobDetail, trigger);
GroupOperationSchedule newSchedule = getGroupOperationSchedule(subject, jobDetail);
@@ -424,6 +430,8 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
public ResourceOperationSchedule getResourceOperationSchedule(Subject whoami, JobDetail jobDetail) {
JobDataMap jobDataMap = jobDetail.getJobDataMap();
+ String jobName = jobDetail.getName();
+ String jobGroup = jobDetail.getGroup();
String description = jobDetail.getDescription();
String operationName = jobDataMap.getString(ResourceOperationJob.DATAMAP_STRING_OPERATION_NAME);
String displayName = jobDataMap.getString(ResourceOperationJob.DATAMAP_STRING_OPERATION_DISPLAY_NAME);
@@ -438,6 +446,8 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
int resourceId = jobDataMap.getIntFromString(ResourceOperationJob.DATAMAP_INT_RESOURCE_ID);
Resource resource = getResourceIfAuthorized(whoami, resourceId);
+ Integer entityId = getOperationScheduleEntityId(jobDetail);
+
// note that we throw an exception if the subject does not exist!
// this is by design to avoid a malicious user creating a dummy subject in the database,
// scheduling a very bad operation, and deleting that subject thus removing all traces
@@ -445,8 +455,9 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
// will need to be deleted and rescheduled.
ResourceOperationSchedule sched = new ResourceOperationSchedule();
- sched.setJobName(jobDetail.getName());
- sched.setJobGroup(jobDetail.getGroup());
+ sched.setId(entityId);
+ sched.setJobName(jobName);
+ sched.setJobGroup(jobGroup);
sched.setResource(resource);
sched.setOperationName(operationName);
sched.setOperationDisplayName(displayName);
@@ -461,6 +472,25 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
return sched;
}
+ private int getOperationScheduleEntityId(JobDetail jobDetail) {
+ JobDataMap jobDataMap = jobDetail.getJobDataMap();
+ Object entityIdObj = jobDataMap.get(ResourceOperationJob.DATAMAP_INT_ENTITY_ID);
+ int entityId;
+ if (entityIdObj != null) {
+ // for jobs created using RHQ 4.0 or later, the map will contain an entityId entry
+ entityId = Integer.valueOf((String)entityIdObj);
+ } else {
+ // for jobs created prior to upgrading to RHQ 4.0, the map will not contain an entityId entry,
+ // so we'll need to lookup the entity id from the DB.
+ String jobName = jobDetail.getName();
+ String jobGroup = jobDetail.getGroup();
+ ScheduleJobId jobId = new ScheduleJobId(jobName, jobGroup);
+ OperationScheduleEntity operationScheduleEntity = findOperationScheduleEntity(jobId);
+ entityId = operationScheduleEntity.getId();
+ }
+ return entityId;
+ }
+
public ResourceOperationSchedule getResourceOperationSchedule(Subject subject, String jobId)
throws SchedulerException {
JobId jobIdObject = new JobId(jobId);
@@ -1430,7 +1460,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Subject overlord = subjectManager.getOverlord();
for (ResourceOperationScheduleComposite composite : results) {
try {
- ResourceOperationSchedule sched = getResourceOperationSchedule(subject, composite.getOperationJobId()
+ ResourceOperationSchedule sched = getResourceOperationSchedule(subject, composite.getJobId()
.toString());
OperationDefinition def = getSupportedResourceOperation(overlord, composite.getResourceId(), sched
.getOperationName(), false);
@@ -1484,7 +1514,7 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
Subject overlord = subjectManager.getOverlord();
for (GroupOperationScheduleComposite composite : results) {
try {
- GroupOperationSchedule sched = getGroupOperationSchedule(subject, composite.getOperationJobId()
+ GroupOperationSchedule sched = getGroupOperationSchedule(subject, composite.getJobId()
.toString());
OperationDefinition def = getSupportedGroupOperation(overlord, composite.getGroupId(), sched
.getOperationName(), false);
@@ -1765,7 +1795,13 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
*/
private OperationScheduleEntity findOperationScheduleEntity(ScheduleJobId jobId) {
OperationScheduleEntity entity = entityManager.find(OperationScheduleEntity.class, jobId);
- return entity;
+ Query query = entityManager.createNamedQuery(OperationScheduleEntity.QUERY_FIND_BY_JOB_ID);
+ String jobName = jobId.getJobName();
+ query.setParameter("jobName", jobName);
+ String jobGroup = jobId.getJobGroup();
+ query.setParameter("jobGroup", jobGroup);
+ OperationScheduleEntity operationScheduleEntity = (OperationScheduleEntity)query.getSingleResult();
+ return operationScheduleEntity;
}
public GroupOperationSchedule scheduleGroupOperation(Subject subject, int groupId, int[] executionOrderResourceIds,
13 years, 5 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ErrorMessageWindow.java | 78 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java | 13 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java | 47 +++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java | 26 ---
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 2
6 files changed, 140 insertions(+), 28 deletions(-)
New commits:
commit 1b25505eb944dd6fe0edb1706e1ff65b6a585461
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Dec 17 15:35:53 2010 -0500
exposing error messages
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ErrorMessageWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ErrorMessageWindow.java
new file mode 100644
index 0000000..bd90b9f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ErrorMessageWindow.java
@@ -0,0 +1,78 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+/**
+ * This is a convienence component that is a simple modal dialog box used to display
+ * things like error messages/stack traces.
+ *
+ * Call {@link #show()} on the instantiated window to display it.
+ *
+ * @author John Mazzitelli
+ */
+public class ErrorMessageWindow extends LocatableWindow {
+ public ErrorMessageWindow(String locatorId, String title, String message) {
+ super(locatorId);
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane(extendLocatorId("winDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultHeight(400);
+ htmlPane.setContents(message);
+
+ setupWindow(title, htmlPane);
+ }
+
+ public ErrorMessageWindow(String locatorId, String title, Canvas item) {
+ super(locatorId);
+ setupWindow(title, item);
+ }
+
+ private void setupWindow(String title, Canvas item) {
+ setTitle(title);
+ setShowMinimizeButton(false);
+ setShowMaximizeButton(true);
+ setIsModal(true);
+ setShowModalMask(true);
+ setAutoSize(true);
+ setAutoCenter(true);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+ addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ markForDestroy();
+ }
+ });
+ addItem(item);
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
index 5e94e47..917b13d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentDataSource.java
@@ -53,6 +53,7 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
public static final String FIELD_DEPLOY_DIR = "deployDir";
public static final String FIELD_DESCRIPTION = "description";
public static final String FIELD_DEPLOY_TIME = "deploymentTime";
+ public static final String FIELD_ERROR_MESSAGE = "errorMessage";
public static final String FIELD_CONFIG = "configuration";
public static final String FIELD_STATUS = "status";
public static final String FIELD_DEPLOYER = "deployer"; // a user name
@@ -153,6 +154,7 @@ public class BundleDeploymentDataSource extends RPCDataSource<BundleDeployment>
record.setAttribute(FIELD_NAME, from.getName());
record.setAttribute(FIELD_DEPLOY_DIR, from.getDestination().getDeployDir());
record.setAttribute(FIELD_DESCRIPTION, from.getDescription());
+ record.setAttribute(FIELD_ERROR_MESSAGE, from.getErrorMessage());
record.setAttribute(FIELD_DEPLOY_TIME, new Date(from.getCtime()));
record.setAttribute(FIELD_CONFIG, from.getConfiguration());
record.setAttribute(FIELD_STATUS, from.getStatus().name());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
index a0658b0..9cb3f58 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
@@ -33,10 +33,13 @@ import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundleVersionDataSource;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
@@ -105,6 +108,16 @@ public class BundleDeploymentListView extends Table<RPCDataSource<BundleDeployme
statusField.setValueIcons(statusIcons);
statusField.setValueIconWidth(11);
statusField.setValueIconHeight(11);
+ statusField.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ String err = event.getRecord().getAttribute(BundleDeploymentDataSource.FIELD_ERROR_MESSAGE);
+ if (err != null && err.length() > 0) {
+ err = "<pre>" + err + "</pre>";
+ new ErrorMessageWindow(extendLocatorId("errWin"), MSG.common_title_error(), err).show();
+ }
+ }
+ });
idField.setWidth(50);
nameField.setWidth("30%");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
index f64edda..97b60af 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
@@ -30,11 +30,14 @@ import java.util.HashSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.AnimationEffect;
import com.smartgwt.client.types.AutoFitWidthApproach;
+import com.smartgwt.client.types.DateDisplayFormat;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -58,6 +61,7 @@ import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
@@ -86,12 +90,21 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
private VLayout detail;
private boolean canManageBundles;
+ private final HashMap<String, String> statusIcons;
+
public BundleDeploymentView(String locatorId, boolean canManageBundles) {
super(locatorId);
this.canManageBundles = canManageBundles;
setWidth100();
setHeight100();
//setMargin(10); // do not set margin, we already have our margin set outside of us
+
+ statusIcons = new HashMap<String, String>();
+ statusIcons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
+ statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Error_11.png");
+ statusIcons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
+ statusIcons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
+ statusIcons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
}
private void viewBundleDeployment(BundleDeployment bundleDeployment, ViewId current) {
@@ -141,8 +154,33 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
bundleVersionName.setTarget("_self");
StaticTextItem deployed = new StaticTextItem("deployed", MSG.view_bundle_deployed());
+ deployed.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
deployed.setValue(new Date(deployment.getCtime()));
+ StaticTextItem deployedBy = new StaticTextItem("deployedBy", MSG.view_bundle_deploy_deployedBy());
+ deployedBy.setValue(deployment.getSubjectName());
+
+ StaticTextItem description = new StaticTextItem("description", MSG.common_title_description());
+ description.setValue(deployment.getDescription());
+
+ StaticTextItem status = new StaticTextItem("status", MSG.common_title_status());
+ status.setValue(deployment.getStatus().name());
+ status.setValueIcons(statusIcons);
+ status.setValueIconHeight(11);
+ status.setValueIconWidth(11);
+ status.setShowValueIconOnly(true);
+ if (deployment.getErrorMessage() != null) {
+ status.setTooltip(MSG.view_bundle_deploy_clickForError());
+ status.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ ErrorMessageWindow win = new ErrorMessageWindow(extendLocatorId("errWin"),
+ MSG.common_title_error(), "<pre>" + deployment.getErrorMessage() + "</pre>");
+ win.show();
+ }
+ });
+ }
+
LinkItem destinationGroup = new LinkItem("group");
destinationGroup.setTitle(MSG.common_title_resource_group());
destinationGroup.setValue(LinkManager.getResourceGroupLink(deployment.getDestination().getGroup().getId()));
@@ -152,7 +190,8 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
StaticTextItem path = new StaticTextItem("path", MSG.view_bundle_deployDir());
path.setValue(deployment.getDestination().getDeployDir());
- form.setFields(bundleName, bundleVersionName, deployed, destinationGroup, path);
+ form.setFields(bundleName, deployed, bundleVersionName, deployedBy, //
+ description, status, destinationGroup, path);
return form;
}
@@ -214,12 +253,6 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
// status icon field
ListGridField status = new ListGridField("status", MSG.common_title_status());
- HashMap<String, String> statusIcons = new HashMap<String, String>();
- statusIcons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
- statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Error_11.png");
- statusIcons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
- statusIcons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
- statusIcons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
status.setValueIcons(statusIcons);
status.setValueIconHeight(11);
status.setValueIconWidth(11);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
index 6093083..972e618 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
@@ -34,8 +34,6 @@ import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.events.DoubleClickEvent;
import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -51,10 +49,10 @@ import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
+import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* @author Greg Hinkle
@@ -170,24 +168,10 @@ public class BundleResourceDeploymentHistoryListView extends LocatableVLayout {
form.setItems(timestamp, action, category, user, status, info, message, detail);
form.editRecord(record);
- final Window window = new LocatableWindow(extendLocatorId("detailsWin"));
- window.setTitle(MSG.view_bundle_deploy_installDetails());
- window.setAutoSize(true);
- window.setWidth(500);
- window.setAutoCenter(true);
- window.setIsModal(true);
- window.setShowModalMask(true);
- window.setCanDragResize(true);
- window.addItem(form);
- window.setShowMinimizeButton(false);
- window.setShowMaximizeButton(true);
- window.addCloseClickHandler(new CloseClickHandler() {
- @Override
- public void onCloseClick(CloseClientEvent event) {
- window.destroy();
- }
- });
- window.show();
+ Window win = new ErrorMessageWindow(extendLocatorId("detailsWin"), MSG.view_bundle_deploy_installDetails(),
+ form);
+ win.setWidth(500);
+ win.show();
}
public ListGridRecord[] buildRecords() {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index b0ceaf9..0009db8 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -970,6 +970,8 @@ view_bundle_deploy_selectARow = Select a row to show installation details
view_bundle_deploy_operatingSystem = Operating System
view_bundle_deploy_loadFailure = Failed to load bundle deployment
view_bundle_deploy_loadBundleFailure = Failed to find bundle
+view_bundle_deploy_deployedBy = Deployed By
+view_bundle_deploy_clickForError = Click the icon for the error message
view_bundle_createWizard_title = Create Bundle
view_bundle_createWizard_windowTitle = Bundle Creation Wizard
view_bundle_createWizard_cancelSuccessful = Canceled the creation of bundle [{0}], version = [{1}]
13 years, 5 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java | 122 ++++++----
1 file changed, 84 insertions(+), 38 deletions(-)
New commits:
commit f65d0fc2c63453daf2af4eb21d7afdcc171b464a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Dec 17 14:08:52 2010 -0500
fix up the deployment details list, add more data like user and timestamp
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
index 9073dc9..6093083 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
@@ -23,17 +23,24 @@
package org.rhq.enterprise.gui.coregui.client.bundle.deployment;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.AutoFitWidthApproach;
+import com.smartgwt.client.types.DateDisplayFormat;
import com.smartgwt.client.types.ExpansionMode;
-import com.smartgwt.client.types.TitleOrientation;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.AutoFitTextAreaItem;
-import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
-import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -44,8 +51,10 @@ import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* @author Greg Hinkle
@@ -53,44 +62,60 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class BundleResourceDeploymentHistoryListView extends LocatableVLayout {
private BundleResourceDeployment resourceDeployment;
+ private HashMap<String, String> statusIcons;
public BundleResourceDeploymentHistoryListView(String locatorId, BundleResourceDeployment resourceDeployment) {
super(locatorId);
-
setWidth100();
setHeight100();
this.resourceDeployment = resourceDeployment;
+ statusIcons = new HashMap<String, String>();
+ statusIcons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
+ statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Error_11.png");
+ statusIcons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
+ statusIcons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
+ statusIcons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
}
@Override
protected void onInit() {
super.onInit();
- ListGrid grid = new LocatableListGrid(this.getLocatorId());
+ final ListGrid grid = new LocatableListGrid(this.getLocatorId());
grid.setWidth100();
grid.setHeight100();
+ grid.setSelectionType(SelectionStyle.SINGLE);
+ grid.setCanExpandRecords(true);
+ grid.setExpansionMode(ExpansionMode.DETAIL_FIELD);
+ grid.setDetailField("message");
ListGridField action = new ListGridField("action", MSG.view_bundle_deploy_action());
+ action.setAutoFitWidth(true);
+ action.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
+
ListGridField message = new ListGridField("info", MSG.common_title_info());
- ListGridField status = new ListGridField("status", MSG.common_title_status());
+ message.setWidth("60%");
- HashMap<String, String> icons = new HashMap<String, String>();
- icons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
- icons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Warning_11.png");
- icons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
- icons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
- icons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
- status.setValueIcons(icons);
- status.setValueIconHeight(11);
- status.setWidth(80);
+ ListGridField user = new ListGridField("user", MSG.common_title_user());
+ user.setHidden(true);
- grid.setCanExpandRecords(true);
- grid.setExpansionMode(ExpansionMode.DETAIL_FIELD);
- grid.setDetailField("message");
+ ListGridField timestamp = new ListGridField("timestamp", MSG.common_title_timestamp());
+ timestamp.setWidth("40%");
+
+ ListGridField status = new ListGridField("status", MSG.common_title_status());
+ status.setValueIcons(statusIcons);
+ status.setValueIconHeight(11);
+ status.setValueIconWidth(11);
+ status.setAutoFitWidth(true);
+ status.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
ListGridField details = new ListGridField("attachment", MSG.common_title_details());
details.setWidth(50);
+ details.setAlign(Alignment.CENTER);
+ details.setType(ListGridFieldType.ICON);
+ details.setIconHeight(11);
+ details.setIconWidth(11);
details.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
return "<img src=\"images/subsystems/bundle/Details_11.png\"/>";
@@ -102,47 +127,67 @@ public class BundleResourceDeploymentHistoryListView extends LocatableVLayout {
}
});
- grid.setFields(action, message, status, details);
+ grid.setFields(action, message, timestamp, status, user, details);
grid.setData(buildRecords());
- addMember(grid);
+ grid.addDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ showDetails(grid.getSelectedRecord());
+ }
+ });
+
+ addMember(grid);
}
private void showDetails(ListGridRecord record) {
+ DynamicForm form = new LocatableDynamicForm(extendLocatorId("detailsForm"));
+ form.setHeight100();
+ form.setWidth100();
+ form.setPadding(20);
+
+ StaticTextItem status = new StaticTextItem("status", MSG.common_title_status());
+ status.setValueIcons(statusIcons);
+ status.setValueIconHeight(11);
+ status.setValueIconWidth(11);
+ status.setShowValueIconOnly(true);
+
+ StaticTextItem user = new StaticTextItem("user", MSG.common_title_user());
- DynamicForm form = new DynamicForm();
+ StaticTextItem timestamp = new StaticTextItem("timestamp", MSG.common_title_timestamp());
+ timestamp.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
StaticTextItem action = new StaticTextItem("action", MSG.view_bundle_deploy_action());
StaticTextItem info = new StaticTextItem("info", MSG.common_title_info());
StaticTextItem category = new StaticTextItem("category", MSG.common_title_category());
- StaticTextItem message = new StaticTextItem("message", MSG.common_title_message());
-
- AutoFitTextAreaItem detail = new AutoFitTextAreaItem("attachement", MSG.common_title_details());
- detail.setTitleOrientation(TitleOrientation.TOP);
- detail.setColSpan(2);
- ButtonItem close = new ButtonItem("close", MSG.common_button_close());
+ StaticTextItem message = new StaticTextItem("message", MSG.common_title_message());
+ message.setTitleVAlign(VerticalAlignment.TOP);
- form.setItems(action, info, category, message, detail, close);
+ AutoFitTextAreaItem detail = new AutoFitTextAreaItem("attachment", MSG.common_title_details());
+ detail.setTitleVAlign(VerticalAlignment.TOP);
+ form.setItems(timestamp, action, category, user, status, info, message, detail);
form.editRecord(record);
- final Window window = new Window();
+ final Window window = new LocatableWindow(extendLocatorId("detailsWin"));
window.setTitle(MSG.view_bundle_deploy_installDetails());
- window.setWidth(800);
- window.setHeight(600);
+ window.setAutoSize(true);
+ window.setWidth(500);
+ window.setAutoCenter(true);
window.setIsModal(true);
window.setShowModalMask(true);
window.setCanDragResize(true);
- window.centerInPage();
window.addItem(form);
- window.show();
-
- close.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
+ window.setShowMinimizeButton(false);
+ window.setShowMaximizeButton(true);
+ window.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
window.destroy();
}
});
+ window.show();
}
public ListGridRecord[] buildRecords() {
@@ -161,10 +206,11 @@ public class BundleResourceDeploymentHistoryListView extends LocatableVLayout {
record.setAttribute("message", step.getMessage());
record.setAttribute("attachment", step.getAttachment());
record.setAttribute("status", step.getStatus().name());
+ record.setAttribute("timestamp", new Date(step.getAuditTime()));
+ record.setAttribute("user", step.getSubjectName());
records.add(record);
}
return records.toArray(new ListGridRecord[records.size()]);
-
}
}
13 years, 5 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java | 177 ++++------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java | 3
2 files changed, 90 insertions(+), 90 deletions(-)
New commits:
commit 0c02640cca3054b976af857ec585a46d07a5cc54
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Dec 17 12:35:41 2010 -0500
add authz check to see deployment info. clean up the ui a bit to make it have a consistent l&f like the other bundle views
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
index 0bb149c..f64edda 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
@@ -29,12 +29,14 @@ import java.util.HashSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.AnimationEffect;
+import com.smartgwt.client.types.AutoFitWidthApproach;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
@@ -49,6 +51,8 @@ import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleResourceDeploymentCriteria;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
@@ -80,12 +84,14 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
private Bundle bundle;
private VLayout detail;
+ private boolean canManageBundles;
- public BundleDeploymentView(String locatorId) {
+ public BundleDeploymentView(String locatorId, boolean canManageBundles) {
super(locatorId);
+ this.canManageBundles = canManageBundles;
setWidth100();
setHeight100();
- setMargin(10);
+ //setMargin(10); // do not set margin, we already have our margin set outside of us
}
private void viewBundleDeployment(BundleDeployment bundleDeployment, ViewId current) {
@@ -97,23 +103,62 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
this.bundle = bundleDeployment.getBundleVersion().getBundle();
addMember(new BackButton(extendLocatorId("BackButton"), MSG.view_bundle_deploy_backButton() + ": "
- + deployment.getDestination().getName(), "Bundles/Bundle/" + version.getBundle().getId() + "/destinations/"
- + deployment.getDestination().getId()));
-
+ + deployment.getDestination().getName(), LinkManager.getBundleDestinationLink(version.getBundle().getId(),
+ deployment.getDestination().getId())));
addMember(new HeaderLabel(Canvas.getImgURL("subsystems/bundle/BundleDeployment_24.png"), deployment.getName()));
+ addMember(createTagEditor());
+ addMember(createSummaryForm());
+ addMemberDeploymentsTable();
+ detail = new VLayout();
+ detail.setAutoHeight();
+ detail.hide();
+ addMember(detail);
+ }
+
+ private LocatableDynamicForm createSummaryForm() {
LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("Summary"));
+ form.setWidth100();
+ form.setAutoHeight();
form.setNumCols(4);
+ form.setWrapItemTitles(false);
+ form.setExtraSpace(10);
+ form.setIsGroup(true);
+ form.setGroupTitle(MSG.common_title_summary());
+ form.setPadding(5);
LinkItem bundleName = new LinkItem("bundle");
bundleName.setTitle(MSG.view_bundle_bundle());
- bundleName.setValue("#Bundles/Bundle/" + bundle.getId());
+ bundleName.setValue(LinkManager.getBundleLink(bundle.getId()));
bundleName.setLinkTitle(bundle.getName());
bundleName.setTarget("_self");
- CanvasItem tagItem = new CanvasItem("tag");
- tagItem.setShowTitle(false);
- TagEditorView tagEditor = new TagEditorView(form.getLocatorId(), version.getTags(), false,
+ LinkItem bundleVersionName = new LinkItem("bundleVersion");
+ bundleVersionName.setTitle(MSG.view_bundle_bundleVersion());
+ bundleVersionName.setValue(LinkManager.getBundleVersionLink(bundle.getId(), deployment.getBundleVersion()
+ .getId()));
+ bundleVersionName.setLinkTitle(deployment.getBundleVersion().getVersion());
+ bundleVersionName.setTarget("_self");
+
+ StaticTextItem deployed = new StaticTextItem("deployed", MSG.view_bundle_deployed());
+ deployed.setValue(new Date(deployment.getCtime()));
+
+ LinkItem destinationGroup = new LinkItem("group");
+ destinationGroup.setTitle(MSG.common_title_resource_group());
+ destinationGroup.setValue(LinkManager.getResourceGroupLink(deployment.getDestination().getGroup().getId()));
+ destinationGroup.setLinkTitle(deployment.getDestination().getGroup().getName());
+ destinationGroup.setTarget("_self");
+
+ StaticTextItem path = new StaticTextItem("path", MSG.view_bundle_deployDir());
+ path.setValue(deployment.getDestination().getDeployDir());
+
+ form.setFields(bundleName, bundleVersionName, deployed, destinationGroup, path);
+ return form;
+ }
+
+ private TagEditorView createTagEditor() {
+ boolean readOnly = !this.canManageBundles;
+ TagEditorView tagEditor = new TagEditorView(extendLocatorId("tagEditor"), version.getTags(), readOnly,
new TagsChangedCallback() {
public void tagsChanged(HashSet<Tag> tags) {
GWTServiceLookup.getTagService().updateBundleDeploymentTags(deployment.getId(), tags,
@@ -130,32 +175,9 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
});
}
});
- tagEditor.setVertical(true);
- tagItem.setCanvas(tagEditor);
- tagItem.setRowSpan(4);
-
- StaticTextItem deployed = new StaticTextItem("deployed", MSG.view_bundle_deployed());
- deployed.setValue(new Date(deployment.getCtime()));
-
- LinkItem destinationGroup = new LinkItem("group");
- destinationGroup.setTitle(MSG.common_title_resource_group());
- destinationGroup.setValue(LinkManager.getResourceGroupLink(deployment.getDestination().getGroup().getId()));
- destinationGroup.setLinkTitle(deployment.getDestination().getGroup().getName());
- destinationGroup.setTarget("_self");
-
- StaticTextItem path = new StaticTextItem("path", MSG.view_bundle_deployDir());
- path.setValue(deployment.getDestination().getDeployDir());
-
- form.setFields(bundleName, tagItem, deployed, destinationGroup, path);
-
- addMember(form);
-
- addMemberDeploymentsTable();
-
- detail = new VLayout();
- detail.setAutoHeight();
- detail.hide();
- addMember(detail);
+ tagEditor.setAutoHeight();
+ tagEditor.setExtraSpace(10);
+ return tagEditor;
}
private Table addMemberDeploymentsTable() {
@@ -163,20 +185,20 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
table.setTitleComponent(new HTMLFlow(MSG.view_bundle_deploy_selectARow()));
- ListGridField resourceIcon = new ListGridField("resourceAvailability", "");
+ // resource icon field
+ ListGridField resourceIcon = new ListGridField("resourceAvailability");
HashMap<String, String> icons = new HashMap<String, String>();
- icons.put("UP", ImageManager.getResourceIcon(ResourceCategory.PLATFORM, Boolean.TRUE));
- icons.put("DOWN", ImageManager.getResourceIcon(ResourceCategory.PLATFORM, Boolean.FALSE));
+ icons.put(AvailabilityType.UP.name(), ImageManager.getResourceIcon(ResourceCategory.PLATFORM, Boolean.TRUE));
+ icons.put(AvailabilityType.DOWN.name(), ImageManager.getResourceIcon(ResourceCategory.PLATFORM, Boolean.FALSE));
resourceIcon.setValueIcons(icons);
resourceIcon.setValueIconSize(16);
- resourceIcon.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- return "";
- }
- });
- resourceIcon.setWidth(30);
+ resourceIcon.setType(ListGridFieldType.ICON);
+ resourceIcon.setWidth(40);
+ // resource field
ListGridField resource = new ListGridField("resource", MSG.common_title_platform());
+ resource.setAutoFitWidth(true);
+ resource.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
resource.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
return "<a href=\"" + LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("resourceId"))
@@ -184,49 +206,55 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
}
});
+
+ // resource version field
ListGridField resourceVersion = new ListGridField("resourceVersion", MSG.view_bundle_deploy_operatingSystem());
+ resourceVersion.setAutoFitWidth(true);
+ resourceVersion.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
+
+ // status icon field
ListGridField status = new ListGridField("status", MSG.common_title_status());
HashMap<String, String> statusIcons = new HashMap<String, String>();
statusIcons.put(BundleDeploymentStatus.IN_PROGRESS.name(), "subsystems/bundle/install-loader.gif");
- statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Warning_11.png");
+ statusIcons.put(BundleDeploymentStatus.FAILURE.name(), "subsystems/bundle/Error_11.png");
statusIcons.put(BundleDeploymentStatus.MIXED.name(), "subsystems/bundle/Warning_11.png");
statusIcons.put(BundleDeploymentStatus.WARN.name(), "subsystems/bundle/Warning_11.png");
statusIcons.put(BundleDeploymentStatus.SUCCESS.name(), "subsystems/bundle/Ok_11.png");
status.setValueIcons(statusIcons);
status.setValueIconHeight(11);
- status.setWidth(80);
+ status.setValueIconWidth(11);
+ status.setWidth("*");
ArrayList<ListGridRecord> records = new ArrayList<ListGridRecord>();
for (BundleResourceDeployment rd : deployment.getResourceDeployments()) {
ListGridRecord record = new ListGridRecord();
- record.setAttribute("resource", rd.getResource().getName());
-
- record.setAttribute("resourceAvailability", rd.getResource().getCurrentAvailability().getAvailabilityType()
- .name());
- record.setAttribute("resourceId", rd.getResource().getId());
- record.setAttribute("resourceVersion", rd.getResource().getVersion());
+ Resource rr = rd.getResource();
+ record.setAttribute("resource", rr.getName());
+ record.setAttribute("resourceAvailability", rr.getCurrentAvailability().getAvailabilityType().name());
+ record.setAttribute("resourceId", rr.getId());
+ record.setAttribute("resourceVersion", rr.getVersion());
record.setAttribute("status", rd.getStatus().name());
record.setAttribute("id", rd.getId());
- record.setAttribute("entity", rd);
+ record.setAttribute("object", rd);
records.add(record);
}
// To get the ListGrid the Table must be initialized (via onInit()) by adding to the Canvas
table.setHeight("30%");
+ table.setWidth100();
table.setShowResizeBar(true);
table.setResizeBarTarget("next");
addMember(table);
- table.getListGrid().setFields(resourceIcon, resource, resourceVersion, status);
-
- table.getListGrid().setData(records.toArray(new ListGridRecord[records.size()]));
-
- table.getListGrid().addSelectionChangedHandler(new SelectionChangedHandler() {
+ ListGrid listGrid = table.getListGrid();
+ listGrid.setFields(resourceIcon, resource, resourceVersion, status);
+ listGrid.setData(records.toArray(new ListGridRecord[records.size()]));
+ listGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent selectionEvent) {
if (selectionEvent.getState()) {
BundleResourceDeployment bundleResourceDeployment = (BundleResourceDeployment) selectionEvent
- .getRecord().getAttributeAsObject("entity");
+ .getRecord().getAttributeAsObject("object");
BundleResourceDeploymentHistoryListView detailView = new BundleResourceDeploymentHistoryListView(
"Detail", bundleResourceDeployment);
@@ -234,24 +262,6 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
detail.addMember(detailView);
detail.setHeight("50%");
detail.animateShow(AnimationEffect.SLIDE);
-
- /*
- BundleResourceDeploymentCriteria criteria = new BundleResourceDeploymentCriteria();
- criteria.addFilterId(selectionEvent.getRecord().getAttributeAsInt("id"));
- criteria.fetchHistories(true);
- criteria.fetchResource(true);
- criteria.fetchBundleDeployment(true);
- bundleService.findBundleResourceDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleResourceDeployment>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load resource deployment history details",caught);
- }
-
- public void onSuccess(PageList<BundleResourceDeployment> result) {
-
- }
- });
- */
-
} else {
detail.animateHide(AnimationEffect.SLIDE);
}
@@ -264,8 +274,6 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
public void renderView(final ViewPath viewPath) {
int bundleDeploymentId = Integer.parseInt(viewPath.getCurrent().getPath());
- final ViewId viewId = viewPath.getCurrent();
-
BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
criteria.addFilterId(bundleDeploymentId);
criteria.fetchBundleVersion(true);
@@ -281,9 +289,7 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
}
public void onSuccess(PageList<BundleDeployment> result) {
-
final BundleDeployment deployment = result.get(0);
-
BundleCriteria bundleCriteria = new BundleCriteria();
bundleCriteria.addFilterId(deployment.getBundleVersion().getBundle().getId());
bundleService.findBundlesByCriteria(bundleCriteria, new AsyncCallback<PageList<Bundle>>() {
@@ -292,11 +298,8 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
}
public void onSuccess(PageList<Bundle> result) {
-
final Bundle bundle = result.get(0);
-
deployment.getBundleVersion().setBundle(bundle);
-
BundleResourceDeploymentCriteria criteria = new BundleResourceDeploymentCriteria();
criteria.addFilterBundleDeploymentId(deployment.getId());
criteria.fetchHistories(true);
@@ -304,7 +307,6 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
criteria.fetchBundleDeployment(true);
bundleService.findBundleResourceDeploymentsByCriteria(criteria,
new AsyncCallback<PageList<BundleResourceDeployment>>() {
-
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deploy_loadFailure(), caught);
}
@@ -314,13 +316,10 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab
viewBundleDeployment(deployment, viewPath.getCurrent());
}
});
-
}
});
-
}
});
-
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
index 15ebed4..1c9dc47 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java
@@ -316,7 +316,8 @@ public class BundleView extends LocatableVLayout implements BookmarkableView {
} else {
// a specific deployment
//removeMembers(getMembers());
- BundleDeploymentView view = new BundleDeploymentView(extendLocatorId("Deployment"));
+ BundleDeploymentView view = new BundleDeploymentView(extendLocatorId("Deployment"),
+ canManageBundles);
addMember(view);
view.renderView(viewPath.next());
}
13 years, 5 months
[rhq] Branch 'release-3.0.0' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java | 17 ++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 8 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java | 19 ++++++++--
3 files changed, 41 insertions(+), 3 deletions(-)
New commits:
commit e45ddc85ee546040b3d8b6b9ff3a671149d2a898
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Sep 28 17:15:48 2010 -0400
[BZ 619781] Handling more scenarios for settting connection properties to default values
Adding logic to handle three additional scenarios each of which involves
connection properties that are required and specify a default value:
1) A new property is added to a new group
2) An existing property not part of a group added to an existing group
3) A property previously in a group moved outside of a group
There were also some scenarios when properties were moved into or out of a group
and the group reference was not getting set or unset.
ConfigurationMetadataManagerBean has been modifed to update these references.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java
index ad0c84b..ecad316 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationDefinitionUpdateReport.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.server.configuration.metadata;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import java.util.HashSet;
import java.util.Set;
@@ -35,6 +36,8 @@ public class ConfigurationDefinitionUpdateReport {
private Set<PropertyDefinition> newPropertyDefs = new HashSet<PropertyDefinition>();
+ private Set<PropertyDefinition> updatedPropertyDefs = new HashSet<PropertyDefinition>();
+
public ConfigurationDefinitionUpdateReport(ConfigurationDefinition configurationDefinition) {
configurationDef = configurationDefinition;
}
@@ -44,11 +47,23 @@ public class ConfigurationDefinitionUpdateReport {
}
public void addNewPropertyDefinition(PropertyDefinition propertyDef) {
- newPropertyDefs.add(propertyDef);
+ if (propertyDef instanceof PropertyDefinitionSimple) {
+ newPropertyDefs.add(propertyDef);
+ }
}
public Set<PropertyDefinition> getNewPropertyDefinitions() {
return newPropertyDefs;
}
+ public void addUpdatedPropertyDefinition(PropertyDefinition propertyDef) {
+ if (propertyDef instanceof PropertyDefinitionSimple) {
+ updatedPropertyDefs.add(propertyDef);
+ }
+ }
+
+ public Set<PropertyDefinition> getUpdatedPropertyDefinitions() {
+ return updatedPropertyDefs;
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 8427c8b..04a3995 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -74,6 +74,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
PropertyDefinition existingProp = existingDefinition.get(newProperty.getName());
if (existingProp != null) {
updatePropertyDefinition(existingProp, newProperty);
+ updateReport.addUpdatedPropertyDefinition(newProperty);
} else {
existingDefinition.put(newProperty);
updateReport.addNewPropertyDefinition(newProperty);
@@ -130,6 +131,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
PropertyDefinition existingProperty = existingDefinition.getPropertyDefinitions().get(nDef.getName());
if (existingProperty != null) {
updatePropertyDefinition(existingProperty, nDef);
+ updateReport.addUpdatedPropertyDefinition(nDef);
} else {
existingDefinition.put(nDef);
updateReport.addNewPropertyDefinition(nDef);
@@ -157,6 +159,11 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
entityManager.persist(def);
def.setPropertyGroupDefinition(group);
def.setConfigurationDefinition(existingDefinition);
+
+ if (!exPDefs.containsKey(def.getName())) {
+ updateReport.addNewPropertyDefinition(def);
+ }
+
exPDefs.put(def.getName(), def);
}
}
@@ -309,6 +316,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
existingProperty.setRequired(newProperty.isRequired());
existingProperty.setReadOnly(newProperty.isReadOnly());
existingProperty.setSummary(newProperty.isSummary());
+ existingProperty.setPropertyGroupDefinition(newProperty.getPropertyGroupDefinition());
/*
* After the general things have been set, go through the subtypes of PropertyDefinition. If the new type is the
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
index 64e9afd..53048c9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
@@ -944,7 +944,8 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
.updateConfigurationDefinition(resourceType.getPluginConfigurationDefinition(),
existingConfigurationDefinition);
- if (updateReport.getNewPropertyDefinitions().size() > 0) {
+ if (updateReport.getNewPropertyDefinitions().size() > 0 ||
+ updateReport.getUpdatedPropertyDefinitions().size() > 0) {
Subject overlord = subjectManager.getOverlord();
ResourceCriteria criteria = new ResourceCriteria();
criteria.addFilterResourceTypeId(existingType.getId());
@@ -966,6 +967,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
private void updateResourcePluginConfiguration(Resource resource, ConfigurationDefinitionUpdateReport updateReport) {
Configuration pluginConfiguration = resource.getPluginConfiguration();
+ boolean modified = false;
int numberOfProperties = pluginConfiguration.getProperties().size();
ConfigurationTemplate template = updateReport.getConfigurationDefinition().getDefaultTemplate();
Configuration templateConfiguration = template.getConfiguration();
@@ -974,10 +976,23 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
if (propertyDef.isRequired()) {
Property templateProperty = templateConfiguration.get(propertyDef.getName());
pluginConfiguration.put(templateProperty.deepCopy(false));
+ modified = true;
}
}
- if (pluginConfiguration.getProperties().size() > numberOfProperties) {
+ for (PropertyDefinition propertyDef : updateReport.getUpdatedPropertyDefinitions()) {
+ if (propertyDef.isRequired()) {
+ String propertyValue = pluginConfiguration.getSimpleValue(propertyDef.getName(), null);
+ if (propertyValue == null) {
+ Property templateProperty = templateConfiguration.get(propertyDef.getName());
+ pluginConfiguration.put(templateProperty.deepCopy(false));
+ modified = true;
+ }
+ }
+ }
+
+// if (pluginConfiguration.getProperties().size() > numberOfProperties) {
+ if (modified) {
resource.setMtime(new Date().getTime());
}
}
13 years, 5 months