use of org.hisp.dhis.sms.outbound.OutboundSms in project dhis2-core by dhis2.
the class SendSmsTask method run.
@Override
public void run() {
notifier.notify(taskId, "Sending SMS");
status = smsSender.sendMessage(smsSubject, text, null, currentUser, new HashSet<>(recipientsList), false);
OutboundSms sms = new OutboundSms();
sms.setMessage(text);
sms.setRecipients(recipientsList.stream().map(item -> item.getPhoneNumber()).collect(Collectors.toSet()));
if (status.isOk()) {
notifier.notify(taskId, "Message sending successful");
sms.setStatus(OutboundSmsStatus.SENT);
} else {
notifier.notify(taskId, "Message sending failed");
sms.setStatus(OutboundSmsStatus.FAILED);
}
outboundSmsService.saveOutboundSms(sms);
}
use of org.hisp.dhis.sms.outbound.OutboundSms in project dhis2-core by dhis2.
the class HibernateOutboundSmsStore method getAllOutboundSms.
@SuppressWarnings("unchecked")
@Override
public List<OutboundSms> getAllOutboundSms(Integer min, Integer max) {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(OutboundSms.class).addOrder(Order.desc("date"));
if (min != null && max != null) {
criteria.setFirstResult(min).setMaxResults(max);
}
return criteria.list();
}
Aggregations