=== 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 @@ + === 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 @@ + + === 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 @@ - periodTypes; + private List periodTypes = new ArrayList(); public List getPeriodTypes() { return periodTypes; } - public void setPeriodTypes( List periodTypes ) + private List userGroups = new ArrayList(); + + public List getUserGroups() { - this.periodTypes = periodTypes; + return userGroups; } private DataSet dataSet; @@ -95,14 +106,14 @@ return dataSet; } - private List dataElements; + private List dataElements = new ArrayList(); public List getDataElements() { return dataElements; } - private List indicators; + private List indicators = new ArrayList(); public List getIndicators() { @@ -117,6 +128,7 @@ throws Exception { periodTypes = periodService.getAllPeriodTypes(); + userGroups = new ArrayList( userGroupService.getAllUserGroups() ); if ( dataSetId != null ) { @@ -125,8 +137,9 @@ indicators = new ArrayList( 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 dataSetDataElements; + private List dataSetDataElements = new ArrayList(); public List getDataSetDataElements() { return dataSetDataElements; } - private List dataSetIndicators; + private List dataSetIndicators = new ArrayList(); public List 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 periodTypes; - - public Collection getPeriodTypes() - { - return periodTypes; - } - - public void setPeriodTypes( Collection 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 @@ - - - - - - @@ -185,6 +178,9 @@ + + + + + + + + + - + /main.vm /dhis-web-maintenance-dataset/addDataSet.vm javascript/shortName.js,javascript/dataSet.js === 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 - + + + + + + + === 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 @@ + + + + + + @@ -104,7 +115,7 @@ $i18n.getString( "form_details" ) -