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.StudyDao.java

License:Open Source License

public void createSearchSubjects(Search search, List<SearchSubject> searchSubjects) {
    Criteria criteria = getSession().createCriteria(SearchSubject.class);
    criteria.add(Restrictions.eq("search", search));
    List<SearchSubject> searchResults = criteria.list();
    for (SearchSubject searchSubject : searchResults) {
        deleteSearchSubject(searchSubject);
    }//from w  w  w .  java 2s  .  c om

    for (Iterator iterator = searchSubjects.iterator(); iterator.hasNext();) {
        SearchSubject searchSubject = (SearchSubject) iterator.next();
        getSession().save(searchSubject);
    }
}

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

License:Open Source License

public GenderType getSubjectGenderType(final String subjectUID, final Long studyId) {
    GenderType genderType = null;//from   w w w. ja  v  a2  s.  c  o m
    Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class, "lss");
    criteria.createAlias("study", "st", JoinType.INNER_JOIN);
    criteria.createAlias("person", "per", JoinType.INNER_JOIN);
    criteria.createAlias("per.genderType", "gen", JoinType.INNER_JOIN);

    criteria.setFetchMode("person", FetchMode.JOIN);

    criteria.add(Restrictions.eq("st.id", studyId));
    criteria.add(Restrictions.eq("lss.subjectUID", subjectUID));

    List list = criteria.list();
    if (list.size() > 0) {
        LinkSubjectStudy subject = (LinkSubjectStudy) list.get(0);
        genderType = subject.getPerson().getGenderType();
    }
    return genderType;
}

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

License:Open Source License

public List<OtherID> getOtherIDs(Person person) {
    if (person != null) {
        Criteria c = getSession().createCriteria(OtherID.class);
        c.setMaxResults(100);/*  w w  w  .  ja  v a  2s. c o m*/
        c.add(Restrictions.eq("person", person));
        List<OtherID> results = c.list();
        return results;
    } else {
        return new ArrayList<OtherID>();
    }

}

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

License:Open Source License

public Collection<PersonLastnameHistory> getPersonLastnameHistory(Person person) {
    Criteria c = getSession().createCriteria(PersonLastnameHistory.class);
    c.setMaxResults(100);/*ww  w.j  a  va 2s  .c om*/
    c.add(Restrictions.eq("person", person));
    Collection<PersonLastnameHistory> results = c.list();
    return results;
}

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

License:Open Source License

public List<ConfigField> getAllConfigFields() {
    Criteria criteria = getSession().createCriteria(ConfigField.class);
    final List<ConfigField> configFields = criteria.list();
    return configFields;
}

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

License:Open Source License

public List<UserConfig> getUserConfigs(ArkUser arkUser) {
    List<UserConfig> userConfigs = new ArrayList<UserConfig>();
    Criteria criteria = getSession().createCriteria(UserConfig.class);
    log.info("arkuser: " + arkUser);
    log.info("arkuser.id: " + arkUser.getId());
    if (arkUser != null && arkUser.getId() != null) {
        criteria.add(Restrictions.eq("arkUser", arkUser));
        userConfigs = criteria.list();
        log.info("userconfs.size: " + userConfigs.size());
    }/* w w w .  jav  a2 s .  c o  m*/
    return userConfigs;
}

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

License:Open Source License

@Override
public List<Study> getChildStudiesForStudy(Study parentStudy) {
    Criteria criteria = getSession().createCriteria(Study.class);
    criteria.add(Restrictions.eq("parentStudy", parentStudy));
    List<Study> childStudies = criteria.list();
    return childStudies;
}

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

License:Open Source License

@Override
public List<String> getAllFamilyUIDs(Study study) {
    Criteria criteria = getSession().createCriteria(FamilyCustomFieldData.class);
    Set<String> familyUIDSet = new HashSet<String>();
    criteria.add(Restrictions.eq("study", study));
    List<FamilyCustomFieldData> familyCustomFieldDatalst = criteria.list();
    for (FamilyCustomFieldData familyCustomFieldData : familyCustomFieldDatalst) {
        familyUIDSet.add(familyCustomFieldData.getFamilyUid());
    }//from  w w  w .jav  a  2s . c o m
    List<String> familyUIDLst = new ArrayList<String>(familyUIDSet);
    return familyUIDLst;
}

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

License:Open Source License

@Override
public List<Search> getSearchesForSearch(Search search) {
    Criteria criteria = getSession().createCriteria(Search.class);
    criteria.add(Restrictions.eq("study", search.getStudy()));
    if (search.getId() != null) {
        criteria.add(Restrictions.eq("id", search.getId()));
    }/*from  w w  w.  j a v a  2 s .c o  m*/
    if (search.getName() != null) {
        criteria.add(Restrictions.like("name", search.getName(), MatchMode.ANYWHERE));
    }
    List<Search> searchList = criteria.list();
    return searchList;
}

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

License:Open Source License

@Override
public List<StudyComp> getStudyComponentsNeverUsedInThisSubject(Study study,
        LinkSubjectStudy linkSubjectStudy) {
    List<StudyComp> consentStudyCompLst = getDifferentStudyComponentsInConsentForSubject(study,
            linkSubjectStudy);//  w  ww .j av  a 2  s.  c o  m
    List<Long> consentStudyCompIdLst = new ArrayList<Long>();
    for (StudyComp studyComp : consentStudyCompLst) {
        consentStudyCompIdLst.add(studyComp.getId());
    }
    Criteria criteria = getSession().createCriteria(StudyComp.class);
    criteria.add(Restrictions.eq("study", study));
    if (!consentStudyCompIdLst.isEmpty()) {
        criteria.add(Restrictions.not(Restrictions.in("id", consentStudyCompIdLst)));
    }
    return criteria.list();
}