Search in sources :

Example 16 with AdminEmailAttributes

use of teammates.common.datatransfer.attributes.AdminEmailAttributes in project teammates by TEAMMATES.

the class AdminEmailComposeSendAction method updateDraftEmailToSent.

private void updateDraftEmailToSent(String emailId, String subject, List<String> addressReceiver, List<String> groupReceiver, String content) {
    AdminEmailAttributes finalisedEmail = AdminEmailAttributes.builder(subject, addressReceiver, groupReceiver, new Text(content)).withSendDate(Instant.now()).build();
    try {
        logic.updateAdminEmailById(finalisedEmail, emailId);
    } catch (InvalidParametersException | EntityDoesNotExistException e) {
        isError = true;
        setStatusForException(e);
        return;
    }
    moveJobToGroupModeTaskQueue();
    moveJobToAddressModeTaskQueue();
}
Also used : Text(com.google.appengine.api.datastore.Text) InvalidParametersException(teammates.common.exception.InvalidParametersException) AdminEmailAttributes(teammates.common.datatransfer.attributes.AdminEmailAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 17 with AdminEmailAttributes

use of teammates.common.datatransfer.attributes.AdminEmailAttributes in project teammates by TEAMMATES.

the class AdminPrepareEmailGroupModeWorkerAction method addAdminEmailToTaskQueue.

private void addAdminEmailToTaskQueue(String emailId, String groupReceiverListFileKey, List<List<String>> processedReceiverEmails, int indexOfEmailListToResume, int indexOfEmailToResume) {
    AdminEmailAttributes adminEmail = logic.getAdminEmailById(emailId);
    Assumption.assertNotNull(adminEmail);
    log.info("Resume adding group mail tasks for mail with id " + emailId + " from list index: " + indexOfEmailListToResume + " and email index: " + indexOfEmailToResume);
    int indexOfLastEmailList = 0;
    int indexOfLastEmail = 0;
    for (int i = indexOfEmailListToResume; i < processedReceiverEmails.size(); i++) {
        List<String> currentEmailList = processedReceiverEmails.get(i);
        for (int j = indexOfEmailToResume; j < currentEmailList.size(); j++) {
            String receiverEmail = currentEmailList.get(j);
            taskQueuer.scheduleAdminEmailForSending(emailId, receiverEmail, adminEmail.getSubject(), adminEmail.getContentValue());
            if (isNearDeadline()) {
                taskQueuer.scheduleAdminEmailPreparationInGroupMode(emailId, groupReceiverListFileKey, i, j);
                log.info("Adding group mail tasks for mail with id " + emailId + " have been paused with list index: " + i + " and email index: " + j);
                return;
            }
            indexOfLastEmail = j;
        }
        indexOfLastEmailList = i;
    }
    log.info("Adding group mail tasks for mail with id " + emailId + "was complete with last reached list index: " + indexOfLastEmailList + " and last reached email index: " + indexOfLastEmail);
}
Also used : AdminEmailAttributes(teammates.common.datatransfer.attributes.AdminEmailAttributes)

Aggregations

AdminEmailAttributes (teammates.common.datatransfer.attributes.AdminEmailAttributes)17 Test (org.testng.annotations.Test)7 Text (com.google.appengine.api.datastore.Text)5 AdminEmailComposePageData (teammates.ui.pagedata.AdminEmailComposePageData)3 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)2 InvalidParametersException (teammates.common.exception.InvalidParametersException)2 ShowPageResult (teammates.ui.controller.ShowPageResult)2 BlobKey (com.google.appengine.api.blobstore.BlobKey)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 TeammatesException (teammates.common.exception.TeammatesException)1 EmailWrapper (teammates.common.util.EmailWrapper)1 StatusMessage (teammates.common.util.StatusMessage)1 EmailGenerator (teammates.logic.api.EmailGenerator)1 AdminEmail (teammates.storage.entity.AdminEmail)1 AdminEmailComposePageAction (teammates.ui.controller.AdminEmailComposePageAction)1 AdminEmailComposeSaveAction (teammates.ui.controller.AdminEmailComposeSaveAction)1