Search in sources :

Example 71 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernateGenericStore method getByAttribute.

@Override
@SuppressWarnings("unchecked")
public T getByAttribute(Attribute attribute) {
    Schema schema = schemaService.getDynamicSchema(getClazz());
    if (schema == null || !schema.havePersistedProperty("attributeValues")) {
        return null;
    }
    Criteria criteria = getCriteria();
    criteria.createAlias("attributeValues", "av");
    criteria.add(Restrictions.eq("av.attribute", attribute));
    return (T) criteria.uniqueResult();
}
Also used : Schema(org.hisp.dhis.schema.Schema) Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Example 72 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernateDataElementStore method getDataElementsByZeroIsSignificant.

@Override
@SuppressWarnings("unchecked")
public List<DataElement> getDataElementsByZeroIsSignificant(boolean zeroIsSignificant) {
    Criteria criteria = getCriteria();
    criteria.add(Restrictions.eq("zeroIsSignificant", zeroIsSignificant));
    criteria.add(Restrictions.in("valueType", ValueType.NUMERIC_TYPES));
    return criteria.list();
}
Also used : Criteria(org.hibernate.Criteria)

Example 73 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernateDataEntryFormStore method getDataEntryFormByName.

// -------------------------------------------------------------------------
// DataEntryFormStore implementation
// -------------------------------------------------------------------------
@Override
public DataEntryForm getDataEntryFormByName(String name) {
    Criteria criteria = getSession().createCriteria(DataEntryForm.class);
    criteria.add(Restrictions.eq("name", name));
    return (DataEntryForm) criteria.uniqueResult();
}
Also used : DataEntryForm(org.hisp.dhis.dataentryform.DataEntryForm) Criteria(org.hibernate.Criteria)

Example 74 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernateCompleteDataSetRegistrationStore method getCompleteDataSetRegistrations.

@Override
@SuppressWarnings("unchecked")
public List<CompleteDataSetRegistration> getCompleteDataSetRegistrations(DataSet dataSet, Collection<OrganisationUnit> sources, Period period, Date deadline) {
    Period storedPeriod = periodStore.reloadPeriod(period);
    if (storedPeriod == null) {
        return null;
    }
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(CompleteDataSetRegistration.class);
    criteria.add(Restrictions.eq("dataSet", dataSet));
    criteria.add(Restrictions.in("source", sources));
    criteria.add(Restrictions.eq("period", period));
    criteria.add(Restrictions.le("date", deadline));
    return criteria.list();
}
Also used : Period(org.hisp.dhis.period.Period) Criteria(org.hibernate.Criteria)

Example 75 with Criteria

use of org.hibernate.Criteria in project dhis2-core by dhis2.

the class HibernateCompleteDataSetRegistrationStore method getCompleteDataSetRegistrations.

@Override
@SuppressWarnings("unchecked")
public List<CompleteDataSetRegistration> getCompleteDataSetRegistrations(DataSet dataSet, Collection<OrganisationUnit> sources, Period period) {
    Period storedPeriod = periodStore.reloadPeriod(period);
    if (storedPeriod == null) {
        return null;
    }
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(CompleteDataSetRegistration.class);
    criteria.add(Restrictions.eq("dataSet", dataSet));
    criteria.add(Restrictions.eq("period", storedPeriod));
    criteria.add(Restrictions.in("source", sources));
    return criteria.list();
}
Also used : Period(org.hisp.dhis.period.Period) 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