dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17158
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6743: Made data set completeness notifications only go out to users who have access to the data set thr...
------------------------------------------------------------
revno: 6743
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-25 16:26:13 +0200
message:
Made data set completeness notifications only go out to users who have access to the data set through user roles
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java
--
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-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-04-25 12:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2012-04-25 14:26:13 +0000
@@ -27,11 +27,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.configuration.ConfigurationService;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
-import org.hisp.dhis.system.util.Clock;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.system.velocity.VelocityManager;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
@@ -39,10 +43,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
/**
* @author Lars Helge Overland
*/
@@ -158,7 +158,9 @@
{
UserGroup userGroup = configurationService.getConfiguration().getCompletenessRecipients();
- if ( userGroup != null && userGroup.getMembers().size() > 0 )
+ DataSet dataSet = registration.getDataSet();
+
+ if ( userGroup != null && !userGroup.getMembers().isEmpty() && dataSet != null )
{
User sender = currentUserService.getCurrentUser();
@@ -167,17 +169,23 @@
MessageConversation conversation = new MessageConversation( COMPLETE_SUBJECT, sender );
conversation.addMessage( new Message( text, null, sender ) );
-
+
for ( User user : userGroup.getMembers() )
{
- conversation.addUserMessage( new UserMessage( user ) );
- }
-
- int id = saveMessageConversation( conversation );
-
- invokeMessageSenders( COMPLETE_SUBJECT, text, sender, userGroup.getMembers() );
-
- return id;
+ 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;