dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20252
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9169: Impl new function for sending a message/notification to the user who completes a form as a confir...
------------------------------------------------------------
revno: 9169
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-12-04 16:27:28 +0100
message:
Impl new function for sending a message/notification to the user who completes a form as a confirmation. This is configurable per data set.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2012-09-27 03:57:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2012-12-04 15:27:28 +0000
@@ -136,7 +136,7 @@
private int expiryDays;
/**
- * Property indicating whether aggregation should be skipped.
+ * Indicating whether aggregation should be skipped.
*/
private boolean skipAggregation;
@@ -144,6 +144,11 @@
* User group which will receive notifications when data set is marked complete.
*/
private UserGroup notificationRecipients;
+
+ /**
+ * Indicating whether the user completing this data set should be sent a notification.
+ */
+ private boolean notifyCompletingUser;
// -------------------------------------------------------------------------
// Form properties
@@ -573,6 +578,19 @@
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public boolean isNotifyCompletingUser()
+ {
+ return notifyCompletingUser;
+ }
+
+ public void setNotifyCompletingUser( boolean notifyCompletingUser )
+ {
+ this.notifyCompletingUser = notifyCompletingUser;
+ }
+
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public boolean isAllowFuturePeriods()
{
return allowFuturePeriods;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2012-12-04 08:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2012-12-04 15:27:28 +0000
@@ -168,27 +168,41 @@
{
DataSet dataSet = registration.getDataSet();
- if ( dataSet == null || dataSet.getNotificationRecipients() == null || dataSet.getNotificationRecipients().getMembers().isEmpty() )
+ if ( dataSet == null )
{
return 0;
}
-
+
UserGroup userGroup = dataSet.getNotificationRecipients();
User sender = currentUserService.getCurrentUser();
+ Set<User> recipients = new HashSet<User>();
+
+ if ( userGroup != null )
+ {
+ recipients.addAll( userGroup.getMembers() );
+ }
+
+ if ( dataSet.isNotifyCompletingUser() )
+ {
+ recipients.add( sender );
+ }
+
+ if ( recipients.isEmpty() )
+ {
+ return 0;
+ }
+
String text = new VelocityManager().render( registration, COMPLETE_TEMPLATE );
MessageConversation conversation = new MessageConversation( COMPLETE_SUBJECT, sender );
conversation.addMessage( new Message( text, null, sender ) );
- for ( User user : userGroup.getMembers() )
+ for ( User user : recipients )
{
- if ( user.getUserCredentials().getAllDataSets().contains( dataSet ) )
- {
- conversation.addUserMessage( new UserMessage( user ) );
- }
+ conversation.addUserMessage( new UserMessage( user ) );
}
if ( !conversation.getUserMessages().isEmpty() )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-11-23 12:51:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-12-04 15:27:28 +0000
@@ -398,6 +398,7 @@
executeSql( "update dataset set mobile = false where mobile is null" );
executeSql( "update dataset set allowfutureperiods = false where allowfutureperiods is null" );
executeSql( "update dataset set validcompleteonly = false where validcompleteonly is null" );
+ executeSql( "update dataset set notifycompletinguser = false where notifycompletinguser is null" );
executeSql( "update dataelement set zeroissignificant = false where zeroissignificant is null" );
executeSql( "update organisationunit set haspatients = false where haspatients is null" );
executeSql( "update dataset set expirydays = 0 where expirydays is null" );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2012-09-27 03:57:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2012-12-04 15:27:28 +0000
@@ -69,6 +69,8 @@
<many-to-one name="notificationRecipients" class="org.hisp.dhis.user.UserGroup"
foreign-key="fk_dataset_notificationrecipients" />
+
+ <property name="notifyCompletingUser" />
<!-- Form properties -->
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java 2012-11-14 17:12:21 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java 2012-12-04 15:27:28 +0000
@@ -205,9 +205,7 @@
registration.setPeriodName( format.formatPeriod( registration.getPeriod() ) );
- boolean notify = dataSet != null && dataSet.getNotificationRecipients() != null;
-
- registrationService.saveCompleteDataSetRegistration( registration, notify );
+ registrationService.saveCompleteDataSetRegistration( registration, true );
log.info( "DataSet registered as complete: " + registration );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java 2012-09-27 03:57:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java 2012-12-04 15:27:28 +0000
@@ -135,6 +135,13 @@
{
this.notificationRecipients = notificationRecipients;
}
+
+ private boolean notifyCompletingUser;
+
+ public void setNotifyCompletingUser( boolean notifyCompletingUser )
+ {
+ this.notifyCompletingUser = notifyCompletingUser;
+ }
private boolean skipAggregation;
@@ -234,6 +241,7 @@
dataSet.setAllowFuturePeriods( allowFuturePeriods );
dataSet.setFieldCombinationRequired( fieldCombinationRequired );
dataSet.setValidCompleteOnly( validCompleteOnly );
+ dataSet.setNotifyCompletingUser( notifyCompletingUser );
dataSet.setSkipOffline( skipOffline );
dataSetService.addDataSet( dataSet );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2012-09-27 03:57:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2012-12-04 15:27:28 +0000
@@ -147,6 +147,13 @@
this.notificationRecipients = notificationRecipients;
}
+ private boolean notifyCompletingUser;
+
+ public void setNotifyCompletingUser( boolean notifyCompletingUser )
+ {
+ this.notifyCompletingUser = notifyCompletingUser;
+ }
+
private boolean skipAggregation;
public void setSkipAggregation( boolean skipAggregation )
@@ -262,6 +269,7 @@
dataSet.setAllowFuturePeriods( allowFuturePeriods );
dataSet.setFieldCombinationRequired( fieldCombinationRequired );
dataSet.setValidCompleteOnly( validCompleteOnly );
+ dataSet.setNotifyCompletingUser( notifyCompletingUser );
dataSet.setSkipOffline( skipOffline );
dataSet.setNotificationRecipients( userGroupService.getUserGroup( notificationRecipients ) );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties 2012-11-20 14:43:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties 2012-12-04 15:27:28 +0000
@@ -106,4 +106,5 @@
notification_recipients=Complete notification recipients
skip_offline=Skip Offline
object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type
-auto_save_data_entry_forms=Auto-save data entry forms
\ No newline at end of file
+auto_save_data_entry_forms=Auto-save data entry forms
+notify_completing_user=Send notification to completing user
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2012-10-17 11:58:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm 2012-12-04 15:27:28 +0000
@@ -101,6 +101,15 @@
</td>
</tr>
<tr>
+ <td><label>$i18n.getString( "notify_completing_user" )</label></td>
+ <td>
+ <select id="notifyCompletingUser" name="notifyCompletingUser">
+ <option value="false">$i18n.getString( "no" )</option>
+ <option value="true">$i18n.getString( "yes" )</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
<td><label>$i18n.getString( "skip_aggregation" )</label></td>
<td>
<select id="skipAggregation" name="skipAggregation">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2012-10-17 11:58:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm 2012-12-04 15:27:28 +0000
@@ -90,15 +90,6 @@
</td>
</tr>
<tr>
- <td><label>$i18n.getString( "skip_aggregation" )</label></td>
- <td>
- <select id="skipAggregation" name="skipAggregation">
- <option value="false">$i18n.getString( "no" )</option>
- <option value="true"#if( $dataSet.skipAggregation == true ) selected="selected"#end>$i18n.getString( "yes" )</option>
- </select>
- </td>
- </tr>
- <tr>
<td><label>$i18n.getString( "notification_recipients" )</label></td>
<td>
<select id="notificationRecipients" name="notificationRecipients">
@@ -109,6 +100,24 @@
</select>
</td>
</tr>
+ <tr>
+ <td><label>$i18n.getString( "notify_completing_user" )</label></td>
+ <td>
+ <select id="notifyCompletingUser" name="notifyCompletingUser">
+ <option value="false">$i18n.getString( "no" )</option>
+ <option value="true"#if( $dataSet.notifyCompletingUser == true ) selected="selected"#end>$i18n.getString( "yes" )</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><label>$i18n.getString( "skip_aggregation" )</label></td>
+ <td>
+ <select id="skipAggregation" name="skipAggregation">
+ <option value="false">$i18n.getString( "no" )</option>
+ <option value="true"#if( $dataSet.skipAggregation == true ) selected="selected"#end>$i18n.getString( "yes" )</option>
+ </select>
+ </td>
+ </tr>
</tbody>
<thead>
<tr>