dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14389
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4879: Implemented sending messages / emails to members of a configurable user group when data sets are ...
------------------------------------------------------------
revno: 4879
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-10-07 13:48:18 +0200
message:
Implemented sending messages / emails to members of a configurable user group when data sets are marked as complete
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserSettingService.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/resources/org/hisp/dhis/configuration/hibernate/Configuration.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-dataentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/user/GetEmailSettingsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/user/SetEmailSettingsAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/userEmailSettings.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/configuration/Configuration.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java 2011-06-12 09:54:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java 2011-10-07 11:48:18 +0000
@@ -50,6 +50,8 @@
private int id;
private UserGroup feedbackRecipients;
+
+ private UserGroup completenessRecipients;
private DataElementGroup infrastructuralDataElements;
@@ -92,6 +94,16 @@
this.feedbackRecipients = feedbackRecipients;
}
+ public UserGroup getCompletenessRecipients()
+ {
+ return completenessRecipients;
+ }
+
+ public void setCompletenessRecipients( UserGroup completenessRecipients )
+ {
+ this.completenessRecipients = completenessRecipients;
+ }
+
public DataElementGroup getInfrastructuralDataElements()
{
return infrastructuralDataElements;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageService.java 2011-10-06 15:39:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageService.java 2011-10-07 11:48:18 +0000
@@ -30,6 +30,7 @@
import java.util.List;
import java.util.Set;
+import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.user.User;
/**
@@ -50,6 +51,8 @@
void updateMessageConversation( MessageConversation conversation );
+ int sendCompletenessMessage( CompleteDataSetRegistration registration );
+
MessageConversation getMessageConversation( int id );
long getUnreadMessageConversationCount();
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserSettingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserSettingService.java 2011-10-07 07:42:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserSettingService.java 2011-10-07 11:48:18 +0000
@@ -49,7 +49,6 @@
final String KEY_STYLE = "stylesheet";
final String KEY_STYLE_DIRECTORY = "stylesheetDirectory";
final String KEY_MESSAGE_EMAIL_NOTIFICATION = "keyMessageEmailNotification";
- final String KEY_COMPLETENESS_EMAIL_NOTIFICATION = "keyCompletenessEmailNotification";
final int DEFAULT_CHARTS_IN_DASHBOARD = 4;
final List<Integer> DASHBOARD_CHARTS_TO_DISPLAY = Arrays.asList( 4, 6, 8 );
=== 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 2011-10-06 15:39:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2011-10-07 11:48:18 +0000
@@ -32,6 +32,7 @@
import java.util.Set;
import org.hisp.dhis.configuration.ConfigurationService;
+import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserGroup;
@@ -43,7 +44,7 @@
@Transactional
public class DefaultMessageService
implements MessageService
-{
+{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -132,7 +133,39 @@
invokeMessageSenders( conversation.getSubject(), text, conversation.getUsers() );
}
+
+ public int sendCompletenessMessage( CompleteDataSetRegistration registration )
+ {
+ UserGroup userGroup = configurationService.getConfiguration().getCompletenessRecipients();
+
+ if ( userGroup != null && userGroup.getMembers().size() > 0 )
+ {
+ User sender = currentUserService.getCurrentUser();
+
+ //TODO i18n and string externalization
+ String subject = "Notification: Form registered as complete";
+ String text = "The form " + registration.getDataSet() + " was registered as complete for period " +
+ registration.getPeriod() + " and organisation unit " + registration.getSource();
+
+ MessageConversation conversation = new MessageConversation( subject, sender );
+
+ conversation.addMessage( new Message( text, null, sender ) );
+
+ for ( User user : userGroup.getMembers() )
+ {
+ conversation.addUserMessage( new UserMessage( user ) );
+ }
+
+ int id = saveMessageConversation( conversation );
+
+ invokeMessageSenders( subject, text, userGroup.getMembers() );
+
+ return id;
+ }
+ return 0;
+ }
+
public int saveMessageConversation( MessageConversation conversation )
{
return messageConversationStore.save( conversation );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml 2011-06-09 14:43:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/configuration/hibernate/Configuration.hbm.xml 2011-10-07 11:48:18 +0000
@@ -13,6 +13,9 @@
<many-to-one name="feedbackRecipients" class="org.hisp.dhis.user.UserGroup"
column="feedbackrecipientsid" foreign-key="fk_configuration_feedback_recipients"/>
+ <many-to-one name="completenessRecipients" class="org.hisp.dhis.user.UserGroup"
+ column="completenessrecipientsid" foreign-key="fk_configuration_completeness_recipients"/>
+
<many-to-one name="infrastructuralDataElements" class="org.hisp.dhis.dataelement.DataElementGroup"
column="infrastructuraldataelementsid" foreign-key="fk_configuration_infrastructural_dataelements"/>
=== 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 2011-08-20 12:10:52 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java 2011-10-07 11:48:18 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
@@ -74,6 +75,13 @@
{
this.organisationUnitService = organisationUnitService;
}
+
+ private MessageService messageService;
+
+ public void setMessageService( MessageService messageService )
+ {
+ this.messageService = messageService;
+ }
// -------------------------------------------------------------------------
// Input
@@ -122,9 +130,10 @@
registrationService.saveCompleteDataSetRegistration( registration );
log.info( "DataSet registered as complete: " + registration );
+
+ messageService.sendCompletenessMessage( registration );
}
-
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-09-26 17:37:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-10-07 11:48:18 +0000
@@ -85,6 +85,7 @@
<property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="messageService" ref="org.hisp.dhis.message.MessageService"/>
</bean>
<bean id="org.hisp.dhis.de.action.UndoCompleteDataSetAction" class="org.hisp.dhis.de.action.UndoCompleteDataSetAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java 2011-10-05 07:03:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetGeneralSettingsAction.java 2011-10-07 11:48:18 +0000
@@ -103,6 +103,13 @@
return feedbackRecipients;
}
+ private UserGroup completenessRecipients;
+
+ public UserGroup getCompletenessRecipients()
+ {
+ return completenessRecipients;
+ }
+
private Collection<String> aggregationStrategies;
public Collection<String> getAggregationStrategies()
@@ -150,6 +157,8 @@
feedbackRecipients = configurationService.getConfiguration().getFeedbackRecipients();
+ completenessRecipients = configurationService.getConfiguration().getCompletenessRecipients();
+
dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
Collections.sort( dataElementGroups, new DataElementGroupNameComparator() );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java 2011-10-06 07:05:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java 2011-10-07 11:48:18 +0000
@@ -142,6 +142,13 @@
{
this.feedbackRecipients = feedbackRecipients;
}
+
+ private Integer completenessRecipients;
+
+ public void setCompletenessRecipients( Integer completenessRecipients )
+ {
+ this.completenessRecipients = completenessRecipients;
+ }
private Integer completenessOffset;
@@ -171,10 +178,8 @@
public String execute()
{
systemSettingManager.saveSystemSetting( KEY_AGGREGATION_STRATEGY, aggregationStrategy );
- systemSettingManager.saveSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART,
- omitIndicatorsZeroNumeratorDataMart );
- systemSettingManager
- .saveSystemSetting( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, disableDataEntryWhenCompleted );
+ systemSettingManager.saveSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, omitIndicatorsZeroNumeratorDataMart );
+ systemSettingManager.saveSystemSetting( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, disableDataEntryWhenCompleted );
systemSettingManager.saveSystemSetting( KEY_FACTOR_OF_DEVIATION, factorDeviation );
systemSettingManager.saveSystemSetting( KEY_COMPLETENESS_OFFSET, completenessOffset );
@@ -185,6 +190,11 @@
configuration.setFeedbackRecipients( userGroupService.getUserGroup( feedbackRecipients ) );
}
+ if ( completenessRecipients != null )
+ {
+ configuration.setCompletenessRecipients( userGroupService.getUserGroup( completenessRecipients ) );
+ }
+
if ( infrastructuralDataElements != null )
{
configuration.setInfrastructuralDataElements( dataElementService
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/user/GetEmailSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/user/GetEmailSettingsAction.java 2011-10-07 08:07:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/user/GetEmailSettingsAction.java 2011-10-07 11:48:18 +0000
@@ -27,7 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.user.UserSettingService.KEY_COMPLETENESS_EMAIL_NOTIFICATION;
import static org.hisp.dhis.user.UserSettingService.KEY_MESSAGE_EMAIL_NOTIFICATION;
import org.hisp.dhis.user.UserSettingService;
@@ -57,13 +56,6 @@
// Output
// -------------------------------------------------------------------------
- private Boolean completenessEmailNotification;
-
- public Boolean getCompletenessEmailNotification()
- {
- return completenessEmailNotification;
- }
-
private Boolean messageEmailNotification;
public Boolean getMessageEmailNotification()
@@ -79,13 +71,6 @@
throws Exception
{
// ---------------------------------------------------------------------
- // Get Completeness-email-notification
- // ---------------------------------------------------------------------
-
- completenessEmailNotification = (Boolean) userSettingService.getUserSetting(
- KEY_COMPLETENESS_EMAIL_NOTIFICATION, false );
-
- // ---------------------------------------------------------------------
// Get Message-email-notification
// ---------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/user/SetEmailSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/user/SetEmailSettingsAction.java 2011-10-07 08:07:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/user/SetEmailSettingsAction.java 2011-10-07 11:48:18 +0000
@@ -27,7 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.user.UserSettingService.KEY_COMPLETENESS_EMAIL_NOTIFICATION;
import static org.hisp.dhis.user.UserSettingService.KEY_MESSAGE_EMAIL_NOTIFICATION;
import org.hisp.dhis.i18n.I18n;
@@ -37,7 +36,6 @@
/**
* @author Dang Duy Hieu
- * @version $Id$
*/
public class SetEmailSettingsAction
implements Action
@@ -64,13 +62,6 @@
this.messageEmailNotification = messageEmailNotification;
}
- private Boolean completenessEmailNotification;
-
- public void setCompletenessEmailNotification( Boolean completenessEmailNotification )
- {
- this.completenessEmailNotification = completenessEmailNotification;
- }
-
private String message;
public String getMessage()
@@ -92,8 +83,6 @@
public String execute()
throws Exception
{
- userSettingService.saveUserSetting( KEY_COMPLETENESS_EMAIL_NOTIFICATION, completenessEmailNotification );
-
userSettingService.saveUserSetting( KEY_MESSAGE_EMAIL_NOTIFICATION, messageEmailNotification );
message = i18n.getString( "settings_updated" );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties 2011-10-07 08:07:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties 2011-10-07 11:48:18 +0000
@@ -115,4 +115,6 @@
no_feedback_recipients = No message recipients
settings_updated = Settings were updated
message_email_notification = Message email notification
-completeness_email_notification = Completeness email notification
\ No newline at end of file
+completeness_email_notification = Completeness email notification
+completeness_recipients = Completeness notification recipients
+no_completeness_recipients = No completeness recipients
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm 2011-10-06 08:48:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm 2011-10-07 11:48:18 +0000
@@ -6,6 +6,7 @@
infrastructuralDataElements: getFieldValue( 'infrastructuralDataElements' ),
infrastructuralPeriodType: getFieldValue( 'infrastructuralPeriodType' ),
feedbackRecipients: getFieldValue( 'feedbackRecipients' ),
+ completenessRecipients: getFieldValue( 'completenessRecipients' ),
omitIndicatorsZeroNumeratorDataMart: jQuery( '#omitIndicatorsZeroNumeratorDataMart' ).is( ':checked' ),
disableDataEntryWhenCompleted: jQuery( '#disableDataEntryWhenCompleted' ).is( ':checked' ),
factorDeviation: getFieldValue( 'factorDeviation' ),
@@ -63,6 +64,18 @@
</select>
</p>
+<!-- completeness_recipients -->
+<h4>$i18n.getString( "completeness_recipients" )</h4>
+
+<p>
+<select id="completenessRecipients" name="completenessRecipients" style="width:30em">
+ <option value="-1">$i18n.getString( "no_completeness_recipients" )</option>
+ #foreach ( $group in $userGroups )
+ <option value="$group.id" #if( $group.id == $!completenessRecipients.id )selected="selected"#end>$encoder.htmlEncode( $group.name )</option>
+ #end
+</select>
+</p>
+
<!-- omit_indicators_zero_numerator_data_mart -->
<h4>$i18n.getString( "omit_indicators_zero_numerator_data_mart" )</h4>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/userEmailSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/userEmailSettings.vm 2011-10-07 08:07:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/userEmailSettings.vm 2011-10-07 11:48:18 +0000
@@ -3,7 +3,6 @@
jQuery(document).ready(function() {
jQuery("input[type=button]").click(function() {
jQuery.postJSON( 'setUserEmailSettings.action', {
- completenessEmailNotification: jQuery( '#completenessEmailNotification' ).is(':checked' ),
messageEmailNotification: jQuery( '#messageEmailNotification' ).is(':checked' )
}, function ( json ) {
if ( json.response == "success" )
@@ -15,9 +14,6 @@
<h3>$i18n.getString("user_email_settings")</h3>
-<h4>$i18n.getString( "completeness_email_notification" )</h4>
-<input type="checkbox" id="completenessEmailNotification" name="completenessEmailNotification" #if( $completenessEmailNotification ) checked="checked"#end/>
-
<h4>$i18n.getString( "message_email_notification" )</h4>
<input type="checkbox" id="messageEmailNotification" name="messageEmailNotification" #if( $messageEmailNotification ) checked="checked"#end/>