← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8237: Impl support for sending messages to a user group per data set when the data set is marked as com...

 

------------------------------------------------------------
revno: 8237
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-09-24 23:54:54 +0200
message:
  Impl support for sending messages to a user group per data set when the data set is marked as complete
removed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/PeriodTypeListAction.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistrationService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultCompleteDataSetRegistrationService.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/META-INF/dhis/beans.xml
  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-dataentry/src/main/resources/META-INF/dhis/beans.xml
  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/EditDataSetFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.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/META-INF/dhis/beans.xml
  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/struts.xml
  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/CompleteDataSetRegistrationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistrationService.java	2012-07-01 07:12:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistrationService.java	2012-09-24 21:54:54 +0000
@@ -49,6 +49,14 @@
     void saveCompleteDataSetRegistration( CompleteDataSetRegistration registration );
 
     /**
+     * Saves a CompleteDataSetRegistration.
+     * 
+     * @param registration the CompleteDataSetRegistration to save.
+     * @param notify indicates whether a notification should be sent.
+     */    
+    void saveCompleteDataSetRegistration( CompleteDataSetRegistration registration, boolean notify );
+
+    /**
      * Updates a CompleteDataSetRegistration.
      * 
      * @param registration the CompleteDataSetRegistration to update.

=== 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-19 16:14:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2012-09-24 21:54:54 +0000
@@ -49,6 +49,7 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.UserGroup;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -138,6 +139,11 @@
      * Property indicating whether aggregation should be skipped.
      */
     private boolean skipAggregation;
+    
+    /**
+     * User group which will receive notifications when data set is marked complete.
+     */
+    private UserGroup notificationRecipients;
 
     // -------------------------------------------------------------------------
     // Form properties
@@ -549,6 +555,19 @@
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+    public UserGroup getNotificationRecipients()
+    {
+        return notificationRecipients;
+    }
+
+    public void setNotificationRecipients( UserGroup notificationRecipients )
+    {
+        this.notificationRecipients = notificationRecipients;
+    }
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public boolean isAllowFuturePeriods()
     {
         return allowFuturePeriods;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java	2012-09-11 06:48:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java	2012-09-24 21:54:54 +0000
@@ -29,7 +29,6 @@
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultCompleteDataSetRegistrationService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultCompleteDataSetRegistrationService.java	2012-07-01 07:12:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultCompleteDataSetRegistrationService.java	2012-09-24 21:54:54 +0000
@@ -27,6 +27,7 @@
 import java.util.Date;
 
 import org.apache.commons.collections.CollectionUtils;
+import org.hisp.dhis.message.MessageService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.springframework.transaction.annotation.Transactional;
@@ -49,7 +50,14 @@
     {
         this.completeDataSetRegistrationStore = completeDataSetRegistrationStore;
     }
-    
+
+    private MessageService messageService;
+
+    public void setMessageService( MessageService messageService )
+    {
+        this.messageService = messageService;
+    }
+
     // -------------------------------------------------------------------------
     // CompleteDataSetRegistrationService
     // -------------------------------------------------------------------------
@@ -59,6 +67,16 @@
         completeDataSetRegistrationStore.saveCompleteDataSetRegistration( registration );
     }
 
