[rhq] .classpath
by mazz
.classpath | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit 2652ac657bd0f7527d231bbfb7d464d1cd6ab3ce
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 21 14:13:40 2012 -0400
add oracle and snmptrapd plugin test modules to eclipse classpath
diff --git a/.classpath b/.classpath
index 9362891..443abde 100644
--- a/.classpath
+++ b/.classpath
@@ -106,6 +106,7 @@
<classpathentry kind="src" path="modules/plugins/postgres/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/mysql/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/oracle/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/oracle/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/apache/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/apache/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/script/src/main/java"/>
@@ -115,6 +116,7 @@
<classpathentry kind="src" path="modules/plugins/filetemplate-bundle/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/filetemplate-bundle/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/snmptrapd/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/snmptrapd/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/byteman/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/iis/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/sshd/src/main/java"/>
11 years, 11 months
[rhq] Branch 'searchbar' - 2 commits - .classpath modules/enterprise
by Jay Shaughnessy
.classpath | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java | 204 ++++------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java | 81 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java | 16
5 files changed, 153 insertions(+), 161 deletions(-)
New commits:
commit 46060c5ceb4b90f87ba735ae59fc2863da6ffa33
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Jun 21 12:57:04 2012 -0400
Add FocusHandler in an attempt to get the picklist to display on first
click. This didn't work, what we really need is a keypress. But simulating
a KeyPressEvent didn't work in my initial attempt.
The FocusHandler replaced the need for the initialize logic. We can add
that back in if we need it later.
Removed the unnecessary getSearchSuggestions().
Turned off autoFetch, we fetch manually.
diff --git a/.classpath b/.classpath
index 76e080c..48c3a33 100644
--- a/.classpath
+++ b/.classpath
@@ -241,7 +241,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/jbossws/jbossws-native-core/3.1.1.GA/jbossws-native-core-3.1.1.GA.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/maven/maven-project/2.0.8/maven-project-2.0.8.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/maven/maven-plugin-api/2.0.8/maven-plugin-api-2.0.8.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/codehaus/swizzle/1.6.1/swizzle-confluence-1.6.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/codehaus/swizzle/swizzle-confluence/1.6.1/swizzle-confluence-1.6.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jvnet/inflector/0.7.0/inflector-0.7.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/net/augeas/augeas/0.0.2/augeas-0.0.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/json/json/20080701/json-20080701.jar"/>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
index 4718fd1..bfd0bd7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
@@ -18,9 +18,11 @@
*/
package org.rhq.enterprise.gui.coregui.client.searchbar;
+import com.smartgwt.client.widgets.form.fields.events.FocusEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
@@ -56,9 +58,6 @@ public abstract class AbstractSearchStrategy implements RecordClickHandler, Cel
subject = UserSessionManager.getSessionSubject();
}
-
- public abstract void initialize();
-
/**
* Handle the key press event in the search bar. Must be overridden in subclass.
* @param keyUpEvent
@@ -66,6 +65,12 @@ public abstract class AbstractSearchStrategy implements RecordClickHandler, Cel
public abstract void searchKeyUpHandler(KeyUpEvent keyUpEvent);
/**
+ * Handle the focus event in the search bar. Must be overridden in subclass.
+ * @param focusEvent
+ */
+ public abstract void searchFocusHandler(FocusEvent focusEvent);
+
+ /**
* Search results can have different heights (i.e. 1 row or 2 rows). Must be overridden
* in subclass.
* @return height in pixels
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
index 787144e..1e61737 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
@@ -24,6 +24,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
+import com.smartgwt.client.widgets.form.fields.events.FocusEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
@@ -97,7 +98,7 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
String clickedExpression = event.getRecord().getAttribute(ATTR_NAME);
searchBar.getSearchComboboxItem().setValue(clickedExpression);
if (null != clickedExpression && clickedExpression.length() > 0) {
- getSearchSuggestions(SearchSubsystem.RESOURCE, clickedExpression, clickedExpression.length());
+ getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE, clickedExpression, clickedExpression.length());
}
}
}
@@ -132,6 +133,19 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
}
@Override
+ public void searchFocusHandler(FocusEvent event) {
+ Log.debug("focus in BasicSearchStrategy");
+ String searchExpression = searchBar.getSearchComboboxItem().getValueAsString();
+ if (null != searchExpression && searchExpression.length() > 0) {
+ getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE,
+ searchBar.getSearchComboboxItem().getValueAsString(), searchBar.getSearchComboboxItem()
+ .getValueAsString().length());
+ } else {
+ getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
+ }
+ }
+
+ @Override
public void searchKeyUpHandler(KeyUpEvent keyUpEvent) {
Log.debug("Keyup in BasicSearchStrategy: " + keyUpEvent.getKeyName());
String searchExpression = searchBar.getSearchComboboxItem().getValueAsString();
@@ -140,7 +154,7 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
searchBar.getSearchComboboxItem().getValueAsString(), searchBar.getSearchComboboxItem()
.getValueAsString().length());
} else {
- getSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
+ getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
}
}
@@ -165,7 +179,6 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
public void onSuccess(List<SearchSuggestion> results) {
ComboBoxItem comboBox = searchBar.getSearchComboboxItem();
DataSource ds = comboBox.getOptionDataSource();
- boolean dofetch = false;
if (null == ds) {
ds = new DataSource();
@@ -181,7 +194,6 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
} else {
ds.invalidateCache();
- dofetch = true;
}
for (SearchSuggestion searchSuggestion : results) {
@@ -197,65 +209,10 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
ds.addData(record);
}
- if (dofetch) {
- comboBox.fetchData();
- }
-
- long suggestFetchTime = System.currentTimeMillis() - suggestStart;
- Log.debug(results.size() + " suggestions searches fetched in: " + suggestFetchTime + "ms");
- }
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to retrieve search suggestion", caught);
- }
-
- });
- }
-
- public void getSearchSuggestions(SearchSubsystem searchSubsystem, String expression, int caretPosition) {
-
- final long suggestStart = System.currentTimeMillis();
-
- searchService.getTabAwareSuggestions(searchSubsystem, expression, caretPosition, null,
- new AsyncCallback<List<SearchSuggestion>>() {
-
- public void onSuccess(List<SearchSuggestion> results) {
- ComboBoxItem comboBox = searchBar.getSearchComboboxItem();
- DataSource ds = comboBox.getOptionDataSource();
- boolean newDs = false;
-
- if (null == ds) {
- ds = new DataSource();
- ds.setClientOnly(true);
- DataSourceTextField idField = new DataSourceTextField(ATTR_ID, "Id");
- idField.setPrimaryKey(true);
- DataSourceTextField valueField = new DataSourceTextField(ATTR_VALUE, "Value");
- DataSourceTextField kindField = new DataSourceTextField(ATTR_KIND, "Kind");
- DataSourceTextField nameField = new DataSourceTextField(ATTR_NAME, "Name");
- ds.setFields(valueField, kindField, nameField);
-
- comboBox.setOptionDataSource(ds);
- newDs = true;
-
- } else {
- ds.invalidateCache();
- }
-
- for (SearchSuggestion searchSuggestion : results) {
- Log.debug("search Suggestions: " + searchSuggestion.getKind() + ", "
- + searchSuggestion.getValue() + ", " + searchSuggestion.getLabel());
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(ATTR_ID, searchSuggestion.getValue());
- if (null != searchSuggestion.getKind()) {
- record.setAttribute(ATTR_KIND, searchSuggestion.getKind().getDisplayName());
- }
- record.setAttribute(ATTR_NAME, searchSuggestion.getLabel());
- record.setAttribute(ATTR_VALUE, searchSuggestion.getValue());
- ds.addData(record);
- }
-
- if (!newDs) {
+ try {
comboBox.fetchData();
+ } catch (Exception e) {
+ Log.debug("Caught exception on fetchData: " + e);
}
long suggestFetchTime = System.currentTimeMillis() - suggestStart;
@@ -269,9 +226,4 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
});
}
- @Override
- public void initialize() {
- getSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
- }
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
index 7f33531..b4852d6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
@@ -18,17 +18,22 @@
*/
package org.rhq.enterprise.gui.coregui.client.searchbar;
+import java.util.EnumMap;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.TextMatchStyle;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.FocusEvent;
+import com.smartgwt.client.widgets.form.fields.events.FocusHandler;
import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyUpHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import com.smartgwt.client.widgets.toolbar.ToolStripButton;
+
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.search.SearchSubsystem;
@@ -41,8 +46,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.SearchGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.EnumMap;
-
/**
* The class defines the UI component of the search bar.
* Behavior related to the retrieving/saving of searches is delegated to the Search Strategies.
@@ -54,7 +57,7 @@ import java.util.EnumMap;
* @author Mike Thompson
*/
public class EnhancedSearchBar extends ToolStrip {
- private static final Messages MSG = CoreGUI.getMessages();
+ private static final Messages MSG = CoreGUI.getMessages();
private SearchSubsystem searchSubsystem;
private Integer currentSearchId = 0;
private ToolStripButton saveSearchButton;
@@ -64,27 +67,29 @@ public class EnhancedSearchBar extends ToolStrip {
private final FavoritesSearchStrategy favoritesSearchStrategy;
private final BasicSearchStrategy basicSearchStrategy;
- private final SearchGWTServiceAsync searchService = GWTServiceLookup.getSearchService();
+ private final SearchGWTServiceAsync searchService = GWTServiceLookup.getSearchService();
+
+ enum SearchMode {
+ BASIC_SEARCH_MODE, SAVED_SEARCH_MODE
+ }
- enum SearchMode {BASIC_SEARCH_MODE, SAVED_SEARCH_MODE}
private SearchMode searchMode = SearchMode.BASIC_SEARCH_MODE;
/**
* The enumMap will act as a simple state machine defining the mappings of search strategy behavior and
* eliminating any if logic.
*/
- private EnumMap<SearchMode,AbstractSearchStrategy> searchStrategies = new EnumMap<SearchMode, AbstractSearchStrategy>(SearchMode.class);
-
-
+ private EnumMap<SearchMode, AbstractSearchStrategy> searchStrategies = new EnumMap<SearchMode, AbstractSearchStrategy>(
+ SearchMode.class);
public EnhancedSearchBar(SearchSubsystem searchSubsystem) {
this(searchSubsystem, null);
}
public EnhancedSearchBar(SearchSubsystem searchSubsystem, String initialSearchText) {
- if(null == searchSubsystem){
+ if (null == searchSubsystem) {
this.searchSubsystem = SearchSubsystem.RESOURCE; // default to resource
- }else {
+ } else {
this.searchSubsystem = searchSubsystem;
}
setAutoHeight();
@@ -96,13 +101,13 @@ public class EnhancedSearchBar extends ToolStrip {
favoritesSearchStrategy = new FavoritesSearchStrategy(this);
basicSearchStrategy = new BasicSearchStrategy(this);
// now we can fill our enumMap
- searchStrategies.put(SearchMode.BASIC_SEARCH_MODE, basicSearchStrategy );
- searchStrategies.put(SearchMode.SAVED_SEARCH_MODE, favoritesSearchStrategy );
-
+ searchStrategies.put(SearchMode.BASIC_SEARCH_MODE, basicSearchStrategy);
+ searchStrategies.put(SearchMode.SAVED_SEARCH_MODE, favoritesSearchStrategy);
searchComboboxItem.setWidth(670);
searchComboboxItem.setBrowserSpellCheck(false);
- searchComboboxItem.setAutoFetchData(true);
+ //we manually fetch each time we update the picklist values
+ searchComboboxItem.setAutoFetchData(false);
searchComboboxItem.setFetchDelay(300);
searchComboboxItem.setCompleteOnTab(true);
@@ -117,7 +122,7 @@ public class EnhancedSearchBar extends ToolStrip {
searchComboboxItem.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent keyUpEvent) {
- Log.debug("onKeyUp search Mode: "+ searchMode);
+ Log.debug("onKeyUp search Mode: " + searchMode);
getSearchStrategy().searchKeyUpHandler(keyUpEvent);
if (keyUpEvent.getKeyName().equals("Enter")) {
@@ -127,6 +132,15 @@ public class EnhancedSearchBar extends ToolStrip {
}
});
+ searchComboboxItem.addFocusHandler(new FocusHandler() {
+ @Override
+ public void onFocus(FocusEvent event) {
+ Log.debug("onFocus search Mode: " + searchMode);
+
+ getSearchStrategy().searchFocusHandler(event);
+ }
+ });
+
searchComboboxItem.setPickListProperties(pickListGrid);
addFormItem(searchComboboxItem);
@@ -158,18 +172,14 @@ public class EnhancedSearchBar extends ToolStrip {
// set the default search provider
switchToBasicSearchMode();
- // do any initialization
- getSearchStrategy().initialize();
-
this.draw();
}
-
- private void saveFavoriteSearch(){
- Log.debug("Saving Favorite Search: "+saveSearchTextItem.getValueAsString());
- createSavedSearch(saveSearchTextItem.getValueAsString(), searchComboboxItem.getValueAsString());
- toggleFavoriteSearch();
- }
+ private void saveFavoriteSearch() {
+ Log.debug("Saving Favorite Search: " + saveSearchTextItem.getValueAsString());
+ createSavedSearch(saveSearchTextItem.getValueAsString(), searchComboboxItem.getValueAsString());
+ toggleFavoriteSearch();
+ }
public SearchMode getSearchMode() {
return searchMode;
@@ -179,30 +189,29 @@ public class EnhancedSearchBar extends ToolStrip {
this.searchMode = searchMode;
}
-
/**
* This is the one method where the searchMode state is allowed to change.
*/
- public void toggleFavoriteSearch(){
- if(getSearchMode().equals(SearchMode.SAVED_SEARCH_MODE)){
+ public void toggleFavoriteSearch() {
+ if (getSearchMode().equals(SearchMode.SAVED_SEARCH_MODE)) {
switchToBasicSearchMode();
- }else {
+ } else {
switchToSavedSearchMode();
}
- Log.debug("toggleFavorites searchMode set to: "+searchMode);
+ Log.debug("toggleFavorites searchMode set to: " + searchMode);
configureCommonHandlers();
}
- public void switchToBasicSearchMode(){
+ public void switchToBasicSearchMode() {
setSearchMode(SearchMode.BASIC_SEARCH_MODE);
saveSearchButton.setIcon(IconEnum.STAR_OFF.getIcon16x16Path());
saveSearchTextItem.hide();
configureCommonHandlers();
}
- public void switchToSavedSearchMode(){
+ public void switchToSavedSearchMode() {
setSearchMode(SearchMode.SAVED_SEARCH_MODE);
saveSearchButton.setIcon(IconEnum.STAR_ON.getIcon16x16Path());
saveSearchTextItem.show();
@@ -219,12 +228,10 @@ public class EnhancedSearchBar extends ToolStrip {
pickListGrid.redraw();
}
-
- public String getValue(){
+ public String getValue() {
return searchComboboxItem.getValueAsString();
}
-
private void createSavedSearch(final String name, final String pattern) {
Subject subject = UserSessionManager.getSessionSubject();
SavedSearch newSavedSearch = new SavedSearch(searchSubsystem, name, pattern, subject);
@@ -232,24 +239,22 @@ public class EnhancedSearchBar extends ToolStrip {
@Override
public void onSuccess(Integer newSavedSearchId) {
currentSearchId = newSavedSearchId;
- Message message = new Message("Successfully Saved Search: "+ name, Message.Severity.Info);
+ Message message = new Message("Successfully Saved Search: " + name, Message.Severity.Info);
CoreGUI.getMessageCenter().notify(message);
}
@Override
public void onFailure(Throwable caught) {
- Message message = new Message("Failure to Save Search "+name, Message.Severity.Error);
+ Message message = new Message("Failure to Save Search " + name, Message.Severity.Error);
CoreGUI.getMessageCenter().notify(message);
}
});
}
-
public AbstractSearchStrategy getSearchStrategy() {
return searchStrategies.get(searchMode);
}
-
public ComboBoxItem getSearchComboboxItem() {
return searchComboboxItem;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
index 2386785..a04a000 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
@@ -18,13 +18,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.searchbar;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.form.fields.events.FocusEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
@@ -32,8 +36,6 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.util.Log;
-import java.util.List;
-
/**
* Search Strategy for the Favorite Saved Searches.
* If you wish to save your searches for later use this search strategy
@@ -89,6 +91,11 @@ public class FavoritesSearchStrategy extends AbstractSearchStrategy {
}
+ @Override
+ public void searchFocusHandler(FocusEvent focusEvent) {
+ // nothing currently
+ }
+
private void populateSearchComboboxSavedSearchesWithAutoComplete(){
SavedSearchCriteria savedSearchCriteria = new SavedSearchCriteria();
@@ -146,9 +153,4 @@ public class FavoritesSearchStrategy extends AbstractSearchStrategy {
// do nothing
Log.debug("return key in SavedSearchProvider");
}
-
- @Override
- public void initialize() {
-
- }
}
commit 6c382afd675216b53ab170d61cfd4819313ac224
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Jun 21 11:03:54 2012 -0400
Hopefully a solution to the suggestion list refresh issue. In short the
change is two-fold. First, don't create a new DataSource for every
change. Just work with one and call invalidateCache when the values
need to be updated. Second, call fetchData() after the values are updated
to force the newly set DS data to be sucked into the picklist.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
index 9300f3f..787144e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.searchbar;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;
@@ -25,6 +27,7 @@ import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+
import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.search.SearchSubsystem;
@@ -34,8 +37,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import java.util.List;
-
/**
* This is the general search strategy implementation used for most searches.
* These strategy classes operate by providing the standard functionality
@@ -46,7 +47,7 @@ import java.util.List;
*/
public class BasicSearchStrategy extends AbstractSearchStrategy {
- public BasicSearchStrategy(EnhancedSearchBar searchBar){
+ public BasicSearchStrategy(EnhancedSearchBar searchBar) {
super(searchBar);
}
@@ -61,12 +62,12 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
String style = "font-variant: small-caps; font-weight: bold; font-size: 11px; float: left; margin-left: 2px; width: 50px;";
StringBuilder sb = new StringBuilder();
sb.append("<div style='height:30px;width:400px;float:left;white-space:nowrap;overflow:hidden;' >");
- String color = (kind.equals(SearchSuggestion.Kind.GlobalSavedSearch.getDisplayName() )
- || kind.equals(SearchSuggestion.Kind.UserSavedSearch.getDisplayName()) ) ? "color:green;" : "color:grey";
- sb.append("<span style='"+style+color+"' >");
+ String color = (kind.equals(SearchSuggestion.Kind.GlobalSavedSearch.getDisplayName()) || kind
+ .equals(SearchSuggestion.Kind.UserSavedSearch.getDisplayName())) ? "color:green;" : "color:grey";
+ sb.append("<span style='" + style + color + "' >");
sb.append(kind);
sb.append("</span>");
- sb.append("<span style='"+style+"' >");
+ sb.append("<span style='" + style + "' >");
sb.append(name);
sb.append("</span>");
sb.append("</div>");
@@ -74,7 +75,6 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
return sb.toString();
}
-
/**
* Executed when this field is clicked on. Note that if {@link
* com.smartgwt.client.widgets.grid.ListGrid#addRecordClickHandler ListGrid.recordClick} is also defined, it will be fired
@@ -87,24 +87,17 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
public void onRecordClick(RecordClickEvent event) {
Log.debug("BasicSearchStrategy click");
String kind = event.getRecord().getAttribute(ATTR_KIND);
- if(kind.equals("SAVED") || kind.equals("GLOBAL")){
+ if (kind.equals("SAVED") || kind.equals("GLOBAL")) {
searchBar.switchToSavedSearchMode();
String savedSearchName = event.getRecord().getAttribute(ATTR_VALUE);
searchBar.getSaveSearchTextItem().setValue(savedSearchName);
- assignSavedSearchExpression(savedSearchName, searchBar.getSearchComboboxItem());
- }else {
+ assignSavedSearchExpression(savedSearchName, searchBar.getSearchComboboxItem());
+ } else {
String clickedExpression = event.getRecord().getAttribute(ATTR_NAME);
searchBar.getSearchComboboxItem().setValue(clickedExpression);
- if(null != clickedExpression && clickedExpression.length() > 0){
+ if (null != clickedExpression && clickedExpression.length() > 0) {
getSearchSuggestions(SearchSubsystem.RESOURCE, clickedExpression, clickedExpression.length());
- /////////////////////////////////////////////////////
- // PROBLEM: cant refresh the pickList grid dynamically
- // click the down arrow button on combobox
- /////////////////////////////////////////////////////
- //@todo: how refresh the pickList properties grid now to reflect new search
- //searchComboBox.focusInItem();
-
}
}
}
@@ -116,35 +109,37 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
criteria.setStrict(true);
GWTServiceLookup.getSearchService().findSavedSearchesByCriteria(criteria,
- new AsyncCallback<List<SavedSearch>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_searchBar_savedSearch_failFind(savedSearchName),
- caught);
- }
+ new AsyncCallback<List<SavedSearch>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_searchBar_savedSearch_failFind(savedSearchName),
+ caught);
+ }
- @Override
- public void onSuccess(List<SavedSearch> results) {
- if (results.size() == 0) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_searchBar_savedSearch_failFind(savedSearchName), Message.Severity.Error));
- } else {
- SavedSearch savedSearch = results.get(0);
- searchComboBoxItem.setValue(savedSearch.getPattern());
- }
+ @Override
+ public void onSuccess(List<SavedSearch> results) {
+ if (results.size() == 0) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_searchBar_savedSearch_failFind(savedSearchName),
+ Message.Severity.Error));
+ } else {
+ SavedSearch savedSearch = results.get(0);
+ searchComboBoxItem.setValue(savedSearch.getPattern());
}
- });
+ }
+ });
}
@Override
public void searchKeyUpHandler(KeyUpEvent keyUpEvent) {
- Log.debug("Keyup in BasicSearchStrategy: "+keyUpEvent.getKeyName());
+ Log.debug("Keyup in BasicSearchStrategy: " + keyUpEvent.getKeyName());
String searchExpression = searchBar.getSearchComboboxItem().getValueAsString();
- if(null != searchExpression && searchExpression.length() > 0){
- getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE, searchBar.getSearchComboboxItem().getValueAsString(),
- searchBar.getSearchComboboxItem().getValueAsString().length());
- }else {
+ if (null != searchExpression && searchExpression.length() > 0) {
+ getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE,
+ searchBar.getSearchComboboxItem().getValueAsString(), searchBar.getSearchComboboxItem()
+ .getValueAsString().length());
+ } else {
getSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
}
@@ -164,86 +159,119 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
final long suggestStart = System.currentTimeMillis();
- searchService.getTabAwareSuggestions(searchSubsystem, expression,
- caretPosition, null, new AsyncCallback<List<SearchSuggestion>>() {
-
- public void onSuccess(List<SearchSuggestion> results) {
- DataSource ds = new DataSource();
- ds.setClientOnly(true);
- DataSourceTextField idField = new DataSourceTextField(ATTR_ID, "Id");
- idField.setPrimaryKey(true);
- DataSourceTextField valueField = new DataSourceTextField(ATTR_VALUE, "Value");
- DataSourceTextField kindField = new DataSourceTextField(ATTR_KIND, "Kind");
- DataSourceTextField nameField = new DataSourceTextField(ATTR_NAME, "Name");
- ds.setFields(idField,valueField, kindField, nameField );
-
- for (SearchSuggestion searchSuggestion : results) {
- Log.debug("search tab aware Suggestions: " + searchSuggestion.getKind() + ", " + searchSuggestion.getValue() + ", " + searchSuggestion.getLabel());
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(ATTR_ID, searchSuggestion.getValue());
- if(null != searchSuggestion.getKind()){
- record.setAttribute(ATTR_KIND, searchSuggestion.getKind().getDisplayName());
+ searchService.getTabAwareSuggestions(searchSubsystem, expression, caretPosition, null,
+ new AsyncCallback<List<SearchSuggestion>>() {
+
+ public void onSuccess(List<SearchSuggestion> results) {
+ ComboBoxItem comboBox = searchBar.getSearchComboboxItem();
+ DataSource ds = comboBox.getOptionDataSource();
+ boolean dofetch = false;
+
+ if (null == ds) {
+ ds = new DataSource();
+ ds.setClientOnly(true);
+ DataSourceTextField idField = new DataSourceTextField(ATTR_ID, "Id");
+ idField.setPrimaryKey(true);
+ DataSourceTextField valueField = new DataSourceTextField(ATTR_VALUE, "Value");
+ DataSourceTextField kindField = new DataSourceTextField(ATTR_KIND, "Kind");
+ DataSourceTextField nameField = new DataSourceTextField(ATTR_NAME, "Name");
+ ds.setFields(idField, valueField, kindField, nameField);
+
+ comboBox.setOptionDataSource(ds);
+
+ } else {
+ ds.invalidateCache();
+ dofetch = true;
}
- record.setAttribute(ATTR_NAME, searchSuggestion.getLabel());
- record.setAttribute(ATTR_VALUE, searchSuggestion.getValue());
- ds.addData(record);
- }
- searchBar.getSearchComboboxItem().setOptionDataSource(ds);
- long suggestFetchTime = System.currentTimeMillis() - suggestStart;
- Log.debug(results.size() + " suggestions searches fetched in: " + suggestFetchTime + "ms");
- }
+ for (SearchSuggestion searchSuggestion : results) {
+ Log.debug("search tab aware Suggestions: " + searchSuggestion.getKind() + ", "
+ + searchSuggestion.getValue() + ", " + searchSuggestion.getLabel());
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(ATTR_ID, searchSuggestion.getValue());
+ if (null != searchSuggestion.getKind()) {
+ record.setAttribute(ATTR_KIND, searchSuggestion.getKind().getDisplayName());
+ }
+ record.setAttribute(ATTR_NAME, searchSuggestion.getLabel());
+ record.setAttribute(ATTR_VALUE, searchSuggestion.getValue());
+ ds.addData(record);
+ }
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to retrieve search suggestion", caught);
- }
+ if (dofetch) {
+ comboBox.fetchData();
+ }
+
+ long suggestFetchTime = System.currentTimeMillis() - suggestStart;
+ Log.debug(results.size() + " suggestions searches fetched in: " + suggestFetchTime + "ms");
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to retrieve search suggestion", caught);
+ }
- });
+ });
}
public void getSearchSuggestions(SearchSubsystem searchSubsystem, String expression, int caretPosition) {
final long suggestStart = System.currentTimeMillis();
- searchService.getTabAwareSuggestions(searchSubsystem, expression,
- caretPosition, null, new AsyncCallback<List<SearchSuggestion>>() {
-
- public void onSuccess(List<SearchSuggestion> results) {
- DataSource ds = new DataSource();
- ds.setClientOnly(true);
- DataSourceTextField idField = new DataSourceTextField(ATTR_ID, "Id");
- idField.setPrimaryKey(true);
- DataSourceTextField valueField = new DataSourceTextField(ATTR_VALUE, "Value");
- DataSourceTextField kindField = new DataSourceTextField(ATTR_KIND, "Kind");
- DataSourceTextField nameField = new DataSourceTextField(ATTR_NAME, "Name");
- ds.setFields(valueField, kindField, nameField );
-
- for (SearchSuggestion searchSuggestion : results) {
- Log.debug("search Suggestions: " + searchSuggestion.getKind() + ", " + searchSuggestion.getValue() + ", " + searchSuggestion.getLabel());
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(ATTR_ID, searchSuggestion.getValue());
- if(null != searchSuggestion.getKind()){
- record.setAttribute(ATTR_KIND, searchSuggestion.getKind().getDisplayName());
+ searchService.getTabAwareSuggestions(searchSubsystem, expression, caretPosition, null,
+ new AsyncCallback<List<SearchSuggestion>>() {
+
+ public void onSuccess(List<SearchSuggestion> results) {
+ ComboBoxItem comboBox = searchBar.getSearchComboboxItem();
+ DataSource ds = comboBox.getOptionDataSource();
+ boolean newDs = false;
+
+ if (null == ds) {
+ ds = new DataSource();
+ ds.setClientOnly(true);
+ DataSourceTextField idField = new DataSourceTextField(ATTR_ID, "Id");
+ idField.setPrimaryKey(true);
+ DataSourceTextField valueField = new DataSourceTextField(ATTR_VALUE, "Value");
+ DataSourceTextField kindField = new DataSourceTextField(ATTR_KIND, "Kind");
+ DataSourceTextField nameField = new DataSourceTextField(ATTR_NAME, "Name");
+ ds.setFields(valueField, kindField, nameField);
+
+ comboBox.setOptionDataSource(ds);
+ newDs = true;
+
+ } else {
+ ds.invalidateCache();
}
- record.setAttribute(ATTR_NAME, searchSuggestion.getLabel());
- record.setAttribute(ATTR_VALUE, searchSuggestion.getValue());
- ds.addData(record);
- }
- searchBar.getSearchComboboxItem().setOptionDataSource(ds);
- long suggestFetchTime = System.currentTimeMillis() - suggestStart;
- Log.debug(results.size() + " suggestions searches fetched in: " + suggestFetchTime + "ms");
- }
+ for (SearchSuggestion searchSuggestion : results) {
+ Log.debug("search Suggestions: " + searchSuggestion.getKind() + ", "
+ + searchSuggestion.getValue() + ", " + searchSuggestion.getLabel());
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(ATTR_ID, searchSuggestion.getValue());
+ if (null != searchSuggestion.getKind()) {
+ record.setAttribute(ATTR_KIND, searchSuggestion.getKind().getDisplayName());
+ }
+ record.setAttribute(ATTR_NAME, searchSuggestion.getLabel());
+ record.setAttribute(ATTR_VALUE, searchSuggestion.getValue());
+ ds.addData(record);
+ }
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to retrieve search suggestion", caught);
- }
+ if (!newDs) {
+ comboBox.fetchData();
+ }
+
+ long suggestFetchTime = System.currentTimeMillis() - suggestStart;
+ Log.debug(results.size() + " suggestions searches fetched in: " + suggestFetchTime + "ms");
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to retrieve search suggestion", caught);
+ }
- });
+ });
}
@Override
public void initialize() {
getSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
}
+
}
11 years, 11 months
[rhq] Branch 'jkremser/upload-progressbar' - modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/FileUploadForm.java | 59 ++++------
modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 5
2 files changed, 30 insertions(+), 34 deletions(-)
New commits:
commit 84cfe8726c3aa0d9f0cbff628b32e554ff59ebc2
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Thu Jun 21 18:55:49 2012 +0200
timeou after progress update increased to 10; some errors removed
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/FileUploadForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/FileUploadForm.java
index 7e8d11d..89cab60 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/FileUploadForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/FileUploadForm.java
@@ -36,9 +36,6 @@ import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
-import com.smartgwt.client.widgets.form.fields.UploadItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
@@ -56,7 +53,8 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
*/
public class FileUploadForm extends DynamicCallbackForm {
- private UploadItem fileUploadItem;
+ private SingleUploader uploader;
+// private UploadItem fileUploadItem;
private ButtonItem uploadButton;
private Boolean uploadResult;
@@ -180,7 +178,8 @@ public class FileUploadForm extends DynamicCallbackForm {
}
protected void changeIcon(FormItemIcon icon, String tooltip) {
- FormItem item = (this.showUploadButton) ? this.uploadButton : this.fileUploadItem;
+// FormItem item = (this.showUploadButton) ? this.uploadButton : this.fileUploadItem;
+ FormItem item = this.uploadButton;
item.setIcons(icon);
item.setIconPrompt(tooltip);
markForRedraw();
@@ -201,11 +200,11 @@ public class FileUploadForm extends DynamicCallbackForm {
versionField.setDefaultValue(version);
onDrawItems.add(versionField);
- fileUploadItem = new UploadItem("fileUploadItem", name);
- fileUploadItem.setShowTitle(showNameLabel);
- fileUploadItem.setWrapTitle(false);
- fileUploadItem.setColSpan(1);
- onDrawItems.add(fileUploadItem);
+// fileUploadItem = new UploadItem("fileUploadItem", name);
+// fileUploadItem.setShowTitle(showNameLabel);
+// fileUploadItem.setWrapTitle(false);
+// fileUploadItem.setColSpan(1);
+// onDrawItems.add(fileUploadItem);
if (showUploadButton) {
// this intercepts an enable request and only allows it if there is a file selected
@@ -216,7 +215,7 @@ public class FileUploadForm extends DynamicCallbackForm {
@Override
public void enable() {
- String selectedFile = fileUploadItem.getValueAsString();
+ String selectedFile = uploader.getBasename();
if (selectedFile != null && selectedFile.length() > 0) {
super.enable();
}
@@ -235,13 +234,13 @@ public class FileUploadForm extends DynamicCallbackForm {
}
});
- fileUploadItem.setEndRow(false);
- fileUploadItem.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent changeEvent) {
- uploadButton.setDisabled(false);
- }
- });
+// fileUploadItem.setEndRow(false);
+// fileUploadItem.addChangeHandler(new ChangeHandler() {
+// @Override
+// public void onChange(ChangeEvent changeEvent) {
+// uploadButton.setDisabled(false);
+// }
+// });
onDrawItems.add(uploadButton);
}
@@ -313,17 +312,17 @@ public class FileUploadForm extends DynamicCallbackForm {
setUploadError(message);
}
- Object value = fileUploadItem.getValue();
- if (value == null || value.toString().length() == 0) {
- String message = MSG.view_upload_prompt_1(name);
- changeIcon(iconRed, message);
- setUploadError(message);
- // note - don't even submit this definite failure
- } else {
-// changeIcon(iconLoading, MSG.common_msg_loading());
- uploadInProgress = true;
-// super.submitForm();
- }
+// Object value = uploader.getBasename();
+// if (value == null || value.toString().length() == 0) {
+// String message = MSG.view_upload_prompt_1(name);
+// changeIcon(iconRed, message);
+// setUploadError(message);
+// // note - don't even submit this definite failure
+// } else {
+//// changeIcon(iconLoading, MSG.common_msg_loading());
+// uploadInProgress = true;
+//// super.submitForm();
+// }
return addDomHandler(handler, com.google.gwt.event.dom.client.ClickEvent.getType());
}
}
@@ -338,7 +337,7 @@ public class FileUploadForm extends DynamicCallbackForm {
// List<FormItem> onDrawItems = getOnDrawItems();
// setItems(onDrawItems.toArray(new FormItem[onDrawItems.size()]));
- SingleUploader uploader = new SingleUploader(null, new UploadButton());
+ uploader = new SingleUploader(null, new UploadButton());
uploader.addOnFinishUploadHandler(new IUploader.OnFinishUploaderHandler() {
public void onFinish(IUploader uploader) {
uploadInProgress = false;
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index c6a33af..ee21988 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -30,11 +30,8 @@
<param-value>209715200</param-value>
</context-param>
<context-param>
- <!-- Useful in development mode to slow down the uploads in fast networks.
- Put the number of milliseconds to sleep in each block received in the server.
- false or 0, means don't use slow uploads -->
<param-name>slowUploads</param-name>
- <param-value>0</param-value>
+ <param-value>10</param-value>
</context-param>
<filter>
11 years, 11 months
[rhq] Changes to 'jkremser/upload-progressbar'
by Jiri Kremser
New branch 'jkremser/upload-progressbar' available with the following commits:
commit 5fceacfff3f6dd9f95c67545741d2f07d8a289b3
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jun 20 15:09:09 2012 +0200
FileUploadForm supports gwtupload component
11 years, 11 months
[rhq] modules/plugins
by ips
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 15 ++++++----
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java | 14 ++++++---
2 files changed, 19 insertions(+), 10 deletions(-)
New commits:
commit cb316267fac790327fe62d1ac8c9ea9bccd3dbe7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Jun 21 11:55:32 2012 -0400
[BZ 834353] update discovery to recognize BRMS as a separate product type (https://bugzilla.redhat.com/show_bug.cgi?id=834353)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
index 31c6ab3..01eb105 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
@@ -576,11 +576,16 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
ComparableVersion version = new ComparableVersion(installInfo.getVersion());
JBossProductType productType = installInfo.getProductType();
ComparableVersion minimumVersion = MINIMUM_PRODUCT_VERSIONS.get(productType);
- // The product is supported if the version is greater than or equal to the minimum version.
- boolean supported = (version.compareTo(minimumVersion) >= 0);
- if (!supported) {
- log.debug(productType + " version " + version + " is not supported by this plugin (minimum " + productType
- + " version is " + minimumVersion + ") - skipping...");
+ boolean supported;
+ if (minimumVersion != null) {
+ // The product is supported if the version is greater than or equal to the minimum version.
+ supported = (version.compareTo(minimumVersion) >= 0);
+ if (!supported) {
+ log.debug(productType + " version " + version + " is not supported by this plugin (minimum " + productType
+ + " version is " + minimumVersion + ") - skipping...");
+ }
+ } else {
+ supported = true;
}
return supported;
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
index 818658b..de5d837 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java
@@ -1,6 +1,6 @@
/*
* Jopr Management Platform
-* Copyright (C) 2005-2010 Red Hat, Inc.
+* Copyright (C) 2005-2012 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -31,10 +31,11 @@ import java.util.jar.Attributes;
* @author Ian Springer
*/
public enum JBossProductType {
- AS("JBoss AS", "JBoss Application Server", "default"), // the public offering
- EAP("JBoss EAP", "JBoss Enterprise Application Platform", "default"), // the customer offering
- EWP("JBoss EWP", "JBoss Enterprise Web Platform", "default"), // the customer offering
- SOA("JBoss SOA-P", "JBoss Enterprise SOA Platform", "default"); // the customer SOA platform
+ AS("JBoss AS", "JBoss Application Server", "default"),
+ EAP("JBoss EAP", "JBoss Enterprise Application Platform", "default"),
+ EWP("JBoss EWP", "JBoss Enterprise Web Platform", "default"),
+ SOA("JBoss SOA-P", "JBoss Enterprise SOA Platform", "default"),
+ BRMS("JBoss BRMS", "JBoss Business Rules Management System", "default");
public final String NAME;
public final String DESCRIPTION;
@@ -43,6 +44,7 @@ public enum JBossProductType {
private static final String EAP_IMPLEMENTATION_TITLE = "JBoss [EAP]";
private static final String EWP_IMPLEMENTATION_TITLE = "JBoss [EWP]";
private static final String SOA_IMPLEMENTATION_TITLE = "JBoss [SOA]";
+ private static final String BRMS_IMPLEMENTATION_TITLE = "JBoss [BRMS]";
JBossProductType(String name, String description, String defaultConfigName) {
this.NAME = name;
@@ -68,6 +70,8 @@ public enum JBossProductType {
result = JBossProductType.EWP;
} else if (implementationTitle.equalsIgnoreCase(SOA_IMPLEMENTATION_TITLE)) {
result = JBossProductType.SOA;
+ } else if (implementationTitle.equalsIgnoreCase(BRMS_IMPLEMENTATION_TITLE)) {
+ result = JBossProductType.BRMS;
}
}
return result;
11 years, 11 months
[rhq] Branch 'searchbar' - 2 commits - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java | 7 ++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java | 7 +++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java | 4 +++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java | 5 +++++
4 files changed, 15 insertions(+), 8 deletions(-)
New commits:
commit c38db268a77276c2ad26c0bc33ed652506f6a54c
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Jun 20 15:39:40 2012 -0700
Make initial population bugfix.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
index 35f45df..4718fd1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
@@ -18,19 +18,16 @@
*/
package org.rhq.enterprise.gui.coregui.client.searchbar;
-import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.SearchGWTServiceAsync;
-import java.util.List;
/**
* AbstractSearchStrategy defines common search strategy behaviors the subclasses must implement.
@@ -60,6 +57,8 @@ public abstract class AbstractSearchStrategy implements RecordClickHandler, Cel
}
+ public abstract void initialize();
+
/**
* Handle the key press event in the search bar. Must be overridden in subclass.
* @param keyUpEvent
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
index 4625ef5..9300f3f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
@@ -201,7 +201,7 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
});
}
- private void getSearchSuggestions(SearchSubsystem searchSubsystem, String expression, int caretPosition) {
+ public void getSearchSuggestions(SearchSubsystem searchSubsystem, String expression, int caretPosition) {
final long suggestStart = System.currentTimeMillis();
@@ -242,5 +242,8 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
});
}
-
+ @Override
+ public void initialize() {
+ getSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
index 7379e52..7f33531 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
@@ -104,7 +104,7 @@ public class EnhancedSearchBar extends ToolStrip {
searchComboboxItem.setBrowserSpellCheck(false);
searchComboboxItem.setAutoFetchData(true);
searchComboboxItem.setFetchDelay(300);
- //searchComboboxItem.setCompleteOnTab(true);
+ searchComboboxItem.setCompleteOnTab(true);
pickListGrid = new ListGrid();
configureCommonHandlers();
@@ -158,6 +158,8 @@ public class EnhancedSearchBar extends ToolStrip {
// set the default search provider
switchToBasicSearchMode();
+ // do any initialization
+ getSearchStrategy().initialize();
this.draw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
index 8fe5bf4..2386785 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
@@ -146,4 +146,9 @@ public class FavoritesSearchStrategy extends AbstractSearchStrategy {
// do nothing
Log.debug("return key in SavedSearchProvider");
}
+
+ @Override
+ public void initialize() {
+
+ }
}
commit 59291f1cf9be64e565acde9bb2acc1cbb06339b1
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Jun 20 09:53:18 2012 -0700
Remove more unused code.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
index b1946d5..35f45df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/AbstractSearchStrategy.java
@@ -24,13 +24,11 @@ import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.SavedSearchCriteria;
-import org.rhq.core.domain.search.SavedSearch;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.SearchGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import java.util.List;
11 years, 11 months
[rhq] modules/core modules/enterprise
by mazz
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java | 244 ------
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/ConfigurationUtility.java | 334 +++++++++
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationUtilityTest.java | 363 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDeploymentConfigStep.java | 12
5 files changed, 721 insertions(+), 554 deletions(-)
New commits:
commit a5ef337f5921c5cc52fd6a96c084925c46b8f4a1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 20 17:26:41 2012 -0400
[BZ 828843] fix bundle deploy wizard's configuration editor initialization so required properties that didn't exist in the live deployment config are set to their default values
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 85ae0bb..6420978 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
@@ -22,31 +22,20 @@
*/
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;
-import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
-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;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
/**
* Utility methods for working with {@link Configuration}s.
*
* @author Ian Springer
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
public abstract class ConfigurationUtility {
@@ -60,21 +49,11 @@ public abstract class ConfigurationUtility {
* 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
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
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;
+ org.rhq.core.domain.configuration.ConfigurationUtility.initializeDefaultTemplate(configDef);
}
/**
@@ -87,17 +66,12 @@ public abstract class ConfigurationUtility {
*
* @param configurationDefinition the configuration definition whose default configuration is to be created
* @return configuration the default configuration
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
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;
+ return org.rhq.core.domain.configuration.ConfigurationUtility
+ .createDefaultConfiguration(configurationDefinition);
}
/**
@@ -107,19 +81,13 @@ public abstract class ConfigurationUtility {
*
* @param configuration the configuration to be normalized
* @param configurationDefinition the configuration definition to normalize the configuration against
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
public static void normalizeConfiguration(@NotNull Configuration configuration,
@Nullable ConfigurationDefinition configurationDefinition) {
- //noinspection ConstantConditions
- if (configuration == null) {
- throw new IllegalArgumentException("Configuration parameter is null.");
- }
- if (configurationDefinition != null) {
- Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- normalizeProperty(childPropertyDefinition, configuration);
- }
- }
+ org.rhq.core.domain.configuration.ConfigurationUtility.normalizeConfiguration(configuration,
+ configurationDefinition, false, false);
}
/**
@@ -132,191 +100,13 @@ public abstract class ConfigurationUtility {
* @param configurationDefinition the configuration definition to validate the configuration against
*
* @return a list of messages describing any errors that were found
+ *
+ * @deprecated use the utility found in the domain module -org.rhq.core.domain.configuration.ConfigurationUtility
*/
@NotNull
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();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- validateProperty(childPropertyDefinition, configuration, errorMessages);
- }
- }
- 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)
- .getMap();
- 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
- {
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName());
- String value = propertySimple.getStringValue();
- if (value != null) {
- if (value.equals("")) {
- // Normalize "" to null, since Oracle will do the same upon persistence.
- propertySimple.setStringValue(null);
- } else if (value.length() > PropertySimple.MAX_VALUE_LENGTH) {
- // Truncate the value to the max length allowed by the DB schema.
- propertySimple.setStringValue(value.substring(0, PropertySimple.MAX_VALUE_LENGTH));
- }
- }
- }
-
- // If the property is a Map, recurse into it and normalize its child properties.
- else if (propertyDefinition instanceof PropertyDefinitionMap) {
- PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
- PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
- normalizePropertyMap(propertyMap, propertyDefinitionMap);
- } else if (propertyDefinition instanceof PropertyDefinitionList) {
- PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
- PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
-
- // If the property is a List of Maps, iterate the list, and recurse into each Map and verify its child
- // properties.
- if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
- PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
- PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
- for (Property property : propertyList.getList()) {
- PropertyMap propertyMap = (PropertyMap) property;
- normalizePropertyMap(propertyMap, propertyDefinitionMap);
- }
- }
- }
- } else // property is not set yet
- {
- Property property;
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- property = new PropertySimple(propertyDefinition.getName(), null);
- } else if (propertyDefinition instanceof PropertyDefinitionMap) {
- property = new PropertyMap(propertyDefinition.getName());
- } else if (propertyDefinition instanceof PropertyDefinitionList) {
- property = new PropertyList(propertyDefinition.getName());
- } 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());
- }
-
- parentPropertyMap.put(property);
- }
- }
-
- private static void normalizePropertyMap(AbstractPropertyMap propertyMap,
- PropertyDefinitionMap propertyDefinitionMap) {
- Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getMap();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- normalizeProperty(childPropertyDefinition, propertyMap);
- }
- }
-
- private static void validateProperty(PropertyDefinition propertyDefinition, AbstractPropertyMap parentPropertyMap,
- List<String> errorMessages) {
- if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName())) // property is already set
- {
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName());
- if (propertyDefinition.isRequired() && (propertySimple.getStringValue() == null)) {
- errorMessages.add("Required property '" + propertyDefinition.getName() + "' has a null value in "
- + parentPropertyMap + ".");
- propertySimple.setStringValue("");
- }
- }
-
- // If the property is a Map, recurse into it and validate its child properties.
- else if (propertyDefinition instanceof PropertyDefinitionMap) {
- PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
- PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
- validatePropertyMap(propertyMap, propertyDefinitionMap, errorMessages);
- } else if (propertyDefinition instanceof PropertyDefinitionList) {
- PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
- PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
-
- // If the property is a List of Maps, iterate the list, and recurse into each Map and validate its child
- // properties.
- if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
- PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
- PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
- for (Property property : propertyList.getList()) {
- PropertyMap propertyMap = (PropertyMap) property;
- validatePropertyMap(propertyMap, propertyDefinitionMap, errorMessages);
- }
- }
- }
- } else // property is not set yet
- {
- if (propertyDefinition.isRequired()) {
- errorMessages.add("Required property '" + propertyDefinition.getName() + "' was not set in "
- + parentPropertyMap + ".");
- if (propertyDefinition instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple = new PropertySimple(propertyDefinition.getName(), "");
- parentPropertyMap.put(propertySimple);
- }
- }
- }
- }
-
- private static void validatePropertyMap(AbstractPropertyMap propertyMap,
- PropertyDefinitionMap propertyDefinitionMap, List<String> errorMessages) {
- Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getMap();
- for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
- validateProperty(childPropertyDefinition, propertyMap, errorMessages);
- }
+ return org.rhq.core.domain.configuration.ConfigurationUtility.validateConfiguration(configuration,
+ configurationDefinition);
}
}
\ No newline at end of file
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
deleted file mode 100644
index 3f3dccd..0000000
--- a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtilityTest.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, 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/ConfigurationUtility.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUtility.java
new file mode 100644
index 0000000..1c32526
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUtility.java
@@ -0,0 +1,334 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+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;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+
+/**
+ * Utility methods for working with {@link Configuration}s.
+ *
+ * @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.
+ * Map properties are set with an empty Map, and List properties with an empty List. By default, simple
+ * properties that are missing will be created and set with a null value. However, if normalizeRequiredDefaults is true,
+ * and a simple property is required with a default, this will set the required property to that default value.
+ * If normalizeOptionalDefaults is true, and a simple property is not required but has a default, this will set the
+ * optional property to that default. If a simple property does not have a default defined, no matter what those
+ * "normalize" booleans are, the simple property will still be set to null since this method won't know what value
+ * to set it to anyway.
+ *
+ * @param configuration the configuration to be normalized (must not be null)
+ * @param configurationDefinition the configuration definition to normalize the configuration against (may be null)
+ * @param normalizeRequiredDefaults if true, and a property is required, its default will be set as that property's value
+ * @param normalizeOptionalDefaults if true, and a property is optional, its default will be set as that property's value
+ */
+ public static void normalizeConfiguration(Configuration configuration,
+ ConfigurationDefinition configurationDefinition, boolean normalizeRequiredDefaults,
+ boolean normalizeOptionalDefaults) {
+ if (configuration == null) {
+ throw new IllegalArgumentException("Configuration parameter is null.");
+ }
+ if (configurationDefinition != null) {
+ Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ normalizeProperty(childPropertyDefinition, configuration, normalizeRequiredDefaults,
+ normalizeOptionalDefaults);
+ }
+ }
+ }
+
+ /**
+ * Validate the given configuration according to the given configuration definition. That is, check that any
+ * required properties in the top-level configuration Map or any sub-Maps, are defined and, in the case of simple
+ * properties, check that they have a non-null value. A list of messages describing any errors that were found is
+ * returned. Additionally, any undefined or null simple properties will be assigned a value of "".
+ *
+ * @param configuration the configuration to be validated (must not be null)
+ * @param configurationDefinition the configuration definition to validate the configuration against (may be null)
+ *
+ * @return a list of messages describing any errors that were found - will be empty if there are no messagse
+ */
+ public static List<String> validateConfiguration(Configuration configuration,
+ ConfigurationDefinition configurationDefinition) {
+ List<String> errorMessages = new ArrayList<String>();
+ if (configurationDefinition != null) {
+ Map<String, PropertyDefinition> childPropertyDefinitions = configurationDefinition.getPropertyDefinitions();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ validateProperty(childPropertyDefinition, configuration, errorMessages);
+ }
+ }
+ 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)
+ .getMap();
+ 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,
+ boolean normalizeRequiredDefaults, boolean normalizeOptionalDefaults) {
+ if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName())) // property is already set
+ {
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName());
+ String value = propertySimple.getStringValue();
+ if (value != null) {
+ if (value.equals("")) {
+ // Normalize "" to null, since Oracle will do the same upon persistence.
+ propertySimple.setStringValue(null);
+ } else if (value.length() > PropertySimple.MAX_VALUE_LENGTH) {
+ // Truncate the value to the max length allowed by the DB schema.
+ propertySimple.setStringValue(value.substring(0, PropertySimple.MAX_VALUE_LENGTH));
+ }
+ }
+ }
+
+ // If property is a Map, recurse into it and normalize its child properties.
+ else if (propertyDefinition instanceof PropertyDefinitionMap) {
+ PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
+ PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
+ normalizePropertyMap(propertyMap, propertyDefinitionMap, false, false); // TODO do we want to pass normalizeRequired/OptionalDefaults?
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
+ PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
+
+ // If property is a List of Maps, iterate the list and recurse into each Map and normalize its child properties.
+ if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
+ PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
+ PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
+ for (Property property : propertyList.getList()) {
+ PropertyMap propertyMap = (PropertyMap) property;
+ normalizePropertyMap(propertyMap, propertyDefinitionMap, false, false); // TODO do we want to pass normalizeRequired/OptionalDefaults?
+ }
+ }
+ }
+ } else // property is not set yet
+ {
+ Property property;
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ String value = null;
+ if (normalizeRequiredDefaults || normalizeOptionalDefaults) {
+ if (propertyDefinition.isRequired()) {
+ if (normalizeRequiredDefaults) {
+ value = ((PropertyDefinitionSimple) propertyDefinition).getDefaultValue();
+ }
+ } else {
+ if (normalizeOptionalDefaults) {
+ value = ((PropertyDefinitionSimple) propertyDefinition).getDefaultValue();
+ }
+ }
+ }
+ property = new PropertySimple(propertyDefinition.getName(), value);
+ } else if (propertyDefinition instanceof PropertyDefinitionMap) {
+ property = new PropertyMap(propertyDefinition.getName());
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ property = new PropertyList(propertyDefinition.getName());
+ } 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());
+ }
+
+ parentPropertyMap.put(property);
+ }
+ }
+
+ private static void normalizePropertyMap(AbstractPropertyMap propertyMap,
+ PropertyDefinitionMap propertyDefinitionMap, boolean normalizeRequiredDefaults,
+ boolean normalizeOptionalDefaults) {
+ Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getMap();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ normalizeProperty(childPropertyDefinition, propertyMap, normalizeRequiredDefaults,
+ normalizeOptionalDefaults);
+ }
+ }
+
+ private static void validateProperty(PropertyDefinition propertyDefinition, AbstractPropertyMap parentPropertyMap,
+ List<String> errorMessages) {
+ if (parentPropertyMap.getMap().keySet().contains(propertyDefinition.getName())) // property is already set
+ {
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName());
+ if (propertyDefinition.isRequired() && (propertySimple.getStringValue() == null)) {
+ errorMessages.add("Required property '" + propertyDefinition.getName() + "' has a null value in "
+ + parentPropertyMap + ".");
+ propertySimple.setStringValue("");
+ }
+ }
+
+ // If the property is a Map, recurse into it and validate its child properties.
+ else if (propertyDefinition instanceof PropertyDefinitionMap) {
+ PropertyMap propertyMap = parentPropertyMap.getMap(propertyDefinition.getName());
+ PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition;
+ validatePropertyMap(propertyMap, propertyDefinitionMap, errorMessages);
+ } else if (propertyDefinition instanceof PropertyDefinitionList) {
+ PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
+ PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
+
+ // If the property is a List of Maps, iterate the list, and recurse into each Map and validate its child
+ // properties.
+ if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
+ PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition;
+ PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName());
+ for (Property property : propertyList.getList()) {
+ PropertyMap propertyMap = (PropertyMap) property;
+ validatePropertyMap(propertyMap, propertyDefinitionMap, errorMessages);
+ }
+ }
+ }
+ } else // property is not set yet
+ {
+ if (propertyDefinition.isRequired()) {
+ errorMessages.add("Required property '" + propertyDefinition.getName() + "' was not set in "
+ + parentPropertyMap + ".");
+ if (propertyDefinition instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple = new PropertySimple(propertyDefinition.getName(), "");
+ parentPropertyMap.put(propertySimple);
+ }
+ }
+ }
+ }
+
+ private static void validatePropertyMap(AbstractPropertyMap propertyMap,
+ PropertyDefinitionMap propertyDefinitionMap, List<String> errorMessages) {
+ Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getMap();
+ for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) {
+ validateProperty(childPropertyDefinition, propertyMap, errorMessages);
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationUtilityTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationUtilityTest.java
new file mode 100644
index 0000000..7c49296
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationUtilityTest.java
@@ -0,0 +1,363 @@
+/*
+ * 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.domain.configuration;
+
+import org.testng.annotations.Test;
+
+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 testNormalizeDefaultSimple() {
+ 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);
+
+ // test normalization
+ Configuration config = new Configuration();
+ ConfigurationUtility.normalizeConfiguration(config, configDef, false, false);
+ assert config.getProperties().size() == 4;
+ assert config.getSimpleValue(simple.getName(), null) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(), null) == null;
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null) == null;
+
+ config = new Configuration();
+ ConfigurationUtility.normalizeConfiguration(config, configDef, true, false);
+ assert config.getProperties().size() == 4;
+ assert config.getSimpleValue(simple.getName(), null) == null;
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null; // there is no default, so nothing to set
+ assert config.getSimpleValue(simpleDefault.getName(), null) == null;
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null).equals("!!simpleRequiredDefaultValue!!");
+
+ config = new Configuration();
+ ConfigurationUtility.normalizeConfiguration(config, configDef, false, true);
+ assert config.getProperties().size() == 4;
+ assert config.getSimpleValue(simple.getName(), null) == null; // there is no default, so nothing to set
+ assert config.getSimpleValue(simpleRequired.getName(), null) == null;
+ assert config.getSimpleValue(simpleDefault.getName(), null).equals("!!simpleDefaultValue!!");
+ assert config.getSimpleValue(simpleRequiredDefault.getName(), null) == null;
+ }
+
+ 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/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 7fc0363..c295b74 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
@@ -19,13 +19,14 @@
package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUtility;
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;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
@@ -58,8 +59,11 @@ public class GetDeploymentConfigStep extends AbstractWizardStep {
// This has started behaving badly. Instead of moving ahead let's give them a message
// and a chance to go back to the previous screen.
// this.wizard.getView().incrementStep();
- HeaderLabel label = new HeaderLabel(MSG.view_bundle_deployWizard_getConfigSkip());
+ HTMLFlow label = new HTMLFlow(MSG.view_bundle_deployWizard_getConfigSkip());
label.setWidth100();
+ label.setHeight(50);
+ label.setStylePrimaryName("HeaderLabel");
+ label.setStyleName("HeaderLabel");
editor = new VLayout();
editor.addMember(label);
} else {
@@ -100,9 +104,7 @@ public class GetDeploymentConfigStep extends AbstractWizardStep {
config = new Configuration();
} else {
config = config.deepCopy(false);
- //TODO: get access to this method, may need to add slsb call
- // also, may need to enhance this drop unnecessary config (maybe it can just stay around)
- //ConfigurationUtility.normalizeConfiguration(config, configDef);
+ ConfigurationUtility.normalizeConfiguration(config, configDef, true, false);
}
return config;
11 years, 11 months
[rhq] modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/pom.xml | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit 8c13179ae885c491088980a88aee43d7b7bf77dd
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Jun 20 12:53:30 2012 -0700
[BZ 830323] Large artifacts get packaged in war file. Remove symbolMap data from GWT compiled war file.
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 45308cc..aac9b9c 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -298,6 +298,8 @@
<compileSourcesArtifact>org.rhq:rhq-core-domain</compileSourcesArtifact>
<style>${gwt.style}</style>
<strict>true</strict>
+ <!-- compiles gwt artifacts like symbolMap outside of war so it doesnt get packaged -->
+ <deploy>${project.build.directory}/gwt-deploy</deploy>
</configuration>
<executions>
11 years, 11 months
[rhq] modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java | 22 +-
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 10 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java | 17 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 28 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java | 96 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java | 12 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 19 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java | 13 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java | 12 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 15 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java | 18 +
26 files changed, 252 insertions(+), 78 deletions(-)
New commits:
commit 3bbec0bbb45429d1f0769753466faa3e26e5623f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jun 20 15:40:39 2012 -0400
[830463 - Re-enabling (actually, updating) an alert definition clears condition logs for existing alerts]
This is sort of complex. The underlying issue is that
AlertDefinitionManagerBean.updateAlertDefinition(updatedDef) replaces
existing AlertConditions with updatedDef.conditions. The detached
conditions were deleted (via Hibernate and DELETE_ORPHAN) regardless of the
fact that they very possibly linked to AlertConditionLog records for existing
Alerts. These log records are what you need to display the actual condition
evaluations that explain why the alert was fired.
The fix was to allow the detached AlertCondition records to stay around and
to deal with the fallout of doing that:
- clean up orphaned AlertConditions (no def and no logs) in the data purge job
- update queries backing AlertManager.deleteAlertsByContext()
- update queries backing resource uninventory bulk delete
Additionally, there was a lot of confusion around the 'purgeInternals' parameter
for updateAlertDefinition(). It was initially thought that setting this true
was responsible for the loss of AlertConditions backing the Alerts. Actually,
what this flag does, when set to true, is to erase any partial condition
matching that has taken place. It must be set true if conditions, dampening rules,
or the condition expression (All vs Any matching) are being updated. Otherwise
it can be false.
I renamed this flag to be 'resetMatching' to hopefully be more clear, and
added some jdoc for the relevant methods.
I had already refactored CoreGUI's editor to correctly set this flag before
realizing it was not the root cause. So that logic is in place and
will optimize the update to some degree.
I think the backend logic can be further optimized using this setting more
intelligently. I plan a subsequent check-in for that before setting to ON_QA.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
index 064400c..8a72244 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
@@ -290,7 +290,11 @@ import org.rhq.core.domain.operation.OperationRequestStatus;
+ " FROM AlertCondition AS ac " //
+ " JOIN ac.alertDefinition ad " //
+ " JOIN ad.resource res " //
- + " WHERE ac.id = :alertConditionId ") })
+ + " WHERE ac.id = :alertConditionId "),
+ @NamedQuery(name = AlertCondition.QUERY_DELETE_ORPHANED, query = "" //
+ + " DELETE FROM AlertCondition ac " //
+ + " WHERE ac.alertDefinition IS NULL " //
+ + " AND NOT EXISTS ( SELECT acl FROM AlertConditionLog acl WHERE acl.condition.id = ac.id ) ") })
@SequenceGenerator(name = "RHQ_ALERT_CONDITION_ID_SEQ", sequenceName = "RHQ_ALERT_CONDITION_ID_SEQ")
@Table(name = "RHQ_ALERT_CONDITION")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -314,6 +318,8 @@ public class AlertCondition implements Serializable {
public static final String QUERY_FIND_RESOURCE_STATUS_BY_CONDITION_ID = "AlertCondition.findResourceStatus";
+ public static final String QUERY_DELETE_ORPHANED = "AlertCondition.deleteOrphaned";
+
public static final String RECOVERY_CONDITIONAL_EXPRESSION = "" //
+ " ( ad.recoveryId = 0 " //
+ " OR ( ad.recoveryId <> 0 " //
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java
index d43bb7f..28355be 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertConditionLog.java
@@ -42,7 +42,7 @@ import javax.persistence.Table;
* @author Joseph Marques
*/
@Entity
-@NamedQueries( {
+@NamedQueries({
@NamedQuery(name = AlertConditionLog.QUERY_FIND_UNMATCHED_LOG_BY_ALERT_CONDITION_ID, //
query = "SELECT acl " //
+ " FROM AlertConditionLog AS acl " //
@@ -63,16 +63,27 @@ import javax.persistence.Table;
+ " FROM Alert a " //
+ " JOIN a.conditionLogs ac" //
+ " WHERE a.id IN ( :alertIds ) )"),
- // deletes condition logs via the alert def, not alerts, because not every condition log may not
- // yet be associated with an alert. Also, avoids joining with the potentially large alert table
- @NamedQuery(name = AlertConditionLog.QUERY_DELETE_BY_RESOURCES, //
+ // This query removes condition logs via the alert def, not alerts, because not every condition log may
+ // yet be associated with an alert. This is required by Resource bulk delete to pick up the condition logs missed
+ // by QUERY_DELETE_BY_RESOURCES. It will not get the logs for AlertConditions detached from the AlertDefinition.
+ @NamedQuery(name = AlertConditionLog.QUERY_DELETE_BY_RESOURCES_BULK_DELETE, //
query = "DELETE AlertConditionLog acl " //
+ " WHERE acl.condition.id IN ( SELECT ac.id " //
+ " FROM AlertCondition ac " //
+ " JOIN ac.alertDefinition ad " //
+ " WHERE ad.resource.id IN ( :resourceIds ) ))"),
+ // This query will remove condition logs for conditions that are associated with alerts, regardless of whether
+ // the AlertCondition has been detached from the AlertDef. This is what you want if you are deleting alerts for
+ // a resource. It does not fully satisfy Resource bulk delete.
+ @NamedQuery(name = AlertConditionLog.QUERY_DELETE_BY_RESOURCES, //
+ query = "DELETE AlertConditionLog acl " //
+ + " WHERE acl.alert.id IN ( SELECT alert.id " //
+ + " FROM AlertDefinition alertDef " //
+ + " JOIN alertDef.alerts alert " //
+ + " WHERE alertDef.resource.id IN ( :resourceIds ) ))"),
@NamedQuery(name = AlertConditionLog.QUERY_DELETE_BY_RESOURCE_TEMPLATE, //
- query = "DELETE AlertConditionLog log " + " WHERE log.alert.id IN (SELECT alert.id "
+ query = "DELETE AlertConditionLog acl " //
+ + " WHERE acl.alert.id IN (SELECT alert.id "
+ " FROM AlertDefinition alertDef "
+ " JOIN alertDef.alerts alert "
+ " WHERE alertDef.resourceType.id = :resourceTypeId)"),
@@ -104,6 +115,7 @@ public class AlertConditionLog implements Serializable {
public static final String QUERY_DELETE_ALL = "AlertConditionLog.deleteByAll";
public static final String QUERY_DELETE_BY_ALERT_IDS = "AlertConditionLog.deleteByAlertIds";
public static final String QUERY_DELETE_BY_RESOURCES = "AlertConditionLog.deleteByResources";
+ public static final String QUERY_DELETE_BY_RESOURCES_BULK_DELETE = "AlertConditionLog.deleteByResourcesBulkDelete";
public static final String QUERY_DELETE_BY_RESOURCE_TEMPLATE = "AlertConditionLog.deleteByResourceType";
public static final String QUERY_DELETE_BY_RESOURCE_GROUPS = "AlertConditionLog.deleteByResourceGroups";
public static final String QUERY_DELETE_BY_ALERT_CTIME = "AlertConditionLog.deleteByAlertCTime";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 7d5e3e8..397e254 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -354,11 +354,17 @@ public class AlertDefinition implements Serializable {
@OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL)
@OrderBy
- @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
- // primary key
+ // We used to use DELETE_ORPHAN here. But the problem is that the the AlertCondition record is needed by the
+ // associated AlertConditionLog for presentation purposes. So, keep the AlertCondition records even if they
+ // are detached from the AlertDefinition (e.g. when the def is updated, see update() below). They will be
+ // cleaned up in the DataPurge job after all relevant alerts have been removed and there are no longer any
+ // referencing AlertConditionLog records.
private Set<AlertCondition> conditions = new LinkedHashSet<AlertCondition>(1); // Most alerts will only have one condition.
@OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL)
+ // Although similar to AlertCondition, we do use DELETE_ORPHAN here. The reason is because AlertNotificationLog
+ // does not refer back to the AlertNotification record and therefore the notification logs are not affected
+ // by the loss of the AlertNotification that spawned the notification.
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private List<AlertNotification> alertNotifications = new ArrayList<AlertNotification>();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 7f2cce0..6a2fbf5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -199,5 +199,5 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
protected abstract void disableButtonPressed(ListGridRecord[] selection);
- protected abstract void commitAlertDefinition(AlertDefinition alertDefinition);
+ protected abstract void commitAlertDefinition(AlertDefinition alertDefinition, boolean isPurgeInternals);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
index d762b23..3b564d4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -58,6 +58,7 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
private StaticTextItem conditionExpressionStatic;
private boolean formBuilt = false;
+ private boolean updated;
public ConditionsAlertDefinitionForm(String locatorId, ResourceType resourceType) {
this(locatorId, resourceType, null);
@@ -67,6 +68,7 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
super(locatorId);
this.resourceType = resourceType;
this.alertDefinition = alertDefinition;
+ this.updated = false;
}
@Override
@@ -86,6 +88,11 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
}
@Override
+ public boolean isResetMatching() {
+ return updated || conditionsEditor.isUpdated();
+ }
+
+ @Override
public void setAlertDefinition(AlertDefinition alertDef) {
alertDefinition = alertDef;
@@ -113,8 +120,12 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
@Override
public void makeViewOnly() {
+ updated = false;
+
conditionExpression.hide();
conditionsEditor.setEditable(false);
+ conditionsEditor.setUpdated(false);
+
conditionExpressionStatic.show();
markForRedraw();
@@ -122,11 +133,15 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
@Override
public void saveAlertDefinition() {
+ updated = false;
+
String condExpr = conditionExpression.getValue().toString();
alertDefinition.setConditionExpression(BooleanExpression.valueOf(condExpr));
HashSet<AlertCondition> conditions = conditionsEditor.getConditions();
alertDefinition.setConditions(conditions);
+
+ conditionsEditor.setUpdated(false);
}
@Override
@@ -167,6 +182,8 @@ public class ConditionsAlertDefinitionForm extends LocatableVLayout implements E
conditionExpression.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
+ updated = true;
+
// Find out if this is using the ALL conjunction - if it is, we can't have more than one conditional use the same metric.
// If we do, immediately abort and warn the user. See BZ 737565
if ((BooleanExpression.ALL.name().equals(event.getValue().toString()))
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 18b9beb..f3317ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -22,6 +22,11 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
@@ -33,6 +38,7 @@ import com.smartgwt.client.widgets.events.CloseClickEvent;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.drift.DriftDefinitionTemplate;
@@ -48,11 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
* @author John Mazzitelli
*/
@@ -62,12 +63,14 @@ public class ConditionsEditor extends LocatableVLayout {
private HashSet<AlertCondition> conditions;
private Table<ConditionDataSource> table;
private final SelectItem conditionExpression;
+ private boolean updated;
public ConditionsEditor(String locatorId, SelectItem conditionExpression, ResourceType resourceType,
HashSet<AlertCondition> conditions) {
super(locatorId);
this.conditionExpression = conditionExpression;
this.resourceType = resourceType;
+ this.updated = false;
setConditions(conditions);
}
@@ -133,6 +136,14 @@ public class ConditionsEditor extends LocatableVLayout {
table.setTableActionDisableOverride(!editable);
}
+ public boolean isUpdated() {
+ return updated;
+ }
+
+ public void setUpdated(boolean updated) {
+ this.updated = updated;
+ }
+
private class ConditionsTable extends Table<ConditionDataSource> {
private ConditionsTable(String locatorId) {
super(locatorId);
@@ -191,12 +202,14 @@ public class ConditionsEditor extends LocatableVLayout {
}
});
+ final int numConditions = conditions.size();
NewConditionEditor newConditionEditor = new NewConditionEditor(
extendLocatorId("newConditionEditor"), conditions,
ConditionsEditor.this.conditionExpression, ConditionsEditor.this.resourceType,
new Runnable() {
@Override
public void run() {
+ updated = updated || numConditions != conditions.size();
winModal.markForDestroy();
refresh();
}
@@ -215,6 +228,7 @@ public class ConditionsEditor extends LocatableVLayout {
for (ListGridRecord record : selection) {
AlertCondition cond = getDataSource().copyValues(record);
conditions.remove(cond);
+ updated = true;
}
refresh();
}
@@ -237,8 +251,8 @@ public class ConditionsEditor extends LocatableVLayout {
protected List<DataSourceField> addDataSourceFields() {
List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION, MSG
- .view_alert_common_tab_conditions_text());
+ DataSourceTextField conditionField = new DataSourceTextField(FIELD_CONDITION,
+ MSG.view_alert_common_tab_conditions_text());
fields.add(conditionField);
return fields;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
index 3ba2182..c5ccfe3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
@@ -34,9 +34,9 @@ import com.smartgwt.client.widgets.form.fields.events.ItemHoverEvent;
import com.smartgwt.client.widgets.form.fields.events.ItemHoverHandler;
import org.rhq.core.domain.alert.AlertDampening;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertDampening.Category;
import org.rhq.core.domain.alert.AlertDampening.TimeUnits;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -69,6 +69,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
private SelectItem durationTimeUnitsSelection;
private StaticTextItem durationTimeUnitsStatic;
+ private boolean updated;
+
public DampeningAlertDefinitionForm(String locatorId) {
this(locatorId, null);
}
@@ -76,6 +78,7 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
public DampeningAlertDefinitionForm(String locatorId, AlertDefinition alertDefinition) {
super(locatorId);
this.alertDefinition = alertDefinition;
+ this.updated = false;
}
@Override
@@ -237,6 +240,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
@Override
public void makeViewOnly() {
+ updated = false;
+
dampeningRuleSelection.hide();
dampeningRuleStatic.show();
@@ -318,6 +323,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
@Override
public void saveAlertDefinition() {
+ updated = false;
+
AlertDampening.Category cat = AlertDampening.Category.valueOf(dampeningRuleSelection.getValue().toString());
AlertDampening alertDampening = new AlertDampening(cat);
switch (cat) {
@@ -381,6 +388,11 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
markForRedraw();
}
+ @Override
+ public boolean isResetMatching() {
+ return updated;
+ }
+
private void buildForm() {
if (!formBuilt) {
dampeningRuleSelection = new SelectItem("dampeningRule", MSG.view_alert_common_tab_dampening());
@@ -413,8 +425,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
// nothing to do - the none category has no ui components to render
// CONSECUTIVE_COUNT
- consecutiveOccurrencesSpinner = new SpinnerItem("consecutiveOccurrencesSpinner", MSG
- .view_alert_common_tab_dampening_consecutive_occurrences_label());
+ consecutiveOccurrencesSpinner = new SpinnerItem("consecutiveOccurrencesSpinner",
+ MSG.view_alert_common_tab_dampening_consecutive_occurrences_label());
consecutiveOccurrencesSpinner.setWrapTitle(false);
consecutiveOccurrencesSpinner.setMin(1);
consecutiveOccurrencesSpinner.setMax(999999);
@@ -423,13 +435,19 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
consecutiveOccurrencesSpinner.setHoverWidth(300);
consecutiveOccurrencesSpinner.setTooltip(MSG
.view_alert_common_tab_dampening_consecutive_occurrences_label_tooltip());
- consecutiveOccurrencesStatic = new StaticTextItem("consecutiveOccurrencesStatic", MSG
- .view_alert_common_tab_dampening_consecutive_occurrences_label());
+ consecutiveOccurrencesStatic = new StaticTextItem("consecutiveOccurrencesStatic",
+ MSG.view_alert_common_tab_dampening_consecutive_occurrences_label());
consecutiveOccurrencesStatic.setWrapTitle(false);
+ consecutiveOccurrencesSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
// PARTIAL_COUNT
- partialOccurrencesSpinner = new SpinnerItem("partialOccurrencesSpinner", MSG
- .view_alert_common_tab_dampening_partial_occurrences_label());
+ partialOccurrencesSpinner = new SpinnerItem("partialOccurrencesSpinner",
+ MSG.view_alert_common_tab_dampening_partial_occurrences_label());
partialOccurrencesSpinner.setWrapTitle(false);
partialOccurrencesSpinner.setMin(1);
partialOccurrencesSpinner.setMax(999999);
@@ -438,12 +456,18 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
partialOccurrencesSpinner.setHoverWidth(300);
partialOccurrencesSpinner.setTooltip(MSG
.view_alert_common_tab_dampening_partial_occurrences_label_tooltip());
- partialOccurrencesStatic = new StaticTextItem("partialOccurrencesStatic", MSG
- .view_alert_common_tab_dampening_partial_occurrences_label());
+ partialOccurrencesStatic = new StaticTextItem("partialOccurrencesStatic",
+ MSG.view_alert_common_tab_dampening_partial_occurrences_label());
partialOccurrencesStatic.setWrapTitle(false);
- partialEvaluationsSpinner = new SpinnerItem("partialEvaluationsSpinner", MSG
- .view_alert_common_tab_dampening_partial_evalatuions_label());
+ partialOccurrencesSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
+ partialEvaluationsSpinner = new SpinnerItem("partialEvaluationsSpinner",
+ MSG.view_alert_common_tab_dampening_partial_evalatuions_label());
partialEvaluationsSpinner.setWrapTitle(false);
partialEvaluationsSpinner.setMin(1);
partialEvaluationsSpinner.setMax(999999);
@@ -452,13 +476,19 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
partialEvaluationsSpinner.setHoverWidth(300);
partialEvaluationsSpinner.setTooltip(MSG
.view_alert_common_tab_dampening_partial_evalatuions_label_tooltip());
- partialEvaluationsStatic = new StaticTextItem("partialEvaluationStatic", MSG
- .view_alert_common_tab_dampening_partial_evalatuions_label());
+ partialEvaluationsStatic = new StaticTextItem("partialEvaluationStatic",
+ MSG.view_alert_common_tab_dampening_partial_evalatuions_label());
partialEvaluationsStatic.setWrapTitle(false);
+ partialEvaluationsSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
// DURATION_COUNT
- durationOccurrencesSpinner = new SpinnerItem("durationOccurrencesSpinner", MSG
- .view_alert_common_tab_dampening_duration_occurrences_label());
+ durationOccurrencesSpinner = new SpinnerItem("durationOccurrencesSpinner",
+ MSG.view_alert_common_tab_dampening_duration_occurrences_label());
durationOccurrencesSpinner.setWrapTitle(false);
durationOccurrencesSpinner.setMin(1);
durationOccurrencesSpinner.setMax(999999);
@@ -467,12 +497,18 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
durationOccurrencesSpinner.setHoverWidth(300);
durationOccurrencesSpinner.setTooltip(MSG
.view_alert_common_tab_dampening_duration_occurrences_label_tooltip());
- durationOccurrencesStatic = new StaticTextItem("durationOccurrencesStatic", MSG
- .view_alert_common_tab_dampening_duration_occurrences_label());
+ durationOccurrencesStatic = new StaticTextItem("durationOccurrencesStatic",
+ MSG.view_alert_common_tab_dampening_duration_occurrences_label());
durationOccurrencesStatic.setWrapTitle(false);
- durationTimePeriodSpinner = new SpinnerItem("durationTimePeriodSpinner", MSG
- .view_alert_common_tab_dampening_duration_period_label());
+ durationOccurrencesSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
+ durationTimePeriodSpinner = new SpinnerItem("durationTimePeriodSpinner",
+ MSG.view_alert_common_tab_dampening_duration_period_label());
durationTimePeriodSpinner.setWrapTitle(false);
durationTimePeriodSpinner.setMin(1);
durationTimePeriodSpinner.setMax(999999);
@@ -480,10 +516,16 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
durationTimePeriodSpinner.setDefaultValue(1);
durationTimePeriodSpinner.setHoverWidth(300);
durationTimePeriodSpinner.setTooltip(MSG.view_alert_common_tab_dampening_duration_period_label_tooltip());
- durationTimePeriodStatic = new StaticTextItem("durationTimePeriodStatic", MSG
- .view_alert_common_tab_dampening_duration_period_label());
+ durationTimePeriodStatic = new StaticTextItem("durationTimePeriodStatic",
+ MSG.view_alert_common_tab_dampening_duration_period_label());
durationTimePeriodStatic.setWrapTitle(false);
+ durationTimePeriodSpinner.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
durationTimeUnitsSelection = new SelectItem("durationTimeUnits", "");
LinkedHashMap<String, String> units = new LinkedHashMap<String, String>(4);
units.put(AlertDampening.TimeUnits.MINUTES.name(), getTimeUnitsTitle(AlertDampening.TimeUnits.MINUTES));
@@ -494,9 +536,17 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
durationTimeUnitsSelection.setDefaultValue(AlertDampening.TimeUnits.MINUTES.name());
durationTimeUnitsStatic = new StaticTextItem("durationTimeUnitsStatic", "");
+ durationTimeUnitsSelection.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ updated = true;
+ }
+ });
+
dampeningRuleSelection.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
+ updated = true;
+
Category cat = AlertDampening.Category.valueOf(event.getValue().toString());
switch (cat) {
case NONE: {
@@ -536,8 +586,8 @@ public class DampeningAlertDefinitionForm extends LocatableDynamicForm implement
break;
}
default: {
- throw new IllegalStateException(MSG
- .view_alert_common_tab_invalid_dampening_category(cat.name())); // should never happen
+ throw new IllegalStateException(
+ MSG.view_alert_common_tab_invalid_dampening_category(cat.name())); // should never happen
}
}
markForRedraw();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
index 439ed3e..da4dfd3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
@@ -9,6 +9,8 @@ public interface EditAlertDefinitionForm {
AlertDefinition getAlertDefinition();
+ boolean isResetMatching();
+
void setAlertDefinition(AlertDefinition alertDef);
void makeEditable();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
index f154b26..fd07a64 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
@@ -32,8 +32,8 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableTextAreaFormItem;
import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableFormItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.SimpleEditableTextAreaFormItem;
import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -197,6 +197,10 @@ public class GeneralPropertiesAlertDefinitionForm extends LocatableDynamicForm i
markForRedraw();
}
+ @Override
+ public boolean isResetMatching() {
+ return false;
+ }
private void buildForm() {
if (!formBuilt) {
nameField = new SimpleEditableFormItem("name", MSG.common_title_name());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index fc0dbb1..b277077 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -198,7 +198,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals) {
if (alertDefinition.getId() == 0) {
GWTServiceLookup.getGroupAlertDefinitionService().createGroupAlertDefinitions(alertDefinition,
Integer.valueOf(this.group.getId()), new AsyncCallback<Integer>() {
@@ -216,7 +216,8 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
});
} else {
- GWTServiceLookup.getGroupAlertDefinitionService().updateGroupAlertDefinitions(alertDefinition, true,
+ GWTServiceLookup.getGroupAlertDefinitionService().updateGroupAlertDefinitions(alertDefinition,
+ purgeInternals,
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(AlertDefinition result) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
index 26dbae8..8a428df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -23,6 +23,9 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+import java.util.ArrayList;
+import java.util.List;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -38,6 +41,7 @@ import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.criteria.Criteria;
@@ -50,9 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author John Mazzitelli
*/
@@ -142,6 +143,11 @@ public class NotificationsAlertDefinitionForm extends LocatableVLayout implement
markForRedraw();
}
+ @Override
+ public boolean isResetMatching() {
+ return false;
+ }
+
private void buildForm() {
if (!formBuilt) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
index a3cfea1..0e8f1b2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
@@ -148,6 +148,11 @@ public class RecoveryAlertDefinitionForm extends LocatableDynamicForm implements
markForRedraw();
}
+ @Override
+ public boolean isResetMatching() {
+ return false;
+ }
+
private void buildForm() {
if (!formBuilt) {
disableWhenFiredSelection = new RadioGroupItem("disableWhenFired", MSG
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index e31e554..00aa951 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -194,7 +194,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals) {
if (alertDefinition.getId() == 0) {
GWTServiceLookup.getAlertDefinitionService().createAlertDefinition(alertDefinition,
Integer.valueOf(resource.getId()), new AsyncCallback<Integer>() {
@@ -213,7 +213,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
});
} else {
GWTServiceLookup.getAlertDefinitionService().updateAlertDefinition(alertDefinition.getId(),
- alertDefinition, true, new AsyncCallback<AlertDefinition>() {
+ alertDefinition, purgeInternals, new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(AlertDefinition result) {
CoreGUI.getMessageCenter().notify(
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index f276937..f2007ce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -70,8 +70,8 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
final LocatableTabSet tabSet = new LocatableTabSet(this.getLocatorId());
tabSet.setHeight100();
- final Tab generalPropertiesTab = new LocatableTab(tabSet.extendLocatorId("General"), MSG
- .view_alert_common_tab_general());
+ final Tab generalPropertiesTab = new LocatableTab(tabSet.extendLocatorId("General"),
+ MSG.view_alert_common_tab_general());
generalProperties = new GeneralPropertiesAlertDefinitionForm(this.getLocatorId(), alertDefinition);
generalPropertiesTab.setPane(generalProperties);
generalPropertiesTab.addTabDeselectedHandler(new TabDeselectedHandler() {
@@ -84,14 +84,14 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
}
});
- Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"), MSG
- .view_alert_common_tab_conditions());
+ Tab conditionsTab = new LocatableTab(tabSet.extendLocatorId("Conditions"),
+ MSG.view_alert_common_tab_conditions());
conditions = new ConditionsAlertDefinitionForm(this.getLocatorId(), alertDefView.getResourceType(),
alertDefinition);
conditionsTab.setPane(conditions);
- Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"), MSG
- .view_alert_common_tab_notifications());
+ Tab notificationsTab = new LocatableTab(tabSet.extendLocatorId("Notifications"),
+ MSG.view_alert_common_tab_notifications());
notifications = new NotificationsAlertDefinitionForm(this.getLocatorId(), alertDefinition);
notificationsTab.setPane(notifications);
@@ -134,11 +134,12 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
@Override
public void onClick(ClickEvent event) {
if (generalProperties.validate()) {
+ boolean resetMatching = isResetMatching();
saveAlertDefinition();
setAlertDefinition(getAlertDefinition()); // loads data into static fields
makeViewOnly();
- alertDefView.commitAlertDefinition(getAlertDefinition());
+ alertDefView.commitAlertDefinition(getAlertDefinition(), resetMatching);
} else {
tabSet.selectTab(generalPropertiesTab);
}
@@ -162,6 +163,10 @@ public class SingleAlertDefinitionView extends LocatableVLayout {
return alertDefinition;
}
+ public boolean isResetMatching() {
+ return conditions.isResetMatching() || dampening.isResetMatching();
+ }
+
public void setAlertDefinition(AlertDefinition alertDef) {
alertDefinition = alertDef;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index 93b3a91..987e62f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -206,7 +206,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals) {
if (alertDefinition.getId() == 0) {
GWTServiceLookup.getAlertTemplateService().createAlertTemplate(alertDefinition,
Integer.valueOf(this.resourceType.getId()), new AsyncCallback<Integer>() {
@@ -224,7 +224,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
});
} else {
- GWTServiceLookup.getAlertTemplateService().updateAlertTemplate(alertDefinition, true,
+ GWTServiceLookup.getAlertTemplateService().updateAlertTemplate(alertDefinition, purgeInternals,
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(AlertDefinition result) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
index ce73f0e..a356ff8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
@@ -32,8 +32,8 @@ public interface AlertDefinitionGWTService extends RemoteService {
int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException;
- AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition,
- boolean updateInternals) throws RuntimeException;
+ AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition, boolean purgeInternals)
+ throws RuntimeException;
int enableAlertDefinitions(int[] alertDefinitionIds) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
index 88a134a..01ba237 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
@@ -74,10 +74,10 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
@Override
public AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition,
- boolean updateInternals) throws RuntimeException {
+ boolean resetMatching) throws RuntimeException {
try {
AlertDefinition results = alertDefManager.updateAlertDefinition(getSessionSubject(), alertDefinitionId,
- alertDefinition, updateInternals);
+ alertDefinition, resetMatching);
return SerialUtility.prepare(results, "updateAlertDefinition");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java
index a26472e..bf87585 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionLogManagerBean.java
@@ -102,9 +102,6 @@ public class AlertConditionLogManagerBean implements AlertConditionLogManagerLoc
} catch (NoResultException nre) { // this is the expected case 90% of the time
// lookup the condition entity
AlertCondition condition = entityManager.find(AlertCondition.class, alertConditionId);
- if (condition == null) {
- // the associated AlertDefinition must have been updated, which removes all previous AlertConditions
- }
// persist the log entry
AlertConditionLog conditionLog = new AlertConditionLog(condition, ctime);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
index fa03aaf..6953bfc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerBean.java
@@ -60,6 +60,7 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
private AuthorizationManagerLocal authorizationManager;
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @Override
public Integer getAlertDefinitionByConditionIdInNewTransaction(int alertConditionId) {
try {
Query query = entityManager.createNamedQuery(AlertDefinition.QUERY_FIND_DEFINITION_ID_BY_CONDITION_ID);
@@ -77,6 +78,7 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
@SuppressWarnings("unchecked")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @Override
public PageList<? extends AbstractAlertConditionCategoryComposite> getAlertConditionComposites(Subject user,
Integer agentId, AlertConditionCategory category, PageControl pageControl) {
if (authorizationManager.isOverlord(user) == false) {
@@ -151,6 +153,7 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @Override
public InventoryStatus getResourceStatusByConditionId(int alertConditionId) {
try {
Query query = entityManager.createNamedQuery(AlertCondition.QUERY_FIND_RESOURCE_STATUS_BY_CONDITION_ID);
@@ -165,4 +168,10 @@ public class AlertConditionManagerBean implements AlertConditionManagerLocal {
}
}
+ @Override
+ public int purgeOrphanedAlertConditions() {
+ Query purgeQuery = entityManager.createNamedQuery(AlertCondition.QUERY_DELETE_ORPHANED);
+ return purgeQuery.executeUpdate();
+ }
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java
index f659716..4c27c75 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertConditionManagerLocal.java
@@ -44,4 +44,6 @@ public interface AlertConditionManagerLocal {
InventoryStatus getResourceStatusByConditionId(int alertConditionId);
+ int purgeOrphanedAlertConditions();
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index c1c9d93..5da131e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -451,9 +451,9 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public AlertDefinition updateAlertDefinition(Subject subject, int alertDefinitionId,
- AlertDefinition alertDefinition, boolean purgeInternals) throws InvalidAlertDefinitionException,
+ AlertDefinition alertDefinition, boolean resetMatching) throws InvalidAlertDefinitionException,
AlertDefinitionUpdateException {
- if (purgeInternals) {
+ if (resetMatching) {
alertDefinitionManager.purgeInternals(alertDefinitionId);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
index 03c8945..d663198 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
@@ -60,8 +60,19 @@ public interface AlertDefinitionManagerLocal {
void copyAlertDefinitions(Subject subject, Integer[] alertDefinitionIds);
+ /**
+ * @param subject
+ * @param alertDefinitionId
+ * @param alertDefinition
+ * @param resetMatching Incur the overhead of resetting any partial alert matching that has taken place. This *must*
+ * be set true if updating conditions, dampening rules or the conditionExpressin (ANY vs ALL). If in doubt, set to true
+ * as the loss of partial matching is better than corrupted matching.
+ * @return
+ * @throws InvalidAlertDefinitionException
+ * @throws AlertDefinitionUpdateException
+ */
AlertDefinition updateAlertDefinition(Subject subject, int alertDefinitionId, AlertDefinition alertDefinition,
- boolean updateInternals) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException;
+ boolean resetMatching) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException;
int purgeUnusedAlertDefinitions();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
index 8974c30..cde2f04 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
@@ -216,7 +216,7 @@ public class GroupAlertDefinitionManagerBean implements GroupAlertDefinitionMana
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public AlertDefinition updateGroupAlertDefinitions(Subject subject, AlertDefinition groupAlertDefinition,
- boolean purgeInternals) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException {
+ boolean resetMatching) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException {
if (LOG.isDebugEnabled()) {
LOG.debug("updateGroupAlertDefinition: " + groupAlertDefinition);
}
@@ -225,7 +225,7 @@ public class GroupAlertDefinitionManagerBean implements GroupAlertDefinitionMana
AlertDefinition updated = null;
try {
updated = alertDefinitionManager.updateAlertDefinition(subject, groupAlertDefinition.getId(),
- groupAlertDefinition, purgeInternals); // do not allow direct undeletes of an alert definition
+ groupAlertDefinition, resetMatching); // do not allow direct undeletes of an alert definition
} catch (Throwable t) {
throw new AlertDefinitionUpdateException("Failed to update a GroupAlertDefinition: "
+ groupAlertDefinition.toSimpleString(), t);
@@ -244,7 +244,7 @@ public class GroupAlertDefinitionManagerBean implements GroupAlertDefinitionMana
for (Integer alertDefinitionId : alertDefinitions) {
try {
alertDefinitionManager.updateAlertDefinition(overlord, alertDefinitionId, groupAlertDefinition,
- purgeInternals);
+ resetMatching);
} catch (Throwable t) {
// continue on error, update as many as possible
if (firstThrowable == null) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java
index 3db4ea9..13faf1d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerLocal.java
@@ -41,8 +41,18 @@ public interface GroupAlertDefinitionManagerLocal {
int disableGroupAlertDefinitions(Subject subject, Integer[] groupAlertDefinitionIds);
+ /**
+ * @param subject
+ * @param groupAlertDefinition
+ * @param resetMatching Incur the overhead of resetting any partial alert matching that has taken place. This *must*
+ * be set true if updating conditions, dampening rules or the conditionExpressin (ANY vs ALL). If in doubt, set to true
+ * as the loss of partial matching is better than corrupted matching.
+ * @return
+ * @throws InvalidAlertDefinitionException
+ * @throws AlertDefinitionUpdateException
+ */
AlertDefinition updateGroupAlertDefinitions(Subject subject, AlertDefinition groupAlertDefinition,
- boolean purgeInternals) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException;
+ boolean resetMatching) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException;
// required to implement system side-effects as a result of modifying group membership or deleting groups
void addGroupAlertDefinitions(Subject subject, int groupId, int[] resourcesIdsToAdd)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 79c7935..f7ae643 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -511,13 +511,14 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
PluginConfigurationUpdate.QUERY_DELETE_BY_RESOURCES_1, // first, delete the raw configs for the config
PluginConfigurationUpdate.QUERY_DELETE_BY_RESOURCES_2, // then delete the config objects
PluginConfigurationUpdate.QUERY_DELETE_BY_RESOURCES_3, // then the history objects wrapping those configs
- AlertConditionLog.QUERY_DELETE_BY_RESOURCES, // Don't
- AlertNotificationLog.QUERY_DELETE_BY_RESOURCES, // alter
- Alert.QUERY_DELETE_BY_RESOURCES, // order
- AlertCondition.QUERY_DELETE_BY_RESOURCES, // of
- AlertDampeningEvent.QUERY_DELETE_BY_RESOURCES, // alert-
- AlertNotification.QUERY_DELETE_BY_RESOURCES, // related
- AlertDefinition.QUERY_DELETE_BY_RESOURCES, // deletes
+ AlertConditionLog.QUERY_DELETE_BY_RESOURCES, // Don't
+ AlertConditionLog.QUERY_DELETE_BY_RESOURCES_BULK_DELETE, // alter
+ AlertNotificationLog.QUERY_DELETE_BY_RESOURCES, // the
+ Alert.QUERY_DELETE_BY_RESOURCES, // order
+ AlertCondition.QUERY_DELETE_BY_RESOURCES, // of
+ AlertDampeningEvent.QUERY_DELETE_BY_RESOURCES, // alert-
+ AlertNotification.QUERY_DELETE_BY_RESOURCES, // related
+ AlertDefinition.QUERY_DELETE_BY_RESOURCES, // deletes
JPADrift.QUERY_DELETE_BY_RESOURCES, // drift before changeset
JPADriftChangeSet.QUERY_DELETE_BY_RESOURCES };
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java
index 0cc04f4..dc8275c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJob.java
@@ -32,6 +32,7 @@ import org.quartz.StatefulJob;
import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.alert.AlertConditionManagerLocal;
import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
@@ -56,7 +57,6 @@ public class DataPurgeJob extends AbstractStatefulJob {
private static final Log LOG = LogFactory.getLog(DataPurgeJob.class);
private static long HOUR = 60 * 60 * 1000L;
- private static long DAY = 24L * HOUR;
/**
* Schedules a purge job to trigger right now. This will not block - it schedules the job to trigger but immediately
@@ -118,6 +118,7 @@ public class DataPurgeJob extends AbstractStatefulJob {
purgeEventData(LookupUtil.getEventManager(), systemConfig);
purgeAlertData(LookupUtil.getAlertManager(), systemConfig);
purgeUnusedAlertDefinitions(LookupUtil.getAlertDefinitionManager());
+ purgeOrphanedAlertConditions(LookupUtil.getAlertConditionManager());
purgeOrphanedAlertNotifications(LookupUtil.getAlertNotificationManager());
purgeMeasurementTraitData(LookupUtil.getMeasurementDataManager(), systemConfig);
purgeAvailabilityData(LookupUtil.getAvailabilityManager(), systemConfig);
@@ -239,6 +240,21 @@ public class DataPurgeJob extends AbstractStatefulJob {
}
}
+ private void purgeOrphanedAlertConditions(AlertConditionManagerLocal alertConditionManager) {
+ long timeStart = System.currentTimeMillis();
+ LOG.info("Alert condition orphan purge starting at " + new Date(timeStart));
+ int orphansPurged = 0;
+
+ try {
+ orphansPurged = alertConditionManager.purgeOrphanedAlertConditions();
+ } catch (Exception e) {
+ LOG.error("Failed to purge alert condition data. Cause: " + e, e);
+ } finally {
+ long duration = System.currentTimeMillis() - timeStart;
+ LOG.info("Purged [" + orphansPurged + "] orphan alert conditions - completed in [" + duration + "]ms");
+ }
+ }
+
private void purgeOrphanedAlertNotifications(AlertNotificationManagerLocal alertNotificationManager) {
long timeStart = System.currentTimeMillis();
LOG.info("Alert notification orphan purge starting at " + new Date(timeStart));
11 years, 11 months
[rhq] .classpath
by mazz
.classpath | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 18f46f5624b562364e6063451392905dc6e95725
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 20 14:04:02 2012 -0400
fix eclipse classpath - location for swizzle is wrong
diff --git a/.classpath b/.classpath
index 76e080c..9362891 100644
--- a/.classpath
+++ b/.classpath
@@ -241,7 +241,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/jbossws/jbossws-native-core/3.1.1.GA/jbossws-native-core-3.1.1.GA.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/maven/maven-project/2.0.8/maven-project-2.0.8.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/maven/maven-plugin-api/2.0.8/maven-plugin-api-2.0.8.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/codehaus/swizzle/1.6.1/swizzle-confluence-1.6.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/codehaus/swizzle/swizzle-confluence/1.6.1/swizzle-confluence-1.6.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jvnet/inflector/0.7.0/inflector-0.7.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/net/augeas/augeas/0.0.2/augeas-0.0.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/json/json/20080701/json-20080701.jar"/>
11 years, 11 months