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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations