List of usage examples for org.hibernate Criteria list
public List list() throws HibernateException;
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Consent> searchConsent(ConsentVO consentVO) throws EntityNotFoundException, ArkSystemException { Criteria criteria = getSession().createCriteria(Consent.class); if (consentVO != null) { criteria.add(Restrictions.eq("study.id", consentVO.getConsent().getStudy().getId())); // must only get consents for subject in context criteria.add(Restrictions.eq("linkSubjectStudy", consentVO.getConsent().getLinkSubjectStudy())); if (consentVO.getConsent().getStudyComp() != null) { criteria.add(Restrictions.eq("studyComp", consentVO.getConsent().getStudyComp())); }//ww w . j av a2 s. c om if (consentVO.getConsent().getStudyComponentStatus() != null) { criteria.add( Restrictions.eq("studyComponentStatus", consentVO.getConsent().getStudyComponentStatus())); } if (consentVO.getConsent().getConsentedBy() != null) { criteria.add(Restrictions.ilike("consentedBy", consentVO.getConsent().getConsentedBy(), MatchMode.ANYWHERE)); } if (consentVO.getConsent().getConsentStatus() != null) { criteria.add(Restrictions.eq("consentStatus", consentVO.getConsent().getConsentStatus())); } if (consentVO.getConsent().getConsentDate() != null) { criteria.add(Restrictions.between("consentDate", consentVO.getConsent().getConsentDate(), consentVO.getConsentDateEnd())); } if (consentVO.getConsent().getConsentType() != null) { criteria.add(Restrictions.eq("consentType", consentVO.getConsent().getConsentType())); } } List<Consent> list = criteria.list(); return list; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<Correspondences> getCorrespondenceList(LinkSubjectStudy lss, Correspondences correspondence) throws ArkSystemException { Criteria criteria = getSession().createCriteria(Correspondences.class, "co"); criteria.createAlias("lss", "lss", JoinType.LEFT_OUTER_JOIN); //criteria.createAlias("study", "st", JoinType.LEFT_OUTER_JOIN); //criteria.createAlias("st.parentStudy", "pstudy", JoinType.LEFT_OUTER_JOIN); if (lss != null) { criteria.add(Restrictions.eq("lss", lss)); }//from ww w.j av a2 s .c o m if (correspondence != null) { // Check context study is match with correspondence study or it's parent study if (correspondence.getLss() != null && correspondence.getLss().getStudy() != null) { criteria.add(Restrictions.disjunction() .add(Restrictions.eq("lss.study", correspondence.getLss().getStudy())));//.add(Restrictions.eq("pstudy", correspondence.getLss().getStudy()))); } if (correspondence.getCorrespondenceDirectionType() != null) { criteria.add(Restrictions.eq("co.correspondenceDirectionType", correspondence.getCorrespondenceDirectionType())); } if (correspondence.getCorrespondenceModeType() != null) { criteria.add( Restrictions.eq("co.correspondenceModeType", correspondence.getCorrespondenceModeType())); } if (correspondence.getCorrespondenceOutcomeType() != null) { criteria.add(Restrictions.eq("co.correspondenceOutcomeType", correspondence.getCorrespondenceOutcomeType())); } if (correspondence.getDate() != null) { criteria.add(Restrictions.eq("co.date", correspondence.getDate())); } if (correspondence.getTime() != null) { criteria.add(Restrictions.eq("co.time", correspondence.getTime())); } if (correspondence.getDetails() != null) { criteria.add(Restrictions.ilike("co.details", correspondence.getDetails(), MatchMode.ANYWHERE)); } if (correspondence.getReason() != null) { criteria.add(Restrictions.ilike("co.reason", correspondence.getDetails(), MatchMode.ANYWHERE)); } if (correspondence.getComments() != null) { criteria.add(Restrictions.ilike("co.comments", correspondence.getComments(), MatchMode.ANYWHERE)); } if (correspondence.getOperator() != null) { criteria.add(Restrictions.eq("co.operator", correspondence.getOperator())); } } List<Correspondences> personCorrespondenceList = criteria.list(); return personCorrespondenceList; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<CorrespondenceDirectionType> getCorrespondenceDirectionTypes() { Example directionTypeExample = Example.create(new CorrespondenceDirectionType()); Criteria criteria = getSession().createCriteria(CorrespondenceDirectionType.class) .add(directionTypeExample);//w w w . jav a2s.co m return criteria.list(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<CorrespondenceModeType> getCorrespondenceModeTypes() { Example modeTypeExample = Example.create(new CorrespondenceModeType()); Criteria criteria = getSession().createCriteria(CorrespondenceModeType.class).add(modeTypeExample); return criteria.list(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<CorrespondenceOutcomeType> getCorrespondenceOutcomeTypes() { Example outcomeTypeExample = Example.create(new CorrespondenceOutcomeType()); Criteria criteria = getSession().createCriteria(CorrespondenceOutcomeType.class).add(outcomeTypeExample); return criteria.list(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<ConsentFile> searchConsentFile(ConsentFile consentFile) throws EntityNotFoundException, ArkSystemException { Criteria criteria = getSession().createCriteria(ConsentFile.class); if (consentFile != null) { if (consentFile.getId() != null) { criteria.add(Restrictions.eq("id", consentFile.getId())); }/*from w ww . j ava2s .c o m*/ if (consentFile.getConsent() != null) { criteria.add(Restrictions.eq("consent", consentFile.getConsent())); } if (consentFile.getFilename() != null) { criteria.add(Restrictions.ilike("filename", consentFile.getFilename(), MatchMode.ANYWHERE)); } } criteria.addOrder(Order.desc("id")); @SuppressWarnings("unchecked") List<ConsentFile> list = criteria.list(); return list; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
private boolean isSubjectUIDUnique(String subjectUID, Long studyId, String action) { boolean isUnique = true; Session session = getSession();//from ww w.ja v a 2 s .c om Criteria criteria = session.createCriteria(LinkSubjectStudy.class); criteria.add(Restrictions.eq("subjectUID", subjectUID)); criteria.add(Restrictions.eq("study.id", studyId)); if (action.equalsIgnoreCase(au.org.theark.core.Constants.ACTION_INSERT)) { if (criteria.list().size() > 0) { isUnique = false; } } else if (action.equalsIgnoreCase(au.org.theark.core.Constants.ACTION_UPDATE)) { if (criteria.list().size() > 1) { isUnique = false; } } return isUnique; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
private ConsentOption getConsentOption(String value) { Criteria criteria = getSession().createCriteria(ConsentOption.class); criteria.add(Restrictions.ilike("name", value)); return (ConsentOption) criteria.list().get(0); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public boolean personHasPreferredMailingAddress(Person person, Long currentAddressId) { boolean hasPreferredMailing = false; Criteria criteria = getSession().createCriteria(Address.class); // YesNo yes = getYesNo("Yes"); criteria.add(Restrictions.eq("person.id", person.getId())); criteria.add(Restrictions.eq("preferredMailingAddress", true)); if (currentAddressId != null) { criteria.add(Restrictions.ne("id", currentAddressId)); }/* w w w. j a v a 2 s. c o m*/ List list = criteria.list(); if (list.size() > 0) { hasPreferredMailing = true; } return hasPreferredMailing; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public PersonLastnameHistory getPreviousSurnameHistory(PersonLastnameHistory personSurnameHistory) { PersonLastnameHistory personLastnameHistoryToReturn = null; Example example = Example.create(personSurnameHistory); Criteria criteria = getSession().createCriteria(PersonLastnameHistory.class).add(example); if (criteria != null && criteria.list() != null && criteria.list().size() > 0) { personLastnameHistoryToReturn = (PersonLastnameHistory) criteria.list().get(0); }//from w ww . java 2 s .c o m return personLastnameHistoryToReturn; }