use of org.hibernate.Criteria in project dhis2-core by dhis2.
the class HibernateSMSCommandStore method getSMSCommand.
@Override
public SMSCommand getSMSCommand(String name) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(SMSCommand.class);
criteria.add(Restrictions.eq("name", name));
if (criteria.list() != null && criteria.list().size() > 0) {
return (SMSCommand) criteria.list().get(0);
}
return null;
}
use of org.hibernate.Criteria in project dhis2-core by dhis2.
the class HibernateIncomingSmsStore method getAllUnparsedSmses.
@SuppressWarnings("unchecked")
@Override
public List<IncomingSms> getAllUnparsedSmses() {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(IncomingSms.class);
criteria.add(Restrictions.eq("parsed", false));
return criteria.list();
}
use of org.hibernate.Criteria in project dhis2-core by dhis2.
the class HibernateIncomingSmsStore method getSmsByStatus.
@Override
@SuppressWarnings("unchecked")
public List<IncomingSms> getSmsByStatus(SmsMessageStatus status, String keyword) {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(IncomingSms.class).addOrder(Order.desc("sentDate"));
if (status != null) {
criteria.add(Restrictions.eq("status", status));
}
criteria.add(Restrictions.ilike("originator", "%" + keyword + "%"));
return criteria.list();
}
use of org.hibernate.Criteria in project dhis2-core by dhis2.
the class HibernateIncomingSmsStore method getSmsByStatus.
@Override
@SuppressWarnings("unchecked")
public List<IncomingSms> getSmsByStatus(SmsMessageStatus status, String keyword, Integer min, Integer max) {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(IncomingSms.class).addOrder(Order.desc("sentDate"));
if (status != null) {
criteria.add(Restrictions.eq("status", status));
}
criteria.add(Restrictions.ilike("originator", "%" + keyword + "%"));
if (min != null && max != null) {
criteria.setFirstResult(min).setMaxResults(max);
}
return criteria.list();
}
use of org.hibernate.Criteria in project dhis2-core by dhis2.
the class HibernateIncomingSmsStore method getSmsByOriginator.
@Override
@SuppressWarnings("unchecked")
public List<IncomingSms> getSmsByOriginator(String originator) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(IncomingSms.class);
criteria.add(Restrictions.eq("originator", originator));
return criteria.list();
}
Aggregations