Example usage for org.hibernate Criteria list

List of usage examples for org.hibernate Criteria list

Introduction

In this page you can find the example usage for org.hibernate Criteria list.

Prototype

public List list() throws HibernateException;

Source Link

Document

Get the results.

Usage

From source file:au.org.theark.core.dao.AuditDao.java

License:Open Source License

@Override
public List<AuditField> getAuditFieldList() {
    Criteria criteria = getSession().createCriteria(AuditField.class);
    return criteria.list();
}

From source file:au.org.theark.core.dao.CSVLoaderDao.java

License:Open Source License

public String getDelimiterTypeByDelimiterChar(char phenotypicDelimChr) {
    String delimiterTypeName = null;
    Criteria criteria = getSession().createCriteria(DelimiterType.class);
    criteria.add(Restrictions.eq("delimiterCharacter", delimiterCharacter));
    List<DelimiterType> results = criteria.list();
    if (results.size() > 0) {
        DelimiterType delimiterType = (DelimiterType) results.get(0);
        delimiterTypeName = delimiterType.getName();
    }/*from w ww  .ja v a2s .c  om*/
    return delimiterTypeName;
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Study> getStudy(Study study) {

    Criteria studyCriteria = getSession().createCriteria(Study.class);

    if (study.getId() != null) {
        studyCriteria.add(Restrictions.eq(Constants.STUDY_KEY, study.getId()));
    }//from   w w  w. ja v a 2s .  c o m

    if (study.getName() != null) {
        studyCriteria.add(Restrictions.ilike(Constants.STUDY_NAME, study.getName(), MatchMode.ANYWHERE));
    }

    if (study.getDateOfApplication() != null) {
        studyCriteria.add(Restrictions.eq(Constants.DATE_OF_APPLICATION, study.getDateOfApplication()));
    }

    if (study.getEstimatedYearOfCompletion() != null) {
        studyCriteria
                .add(Restrictions.eq(Constants.EST_YEAR_OF_COMPLETION, study.getEstimatedYearOfCompletion()));
    }

    if (study.getChiefInvestigator() != null) {
        studyCriteria.add(Restrictions.ilike(Constants.CHIEF_INVESTIGATOR, study.getChiefInvestigator(),
                MatchMode.ANYWHERE));
    }

    if (study.getContactPerson() != null) {
        studyCriteria.add(
                Restrictions.ilike(Constants.CONTACT_PERSON, study.getContactPerson(), MatchMode.ANYWHERE));
    }

    if (study.getStudyStatus() != null) {
        studyCriteria.add(Restrictions.eq(Constants.STUDY_STATUS, study.getStudyStatus()));
        try {
            StudyStatus status = getStudyStatus("Archive");
            studyCriteria.add(Restrictions.ne(Constants.STUDY_STATUS, status));
        } catch (StatusNotAvailableException notAvailable) {
            log.error("Cannot look up and filter on archive status. Reference data could be missing");
        }
    } else {
        try {
            StudyStatus status = getStudyStatus("Archive");
            studyCriteria.add(Restrictions.ne(Constants.STUDY_STATUS, status));
        } catch (StatusNotAvailableException notAvailable) {
            log.error("Cannot look up and filter on archive status. Reference data could be missing");
        }

    }

    studyCriteria.addOrder(Order.asc(Constants.STUDY_NAME));
    List<Study> studyList = studyCriteria.list();

    return studyList;
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public SubjectStatus getSubjectStatus(String statusName) {

    SubjectStatus statusToReturn = null;

    SubjectStatus subjectStatus = new SubjectStatus();
    subjectStatus.setName(statusName);// ww w.j  a va  2  s.c o  m
    Example example = Example.create(subjectStatus);

    Criteria criteria = getSession().createCriteria(SubjectStatus.class).add(example);

    if (criteria != null) {
        List<SubjectStatus> results = criteria.list();
        if (results != null && !results.isEmpty()) {
            statusToReturn = (SubjectStatus) results.get(0);
        }
    }

    return statusToReturn;
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

/**
 * Given a status name will return the StudyStatus object.
 *//* w w  w .jav  a  2  s  . co  m*/
@SuppressWarnings("unchecked")
public StudyStatus getStudyStatus(String statusName) throws StatusNotAvailableException {
    StudyStatus studyStatus = new StudyStatus();
    studyStatus.setName("Archive");
    Example studyStatusExample = Example.create(studyStatus);

    Criteria studyStatusCriteria = getSession().createCriteria(StudyStatus.class).add(studyStatusExample);
    if (studyStatusCriteria != null) {
        List<StudyStatus> results = studyStatusCriteria.list();
        if (results != null && results.size() > 0) {
            return (StudyStatus) results.get(0);
        }
    }

    log.error(
            "Study Status Table maybe out of synch. Please check if it has an entry for Archive status.  Cannot locate a study status with "
                    + statusName + " in the database");
    throw new StatusNotAvailableException();

}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<StudyStatus> getListOfStudyStatus() {
    Example studyStatus = Example.create(new StudyStatus());
    Criteria criteria = getSession().createCriteria(StudyStatus.class).add(studyStatus);
    return criteria.list();

}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public Collection<TitleType> getTitleType() {
    Example example = Example.create(new TitleType());
    Criteria criteria = getSession().createCriteria(TitleType.class).add(example);
    return criteria.list();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public Collection<VitalStatus> getVitalStatus() {
    Example example = Example.create(new VitalStatus());
    Criteria criteria = getSession().createCriteria(VitalStatus.class).add(example);
    return criteria.list();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public Collection<GenderType> getGenderTypes() {
    Example example = Example.create(new GenderType());
    Criteria criteria = getSession().createCriteria(GenderType.class).add(example);
    return criteria.list();
}

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<PhoneType> getListOfPhoneType() {
    Example phoneTypeExample = Example.create(new PhoneType());
    Criteria criteria = getSession().createCriteria(PhoneType.class).add(phoneTypeExample);
    return criteria.list();
}