Package org.sis.ancmessaging.server.domain

Examples of org.sis.ancmessaging.server.domain.TextMessage


            int smscCode = Integer.parseInt(message.getRefNo());
            String recipient = "+" + message.getRecipient();
           
            mainForm.setLogText("\n\nIncoming status Report ...");

            TextMessage textMessage = textMessageDao.getBySmscCodeAndRecipient(smscCode, recipient);
            if (textMessage != null) {
                Mother mother = motherDao.getMother(textMessage.getSeqId());
                String reminderType = textMessage.getMessageType();
                boolean reminderAlreadySent;
                if (reminderType.equals("MONTHLY")) {
                    reminderAlreadySent = motherDao.hasMonthlyReminder(mother);
                } else {
                    reminderAlreadySent = motherDao.hasWeeklyReminder(mother);
                }

                if (!reminderAlreadySent) {
                    textMessageDao.changeStatus(textMessage, "A");
                    mainForm.setLogText("\nReminder to be written to database ...");
                    DateTime eddGreg = new DateTime(mother.getEdd());
                    LocalDate eddEth = eddGreg.withChronology(EthiopicChronology.getInstance()).toLocalDate();
                    String date = eddEth.getDayOfMonth() + "/" + eddEth.getMonthOfYear() + "/" + eddEth.getYear();
                    String gott = (mother.getGott() == null) ? "Urban" : mother.getGott();
                    String template = "ID: " + mother.getSeqId() + "\n" + mother.getFullName() + "\n" + gott + "\nEDD: " + date;

                    Reminder reminder = new Reminder();
                    reminder.setStatus("UNCONFIRMED");
                    reminder.setContent(template);
                    reminder.setMother(mother);
                    reminder.setReminderSentOn(new DateTime().toLocalDate().toDate());
                    reminder.setReminderType(textMessage.getMessageType());
                    reminderDao.save(reminder);
                } else {
                    if (textMessage.getStatus().equals("P")) {
                        textMessageDao.changeStatus(textMessage, "R");
                    }
                }
            }
            mainForm.setLogText("\nProcess completed.");
View Full Code Here


        String recipient = healthWorker.getPhoneNumber();
    messageHandler.setRecipient(recipient);
    try {
            int smscCode = Integer.parseInt(messageHandler.sendMessage());
            TextMessage oldMessage = textMessageDao.getMessageInProgress(mother.getSeqId());
            if (oldMessage != null) {
                textMessageDao.changeStatus(oldMessage, "R");
            }
            TextMessage textMessage = new TextMessage();
            textMessage.setMessageType(type);
            textMessage.setAttemptSendingOn(new DateTime().toLocalDate().toDate());
            textMessage.setRecipient(recipient);
            textMessage.setSeqId(mother.getSeqId());
            textMessage.setSmscCode(smscCode);
            if (smscCode > 0) {
                textMessage.setStatus("A");
                Reminder reminder = new Reminder();
                reminder.setStatus("UNCONFIRMED");
                reminder.setContent(template);
                reminder.setMother(mother);
                reminder.setReminderSentOn(new DateTime().toLocalDate().toDate());
                reminder.setReminderType(type);
                reminderDao.save(reminder);
            } else {
                textMessage.setStatus("P");
            }

            textMessageDao.save(textMessage);

            //incomingService.readIncomingInInterval();
View Full Code Here

        return (TextMessage) criteria.uniqueResult();
    }

    @Override
    public void changeStatus(TextMessage textMessage, String newStatus) {
        TextMessage oldMessage = (TextMessage) getSession().get(TextMessage.class, textMessage.getMessageId());
        oldMessage.setStatus(newStatus);
        getSession().update(oldMessage);
    }
View Full Code Here

TOP

Related Classes of org.sis.ancmessaging.server.domain.TextMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.