List of usage examples for org.hibernate Criteria list
public List list() throws HibernateException;
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<SubjectStatus> getSubjectStatus() { Example example = Example.create(new SubjectStatus()); Criteria criteria = getSession().createCriteria(SubjectStatus.class).add(example); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<MaritalStatus> getMaritalStatus() { Example example = Example.create(new MaritalStatus()); Criteria criteria = getSession().createCriteria(MaritalStatus.class).add(example); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<EmailStatus> getAllEmailStatuses() { Example example = Example.create(new EmailStatus()); Criteria criteria = getSession().createCriteria(EmailStatus.class).add(example); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
/** * Look up the Link Subject Study for subjects linked to a study * // w w w . ja v a2 s . c o m * @param subjectVO * @return */ @SuppressWarnings("unchecked") public Collection<SubjectVO> getSubject(SubjectVO subjectVO) { Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class); criteria.createAlias("person", "p"); criteria.add(Restrictions.eq("study.id", subjectVO.getLinkSubjectStudy().getStudy().getId())); if (subjectVO.getLinkSubjectStudy().getPerson() != null) { if (subjectVO.getLinkSubjectStudy().getPerson().getId() != null) { criteria.add(Restrictions.eq("p.id", subjectVO.getLinkSubjectStudy().getPerson().getId())); } if (subjectVO.getLinkSubjectStudy().getPerson().getFirstName() != null) { criteria.add(Restrictions.ilike("p.firstName", subjectVO.getLinkSubjectStudy().getPerson().getFirstName(), MatchMode.ANYWHERE)); } if (subjectVO.getLinkSubjectStudy().getPerson().getMiddleName() != null) { criteria.add(Restrictions.ilike("p.middleName", subjectVO.getLinkSubjectStudy().getPerson().getMiddleName(), MatchMode.ANYWHERE)); } if (subjectVO.getLinkSubjectStudy().getPerson().getLastName() != null) { criteria.add(Restrictions.ilike("p.lastName", subjectVO.getLinkSubjectStudy().getPerson().getLastName(), MatchMode.ANYWHERE)); } if (subjectVO.getLinkSubjectStudy().getPerson().getDateOfBirth() != null) { criteria.add(Restrictions.eq("p.dateOfBirth", subjectVO.getLinkSubjectStudy().getPerson().getDateOfBirth())); } if (subjectVO.getLinkSubjectStudy().getPerson().getGenderType() != null) { criteria.add(Restrictions.eq("p.genderType.id", subjectVO.getLinkSubjectStudy().getPerson().getGenderType().getId())); } if (subjectVO.getLinkSubjectStudy().getPerson().getVitalStatus() != null) { criteria.add(Restrictions.eq("p.vitalStatus.id", subjectVO.getLinkSubjectStudy().getPerson().getVitalStatus().getId())); } } if (subjectVO.getLinkSubjectStudy().getSubjectUID() != null && subjectVO.getLinkSubjectStudy().getSubjectUID().length() > 0) { criteria.add(Restrictions.eq("subjectUID", subjectVO.getLinkSubjectStudy().getSubjectUID())); } if (subjectVO.getLinkSubjectStudy().getSubjectStatus() != null) { criteria.add(Restrictions.eq("subjectStatus", subjectVO.getLinkSubjectStudy().getSubjectStatus())); SubjectStatus subjectStatus = getSubjectStatus("Archive"); if (subjectStatus != null) { criteria.add(Restrictions.ne("subjectStatus", subjectStatus)); } } else { SubjectStatus subjectStatus = getSubjectStatus("Archive"); if (subjectStatus != null) { criteria.add(Restrictions.ne("subjectStatus", subjectStatus)); } } criteria.addOrder(Order.asc("subjectUID")); List<LinkSubjectStudy> list = criteria.list(); Collection<SubjectVO> subjectVOList = new ArrayList<SubjectVO>(); for (Iterator iterator = list.iterator(); iterator.hasNext();) { LinkSubjectStudy linkSubjectStudy = (LinkSubjectStudy) iterator.next(); // Place the LinkSubjectStudy instance into a SubjectVO and add the // SubjectVO into a List SubjectVO subject = new SubjectVO(); subject.setLinkSubjectStudy(linkSubjectStudy); Person person = subject.getLinkSubjectStudy().getPerson(); subject.setSubjectPreviousLastname(getPreviousLastname(person)); subjectVOList.add(subject); } return subjectVOList; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Phone> getPhonesForPerson(Person person) { Criteria personCriteria = getSession().createCriteria(Phone.class); personCriteria.add(Restrictions.eq("person", person));// Filter the // phones linked // to this//from w w w . j a v a 2 s . c om // personID/Key return personCriteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public LinkSubjectStudy getLinkSubjectStudy(Long id) throws EntityNotFoundException { Criteria linkSubjectStudyCriteria = getSession().createCriteria(LinkSubjectStudy.class); linkSubjectStudyCriteria.add(Restrictions.eq("id", id)); List<LinkSubjectStudy> listOfSubjects = linkSubjectStudyCriteria.list(); if (listOfSubjects != null && listOfSubjects.size() > 0) { return listOfSubjects.get(0); } else {/*from ww w .j av a2s . com*/ throw new EntityNotFoundException("The entity with id" + id.toString() + " cannot be found."); } }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public LinkSubjectStudy getSubjectByUID(String subjectUID, Study study) throws EntityNotFoundException { Criteria linkSubjectStudyCriteria = getSession().createCriteria(LinkSubjectStudy.class); linkSubjectStudyCriteria.add(Restrictions.eq("subjectUID", subjectUID)); linkSubjectStudyCriteria.add(Restrictions.eq("study", study)); List<LinkSubjectStudy> listOfSubjects = linkSubjectStudyCriteria.list(); if (listOfSubjects != null && listOfSubjects.size() > 0) { return listOfSubjects.get(0); } else {/*from ww w. ja v a2s . com*/ throw new EntityNotFoundException("There is no subject with the given UID " + subjectUID.toString()); } }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
/** * Returns a list of Countries// w w w .ja va 2s .c o m */ @SuppressWarnings("unchecked") public List<Country> getCountries() { Criteria criteria = getSession().createCriteria(Country.class); criteria.addOrder(Order.asc("name")); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public Country getCountry(Long id) { Criteria criteria = getSession().createCriteria(Country.class); criteria.add(Restrictions.eq("id", id)); return (Country) criteria.list().get(0); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public Country getCountry(String countryCode) { Criteria criteria = getSession().createCriteria(Country.class); criteria.add(Restrictions.eq("countryCode", countryCode)); return (Country) criteria.list().get(0); }