+    public void saveCompleteDataSetRegistration( CompleteDataSetRegistration registration, boolean notify )
+    {
+        saveCompleteDataSetRegistration( registration );
+        
+        if ( notify )
+        {
+            messageService.sendCompletenessMessage( registration );
+        }
+    }
+    
     public void updateCompleteDataSetRegistration( CompleteDataSetRegistration registration )
     {
         completeDataSetRegistrationStore.updateCompleteDataSetRegistration( registration );

=== 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-09-24 14:34:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java	2012-09-24 21:54:54 +0000
@@ -156,38 +156,40 @@
 
     public int sendCompletenessMessage( CompleteDataSetRegistration registration )
     {
-        UserGroup userGroup = new UserGroup(); //TODO
-
         DataSet dataSet = registration.getDataSet();
         
-        if ( userGroup != null && !userGroup.getMembers().isEmpty() && dataSet != null )
-        {
-            User sender = currentUserService.getCurrentUser();
-
-            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() )
-            {
-                if ( user.getUserCredentials().getAllDataSets().contains( dataSet ) )
-                {
-                    conversation.addUserMessage( new UserMessage( user ) );
-                }
-            }
-
-            if ( !conversation.getUserMessages().isEmpty() )
-            {
-                int id = saveMessageConversation( conversation );
-                
-                invokeMessageSenders( COMPLETE_SUBJECT, text, sender, conversation.getUsers() );
-                
-                return id;
-            }
-        }
-
+        if ( dataSet == null || dataSet.getNotificationRecipients() == null || dataSet.getNotificationRecipients().getMembers().isEmpty() )
+        {
+            return 0;
+        }
+        
+        UserGroup userGroup = dataSet.getNotificationRecipients();
+        
+        User sender = currentUserService.getCurrentUser();
+
+        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() )
+        {
+            if ( user.getUserCredentials().getAllDataSets().contains( dataSet ) )
+            {
+                conversation.addUserMessage( new UserMessage( user ) );
+            }
+        }
+
+        if ( !conversation.getUserMessages().isEmpty() )
+        {
+            int id = saveMessageConversation( conversation );
+            
+            invokeMessageSenders( COMPLETE_SUBJECT, text, sender, conversation.getUsers() );
+            
+            return id;
+        }
+            
         return 0;
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-09-24 18:05:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2012-09-24 21:54:54 +0000
@@ -337,6 +337,7 @@
 
   <bean id="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" class="org.hisp.dhis.dataset.DefaultCompleteDataSetRegistrationService">
     <property name="completeDataSetRegistrationStore" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationStore" />
+    <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
   </bean>
 
   <bean id="org.hisp.dhis.dataset.SectionService" class="org.hisp.dhis.dataset.DefaultSectionService">

=== 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-19 16:14:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml	2012-09-24 21:54:54 +0000
@@ -66,6 +66,9 @@
     <property name="expiryDays" />
 	
 	<property name="skipAggregation" />
+	
+	<many-to-one name="notificationRecipients" class="org.hisp.dhis.user.UserGroup"
+	   foreign-key="fk_dataset_notificationrecipients" />
 
 	<!-- 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-02-21 18:45:10 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/RegisterCompleteDataSetAction.java	2012-09-24 21:54:54 +0000
@@ -27,7 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.opensymphony.xwork2.Action;
+import java.util.Date;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
@@ -35,14 +36,13 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.message.MessageService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.CurrentUserService;
 
