Search in sources :

Example 81 with Criteria

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;
}
Also used : SMSCommand(org.hisp.dhis.sms.command.SMSCommand) Criteria(org.hibernate.Criteria)

Example 82 with Criteria

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();
}
Also used : Criteria(org.hibernate.Criteria)

Example 83 with Criteria

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();
}
Also used : IncomingSms(org.hisp.dhis.sms.incoming.IncomingSms) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 84 with Criteria

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();
}
Also used : IncomingSms(org.hisp.dhis.sms.incoming.IncomingSms) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 85 with Criteria

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();
}
Also used : Criteria(org.hibernate.Criteria)

Aggregations

Criteria (org.hibernate.Criteria)180 Session (org.hibernate.Session)95 Test (org.junit.Test)69 List (java.util.List)39 Transaction (org.hibernate.Transaction)39 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)27 ArrayList (java.util.ArrayList)15 TestForIssue (org.hibernate.testing.TestForIssue)12 Iterator (java.util.Iterator)9 Period (org.hisp.dhis.period.Period)8 Map (java.util.Map)6 State (org.hibernate.test.cache.infinispan.functional.entities.State)5 OnmsCriteria (org.opennms.netmgt.model.OnmsCriteria)5 HibernateCallback (org.springframework.orm.hibernate3.HibernateCallback)5 HashSet (java.util.HashSet)3 Criterion (org.hibernate.criterion.Criterion)3 Statistics (org.hibernate.stat.Statistics)3 Pager (org.hisp.dhis.common.Pager)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 HashMap (java.util.HashMap)2