List of usage examples for org.hibernate.criterion Restrictions eq
public static SimpleExpression eq(String propertyName, Object value)
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<Consent> searchConsent(Consent consent) throws EntityNotFoundException, ArkSystemException { Criteria criteria = getSession().createCriteria(Consent.class); if (consent != null) { criteria.add(Restrictions.eq("study.id", consent.getStudy().getId())); if (consent.getStudyComp() != null) { criteria.add(Restrictions.eq("studyComp", consent.getStudyComp())); }//from w w w.j ava 2s . c om if (consent.getStudyComponentStatus() != null) { criteria.add(Restrictions.eq("studyComponentStatus", consent.getStudyComponentStatus())); } if (consent.getConsentedBy() != null) { criteria.add(Restrictions.ilike("consentedBy", consent.getConsentedBy(), MatchMode.ANYWHERE)); } if (consent.getConsentStatus() != null) { criteria.add(Restrictions.eq("consentStatus", consent.getConsentStatus())); } if (consent.getConsentDate() != null) { criteria.add(Restrictions.eq("consentDate", consent.getConsentDate())); } if (consent.getConsentType() != null) { criteria.add(Restrictions.eq("consentType", consent.getConsentType())); } } return criteria.list(); }
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())); }//from w w w . java 2 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 w w w . j ava 2s . co 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<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 w w . ja va 2 s .co 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 . j a v a 2s .c o m 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
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 ww .j av a2 s. co 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 String getPreviousLastname(Person person) { PersonLastnameHistory personLastameHistory = new PersonLastnameHistory(); // Only get previous lastname if person in context if (person.getId() != null && person.getLastName() != null) { Criteria criteria = getSession().createCriteria(PersonLastnameHistory.class); criteria.add(Restrictions.eq(au.org.theark.core.Constants.PERSON_SURNAME_HISTORY_PERSON, person)); criteria.addOrder(Order.desc("id")); List pastNamesList = criteria.list(); if (!pastNamesList.isEmpty()) { if (pastNamesList.size() > 0) personLastameHistory = (PersonLastnameHistory) pastNamesList.get((pastNamesList.size() - 1)); }/*from w ww.ja va 2 s . c o m*/ } return personLastameHistory.getLastName(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<PersonLastnameHistory> getLastnameHistory(Person person) { Criteria criteria = getSession().createCriteria(PersonLastnameHistory.class); if (person.getId() != null) { criteria.add(Restrictions.eq(au.org.theark.core.Constants.PERSON_SURNAME_HISTORY_PERSON, person)); }//w w w.jav a2 s . co m return criteria.list(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<SubjectFile> searchSubjectFile(SubjectFile subjectFile) throws EntityNotFoundException, ArkSystemException { Criteria criteria = getSession().createCriteria(SubjectFile.class); if (subjectFile != null) { if (subjectFile.getId() != null) { criteria.add(Restrictions.eq("id", subjectFile.getId())); }/* w ww .j a v a2 s . c o m*/ if (subjectFile.getLinkSubjectStudy() != null) { criteria.add(Restrictions.eq("linkSubjectStudy", subjectFile.getLinkSubjectStudy())); } if (subjectFile.getStudyComp() != null) { criteria.add(Restrictions.eq("studyComp", subjectFile.getStudyComp())); } if (subjectFile.getFilename() != null) { criteria.add(Restrictions.ilike("filename", subjectFile.getFilename(), MatchMode.ANYWHERE)); } } criteria.addOrder(Order.desc("id")); @SuppressWarnings("unchecked") List<SubjectFile> list = criteria.list(); return list; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public LinkSubjectStudy getSubjectLinkedToStudy(Long personId, Study study) throws EntityNotFoundException, ArkSystemException { Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class); Person person = getPerson(personId); criteria.add(Restrictions.eq("person", person)); criteria.add(Restrictions.eq("study", study)); criteria.setMaxResults(1);//from ww w. j a v a 2 s . c o m return (LinkSubjectStudy) criteria.uniqueResult(); }