-import java.util.Date;
+import com.opensymphony.xwork2.Action;
 
 /**
  * @author Lars Helge Overland
@@ -84,13 +84,6 @@
         this.currentUserService = currentUserService;
     }
 
-    private MessageService messageService;
-
-    public void setMessageService( MessageService messageService )
-    {
-        this.messageService = messageService;
-    }
-
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -165,13 +158,13 @@
             registration.setDate( new Date() );
             registration.setStoredBy( storedBy );
 
-            registrationService.saveCompleteDataSetRegistration( registration );
+            registration.getPeriod().setName( format.formatPeriod( registration.getPeriod() ) );
+
+            boolean notify = dataSet != null && dataSet.getNotificationRecipients() != null;
+            
+            registrationService.saveCompleteDataSetRegistration( registration, notify );
 
             log.info( "DataSet registered as complete: " + registration );
-
-            registration.getPeriod().setName( format.formatPeriod( registration.getPeriod() ) );
-
-            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	2012-07-25 13:18:48 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2012-09-24 21:54:54 +0000
@@ -90,7 +90,6 @@
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-    <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-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-19 16:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2012-09-24 21:54:54 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.UserGroupService;
 import org.hisp.dhis.user.UserService;
 
 import com.opensymphony.xwork2.Action;
@@ -68,6 +69,13 @@
         this.dataElementService = dataElementService;
     }
 
+    private IndicatorService indicatorService;
+
+    public void setIndicatorService( IndicatorService indicatorService )
+    {
+        this.indicatorService = indicatorService;
+    }
+
     private UserService userService;
 
     public void setUserService( UserService userService )
@@ -75,11 +83,11 @@
         this.userService = userService;
     }
 
-    private IndicatorService indicatorService;
+    private UserGroupService userGroupService;
 
-    public void setIndicatorService( IndicatorService indicatorService )
+    public void setUserGroupService( UserGroupService userGroupService )
     {
-        this.indicatorService = indicatorService;
+        this.userGroupService = userGroupService;
     }
 
     // -------------------------------------------------------------------------
@@ -121,6 +129,13 @@
         this.expiryDays = expiryDays;
     }
     
+    private int notificationRecipients;
+    
+    public void setNotificationRecipients( int notificationRecipients )
+    {
+        this.notificationRecipients = notificationRecipients;
+    }
+
     private boolean skipAggregation;
 
     public void setSkipAggregation( boolean skipAggregation )
@@ -203,15 +218,16 @@
         {
             indicators.add( indicatorService.getIndicator( Integer.parseInt( id ) ) );
         }
-
+        
         dataSet.setDescription( description );
         dataSet.setVersion( 1 );
         dataSet.setMobile( false );
         dataSet.setIndicators( indicators );
+        dataSet.setNotificationRecipients( userGroupService.getUserGroup( notificationRecipients ) );
         dataSet.setAllowFuturePeriods( allowFuturePeriods );
         dataSet.setFieldCombinationRequired( fieldCombinationRequired );
         dataSet.setValidCompleteOnly( validCompleteOnly );
-
+        
         dataSetService.addDataSet( dataSet );
 
         userService.assignDataSetToUserRole( dataSet );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java	2012-02-01 09:54:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java	2012-09-24 21:54:54 +0000
@@ -38,6 +38,8 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -64,6 +66,13 @@
     {
         this.dataSetService = dataSetService;
     }
+    
+    private UserGroupService userGroupService;
+
+    public void setUserGroupService( UserGroupService userGroupService )
+    {
+        this.userGroupService = userGroupService;
+    }
 
     // -------------------------------------------------------------------------
     // Input & output
@@ -76,16 +85,18 @@
         this.dataSetId = dataSetId;
     }
 
-    private List<PeriodType> periodTypes;
+    private List<PeriodType> periodTypes = new ArrayList<PeriodType>();
 
     public List<PeriodType> getPeriodTypes()
     {
         return periodTypes;
     }
 
-    public void setPeriodTypes( List<PeriodType> periodTypes )
+    private List<UserGroup> userGroups = new ArrayList<UserGroup>();
+
+    public List<UserGroup> getUserGroups()
     {
-        this.periodTypes = periodTypes;
+        return userGroups;
     }
 
     private DataSet dataSet;
@@ -95,14 +106,14 @@
         return dataSet;
     }
 
-    private List<DataElement> dataElements;
+    private List<DataElement> dataElements = new ArrayList<DataElement>();
 
     public List<DataElement> getDataElements()
     {
         return dataElements;
     }
 
-    private List<Indicator> indicators;
+    private List<Indicator> indicators = new ArrayList<Indicator>();
 
     public List<Indicator> getIndicators()
     {
@@ -117,6 +128,7 @@
         throws Exception
     {
         periodTypes = periodService.getAllPeriodTypes();
+        userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
 
         if ( dataSetId != null )
         {
@@ -125,8 +137,9 @@
             indicators = new ArrayList<Indicator>( dataSet.getIndicators() );
         }
 
-        Collections.sort( dataElements, new IdentifiableObjectNameComparator() );
-        Collections.sort( indicators, new IdentifiableObjectNameComparator() );
+        Collections.sort( userGroups, IdentifiableObjectNameComparator.INSTANCE );
+        Collections.sort( dataElements, IdentifiableObjectNameComparator.INSTANCE );
+        Collections.sort( indicators, IdentifiableObjectNameComparator.INSTANCE );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java	2012-02-01 09:54:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/GetDataSetAction.java	2012-09-24 21:54:54 +0000
@@ -66,7 +66,7 @@
     {
         this.selectionTreeManager = selectionTreeManager;
     }
-
+    
     // -------------------------------------------------------------------------
     // Input & output
     // -------------------------------------------------------------------------
@@ -90,14 +90,14 @@
         return dataSet;
     }
 
-    private List<DataElement> dataSetDataElements;
+    private List<DataElement> dataSetDataElements = new ArrayList<DataElement>();
 
     public List<DataElement> getDataSetDataElements()
     {
         return dataSetDataElements;
     }
 
-    private List<Indicator> dataSetIndicators;
+    private List<Indicator> dataSetIndicators = new ArrayList<Indicator>();
 
     public List<Indicator> getDataSetIndicators()
     {

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/PeriodTypeListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/PeriodTypeListAction.java	2011-10-13 03:03:58 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/PeriodTypeListAction.java	1970-01-01 00:00:00 +0000
@@ -1,81 +0,0 @@
-package org.hisp.dhis.dataset.action;
-
-/*
- * Copyright (c) 2004-2011, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.Collection;
-
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Kristian
- */
-public class PeriodTypeListAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private PeriodService periodService;
-
-    public void setPeriodService( PeriodService periodService )
-    {
-        this.periodService = periodService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input & output
-    // -------------------------------------------------------------------------
-
-    private Collection<PeriodType> periodTypes;
-
-    public Collection<PeriodType> getPeriodTypes()
-    {
-        return periodTypes;
-    }
-
-    public void setPeriodTypes( Collection<PeriodType> periodTypes )
-    {
-        this.periodTypes = periodTypes;
-    }
-
-    // -------------------------------------------------------------------------
-    // Execute
-    // -------------------------------------------------------------------------
-
-    public String execute()
-        throws Exception
-    {
-        periodTypes = periodService.getAllPeriodTypes();
-
-        return SUCCESS;
-    }
-}

