Search in sources :

Example 1 with MessageConversationParams

use of org.hisp.dhis.message.MessageConversationParams in project dhis2-core by dhis2.

the class SystemUpdateService method sendMessageForEachVersion.

public void sendMessageForEachVersion(Map<Semver, Map<String, String>> patchVersions) {
    Set<User> recipients = getRecipients();
    for (Map.Entry<Semver, Map<String, String>> entry : patchVersions.entrySet()) {
        Semver version = entry.getKey();
        Map<String, String> message = entry.getValue();
        for (User recipient : recipients) {
            // Check if message has been sent before using
            // version.getValue() as extMessageId
            List<MessageConversation> existingMessages = messageService.getMatchingExtId(version.getValue());
            if (existingMessages.isEmpty()) {
                MessageConversationParams params = new MessageConversationParams.Builder().withRecipients(ImmutableSet.of(recipient)).withSubject(NEW_VERSION_AVAILABLE_MESSAGE_SUBJECT).withText(buildMessageText(message)).withMessageType(MessageType.SYSTEM).withExtMessageId(version.getValue()).build();
                messageService.sendMessage(params);
            }
        }
    }
}
Also used : User(org.hisp.dhis.user.User) MessageConversationParams(org.hisp.dhis.message.MessageConversationParams) MessageConversation(org.hisp.dhis.message.MessageConversation) Semver(com.vdurmont.semver4j.Semver) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

Semver (com.vdurmont.semver4j.Semver)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 MessageConversation (org.hisp.dhis.message.MessageConversation)1 MessageConversationParams (org.hisp.dhis.message.MessageConversationParams)1 User (org.hisp.dhis.user.User)1