modules/core/dbutils/pom.xml
| 2
modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
| 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
| 5 +
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
| 2
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
| 23 ++++-
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
| 28 ++++++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
| 45 +++++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
| 9 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
| 3
9 files changed, 98 insertions(+), 21 deletions(-)
New commits:
commit 97694dbe0007249b3e6c7e23fc68d77748ff39ef
Author: Justin Harris <jharris(a)redhat.com>
Date: Tue Jan 5 11:05:53 2010 -0500
Adding in ordering to alert notifications, as well as the ability to name each new
notification when it is created.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index c754814..a371f96 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.70.2</db.schema.version>
+ <db.schema.version>2.70.3</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
index a13e2c6..5430cf0 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -131,6 +131,8 @@
<column name="SNMP_OID" size="250"
type="VARCHAR2"/>
<column name="ALERT_CONFIG_ID" required="false"
type="INTEGER" references="RHQ_CONFIG(ID)"/>
<column name="ALERT_SENDER_NAME" required="false"
size="100" type="VARCHAR2" /> <!-- TODO make required = true
-->
+ <column name="ALERT_ORDER" type="INTEGER" />
+ <column name="NAME" type="VARCHAR2" size="100"
/>
</table>
<table name="RHQ_ALERT_NOTIF_TEMPL"
tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 064dab9..2073231 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2301,6 +2301,11 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.70.3">
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION"
column="ALERT_ORDER" columnType="INTEGER"/>
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION"
column="NAME" columnType="VARCHAR2"/>
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index abda6bc..a7a5361 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -352,7 +352,7 @@ public class AlertDefinition implements Serializable {
private Set<AlertCondition> conditions = new
LinkedHashSet<AlertCondition>(1); // Most alerts will only have one condition.
@OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL)
- @OrderBy
+ @OrderBy("order asc")
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private List<AlertNotification> alertNotifications = new
ArrayList<AlertNotification>();
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index 7efa51b..87e5888 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -81,6 +81,12 @@ public class AlertNotification implements Serializable {
@Column(name = "ALERT_SENDER_NAME")
private String senderName;
+ @Column(name = "ALERT_ORDER")
+ private int order;
+
+ @Column(name = "NAME")
+ private String name;
+
protected AlertNotification() {
} // JPA spec
@@ -102,7 +108,6 @@ public class AlertNotification implements Serializable {
}
-
public int getId() {
return id;
}
@@ -147,4 +152,20 @@ public class AlertNotification implements Serializable {
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
+
+ public int getOrder() {
+ return order;
+ }
+
+ public void setOrder(int order) {
+ this.order = order;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
}
diff --git
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
index ebaea47..747fbab 100644
---
a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
+++
b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
@@ -57,6 +57,7 @@ public class AlertNotificationsUIBean {
private Integer notificationId;
private List<AlertNotification> alertNotifications;
private Set<AlertNotification> selectedNotifications;
+ private String newAlertName;
private String selectedNewSender;
private AlertNotification activeNotification;
private ConfigurationDefinition activeConfigDefinition;
@@ -67,6 +68,10 @@ public class AlertNotificationsUIBean {
return alertNotifications;
}
+ public void setAlertNotifications(List<AlertNotification> alertNotifications)
{
+ this.alertNotifications = alertNotifications;
+ }
+
public Set<AlertNotification> getSelectedNotifications() {
return selectedNotifications;
}
@@ -75,6 +80,14 @@ public class AlertNotificationsUIBean {
this.selectedNotifications = selectedNotifications;
}
+ public String getNewAlertName() {
+ return newAlertName;
+ }
+
+ public void setNewAlertName(String newAlertName) {
+ this.newAlertName = newAlertName;
+ }
+
public String getSelectedNewSender() {
return selectedNewSender;
}
@@ -164,7 +177,7 @@ public class AlertNotificationsUIBean {
newSenderConfig = new Configuration();
}
- this.activeNotification =
this.alertNotificationManager.addAlertNotification(subject, alertDefinitionId,
selectedNewSender, newSenderConfig);
+ this.activeNotification =
this.alertNotificationManager.addAlertNotification(subject, alertDefinitionId,
selectedNewSender, newAlertName, newSenderConfig);
return SUCCESS_OUTCOME;
}
@@ -186,6 +199,19 @@ public class AlertNotificationsUIBean {
return SUCCESS_OUTCOME;
}
+ public String saveOrder() {
+ int orderIndex = 0;
+
+ for (AlertNotification notification : this.alertNotifications) {
+ notification.setOrder(orderIndex++);
+
+ // TODO: Wait and persist these all in a single operation?
+ this.alertNotificationManager.updateAlertNotification(notification);
+ }
+
+ return SUCCESS_OUTCOME;
+ }
+
private List<Integer> getSelectedIds(Collection<AlertNotification>
notifications) {
List<Integer> ids = new ArrayList<Integer>(notifications.size());
for (AlertNotification notification : notifications) {
diff --git
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
index e9a6e3c..b3288e3 100644
---
a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
+++
b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
@@ -39,19 +39,18 @@
</h:outputLink>
<h:outputText> > </h:outputText>
<h:outputLink value="listAlertSender.xhtml">
- Alert Sender Definitions
+ Alert Notification Definitions
</h:outputLink>
</ui:define>
<ui:define name="body">
<br/>
- <h:messages showSummary="true"
- showDetail="true"
+ <h:messages showDetail="true"
+ globalOnly="true"
infoClass="InfoBlock"
warnClass="WarnBlock"
errorClass="ErrorBlock"
fatalClass="FatalBlock"
- globalOnly="true"
layout="table"
width="100%"/>
@@ -66,16 +65,16 @@
<input type="hidden" name="ad"
value="${param.ad}"/>
<rich:orderingList
value="#{alertNotificationsUIBean.alertNotifications}"
- var="alertSender"
+ var="alertNotification"
selection="#{alertNotificationsUIBean.selectedNotifications}"
activeItem="#{alertNotificationsUIBean.activeNotification}"
converter="#{alertNotificationsUIBean.notificationConverter}"
listWidth="250">
<rich:column>
<f:facet name="header">
- <h:outputText value="Alert Sender (Select to
Edit)" />
+ <h:outputText value="Alert Notifications
(Select to Edit)" />
</f:facet>
- <h:outputText
value="#{alertSender.senderName}" />
+ <h:outputText value="#{alertNotification.name}
(#{alertNotification.senderName})" />
</rich:column>
<a4j:support event="onclick"
@@ -88,6 +87,10 @@
requestDelay="150"
reRender="alertConfig,senderName"
oncomplete="updateCustomContent();"
/>
+ <a4j:support event="onorderchanged"
+ ignoreDupResponses="true"
+ requestDelay="250"
+ reRender="senderName" />
</rich:orderingList>
</h:form>
@@ -95,8 +98,13 @@
<input type="hidden" name="id"
value="${param.id}"/>
<input type="hidden" name="ad"
value="${param.ad}"/>
+ <h:commandButton id="saveAlertOrderButton"
+ value="Save Order"
+
action="#{alertNotificationsUIBean.saveOrder}"
+ styleClass="buttonmed"/>
+
<h:commandButton id="removeAlertButton"
- value="Remove Selected Alerts"
+ value="Remove Selected"
action="#{alertNotificationsUIBean.removeSelected}"
styleClass="buttonmed"/>
</h:form>
@@ -129,19 +137,36 @@
<rich:panel id="addAlertPanel">
<f:facet name="header">
- <h:outputText value="Add Alert Sender" />
+ <h:outputText value="Add Alert Notification" />
</f:facet>
<h:form id="newNotificationForm">
<input type="hidden" name="id"
value="${param.id}"/>
<input type="hidden" name="ad"
value="${param.ad}"/>
+ <h:outputLabel for="alertNameInput" value="Alert
Notification Name:" />
+ <br />
+ <h:inputText id="alertNameInput"
+ value="#{alertNotificationsUIBean.newAlertName}"
+ maxlength="100"
+ required="true" />
+
+ <h:message for="alertNameInput"
+ infoClass="InfoBlock"
+ warnClass="WarnBlock"
+ errorClass="ErrorBlock"
+ fatalClass="FatalBlock" />
+ <br /><br />
+
+ <h:outputLabel for="senderList" value="Alert Sender
Type:" />
+ <br />
<h:selectOneMenu id="senderList"
value="#{alertNotificationsUIBean.selectedNewSender}">
<f:selectItems
value="#{alertNotificationsUIBean.allAlertSenders}" />
</h:selectOneMenu>
+ <br /><br />
<h:commandButton id="addAlertButton"
- value="Add Alert Sender"
+ value="Add Alert Notification"
action="#{alertNotificationsUIBean.addAlertSender}"
styleClass="buttonmed">
</h:commandButton>
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 9f4eb22..e769fc1 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -499,13 +499,9 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
}
/**
- * Add a new AlertNotification to the passed definition
- * @param user subject of the caller
- * @param alertDefinitionId Id of the alert definition
- * @param senderName shortName of the {@link AlertSender}
- * @param configuration Properties for this alert sender.
+ * {@inheritDoc}
*/
- public AlertNotification addAlertNotification(Subject user, int alertDefinitionId,
String senderName, Configuration configuration) {
+ public AlertNotification addAlertNotification(Subject user, int alertDefinitionId,
String senderName, String alertName, Configuration configuration) {
AlertDefinition definition =
alertDefinitionManager.getAlertDefinition(user,alertDefinitionId);
if (definition==null) {
@@ -516,6 +512,7 @@ public class AlertNotificationManagerBean implements
AlertNotificationManagerLoc
entityManager.persist(configuration);
AlertNotification notif = new AlertNotification(definition);
notif.setSenderName(senderName);
+ notif.setName(alertName);
notif.setConfiguration(configuration);
entityManager.persist(notif);
definition.getAlertNotifications().add(notif);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
index 20afccd..b4d8ae7 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
@@ -94,9 +94,10 @@ public interface AlertNotificationManagerLocal {
* @param user subject of the caller
* @param alertDefinitionId Id of the alert definition
* @param senderName shortName of the {@link AlertSender}
+ * @param alertName name of the new {@link AlertNotification}
* @param configuration Properties for this alert sender.
*/
- AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String
senderName, Configuration configuration);
+ AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String
senderName, String alertName, Configuration configuration);
/**
* Return notifications for a certain alertDefinitionId