=== 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-19 16:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2012-09-24 21:54:54 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.UserGroupService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -93,6 +94,13 @@
         this.sectionService = sectionService;
     }
 
+    private UserGroupService userGroupService;
+
+    public void setUserGroupService( UserGroupService userGroupService )
+    {
+        this.userGroupService = userGroupService;
+    }
+
     // -------------------------------------------------------------------------
     // Input & output
     // -------------------------------------------------------------------------
@@ -132,6 +140,13 @@
         this.expiryDays = expiryDays;
     }
 
+    private int notificationRecipients;
+    
+    public void setNotificationRecipients( int notificationRecipients )
+    {
+        this.notificationRecipients = notificationRecipients;
+    }
+
     private boolean skipAggregation;
 
     public void setSkipAggregation( boolean skipAggregation )
@@ -223,7 +238,7 @@
 
         dataSet.setExpiryDays( expiryDays );
         dataSet.setSkipAggregation( skipAggregation );
-
+        
         if ( !(equalsNullSafe( name, dataSet.getName() ) && periodType.equals( dataSet.getPeriodType() )
             && dataElements.equals( dataSet.getDataElements() ) && indicators.equals( dataSet.getIndicators() )) )
         {
@@ -240,6 +255,7 @@
         dataSet.setAllowFuturePeriods( allowFuturePeriods );
         dataSet.setFieldCombinationRequired( fieldCombinationRequired );
         dataSet.setValidCompleteOnly( validCompleteOnly );
+        dataSet.setNotificationRecipients( userGroupService.getUserGroup( notificationRecipients ) );
 
         dataSetService.updateDataSet( dataSet );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2012-09-12 20:07:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2012-09-24 21:54:54 +0000
@@ -163,13 +163,6 @@
     </property>
   </bean>
 
-  <bean id="org.hisp.dhis.dataset.action.PeriodTypeListAction" class="org.hisp.dhis.dataset.action.PeriodTypeListAction"
-    scope="prototype">
-    <property name="periodService">
-      <ref bean="org.hisp.dhis.period.PeriodService" />
-    </property>
-  </bean>
-
   <bean id="org.hisp.dhis.dataset.action.SaveDataSetSortOrderAction" class="org.hisp.dhis.dataset.action.SaveDataSetSortOrderAction"
     scope="prototype">
     <property name="dataSetService">
@@ -185,6 +178,9 @@
     <property name="periodService">
       <ref bean="org.hisp.dhis.period.PeriodService" />
     </property>
+    <property name="userGroupService">
+      <ref bean="org.hisp.dhis.user.UserGroupService" />
+    </property>
   </bean>
 
   <bean id="org.hisp.dhis.dataset.action.AddDataSetAction" class="org.hisp.dhis.dataset.action.AddDataSetAction"
@@ -201,6 +197,9 @@
     <property name="userService">
       <ref bean="org.hisp.dhis.user.UserService" />
     </property>
+    <property name="userGroupService">
+      <ref bean="org.hisp.dhis.user.UserGroupService" />
+    </property>
   </bean>
 
   <bean id="org.hisp.dhis.dataset.action.UpdateDataSetAction" class="org.hisp.dhis.dataset.action.UpdateDataSetAction"
@@ -220,6 +219,9 @@
     <property name="indicatorService">
       <ref bean="org.hisp.dhis.indicator.IndicatorService" />
     </property>
+    <property name="userGroupService">
+      <ref bean="org.hisp.dhis.user.UserGroupService" />
+    </property>
   </bean>
 
   <bean id="org.hisp.dhis.dataset.action.GetDataSetAction" class="org.hisp.dhis.dataset.action.GetDataSetAction"

=== 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-09-19 16:14:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2012-09-24 21:54:54 +0000
@@ -102,4 +102,5 @@
 cat_combo_not_exist=Category combo does not exist
 all_fields_for_data_element_required=All fields for data elements required
 form_details=Form details
-complete_allowed_only_if_validation_passes=Complete allowed only if validation passes
\ No newline at end of file
+complete_allowed_only_if_validation_passes=Complete allowed only if validation passes
+notification_recipients=Complete notification recipients
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2012-04-23 14:30:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2012-09-24 21:54:54 +0000
@@ -113,7 +113,7 @@
 
 	<!-- Show add DataSet form -->
 
-    <action name="addDataSetForm" class="org.hisp.dhis.dataset.action.PeriodTypeListAction">
+    <action name="addDataSetForm" class="org.hisp.dhis.dataset.action.EditDataSetFormAction">
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-maintenance-dataset/addDataSet.vm</param>
       <param name="javascripts">javascript/shortName.js,javascript/dataSet.js</param>

=== 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-09-24 03:14:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2012-09-24 21:54:54 +0000
@@ -88,7 +88,18 @@
             #end
           </select>
         </td>
-      </tr>   
+      </tr>
+      <tr>
+      	<td><label>$i18n.getString( "notification_recipients" )</label></td>
+      	<td>
+      	  <select id="notificationRecipients" name="notificationRecipients" style="min-width:20em; margin:0;">
+      	  	<option value="-1">[ $i18n.getString( "none" ) ]</option>
+      	  	#foreach( $group in $userGroups )
+      	  	  <option value="$group.id">$encoder.htmlEncode( $group.name )</option>
+	  	    #end
+  	      </select>
+	    </td>
+      </tr>
       <tr>
       	<td><label>$i18n.getString( "skip_aggregation" )</label></td>
       	<td>

=== 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-09-24 03:14:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2012-09-24 21:54:54 +0000
@@ -97,6 +97,17 @@
       	  	<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" style="min-width:20em; margin:0;">
+          	<option value="-1">[ $i18n.getString( "none" ) ]</option>
+            #foreach( $group in $userGroups )
+              <option value="$group.id"#if( $dataSet.notificationRecipients && $dataSet.notificationRecipients.equals( $group ) ) selected="selected"#end>$encoder.htmlEncode( $group.name )</option>
+            #end
+          </select>
+        </td>
       </tr>
     </tbody>
     <thead>
@@ -104,7 +115,7 @@
         <th colspan="2">$i18n.getString( "form_details" )</th>
       </tr>
     </thead>
-    <tobd
+    <tbody>
       <tr>
       	<td><label>$i18n.getString( "allow_future_periods" )</label></td>
       	<td>