[rhq] Branch 'heiko-rest' - modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit e48a90a80c62973ca2443750573174d21f799f99
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Sun Jul 31 23:09:36 2011 +0200
Argh, the Interceptors annotation had vanished - readding.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
index bd541a4..8cff7bc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
@@ -37,7 +37,7 @@ import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
* Deal with metrics
* @author Heiko W. Rupp
*/
-
+(a)Interceptors(SetCallerInterceptor.class)
@Stateless
public class MetricHandlerBean extends AbstractRestBean implements MetricHandlerLocal {
12 years, 4 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 26 +++++++---
1 file changed, 20 insertions(+), 6 deletions(-)
New commits:
commit c4a82bca1620900e3bb2c7353ca5425a1ee4b354
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 17:20:11 2011 -0400
[BZ-726508 - Can't create alert condition on certain metrics]
Since metric def names may not be unique, they are duplicated
for the 'Per Minute' version of certain metrics, don't use them
for the value map keys in alert def drop downs.
- Also, some of these metric name lists are long, sort the
menu entries.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 2fd9400..44875d8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,9 +24,11 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
+import java.util.TreeSet;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -572,7 +574,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.TRAIT) {
- traitsMap.put(def.getName(), def.getDisplayName());
+ traitsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -703,10 +705,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, boolean dynamicOnly, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
- for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ TreeSet<MeasurementDefinition> sortedDefs = new TreeSet<MeasurementDefinition>(
+ new Comparator<MeasurementDefinition>() {
+
+ @Override
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return o1.getDisplayName().compareTo(o2.getDisplayName());
+ }
+ });
+ sortedDefs.addAll(this.resourceType.getMetricDefinitions());
+
+ for (MeasurementDefinition def : sortedDefs) {
if (def.getDataType() == DataType.MEASUREMENT) {
if (!dynamicOnly || def.getNumericType() == NumericType.DYNAMIC) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ // use id as opposed to name for key, the name is not unique when per-minute metric is also used
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
}
@@ -726,7 +739,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.CALLTIME) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -790,9 +803,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
return help;
}
- private MeasurementDefinition getMeasurementDefinition(String metricName) {
+ private MeasurementDefinition getMeasurementDefinition(String metricId) {
+ int id = Integer.valueOf(metricId).intValue();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
- if (metricName.equals(def.getName())) {
+ if (id == def.getId()) {
return def;
}
}
12 years, 4 months
[rhq] Branch 'drift' - 2 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 26 +++++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 11 ++++
2 files changed, 31 insertions(+), 6 deletions(-)
New commits:
commit 608dffc9a54c653d6c27b560730fe939d72a0a0e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 17:20:11 2011 -0400
[BZ-726508 - Can't create alert condition on certain metrics]
Since metric def names may not be unique, they are duplicated
for the 'Per Minute' version of certain metrics, don't use them
for the value map keys in alert def drop downs.
- Also, some of these metric name lists are long, sort the
menu entries.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 2fd9400..44875d8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,9 +24,11 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
+import java.util.TreeSet;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -572,7 +574,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.TRAIT) {
- traitsMap.put(def.getName(), def.getDisplayName());
+ traitsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -703,10 +705,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, boolean dynamicOnly, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
- for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ TreeSet<MeasurementDefinition> sortedDefs = new TreeSet<MeasurementDefinition>(
+ new Comparator<MeasurementDefinition>() {
+
+ @Override
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return o1.getDisplayName().compareTo(o2.getDisplayName());
+ }
+ });
+ sortedDefs.addAll(this.resourceType.getMetricDefinitions());
+
+ for (MeasurementDefinition def : sortedDefs) {
if (def.getDataType() == DataType.MEASUREMENT) {
if (!dynamicOnly || def.getNumericType() == NumericType.DYNAMIC) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ // use id as opposed to name for key, the name is not unique when per-minute metric is also used
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
}
@@ -726,7 +739,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.CALLTIME) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -790,9 +803,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
return help;
}
- private MeasurementDefinition getMeasurementDefinition(String metricName) {
+ private MeasurementDefinition getMeasurementDefinition(String metricId) {
+ int id = Integer.valueOf(metricId).intValue();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
- if (metricName.equals(def.getName())) {
+ if (id == def.getId()) {
return def;
}
}
commit db8e0a195c7ef54dca2d137933d9f52b2bac9539
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 13:28:33 2011 -0400
[BZ-726714 - Metric template creation generates NPE (null pointer exception)]
Fix a problem when trying to apply a metric template to a resource in a
"hidden" state like UNINVENTORIED.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index 98110ac..03cd4bb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -498,6 +498,17 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
for (Integer resourceId : reqMap.keySet()) {
Agent agent = agentManager.getAgentByResourceId(subjectManager.getOverlord(), resourceId);
+ // Ignore resources that are not actually associated with an agent. For example,
+ // those with an UNINVENTORIED status.
+ if (null == agent) {
+ if (log.isDebugEnabled()) {
+ log.debug("Ignoring measurement schedule change for non-agent-related resource ["
+ + resourceId + "]. It is probably waiting to be uninventoried.");
+ }
+
+ continue;
+ }
+
Set<ResourceMeasurementScheduleRequest> agentUpdate = agentUpdates.get(agent);
if (agentUpdate == null) {
agentUpdate = new HashSet<ResourceMeasurementScheduleRequest>();
12 years, 4 months
[rhq] Branch 'drift' - 28 commits - modules/core modules/enterprise modules/plugins modules/test-utils
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java | 142 +++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftCriteria.java | 135 +++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java | 32
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java | 91 ++
modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java | 94 ++
modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftFileDTO.java | 50 +
modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java | 94 --
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java | 3
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java | 2
modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java | 2
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/GroupAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java | 405 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java | 128 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 365 +--------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection2.java | 367 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java | 48 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 42 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java | 3
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java | 5
modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerRemote.java | 18
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java | 2
modules/enterprise/server/plugins/drift-mongodb/pom.xml | 290 +++++++
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java | 217 +++++
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java | 122 +++
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java | 94 ++
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBFile.java | 49 +
modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml | 22
modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java | 95 ++
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java | 29
modules/enterprise/server/plugins/pom.xml | 1
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 12
modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java | 17
modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java | 11
63 files changed, 2583 insertions(+), 553 deletions(-)
New commits:
commit ff805de329d0aacfc2a9345987a1274a4e4d8930
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 16:54:51 2011 -0400
Adding a drift template
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index 21161fe..4cf5b2d 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -1191,6 +1191,18 @@
</configuration>
</content>
+ <drift-configuration name="Core Files">
+ <basedir>
+ <value-context>pluginConfiguration</value-context>
+ <value-name>jbossHomeDir</value-name>
+ </basedir>
+ <includes>
+ <include path="bin" />
+ <include path="lib" />
+ <include path="client" />
+ </includes>
+ </drift-configuration>
+
<bundle-target>
<destination-base-dir name="Install Directory" description="The top directory where the JBossAS Server is installed. (i.e. the value found in the 'JBoss Home Directory' connection property)">
<value-context>pluginConfiguration</value-context>
commit f7da51617e05e16c33791a92907e359c201e18ee
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 16:48:16 2011 -0400
emit a warning if the query returns us too much stuff
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index aee99cf..c51806a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -35,6 +35,8 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -64,6 +66,12 @@ public class DriftDetailsView extends LocatableVLayout {
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
@Override
public void onSuccess(PageList<Drift> result) {
+ if (result.getTotalSize() != 1) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Got [" + result.getTotalSize()
+ + "] results. Should have been 1. The details shown here might not be correct.",
+ Severity.Warning));
+ }
Drift drift = result.get(0);
show(drift);
}
@@ -78,6 +86,7 @@ public class DriftDetailsView extends LocatableVLayout {
private void show(Drift drift) {
for (Canvas child : getMembers()) {
removeMember(child);
+ child.destroy();
}
// the change set to which the drift belongs
commit b7c8d2f78a437a375f250d38de47dc08aa0e633c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 16:18:20 2011 -0400
make sure the URL id is prefexed with 0id_ so CoreGUI knows this is an ID
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 378350d..646c32f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
+import org.rhq.enterprise.gui.coregui.client.components.table.StringIDTableSection;
/**
* @author Greg Hinkle
@@ -218,14 +219,6 @@ public class LinkManager {
return link;
}
- public static String getSubsystemDriftHistoryLink(int resourceId, String driftId) {
- return "#Resource/" + resourceId + "/Drift/History/" + driftId;
- }
-
- public static String getSubsystemDriftConfigLink(int resourceId, int driftConfigId) {
- return "#Resource/" + resourceId + "/Drift/Config/" + driftConfigId;
- }
-
public static String getAutodiscoveryQueueLink() {
if (GWT) {
return "#Administration/Security/Auto%20Discovery%20Queue";
@@ -459,7 +452,14 @@ public class LinkManager {
return "#Bundles/Bundle/" + bundleId + "/deployments/" + bundleDeploymentId;
}
- public static String getDriftHistoryLink(int resourceId, int driftId) {
+ public static String getDriftHistoryLink(int resourceId, String driftId) {
+ if (!driftId.startsWith(StringIDTableSection.ID_PREFIX)) {
+ driftId = StringIDTableSection.ID_PREFIX + driftId;
+ }
return "#Resource/" + resourceId + "/Drift/History/" + driftId;
}
+
+ public static String getDriftConfigLink(int resourceId, int driftConfigId) {
+ return "#Resource/" + resourceId + "/Drift/Config/" + driftConfigId;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
index c4118af..1c5a333 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
@@ -93,7 +93,7 @@ public abstract class StringIDTableSection<DS extends RPCDataSource> extends Abs
@Override
public void showDetails(String id) {
if (id != null && id.length() > 0) {
- History.newItem(getBasePath() + "/" + id);
+ History.newItem(getBasePath() + "/" + convertIDToCurrentViewPath(id));
} else {
String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
.toString());
@@ -105,18 +105,24 @@ public abstract class StringIDTableSection<DS extends RPCDataSource> extends Abs
@Override
public abstract Canvas getDetailsView(String id);
- private static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
+ // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL is an ID.
+ public static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
@Override
protected String convertCurrentViewPathToID(String path) {
+ if (!path.startsWith(ID_PREFIX)) {
+ return path; // prefixed has already been stripped
+ }
return path.substring(ID_PREFIX.length()); // skip the initial "0id_" - see convertIDToCurrentViewPath for what this is all about
}
@Override
protected String convertIDToCurrentViewPath(String id) {
- // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL
- // is an ID. Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
+ // Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
// look like an ID to CoreGUI. We will strip this off when we convert this back to an ID - see convertCurrentViewPathToID
+ if (id.startsWith(ID_PREFIX)) {
+ return id; // it is already prefixed
+ }
return ID_PREFIX + id;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index 6f4bbf2..aee99cf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -20,6 +20,8 @@
package org.rhq.enterprise.gui.coregui.client.drift;
+import static org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
+
import java.util.LinkedHashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -30,34 +32,29 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.criteria.BasicDriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import static org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
-
/**
* @author Jay Shaughnessy
*/
-public class DriftDetailsView extends LocatableVLayout implements BookmarkableView {
+public class DriftDetailsView extends LocatableVLayout {
private String driftId;
- private static DriftDetailsView INSTANCE = new DriftDetailsView("DriftDetailsView");
-
- public static DriftDetailsView getInstance() {
- return INSTANCE;
+ public DriftDetailsView(String locatorId, String driftId) {
+ super(locatorId);
+ this.driftId = driftId;
+ setMembersMargin(10);
}
- private DriftDetailsView(String id) {
- // access through the static singleton only (see renderView)
- super(id);
-
- setMembersMargin(10);
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ show(this.driftId);
}
private void show(String driftId) {
@@ -80,7 +77,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
private void show(Drift drift) {
for (Canvas child : getMembers()) {
- removeChild(child);
+ removeMember(child);
}
// the change set to which the drift belongs
@@ -157,11 +154,4 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
addMember(driftForm);
}
-
- @Override
- public void renderView(ViewPath viewPath) {
- driftId = viewPath.getCurrent().getPath();
- show(driftId);
- }
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index 060c9d1..cf42485 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -156,7 +156,7 @@ public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
public String format(Object value, ListGridRecord record, int i, int i1) {
Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
String driftId = getId(record);
- String url = LinkManager.getSubsystemDriftHistoryLink(resourceId, driftId);
+ String url = LinkManager.getDriftHistoryLink(resourceId, driftId);
String formattedValue = TimestampCellFormatter.format(value);
return SeleniumUtility.getLocatableHref(url, formattedValue, null);
}
@@ -285,7 +285,7 @@ public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
@Override
public Canvas getDetailsView(String driftId) {
- return DriftDetailsView.getInstance();
+ return new DriftDetailsView(extendLocatorId("Details"), driftId);
}
public EntityContext getContext() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index 3ee0b5f..51f2ec2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -47,7 +47,7 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
protected String getNodeTargetLink(TreeNode node) {
if (node instanceof DriftTreeNode) {
String driftIdStr = node.getAttribute(AbstractDriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
- String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, driftIdStr);
return path;
}
return null;
commit 385db545221d5aa7bcbdca6abc23b3ffbb294d70
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 15:13:29 2011 -0400
factor TableSection to support string IDs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 85f5e92..1c52477 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -53,8 +53,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceT
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
-import org.rhq.enterprise.gui.coregui.client.test.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.TestDataSourceResponseStatisticsView;
+import org.rhq.enterprise.gui.coregui.client.test.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.TestTopView;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -383,6 +383,11 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String>, Event.Na
} else {
if (view.matches(TREE_NAV_VIEW_PATTERN)) {
// e.g. "Resource/10001" or "Resource/AutoGroup/10003"
+ // TODO: need to support string IDs "Drift/History/0id_abcdefghijk"
+ // TODO: see StringIDTableSection.ID_PREFIX
+ // TODO: remember \D is a non-digit, and \d is a digit
+ // TODO: String suffix = currentViewPath.replaceFirst("\\D*[^/]*", ""); // this might be OK if 0id_ starts with a digit
+ // TODO: suffix = suffix.replaceFirst("((\\d.*)|(0id_[^/]*))", "");
if (!currentViewPath.startsWith(view)) {
// The Node that was selected is not the same Node that was previously selected - it
// may not even be the same node type. For example, the user could have moved from a
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
index 115d4a8..bfa9ae6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
@@ -26,9 +26,9 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
import com.smartgwt.client.widgets.grid.events.CellClickEvent;
import com.smartgwt.client.widgets.grid.events.CellClickHandler;
+
import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
@@ -85,7 +85,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
addTableAction(extendLocatorId("New"), MSG.common_button_new(), createNewAction());
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), getDeleteConfirmMessage(),
- createDeleteAction());
+ createDeleteAction());
super.configureTable();
}
@@ -184,7 +184,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
}
@Override
- public Canvas getDetailsView(int roleId) {
+ public Canvas getDetailsView(Integer roleId) {
return new RoleEditView(extendLocatorId("Detail"), roleId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index 427b1c2..4fdd6e5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -26,9 +26,9 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
import com.smartgwt.client.widgets.grid.events.CellClickEvent;
import com.smartgwt.client.widgets.grid.events.CellClickHandler;
+
import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
@@ -211,7 +211,8 @@ public class UsersView extends TableSection<UsersDataSource> {
};
}
- public Canvas getDetailsView(int subjectId) {
+ @Override
+ public Canvas getDetailsView(Integer subjectId) {
return new UserEditView(extendLocatorId("Detail"), subjectId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
index 45dd32c..3fa6202 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
@@ -277,7 +277,7 @@ public class AlertHistoryView extends TableSection<AlertDataSource> {
}
@Override
- public Canvas getDetailsView(int alertId) {
+ public Canvas getDetailsView(Integer alertId) {
return AlertDetailsView.getInstance();
}
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 c49fc4f..7f2cce0 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
@@ -134,7 +134,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
}
@Override
- public SingleAlertDefinitionView getDetailsView(final int id) {
+ public SingleAlertDefinitionView getDetailsView(final Integer id) {
final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
.extendLocatorId("singleAlertDefinitionView"), this);
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 9fa9c31..fc0dbb1 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
@@ -93,7 +93,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
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 ea41bc2..e31e554 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
@@ -93,7 +93,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
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 688dea4..755c8d7 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
@@ -100,7 +100,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
index df8a406..7178269 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
@@ -39,7 +39,6 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.DetailsView;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
@@ -49,10 +48,16 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
+ * Provides the typical table view with the additional ability of traversing to a "details" view
+ * when double-clicking a individual row in the table - a masters/detail view in effect.
+ *
+ * @param <DS> the datasource used to obtain data for the table
+ * @param <ID> the type used for IDs. This identifies the type used to uniquely refer to a row in the table
+ *
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
+public abstract class AbstractTableSection<DS extends RPCDataSource, ID> extends Table<DS> implements BookmarkableView {
private VLayout detailsHolder;
private Canvas detailsView;
@@ -60,38 +65,39 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
private boolean escapeHtmlInDetailsLinkColumn;
private boolean initialDisplay;
- protected TableSection(String locatorId, String tableTitle) {
+ protected AbstractTableSection(String locatorId, String tableTitle) {
super(locatorId, tableTitle);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria) {
super(locatorId, tableTitle, criteria);
}
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ protected AbstractTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
super(locatorId, tableTitle, sortSpecifiers);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers) {
super(locatorId, tableTitle, sortSpecifiers, criteria);
}
- protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ protected AbstractTableSection(String locatorId, String tableTitle, boolean autoFetchData) {
super(locatorId, tableTitle, autoFetchData);
}
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ protected AbstractTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
String[] excludedFieldNames) {
super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers, String[] excludedFieldNames) {
super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames, boolean autoFetchData) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers, String[] excludedFieldNames, boolean autoFetchData) {
super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
}
@@ -177,8 +183,8 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
if (value == null) {
return "";
}
- Integer recordId = getId(record);
- String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ ID recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + convertIDToCurrentViewPath(recordId);
String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
: value.toString();
return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
@@ -190,7 +196,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* Shows the details view for the given record of the table.
*
* The default implementation of this method assumes there is an
- * id attribute on the record and passes it to {@link #showDetails(int)}.
+ * id attribute on the record and passes it to {@link #showDetails(Object)}.
* Subclasses are free to override this behavior. Subclasses usually
* will need to set the {@link #setDetailsView(Canvas) details view}
* explicitly.
@@ -202,7 +208,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
throw new IllegalArgumentException("'record' parameter is null.");
}
- Integer id = getId(record);
+ ID id = getId(record);
showDetails(id);
}
@@ -210,7 +216,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* Returns the details canvas with information on the item given its list grid record.
*
* The default implementation of this method is to assume there is an
- * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
+ * id attribute on the record and pass that ID to {@link #getDetailsView(Object)}.
* Subclasses are free to override this - which you usually want to do
* if you know the full details of the item are stored in the record attributes
* and thus help avoid making a round trip to the DB.
@@ -218,66 +224,76 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
*/
public Canvas getDetailsView(ListGridRecord record) {
- Integer id = getId(record);
+ ID id = getId(record);
return getDetailsView(id);
}
- protected Integer getId(ListGridRecord record) {
- Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
- if (id == null) {
- String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalStateException(msg);
- }
- return id;
- }
+ /**
+ * Subclasses define how they want to format their identifiers. These uniquely identify
+ * rows in the table. Typical values/types for IDs are Integers or Strings.
+ *
+ * @param record the individual record that contains the ID to be extracted and returned
+ *
+ * @return the ID of the given row/record from the table.
+ */
+ protected abstract ID getId(ListGridRecord record);
/**
* Shows empty details for a new item being created.
* This method is usually called when a user clicks a 'New' button.
*
+ * Subclasses are free to override this if they need a custom way to show the details view.
+ *
* @see #showDetails(ListGridRecord)
*/
public void newDetails() {
- History.newItem(basePath + "/0");
+ History.newItem(basePath + "/0"); // assumes the subclasses will understand "0" means "new details page"
}
/**
- * Shows the details for an item has the given ID.
+ * Shows the details for an item that has the given ID.
* This method is usually called when a user goes to the details
* page via a bookmark, double-cick on a list view row, or direct link.
*
- * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
+ * @param id the id of the row whose details are to be shown; Must be a valid ID.
*
* @see #showDetails(ListGridRecord)
*
- * @throws IllegalArgumentException if id <= 0.
+ * @throws IllegalArgumentException if id is invalid
*/
- public void showDetails(int id) {
- if (id > 0) {
- History.newItem(basePath + "/" + id);
- } else {
- String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalArgumentException(msg);
- }
- }
+ public abstract void showDetails(ID id);
/**
* Returns the details canvas with information on the item that has the given ID.
* Note that an empty details view should be returned if the id passed in is 0 (as would
* be the case if a new item is to be created using the details view).
*
- * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
+ * @param id the id of the details to be shown; will be "0" if an empty details view should be shown.
+ */
+ public abstract Canvas getDetailsView(ID id);
+
+ /**
+ * Given the path from the URL that identifies the ID, this returns the ID represented by that path string.
+ * @param path the path as it was found in the current view path (i.e. in the URL)
+ * @return the ID that identifies the item referred to by the URL
+ */
+ protected abstract ID convertCurrentViewPathToID(String path);
+
+ /**
+ * Given the ID of a particular item, this returns a path string suitable for placement in a URL such that that URL will
+ * identify the particular item.
+ *
+ * @return how the ID can be represented within a view path (i.e. in a URL)
+ * @param id the ID that identifies the item to be referred by in a URL
*/
- public abstract Canvas getDetailsView(int id);
+ protected abstract String convertIDToCurrentViewPath(ID id);
@Override
public void renderView(ViewPath viewPath) {
this.basePath = viewPath.getPathToCurrent();
if (!viewPath.isEnd()) {
- int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ ID id = convertCurrentViewPathToID(viewPath.getCurrent().getPath());
this.detailsView = getDetailsView(id);
if (this.detailsView instanceof BookmarkableView) {
((BookmarkableView) this.detailsView).renderView(viewPath);
@@ -325,7 +341,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* detailsView in edit-mode, the content canvas will already be hidden, which means the
* animateHide would be a no-op (the event won't fire). this causes the detailsHolder
* to keep a reference to the previous detailsView (the one in create-mode) instead of the
- * newly returned reference from getDetailsView(int) that was called when the renderView
+ * newly returned reference from getDetailsView(ID) that was called when the renderView
* methods were called hierarchically down to render the new detailsView in edit-mode.
* therefore, we need to explicitly destroy what's already there (presumably the detailsView
* in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
new file mode 100644
index 0000000..c4118af
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
@@ -0,0 +1,122 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * The TableSection abstract implementation that supports IDs as basic Strings.
+ *
+ * Use this if you have tabular data whose rows are not identified with Integers but
+ * some other non-numeric string.
+ *
+ * If you have tabular data whose rows have integer IDs, use {@link TableSection}.
+ *
+ * @author John Mazzitelli
+ */
+public abstract class StringIDTableSection<DS extends RPCDataSource> extends AbstractTableSection<DS, String> {
+
+ public StringIDTableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, sortSpecifiers, excludedFieldNames);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ @Override
+ protected String getId(ListGridRecord record) {
+ String id = null;
+ if (record != null) {
+ id = record.getAttribute("id");
+ }
+
+ if (id == null || id.length() == 0) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ @Override
+ public void showDetails(String id) {
+ if (id != null && id.length() > 0) {
+ History.newItem(getBasePath() + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
+ .toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ @Override
+ public abstract Canvas getDetailsView(String id);
+
+ private static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
+
+ @Override
+ protected String convertCurrentViewPathToID(String path) {
+ return path.substring(ID_PREFIX.length()); // skip the initial "0id_" - see convertIDToCurrentViewPath for what this is all about
+ }
+
+ @Override
+ protected String convertIDToCurrentViewPath(String id) {
+ // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL
+ // is an ID. Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
+ // look like an ID to CoreGUI. We will strip this off when we convert this back to an ID - see convertCurrentViewPathToID
+ return ID_PREFIX + id;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
new file mode 100644
index 0000000..3eb65c5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * The TableSection abstract implementation that supports IDs as Integers.
+ *
+ * Since most master/detail table views have Integers for IDs that uniquely identify
+ * rows in the table, this is the typical superclass implementation used for
+ * most of RHQ's concrete TableSection views.
+ *
+ * @author John Mazzitelli
+ */
+public abstract class TableSection<DS extends RPCDataSource> extends AbstractTableSection<DS, Integer> {
+
+ public TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ public TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers, String[] excludedFieldNames) {
+ super(locatorId, tableTitle, sortSpecifiers, excludedFieldNames);
+ }
+
+ public TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ public TableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ @Override
+ protected Integer getId(ListGridRecord record) {
+ Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
+ if (id == null) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ @Override
+ public void showDetails(Integer id) {
+ if (id != null && id.intValue() > 0) {
+ History.newItem(getBasePath() + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
+ .toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ @Override
+ public abstract Canvas getDetailsView(Integer id);
+
+ @Override
+ protected Integer convertCurrentViewPathToID(String path) {
+ return Integer.valueOf(path);
+ }
+
+ @Override
+ protected String convertIDToCurrentViewPath(Integer id) {
+ if (id == null) {
+ return "0";
+ }
+ return id.toString();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
index 071e2de..f090bd8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
@@ -226,7 +226,7 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
}
@Override
- public Canvas getDetailsView(int driftConfigId) {
+ public Canvas getDetailsView(Integer driftConfigId) {
return new DriftConfigurationEditView(extendLocatorId("ConfigEdit"), context, driftConfigId, hasWriteAccess);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index f00640a..060c9d1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -42,9 +42,9 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.StringIDTableSection;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection2;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*
* @author Jay Shaughnessy
*/
-public class DriftHistoryView extends TableSection2<DriftDataSource> {
+public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
public static final ViewName SUBSYSTEM_VIEW_ID = new ViewName("RecentDrifts", MSG.common_title_recent_drifts());
@@ -283,7 +283,6 @@ public class DriftHistoryView extends TableSection2<DriftDataSource> {
// });
// }
-
@Override
public Canvas getDetailsView(String driftId) {
return DriftDetailsView.getInstance();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index fa623f1..e146f0e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -211,7 +211,7 @@ public class EventCompositeHistoryView extends TableSection<EventCompositeDataso
}
@Override
- public Canvas getDetailsView(int eventId) {
+ public Canvas getDetailsView(Integer eventId) {
return EventCompositeDetailsView.getInstance();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
index 7e1d548..4a6db81 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
@@ -128,26 +128,26 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
nextCalculationTimeField);
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
- new AbstractTableAction(TableActionEnablement.ANY) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- final int[] groupDefinitionIds = TableUtility.getIds(selection);
- ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(60000);
- groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_dynagroup_deleteSuccessfulSelection(String
- .valueOf(groupDefinitionIds.length)), Severity.Info));
- GroupDefinitionListView.this.refresh();
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_deleteFailureSelection(), caught);
- }
- });
- }
- });
+ new AbstractTableAction(TableActionEnablement.ANY) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ final int[] groupDefinitionIds = TableUtility.getIds(selection);
+ ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(60000);
+ groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_dynagroup_deleteSuccessfulSelection(String
+ .valueOf(groupDefinitionIds.length)), Severity.Info));
+ GroupDefinitionListView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_deleteFailureSelection(), caught);
+ }
+ });
+ }
+ });
addTableAction(extendLocatorId("New"), MSG.common_button_new(), null, new AbstractTableAction() {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -180,7 +180,7 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
final SingleGroupDefinitionView singleGroupDefinitionView = new SingleGroupDefinitionView(this
.extendLocatorId("Details"));
return singleGroupDefinitionView;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
index f1c7cfa..10d2cb9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
@@ -74,7 +74,7 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
}
@Override
- public Canvas getDetailsView(int definitionId) {
+ public Canvas getDetailsView(Integer definitionId) {
return new TraitsDetailView(extendLocatorId("Detail"), this.groupId, definitionId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
index b9eb6bb..03dde04 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
@@ -80,7 +80,7 @@ public class GroupMemberResourceOperationHistoryListView extends
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(extendLocatorId("DetailsView"), true);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
index 8ad3170..ecf55ca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
@@ -45,7 +45,7 @@ public class GroupOperationHistoryListView extends AbstractOperationHistoryListV
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new GroupOperationHistoryDetailsView(extendLocatorId("DetailsView"), this.groupComposite);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
index 7f9c2f1..6561291 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
@@ -20,6 +20,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
import com.smartgwt.client.widgets.Canvas;
+
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleListView;
@@ -45,9 +46,8 @@ public class GroupOperationScheduleListView extends AbstractOperationScheduleLis
}
@Override
- public Canvas getDetailsView(int scheduleId) {
- return new GroupOperationScheduleDetailsView(extendLocatorId("DetailsView"),
- this.groupComposite, scheduleId);
+ public Canvas getDetailsView(Integer scheduleId) {
+ return new GroupOperationScheduleDetailsView(extendLocatorId("DetailsView"), this.groupComposite, scheduleId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index c445d32..50fbc30 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -58,7 +58,7 @@ public class ConfigurationHistoryView extends AbstractConfigurationHistoryView<C
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
ConfigurationHistoryDetailView detailView = new ConfigurationHistoryDetailView(this.getLocatorId());
return detailView;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
index fdd6657..4fad987 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
@@ -60,7 +60,7 @@ public class PluginConfigurationHistoryView extends
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
PluginConfigurationHistoryDetailView detailView = new PluginConfigurationHistoryDetailView(this.getLocatorId());
return detailView;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
index 55a6f99..fe7b9ec 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
@@ -38,7 +38,7 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
}
@Override
- public Canvas getDetailsView(int definitionId) {
+ public Canvas getDetailsView(Integer definitionId) {
return new TraitsDetailView(extendLocatorId("Detail"), this.resourceId, definitionId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
index 3d64039..a222b73 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -47,7 +47,7 @@ public class ResourceOperationHistoryListView extends OperationHistoryView {
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(this.extendLocatorId("DetailsView"));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
index 221390c..859747a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
@@ -46,9 +46,9 @@ public class ResourceOperationScheduleListView extends AbstractOperationSchedule
}
@Override
- public Canvas getDetailsView(int scheduleId) {
- return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"),
- this.resourceComposite, scheduleId);
+ public Canvas getDetailsView(Integer scheduleId) {
+ return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"), this.resourceComposite,
+ scheduleId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
index 70a5ff9..5461aa0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
@@ -23,13 +23,9 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
@@ -191,7 +187,8 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
final List<Integer> successIds = new ArrayList<Integer>();
final List<Integer> failureIds = new ArrayList<Integer>();
for (ListGridRecord record : recordsToBeDeleted) {
- final ResourceOperationHistory operationHistoryToRemove = new OperationHistoryDataSource().copyValues(record);
+ final ResourceOperationHistory operationHistoryToRemove = new OperationHistoryDataSource()
+ .copyValues(record);
GWTServiceLookup.getOperationService().deleteOperationHistory(operationHistoryToRemove.getId(), force,
new AsyncCallback<Void>() {
public void onSuccess(Void result) {
@@ -202,7 +199,7 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
public void onFailure(Throwable caught) {
// TODO: i18n
CoreGUI.getErrorHandler().handleError("Failed to delete " + operationHistoryToRemove + ".",
- caught);
+ caught);
failureIds.add(operationHistoryToRemove.getId());
handleCompletion(successIds, failureIds, numberOfRecordsToBeDeleted);
}
@@ -214,10 +211,13 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
if ((successIds.size() + failureIds.size()) == numberOfRecordsToBeDeleted) {
// TODO: i18n
if (successIds.size() == numberOfRecordsToBeDeleted) {
- CoreGUI.getMessageCenter().notify(new Message("Deleted " + numberOfRecordsToBeDeleted + " operation history items."));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Deleted " + numberOfRecordsToBeDeleted + " operation history items."));
} else {
- CoreGUI.getMessageCenter().notify(new Message("Deleted " + successIds.size()
- + " operation history items, but failed to delete the items with the following IDs: " + failureIds));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Deleted " + successIds.size()
+ + " operation history items, but failed to delete the items with the following IDs: "
+ + failureIds));
}
refresh();
}
@@ -228,7 +228,7 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(extendLocatorId("Detail"));
}
@@ -237,5 +237,4 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
return OperationHistoryDataSource.Field.OPERATION_NAME;
}
-
}
commit 66bcc38c099082f3077f7cf5f1b0429cb826f2d8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 15:13:12 2011 -0400
rename TableSection to AbstractTableSection to prepare for refactoring of the TableSection hierarchy
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
new file mode 100644
index 0000000..df8a406
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
@@ -0,0 +1,389 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.AnimationEffect;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.AnimationCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.DetailsView;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
+
+ private VLayout detailsHolder;
+ private Canvas detailsView;
+ private String basePath;
+ private boolean escapeHtmlInDetailsLinkColumn;
+ private boolean initialDisplay;
+
+ protected TableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers, criteria);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ this.initialDisplay = true;
+
+ detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
+ detailsHolder.setAlign(VerticalAlignment.TOP);
+ //detailsHolder.setWidth100();
+ //detailsHolder.setHeight100();
+ detailsHolder.setMargin(4);
+ detailsHolder.hide();
+
+ addMember(detailsHolder);
+
+ // if the detailsView is already defined it means we want the details view to be rendered prior to
+ // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
+ if (null != detailsView) {
+ switchToDetailsView();
+ }
+ }
+
+ /**
+ * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
+ * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
+ * view, given the 'id'. Also, establishes a double click handler for the row which invokes
+ * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
+ * </br>
+ * In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
+ *
+ * @see org.rhq.enterprise.gui.coregui.client.components.table.Table#configureTable()
+ */
+ @Override
+ protected void configureTable() {
+ if (isDetailsEnabled()) {
+ ListGrid grid = getListGrid();
+
+ // Make the value of some specific field a link to the details view for the corresponding record.
+ ListGridField field = (grid != null) ? grid.getField(getDetailsLinkColumnName()) : null;
+ if (field != null) {
+ field.setCellFormatter(getDetailsLinkColumnCellFormatter());
+ }
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ showDetails(selectedRows[0]);
+ }
+ }
+ });
+ }
+ }
+
+ protected boolean isDetailsEnabled() {
+ return true;
+ }
+
+ public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
+ this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
+ }
+
+ /**
+ * Override if you don't want FIELD_NAME to be wrapped ina link.
+ * @return the name of the field to be wrapped, or null if no field should be wrapped.
+ */
+ protected String getDetailsLinkColumnName() {
+ return FIELD_NAME;
+ }
+
+ /**
+ * Override if you don't want the detailsLinkColumn to have the default link wrapper.
+ * @return the desired CellFormatter.
+ */
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ if (value == null) {
+ return "";
+ }
+ Integer recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
+ : value.toString();
+ return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
+ }
+ };
+ }
+
+ /**
+ * Shows the details view for the given record of the table.
+ *
+ * The default implementation of this method assumes there is an
+ * id attribute on the record and passes it to {@link #showDetails(int)}.
+ * Subclasses are free to override this behavior. Subclasses usually
+ * will need to set the {@link #setDetailsView(Canvas) details view}
+ * explicitly.
+ *
+ * @param record the record whose details are to be shown
+ */
+ public void showDetails(ListGridRecord record) {
+ if (record == null) {
+ throw new IllegalArgumentException("'record' parameter is null.");
+ }
+
+ Integer id = getId(record);
+ showDetails(id);
+ }
+
+ /**
+ * Returns the details canvas with information on the item given its list grid record.
+ *
+ * The default implementation of this method is to assume there is an
+ * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
+ * Subclasses are free to override this - which you usually want to do
+ * if you know the full details of the item are stored in the record attributes
+ * and thus help avoid making a round trip to the DB.
+ *
+ * @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
+ */
+ public Canvas getDetailsView(ListGridRecord record) {
+ Integer id = getId(record);
+ return getDetailsView(id);
+ }
+
+ protected Integer getId(ListGridRecord record) {
+ Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
+ if (id == null) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ /**
+ * Shows empty details for a new item being created.
+ * This method is usually called when a user clicks a 'New' button.
+ *
+ * @see #showDetails(ListGridRecord)
+ */
+ public void newDetails() {
+ History.newItem(basePath + "/0");
+ }
+
+ /**
+ * Shows the details for an item has the given ID.
+ * This method is usually called when a user goes to the details
+ * page via a bookmark, double-cick on a list view row, or direct link.
+ *
+ * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
+ *
+ * @see #showDetails(ListGridRecord)
+ *
+ * @throws IllegalArgumentException if id <= 0.
+ */
+ public void showDetails(int id) {
+ if (id > 0) {
+ History.newItem(basePath + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Returns the details canvas with information on the item that has the given ID.
+ * Note that an empty details view should be returned if the id passed in is 0 (as would
+ * be the case if a new item is to be created using the details view).
+ *
+ * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
+ */
+ public abstract Canvas getDetailsView(int id);
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ this.basePath = viewPath.getPathToCurrent();
+
+ if (!viewPath.isEnd()) {
+ int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ this.detailsView = getDetailsView(id);
+ if (this.detailsView instanceof BookmarkableView) {
+ ((BookmarkableView) this.detailsView).renderView(viewPath);
+ }
+
+ switchToDetailsView();
+ } else {
+ switchToTableView();
+ }
+ }
+
+ protected String getBasePath() {
+ return this.basePath;
+ }
+
+ /**
+ * For use by subclasses that want to define their own details view.
+ *
+ * @param detailsView the new details view
+ */
+ protected void setDetailsView(Canvas detailsView) {
+ this.detailsView = detailsView;
+ }
+
+ /**
+ * Switches to viewing the details canvas, hiding the table. This does not
+ * do anything with reloading data or switching to the selected row in the table;
+ * this only changes the visibility of canvases.
+ */
+ protected void switchToDetailsView() {
+ Canvas contents = getTableContents();
+
+ // If the Table has not yet been initialized then ignore
+ if (contents != null) {
+ if (contents.isVisible()) {
+ contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ buildDetailsView();
+ }
+ });
+ } else {
+ /*
+ * if the programmer chooses to go directly from the detailView in create-mode to the
+ * detailsView in edit-mode, the content canvas will already be hidden, which means the
+ * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
+ * to keep a reference to the previous detailsView (the one in create-mode) instead of the
+ * newly returned reference from getDetailsView(int) that was called when the renderView
+ * methods were called hierarchically down to render the new detailsView in edit-mode.
+ * therefore, we need to explicitly destroy what's already there (presumably the detailsView
+ * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
+ */
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ buildDetailsView();
+ }
+ }
+ }
+
+ private void buildDetailsView() {
+ detailsView.setWidth100();
+ detailsView.setHeight100();
+
+ boolean isEditable = (detailsView instanceof DetailsView && ((DetailsView) detailsView).isEditable());
+ if (!isEditable) {
+ // Only add the "Back to List" button if the details are definitely not editable, because if they are
+ // editable, a Cancel button should already be provided by the details view.
+ BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_tableSection_backButton(),
+ basePath);
+ detailsHolder.addMember(backButton);
+ VLayout verticalSpacer = new LocatableVLayout(extendLocatorId("verticalSpacer"));
+ verticalSpacer.setHeight(8);
+ detailsHolder.addMember(verticalSpacer);
+ }
+
+ detailsHolder.addMember(detailsView);
+ detailsHolder.animateShow(AnimationEffect.WIPE);
+ }
+
+ /**
+ * Switches to viewing the table, hiding the details canvas.
+ */
+ protected void switchToTableView() {
+ final Canvas contents = getTableContents();
+ if (contents != null) {
+ // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
+ // redundant, since the data was just loaded when the table was drawn.
+ if (this.initialDisplay) {
+ this.initialDisplay = false;
+ } else {
+ Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
+ refresh();
+ }
+ if (detailsHolder != null && detailsHolder.isVisible()) {
+ detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ });
+ } else {
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
deleted file mode 100644
index df8a406..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.components.table;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.user.client.History;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.SortSpecifier;
-import com.smartgwt.client.types.AnimationEffect;
-import com.smartgwt.client.types.VerticalAlignment;
-import com.smartgwt.client.widgets.AnimationCallback;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.DetailsView;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-
-/**
- * @author Greg Hinkle
- * @author John Mazzitelli
- */
-public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
-
- private VLayout detailsHolder;
- private Canvas detailsView;
- private String basePath;
- private boolean escapeHtmlInDetailsLinkColumn;
- private boolean initialDisplay;
-
- protected TableSection(String locatorId, String tableTitle) {
- super(locatorId, tableTitle);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
- super(locatorId, tableTitle, criteria);
- }
-
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
- super(locatorId, tableTitle, sortSpecifiers);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
- super(locatorId, tableTitle, sortSpecifiers, criteria);
- }
-
- protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
- super(locatorId, tableTitle, autoFetchData);
- }
-
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
- super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
- super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames, boolean autoFetchData) {
- super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- this.initialDisplay = true;
-
- detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
- detailsHolder.setAlign(VerticalAlignment.TOP);
- //detailsHolder.setWidth100();
- //detailsHolder.setHeight100();
- detailsHolder.setMargin(4);
- detailsHolder.hide();
-
- addMember(detailsHolder);
-
- // if the detailsView is already defined it means we want the details view to be rendered prior to
- // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
- if (null != detailsView) {
- switchToDetailsView();
- }
- }
-
- /**
- * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
- * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
- * view, given the 'id'. Also, establishes a double click handler for the row which invokes
- * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
- * </br>
- * In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
- *
- * @see org.rhq.enterprise.gui.coregui.client.components.table.Table#configureTable()
- */
- @Override
- protected void configureTable() {
- if (isDetailsEnabled()) {
- ListGrid grid = getListGrid();
-
- // Make the value of some specific field a link to the details view for the corresponding record.
- ListGridField field = (grid != null) ? grid.getField(getDetailsLinkColumnName()) : null;
- if (field != null) {
- field.setCellFormatter(getDetailsLinkColumnCellFormatter());
- }
-
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid listGrid = (ListGrid) event.getSource();
- ListGridRecord[] selectedRows = listGrid.getSelection();
- if (selectedRows != null && selectedRows.length == 1) {
- showDetails(selectedRows[0]);
- }
- }
- });
- }
- }
-
- protected boolean isDetailsEnabled() {
- return true;
- }
-
- public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
- this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
- }
-
- /**
- * Override if you don't want FIELD_NAME to be wrapped ina link.
- * @return the name of the field to be wrapped, or null if no field should be wrapped.
- */
- protected String getDetailsLinkColumnName() {
- return FIELD_NAME;
- }
-
- /**
- * Override if you don't want the detailsLinkColumn to have the default link wrapper.
- * @return the desired CellFormatter.
- */
- protected CellFormatter getDetailsLinkColumnCellFormatter() {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int i1) {
- if (value == null) {
- return "";
- }
- Integer recordId = getId(record);
- String detailsUrl = "#" + getBasePath() + "/" + recordId;
- String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
- : value.toString();
- return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
- }
- };
- }
-
- /**
- * Shows the details view for the given record of the table.
- *
- * The default implementation of this method assumes there is an
- * id attribute on the record and passes it to {@link #showDetails(int)}.
- * Subclasses are free to override this behavior. Subclasses usually
- * will need to set the {@link #setDetailsView(Canvas) details view}
- * explicitly.
- *
- * @param record the record whose details are to be shown
- */
- public void showDetails(ListGridRecord record) {
- if (record == null) {
- throw new IllegalArgumentException("'record' parameter is null.");
- }
-
- Integer id = getId(record);
- showDetails(id);
- }
-
- /**
- * Returns the details canvas with information on the item given its list grid record.
- *
- * The default implementation of this method is to assume there is an
- * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
- * Subclasses are free to override this - which you usually want to do
- * if you know the full details of the item are stored in the record attributes
- * and thus help avoid making a round trip to the DB.
- *
- * @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
- */
- public Canvas getDetailsView(ListGridRecord record) {
- Integer id = getId(record);
- return getDetailsView(id);
- }
-
- protected Integer getId(ListGridRecord record) {
- Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
- if (id == null) {
- String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalStateException(msg);
- }
- return id;
- }
-
- /**
- * Shows empty details for a new item being created.
- * This method is usually called when a user clicks a 'New' button.
- *
- * @see #showDetails(ListGridRecord)
- */
- public void newDetails() {
- History.newItem(basePath + "/0");
- }
-
- /**
- * Shows the details for an item has the given ID.
- * This method is usually called when a user goes to the details
- * page via a bookmark, double-cick on a list view row, or direct link.
- *
- * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
- *
- * @see #showDetails(ListGridRecord)
- *
- * @throws IllegalArgumentException if id <= 0.
- */
- public void showDetails(int id) {
- if (id > 0) {
- History.newItem(basePath + "/" + id);
- } else {
- String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalArgumentException(msg);
- }
- }
-
- /**
- * Returns the details canvas with information on the item that has the given ID.
- * Note that an empty details view should be returned if the id passed in is 0 (as would
- * be the case if a new item is to be created using the details view).
- *
- * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
- */
- public abstract Canvas getDetailsView(int id);
-
- @Override
- public void renderView(ViewPath viewPath) {
- this.basePath = viewPath.getPathToCurrent();
-
- if (!viewPath.isEnd()) {
- int id = Integer.parseInt(viewPath.getCurrent().getPath());
- this.detailsView = getDetailsView(id);
- if (this.detailsView instanceof BookmarkableView) {
- ((BookmarkableView) this.detailsView).renderView(viewPath);
- }
-
- switchToDetailsView();
- } else {
- switchToTableView();
- }
- }
-
- protected String getBasePath() {
- return this.basePath;
- }
-
- /**
- * For use by subclasses that want to define their own details view.
- *
- * @param detailsView the new details view
- */
- protected void setDetailsView(Canvas detailsView) {
- this.detailsView = detailsView;
- }
-
- /**
- * Switches to viewing the details canvas, hiding the table. This does not
- * do anything with reloading data or switching to the selected row in the table;
- * this only changes the visibility of canvases.
- */
- protected void switchToDetailsView() {
- Canvas contents = getTableContents();
-
- // If the Table has not yet been initialized then ignore
- if (contents != null) {
- if (contents.isVisible()) {
- contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
- @Override
- public void execute(boolean b) {
- buildDetailsView();
- }
- });
- } else {
- /*
- * if the programmer chooses to go directly from the detailView in create-mode to the
- * detailsView in edit-mode, the content canvas will already be hidden, which means the
- * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
- * to keep a reference to the previous detailsView (the one in create-mode) instead of the
- * newly returned reference from getDetailsView(int) that was called when the renderView
- * methods were called hierarchically down to render the new detailsView in edit-mode.
- * therefore, we need to explicitly destroy what's already there (presumably the detailsView
- * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
- */
- SeleniumUtility.destroyMembers(detailsHolder);
-
- buildDetailsView();
- }
- }
- }
-
- private void buildDetailsView() {
- detailsView.setWidth100();
- detailsView.setHeight100();
-
- boolean isEditable = (detailsView instanceof DetailsView && ((DetailsView) detailsView).isEditable());
- if (!isEditable) {
- // Only add the "Back to List" button if the details are definitely not editable, because if they are
- // editable, a Cancel button should already be provided by the details view.
- BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_tableSection_backButton(),
- basePath);
- detailsHolder.addMember(backButton);
- VLayout verticalSpacer = new LocatableVLayout(extendLocatorId("verticalSpacer"));
- verticalSpacer.setHeight(8);
- detailsHolder.addMember(verticalSpacer);
- }
-
- detailsHolder.addMember(detailsView);
- detailsHolder.animateShow(AnimationEffect.WIPE);
- }
-
- /**
- * Switches to viewing the table, hiding the details canvas.
- */
- protected void switchToTableView() {
- final Canvas contents = getTableContents();
- if (contents != null) {
- // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
- // redundant, since the data was just loaded when the table was drawn.
- if (this.initialDisplay) {
- this.initialDisplay = false;
- } else {
- Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
- refresh();
- }
- if (detailsHolder != null && detailsHolder.isVisible()) {
- detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
- @Override
- public void execute(boolean b) {
- SeleniumUtility.destroyMembers(detailsHolder);
-
- contents.animateShow(AnimationEffect.WIPE);
- }
- });
- } else {
- contents.animateShow(AnimationEffect.WIPE);
- }
- }
- }
-
-}
commit 276d4aa49f568399f5adb35134647e84a119aff9
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 15:23:28 2011 -0400
Need to copy resource id filer into jpa criteria object
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 54eda95..8e4d1f7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -66,11 +66,11 @@ import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
-import org.rhq.core.domain.drift.RhqDriftFile;
import org.rhq.core.domain.drift.DriftFileBits;
import org.rhq.core.domain.drift.DriftFileStatus;
import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.drift.RhqDriftFile;
import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index bed8bd5..1755d3e 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -110,6 +110,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
private DriftChangeSetJPACriteria toJPACriteria(DriftChangeSetCriteria criteria) {
DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
+ jpaCriteria.addFilterResourceId(criteria.getFilterResourceId());
jpaCriteria.addFilterCategory(criteria.getFilterCategory());
jpaCriteria.addFilterCreatedAfter(criteria.getFilterCreatedAfter());
jpaCriteria.addFilterCreatedBefore(criteria.getFilterCreatedBefore());
commit f557f05fa617968bd151a83765b0fa0dcf98a5e5
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 13:57:20 2011 -0400
fixing import
diff --git a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
index 622108f..da296f9 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
@@ -6,7 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import static junitx.util.Converter.asList;
+import static java.util.Arrays.asList;
public class CollectionMatchesChecker<T> {
commit 7e9ec31437b8b547bb1c048113081031b86a9721
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 13:47:51 2011 -0400
Fix filter overrides for range filters
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
index 6c17877..7a7f78f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -39,9 +39,9 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
private Integer filterId;
private Integer filterInitial; // needs override
private Integer filterResourceId; // needs override
- private String filterVersion;
- private String filterStartVersion;
- private String filterEndVersion;
+ private Integer filterVersion;
+ private Integer filterStartVersion;
+ private Integer filterEndVersion;
private Long filterCreatedAfter;
private Long filterCreatedBefore;
private DriftChangeSetCategory filterCategory;
@@ -52,10 +52,10 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
public DriftChangeSetJPACriteria() {
filterOverrides.put("initial", "version = 0");
filterOverrides.put("resourceId", "resource.id = ?");
- filterOverrides.put("filterStartVersion", "version >= ?");
- filterOverrides.put("filterEndVersion", "version <= ?");
- filterOverrides.put("filterCreatedAfter", "ctime >= ?");
- filterOverrides.put("filterCreatedBefore", "ctime <= ?");
+ filterOverrides.put("startVersion", "version >= ?");
+ filterOverrides.put("endVersion", "version <= ?");
+ filterOverrides.put("createdAfter", "ctime >= ?");
+ filterOverrides.put("createdBefore", "ctime <= ?");
}
@Override
@@ -75,32 +75,38 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
}
public void addFilterVersion(String filterVersion) {
- this.filterVersion = filterVersion;
+ if (filterVersion != null) {
+ this.filterVersion = Integer.parseInt(filterVersion);
+ }
}
@Override
public String getFilterVersion() {
- return filterVersion;
+ return filterVersion == null ? null : filterVersion.toString();
}
@Override
public void addFilterStartVersion(String filterStartVersion) {
- this.filterStartVersion = filterStartVersion;
+ if (filterStartVersion != null) {
+ this.filterStartVersion = Integer.parseInt(filterStartVersion);
+ }
}
@Override
public String getFilterStartVersion() {
- return filterStartVersion;
+ return filterStartVersion == null ? null : filterStartVersion.toString();
}
@Override
public void addFilterEndVersion(String filterEndVersion) {
- this.filterEndVersion = filterEndVersion;
+ if (filterEndVersion != null) {
+ this.filterEndVersion = Integer.parseInt(filterEndVersion);
+ }
}
@Override
public String getFilterEndVersion() {
- return filterEndVersion;
+ return filterEndVersion == null ? null : filterEndVersion.toString();
}
@Override
commit 921524020da4ac5149eafeea5cfd89ccc2ce849a
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 12:30:46 2011 -0400
Prepend directory in path of file entries
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index c24099a..bc88533 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -37,6 +37,7 @@ import org.rhq.core.domain.drift.dto.DriftFileDTO;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
+import org.rhq.core.util.file.FileUtil;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet;
@@ -100,9 +101,11 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
for (DirectoryEntry dirEntry : reader) {
for (FileEntry fileEntry : dirEntry) {
+ String path = new File(dirEntry.getDirectory(), fileEntry.getFile()).getPath();
+ path = FileUtil.useForwardSlash(path);
MongoDBChangeSetEntry entry = new MongoDBChangeSetEntry();
entry.setCategory(fileEntry.getType());
- entry.setPath(fileEntry.getFile());
+ entry.setPath(path);
changeSet.add(entry);
}
}
commit 7ac71a20e868119305be5afb400570a0ac3cbdf7
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 11:59:25 2011 -0400
Adding DriftServer to remote client for use from CLI
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java
index a965cb9..8538d9a 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java
@@ -32,6 +32,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -89,6 +90,8 @@ public interface RhqFacade {
DiscoveryBossRemote getDiscoveryBoss();
+ DriftServerRemote getDriftServer();
+
DriftManagerRemote getDriftManager();
EventManagerRemote getEventManager();
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java
index 473d95e..ff632d7 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java
@@ -29,6 +29,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -64,6 +65,7 @@ public enum RhqManagers {
ConfigurationManager(ConfigurationManagerRemote.class), //
ContentManager(ContentManagerRemote.class), //
DataAccessManager(DataAccessManagerRemote.class), //
+ DriftServer(DriftServerRemote.class),
DriftManager(DriftManagerRemote.class), //
DiscoveryBoss(DiscoveryBossRemote.class), //
EventManager(EventManagerRemote.class), //
diff --git a/modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java b/modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java
index 4fb2364..6060d9e 100644
--- a/modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java
+++ b/modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java
@@ -34,6 +34,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -179,6 +180,10 @@ public class FakeRhqFacade implements RhqFacade {
return null;
}
+ public DriftServerRemote getDriftServer() {
+ return null;
+ }
+
@Override
public DriftManagerRemote getDriftManager() {
return null;
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index 0460864..2d9973d 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -44,6 +44,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -275,6 +276,10 @@ public class RemoteClient implements RhqFacade {
return RemoteClientProxy.getProcessor(this, RhqManagers.CallTimeDataManager);
}
+ public DriftServerRemote getDriftServer() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.DriftServer);
+ }
+
public DriftManagerRemote getDriftManager() {
return RemoteClientProxy.getProcessor(this, RhqManagers.DriftManager);
}
diff --git a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
index 96778f9..b3c2b8c 100644
--- a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
+++ b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
@@ -41,6 +41,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -132,6 +133,10 @@ public class LocalClient implements RhqFacade {
return getProxy(LookupUtil.getDiscoveryBoss(), DiscoveryBossRemote.class);
}
+ public DriftServerRemote getDriftServer() {
+ return getProxy(LookupUtil.getDriftServer(), DriftServerRemote.class);
+ }
+
public DriftManagerRemote getDriftManager() {
return getProxy(LookupUtil.getDriftManager(), DriftManagerRemote.class);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 005ed8b..f66c3ab 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -19,7 +19,6 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
@@ -41,7 +40,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
@Stateless
-public class DriftServerBean implements DriftServerLocal {
+public class DriftServerBean implements DriftServerLocal, DriftServerRemote {
// TODO Should security checks be handled here instead of delegating to the drift plugin?
// Currently any security checks that need to be performed are delegated to the plugin.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerRemote.java
new file mode 100644
index 0000000..a3dc30b
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerRemote.java
@@ -0,0 +1,18 @@
+package org.rhq.enterprise.server.drift;
+
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.Snapshot;
+import org.rhq.core.domain.util.PageList;
+
+@Remote
+public interface DriftServerRemote {
+
+ PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria);
+
+ Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria);
+
+}
commit 4fc7ef6434bcfab86d8b2459e3f263106606267b
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 07:06:15 2011 -0400
createSnapshot method in drift server api needs to use criteria interfaces
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
index 10f72f5..cc7c6f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
@@ -118,7 +118,7 @@ public interface DriftGWTService extends RemoteService {
PageList<DriftComposite> findDriftCompositesByCriteria(DriftCriteria criteria);
- Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria);
/**
* Get the specified drift configuration for the specified context.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index b440ffd..cb44a90 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
@@ -125,7 +124,7 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
}
@Override
- public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria) {
try {
return driftServer.createSnapshot(subject, criteria);
} catch (Throwable t) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 9de0966..005ed8b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -98,7 +98,7 @@ public class DriftServerBean implements DriftServerLocal {
@Override
@TransactionAttribute(NOT_SUPPORTED)
- public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria) {
DriftServerPluginFacet driftServerPlugin = getServerPlugin();
return driftServerPlugin.createSnapshot(subject, criteria);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
index 5046e83..eda3a4f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
@@ -7,7 +7,6 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
@@ -35,6 +34,6 @@ public interface DriftServerLocal {
PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria);
- Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
index 867464d..5a57837 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
@@ -50,5 +50,5 @@ public interface DriftServerPluginFacet extends ServerPluginComponent {
void saveChangeSetFiles(File changeSetFilesZip) throws Exception;
- Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria);
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index bc9feaa..c24099a 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -25,7 +25,6 @@ import org.rhq.common.drift.FileEntry;
import org.rhq.common.drift.Headers;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.drift.Drift;
@@ -165,7 +164,7 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
}
@Override
- public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria) {
return null;
}
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 78d7843..bed8bd5 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -102,9 +102,9 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
}
@Override
- public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria) {
DriftManagerLocal driftMgr = getDriftManager();
- return driftMgr.createSnapshot(subject, criteria);
+ return driftMgr.createSnapshot(subject, toJPACriteria(criteria));
}
private DriftChangeSetJPACriteria toJPACriteria(DriftChangeSetCriteria criteria) {
commit 0f7a3a150bc05d585706e0c059d5e09727298b40
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 00:44:28 2011 -0400
Updating drift-mongodb plugin to display drift details (still POC)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
index 50b4634..8453713 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
@@ -32,8 +32,8 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.criteria.BaseCriteria;
+import org.rhq.core.domain.criteria.BasicDriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
@@ -177,7 +177,7 @@ public abstract class AbstractDriftChangeSetsTreeDataSource extends RPCDataSourc
* @return the criteria to use when querying for change setss
*/
protected DriftChangeSetCriteria getDriftChangeSetCriteria(final DSRequest request) {
- DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ BasicDriftChangeSetCriteria criteria = new BasicDriftChangeSetCriteria();
criteria.addSortVersion(PageOrdering.DESC);
criteria.setPageControl(getPageControl(request));
return criteria;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index 0e3f7ed..0d59be8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -37,8 +37,8 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.BasicDriftCriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftComposite;
@@ -263,7 +263,7 @@ public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria
return null; // user didn't select any priorities - return null to indicate no data should be displayed
}
- DriftJPACriteria criteria = new DriftJPACriteria();
+ BasicDriftCriteria criteria = new BasicDriftCriteria();
criteria.fetchChangeSet(true);
criteria.addFilterCategories(categoriesFilter);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index 2582a49..6f4bbf2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -27,8 +27,7 @@ import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.criteria.BasicDriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
@@ -62,7 +61,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
}
private void show(String driftId) {
- DriftCriteria criteria = new DriftJPACriteria();
+ BasicDriftCriteria criteria = new BasicDriftCriteria();
criteria.addFilterId(driftId);
criteria.fetchChangeSet(true);
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index c90594a..bc9feaa 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -16,6 +16,7 @@ import com.mongodb.Mongo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.bson.types.ObjectId;
import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetReaderImpl;
@@ -33,6 +34,7 @@ import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.drift.dto.DriftChangeSetDTO;
import org.rhq.core.domain.drift.dto.DriftDTO;
+import org.rhq.core.domain.drift.dto.DriftFileDTO;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
@@ -124,7 +126,23 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
@Override
public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
- return new PageList<Drift>();
+ String[] idFields = criteria.getFilterId().split(":");
+ ObjectId changeSetId = new ObjectId(idFields[0]);
+ String path = idFields[1];
+ Query<MongoDBChangeSet> query = ds.createQuery(MongoDBChangeSet.class)
+ .filter("id = ", changeSetId)
+ .filter("files.path = ", path);
+
+ PageList results = new PageList<DriftDTO>();
+
+ for (MongoDBChangeSet changeSet : query) {
+ DriftChangeSetDTO changeSetDTO = toDTO(changeSet);
+ for (MongoDBChangeSetEntry entry : changeSet.getDrifts()) {
+ results.add((toDTO(entry, changeSetDTO)));
+ }
+ }
+
+ return (PageList<Drift>) results;
}
@Override
@@ -185,6 +203,13 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
dto.setPath(entry.getPath());
dto.setCategory(entry.getCategory());
+ DriftFileDTO fileDTO = new DriftFileDTO();
+ fileDTO.setHashId("1a2b3c4e5f");
+
+ dto.setOldDriftFile(fileDTO);
+ dto.setNewDriftFile(fileDTO);
+
return dto;
}
+
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
index 6aff9aa..cfdc802 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -1,5 +1,7 @@
package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+import java.util.List;
+
import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
import com.google.code.morphia.query.Query;
@@ -14,6 +16,7 @@ import org.rhq.core.domain.drift.DriftCategory;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
import static org.rhq.test.AssertUtils.assertPropertiesMatch;
+import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
public class MongoDBChangeSetTest {
@@ -72,4 +75,21 @@ public class MongoDBChangeSetTest {
"changeSet");
}
+ @Test
+ public void saveAndFindChangeSetById() throws Exception {
+ MongoDBChangeSet expected = new MongoDBChangeSet();
+ expected.setCategory(COVERAGE);
+ expected.setVersion(1);
+ expected.setDriftConfigurationId(1);
+
+ ds.save(expected);
+
+ List<MongoDBChangeSet> results = ds.createQuery(MongoDBChangeSet.class)
+ .filter("id = ", expected.getObjectId())
+ .asList();
+
+ assertEquals(results.size(), 1, "Expected to get back one change set");
+
+ }
+
}
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 8d4cae4..78d7843 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -73,15 +73,8 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
@Override
public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
- DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
- jpaCriteria.addFilterId(criteria.getFilterId());
- jpaCriteria.addFilterResourceId(criteria.getFilterResourceId());
- jpaCriteria.addFilterVersion(criteria.getFilterVersion());
- jpaCriteria.addFilterCategory(criteria.getFilterCategory());
- jpaCriteria.fetchDrifts(criteria.isFetchDrifts());
-
PageList<? extends DriftChangeSet> results = getDriftManager().findDriftChangeSetsByCriteria(subject,
- jpaCriteria);
+ toJPACriteria(criteria));
return (PageList<DriftChangeSet>) results;
}
@@ -114,6 +107,21 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
return driftMgr.createSnapshot(subject, criteria);
}
+ private DriftChangeSetJPACriteria toJPACriteria(DriftChangeSetCriteria criteria) {
+ DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
+ jpaCriteria.addFilterId(criteria.getFilterId());
+ jpaCriteria.addFilterCategory(criteria.getFilterCategory());
+ jpaCriteria.addFilterCreatedAfter(criteria.getFilterCreatedAfter());
+ jpaCriteria.addFilterCreatedBefore(criteria.getFilterCreatedBefore());
+ jpaCriteria.addFilterEndVersion(criteria.getFilterEndVersion());
+ jpaCriteria.addFilterStartVersion(criteria.getFilterStartVersion());
+ jpaCriteria.addFilterVersion(criteria.getFilterVersion());
+ jpaCriteria.addSortVersion(criteria.getSortVersion());
+ jpaCriteria.fetchDrifts(criteria.isFetchDrifts());
+
+ return jpaCriteria;
+ }
+
private DriftJPACriteria toJPACriteria(DriftCriteria criteria) {
DriftJPACriteria jpaCriteria = new DriftJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
commit 756469b8265282e85dd8405547ee3b6e3a06a625
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 21:48:04 2011 -0400
Initial commit for "basic" criteria classes
coregui needs to use the basic criteria classes and not the JPA criteria
classes. The JPA criteria classes convert string ids to integers, and
this results in an exception when using a drift server plugin other than
the default.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
new file mode 100644
index 0000000..2debece
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
@@ -0,0 +1,142 @@
+package org.rhq.core.domain.criteria;
+
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageOrdering;
+
+public class BasicDriftChangeSetCriteria implements DriftChangeSetCriteria {
+
+ private static final long serialVersionUID = 1L;
+
+ private String filterId;
+
+ private String filterVersion;
+
+ private String filterStartVersion;
+
+ private String filterEndVersion;
+
+ private Long filterCreatedAfter;
+
+ private Long filterCreatedBefore;
+
+ private Integer filterResourceId;
+
+ private DriftChangeSetCategory filterCategory;
+
+ private boolean fetchDrifts;
+
+ private PageOrdering sortVersion;
+
+ private PageControl pageControl;
+
+ @Override
+ public void addFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId;
+ }
+
+ @Override
+ public void addFilterVersion(String filterVersion) {
+ this.filterVersion = filterVersion;
+ }
+
+ @Override
+ public String getFilterVersion() {
+ return filterVersion;
+ }
+
+ @Override
+ public void addFilterStartVersion(String filterStartVersion) {
+ this.filterStartVersion = filterStartVersion;
+ }
+
+ @Override
+ public String getFilterStartVersion() {
+ return filterStartVersion;
+ }
+
+ @Override
+ public void addFilterEndVersion(String filterEndVersion) {
+ this.filterEndVersion = filterEndVersion;
+ }
+
+ @Override
+ public String getFilterEndVersion() {
+ return filterEndVersion;
+ }
+
+ @Override
+ public void addFilterCreatedAfter(Long filterCreatedAfter) {
+ this.filterCreatedAfter = filterCreatedAfter;
+ }
+
+ @Override
+ public Long getFilterCreatedAfter() {
+ return filterCreatedAfter;
+ }
+
+ @Override
+ public void addFilterCreatedBefore(Long filterCreatedBefore) {
+ this.filterCreatedBefore = filterCreatedBefore;
+ }
+
+ @Override
+ public Long getFilterCreatedBefore() {
+ return filterCreatedBefore;
+ }
+
+ @Override
+ public void addFilterResourceId(Integer filterResourceId) {
+ this.filterResourceId = filterResourceId;
+ }
+
+ @Override
+ public Integer getFilterResourceId() {
+ return filterResourceId;
+ }
+
+ @Override
+ public void addFilterCategory(DriftChangeSetCategory filterCategory) {
+ this.filterCategory = filterCategory;
+ }
+
+ @Override
+ public DriftChangeSetCategory getFilterCategory() {
+ return filterCategory;
+ }
+
+ @Override
+ public void fetchDrifts(boolean fetchDrifts) {
+ this.fetchDrifts = fetchDrifts;
+ }
+
+ @Override
+ public boolean isFetchDrifts() {
+ return fetchDrifts;
+ }
+
+ @Override
+ public void addSortVersion(PageOrdering sortVersion) {
+ this.sortVersion = sortVersion;
+ }
+
+ @Override
+ public PageOrdering getSortVersion() {
+ return sortVersion;
+ }
+
+ @Override
+ public PageControl getPageControlOverrides() {
+ return pageControl;
+ }
+
+ @Override
+ public void setPageControl(PageControl pageControl) {
+ this.pageControl = pageControl;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftCriteria.java
new file mode 100644
index 0000000..b1a5695
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftCriteria.java
@@ -0,0 +1,135 @@
+package org.rhq.core.domain.criteria;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageOrdering;
+
+import static org.rhq.core.domain.util.CriteriaUtils.getListIgnoringNulls;
+
+public class BasicDriftCriteria implements DriftCriteria {
+
+ private static final long serialVersionUID = 1L;
+
+ private String filterId;
+
+ private List<DriftCategory> filterCategories = new ArrayList<DriftCategory>();
+
+ private String filterChangeSetId;
+
+ private String filterPath;
+
+ private List<Integer> filterResourceIds = new ArrayList<Integer>();
+
+ private boolean fetchChangeSet;
+
+ private Long filterStartTime;
+
+ private Long filterEndTime;
+
+ private PageControl pageControl;
+
+ private PageOrdering sortCtime;
+
+ @Override
+ public void addFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId;
+ }
+
+ @Override
+ public void addFilterCategories(DriftCategory... filterCategories) {
+ this.filterCategories = getListIgnoringNulls(filterCategories);
+ }
+
+ @Override
+ public List<DriftCategory> getFilterCategories() {
+ return filterCategories;
+ }
+
+ @Override
+ public void addFilterChangeSetId(String filterChangeSetId) {
+ this.filterChangeSetId = filterChangeSetId;
+ }
+
+ @Override
+ public String getFilterChangeSetId() {
+ return filterChangeSetId;
+ }
+
+ @Override
+ public void addFilterPath(String filterPath) {
+ this.filterPath = filterPath;
+ }
+
+ @Override
+ public String getFilterPath() {
+ return filterPath;
+ }
+
+ @Override
+ public void addFilterResourceIds(Integer... filterResourceIds) {
+ this.filterResourceIds = getListIgnoringNulls(filterResourceIds);
+ }
+
+ @Override
+ public List<Integer> getFilterResourceIds() {
+ return filterResourceIds;
+ }
+
+ @Override
+ public void addFilterStartTime(Long filterStartTime) {
+ this.filterStartTime = filterStartTime;
+ }
+
+ @Override
+ public Long getFilterStartTime() {
+ return filterStartTime;
+ }
+
+ @Override
+ public void addFilterEndTime(Long filterEndTime) {
+ this.filterEndTime = filterEndTime;
+ }
+
+ @Override
+ public Long getFilterEndTime() {
+ return filterEndTime;
+ }
+
+ @Override
+ public void fetchChangeSet(boolean fetchChangeSet) {
+ this.fetchChangeSet = fetchChangeSet;
+ }
+
+ @Override
+ public boolean isFetchChangeSet() {
+ return fetchChangeSet;
+ }
+
+ @Override
+ public void addSortCtime(PageOrdering sortCtime) {
+ this.sortCtime = sortCtime;
+ }
+
+ @Override
+ public PageOrdering getSortCtime() {
+ return sortCtime;
+ }
+
+ @Override
+ public PageControl getPageControlOverrides() {
+ return pageControl;
+ }
+
+ @Override
+ public void setPageControl(PageControl pageControl) {
+ this.pageControl = pageControl;
+ }
+}
commit 956cbb899ed45301921c7ab3fc39a9e9eb67ce30
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 21:03:27 2011 -0400
Adding support in coregui for string ids
TableSection has a lot of code driven off of integer ids, and there are
a lots of subclasses. I started out trying to refactor it to support
string ids, but due to concerns over introducing regressions in existing
(and working) subclasses, I decided to introduce TableSection2 which
deals with string ids. After review, this code may get refactored or
altogether go away with the logic being merged into TableSection.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 10c15e4..378350d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -218,7 +218,7 @@ public class LinkManager {
return link;
}
- public static String getSubsystemDriftHistoryLink(int resourceId, int driftId) {
+ public static String getSubsystemDriftHistoryLink(int resourceId, String driftId) {
return "#Resource/" + resourceId + "/Drift/History/" + driftId;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection2.java
new file mode 100644
index 0000000..28beafe
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection2.java
@@ -0,0 +1,367 @@
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.AnimationEffect;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.AnimationCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.DetailsView;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+public abstract class TableSection2 <DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
+
+ private VLayout detailsHolder;
+ private Canvas detailsView;
+ private String basePath;
+ private boolean escapeHtmlInDetailsLinkColumn;
+ private boolean initialDisplay;
+
+ protected TableSection2(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers, criteria);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ this.initialDisplay = true;
+
+ detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
+ detailsHolder.setAlign(VerticalAlignment.TOP);
+ //detailsHolder.setWidth100();
+ //detailsHolder.setHeight100();
+ detailsHolder.setMargin(4);
+ detailsHolder.hide();
+
+ addMember(detailsHolder);
+
+ // if the detailsView is already defined it means we want the details view to be rendered prior to
+ // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
+ if (null != detailsView) {
+ switchToDetailsView();
+ }
+ }
+
+ /**
+ * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
+ * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
+ * view, given the 'id'. Also, establishes a double click handler for the row which invokes
+ * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
+ * </br>
+ * In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
+ *
+ * @see org.rhq.enterprise.gui.coregui.client.components.table.Table#configureTable()
+ */
+ @Override
+ protected void configureTable() {
+ if (isDetailsEnabled()) {
+ ListGrid grid = getListGrid();
+
+ // Make the value of some specific field a link to the details view for the corresponding record.
+ ListGridField field = (grid != null) ? grid.getField(getDetailsLinkColumnName()) : null;
+ if (field != null) {
+ field.setCellFormatter(getDetailsLinkColumnCellFormatter());
+ }
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ showDetails(selectedRows[0]);
+ }
+ }
+ });
+ }
+ }
+
+ protected boolean isDetailsEnabled() {
+ return true;
+ }
+
+ public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
+ this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
+ }
+
+ /**
+ * Override if you don't want FIELD_NAME to be wrapped ina link.
+ * @return the name of the field to be wrapped, or null if no field should be wrapped.
+ */
+ protected String getDetailsLinkColumnName() {
+ return FIELD_NAME;
+ }
+
+ /**
+ * Override if you don't want the detailsLinkColumn to have the default link wrapper.
+ * @return the desired CellFormatter.
+ */
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ if (value == null) {
+ return "";
+ }
+ String recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
+ : value.toString();
+ return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
+ }
+ };
+ }
+
+ /**
+ * Shows the details view for the given record of the table.
+ *
+ * The default implementation of this method assumes there is an
+ * id attribute on the record and passes it to {@link #showDetails(String)}.
+ * Subclasses are free to override this behavior. Subclasses usually
+ * will need to set the {@link #setDetailsView(Canvas) details view}
+ * explicitly.
+ *
+ * @param record the record whose details are to be shown
+ */
+ public void showDetails(ListGridRecord record) {
+ if (record == null) {
+ throw new IllegalArgumentException("'record' parameter is null.");
+ }
+
+ String id = getId(record);
+ showDetails(id);
+ }
+
+ /**
+ * Returns the details canvas with information on the item given its list grid record.
+ *
+ * The default implementation of this method is to assume there is an
+ * id attribute on the record and pass that ID to {@link #getDetailsView(String)}.
+ * Subclasses are free to override this - which you usually want to do
+ * if you know the full details of the item are stored in the record attributes
+ * and thus help avoid making a round trip to the DB.
+ *
+ * @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
+ */
+ public Canvas getDetailsView(ListGridRecord record) {
+ String id = getId(record);
+ return getDetailsView(id);
+ }
+
+ protected String getId(ListGridRecord record) {
+ String id = null;
+ if (record != null) {
+ id = record.getAttribute("id");
+ }
+ if (id == null || id.length() == 0) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ /**
+ * Shows empty details for a new item being created.
+ * This method is usually called when a user clicks a 'New' button.
+ *
+ * @see #showDetails(ListGridRecord)
+ */
+ public void newDetails() {
+ History.newItem(basePath + "/0");
+ }
+
+ /**
+ * Shows the details for an item has the given ID.
+ * This method is usually called when a user goes to the details
+ * page via a bookmark, double-cick on a list view row, or direct link.
+ *
+ * @param id the id of the row whose details are to be shown; Should be a valid id.
+ *
+ * @see #showDetails(ListGridRecord)
+ *
+ * @throws IllegalArgumentException if id is null or empty string
+ */
+ public void showDetails(String id) {
+ if (id == null || id.length() == 0) {
+ History.newItem(basePath + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), id);
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Returns the details canvas with information on the item that has the given ID.
+ * Note that an empty details view should be returned if the id passed in is 0 (as would
+ * be the case if a new item is to be created using the details view).
+ *
+ * @param id the id of the details to be shown; will be null if an empty details view should be shown.
+ */
+ public abstract Canvas getDetailsView(String id);
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ this.basePath = viewPath.getPathToCurrent();
+
+ if (!viewPath.isEnd()) {
+ String id = viewPath.getCurrent().getPath();
+ this.detailsView = getDetailsView(id);
+ if (this.detailsView instanceof BookmarkableView) {
+ ((BookmarkableView) this.detailsView).renderView(viewPath);
+ }
+ switchToDetailsView();
+ } else {
+ switchToTableView();
+ }
+ }
+
+ protected String getBasePath() {
+ return this.basePath;
+ }
+
+ /**
+ * For use by subclasses that want to define their own details view.
+ *
+ * @param detailsView the new details view
+ */
+ protected void setDetailsView(Canvas detailsView) {
+ this.detailsView = detailsView;
+ }
+
+ /**
+ * Switches to viewing the details canvas, hiding the table. This does not
+ * do anything with reloading data or switching to the selected row in the table;
+ * this only changes the visibility of canvases.
+ */
+ protected void switchToDetailsView() {
+ Canvas contents = getTableContents();
+
+ // If the Table has not yet been initialized then ignore
+ if (contents != null) {
+ if (contents.isVisible()) {
+ contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ buildDetailsView();
+ }
+ });
+ } else {
+ /*
+ * if the programmer chooses to go directly from the detailView in create-mode to the
+ * detailsView in edit-mode, the content canvas will already be hidden, which means the
+ * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
+ * to keep a reference to the previous detailsView (the one in create-mode) instead of the
+ * newly returned reference from getDetailsView(String) that was called when the renderView
+ * methods were called hierarchically down to render the new detailsView in edit-mode.
+ * therefore, we need to explicitly destroy what's already there (presumably the detailsView
+ * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
+ */
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ buildDetailsView();
+ }
+ }
+ }
+
+ private void buildDetailsView() {
+ detailsView.setWidth100();
+ detailsView.setHeight100();
+
+ boolean isEditable = (detailsView instanceof DetailsView && ((DetailsView) detailsView).isEditable());
+ if (!isEditable) {
+ // Only add the "Back to List" button if the details are definitely not editable, because if they are
+ // editable, a Cancel button should already be provided by the details view.
+ BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_tableSection_backButton(),
+ basePath);
+ detailsHolder.addMember(backButton);
+ VLayout verticalSpacer = new LocatableVLayout(extendLocatorId("verticalSpacer"));
+ verticalSpacer.setHeight(8);
+ detailsHolder.addMember(verticalSpacer);
+ }
+
+ detailsHolder.addMember(detailsView);
+ detailsHolder.animateShow(AnimationEffect.WIPE);
+ }
+
+ /**
+ * Switches to viewing the table, hiding the details canvas.
+ */
+ protected void switchToTableView() {
+ final Canvas contents = getTableContents();
+ if (contents != null) {
+ // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
+ // redundant, since the data was just loaded when the table was drawn.
+ if (this.initialDisplay) {
+ this.initialDisplay = false;
+ } else {
+ Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
+ refresh();
+ }
+ if (detailsHolder != null && detailsHolder.isVisible()) {
+ detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ });
+ } else {
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ }
+ }
+
+
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index 5563a8c..0e3f7ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -302,7 +302,7 @@ public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria
public static ListGridRecord convert(DriftComposite from) {
ListGridRecord record = new ListGridRecord();
Drift drift = from.getDrift();
- record.setAttribute(ATTR_ID, Integer.valueOf(drift.getId()));
+ record.setAttribute(ATTR_ID, drift.getId());
record.setAttribute(ATTR_CTIME, new Date(drift.getCtime()));
record.setAttribute(ATTR_CATEGORY, ImageManager.getDriftCategoryIcon(drift.getCategory()));
record.setAttribute(ATTR_PATH, drift.getPath());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index a608f8f..f00640a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -44,7 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection2;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*
* @author Jay Shaughnessy
*/
-public class DriftHistoryView extends TableSection<DriftDataSource> {
+public class DriftHistoryView extends TableSection2<DriftDataSource> {
public static final ViewName SUBSYSTEM_VIEW_ID = new ViewName("RecentDrifts", MSG.common_title_recent_drifts());
@@ -155,7 +155,7 @@ public class DriftHistoryView extends TableSection<DriftDataSource> {
return new CellFormatter() {
public String format(Object value, ListGridRecord record, int i, int i1) {
Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
- Integer driftId = getId(record);
+ String driftId = getId(record);
String url = LinkManager.getSubsystemDriftHistoryLink(resourceId, driftId);
String formattedValue = TimestampCellFormatter.format(value);
return SeleniumUtility.getLocatableHref(url, formattedValue, null);
@@ -283,8 +283,9 @@ public class DriftHistoryView extends TableSection<DriftDataSource> {
// });
// }
+
@Override
- public Canvas getDetailsView(int driftId) {
+ public Canvas getDetailsView(String driftId) {
return DriftDetailsView.getInstance();
}
commit b6c8e5e261b4662afcd71dbdb99d1be2a50e3596
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 16:09:13 2011 -0400
Updating drift-mongodb plugin to use drift DTOs
The drift-mongodb plugin defines its own implementations of the Drift
entities. Those entities live inside the drift-mongodb plugin and
consequently are not known or usable from coregui. Drift server plugins
will have to go through the DTO layer to ensure compatibility with
coregui.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
index 68a5ff7..4ace8d1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
@@ -1,12 +1,15 @@
package org.rhq.core.domain.drift.dto;
+import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
-public class DriftChangeSetDTO implements DriftChangeSet<DriftDTO> {
+public class DriftChangeSetDTO implements DriftChangeSet<DriftDTO>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private String id;
@@ -37,6 +40,10 @@ public class DriftChangeSetDTO implements DriftChangeSet<DriftDTO> {
return ctime;
}
+ public void setCtime(Long ctime) {
+ this.ctime = ctime;
+ }
+
@Override
public int getVersion() {
return version;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
index adc5c52..a75858f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
@@ -1,9 +1,13 @@
package org.rhq.core.domain.drift.dto;
+import java.io.Serializable;
+
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
-public class DriftDTO implements Drift<DriftChangeSetDTO, DriftFileDTO> {
+public class DriftDTO implements Drift<DriftChangeSetDTO, DriftFileDTO>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private String id;
@@ -34,6 +38,10 @@ public class DriftDTO implements Drift<DriftChangeSetDTO, DriftFileDTO> {
return ctime;
}
+ public void setCtime(Long ctime) {
+ this.ctime = ctime;
+ }
+
@Override
public DriftChangeSetDTO getChangeSet() {
return changeSet;
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index 2b3aca0..c90594a 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -31,6 +31,8 @@ import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.Snapshot;
+import org.rhq.core.domain.drift.dto.DriftChangeSetDTO;
+import org.rhq.core.domain.drift.dto.DriftDTO;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
@@ -135,9 +137,9 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
Map<Integer, Resource> resources = loadResourceMap(subject, criteria.getFilterResourceIds());
for (MongoDBChangeSet changeSet : query) {
+ DriftChangeSetDTO changeSetDTO = toDTO(changeSet);
for (MongoDBChangeSetEntry entry : changeSet.getDrifts()) {
- entry.setChangeSet(changeSet);
- results.add(new DriftComposite(entry, resources.get(changeSet.getResourceId())));
+ results.add(new DriftComposite(toDTO(entry, changeSetDTO), resources.get(changeSet.getResourceId())));
}
}
@@ -163,4 +165,26 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
return map;
}
+
+ DriftChangeSetDTO toDTO(MongoDBChangeSet changeSet) {
+ DriftChangeSetDTO dto = new DriftChangeSetDTO();
+ dto.setId(changeSet.getId());
+ dto.setDriftConfigurationId(changeSet.getDriftConfigurationId());
+ dto.setVersion(changeSet.getVersion());
+ dto.setCtime(changeSet.getCtime());
+ dto.setCategory(changeSet.getCategory());
+
+ return dto;
+ }
+
+ DriftDTO toDTO(MongoDBChangeSetEntry entry, DriftChangeSetDTO changeSetDTO) {
+ DriftDTO dto = new DriftDTO();
+ dto.setChangeSet(changeSetDTO);
+ dto.setId(entry.getId());
+ dto.setCtime(entry.getCtime());
+ dto.setPath(entry.getPath());
+ dto.setCategory(entry.getCategory());
+
+ return dto;
+ }
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
index 2818b2c..bcf9f5c 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
@@ -7,6 +7,7 @@ import java.util.Set;
import com.google.code.morphia.annotations.Embedded;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
+import com.google.code.morphia.annotations.PostLoad;
import org.bson.types.ObjectId;
@@ -103,6 +104,7 @@ public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry>,
public MongoDBChangeSet add(MongoDBChangeSetEntry entry) {
entries.add(entry);
+ entry.setChangeSet(this);
return this;
}
@@ -110,4 +112,11 @@ public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry>,
public void setDrifts(Set<MongoDBChangeSetEntry> drifts) {
entries = drifts;
}
+
+ @PostLoad
+ void initEntries() {
+ for (MongoDBChangeSetEntry entry : entries) {
+ entry.setChangeSet(this);
+ }
+ }
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
index ced7bff..dddfb02 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
@@ -3,6 +3,7 @@ package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
import java.io.Serializable;
import com.google.code.morphia.annotations.Embedded;
+import com.google.code.morphia.annotations.Transient;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
@@ -18,6 +19,9 @@ public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFil
private String path;
+ @Transient
+ private MongoDBChangeSet changeSet;
+
public MongoDBChangeSetEntry() {
}
@@ -28,7 +32,7 @@ public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFil
@Override
public String getId() {
- return null;
+ return changeSet.getId() + ":" + path;
}
@Override
@@ -37,16 +41,17 @@ public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFil
@Override
public Long getCtime() {
- return null;
+ return ctime;
}
@Override
public MongoDBChangeSet getChangeSet() {
- return null;
+ return changeSet;
}
@Override
public void setChangeSet(MongoDBChangeSet changeSet) {
+ this.changeSet = changeSet;
}
@Override
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
index b5b8306..6aff9aa 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -9,7 +9,8 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
+import org.rhq.core.domain.drift.DriftCategory;
+
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
import static org.rhq.test.AssertUtils.assertPropertiesMatch;
@@ -32,7 +33,7 @@ public class MongoDBChangeSetTest {
.map(MongoDBChangeSetEntry.class)
.map(MongoDBFile.class);
- ds = morphia.createDatastore(connection, "rhq");
+ ds = morphia.createDatastore(connection, "rhqtest");
}
@BeforeMethod
@@ -59,7 +60,7 @@ public class MongoDBChangeSetTest {
public void saveAndLoadChangeSetWithOneEntry() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
expected.setResourceId(10001);
- expected.getDrifts().add(new MongoDBChangeSetEntry("foo", FILE_ADDED));
+ expected.add(new MongoDBChangeSetEntry("foo", DriftCategory.FILE_ADDED));
ds.save(expected);
@@ -67,7 +68,8 @@ public class MongoDBChangeSetTest {
assertNotNull(expected, "Failed to load change set");
assertPropertiesMatch("Failed to save change set", expected, actual, "drifts");
- assertCollectionMatchesNoOrder(expected.getDrifts(), actual.getDrifts(), "Failed to save change set entries");
+ assertCollectionMatchesNoOrder("Failed to save change set entries", expected.getDrifts(), actual.getDrifts(),
+ "changeSet");
}
}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
index fc41623..7524fc8 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
@@ -23,13 +23,14 @@
package org.rhq.test;
-import static org.testng.Assert.*;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
public class AssertUtils {
/**
@@ -123,4 +124,16 @@ public class AssertUtils {
assertTrue(result.isMatch(), msg + " -- " + result.getDetails());
}
+ public static <T> void assertCollectionMatchesNoOrder(String msg, Collection<T> expected, Collection<T> actual,
+ String... ignoredProperties) {
+ CollectionMatchesChecker<T> checker = new CollectionMatchesChecker<T>();
+ checker.setExpected(expected);
+ checker.setActual(actual);
+ checker.setIgnoredProperties(ignoredProperties);
+
+ MatchResult result = checker.execute();
+
+ assertTrue(result.isMatch(), msg + " -- " + result.getDetails());
+ }
+
}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
index 26b75c9..622108f 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
@@ -2,7 +2,11 @@ package org.rhq.test;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+
+import static junitx.util.Converter.asList;
public class CollectionMatchesChecker<T> {
@@ -10,6 +14,8 @@ public class CollectionMatchesChecker<T> {
private Collection<T> actual;
+ private Set<String> ignoredProperties = new HashSet<String>();
+
public void setExpected(Collection<T> expected) {
this.expected = expected;
}
@@ -18,6 +24,10 @@ public class CollectionMatchesChecker<T> {
this.actual = actual;
}
+ public void setIgnoredProperties(String... ignoredProperties) {
+ this.ignoredProperties.addAll(asList(ignoredProperties));
+ }
+
public MatchResult execute() {
boolean isMatch = true;
StringBuilder details = new StringBuilder();
@@ -63,6 +73,7 @@ public class CollectionMatchesChecker<T> {
PropertyMatcher<T> matcher = new PropertyMatcher<T>();
matcher.setExpected(elementToSearchFor);
matcher.setActual(actual);
+ matcher.setIgnoredProperties(ignoredProperties);
MatchResult result = matcher.execute();
if (result.isMatch()) {
commit e3ac67735346a310e142e7ed28fb65126e26e440
Merge: 5d5f12b fb4f3a1
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 09:13:44 2011 -0400
Merge branch 'drift' into drift-mongodb
commit 5d5f12b94c665c3c28841a56d58e633cd612d687
Merge: e753a90 b384576
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 09:07:41 2011 -0400
Merge branch 'drift' into drift-mongodb
commit e753a90cb8d2ab73c2943d9c9491962798ff771d
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 22:32:38 2011 -0400
Initial commit for drift DTOs
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java
index 068907a..3313755 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java
@@ -24,7 +24,15 @@ public class DriftComposite implements Serializable {
return drift;
}
+ public void setDrift(Drift drift) {
+ this.drift = drift;
+ }
+
public Resource getResource() {
return resource;
}
+
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
new file mode 100644
index 0000000..68a5ff7
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
@@ -0,0 +1,84 @@
+package org.rhq.core.domain.drift.dto;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+
+public class DriftChangeSetDTO implements DriftChangeSet<DriftDTO> {
+
+ private String id;
+
+ private Long ctime;
+
+ private int version;
+
+ private DriftChangeSetCategory category;
+
+ private int configId;
+
+ private int resourceId;
+
+ private Set<DriftDTO> drifts = new HashSet<DriftDTO>();
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public int getDriftConfigurationId() {
+ return configId;
+ }
+
+ @Override
+ public void setDriftConfigurationId(int id) {
+ configId = id;
+ }
+
+ @Override
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ @Override
+ public Set<DriftDTO> getDrifts() {
+ return drifts;
+ }
+
+ @Override
+ public void setDrifts(Set<DriftDTO> drifts) {
+ this.drifts = drifts;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
new file mode 100644
index 0000000..adc5c52
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
@@ -0,0 +1,86 @@
+package org.rhq.core.domain.drift.dto;
+
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftCategory;
+
+public class DriftDTO implements Drift<DriftChangeSetDTO, DriftFileDTO> {
+
+ private String id;
+
+ private Long ctime;
+
+ private DriftChangeSetDTO changeSet;
+
+ private DriftCategory category;
+
+ private String path;
+
+ private DriftFileDTO oldDriftFile;
+
+ private DriftFileDTO newDriftFile;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public DriftChangeSetDTO getChangeSet() {
+ return changeSet;
+ }
+
+ @Override
+ public void setChangeSet(DriftChangeSetDTO changeSet) {
+ this.changeSet = changeSet;
+ }
+
+ @Override
+ public DriftCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public DriftFileDTO getOldDriftFile() {
+ return oldDriftFile;
+ }
+
+ @Override
+ public void setOldDriftFile(DriftFileDTO oldDriftFile) {
+ this.oldDriftFile = oldDriftFile;
+ }
+
+ @Override
+ public DriftFileDTO getNewDriftFile() {
+ return newDriftFile;
+ }
+
+ @Override
+ public void setNewDriftFile(DriftFileDTO newDriftFile) {
+ this.newDriftFile = newDriftFile;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftFileDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftFileDTO.java
new file mode 100644
index 0000000..97fa7ef
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftFileDTO.java
@@ -0,0 +1,50 @@
+package org.rhq.core.domain.drift.dto;
+
+import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.drift.DriftFileStatus;
+
+public class DriftFileDTO implements DriftFile {
+
+ private String hash;
+
+ private Long ctime;
+
+ private Long size;
+
+ private DriftFileStatus status;
+
+ @Override
+ public String getHashId() {
+ return hash;
+ }
+
+ @Override
+ public void setHashId(String hashId) {
+ hash = hashId;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public Long getDataSize() {
+ return size;
+ }
+
+ @Override
+ public void setDataSize(Long size) {
+ this.size = size;
+ }
+
+ @Override
+ public DriftFileStatus getStatus() {
+ return status;
+ }
+
+ @Override
+ public void setStatus(DriftFileStatus status) {
+ this.status = status;
+ }
+}
commit d9fdb0434e2828b47b77138f8fd1856f3728c4a1
Merge: 5840be4 e14fb8a
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 22:33:24 2011 -0400
Merge branch 'drift' into drift-mongodb
commit 5840be4d821c70b293c8be154e6beb174b929960
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 25 17:11:41 2011 -0400
Adding mapping fields to drift mongodb entities
Also adding initial implementation for
DriftServerPluginFacet.findDriftCompositesByCriteria. The method does
return results but it is not yet usable from the GWT UI since the entity
classes returned are known only to the rhq-mongodb plugin.
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index 722dd22..2b3aca0 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -3,11 +3,15 @@ package org.rhq.enterprise.server.plugins.drift.mongodb;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
+import com.google.code.morphia.query.Query;
import com.mongodb.Mongo;
import org.apache.commons.logging.Log;
@@ -22,10 +26,12 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.Snapshot;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
@@ -33,6 +39,9 @@ import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSetEntry;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBFile;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+
+import static org.rhq.enterprise.server.util.LookupUtil.getResourceManager;
public class MongoDBDriftServer implements DriftServerPluginFacet {
@@ -118,11 +127,40 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
@Override
public PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria) {
- return new PageList<DriftComposite>();
+ Query<MongoDBChangeSet> query = ds.createQuery(MongoDBChangeSet.class)
+ .filter("files.category in ", criteria.getFilterCategories())
+ .filter("resourceId in", criteria.getFilterResourceIds());
+
+ PageList<DriftComposite> results = new PageList<DriftComposite>();
+ Map<Integer, Resource> resources = loadResourceMap(subject, criteria.getFilterResourceIds());
+
+ for (MongoDBChangeSet changeSet : query) {
+ for (MongoDBChangeSetEntry entry : changeSet.getDrifts()) {
+ entry.setChangeSet(changeSet);
+ results.add(new DriftComposite(entry, resources.get(changeSet.getResourceId())));
+ }
+ }
+
+ return results;
}
@Override
public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
return null;
}
+
+ Map<Integer, Resource> loadResourceMap(Subject subject, List<Integer> resourceIds) {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterIds(resourceIds.toArray(new Integer[resourceIds.size()]));
+
+ ResourceManagerLocal resourceMgr = getResourceManager();
+ PageList<Resource> resources = resourceMgr.findResourcesByCriteria(subject, criteria);
+
+ Map<Integer, Resource> map = new HashMap<Integer, Resource>();
+ for (Resource r : resources) {
+ map.put(r.getId(), r);
+ }
+
+ return map;
+ }
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
index 2640eff..2818b2c 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
@@ -1,5 +1,6 @@
package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -13,7 +14,9 @@ import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
@Entity("changesets")
-public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry> {
+public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry>, Serializable {
+
+ private static final long serialVersionUID = 1L;
@Id
private ObjectId id;
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
index 80cdc0c..ced7bff 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
@@ -1,12 +1,16 @@
package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+import java.io.Serializable;
+
import com.google.code.morphia.annotations.Embedded;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
@Embedded
-public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFile> {
+public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFile>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private Long ctime = System.currentTimeMillis();
@@ -14,6 +18,14 @@ public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFil
private String path;
+ public MongoDBChangeSetEntry() {
+ }
+
+ public MongoDBChangeSetEntry(String path, DriftCategory category) {
+ this.path = path;
+ this.category = category;
+ }
+
@Override
public String getId() {
return null;
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
index e6aec82..b5b8306 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -9,6 +9,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
import static org.rhq.test.AssertUtils.assertPropertiesMatch;
@@ -57,7 +58,8 @@ public class MongoDBChangeSetTest {
@Test
public void saveAndLoadChangeSetWithOneEntry() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
- expected.getDrifts().add(new MongoDBChangeSetEntry());
+ expected.setResourceId(10001);
+ expected.getDrifts().add(new MongoDBChangeSetEntry("foo", FILE_ADDED));
ds.save(expected);
commit fe7f34b7c81f58995cba007e0105478d3c53b97c
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 25 13:54:24 2011 -0400
Initial commit for entity classes and some initial unit tests
This commit provides the first cut at drift entities for mongodb. I also
provided an initial implementation for
DriftServerPluginFacet.saveChangeSet.
diff --git a/modules/enterprise/server/plugins/drift-mongodb/pom.xml b/modules/enterprise/server/plugins/drift-mongodb/pom.xml
index 8721db7..958d3e0 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/pom.xml
+++ b/modules/enterprise/server/plugins/drift-mongodb/pom.xml
@@ -33,6 +33,19 @@
</dependency>
<dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-common-drift</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.6.3</version>
@@ -72,16 +85,44 @@
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy-libs</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongo-java-driver</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.google.code.morphia</groupId>
+ <artifactId>morphia</artifactId>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<repositories>
- <id>morphia-repo</id>
- <name>Morphia Repo</name>
- <url>http://morphia.googlecode.com/svn/mavenrepo/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
+ <repository>
+ <id>morphia-repo</id>
+ <name>Morphia Repo</name>
+ <url>http://morphia.googlecode.com/svn/mavenrepo/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
</repositories>
<profiles>
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index d7c7202..722dd22 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -1,12 +1,61 @@
package org.rhq.enterprise.server.plugins.drift.mongodb;
+import java.io.BufferedReader;
import java.io.File;
-
+import java.io.InputStreamReader;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import com.google.code.morphia.Datastore;
+import com.google.code.morphia.Morphia;
+import com.mongodb.Mongo;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.common.drift.ChangeSetReader;
+import org.rhq.common.drift.ChangeSetReaderImpl;
+import org.rhq.common.drift.DirectoryEntry;
+import org.rhq.common.drift.FileEntry;
+import org.rhq.common.drift.Headers;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftComposite;
+import org.rhq.core.domain.drift.Snapshot;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.ZipUtil;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
+import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet;
+import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSetEntry;
+import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBFile;
public class MongoDBDriftServer implements DriftServerPluginFacet {
+ private final Log log = LogFactory.getLog(MongoDBDriftServer.class);
+
+ private Mongo connection;
+
+ private Morphia morphia;
+
+ private Datastore ds;
+
+ static int changeSetVersions = 0;
+
+ @Override
+ public void initialize(ServerPluginContext context) throws Exception {
+ connection = new Mongo("localhost");
+ morphia = new Morphia()
+ .map(MongoDBChangeSet.class)
+ .map(MongoDBChangeSetEntry.class)
+ .map(MongoDBFile.class);
+ ds = morphia.createDatastore(connection, "rhq");
+ }
+
@Override
public void start() {
@@ -23,8 +72,33 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
}
@Override
- public void saveChangeSet(int resourceId, File changeSetZip) throws Exception {
-
+ public void saveChangeSet(final int resourceId, final File changeSetZip) throws Exception {
+ ZipUtil.walkZipFile(changeSetZip, new ZipUtil.ZipEntryVisitor() {
+ @Override
+ public boolean visit(ZipEntry zipEntry, ZipInputStream stream) throws Exception {
+ ChangeSetReader reader = new ChangeSetReaderImpl(new BufferedReader(new InputStreamReader(stream)));
+
+ Headers headers = reader.getHeaders();
+ MongoDBChangeSet changeSet = new MongoDBChangeSet();
+ changeSet.setCategory(headers.getType());
+ changeSet.setResourceId(resourceId);
+ // TODO Figure out how best to handle drift config reference
+ changeSet.setDriftConfigurationId(1);
+ changeSet.setVersion(changeSetVersions++);
+
+ for (DirectoryEntry dirEntry : reader) {
+ for (FileEntry fileEntry : dirEntry) {
+ MongoDBChangeSetEntry entry = new MongoDBChangeSetEntry();
+ entry.setCategory(fileEntry.getType());
+ entry.setPath(fileEntry.getFile());
+ changeSet.add(entry);
+ }
+ }
+
+ ds.save(changeSet);
+ return true;
+ }
+ });
}
@Override
@@ -33,8 +107,22 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
}
@Override
- public void initialize(ServerPluginContext context) throws Exception {
+ public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
+ return new PageList<DriftChangeSet>();
+ }
+ @Override
+ public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
+ return new PageList<Drift>();
}
+ @Override
+ public PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria) {
+ return new PageList<DriftComposite>();
+ }
+
+ @Override
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ return null;
+ }
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
new file mode 100644
index 0000000..2640eff
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
@@ -0,0 +1,110 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.code.morphia.annotations.Embedded;
+import com.google.code.morphia.annotations.Entity;
+import com.google.code.morphia.annotations.Id;
+
+import org.bson.types.ObjectId;
+
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+
+@Entity("changesets")
+public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry> {
+
+ @Id
+ private ObjectId id;
+
+ private Long ctime = System.currentTimeMillis();
+
+ private int version;
+
+ private DriftChangeSetCategory category;
+
+ private int configId;
+
+ private int resourceId;
+
+ @Embedded("files")
+ private Set<MongoDBChangeSetEntry> entries = new HashSet<MongoDBChangeSetEntry>();
+
+ public ObjectId getObjectId() {
+ return id;
+ }
+
+ @Override
+ public String getId() {
+ return id.toString();
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = new ObjectId(id);
+ }
+
+ public void setId(ObjectId id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public int getDriftConfigurationId() {
+ return configId;
+ }
+
+ @Override
+ public void setDriftConfigurationId(int id) {
+ configId = id;
+ }
+
+ @Override
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(int id) {
+ resourceId = id;
+ }
+
+ @Override
+ public Set<MongoDBChangeSetEntry> getDrifts() {
+ return entries;
+ }
+
+ public MongoDBChangeSet add(MongoDBChangeSetEntry entry) {
+ entries.add(entry);
+ return this;
+ }
+
+ @Override
+ public void setDrifts(Set<MongoDBChangeSetEntry> drifts) {
+ entries = drifts;
+ }
+}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
new file mode 100644
index 0000000..80cdc0c
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
@@ -0,0 +1,77 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+
+import com.google.code.morphia.annotations.Embedded;
+
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftCategory;
+
+@Embedded
+public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFile> {
+
+ private Long ctime = System.currentTimeMillis();
+
+ private DriftCategory category;
+
+ private String path;
+
+ @Override
+ public String getId() {
+ return null;
+ }
+
+ @Override
+ public void setId(String id) {
+ }
+
+ @Override
+ public Long getCtime() {
+ return null;
+ }
+
+ @Override
+ public MongoDBChangeSet getChangeSet() {
+ return null;
+ }
+
+ @Override
+ public void setChangeSet(MongoDBChangeSet changeSet) {
+ }
+
+ @Override
+ public DriftCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public MongoDBFile getOldDriftFile() {
+ return null;
+ }
+
+ @Override
+ public void setOldDriftFile(MongoDBFile oldDriftFile) {
+ }
+
+ @Override
+ public MongoDBFile getNewDriftFile() {
+ return null;
+ }
+
+ @Override
+ public void setNewDriftFile(MongoDBFile newDriftFile) {
+ }
+}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBFile.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBFile.java
new file mode 100644
index 0000000..ea0c509
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBFile.java
@@ -0,0 +1,49 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+
+import com.google.code.morphia.annotations.Entity;
+import com.google.code.morphia.annotations.Id;
+
+import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.drift.DriftFileStatus;
+
+@Entity
+public class MongoDBFile implements DriftFile {
+
+ @Id
+ private String hash;
+
+ @Override
+ public String getHashId() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setHashId(String hashId) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Long getCtime() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Long getDataSize() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setDataSize(Long size) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public DriftFileStatus getStatus() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setStatus(DriftFileStatus status) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
index e1894d0..eb32c51 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -4,9 +4,9 @@
version="1.0"
apiVersion="1.0"
description="The Drift Management MongoDB Persistence Store"
- displayName="Drift:RHQ"
+ displayName="Drift:MongoDB"
name="drift-mongodb"
- package="org.rhq.enterprise.server.plugins.drift.MorphiaTest"
+ package="org.rhq.enterprise.server.plugins.drift.mongodb"
xmlns="urn:xmlns:rhq-serverplugin.drift"
xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java
deleted file mode 100644
index c88432e..0000000
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.rhq.enterprise.server.plugins.drift;
-
-import com.google.code.morphia.Datastore;
-import com.google.code.morphia.Morphia;
-import com.mongodb.DB;
-import com.mongodb.Mongo;
-
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.drift.DriftChangeSet;
-
-public class MorphiaTest {
-
- @Test
- public void connectToMongoDB() throws Exception {
- Mongo connection = new Mongo("localhost");
- DB db = connection.getDB("test");
-
- Morphia morphia = new Morphia();
- morphia.map(DriftChangeSet.class);
-
- Datastore ds = morphia.createDatastore(connection, "test");
-
-// DriftChangeSet changeSet = new DriftChangeSet(null, 1, COVERAGE);
-// ds.save(changeSet);
- }
-
-}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
new file mode 100644
index 0000000..e6aec82
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -0,0 +1,71 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+
+import com.google.code.morphia.Datastore;
+import com.google.code.morphia.Morphia;
+import com.google.code.morphia.query.Query;
+import com.mongodb.Mongo;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
+import static org.rhq.test.AssertUtils.assertPropertiesMatch;
+import static org.testng.Assert.assertNotNull;
+
+public class MongoDBChangeSetTest {
+
+ Mongo connection;
+
+ Morphia morphia;
+
+ Datastore ds;
+
+ @BeforeClass
+ public void initDB() throws Exception {
+ connection = new Mongo("localhost");
+
+ morphia = new Morphia()
+ .map(MongoDBChangeSet.class)
+ .map(MongoDBChangeSetEntry.class)
+ .map(MongoDBFile.class);
+
+ ds = morphia.createDatastore(connection, "rhq");
+ }
+
+ @BeforeMethod
+ public void clearCollections() throws Exception {
+ Query deleteAll = ds.createQuery(MongoDBChangeSet.class);
+ ds.delete(deleteAll);
+ }
+
+ @Test
+ public void saveAndLoadEmptyChangeSet() throws Exception {
+ MongoDBChangeSet expected = new MongoDBChangeSet();
+ expected.setCategory(COVERAGE);
+ expected.setVersion(1);
+ expected.setDriftConfigurationId(1);
+
+ ds.save(expected);
+ MongoDBChangeSet actual = ds.get(MongoDBChangeSet.class, expected.getObjectId());
+
+ assertNotNull(actual, "Failed to load change set");
+ assertPropertiesMatch("Failed to save change set", expected, actual);
+ }
+
+ @Test
+ public void saveAndLoadChangeSetWithOneEntry() throws Exception {
+ MongoDBChangeSet expected = new MongoDBChangeSet();
+ expected.getDrifts().add(new MongoDBChangeSetEntry());
+
+ ds.save(expected);
+
+ MongoDBChangeSet actual = ds.get(MongoDBChangeSet.class, expected.getObjectId());
+
+ assertNotNull(expected, "Failed to load change set");
+ assertPropertiesMatch("Failed to save change set", expected, actual, "drifts");
+ assertCollectionMatchesNoOrder(expected.getDrifts(), actual.getDrifts(), "Failed to save change set entries");
+ }
+
+}
commit dd2b33298b58db71552a7435bd9dbdb1bcaa125b
Merge: d2b6c62 3b0c734
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 24 22:01:49 2011 -0400
Merge branch 'drift' into drift-mongodb
Conflicts:
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDrift.java
modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDriftChangeSet.java
modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
diff --cc modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index 26520a1,bc8d26a..0000000
deleted file mode 100644,100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ /dev/null
commit d2b6c62d7894fc85f8bf0613d36d957f70b81581
Merge: fc8d638 bc3c8ab
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 21:08:01 2011 -0400
Merge branch 'drift' into drift-mongodb
commit bc3c8abff3baaade68753f45e0eb47a049815e5f
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 20:58:25 2011 -0400
More refactoring to better support criteria queries for non-JPA back ends
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
new file mode 100644
index 0000000..edc436b
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
@@ -0,0 +1,15 @@
+package org.rhq.core.domain.criteria;
+
+import org.rhq.core.domain.util.PageControl;
+
+/**
+ * Created by IntelliJ IDEA. User: jsanda Date: 7/19/11 Time: 5:30 PM To change this template use File | Settings | File
+ * Templates.
+ */
+public interface BaseCriteria {
+
+ PageControl getPageControlOverrides();
+
+ void setPageControl(PageControl pageControl);
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
index b3c4dc2..55201d8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
@@ -40,7 +40,7 @@ import org.rhq.core.domain.util.PageList;
* @author Joseph Marques
*/
@XmlAccessorType(XmlAccessType.FIELD)
-public abstract class Criteria implements Serializable {
+public abstract class Criteria implements Serializable, BaseCriteria {
public enum Type {
FILTER, FETCH, SORT;
}
@@ -150,6 +150,7 @@ public abstract class Criteria implements Serializable {
* which is useful from a server-side calling context where the PageControl object
* will already have been created for you by the extensions at the JSF layer.
*/
+ @Override
public void setPageControl(PageControl pageControl) {
this.pageControlOverrides = pageControl;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
new file mode 100644
index 0000000..9b39cc3
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.criteria;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Jay Shaughnessy
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSetCriteria {
+ private static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private Integer filterInitial; // needs override
+ private Integer filterResourceId; // needs override
+ private String filterVersion;
+ private DriftChangeSetCategory filterCategory;
+ private boolean fetchDrifts;
+
+ private PageOrdering sortVersion;
+
+ public DriftChangeSetJPACriteria() {
+ filterOverrides.put("initial", "version = 0");
+ filterOverrides.put("resourceId", "resource.id = ?");
+ }
+
+ @Override
+ public Class<RhqDriftChangeSet> getPersistentClass() {
+ return RhqDriftChangeSet.class;
+ }
+
+ public void addFilterId(String filterId) {
+ if (filterId != null) {
+ this.filterId = Integer.parseInt(filterId);
+ }
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId == null ? null : filterId.toString();
+ }
+
+ public void addFilterVersion(String filterVersion) {
+ this.filterVersion = filterVersion;
+ }
+
+ @Override
+ public String getFilterVersion() {
+ return filterVersion;
+ }
+
+ public void addFilterResourceId(Integer filterResourceId) {
+ this.filterResourceId = filterResourceId;
+ }
+
+ @Override
+ public Integer getFilterResourceId() {
+ return filterResourceId;
+ }
+
+ public void addFilterCategory(DriftChangeSetCategory filterCategory) {
+ this.filterCategory = filterCategory;
+ }
+
+ @Override
+ public DriftChangeSetCategory getFilterCategory() {
+ return filterCategory;
+ }
+
+ public void fetchDrifts(boolean fetchDrifts) {
+ this.fetchDrifts = fetchDrifts;
+ }
+
+ @Override
+ public boolean isFetchDrifts() {
+ return fetchDrifts;
+ }
+
+ public void addSortVersion(PageOrdering sortVersion) {
+ addSortField("version");
+ this.sortVersion = sortVersion;
+ }
+
+ @Override
+ public PageOrdering getSortVersion() {
+ return sortVersion;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
index dc9764c..cdd061e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
@@ -6,7 +6,7 @@ import java.util.List;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.util.PageOrdering;
-public interface DriftCriteria extends Serializable {
+public interface DriftCriteria extends BaseCriteria, Serializable {
void addFilterId(String filterId);
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftJPACriteria.java
new file mode 100644
index 0000000..506cb06
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftJPACriteria.java
@@ -0,0 +1,153 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.criteria;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.util.CriteriaUtils;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Jay Shaughnessy
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class DriftJPACriteria extends Criteria implements DriftCriteria {
+ private static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private List<DriftCategory> filterCategories = new ArrayList<DriftCategory>();
+ private Integer filterChangeSetId; // needs override
+ private String filterPath;
+ private List<Integer> filterResourceIds = new ArrayList<Integer>();
+ private Long filterStartTime; // requires overrides
+ private Long filterEndTime; // requires overrides
+
+ private boolean fetchChangeSet;
+
+ private PageOrdering sortCtime;
+
+ public DriftJPACriteria() {
+ filterOverrides.put("changeSetId", "changeSet.id = ?");
+ filterOverrides.put("categories", "category IN ( ? )");
+ filterOverrides.put("resourceIds", "changeSet.resource.id IN ( ? )");
+ filterOverrides.put("startTime", "ctime >= ?");
+ filterOverrides.put("endTime", "ctime <= ?");
+ }
+
+ @Override
+ public Class<RhqDrift> getPersistentClass() {
+ return RhqDrift.class;
+ }
+
+ public void addFilterId(String filterId) {
+ if (filterId != null) {
+ this.filterId = Integer.parseInt(filterId);
+ }
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId == null ? null : filterId.toString();
+ }
+
+ public void addFilterCategories(DriftCategory... filterCategories) {
+ this.filterCategories = CriteriaUtils.getListIgnoringNulls(filterCategories);
+ }
+
+ @Override
+ public List<DriftCategory> getFilterCategories() {
+ return filterCategories;
+ }
+
+ public void addFilterChangeSetId(String filterChangeSetId) {
+ if (filterChangeSetId != null) {
+ this.filterChangeSetId = Integer.parseInt(filterChangeSetId);
+ }
+ }
+
+ @Override
+ public String getFilterChangeSetId() {
+ return filterChangeSetId == null ? null : filterChangeSetId.toString();
+ }
+
+ public void addFilterPath(String filterPath) {
+ this.filterPath = filterPath;
+ }
+
+ @Override
+ public String getFilterPath() {
+ return filterPath;
+ }
+
+ public void addFilterResourceIds(Integer... filterResourceIds) {
+ this.filterResourceIds = CriteriaUtils.getListIgnoringNulls(filterResourceIds);
+ }
+
+ @Override
+ public List<Integer> getFilterResourceIds() {
+ return filterResourceIds;
+ }
+
+ public void addFilterStartTime(Long filterStartTime) {
+ this.filterStartTime = filterStartTime;
+ }
+
+ @Override
+ public Long getFilterStartTime() {
+ return filterStartTime;
+ }
+
+ public void addFilterEndTime(Long filterEndTime) {
+ this.filterEndTime = filterEndTime;
+ }
+
+ @Override
+ public Long getFilterEndTime() {
+ return filterEndTime;
+ }
+
+ public void fetchChangeSet(boolean fetchChangeSet) {
+ this.fetchChangeSet = fetchChangeSet;
+ }
+
+ @Override
+ public boolean isFetchChangeSet() {
+ return fetchChangeSet;
+ }
+
+ public void addSortCtime(PageOrdering sortCtime) {
+ addSortField("ctime");
+ this.sortCtime = sortCtime;
+ }
+
+ @Override
+ public PageOrdering getSortCtime() {
+ return sortCtime;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java
deleted file mode 100644
index 7c09542..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.core.domain.criteria;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.rhq.core.domain.drift.DriftChangeSetCategory;
-import org.rhq.core.domain.drift.RhqDriftChangeSet;
-import org.rhq.core.domain.util.PageOrdering;
-
-/**
- * @author Jay Shaughnessy
- */
-@XmlRootElement
-(a)XmlAccessorType(XmlAccessType.FIELD)
-@SuppressWarnings("unused")
-public class RhqDriftChangeSetCriteria extends Criteria implements DriftChangeSetCriteria {
- private static final long serialVersionUID = 1L;
-
- private Integer filterId;
- private Integer filterInitial; // needs override
- private Integer filterResourceId; // needs override
- private String filterVersion;
- private DriftChangeSetCategory filterCategory;
- private boolean fetchDrifts;
-
- private PageOrdering sortVersion;
-
- public RhqDriftChangeSetCriteria() {
- filterOverrides.put("initial", "version = 0");
- filterOverrides.put("resourceId", "resource.id = ?");
- }
-
- @Override
- public Class<RhqDriftChangeSet> getPersistentClass() {
- return RhqDriftChangeSet.class;
- }
-
- public void addFilterId(String filterId) {
- if (filterId != null) {
- this.filterId = Integer.parseInt(filterId);
- }
- }
-
- @Override
- public String getFilterId() {
- return filterId == null ? null : filterId.toString();
- }
-
- public void addFilterVersion(String filterVersion) {
- this.filterVersion = filterVersion;
- }
-
- @Override
- public String getFilterVersion() {
- return filterVersion;
- }
-
- public void addFilterResourceId(Integer filterResourceId) {
- this.filterResourceId = filterResourceId;
- }
-
- @Override
- public Integer getFilterResourceId() {
- return filterResourceId;
- }
-
- public void addFilterCategory(DriftChangeSetCategory filterCategory) {
- this.filterCategory = filterCategory;
- }
-
- @Override
- public DriftChangeSetCategory getFilterCategory() {
- return filterCategory;
- }
-
- public void fetchDrifts(boolean fetchDrifts) {
- this.fetchDrifts = fetchDrifts;
- }
-
- @Override
- public boolean isFetchDrifts() {
- return fetchDrifts;
- }
-
- public void addSortVersion(PageOrdering sortVersion) {
- addSortField("version");
- this.sortVersion = sortVersion;
- }
-
- @Override
- public PageOrdering getSortVersion() {
- return sortVersion;
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
deleted file mode 100644
index ca37104..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.core.domain.criteria;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.rhq.core.domain.drift.DriftCategory;
-import org.rhq.core.domain.drift.RhqDrift;
-import org.rhq.core.domain.util.CriteriaUtils;
-import org.rhq.core.domain.util.PageOrdering;
-
-/**
- * @author Jay Shaughnessy
- */
-@XmlRootElement
-(a)XmlAccessorType(XmlAccessType.FIELD)
-@SuppressWarnings("unused")
-public class RhqDriftCriteria extends Criteria implements DriftCriteria {
- private static final long serialVersionUID = 1L;
-
- private Integer filterId;
- private List<DriftCategory> filterCategories = new ArrayList<DriftCategory>();
- private Integer filterChangeSetId; // needs override
- private String filterPath;
- private List<Integer> filterResourceIds = new ArrayList<Integer>();
- private Long filterStartTime; // requires overrides
- private Long filterEndTime; // requires overrides
-
- private boolean fetchChangeSet;
-
- private PageOrdering sortCtime;
-
- public RhqDriftCriteria() {
- filterOverrides.put("changeSetId", "changeSet.id = ?");
- filterOverrides.put("categories", "category IN ( ? )");
- filterOverrides.put("resourceIds", "changeSet.resource.id IN ( ? )");
- filterOverrides.put("startTime", "ctime >= ?");
- filterOverrides.put("endTime", "ctime <= ?");
- }
-
- @Override
- public Class<RhqDrift> getPersistentClass() {
- return RhqDrift.class;
- }
-
- public void addFilterId(String filterId) {
- if (filterId != null) {
- this.filterId = Integer.parseInt(filterId);
- }
- }
-
- @Override
- public String getFilterId() {
- return filterId == null ? null : filterId.toString();
- }
-
- public void addFilterCategories(DriftCategory... filterCategories) {
- this.filterCategories = CriteriaUtils.getListIgnoringNulls(filterCategories);
- }
-
- @Override
- public List<DriftCategory> getFilterCategories() {
- return filterCategories;
- }
-
- public void addFilterChangeSetId(String filterChangeSetId) {
- if (filterChangeSetId != null) {
- this.filterChangeSetId = Integer.parseInt(filterChangeSetId);
- }
- }
-
- @Override
- public String getFilterChangeSetId() {
- return filterChangeSetId == null ? null : filterChangeSetId.toString();
- }
-
- public void addFilterPath(String filterPath) {
- this.filterPath = filterPath;
- }
-
- @Override
- public String getFilterPath() {
- return filterPath;
- }
-
- public void addFilterResourceIds(Integer... filterResourceIds) {
- this.filterResourceIds = CriteriaUtils.getListIgnoringNulls(filterResourceIds);
- }
-
- @Override
- public List<Integer> getFilterResourceIds() {
- return filterResourceIds;
- }
-
- public void addFilterStartTime(Long filterStartTime) {
- this.filterStartTime = filterStartTime;
- }
-
- @Override
- public Long getFilterStartTime() {
- return filterStartTime;
- }
-
- public void addFilterEndTime(Long filterEndTime) {
- this.filterEndTime = filterEndTime;
- }
-
- @Override
- public Long getFilterEndTime() {
- return filterEndTime;
- }
-
- public void fetchChangeSet(boolean fetchChangeSet) {
- this.fetchChangeSet = fetchChangeSet;
- }
-
- @Override
- public boolean isFetchChangeSet() {
- return fetchChangeSet;
- }
-
- public void addSortCtime(PageOrdering sortCtime) {
- addSortField("ctime");
- this.sortCtime = sortCtime;
- }
-
- @Override
- public PageOrdering getSortCtime() {
- return sortCtime;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
index 59f9eb3..75967aa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
@@ -23,8 +23,7 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
@@ -356,8 +355,8 @@ public abstract class AbstractRecentDriftsPortlet extends DriftHistoryView imple
}
@Override
- protected RhqDriftCriteria getFetchCriteria(DSRequest request) {
- RhqDriftCriteria criteria = new RhqDriftCriteria();
+ protected DriftJPACriteria getFetchCriteria(DSRequest request) {
+ DriftJPACriteria criteria = new DriftJPACriteria();
// result count
String currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index 5c80eca..a9faf69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -38,7 +38,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftCategory;
@@ -61,7 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Jay Shaughnessy
* @author John Mazzitelli
*/
-public class DriftDataSource extends RPCDataSource<Drift, RhqDriftCriteria> {
+public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
public static final String CATEGORY_ICON_ADD = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_ADDED);
public static final String CATEGORY_ICON_CHANGE = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_CHANGED);
@@ -162,7 +162,7 @@ public class DriftDataSource extends RPCDataSource<Drift, RhqDriftCriteria> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final RhqDriftCriteria criteria) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final DriftCriteria criteria) {
if (criteria == null) {
// the user selected no categories in the filter - it makes sense from the UI perspective to show 0 rows
response.setTotalRows(0);
@@ -248,14 +248,14 @@ public class DriftDataSource extends RPCDataSource<Drift, RhqDriftCriteria> {
}
@Override
- protected RhqDriftCriteria getFetchCriteria(DSRequest request) {
+ protected DriftCriteria getFetchCriteria(DSRequest request) {
DriftCategory[] categoriesFilter = getArrayFilter(request, FILTER_CATEGORIES, DriftCategory.class);
if (categoriesFilter == null || categoriesFilter.length == 0) {
return null; // user didn't select any priorities - return null to indicate no data should be displayed
}
- RhqDriftCriteria criteria = new RhqDriftCriteria();
+ DriftJPACriteria criteria = new DriftJPACriteria();
criteria.fetchChangeSet(true);
criteria.addFilterCategories(categoriesFilter);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index f5ffc9c..9a5c52b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -28,7 +28,7 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
@@ -58,7 +58,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
}
private void show(String driftId) {
- DriftCriteria criteria = new RhqDriftCriteria();
+ DriftCriteria criteria = new DriftJPACriteria();
criteria.addFilterId(driftId);
criteria.fetchChangeSet(true);
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index d916075..014466b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -49,6 +49,7 @@ import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.criteria.BaseCriteria;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.operation.OperationRequestStatus;
@@ -72,7 +73,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class RPCDataSource<T, C extends org.rhq.core.domain.criteria.Criteria> extends DataSource {
+public abstract class RPCDataSource<T, C extends BaseCriteria> extends DataSource {
protected static final Messages MSG = CoreGUI.getMessages();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index f10c3fb..a1a7e6e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -58,8 +58,8 @@ import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
@@ -143,7 +143,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
try {
- RhqDriftChangeSetCriteria c = new RhqDriftChangeSetCriteria();
+ DriftChangeSetJPACriteria c = new DriftChangeSetJPACriteria();
c.addFilterResourceId(resourceId);
List<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
final int version = changeSets.size();
@@ -355,7 +355,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
@Override
public int deleteDriftsByContext(Subject subject, EntityContext entityContext) throws RuntimeException {
int result = 0;
- RhqDriftCriteria criteria = new RhqDriftCriteria();
+ DriftJPACriteria criteria = new DriftJPACriteria();
switch (entityContext.getType()) {
case Resource:
@@ -457,7 +457,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
- public PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, RhqDriftChangeSetCriteria criteria) {
+ public PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetJPACriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
CriteriaQueryRunner<RhqDriftChangeSet> queryRunner = new CriteriaQueryRunner<RhqDriftChangeSet>(criteria, generator,
@@ -467,7 +467,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
- public PageList<RhqDrift> findDriftsByCriteria(Subject subject, RhqDriftCriteria criteria) {
+ public PageList<RhqDrift> findDriftsByCriteria(Subject subject, DriftJPACriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
CriteriaQueryRunner<RhqDrift> queryRunner = new CriteriaQueryRunner<RhqDrift>(criteria, generator, entityManager);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index c052b46..de1453f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -26,8 +26,8 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.RhqDrift;
@@ -116,7 +116,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param criteria
* @return The DriftChangeSets matching the criteria
*/
- PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, RhqDriftChangeSetCriteria criteria);
+ PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetJPACriteria criteria);
/**
* Standard criteria based fetch method
@@ -124,7 +124,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param criteria
* @return The Drifts matching the criteria
*/
- PageList<RhqDrift> findDriftsByCriteria(Subject subject, RhqDriftCriteria criteria);
+ PageList<RhqDrift> findDriftsByCriteria(Subject subject, DriftJPACriteria criteria);
/**
* Get the specified drift configuration for the specified context.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
index ce3c4b0..0252284 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
@@ -40,7 +40,7 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
@@ -118,7 +118,7 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
assertTrue(changeset1.exists());
driftManager.storeChangeSet(newResource.getId(), changeset1);
- RhqDriftChangeSetCriteria c = new RhqDriftChangeSetCriteria();
+ DriftChangeSetJPACriteria c = new DriftChangeSetJPACriteria();
c.addFilterResourceId(newResource.getId());
c.fetchDrifts(true);
List<RhqDriftChangeSet> changeSets = driftManager.findDriftChangeSetsByCriteria(overlord, c);
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 67658f5..b727deb 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -27,8 +27,8 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftChangeSet;
@@ -71,7 +71,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
@Override
public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
- RhqDriftChangeSetCriteria rhqCriteria = new RhqDriftChangeSetCriteria();
+ DriftChangeSetJPACriteria rhqCriteria = new DriftChangeSetJPACriteria();
rhqCriteria.addFilterId(criteria.getFilterId());
rhqCriteria.addFilterResourceId(criteria.getFilterResourceId());
rhqCriteria.addFilterVersion(criteria.getFilterVersion());
@@ -85,7 +85,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
@Override
public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
- RhqDriftCriteria rhqCriteria = new RhqDriftCriteria();
+ DriftJPACriteria rhqCriteria = new DriftJPACriteria();
rhqCriteria.addFilterId(criteria.getFilterId());
rhqCriteria.addFilterCategories(criteria.getFilterCategories().toArray(new DriftCategory[] {}));
rhqCriteria.addFilterChangeSetId(criteria.getFilterChangeSetId());
commit 00dd47d5962a0b5a4129e4600594893b8e8ae9bf
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 15:08:25 2011 -0400
Cannot use java.util.Collections in criteria classes
Collections is not Serializable which was causing client-side errors in
the GWT code.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
index b5cb14e..ca37104 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
@@ -19,16 +19,15 @@
package org.rhq.core.domain.criteria;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
@@ -42,10 +41,10 @@ public class RhqDriftCriteria extends Criteria implements DriftCriteria {
private static final long serialVersionUID = 1L;
private Integer filterId;
- private List<DriftCategory> filterCategories = Collections.emptyList();
+ private List<DriftCategory> filterCategories = new ArrayList<DriftCategory>();
private Integer filterChangeSetId; // needs override
private String filterPath;
- private List<Integer> filterResourceIds = Collections.emptyList(); // requires overrides
+ private List<Integer> filterResourceIds = new ArrayList<Integer>();
private Long filterStartTime; // requires overrides
private Long filterEndTime; // requires overrides
commit 18c8e52eecc6bb71e2f6472de108215ba47eb96a
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 14:03:46 2011 -0400
Removing hibernate custom type and making criteria interfaces Serializable
IntegerString is not used so it can safely be removed.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index 023115d..6ba63df 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -1,9 +1,11 @@
package org.rhq.core.domain.criteria;
+import java.io.Serializable;
+
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.util.PageOrdering;
-public interface DriftChangeSetCriteria {
+public interface DriftChangeSetCriteria extends Serializable {
void addFilterId(String filterId);
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
index d693cb3..dc9764c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
@@ -1,11 +1,12 @@
package org.rhq.core.domain.criteria;
+import java.io.Serializable;
import java.util.List;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.util.PageOrdering;
-public interface DriftCriteria {
+public interface DriftCriteria extends Serializable {
void addFilterId(String filterId);
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
index 5d027dc..b5cb14e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
@@ -62,7 +62,7 @@ public class RhqDriftCriteria extends Criteria implements DriftCriteria {
}
@Override
- public Class<? extends Drift> getPersistentClass() {
+ public Class<RhqDrift> getPersistentClass() {
return RhqDrift.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/hibernate/types/IntegerString.java b/modules/core/domain/src/main/java/org/rhq/core/domain/hibernate/types/IntegerString.java
deleted file mode 100644
index 6fa6658..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/hibernate/types/IntegerString.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.rhq.core.domain.hibernate.types;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.usertype.UserType;
-
-public class IntegerString implements UserType {
-
- @Override
- public int[] sqlTypes() {
- return new int[] {Hibernate.INTEGER.sqlType()};
- }
-
- @Override
- public Class returnedClass() {
- return String.class;
- }
-
- @Override
- public boolean equals(Object x, Object y) throws HibernateException {
- if (x == y) {
- return true;
- }
- if (x == null || y == null) {
- return false;
- }
- return x.equals(y);
- }
-
- @Override
- public int hashCode(Object o) throws HibernateException {
- return o.hashCode();
- }
-
- @Override
- public Object nullSafeGet(ResultSet resultSet, String[] names, Object o) throws HibernateException, SQLException {
- int value = resultSet.getInt(names[0]);
-
- if (resultSet.wasNull()) {
- return null;
- }
- return Integer.toString(value);
- }
-
- @Override
- public void nullSafeSet(PreparedStatement stmt, Object value, int index) throws HibernateException,
- SQLException {
- if (value == null) {
- stmt.setNull(index, Hibernate.INTEGER.sqlType());
- } else {
- stmt.setInt(index, Integer.parseInt((String) value));
- }
- }
-
- @Override
- public Object deepCopy(Object value) throws HibernateException {
- return value;
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
-
- @Override
- public Serializable disassemble(Object value) throws HibernateException {
- return (Serializable) value;
- }
-
- @Override
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return cached;
- }
-
- @Override
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return original;
- }
-}
commit dc69b44ceb8d0eebc3d4aae3f9bab663bc7dc8a9
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 13:35:24 2011 -0400
Refactoring drift domain and criteria classes to make them pluggable
diff --git a/modules/core/client-api/src/main/resources/rhq-drift.xsd b/modules/core/client-api/src/main/resources/rhq-drift.xsd
index 2330c64..afc8142 100644
--- a/modules/core/client-api/src/main/resources/rhq-drift.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-drift.xsd
@@ -37,7 +37,7 @@
</xs:appinfo>
</xs:annotation>
- <xs:complexType name="Drift">
+ <xs:complexType name="RhqDrift">
<xs:annotation>
<xs:appinfo>
<jaxb:class name="DriftDescriptor" />
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index 355a354..023115d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -1,84 +1,32 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
package org.rhq.core.domain.criteria;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.util.PageOrdering;
-/**
- * @author Jay Shaughnessy
- */
-@XmlRootElement
-(a)XmlAccessorType(XmlAccessType.FIELD)
-@SuppressWarnings("unused")
-public class DriftChangeSetCriteria extends Criteria {
- private static final long serialVersionUID = 1L;
+public interface DriftChangeSetCriteria {
+
+ void addFilterId(String filterId);
- private String filterId;
- private Integer filterInitial; // needs override
- private Integer filterResourceId; // needs override
- private String filterVersion;
- private DriftChangeSetCategory filterCategory;
+ String getFilterId();
- private boolean fetchDrifts;
+ void addFilterVersion(String filterVersion);
- private PageOrdering sortVersion;
+ String getFilterVersion();
- public DriftChangeSetCriteria() {
- filterOverrides.put("initial", "version = 0");
- filterOverrides.put("resourceId", "resource.id = ?");
- }
+ void addFilterResourceId(Integer filterResourceId);
- @Override
- public Class<DriftChangeSet> getPersistentClass() {
- return DriftChangeSet.class;
- }
+ Integer getFilterResourceId();
- public void addFilterId(String filterId) {
- this.filterId = filterId;
- }
+ void addFilterCategory(DriftChangeSetCategory filterCategory);
- public void addFilterVersion(String filterVersion) {
- this.filterVersion = filterVersion;
- }
+ DriftChangeSetCategory getFilterCategory();
- public void addFilterResourceId(Integer filterResourceId) {
- this.filterResourceId = filterResourceId;
- }
+ void fetchDrifts(boolean fetchDrifts);
- public void addFilterCategory(DriftChangeSetCategory filterCategory) {
- this.filterCategory = filterCategory;
- }
+ boolean isFetchDrifts();
- public void fetchDrifts(boolean fetchDrifts) {
- this.fetchDrifts = fetchDrifts;
- }
+ void addSortVersion(PageOrdering sortVersion);
- public void addSortVersion(PageOrdering sortVersion) {
- addSortField("version");
- this.sortVersion = sortVersion;
- }
+ PageOrdering getSortVersion();
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
index 1988410..d693cb3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
@@ -1,104 +1,48 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
package org.rhq.core.domain.criteria;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
-import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
-/**
- * @author Jay Shaughnessy
- */
-@XmlRootElement
-(a)XmlAccessorType(XmlAccessType.FIELD)
-@SuppressWarnings("unused")
-public class DriftCriteria extends Criteria {
- private static final long serialVersionUID = 1L;
-
- private String filterId;
- private List<DriftCategory> filterCategories;
- private String filterChangeSetId; // needs override
- private String filterPath;
- private List<Integer> filterResourceIds; // requires overrides
- private Long filterStartTime; // requires overrides
- private Long filterEndTime; // requires overrides
-
- private boolean fetchChangeSet;
-
- private PageOrdering sortCtime;
-
- public DriftCriteria() {
- filterOverrides.put("changeSetId", "changeSet.id = ?");
- filterOverrides.put("categories", "category IN ( ? )");
- filterOverrides.put("resourceIds", "changeSet.resource.id IN ( ? )");
- filterOverrides.put("startTime", "ctime >= ?");
- filterOverrides.put("endTime", "ctime <= ?");
- }
-
- @Override
- public Class<Drift> getPersistentClass() {
- return Drift.class;
- }
-
- public void addFilterId(String filterId) {
- this.filterId = filterId;
- }
-
- public void addFilterCategories(DriftCategory... filterCategories) {
- this.filterCategories = CriteriaUtils.getListIgnoringNulls(filterCategories);
- }
-
- public void addFilterChangeSetId(String filterChangeSetId) {
- this.filterChangeSetId = filterChangeSetId;
- }
-
- public void addFilterPath(String filterPath) {
- this.filterPath = filterPath;
- }
-
- public void addFilterResourceIds(Integer... filterResourceIds) {
- this.filterResourceIds = CriteriaUtils.getListIgnoringNulls(filterResourceIds);
- }
-
- public void addFilterStartTime(Long filterStartTime) {
- this.filterStartTime = filterStartTime;
- }
-
- public void addFilterEndTime(Long filterEndTime) {
- this.filterEndTime = filterEndTime;
- }
-
- public void fetchChangeSet(boolean fetchChangeSet) {
- this.fetchChangeSet = fetchChangeSet;
- }
-
- public void addSortCtime(PageOrdering sortCtime) {
- addSortField("ctime");
- this.sortCtime = sortCtime;
- }
+public interface DriftCriteria {
+
+ void addFilterId(String filterId);
+
+ String getFilterId();
+
+ void addFilterCategories(DriftCategory... filterCategories);
+
+ List<DriftCategory> getFilterCategories();
+
+ void addFilterChangeSetId(String filterChangeSetId);
+
+ String getFilterChangeSetId();
+
+ void addFilterPath(String filterPath);
+
+ String getFilterPath();
+
+ void addFilterResourceIds(Integer... filterResourceIds);
+
+ List<Integer> getFilterResourceIds();
+
+ void addFilterStartTime(Long filterStartTime);
+
+ Long getFilterStartTime();
+
+ void addFilterEndTime(Long filterEndTime);
+
+ Long getFilterEndTime();
+
+ void fetchChangeSet(boolean fetchChangeSet);
+
+ boolean isFetchChangeSet();
+
+ void addSortCtime(PageOrdering sortCtime);
+
+ PageOrdering getSortCtime();
+
+
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java
new file mode 100644
index 0000000..7c09542
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.criteria;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Jay Shaughnessy
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class RhqDriftChangeSetCriteria extends Criteria implements DriftChangeSetCriteria {
+ private static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private Integer filterInitial; // needs override
+ private Integer filterResourceId; // needs override
+ private String filterVersion;
+ private DriftChangeSetCategory filterCategory;
+ private boolean fetchDrifts;
+
+ private PageOrdering sortVersion;
+
+ public RhqDriftChangeSetCriteria() {
+ filterOverrides.put("initial", "version = 0");
+ filterOverrides.put("resourceId", "resource.id = ?");
+ }
+
+ @Override
+ public Class<RhqDriftChangeSet> getPersistentClass() {
+ return RhqDriftChangeSet.class;
+ }
+
+ public void addFilterId(String filterId) {
+ if (filterId != null) {
+ this.filterId = Integer.parseInt(filterId);
+ }
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId == null ? null : filterId.toString();
+ }
+
+ public void addFilterVersion(String filterVersion) {
+ this.filterVersion = filterVersion;
+ }
+
+ @Override
+ public String getFilterVersion() {
+ return filterVersion;
+ }
+
+ public void addFilterResourceId(Integer filterResourceId) {
+ this.filterResourceId = filterResourceId;
+ }
+
+ @Override
+ public Integer getFilterResourceId() {
+ return filterResourceId;
+ }
+
+ public void addFilterCategory(DriftChangeSetCategory filterCategory) {
+ this.filterCategory = filterCategory;
+ }
+
+ @Override
+ public DriftChangeSetCategory getFilterCategory() {
+ return filterCategory;
+ }
+
+ public void fetchDrifts(boolean fetchDrifts) {
+ this.fetchDrifts = fetchDrifts;
+ }
+
+ @Override
+ public boolean isFetchDrifts() {
+ return fetchDrifts;
+ }
+
+ public void addSortVersion(PageOrdering sortVersion) {
+ addSortField("version");
+ this.sortVersion = sortVersion;
+ }
+
+ @Override
+ public PageOrdering getSortVersion() {
+ return sortVersion;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
new file mode 100644
index 0000000..5d027dc
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
@@ -0,0 +1,154 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.criteria;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.util.CriteriaUtils;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Jay Shaughnessy
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class RhqDriftCriteria extends Criteria implements DriftCriteria {
+ private static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private List<DriftCategory> filterCategories = Collections.emptyList();
+ private Integer filterChangeSetId; // needs override
+ private String filterPath;
+ private List<Integer> filterResourceIds = Collections.emptyList(); // requires overrides
+ private Long filterStartTime; // requires overrides
+ private Long filterEndTime; // requires overrides
+
+ private boolean fetchChangeSet;
+
+ private PageOrdering sortCtime;
+
+ public RhqDriftCriteria() {
+ filterOverrides.put("changeSetId", "changeSet.id = ?");
+ filterOverrides.put("categories", "category IN ( ? )");
+ filterOverrides.put("resourceIds", "changeSet.resource.id IN ( ? )");
+ filterOverrides.put("startTime", "ctime >= ?");
+ filterOverrides.put("endTime", "ctime <= ?");
+ }
+
+ @Override
+ public Class<? extends Drift> getPersistentClass() {
+ return RhqDrift.class;
+ }
+
+ public void addFilterId(String filterId) {
+ if (filterId != null) {
+ this.filterId = Integer.parseInt(filterId);
+ }
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId == null ? null : filterId.toString();
+ }
+
+ public void addFilterCategories(DriftCategory... filterCategories) {
+ this.filterCategories = CriteriaUtils.getListIgnoringNulls(filterCategories);
+ }
+
+ @Override
+ public List<DriftCategory> getFilterCategories() {
+ return filterCategories;
+ }
+
+ public void addFilterChangeSetId(String filterChangeSetId) {
+ if (filterChangeSetId != null) {
+ this.filterChangeSetId = Integer.parseInt(filterChangeSetId);
+ }
+ }
+
+ @Override
+ public String getFilterChangeSetId() {
+ return filterChangeSetId == null ? null : filterChangeSetId.toString();
+ }
+
+ public void addFilterPath(String filterPath) {
+ this.filterPath = filterPath;
+ }
+
+ @Override
+ public String getFilterPath() {
+ return filterPath;
+ }
+
+ public void addFilterResourceIds(Integer... filterResourceIds) {
+ this.filterResourceIds = CriteriaUtils.getListIgnoringNulls(filterResourceIds);
+ }
+
+ @Override
+ public List<Integer> getFilterResourceIds() {
+ return filterResourceIds;
+ }
+
+ public void addFilterStartTime(Long filterStartTime) {
+ this.filterStartTime = filterStartTime;
+ }
+
+ @Override
+ public Long getFilterStartTime() {
+ return filterStartTime;
+ }
+
+ public void addFilterEndTime(Long filterEndTime) {
+ this.filterEndTime = filterEndTime;
+ }
+
+ @Override
+ public Long getFilterEndTime() {
+ return filterEndTime;
+ }
+
+ public void fetchChangeSet(boolean fetchChangeSet) {
+ this.fetchChangeSet = fetchChangeSet;
+ }
+
+ @Override
+ public boolean isFetchChangeSet() {
+ return fetchChangeSet;
+ }
+
+ public void addSortCtime(PageOrdering sortCtime) {
+ addSortField("ctime");
+ this.sortCtime = sortCtime;
+ }
+
+ @Override
+ public PageOrdering getSortCtime() {
+ return sortCtime;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java
index a9e95e0..ef6a1ed 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java
@@ -1,171 +1,29 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
package org.rhq.core.domain.drift;
-import java.io.Serializable;
+public interface Drift {
+ String getId();
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.PrePersist;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
+ void setId(String id);
-import org.hibernate.annotations.Type;
+ Long getCtime();
-/**
- * An occurrence of drifty to be reported and managed by the user.
-
- * @author Jay Shaughnessy
- * @author John Sanda
- */
-@Entity
-@NamedQueries( { @NamedQuery(name = Drift.QUERY_DELETE_BY_RESOURCES, query = "" //
- + "DELETE FROM Drift d " //
- + " WHERE d.changeSet IN ( SELECT dcs FROM DriftChangeSet dcs WHERE dcs.resource.id IN ( :resourceIds ) ) )") })
-@Table(name = "RHQ_DRIFT")
-@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DRIFT_ID_SEQ")
-public class Drift implements Serializable {
- private static final long serialVersionUID = 1L;
+ DriftChangeSet getChangeSet();
- public static final String QUERY_DELETE_BY_RESOURCES = "Drift.deleteByResources";
+ void setChangeSet(RhqDriftChangeSet changeSet);
- @Type(type = "org.rhq.core.domain.hibernate.types.IntegerString")
- @Column(name = "ID", nullable = false)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
- @Id
- private String id;
+ DriftCategory getCategory();
- @Column(name = "CTIME", nullable = false)
- private Long ctime = -1L;
+ void setCategory(DriftCategory category);
- @Column(name = "CATEGORY", nullable = false)
- @Enumerated(EnumType.STRING)
- private DriftCategory category;
+ String getPath();
- @Column(name = "PATH", nullable = false)
- @Enumerated(EnumType.STRING)
- private String path;
+ void setPath(String path);
- @JoinColumn(name = "DRIFT_CHANGE_SET_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY, optional = false)
- private DriftChangeSet changeSet;
+ DriftFile getOldDriftFile();
- @JoinColumn(name = "OLD_DRIFT_FILE", referencedColumnName = "HASH_ID", nullable = true)
- @ManyToOne(fetch = FetchType.EAGER, optional = true)
- private DriftFile oldDriftFile;
+ void setOldDriftFile(DriftFile oldDriftFile);
- @JoinColumn(name = "NEW_DRIFT_FILE", referencedColumnName = "HASH_ID", nullable = true)
- @ManyToOne(fetch = FetchType.EAGER, optional = true)
- private DriftFile newDriftFile;
-
- protected Drift() {
- }
-
- /**
- * @param resource
- * @param category
- * @param oldDriftFile required for FILE_CHANGED and FILE_REMOVED, null for FILE_ADDED
- * @param newDriftFile required for FILE_CHANGED and FILE_ADDED, null for FILE_REMOVED
- */
- public Drift(DriftChangeSet changeSet, String path, DriftCategory category, DriftFile oldDriftFile,
- DriftFile newDriftFile) {
- this.changeSet = changeSet;
- this.path = path;
- this.category = category;
- this.oldDriftFile = oldDriftFile;
- this.newDriftFile = newDriftFile;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Long getCtime() {
- return ctime;
- }
-
- @PrePersist
- void onPersist() {
- this.ctime = System.currentTimeMillis();
- }
-
- public DriftChangeSet getChangeSet() {
- return changeSet;
- }
-
- public void setChangeSet(DriftChangeSet changeSet) {
- this.changeSet = changeSet;
- }
-
- public DriftCategory getCategory() {
- return category;
- }
-
- public void setCategory(DriftCategory category) {
- this.category = category;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public DriftFile getOldDriftFile() {
- return oldDriftFile;
- }
-
- public void setOldDriftFile(DriftFile oldDriftFile) {
- this.oldDriftFile = oldDriftFile;
- }
-
- public DriftFile getNewDriftFile() {
- return newDriftFile;
- }
-
- public void setNewDriftFile(DriftFile newDriftFile) {
- this.newDriftFile = newDriftFile;
- }
-
- @Override
- public String toString() {
- return "Drift [ id=" + id + ", category=" + category + ", path=" + path + ", changeSet=" + changeSet + "]";
- }
+ DriftFile getNewDriftFile();
+ void setNewDriftFile(DriftFile newDriftFile);
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
index 97a76ee..a07a95a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
@@ -1,152 +1,29 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
package org.rhq.core.domain.drift;
-import java.io.Serializable;
-import java.util.LinkedHashSet;
import java.util.Set;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.PrePersist;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-import org.hibernate.annotations.Type;
-
import org.rhq.core.domain.resource.Resource;
-/**
- * @author Jay Shaughnessy
- * @author John Sanda
- */
-@Entity
-@NamedQueries( { @NamedQuery(name = DriftChangeSet.QUERY_DELETE_BY_RESOURCES, query = "" //
- + "DELETE FROM DriftChangeSet dcs " //
- + " WHERE dcs.resource.id IN ( :resourceIds )") })
-@Table(name = "RHQ_DRIFT_CHANGE_SET")
-@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DRIFT_CHANGE_SET_ID_SEQ")
-public class DriftChangeSet implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public static final String QUERY_DELETE_BY_RESOURCES = "DriftChangeSet.deleteByResources";
-
- @Type(type = "org.rhq.core.domain.hibernate.types.IntegerString")
- @Column(name = "ID", nullable = false)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
- @Id
- private String id;
-
- @Column(name = "CTIME", nullable = false)
- private Long ctime = -1L;
-
- // 0..N
- @Column(name = "VERSION", nullable = false)
- private int version;
-
- @Column(name = "CATEGORY", nullable = false)
- @Enumerated(EnumType.STRING)
- private DriftChangeSetCategory category;
-
- @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(optional = false)
- private Resource resource;
-
- @OneToMany(mappedBy = "changeSet", cascade = { CascadeType.ALL })
- private Set<Drift> drifts = new LinkedHashSet<Drift>();
-
- protected DriftChangeSet() {
- }
-
- public DriftChangeSet(Resource resource, int version, DriftChangeSetCategory category) {
- this.resource = resource;
- this.version = version;
- this.category = category;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Long getCtime() {
- return ctime;
- }
-
- @PrePersist
- void onPersist() {
- this.ctime = System.currentTimeMillis();
- }
+public interface DriftChangeSet<D extends Drift> {
+ String getId();
- public int getVersion() {
- return version;
- }
+ void setId(String id);
- public void setVersion(int version) {
- this.version = version;
- }
+ Long getCtime();
- public DriftChangeSetCategory getCategory() {
- return category;
- }
+ int getVersion();
- public void setCategory(DriftChangeSetCategory category) {
- this.category = category;
- }
+ void setVersion(int version);
- public Resource getResource() {
- return resource;
- }
+ DriftChangeSetCategory getCategory();
- public void setResource(Resource resource) {
- this.resource = resource;
- }
+ void setCategory(DriftChangeSetCategory category);
- public Set<Drift> getDrifts() {
- return drifts;
- }
+ Resource getResource();
- public void setDrifts(Set<Drift> drifts) {
- this.drifts = drifts;
- }
+ void setResource(Resource resource);
- @Override
- public String toString() {
- return "DriftChangeSet [id=" + id + ", resource=" + resource + ", version=" + version + "]";
- }
+ Set<D> getDrifts();
+ void setDrifts(Set<D> drifts);
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDrift.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDrift.java
new file mode 100644
index 0000000..d82520e
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDrift.java
@@ -0,0 +1,183 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.drift;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrePersist;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+
+/**
+ * An occurrence of drifty to be reported and managed by the user.
+
+ * @author Jay Shaughnessy
+ * @author John Sanda
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = RhqDrift.QUERY_DELETE_BY_RESOURCES, query = "" //
+ + "DELETE FROM RhqDrift d " //
+ + " WHERE d.changeSet IN ( SELECT dcs FROM RhqDriftChangeSet dcs WHERE dcs.resource.id IN ( :resourceIds ) ) )") })
+@Table(name = "RHQ_DRIFT")
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DRIFT_ID_SEQ")
+public class RhqDrift implements Serializable, Drift {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_DELETE_BY_RESOURCES = "RhqDrift.deleteByResources";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "CTIME", nullable = false)
+ private Long ctime = -1L;
+
+ @Column(name = "CATEGORY", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private DriftCategory category;
+
+ @Column(name = "PATH", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private String path;
+
+ @JoinColumn(name = "DRIFT_CHANGE_SET_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ private RhqDriftChangeSet changeSet;
+
+ @JoinColumn(name = "OLD_DRIFT_FILE", referencedColumnName = "HASH_ID", nullable = true)
+ @ManyToOne(fetch = FetchType.EAGER, optional = true)
+ private DriftFile oldDriftFile;
+
+ @JoinColumn(name = "NEW_DRIFT_FILE", referencedColumnName = "HASH_ID", nullable = true)
+ @ManyToOne(fetch = FetchType.EAGER, optional = true)
+ private DriftFile newDriftFile;
+
+ protected RhqDrift() {
+ }
+
+ /**
+ * @param resource
+ * @param category
+ * @param oldDriftFile required for FILE_CHANGED and FILE_REMOVED, null for FILE_ADDED
+ * @param newDriftFile required for FILE_CHANGED and FILE_ADDED, null for FILE_REMOVED
+ */
+ public RhqDrift(RhqDriftChangeSet changeSet, String path, DriftCategory category, DriftFile oldDriftFile,
+ DriftFile newDriftFile) {
+ this.changeSet = changeSet;
+ this.path = path;
+ this.category = category;
+ this.oldDriftFile = oldDriftFile;
+ this.newDriftFile = newDriftFile;
+ }
+
+ @Override
+ public String getId() {
+ return Integer.toString(id);
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = Integer.parseInt(id);
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @PrePersist
+ void onPersist() {
+ this.ctime = System.currentTimeMillis();
+ }
+
+ @Override
+ public DriftChangeSet getChangeSet() {
+ return changeSet;
+ }
+
+ @Override
+ public void setChangeSet(RhqDriftChangeSet changeSet) {
+ this.changeSet = changeSet;
+ }
+
+ @Override
+ public DriftCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public DriftFile getOldDriftFile() {
+ return oldDriftFile;
+ }
+
+ @Override
+ public void setOldDriftFile(DriftFile oldDriftFile) {
+ this.oldDriftFile = oldDriftFile;
+ }
+
+ @Override
+ public DriftFile getNewDriftFile() {
+ return newDriftFile;
+ }
+
+ @Override
+ public void setNewDriftFile(DriftFile newDriftFile) {
+ this.newDriftFile = newDriftFile;
+ }
+
+ @Override
+ public String toString() {
+ return "RhqDrift [ id=" + id + ", category=" + category + ", path=" + path + ", changeSet=" + changeSet + "]";
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDriftChangeSet.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDriftChangeSet.java
new file mode 100644
index 0000000..28ebfbb
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDriftChangeSet.java
@@ -0,0 +1,162 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.drift;
+
+import java.io.Serializable;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * @author Jay Shaughnessy
+ * @author John Sanda
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = RhqDriftChangeSet.QUERY_DELETE_BY_RESOURCES, query = "" //
+ + "DELETE FROM RhqDriftChangeSet dcs " //
+ + " WHERE dcs.resource.id IN ( :resourceIds )") })
+@Table(name = "RHQ_DRIFT_CHANGE_SET")
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DRIFT_CHANGE_SET_ID_SEQ")
+public class RhqDriftChangeSet implements Serializable, DriftChangeSet<RhqDrift> {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_DELETE_BY_RESOURCES = "RhqDriftChangeSet.deleteByResources";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "CTIME", nullable = false)
+ private Long ctime = -1L;
+
+ // 0..N
+ @Column(name = "VERSION", nullable = false)
+ private int version;
+
+ @Column(name = "CATEGORY", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private DriftChangeSetCategory category;
+
+ @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(optional = false)
+ private Resource resource;
+
+ @OneToMany(mappedBy = "changeSet", cascade = { CascadeType.ALL })
+ private Set<RhqDrift> drifts = new LinkedHashSet<RhqDrift>();
+
+ protected RhqDriftChangeSet() {
+ }
+
+ public RhqDriftChangeSet(Resource resource, int version, DriftChangeSetCategory category) {
+ this.resource = resource;
+ this.version = version;
+ this.category = category;
+ }
+
+ @Override
+ public String getId() {
+ return Integer.toString(id);
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = Integer.parseInt(id);
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @PrePersist
+ void onPersist() {
+ this.ctime = System.currentTimeMillis();
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public Resource getResource() {
+ return resource;
+ }
+
+ @Override
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
+
+ @Override
+ public Set<RhqDrift> getDrifts() {
+ return drifts;
+ }
+
+ @Override
+ public void setDrifts(Set<RhqDrift> drifts) {
+ this.drifts = drifts;
+ }
+
+ @Override
+ public String toString() {
+ return "RhqDriftChangeSet [id=" + id + ", resource=" + resource + ", version=" + version + "]";
+ }
+
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftChangeSetTest.java
deleted file mode 100644
index b06d8a4..0000000
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftChangeSetTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.rhq.core.domain.drift;
-
-import javax.transaction.SystemException;
-
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.AlertCondition;
-import org.rhq.core.domain.alert.AlertConditionLog;
-import org.rhq.core.domain.alert.AlertDampeningEvent;
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationLog;
-import org.rhq.core.domain.bundle.BundleResourceDeployment;
-import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
-import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
-import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
-import org.rhq.core.domain.content.ContentServiceRequest;
-import org.rhq.core.domain.content.InstalledPackage;
-import org.rhq.core.domain.content.InstalledPackageHistory;
-import org.rhq.core.domain.content.PackageInstallationStep;
-import org.rhq.core.domain.content.ResourceRepo;
-import org.rhq.core.domain.event.Event;
-import org.rhq.core.domain.event.EventSource;
-import org.rhq.core.domain.measurement.Availability;
-import org.rhq.core.domain.measurement.MeasurementBaseline;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.measurement.MeasurementOOB;
-import org.rhq.core.domain.measurement.MeasurementSchedule;
-import org.rhq.core.domain.measurement.calltime.CallTimeDataKey;
-import org.rhq.core.domain.measurement.calltime.CallTimeDataValue;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.operation.ResourceOperationScheduleEntity;
-import org.rhq.core.domain.resource.CreateResourceHistory;
-import org.rhq.core.domain.resource.DeleteResourceHistory;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceError;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.shared.ResourceBuilder;
-import org.rhq.core.domain.test.AbstractEJB3Test;
-
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-
-public class DriftChangeSetTest extends AbstractEJB3Test {
-
- static interface TransactionCallback {
- void execute() throws Exception;
- }
-
- Resource resource;
-
- @BeforeGroups(groups = {"drift.changeset"})
- public void initResource() throws Exception {
- resource = new ResourceBuilder().createRandomServer().build();
- resource.setId(0);
-
- final ResourceType type = resource.getResourceType();
- type.setId(0);
-
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- getEntityManager().createQuery("delete from DriftChangeSet").executeUpdate();
- getEntityManager().createQuery("delete from Resource").executeUpdate();
- getEntityManager().createQuery("delete from ResourceType").executeUpdate();
- }
- });
-
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- getEntityManager().persist(type);
- getEntityManager().persist(resource);
- }
- });
- }
-
- @BeforeMethod(groups = {"drift.changeset"})
- public void setup() throws Exception {
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- getEntityManager().createQuery("delete from DriftChangeSet").executeUpdate();
- }
- });
- }
-
- @Test(groups = {"integration.ejb3", "drift.changeset"}, enabled = false)
- public void insertAndLoad() throws Exception {
- final DriftChangeSet changeSet = new DriftChangeSet();
-
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- changeSet.setCategory(COVERAGE);
- changeSet.setVersion(0);
- changeSet.setResource(resource);
-
- getEntityManager().persist(changeSet);
- }
- });
-
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- // Verify that we can both load by id and by JPQL to ensure that using a
- // custom type for the id works.
-
- DriftChangeSet actual = getEntityManager().find(DriftChangeSet.class, changeSet.getId());
- assertNotNull("Failed to load change set by id", actual);
-
- actual = (DriftChangeSet) getEntityManager().createQuery("from DriftChangeSet where id = :id")
- .setParameter("id", actual.getId())
- .getSingleResult();
- assertNotNull("Failed to load change set with JPQL query", actual);
- }
- });
- }
-
- void executeInTransaction(TransactionCallback callback) {
- try {
- getTransactionManager().begin();
- callback.execute();
- getTransactionManager().commit();
- } catch (Throwable t) {
- try {
- getTransactionManager().rollback();
- } catch (SystemException e) {
- throw new RuntimeException("Failed to rollback transaction", e);
- }
- throw new RuntimeException(t.getCause());
- }
- }
-
-}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
new file mode 100644
index 0000000..26520a1
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -0,0 +1,107 @@
+package org.rhq.core.domain.drift;
+
+import javax.transaction.SystemException;
+
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.shared.ResourceBuilder;
+import org.rhq.core.domain.test.AbstractEJB3Test;
+
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+
+public class RhqDriftChangeSetTest extends AbstractEJB3Test {
+
+ static interface TransactionCallback {
+ void execute() throws Exception;
+ }
+
+ Resource resource;
+
+ @BeforeGroups(groups = {"drift.changeset"})
+ public void initResource() throws Exception {
+ resource = new ResourceBuilder().createRandomServer().build();
+ resource.setId(0);
+
+ final ResourceType type = resource.getResourceType();
+ type.setId(0);
+
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
+ getEntityManager().createQuery("delete from Resource").executeUpdate();
+ getEntityManager().createQuery("delete from ResourceType").executeUpdate();
+ }
+ });
+
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ getEntityManager().persist(type);
+ getEntityManager().persist(resource);
+ }
+ });
+ }
+
+ @BeforeMethod(groups = {"drift.changeset"})
+ public void setup() throws Exception {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
+ }
+ });
+ }
+
+ @Test(groups = {"integration.ejb3", "drift.changeset"}, enabled = false)
+ public void insertAndLoad() throws Exception {
+ final RhqDriftChangeSet changeSet = new RhqDriftChangeSet();
+
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ changeSet.setCategory(COVERAGE);
+ changeSet.setVersion(0);
+ changeSet.setResource(resource);
+
+ getEntityManager().persist(changeSet);
+ }
+ });
+
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ // Verify that we can both load by id and by JPQL to ensure that using a
+ // custom type for the id works.
+
+ RhqDriftChangeSet actual = getEntityManager().find(RhqDriftChangeSet.class, changeSet.getId());
+ assertNotNull("Failed to load change set by id", actual);
+
+ actual = (RhqDriftChangeSet) getEntityManager().createQuery("from RhqDriftChangeSet where id = :id")
+ .setParameter("id", actual.getId())
+ .getSingleResult();
+ assertNotNull("Failed to load change set with JPQL query", actual);
+ }
+ });
+ }
+
+ void executeInTransaction(TransactionCallback callback) {
+ try {
+ getTransactionManager().begin();
+ callback.execute();
+ getTransactionManager().commit();
+ } catch (Throwable t) {
+ try {
+ getTransactionManager().rollback();
+ } catch (SystemException e) {
+ throw new RuntimeException("Failed to rollback transaction", e);
+ }
+ throw new RuntimeException(t.getCause());
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
index 8e858de..59f9eb3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
@@ -24,6 +24,7 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
@@ -355,8 +356,8 @@ public abstract class AbstractRecentDriftsPortlet extends DriftHistoryView imple
}
@Override
- protected DriftCriteria getFetchCriteria(DSRequest request) {
- DriftCriteria criteria = new DriftCriteria();
+ protected RhqDriftCriteria getFetchCriteria(DSRequest request) {
+ RhqDriftCriteria criteria = new RhqDriftCriteria();
// result count
String currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index eaefcfb..5c80eca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -38,9 +38,10 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
@@ -60,7 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Jay Shaughnessy
* @author John Mazzitelli
*/
-public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
+public class DriftDataSource extends RPCDataSource<Drift, RhqDriftCriteria> {
public static final String CATEGORY_ICON_ADD = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_ADDED);
public static final String CATEGORY_ICON_CHANGE = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_CHANGED);
@@ -161,7 +162,7 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final DriftCriteria criteria) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final RhqDriftCriteria criteria) {
if (criteria == null) {
// the user selected no categories in the filter - it makes sense from the UI perspective to show 0 rows
response.setTotalRows(0);
@@ -200,7 +201,7 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
default:
Set<Integer> typesSet = new HashSet<Integer>();
Set<String> ancestries = new HashSet<String>();
- for (Drift drift : result) {
+ for (Drift drift : result) {
Resource resource = drift.getChangeSet().getResource();
typesSet.add(resource.getResourceType().getId());
ancestries.add(resource.getAncestry());
@@ -247,14 +248,14 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
}
@Override
- protected DriftCriteria getFetchCriteria(DSRequest request) {
+ protected RhqDriftCriteria getFetchCriteria(DSRequest request) {
DriftCategory[] categoriesFilter = getArrayFilter(request, FILTER_CATEGORIES, DriftCategory.class);
if (categoriesFilter == null || categoriesFilter.length == 0) {
return null; // user didn't select any priorities - return null to indicate no data should be displayed
}
- DriftCriteria criteria = new DriftCriteria();
+ RhqDriftCriteria criteria = new RhqDriftCriteria();
criteria.fetchChangeSet(true);
criteria.addFilterCategories(categoriesFilter);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index ffa7185..f5ffc9c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -28,6 +28,7 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
@@ -57,7 +58,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
}
private void show(String driftId) {
- DriftCriteria criteria = new DriftCriteria();
+ DriftCriteria criteria = new RhqDriftCriteria();
criteria.addFilterId(driftId);
criteria.fetchChangeSet(true);
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index 74531cc..a608f8f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -53,7 +53,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
- * A view that displays a paginated table of {@link org.rhq.core.domain.drift.Drift}s, along with the
+ * A view that displays a paginated table of {@link org.rhq.core.domain.drift.RhqDrift}s, along with the
* ability to filter those drifts, sort those drifts, double-click a row to view full details a drift, and perform
* various actions on the the drifts: delete selected, delete all from source, etc.
* This view full respects the user's authorization, and will not allow acttions on the drifts unless the user is
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index a5c0209..7767a8f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -91,12 +91,10 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
}
@Override
- public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(DriftChangeSetCriteria criteria)
- throws RuntimeException {
+ public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(DriftChangeSetCriteria criteria) {
try {
- PageList<DriftChangeSet> result = driftManager.findDriftChangeSetsByCriteria(getSessionSubject(),
- criteria);
- return SerialUtility.prepare(result, "DriftService.findDriftChangeSetsByCriteria");
+ PageList<DriftChangeSet> results = driftServer.findDriftChangeSetsByCriteria(getSessionSubject(), criteria);
+ return SerialUtility.prepare(results, "DriftService.findDriftChangeSetsByCriteria");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
@@ -105,8 +103,8 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
@Override
public PageList<Drift> findDriftsByCriteria(DriftCriteria criteria) throws RuntimeException {
try {
- PageList<Drift> result = driftManager.findDriftsByCriteria(getSessionSubject(), criteria);
- return SerialUtility.prepare(result, "DriftService.findDriftsByCriteria");
+ PageList<Drift> results = driftServer.findDriftsByCriteria(getSessionSubject(), criteria);
+ return SerialUtility.prepare(results, "DriftService.findDriftsByCriteria");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 817bb13..f10c3fb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -19,8 +19,6 @@
*/
package org.rhq.enterprise.server.drift;
-import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
-
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -60,15 +58,16 @@ import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftFileBits;
import org.rhq.core.domain.drift.DriftFileStatus;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
@@ -80,6 +79,8 @@ import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
@Stateless
public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
private final Log log = LogFactory.getLog(this.getClass());
@@ -142,9 +143,9 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
try {
- DriftChangeSetCriteria c = new DriftChangeSetCriteria();
+ RhqDriftChangeSetCriteria c = new RhqDriftChangeSetCriteria();
c.addFilterResourceId(resourceId);
- List<DriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
+ List<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
final int version = changeSets.size();
ZipUtil.walkZipFile(changeSetZip, new ChangeSetFileVisitor() {
@@ -152,7 +153,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
@Override
public boolean visit(ZipEntry zipEntry, ZipInputStream stream) throws Exception {
List<DriftFile> emptyDriftFiles = new ArrayList<DriftFile>();
- DriftChangeSet driftChangeSet = null;
+ RhqDriftChangeSet driftChangeSet = null;
try {
ChangeSetReader reader = new ChangeSetReaderImpl(new BufferedReader(new InputStreamReader(
@@ -160,7 +161,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
// store the new change set info (not the actual blob)
DriftChangeSetCategory category = reader.getHeaders().getType();
- driftChangeSet = new DriftChangeSet(resource, version, category);
+ driftChangeSet = new RhqDriftChangeSet(resource, version, category);
entityManager.persist(driftChangeSet);
for (DirectoryEntry dir = reader.readDirectoryEntry(); null != dir; dir = reader
@@ -177,7 +178,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
// use a path with only forward slashing to ensure consistent paths across reports
String path = new File(dir.getDirectory(), entry.getFile()).getPath();
path = FileUtil.useForwardSlash(path);
- Drift drift = new Drift(driftChangeSet, path, entry.getType(), oldDriftFile,
+ Drift drift = new RhqDrift(driftChangeSet, path, entry.getType(), oldDriftFile,
newDriftFile);
entityManager.persist(drift);
}
@@ -329,7 +330,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
int result = 0;
for (String driftId : driftIds) {
- Drift doomed = entityManager.find(Drift.class, driftId);
+ Drift doomed = entityManager.find(RhqDrift.class, driftId);
if (null != doomed) {
entityManager.remove(doomed);
++result;
@@ -354,7 +355,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
@Override
public int deleteDriftsByContext(Subject subject, EntityContext entityContext) throws RuntimeException {
int result = 0;
- DriftCriteria criteria = new DriftCriteria();
+ RhqDriftCriteria criteria = new RhqDriftCriteria();
switch (entityContext.getType()) {
case Resource:
@@ -369,7 +370,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
throw new IllegalArgumentException("Entity Context Type not supported [" + entityContext + "]");
}
- List<Drift> drifts = driftManager.findDriftsByCriteria(subject, criteria);
+ List<RhqDrift> drifts = driftManager.findDriftsByCriteria(subject, criteria);
if (!drifts.isEmpty()) {
String[] driftIds = new String[drifts.size()];
int i = 0;
@@ -456,21 +457,21 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
- public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
+ public PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, RhqDriftChangeSetCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- CriteriaQueryRunner<DriftChangeSet> queryRunner = new CriteriaQueryRunner<DriftChangeSet>(criteria, generator,
+ CriteriaQueryRunner<RhqDriftChangeSet> queryRunner = new CriteriaQueryRunner<RhqDriftChangeSet>(criteria, generator,
entityManager);
- PageList<DriftChangeSet> result = queryRunner.execute();
+ PageList<RhqDriftChangeSet> result = queryRunner.execute();
return result;
}
@Override
- public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
+ public PageList<RhqDrift> findDriftsByCriteria(Subject subject, RhqDriftCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- CriteriaQueryRunner<Drift> queryRunner = new CriteriaQueryRunner<Drift>(criteria, generator, entityManager);
- PageList<Drift> result = queryRunner.execute();
+ CriteriaQueryRunner<RhqDrift> queryRunner = new CriteriaQueryRunner<RhqDrift>(criteria, generator, entityManager);
+ PageList<RhqDrift> result = queryRunner.execute();
return result;
}
@@ -501,7 +502,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
if (null == result) {
- throw new IllegalArgumentException("Drift Configuration Id [" + driftConfigId
+ throw new IllegalArgumentException("RhqDrift Configuration Id [" + driftConfigId
+ "] not found for entityContext [" + entityContext + "]");
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index b1bfa34..c052b46 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -26,12 +26,12 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.util.PageList;
@Local
@@ -91,7 +91,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
*
* @return the number of Drift records deleted
*/
- int deleteDriftsByContext(Subject subject, EntityContext entityContext) throws RuntimeException;
+ int deleteDriftsByContext(Subject subject, EntityContext entityContext);
/**
* Remove the provided driftConfig (identified by name) on the specified entityContext.
@@ -116,7 +116,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param criteria
* @return The DriftChangeSets matching the criteria
*/
- PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria);
+ PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, RhqDriftChangeSetCriteria criteria);
/**
* Standard criteria based fetch method
@@ -124,7 +124,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param criteria
* @return The Drifts matching the criteria
*/
- PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria);
+ PageList<RhqDrift> findDriftsByCriteria(Subject subject, RhqDriftCriteria criteria);
/**
* Get the specified drift configuration for the specified context.
@@ -134,8 +134,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @return The drift configuration
* @throws RuntimeException, IllegalArgumentException if entity or driftConfig not found.
*/
- DriftConfiguration getDriftConfiguration(Subject subject, EntityContext entityContext, int driftConfigId)
- throws RuntimeException;
+ DriftConfiguration getDriftConfiguration(Subject subject, EntityContext entityContext, int driftConfigId);
/**
* This method stores the provided change-set file for the resource. The version will be incremented based
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 3814288..8cef2a7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -18,8 +18,13 @@ import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
@@ -47,6 +52,18 @@ public class DriftServerBean implements DriftServerLocal {
private AgentManagerLocal agentMgr;
@Override
+ public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
+ DriftServerPluginFacet driftServerPlugin = getServerPlugin();
+ return driftServerPlugin.findDriftChangeSetsByCriteria(subject, criteria);
+ }
+
+ @Override
+ public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
+ DriftServerPluginFacet driftServerPlugin = getServerPlugin();
+ return driftServerPlugin.findDriftsByCriteria(subject, criteria);
+ }
+
+ @Override
@TransactionAttribute(NOT_SUPPORTED)
public void saveChangeSet(int resourceId, File changeSetZip) throws Exception {
DriftServerPluginFacet driftServerPlugin = getServerPlugin();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
index 014a5a8..e24ef5e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
@@ -6,7 +6,12 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.util.PageList;
@Local
public interface DriftServerLocal {
@@ -21,4 +26,8 @@ public interface DriftServerLocal {
void detectDrift(Subject subject, EntityContext context, DriftConfiguration driftConfig);
+ PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria);
+
+ PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria);
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
index c5423c6..02375b7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
@@ -21,7 +21,12 @@ package org.rhq.enterprise.server.plugin.pc.drift;
import java.io.File;
-import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
/**
@@ -32,6 +37,10 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
*/
public interface DriftServerPluginFacet extends ServerPluginComponent {
+ PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria);
+
+ PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria);
+
void saveChangeSet(int resourceId, File changeSetZip) throws Exception;
void saveChangeSetFiles(File changeSetFilesZip) throws Exception;
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 9792fad..53ec93e 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
@@ -69,8 +69,8 @@ import org.rhq.core.domain.content.PackageInstallationStep;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSource;
import org.rhq.core.domain.measurement.Availability;
@@ -503,8 +503,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
AlertDampeningEvent.QUERY_DELETE_BY_RESOURCES, // alert-
AlertNotification.QUERY_DELETE_BY_RESOURCES, // related
AlertDefinition.QUERY_DELETE_BY_RESOURCES, // deletes
- Drift.QUERY_DELETE_BY_RESOURCES, // drift before changeset
- DriftChangeSet.QUERY_DELETE_BY_RESOURCES };
+ RhqDrift.QUERY_DELETE_BY_RESOURCES, // drift before changeset
+ RhqDriftChangeSet.QUERY_DELETE_BY_RESOURCES };
List<Integer> resourceIds = new ArrayList<Integer>();
resourceIds.add(resourceId);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
index eef7aba..ce3c4b0 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
@@ -40,15 +40,15 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
-import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftFileStatus;
import org.rhq.core.domain.drift.DriftConfigurationDefinition.BaseDirValueContext;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
@@ -118,12 +118,12 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
assertTrue(changeset1.exists());
driftManager.storeChangeSet(newResource.getId(), changeset1);
- DriftChangeSetCriteria c = new DriftChangeSetCriteria();
+ RhqDriftChangeSetCriteria c = new RhqDriftChangeSetCriteria();
c.addFilterResourceId(newResource.getId());
c.fetchDrifts(true);
- List<DriftChangeSet> changeSets = driftManager.findDriftChangeSetsByCriteria(overlord, c);
+ List<RhqDriftChangeSet> changeSets = driftManager.findDriftChangeSetsByCriteria(overlord, c);
assertEquals(1, changeSets.size());
- DriftChangeSet changeSet = changeSets.get(0);
+ RhqDriftChangeSet changeSet = changeSets.get(0);
assertEquals(0, changeSet.getVersion());
assertEquals(0, changeSet.getDrifts().size());
@@ -144,7 +144,7 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
changeSet = changeSets.get(1);
assertEquals(1, changeSet.getVersion());
assertEquals(1, changeSet.getDrifts().size());
- Drift drift = changeSet.getDrifts().iterator().next();
+ RhqDrift drift = changeSet.getDrifts().iterator().next();
assertEquals("dir/filename.ext", drift.getPath());
assertEquals("aaaaa", drift.getOldDriftFile().getHashId());
assertEquals("bbbbb", drift.getNewDriftFile().getHashId());
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index f6e657a..67658f5 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -24,15 +24,18 @@ import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.drift.DriftManagerLocal;
-import org.rhq.enterprise.server.plugin.pc.ControlFacet;
-import org.rhq.enterprise.server.plugin.pc.ControlResults;
-import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
-import org.rhq.enterprise.server.util.LookupUtil;
import static org.rhq.enterprise.server.util.LookupUtil.getDriftManager;
@@ -67,6 +70,37 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
}
@Override
+ public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
+ RhqDriftChangeSetCriteria rhqCriteria = new RhqDriftChangeSetCriteria();
+ rhqCriteria.addFilterId(criteria.getFilterId());
+ rhqCriteria.addFilterResourceId(criteria.getFilterResourceId());
+ rhqCriteria.addFilterVersion(criteria.getFilterVersion());
+ rhqCriteria.addFilterCategory(criteria.getFilterCategory());
+ rhqCriteria.fetchDrifts(criteria.isFetchDrifts());
+
+ PageList<? extends DriftChangeSet> results = getDriftManager().findDriftChangeSetsByCriteria(subject,
+ rhqCriteria);
+ return (PageList<DriftChangeSet>) results;
+ }
+
+ @Override
+ public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
+ RhqDriftCriteria rhqCriteria = new RhqDriftCriteria();
+ rhqCriteria.addFilterId(criteria.getFilterId());
+ rhqCriteria.addFilterCategories(criteria.getFilterCategories().toArray(new DriftCategory[] {}));
+ rhqCriteria.addFilterChangeSetId(criteria.getFilterChangeSetId());
+ rhqCriteria.addFilterEndTime(criteria.getFilterEndTime());
+ rhqCriteria.addFilterPath(criteria.getFilterPath());
+ rhqCriteria.addFilterResourceIds(criteria.getFilterResourceIds().toArray(new Integer[] {}));
+ rhqCriteria.addFilterStartTime(criteria.getFilterStartTime());
+ rhqCriteria.fetchChangeSet(criteria.isFetchChangeSet());
+ rhqCriteria.addSortCtime(criteria.getSortCtime());
+
+ PageList<? extends Drift> results = getDriftManager().findDriftsByCriteria(subject, rhqCriteria);
+ return (PageList<Drift>) results;
+ }
+
+ @Override
public void saveChangeSet(int resourceId, File changeSetZip) throws Exception {
DriftManagerLocal driftMgr = getDriftManager();
driftMgr.storeChangeSet(resourceId, changeSetZip);
commit fc8d638828caaf235ddeff2bbe3dfd19dcbbf0a5
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 18 13:25:26 2011 -0400
Initial commit for drift mongodb server plugin
diff --git a/modules/enterprise/server/plugins/drift-mongodb/pom.xml b/modules/enterprise/server/plugins/drift-mongodb/pom.xml
new file mode 100644
index 0000000..8721db7
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/pom.xml
@@ -0,0 +1,249 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server-plugins-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>drift-mongodb-serverplugin</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Drift Server MongoDB Plugin</name>
+ <description>Server side plugin providing MongoDB Backend for drift management</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/server/...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/server/...</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/enterprise/server/plugins/drift-mongodb/</scm.module.path>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongo-java-driver</artifactId>
+ <version>2.6.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.morphia</groupId>
+ <artifactId>morphia</artifactId>
+ <version>1.00-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thoughtworks.proxytoys</groupId>
+ <artifactId>proxytoys</artifactId>
+ <version>1.0</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <!--
+ <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
+ -->
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <repositories>
+ <id>morphia-repo</id>
+ <name>Morphia Repo</name>
+ <url>http://morphia.googlecode.com/svn/mavenrepo/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repositories>
+
+ <profiles>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-serverplugins</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**" />
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>cobertura-plugins</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>cobertura-instrument</id>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <tasks>
+ <!-- prepare directory structure for cobertura-->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/cobertura/backup" />
+ <!-- backup all classes so that we can instrument the original classes-->
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <fileset dir="target/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- create a properties file and save there location of cobertura data file-->
+ <touch file="target/classes/cobertura.properties" />
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- instrument all classes in target/classes directory -->
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </cobertura-instrument>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>cobertura-report</id>
+ <phase>post-integration-test</phase>
+ <configuration>
+ <tasks>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- prepare directory structure for cobertura-->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/site/cobertura" />
+ <!-- restore classes from backup folder to classes folder -->
+ <copy toDir="target/classes" verbose="true" overwrite="true">
+ <fileset dir="target/cobertura/backup">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- delete backup folder-->
+ <delete dir="target/cobertura/backup" />
+ <!-- create a code coverage report -->
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <fileset dir="${basedir}/src/main/java">
+ <include name="**/*.java" />
+ </fileset>
+ </cobertura-report>
+ <!-- delete cobertura.properties file -->
+ <delete file="target/classes/cobertura.properties" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
new file mode 100644
index 0000000..d7c7202
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -0,0 +1,40 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb;
+
+import java.io.File;
+
+import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
+
+public class MongoDBDriftServer implements DriftServerPluginFacet {
+
+ @Override
+ public void start() {
+
+ }
+
+ @Override
+ public void stop() {
+
+ }
+
+ @Override
+ public void shutdown() {
+
+ }
+
+ @Override
+ public void saveChangeSet(int resourceId, File changeSetZip) throws Exception {
+
+ }
+
+ @Override
+ public void saveChangeSetFiles(File changeSetFilesZip) throws Exception {
+
+ }
+
+ @Override
+ public void initialize(ServerPluginContext context) throws Exception {
+
+ }
+
+}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
new file mode 100644
index 0000000..e1894d0
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<drift-plugin
+ version="1.0"
+ apiVersion="1.0"
+ description="The Drift Management MongoDB Persistence Store"
+ displayName="Drift:RHQ"
+ name="drift-mongodb"
+ package="org.rhq.enterprise.server.plugins.drift.MorphiaTest"
+ xmlns="urn:xmlns:rhq-serverplugin.drift"
+ xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <serverplugin:help><![CDATA[
+ Provides back-end store and retrieve for drift files.
+ ]]></serverplugin:help>
+
+ <serverplugin:plugin-component class="MongoDBDriftServer"/>
+
+ <drift diff-support="false" />
+
+</drift-plugin>
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java
new file mode 100644
index 0000000..c88432e
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java
@@ -0,0 +1,28 @@
+package org.rhq.enterprise.server.plugins.drift;
+
+import com.google.code.morphia.Datastore;
+import com.google.code.morphia.Morphia;
+import com.mongodb.DB;
+import com.mongodb.Mongo;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.drift.DriftChangeSet;
+
+public class MorphiaTest {
+
+ @Test
+ public void connectToMongoDB() throws Exception {
+ Mongo connection = new Mongo("localhost");
+ DB db = connection.getDB("test");
+
+ Morphia morphia = new Morphia();
+ morphia.map(DriftChangeSet.class);
+
+ Datastore ds = morphia.createDatastore(connection, "test");
+
+// DriftChangeSet changeSet = new DriftChangeSet(null, 1, COVERAGE);
+// ds.save(changeSet);
+ }
+
+}
diff --git a/modules/enterprise/server/plugins/pom.xml b/modules/enterprise/server/plugins/pom.xml
index f3362ef..abf3f43 100644
--- a/modules/enterprise/server/plugins/pom.xml
+++ b/modules/enterprise/server/plugins/pom.xml
@@ -84,6 +84,7 @@
<module>alert-log4j</module>
<module>cobbler</module>
<module>drift-rhq</module>
+ <module>drift-mongodb</module>
<module>filetemplate-bundle</module>
<module>ant-bundle</module>
<module>validate-all-serverplugins</module>
12 years, 4 months
[rhq] Branch 'drift-mongodb' - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java | 9 +++++++++
1 file changed, 9 insertions(+)
New commits:
commit f7da51617e05e16c33791a92907e359c201e18ee
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 16:48:16 2011 -0400
emit a warning if the query returns us too much stuff
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index aee99cf..c51806a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -35,6 +35,8 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -64,6 +66,12 @@ public class DriftDetailsView extends LocatableVLayout {
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
@Override
public void onSuccess(PageList<Drift> result) {
+ if (result.getTotalSize() != 1) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Got [" + result.getTotalSize()
+ + "] results. Should have been 1. The details shown here might not be correct.",
+ Severity.Warning));
+ }
Drift drift = result.get(0);
show(drift);
}
@@ -78,6 +86,7 @@ public class DriftDetailsView extends LocatableVLayout {
private void show(Drift drift) {
for (Canvas child : getMembers()) {
removeMember(child);
+ child.destroy();
}
// the change set to which the drift belongs
12 years, 4 months
[rhq] Branch 'drift-mongodb' - 3 commits - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java | 2
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/GroupAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java | 405 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java | 128 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 365 +--------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java | 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 42 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java | 21
28 files changed, 667 insertions(+), 415 deletions(-)
New commits:
commit b7c8d2f78a437a375f250d38de47dc08aa0e633c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 16:18:20 2011 -0400
make sure the URL id is prefexed with 0id_ so CoreGUI knows this is an ID
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 378350d..646c32f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
+import org.rhq.enterprise.gui.coregui.client.components.table.StringIDTableSection;
/**
* @author Greg Hinkle
@@ -218,14 +219,6 @@ public class LinkManager {
return link;
}
- public static String getSubsystemDriftHistoryLink(int resourceId, String driftId) {
- return "#Resource/" + resourceId + "/Drift/History/" + driftId;
- }
-
- public static String getSubsystemDriftConfigLink(int resourceId, int driftConfigId) {
- return "#Resource/" + resourceId + "/Drift/Config/" + driftConfigId;
- }
-
public static String getAutodiscoveryQueueLink() {
if (GWT) {
return "#Administration/Security/Auto%20Discovery%20Queue";
@@ -459,7 +452,14 @@ public class LinkManager {
return "#Bundles/Bundle/" + bundleId + "/deployments/" + bundleDeploymentId;
}
- public static String getDriftHistoryLink(int resourceId, int driftId) {
+ public static String getDriftHistoryLink(int resourceId, String driftId) {
+ if (!driftId.startsWith(StringIDTableSection.ID_PREFIX)) {
+ driftId = StringIDTableSection.ID_PREFIX + driftId;
+ }
return "#Resource/" + resourceId + "/Drift/History/" + driftId;
}
+
+ public static String getDriftConfigLink(int resourceId, int driftConfigId) {
+ return "#Resource/" + resourceId + "/Drift/Config/" + driftConfigId;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
index c4118af..1c5a333 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
@@ -93,7 +93,7 @@ public abstract class StringIDTableSection<DS extends RPCDataSource> extends Abs
@Override
public void showDetails(String id) {
if (id != null && id.length() > 0) {
- History.newItem(getBasePath() + "/" + id);
+ History.newItem(getBasePath() + "/" + convertIDToCurrentViewPath(id));
} else {
String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
.toString());
@@ -105,18 +105,24 @@ public abstract class StringIDTableSection<DS extends RPCDataSource> extends Abs
@Override
public abstract Canvas getDetailsView(String id);
- private static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
+ // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL is an ID.
+ public static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
@Override
protected String convertCurrentViewPathToID(String path) {
+ if (!path.startsWith(ID_PREFIX)) {
+ return path; // prefixed has already been stripped
+ }
return path.substring(ID_PREFIX.length()); // skip the initial "0id_" - see convertIDToCurrentViewPath for what this is all about
}
@Override
protected String convertIDToCurrentViewPath(String id) {
- // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL
- // is an ID. Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
+ // Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
// look like an ID to CoreGUI. We will strip this off when we convert this back to an ID - see convertCurrentViewPathToID
+ if (id.startsWith(ID_PREFIX)) {
+ return id; // it is already prefixed
+ }
return ID_PREFIX + id;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index 6f4bbf2..aee99cf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -20,6 +20,8 @@
package org.rhq.enterprise.gui.coregui.client.drift;
+import static org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
+
import java.util.LinkedHashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -30,34 +32,29 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.criteria.BasicDriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import static org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
-
/**
* @author Jay Shaughnessy
*/
-public class DriftDetailsView extends LocatableVLayout implements BookmarkableView {
+public class DriftDetailsView extends LocatableVLayout {
private String driftId;
- private static DriftDetailsView INSTANCE = new DriftDetailsView("DriftDetailsView");
-
- public static DriftDetailsView getInstance() {
- return INSTANCE;
+ public DriftDetailsView(String locatorId, String driftId) {
+ super(locatorId);
+ this.driftId = driftId;
+ setMembersMargin(10);
}
- private DriftDetailsView(String id) {
- // access through the static singleton only (see renderView)
- super(id);
-
- setMembersMargin(10);
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ show(this.driftId);
}
private void show(String driftId) {
@@ -80,7 +77,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
private void show(Drift drift) {
for (Canvas child : getMembers()) {
- removeChild(child);
+ removeMember(child);
}
// the change set to which the drift belongs
@@ -157,11 +154,4 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
addMember(driftForm);
}
-
- @Override
- public void renderView(ViewPath viewPath) {
- driftId = viewPath.getCurrent().getPath();
- show(driftId);
- }
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index 060c9d1..cf42485 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -156,7 +156,7 @@ public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
public String format(Object value, ListGridRecord record, int i, int i1) {
Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
String driftId = getId(record);
- String url = LinkManager.getSubsystemDriftHistoryLink(resourceId, driftId);
+ String url = LinkManager.getDriftHistoryLink(resourceId, driftId);
String formattedValue = TimestampCellFormatter.format(value);
return SeleniumUtility.getLocatableHref(url, formattedValue, null);
}
@@ -285,7 +285,7 @@ public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
@Override
public Canvas getDetailsView(String driftId) {
- return DriftDetailsView.getInstance();
+ return new DriftDetailsView(extendLocatorId("Details"), driftId);
}
public EntityContext getContext() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index 3ee0b5f..51f2ec2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -47,7 +47,7 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
protected String getNodeTargetLink(TreeNode node) {
if (node instanceof DriftTreeNode) {
String driftIdStr = node.getAttribute(AbstractDriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
- String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, driftIdStr);
return path;
}
return null;
commit 385db545221d5aa7bcbdca6abc23b3ffbb294d70
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 15:13:29 2011 -0400
factor TableSection to support string IDs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 85f5e92..1c52477 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -53,8 +53,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceT
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
-import org.rhq.enterprise.gui.coregui.client.test.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.TestDataSourceResponseStatisticsView;
+import org.rhq.enterprise.gui.coregui.client.test.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.TestTopView;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -383,6 +383,11 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String>, Event.Na
} else {
if (view.matches(TREE_NAV_VIEW_PATTERN)) {
// e.g. "Resource/10001" or "Resource/AutoGroup/10003"
+ // TODO: need to support string IDs "Drift/History/0id_abcdefghijk"
+ // TODO: see StringIDTableSection.ID_PREFIX
+ // TODO: remember \D is a non-digit, and \d is a digit
+ // TODO: String suffix = currentViewPath.replaceFirst("\\D*[^/]*", ""); // this might be OK if 0id_ starts with a digit
+ // TODO: suffix = suffix.replaceFirst("((\\d.*)|(0id_[^/]*))", "");
if (!currentViewPath.startsWith(view)) {
// The Node that was selected is not the same Node that was previously selected - it
// may not even be the same node type. For example, the user could have moved from a
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
index 115d4a8..bfa9ae6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
@@ -26,9 +26,9 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
import com.smartgwt.client.widgets.grid.events.CellClickEvent;
import com.smartgwt.client.widgets.grid.events.CellClickHandler;
+
import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
@@ -85,7 +85,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
addTableAction(extendLocatorId("New"), MSG.common_button_new(), createNewAction());
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), getDeleteConfirmMessage(),
- createDeleteAction());
+ createDeleteAction());
super.configureTable();
}
@@ -184,7 +184,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
}
@Override
- public Canvas getDetailsView(int roleId) {
+ public Canvas getDetailsView(Integer roleId) {
return new RoleEditView(extendLocatorId("Detail"), roleId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index 427b1c2..4fdd6e5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -26,9 +26,9 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
import com.smartgwt.client.widgets.grid.events.CellClickEvent;
import com.smartgwt.client.widgets.grid.events.CellClickHandler;
+
import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
@@ -211,7 +211,8 @@ public class UsersView extends TableSection<UsersDataSource> {
};
}
- public Canvas getDetailsView(int subjectId) {
+ @Override
+ public Canvas getDetailsView(Integer subjectId) {
return new UserEditView(extendLocatorId("Detail"), subjectId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
index 45dd32c..3fa6202 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
@@ -277,7 +277,7 @@ public class AlertHistoryView extends TableSection<AlertDataSource> {
}
@Override
- public Canvas getDetailsView(int alertId) {
+ public Canvas getDetailsView(Integer alertId) {
return AlertDetailsView.getInstance();
}
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 c49fc4f..7f2cce0 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
@@ -134,7 +134,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
}
@Override
- public SingleAlertDefinitionView getDetailsView(final int id) {
+ public SingleAlertDefinitionView getDetailsView(final Integer id) {
final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
.extendLocatorId("singleAlertDefinitionView"), this);
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 9fa9c31..fc0dbb1 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
@@ -93,7 +93,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
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 ea41bc2..e31e554 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
@@ -93,7 +93,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
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 688dea4..755c8d7 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
@@ -100,7 +100,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
index df8a406..7178269 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
@@ -39,7 +39,6 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.DetailsView;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
@@ -49,10 +48,16 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
+ * Provides the typical table view with the additional ability of traversing to a "details" view
+ * when double-clicking a individual row in the table - a masters/detail view in effect.
+ *
+ * @param <DS> the datasource used to obtain data for the table
+ * @param <ID> the type used for IDs. This identifies the type used to uniquely refer to a row in the table
+ *
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
+public abstract class AbstractTableSection<DS extends RPCDataSource, ID> extends Table<DS> implements BookmarkableView {
private VLayout detailsHolder;
private Canvas detailsView;
@@ -60,38 +65,39 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
private boolean escapeHtmlInDetailsLinkColumn;
private boolean initialDisplay;
- protected TableSection(String locatorId, String tableTitle) {
+ protected AbstractTableSection(String locatorId, String tableTitle) {
super(locatorId, tableTitle);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria) {
super(locatorId, tableTitle, criteria);
}
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ protected AbstractTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
super(locatorId, tableTitle, sortSpecifiers);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers) {
super(locatorId, tableTitle, sortSpecifiers, criteria);
}
- protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ protected AbstractTableSection(String locatorId, String tableTitle, boolean autoFetchData) {
super(locatorId, tableTitle, autoFetchData);
}
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ protected AbstractTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
String[] excludedFieldNames) {
super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers, String[] excludedFieldNames) {
super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames, boolean autoFetchData) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers, String[] excludedFieldNames, boolean autoFetchData) {
super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
}
@@ -177,8 +183,8 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
if (value == null) {
return "";
}
- Integer recordId = getId(record);
- String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ ID recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + convertIDToCurrentViewPath(recordId);
String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
: value.toString();
return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
@@ -190,7 +196,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* Shows the details view for the given record of the table.
*
* The default implementation of this method assumes there is an
- * id attribute on the record and passes it to {@link #showDetails(int)}.
+ * id attribute on the record and passes it to {@link #showDetails(Object)}.
* Subclasses are free to override this behavior. Subclasses usually
* will need to set the {@link #setDetailsView(Canvas) details view}
* explicitly.
@@ -202,7 +208,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
throw new IllegalArgumentException("'record' parameter is null.");
}
- Integer id = getId(record);
+ ID id = getId(record);
showDetails(id);
}
@@ -210,7 +216,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* Returns the details canvas with information on the item given its list grid record.
*
* The default implementation of this method is to assume there is an
- * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
+ * id attribute on the record and pass that ID to {@link #getDetailsView(Object)}.
* Subclasses are free to override this - which you usually want to do
* if you know the full details of the item are stored in the record attributes
* and thus help avoid making a round trip to the DB.
@@ -218,66 +224,76 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
*/
public Canvas getDetailsView(ListGridRecord record) {
- Integer id = getId(record);
+ ID id = getId(record);
return getDetailsView(id);
}
- protected Integer getId(ListGridRecord record) {
- Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
- if (id == null) {
- String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalStateException(msg);
- }
- return id;
- }
+ /**
+ * Subclasses define how they want to format their identifiers. These uniquely identify
+ * rows in the table. Typical values/types for IDs are Integers or Strings.
+ *
+ * @param record the individual record that contains the ID to be extracted and returned
+ *
+ * @return the ID of the given row/record from the table.
+ */
+ protected abstract ID getId(ListGridRecord record);
/**
* Shows empty details for a new item being created.
* This method is usually called when a user clicks a 'New' button.
*
+ * Subclasses are free to override this if they need a custom way to show the details view.
+ *
* @see #showDetails(ListGridRecord)
*/
public void newDetails() {
- History.newItem(basePath + "/0");
+ History.newItem(basePath + "/0"); // assumes the subclasses will understand "0" means "new details page"
}
/**
- * Shows the details for an item has the given ID.
+ * Shows the details for an item that has the given ID.
* This method is usually called when a user goes to the details
* page via a bookmark, double-cick on a list view row, or direct link.
*
- * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
+ * @param id the id of the row whose details are to be shown; Must be a valid ID.
*
* @see #showDetails(ListGridRecord)
*
- * @throws IllegalArgumentException if id <= 0.
+ * @throws IllegalArgumentException if id is invalid
*/
- public void showDetails(int id) {
- if (id > 0) {
- History.newItem(basePath + "/" + id);
- } else {
- String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalArgumentException(msg);
- }
- }
+ public abstract void showDetails(ID id);
/**
* Returns the details canvas with information on the item that has the given ID.
* Note that an empty details view should be returned if the id passed in is 0 (as would
* be the case if a new item is to be created using the details view).
*
- * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
+ * @param id the id of the details to be shown; will be "0" if an empty details view should be shown.
+ */
+ public abstract Canvas getDetailsView(ID id);
+
+ /**
+ * Given the path from the URL that identifies the ID, this returns the ID represented by that path string.
+ * @param path the path as it was found in the current view path (i.e. in the URL)
+ * @return the ID that identifies the item referred to by the URL
+ */
+ protected abstract ID convertCurrentViewPathToID(String path);
+
+ /**
+ * Given the ID of a particular item, this returns a path string suitable for placement in a URL such that that URL will
+ * identify the particular item.
+ *
+ * @return how the ID can be represented within a view path (i.e. in a URL)
+ * @param id the ID that identifies the item to be referred by in a URL
*/
- public abstract Canvas getDetailsView(int id);
+ protected abstract String convertIDToCurrentViewPath(ID id);
@Override
public void renderView(ViewPath viewPath) {
this.basePath = viewPath.getPathToCurrent();
if (!viewPath.isEnd()) {
- int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ ID id = convertCurrentViewPathToID(viewPath.getCurrent().getPath());
this.detailsView = getDetailsView(id);
if (this.detailsView instanceof BookmarkableView) {
((BookmarkableView) this.detailsView).renderView(viewPath);
@@ -325,7 +341,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* detailsView in edit-mode, the content canvas will already be hidden, which means the
* animateHide would be a no-op (the event won't fire). this causes the detailsHolder
* to keep a reference to the previous detailsView (the one in create-mode) instead of the
- * newly returned reference from getDetailsView(int) that was called when the renderView
+ * newly returned reference from getDetailsView(ID) that was called when the renderView
* methods were called hierarchically down to render the new detailsView in edit-mode.
* therefore, we need to explicitly destroy what's already there (presumably the detailsView
* in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
new file mode 100644
index 0000000..c4118af
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
@@ -0,0 +1,122 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * The TableSection abstract implementation that supports IDs as basic Strings.
+ *
+ * Use this if you have tabular data whose rows are not identified with Integers but
+ * some other non-numeric string.
+ *
+ * If you have tabular data whose rows have integer IDs, use {@link TableSection}.
+ *
+ * @author John Mazzitelli
+ */
+public abstract class StringIDTableSection<DS extends RPCDataSource> extends AbstractTableSection<DS, String> {
+
+ public StringIDTableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, sortSpecifiers, excludedFieldNames);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ @Override
+ protected String getId(ListGridRecord record) {
+ String id = null;
+ if (record != null) {
+ id = record.getAttribute("id");
+ }
+
+ if (id == null || id.length() == 0) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ @Override
+ public void showDetails(String id) {
+ if (id != null && id.length() > 0) {
+ History.newItem(getBasePath() + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
+ .toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ @Override
+ public abstract Canvas getDetailsView(String id);
+
+ private static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
+
+ @Override
+ protected String convertCurrentViewPathToID(String path) {
+ return path.substring(ID_PREFIX.length()); // skip the initial "0id_" - see convertIDToCurrentViewPath for what this is all about
+ }
+
+ @Override
+ protected String convertIDToCurrentViewPath(String id) {
+ // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL
+ // is an ID. Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
+ // look like an ID to CoreGUI. We will strip this off when we convert this back to an ID - see convertCurrentViewPathToID
+ return ID_PREFIX + id;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
new file mode 100644
index 0000000..3eb65c5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * The TableSection abstract implementation that supports IDs as Integers.
+ *
+ * Since most master/detail table views have Integers for IDs that uniquely identify
+ * rows in the table, this is the typical superclass implementation used for
+ * most of RHQ's concrete TableSection views.
+ *
+ * @author John Mazzitelli
+ */
+public abstract class TableSection<DS extends RPCDataSource> extends AbstractTableSection<DS, Integer> {
+
+ public TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ public TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers, String[] excludedFieldNames) {
+ super(locatorId, tableTitle, sortSpecifiers, excludedFieldNames);
+ }
+
+ public TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ public TableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ @Override
+ protected Integer getId(ListGridRecord record) {
+ Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
+ if (id == null) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ @Override
+ public void showDetails(Integer id) {
+ if (id != null && id.intValue() > 0) {
+ History.newItem(getBasePath() + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
+ .toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ @Override
+ public abstract Canvas getDetailsView(Integer id);
+
+ @Override
+ protected Integer convertCurrentViewPathToID(String path) {
+ return Integer.valueOf(path);
+ }
+
+ @Override
+ protected String convertIDToCurrentViewPath(Integer id) {
+ if (id == null) {
+ return "0";
+ }
+ return id.toString();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
index 071e2de..f090bd8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
@@ -226,7 +226,7 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
}
@Override
- public Canvas getDetailsView(int driftConfigId) {
+ public Canvas getDetailsView(Integer driftConfigId) {
return new DriftConfigurationEditView(extendLocatorId("ConfigEdit"), context, driftConfigId, hasWriteAccess);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index f00640a..060c9d1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -42,9 +42,9 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.StringIDTableSection;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection2;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*
* @author Jay Shaughnessy
*/
-public class DriftHistoryView extends TableSection2<DriftDataSource> {
+public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
public static final ViewName SUBSYSTEM_VIEW_ID = new ViewName("RecentDrifts", MSG.common_title_recent_drifts());
@@ -283,7 +283,6 @@ public class DriftHistoryView extends TableSection2<DriftDataSource> {
// });
// }
-
@Override
public Canvas getDetailsView(String driftId) {
return DriftDetailsView.getInstance();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index fa623f1..e146f0e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -211,7 +211,7 @@ public class EventCompositeHistoryView extends TableSection<EventCompositeDataso
}
@Override
- public Canvas getDetailsView(int eventId) {
+ public Canvas getDetailsView(Integer eventId) {
return EventCompositeDetailsView.getInstance();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
index 7e1d548..4a6db81 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
@@ -128,26 +128,26 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
nextCalculationTimeField);
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
- new AbstractTableAction(TableActionEnablement.ANY) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- final int[] groupDefinitionIds = TableUtility.getIds(selection);
- ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(60000);
- groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_dynagroup_deleteSuccessfulSelection(String
- .valueOf(groupDefinitionIds.length)), Severity.Info));
- GroupDefinitionListView.this.refresh();
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_deleteFailureSelection(), caught);
- }
- });
- }
- });
+ new AbstractTableAction(TableActionEnablement.ANY) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ final int[] groupDefinitionIds = TableUtility.getIds(selection);
+ ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(60000);
+ groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_dynagroup_deleteSuccessfulSelection(String
+ .valueOf(groupDefinitionIds.length)), Severity.Info));
+ GroupDefinitionListView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_deleteFailureSelection(), caught);
+ }
+ });
+ }
+ });
addTableAction(extendLocatorId("New"), MSG.common_button_new(), null, new AbstractTableAction() {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -180,7 +180,7 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
final SingleGroupDefinitionView singleGroupDefinitionView = new SingleGroupDefinitionView(this
.extendLocatorId("Details"));
return singleGroupDefinitionView;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
index f1c7cfa..10d2cb9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
@@ -74,7 +74,7 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
}
@Override
- public Canvas getDetailsView(int definitionId) {
+ public Canvas getDetailsView(Integer definitionId) {
return new TraitsDetailView(extendLocatorId("Detail"), this.groupId, definitionId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
index b9eb6bb..03dde04 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
@@ -80,7 +80,7 @@ public class GroupMemberResourceOperationHistoryListView extends
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(extendLocatorId("DetailsView"), true);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
index 8ad3170..ecf55ca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
@@ -45,7 +45,7 @@ public class GroupOperationHistoryListView extends AbstractOperationHistoryListV
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new GroupOperationHistoryDetailsView(extendLocatorId("DetailsView"), this.groupComposite);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
index 7f9c2f1..6561291 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
@@ -20,6 +20,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
import com.smartgwt.client.widgets.Canvas;
+
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleListView;
@@ -45,9 +46,8 @@ public class GroupOperationScheduleListView extends AbstractOperationScheduleLis
}
@Override
- public Canvas getDetailsView(int scheduleId) {
- return new GroupOperationScheduleDetailsView(extendLocatorId("DetailsView"),
- this.groupComposite, scheduleId);
+ public Canvas getDetailsView(Integer scheduleId) {
+ return new GroupOperationScheduleDetailsView(extendLocatorId("DetailsView"), this.groupComposite, scheduleId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index c445d32..50fbc30 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -58,7 +58,7 @@ public class ConfigurationHistoryView extends AbstractConfigurationHistoryView<C
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
ConfigurationHistoryDetailView detailView = new ConfigurationHistoryDetailView(this.getLocatorId());
return detailView;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
index fdd6657..4fad987 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
@@ -60,7 +60,7 @@ public class PluginConfigurationHistoryView extends
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
PluginConfigurationHistoryDetailView detailView = new PluginConfigurationHistoryDetailView(this.getLocatorId());
return detailView;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
index 55a6f99..fe7b9ec 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
@@ -38,7 +38,7 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
}
@Override
- public Canvas getDetailsView(int definitionId) {
+ public Canvas getDetailsView(Integer definitionId) {
return new TraitsDetailView(extendLocatorId("Detail"), this.resourceId, definitionId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
index 3d64039..a222b73 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -47,7 +47,7 @@ public class ResourceOperationHistoryListView extends OperationHistoryView {
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(this.extendLocatorId("DetailsView"));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
index 221390c..859747a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
@@ -46,9 +46,9 @@ public class ResourceOperationScheduleListView extends AbstractOperationSchedule
}
@Override
- public Canvas getDetailsView(int scheduleId) {
- return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"),
- this.resourceComposite, scheduleId);
+ public Canvas getDetailsView(Integer scheduleId) {
+ return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"), this.resourceComposite,
+ scheduleId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
index 70a5ff9..5461aa0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
@@ -23,13 +23,9 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
@@ -191,7 +187,8 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
final List<Integer> successIds = new ArrayList<Integer>();
final List<Integer> failureIds = new ArrayList<Integer>();
for (ListGridRecord record : recordsToBeDeleted) {
- final ResourceOperationHistory operationHistoryToRemove = new OperationHistoryDataSource().copyValues(record);
+ final ResourceOperationHistory operationHistoryToRemove = new OperationHistoryDataSource()
+ .copyValues(record);
GWTServiceLookup.getOperationService().deleteOperationHistory(operationHistoryToRemove.getId(), force,
new AsyncCallback<Void>() {
public void onSuccess(Void result) {
@@ -202,7 +199,7 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
public void onFailure(Throwable caught) {
// TODO: i18n
CoreGUI.getErrorHandler().handleError("Failed to delete " + operationHistoryToRemove + ".",
- caught);
+ caught);
failureIds.add(operationHistoryToRemove.getId());
handleCompletion(successIds, failureIds, numberOfRecordsToBeDeleted);
}
@@ -214,10 +211,13 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
if ((successIds.size() + failureIds.size()) == numberOfRecordsToBeDeleted) {
// TODO: i18n
if (successIds.size() == numberOfRecordsToBeDeleted) {
- CoreGUI.getMessageCenter().notify(new Message("Deleted " + numberOfRecordsToBeDeleted + " operation history items."));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Deleted " + numberOfRecordsToBeDeleted + " operation history items."));
} else {
- CoreGUI.getMessageCenter().notify(new Message("Deleted " + successIds.size()
- + " operation history items, but failed to delete the items with the following IDs: " + failureIds));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Deleted " + successIds.size()
+ + " operation history items, but failed to delete the items with the following IDs: "
+ + failureIds));
}
refresh();
}
@@ -228,7 +228,7 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(extendLocatorId("Detail"));
}
@@ -237,5 +237,4 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
return OperationHistoryDataSource.Field.OPERATION_NAME;
}
-
}
commit 66bcc38c099082f3077f7cf5f1b0429cb826f2d8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 15:13:12 2011 -0400
rename TableSection to AbstractTableSection to prepare for refactoring of the TableSection hierarchy
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
new file mode 100644
index 0000000..df8a406
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
@@ -0,0 +1,389 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.AnimationEffect;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.AnimationCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.DetailsView;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
+
+ private VLayout detailsHolder;
+ private Canvas detailsView;
+ private String basePath;
+ private boolean escapeHtmlInDetailsLinkColumn;
+ private boolean initialDisplay;
+
+ protected TableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers, criteria);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ this.initialDisplay = true;
+
+ detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
+ detailsHolder.setAlign(VerticalAlignment.TOP);
+ //detailsHolder.setWidth100();
+ //detailsHolder.setHeight100();
+ detailsHolder.setMargin(4);
+ detailsHolder.hide();
+
+ addMember(detailsHolder);
+
+ // if the detailsView is already defined it means we want the details view to be rendered prior to
+ // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
+ if (null != detailsView) {
+ switchToDetailsView();
+ }
+ }
+
+ /**
+ * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
+ * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
+ * view, given the 'id'. Also, establishes a double click handler for the row which invokes
+ * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
+ * </br>
+ * In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
+ *
+ * @see org.rhq.enterprise.gui.coregui.client.components.table.Table#configureTable()
+ */
+ @Override
+ protected void configureTable() {
+ if (isDetailsEnabled()) {
+ ListGrid grid = getListGrid();
+
+ // Make the value of some specific field a link to the details view for the corresponding record.
+ ListGridField field = (grid != null) ? grid.getField(getDetailsLinkColumnName()) : null;
+ if (field != null) {
+ field.setCellFormatter(getDetailsLinkColumnCellFormatter());
+ }
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ showDetails(selectedRows[0]);
+ }
+ }
+ });
+ }
+ }
+
+ protected boolean isDetailsEnabled() {
+ return true;
+ }
+
+ public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
+ this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
+ }
+
+ /**
+ * Override if you don't want FIELD_NAME to be wrapped ina link.
+ * @return the name of the field to be wrapped, or null if no field should be wrapped.
+ */
+ protected String getDetailsLinkColumnName() {
+ return FIELD_NAME;
+ }
+
+ /**
+ * Override if you don't want the detailsLinkColumn to have the default link wrapper.
+ * @return the desired CellFormatter.
+ */
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ if (value == null) {
+ return "";
+ }
+ Integer recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
+ : value.toString();
+ return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
+ }
+ };
+ }
+
+ /**
+ * Shows the details view for the given record of the table.
+ *
+ * The default implementation of this method assumes there is an
+ * id attribute on the record and passes it to {@link #showDetails(int)}.
+ * Subclasses are free to override this behavior. Subclasses usually
+ * will need to set the {@link #setDetailsView(Canvas) details view}
+ * explicitly.
+ *
+ * @param record the record whose details are to be shown
+ */
+ public void showDetails(ListGridRecord record) {
+ if (record == null) {
+ throw new IllegalArgumentException("'record' parameter is null.");
+ }
+
+ Integer id = getId(record);
+ showDetails(id);
+ }
+
+ /**
+ * Returns the details canvas with information on the item given its list grid record.
+ *
+ * The default implementation of this method is to assume there is an
+ * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
+ * Subclasses are free to override this - which you usually want to do
+ * if you know the full details of the item are stored in the record attributes
+ * and thus help avoid making a round trip to the DB.
+ *
+ * @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
+ */
+ public Canvas getDetailsView(ListGridRecord record) {
+ Integer id = getId(record);
+ return getDetailsView(id);
+ }
+
+ protected Integer getId(ListGridRecord record) {
+ Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
+ if (id == null) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ /**
+ * Shows empty details for a new item being created.
+ * This method is usually called when a user clicks a 'New' button.
+ *
+ * @see #showDetails(ListGridRecord)
+ */
+ public void newDetails() {
+ History.newItem(basePath + "/0");
+ }
+
+ /**
+ * Shows the details for an item has the given ID.
+ * This method is usually called when a user goes to the details
+ * page via a bookmark, double-cick on a list view row, or direct link.
+ *
+ * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
+ *
+ * @see #showDetails(ListGridRecord)
+ *
+ * @throws IllegalArgumentException if id <= 0.
+ */
+ public void showDetails(int id) {
+ if (id > 0) {
+ History.newItem(basePath + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Returns the details canvas with information on the item that has the given ID.
+ * Note that an empty details view should be returned if the id passed in is 0 (as would
+ * be the case if a new item is to be created using the details view).
+ *
+ * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
+ */
+ public abstract Canvas getDetailsView(int id);
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ this.basePath = viewPath.getPathToCurrent();
+
+ if (!viewPath.isEnd()) {
+ int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ this.detailsView = getDetailsView(id);
+ if (this.detailsView instanceof BookmarkableView) {
+ ((BookmarkableView) this.detailsView).renderView(viewPath);
+ }
+
+ switchToDetailsView();
+ } else {
+ switchToTableView();
+ }
+ }
+
+ protected String getBasePath() {
+ return this.basePath;
+ }
+
+ /**
+ * For use by subclasses that want to define their own details view.
+ *
+ * @param detailsView the new details view
+ */
+ protected void setDetailsView(Canvas detailsView) {
+ this.detailsView = detailsView;
+ }
+
+ /**
+ * Switches to viewing the details canvas, hiding the table. This does not
+ * do anything with reloading data or switching to the selected row in the table;
+ * this only changes the visibility of canvases.
+ */
+ protected void switchToDetailsView() {
+ Canvas contents = getTableContents();
+
+ // If the Table has not yet been initialized then ignore
+ if (contents != null) {
+ if (contents.isVisible()) {
+ contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ buildDetailsView();
+ }
+ });
+ } else {
+ /*
+ * if the programmer chooses to go directly from the detailView in create-mode to the
+ * detailsView in edit-mode, the content canvas will already be hidden, which means the
+ * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
+ * to keep a reference to the previous detailsView (the one in create-mode) instead of the
+ * newly returned reference from getDetailsView(int) that was called when the renderView
+ * methods were called hierarchically down to render the new detailsView in edit-mode.
+ * therefore, we need to explicitly destroy what's already there (presumably the detailsView
+ * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
+ */
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ buildDetailsView();
+ }
+ }
+ }
+
+ private void buildDetailsView() {
+ detailsView.setWidth100();
+ detailsView.setHeight100();
+
+ boolean isEditable = (detailsView instanceof DetailsView && ((DetailsView) detailsView).isEditable());
+ if (!isEditable) {
+ // Only add the "Back to List" button if the details are definitely not editable, because if they are
+ // editable, a Cancel button should already be provided by the details view.
+ BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_tableSection_backButton(),
+ basePath);
+ detailsHolder.addMember(backButton);
+ VLayout verticalSpacer = new LocatableVLayout(extendLocatorId("verticalSpacer"));
+ verticalSpacer.setHeight(8);
+ detailsHolder.addMember(verticalSpacer);
+ }
+
+ detailsHolder.addMember(detailsView);
+ detailsHolder.animateShow(AnimationEffect.WIPE);
+ }
+
+ /**
+ * Switches to viewing the table, hiding the details canvas.
+ */
+ protected void switchToTableView() {
+ final Canvas contents = getTableContents();
+ if (contents != null) {
+ // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
+ // redundant, since the data was just loaded when the table was drawn.
+ if (this.initialDisplay) {
+ this.initialDisplay = false;
+ } else {
+ Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
+ refresh();
+ }
+ if (detailsHolder != null && detailsHolder.isVisible()) {
+ detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ });
+ } else {
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
deleted file mode 100644
index df8a406..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.components.table;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.user.client.History;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.SortSpecifier;
-import com.smartgwt.client.types.AnimationEffect;
-import com.smartgwt.client.types.VerticalAlignment;
-import com.smartgwt.client.widgets.AnimationCallback;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.DetailsView;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-
-/**
- * @author Greg Hinkle
- * @author John Mazzitelli
- */
-public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
-
- private VLayout detailsHolder;
- private Canvas detailsView;
- private String basePath;
- private boolean escapeHtmlInDetailsLinkColumn;
- private boolean initialDisplay;
-
- protected TableSection(String locatorId, String tableTitle) {
- super(locatorId, tableTitle);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
- super(locatorId, tableTitle, criteria);
- }
-
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
- super(locatorId, tableTitle, sortSpecifiers);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
- super(locatorId, tableTitle, sortSpecifiers, criteria);
- }
-
- protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
- super(locatorId, tableTitle, autoFetchData);
- }
-
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
- super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
- super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames, boolean autoFetchData) {
- super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- this.initialDisplay = true;
-
- detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
- detailsHolder.setAlign(VerticalAlignment.TOP);
- //detailsHolder.setWidth100();
- //detailsHolder.setHeight100();
- detailsHolder.setMargin(4);
- detailsHolder.hide();
-
- addMember(detailsHolder);
-
- // if the detailsView is already defined it means we want the details view to be rendered prior to
- // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
- if (null != detailsView) {
- switchToDetailsView();
- }
- }
-
- /**
- * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
- * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
- * view, given the 'id'. Also, establishes a double click handler for the row which invokes
- * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
- * </br>
- * In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
- *
- * @see org.rhq.enterprise.gui.coregui.client.components.table.Table#configureTable()
- */
- @Override
- protected void configureTable() {
- if (isDetailsEnabled()) {
- ListGrid grid = getListGrid();
-
- // Make the value of some specific field a link to the details view for the corresponding record.
- ListGridField field = (grid != null) ? grid.getField(getDetailsLinkColumnName()) : null;
- if (field != null) {
- field.setCellFormatter(getDetailsLinkColumnCellFormatter());
- }
-
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid listGrid = (ListGrid) event.getSource();
- ListGridRecord[] selectedRows = listGrid.getSelection();
- if (selectedRows != null && selectedRows.length == 1) {
- showDetails(selectedRows[0]);
- }
- }
- });
- }
- }
-
- protected boolean isDetailsEnabled() {
- return true;
- }
-
- public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
- this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
- }
-
- /**
- * Override if you don't want FIELD_NAME to be wrapped ina link.
- * @return the name of the field to be wrapped, or null if no field should be wrapped.
- */
- protected String getDetailsLinkColumnName() {
- return FIELD_NAME;
- }
-
- /**
- * Override if you don't want the detailsLinkColumn to have the default link wrapper.
- * @return the desired CellFormatter.
- */
- protected CellFormatter getDetailsLinkColumnCellFormatter() {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int i1) {
- if (value == null) {
- return "";
- }
- Integer recordId = getId(record);
- String detailsUrl = "#" + getBasePath() + "/" + recordId;
- String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
- : value.toString();
- return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
- }
- };
- }
-
- /**
- * Shows the details view for the given record of the table.
- *
- * The default implementation of this method assumes there is an
- * id attribute on the record and passes it to {@link #showDetails(int)}.
- * Subclasses are free to override this behavior. Subclasses usually
- * will need to set the {@link #setDetailsView(Canvas) details view}
- * explicitly.
- *
- * @param record the record whose details are to be shown
- */
- public void showDetails(ListGridRecord record) {
- if (record == null) {
- throw new IllegalArgumentException("'record' parameter is null.");
- }
-
- Integer id = getId(record);
- showDetails(id);
- }
-
- /**
- * Returns the details canvas with information on the item given its list grid record.
- *
- * The default implementation of this method is to assume there is an
- * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
- * Subclasses are free to override this - which you usually want to do
- * if you know the full details of the item are stored in the record attributes
- * and thus help avoid making a round trip to the DB.
- *
- * @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
- */
- public Canvas getDetailsView(ListGridRecord record) {
- Integer id = getId(record);
- return getDetailsView(id);
- }
-
- protected Integer getId(ListGridRecord record) {
- Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
- if (id == null) {
- String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalStateException(msg);
- }
- return id;
- }
-
- /**
- * Shows empty details for a new item being created.
- * This method is usually called when a user clicks a 'New' button.
- *
- * @see #showDetails(ListGridRecord)
- */
- public void newDetails() {
- History.newItem(basePath + "/0");
- }
-
- /**
- * Shows the details for an item has the given ID.
- * This method is usually called when a user goes to the details
- * page via a bookmark, double-cick on a list view row, or direct link.
- *
- * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
- *
- * @see #showDetails(ListGridRecord)
- *
- * @throws IllegalArgumentException if id <= 0.
- */
- public void showDetails(int id) {
- if (id > 0) {
- History.newItem(basePath + "/" + id);
- } else {
- String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalArgumentException(msg);
- }
- }
-
- /**
- * Returns the details canvas with information on the item that has the given ID.
- * Note that an empty details view should be returned if the id passed in is 0 (as would
- * be the case if a new item is to be created using the details view).
- *
- * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
- */
- public abstract Canvas getDetailsView(int id);
-
- @Override
- public void renderView(ViewPath viewPath) {
- this.basePath = viewPath.getPathToCurrent();
-
- if (!viewPath.isEnd()) {
- int id = Integer.parseInt(viewPath.getCurrent().getPath());
- this.detailsView = getDetailsView(id);
- if (this.detailsView instanceof BookmarkableView) {
- ((BookmarkableView) this.detailsView).renderView(viewPath);
- }
-
- switchToDetailsView();
- } else {
- switchToTableView();
- }
- }
-
- protected String getBasePath() {
- return this.basePath;
- }
-
- /**
- * For use by subclasses that want to define their own details view.
- *
- * @param detailsView the new details view
- */
- protected void setDetailsView(Canvas detailsView) {
- this.detailsView = detailsView;
- }
-
- /**
- * Switches to viewing the details canvas, hiding the table. This does not
- * do anything with reloading data or switching to the selected row in the table;
- * this only changes the visibility of canvases.
- */
- protected void switchToDetailsView() {
- Canvas contents = getTableContents();
-
- // If the Table has not yet been initialized then ignore
- if (contents != null) {
- if (contents.isVisible()) {
- contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
- @Override
- public void execute(boolean b) {
- buildDetailsView();
- }
- });
- } else {
- /*
- * if the programmer chooses to go directly from the detailView in create-mode to the
- * detailsView in edit-mode, the content canvas will already be hidden, which means the
- * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
- * to keep a reference to the previous detailsView (the one in create-mode) instead of the
- * newly returned reference from getDetailsView(int) that was called when the renderView
- * methods were called hierarchically down to render the new detailsView in edit-mode.
- * therefore, we need to explicitly destroy what's already there (presumably the detailsView
- * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
- */
- SeleniumUtility.destroyMembers(detailsHolder);
-
- buildDetailsView();
- }
- }
- }
-
- private void buildDetailsView() {
- detailsView.setWidth100();
- detailsView.setHeight100();
-
- boolean isEditable = (detailsView instanceof DetailsView && ((DetailsView) detailsView).isEditable());
- if (!isEditable) {
- // Only add the "Back to List" button if the details are definitely not editable, because if they are
- // editable, a Cancel button should already be provided by the details view.
- BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_tableSection_backButton(),
- basePath);
- detailsHolder.addMember(backButton);
- VLayout verticalSpacer = new LocatableVLayout(extendLocatorId("verticalSpacer"));
- verticalSpacer.setHeight(8);
- detailsHolder.addMember(verticalSpacer);
- }
-
- detailsHolder.addMember(detailsView);
- detailsHolder.animateShow(AnimationEffect.WIPE);
- }
-
- /**
- * Switches to viewing the table, hiding the details canvas.
- */
- protected void switchToTableView() {
- final Canvas contents = getTableContents();
- if (contents != null) {
- // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
- // redundant, since the data was just loaded when the table was drawn.
- if (this.initialDisplay) {
- this.initialDisplay = false;
- } else {
- Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
- refresh();
- }
- if (detailsHolder != null && detailsHolder.isVisible()) {
- detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
- @Override
- public void execute(boolean b) {
- SeleniumUtility.destroyMembers(detailsHolder);
-
- contents.animateShow(AnimationEffect.WIPE);
- }
- });
- } else {
- contents.animateShow(AnimationEffect.WIPE);
- }
- }
- }
-
-}
12 years, 4 months
[rhq] Branch 'drift-mongodb' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 2 +-
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 276d4aa49f568399f5adb35134647e84a119aff9
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 15:23:28 2011 -0400
Need to copy resource id filer into jpa criteria object
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 54eda95..8e4d1f7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -66,11 +66,11 @@ import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
-import org.rhq.core.domain.drift.RhqDriftFile;
import org.rhq.core.domain.drift.DriftFileBits;
import org.rhq.core.domain.drift.DriftFileStatus;
import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.drift.RhqDriftFile;
import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index bed8bd5..1755d3e 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -110,6 +110,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
private DriftChangeSetJPACriteria toJPACriteria(DriftChangeSetCriteria criteria) {
DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
+ jpaCriteria.addFilterResourceId(criteria.getFilterResourceId());
jpaCriteria.addFilterCategory(criteria.getFilterCategory());
jpaCriteria.addFilterCreatedAfter(criteria.getFilterCreatedAfter());
jpaCriteria.addFilterCreatedBefore(criteria.getFilterCreatedBefore());
12 years, 4 months
[rhq] modules/plugins
by ips
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit e431028f07369d98a0ffc72c883a8be1c4ab39f6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Jul 29 15:03:54 2011 -0400
[BZ 710230] improve description of testConnection operation on datasources/connFactories (https://bugzilla.redhat.com/show_bug.cgi?id=710230)
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index 21161fe..bbe70ea 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -37,7 +37,7 @@
</results>
</operation>
- <operation name="testConnection" displayName="Test Connection" description="Test if a connection can be obtained">
+ <operation name="testConnection" displayName="Test Connection" description="Test if a connection can be obtained - returns true if a connection was obtained, or false if not; NOTE: this operation will always return a status of Successful - the results of the operation must be inspected to see whether or not a connection was obtained">
<results>
<c:notes>Test if a connection can be obtained</c:notes>
<c:simple-property type="boolean" name="result" description="Was a connection obtained?"/>
12 years, 4 months
[rhq] Branch 'drift-mongodb' - modules/test-utils
by John Sanda
modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit f557f05fa617968bd151a83765b0fa0dcf98a5e5
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 13:57:20 2011 -0400
fixing import
diff --git a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
index 622108f..da296f9 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
@@ -6,7 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import static junitx.util.Converter.asList;
+import static java.util.Arrays.asList;
public class CollectionMatchesChecker<T> {
12 years, 4 months
[rhq] Branch 'drift-mongodb' - modules/core
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java | 32 +++++-----
1 file changed, 19 insertions(+), 13 deletions(-)
New commits:
commit 7e9ec31437b8b547bb1c048113081031b86a9721
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 13:47:51 2011 -0400
Fix filter overrides for range filters
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
index 6c17877..7a7f78f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -39,9 +39,9 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
private Integer filterId;
private Integer filterInitial; // needs override
private Integer filterResourceId; // needs override
- private String filterVersion;
- private String filterStartVersion;
- private String filterEndVersion;
+ private Integer filterVersion;
+ private Integer filterStartVersion;
+ private Integer filterEndVersion;
private Long filterCreatedAfter;
private Long filterCreatedBefore;
private DriftChangeSetCategory filterCategory;
@@ -52,10 +52,10 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
public DriftChangeSetJPACriteria() {
filterOverrides.put("initial", "version = 0");
filterOverrides.put("resourceId", "resource.id = ?");
- filterOverrides.put("filterStartVersion", "version >= ?");
- filterOverrides.put("filterEndVersion", "version <= ?");
- filterOverrides.put("filterCreatedAfter", "ctime >= ?");
- filterOverrides.put("filterCreatedBefore", "ctime <= ?");
+ filterOverrides.put("startVersion", "version >= ?");
+ filterOverrides.put("endVersion", "version <= ?");
+ filterOverrides.put("createdAfter", "ctime >= ?");
+ filterOverrides.put("createdBefore", "ctime <= ?");
}
@Override
@@ -75,32 +75,38 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
}
public void addFilterVersion(String filterVersion) {
- this.filterVersion = filterVersion;
+ if (filterVersion != null) {
+ this.filterVersion = Integer.parseInt(filterVersion);
+ }
}
@Override
public String getFilterVersion() {
- return filterVersion;
+ return filterVersion == null ? null : filterVersion.toString();
}
@Override
public void addFilterStartVersion(String filterStartVersion) {
- this.filterStartVersion = filterStartVersion;
+ if (filterStartVersion != null) {
+ this.filterStartVersion = Integer.parseInt(filterStartVersion);
+ }
}
@Override
public String getFilterStartVersion() {
- return filterStartVersion;
+ return filterStartVersion == null ? null : filterStartVersion.toString();
}
@Override
public void addFilterEndVersion(String filterEndVersion) {
- this.filterEndVersion = filterEndVersion;
+ if (filterEndVersion != null) {
+ this.filterEndVersion = Integer.parseInt(filterEndVersion);
+ }
}
@Override
public String getFilterEndVersion() {
- return filterEndVersion;
+ return filterEndVersion == null ? null : filterEndVersion.toString();
}
@Override
12 years, 4 months