List of usage examples for org.hibernate Criteria add
public Criteria add(Criterion criterion);
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public long getRelationshipCount(final String subjectUID, final Long studyId) { long count = 0; Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class, "lsp"); criteria.createAlias("subject", "sub", JoinType.INNER_JOIN); criteria.createAlias("relative", "rel", JoinType.INNER_JOIN); criteria.createAlias("sub.study", "substudy", JoinType.INNER_JOIN); criteria.createAlias("rel.study", "relstudy", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("substudy.id", studyId)); criteria.add(Restrictions.eq("relstudy.id", studyId)); Disjunction or = Restrictions.disjunction(); or.add(Restrictions.eq("sub.subjectUID", subjectUID)); or.add(Restrictions.eq("rel.subjectUID", subjectUID)); criteria.add(or);/*from w w w . j av a 2 s.com*/ ProjectionList projList = Projections.projectionList(); projList.add(Projections.count("lsp.id")); criteria.setProjection(projList); List list = criteria.list(); if (list.size() > 0) { count = Integer.parseInt(list.get(0).toString()); } return count; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<CustomField> getBinaryCustomFieldsForPedigreeRelativesList(Long studyId) { List<CustomField> pedigreeCustomFields = null; Criteria criteria = getSession().createCriteria(CustomField.class, "cf"); criteria.createAlias("study", "st", JoinType.INNER_JOIN); criteria.createAlias("arkFunction", "af", JoinType.INNER_JOIN); criteria.createAlias("customFieldType", "cft", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("fieldType", "ft", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("st.id", studyId)); criteria.add(/*from w w w .j a va 2 s.c om*/ Restrictions.eq("af.name", au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD)); criteria.add(Restrictions.eq("cf.encodedValues", "0=Yes;1=No;").ignoreCase()); criteria.add(Restrictions.or(Restrictions.isNull("cft.id"), Restrictions.eq("cft.name", au.org.theark.core.Constants.SUBJECT))); pedigreeCustomFields = criteria.list(); return pedigreeCustomFields; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
@Override public List<CustomField> getFamilyUIdCustomFieldsForPedigreeRelativesList(Long studyId) { List<CustomField> pedigreeCustomFields = null; Criteria criteria = getSession().createCriteria(CustomField.class, "cf"); criteria.createAlias("study", "st", JoinType.INNER_JOIN); criteria.createAlias("arkFunction", "af", JoinType.INNER_JOIN); criteria.createAlias("fieldType", "ft", JoinType.INNER_JOIN); criteria.createAlias("customFieldType", "cft", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.eq("st.id", studyId)); criteria.add(/*w w w . j av a2 s .c om*/ Restrictions.eq("af.name", au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD)); criteria.add(Restrictions.isNull("cf.encodedValues")); criteria.add(Restrictions.eq("ft.name", au.org.theark.core.Constants.FIELD_TYPE_CHARACTER)); criteria.add(Restrictions.or(Restrictions.isNull("cft.id"), Restrictions.eq("cft.name", au.org.theark.core.Constants.SUBJECT))); pedigreeCustomFields = criteria.list(); return pedigreeCustomFields; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public StudyPedigreeConfiguration getStudyPedigreeConfiguration(Long studyId) { StudyPedigreeConfiguration pedigreeConfig = null; Criteria criteria = getSession().createCriteria(StudyPedigreeConfiguration.class, "spc"); criteria.createAlias("study", "st", JoinType.INNER_JOIN); criteria.setFetchMode("customField", FetchMode.JOIN); criteria.add(Restrictions.eq("st.id", studyId)); List<StudyPedigreeConfiguration> list = criteria.list(); pedigreeConfig = list.size() == 1 ? list.get(0) : new StudyPedigreeConfiguration(); return pedigreeConfig; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
/** * Genenal Phone search.// ww w . j a va2 s. co m * @param personId * @param phone * @return */ private Criteria buildGeneralPhoneCriteria(Long personId, Phone phone) { Criteria phoneCriteria = getSession().createCriteria(Phone.class); if (personId != null) { phoneCriteria.add(Restrictions.eq(Constants.PERSON_PERSON_ID, personId)); } if (phone != null) { if (phone.getId() != null) { phoneCriteria.add(Restrictions.eq(Constants.PHONE_ID, phone.getId())); } if (phone.getPhoneNumber() != null) { phoneCriteria.add(Restrictions.ilike(Constants.PHONE_NUMBER, phone.getPhoneNumber())); } if (phone.getPhoneType() != null) { phoneCriteria.add(Restrictions.eq(Constants.PHONE_TYPE, phone.getPhoneType())); } if (phone.getAreaCode() != null) { phoneCriteria.add(Restrictions.eq(Constants.AREA_CODE, phone.getAreaCode())); } phoneCriteria.setFetchMode("silentMode", FetchMode.JOIN); } return phoneCriteria; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
/** * General Address search.// w w w .ja va 2 s .c om * @param personId * @param address * @return */ private Criteria buildGeneralAddressCriteria(Long personId, Address address) { Criteria criteria = getSession().createCriteria(Address.class); if (personId != null) { criteria.add(Restrictions.eq(Constants.PERSON_PERSON_ID, personId)); } if (address != null) { // Add criteria for address if (address.getStreetAddress() != null) { criteria.add(Restrictions.ilike(Constants.STREET_ADDRESS, address.getStreetAddress(), MatchMode.ANYWHERE)); } if (address.getCountry() != null) { criteria.add(Restrictions.eq(Constants.COUNTRY_NAME, address.getCountry())); } if (address.getPostCode() != null) { criteria.add(Restrictions.eq(Constants.POST_CODE, address.getPostCode())); } if (address.getCity() != null) { criteria.add(Restrictions.ilike(Constants.CITY, address.getCity())); } if (address.getState() != null) { criteria.add(Restrictions.eq(Constants.STATE_NAME, address.getState())); } if (address.getAddressType() != null) { criteria.add(Restrictions.eq(Constants.ADDRESS_TYPE, address.getAddressType())); } } return criteria; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
@Override public void saveOrUpdate(StudyCalendarVo studyCalendarVo) { StudyCalendar calendar = studyCalendarVo.getStudyCalendar(); saveOrUpdate(calendar);//from ww w .j ava2 s. c o m Criteria criteria = getSession().createCriteria(LinkCalendarCustomField.class); criteria.add(Restrictions.eq("studyCalendar", calendar)); List<LinkCalendarCustomField> searchResults = criteria.list(); for (LinkCalendarCustomField calendarCustomFields : searchResults) { deleteCalendarCustomField(calendarCustomFields); } for (CustomField customField : studyCalendarVo.getSelectedCustomFields()) { LinkCalendarCustomField linkCalendarCustomField = new LinkCalendarCustomField(); linkCalendarCustomField.setStudyCalendar(calendar); linkCalendarCustomField.setCustomField(customField); saveCalendarCustomField(linkCalendarCustomField); } }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<StudyCalendar> searchStudyCalenderList(StudyCalendar studyCalendar) { List<StudyCalendar> list = new ArrayList<StudyCalendar>(); Criteria criteria = getSession().createCriteria(StudyCalendar.class); criteria.add(Restrictions.eq("study", studyCalendar.getStudy())); if (studyCalendar.getName() != null) { criteria.add(Restrictions.ilike("name", studyCalendar.getName(), MatchMode.ANYWHERE)); }/* w w w. ja v a 2 s . c om*/ if (studyCalendar.getStartDate() != null) { criteria.add(Restrictions.ge("startDate", studyCalendar.getStartDate())); } if (studyCalendar.getEndDate() != null) { criteria.add(Restrictions.le("endDate", studyCalendar.getEndDate())); } criteria.setFetchMode("studyComp", FetchMode.JOIN); list = criteria.list(); return list; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<CustomField> getStudySubjectCustomFieldList(Long studyId) { List<CustomField> list = new ArrayList<CustomField>(); Criteria criteria = getSession().createCriteria(CustomField.class); criteria.createAlias("study", "st", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("customFieldType", "cft", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.eq("st.id", studyId)); criteria.add(Restrictions.eq("cft.name", au.org.theark.core.Constants.SUBJECT)); list = criteria.list();//w w w .ja va 2s . c o m return list; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<CustomField> getSelectedCalendarCustomFieldList(StudyCalendar studyCalendar) { List<CustomField> list = new ArrayList<CustomField>(); Criteria criteria = getSession().createCriteria(CustomField.class); criteria.createAlias("linkCalendarCustomField", "lccf", JoinType.INNER_JOIN); criteria.createAlias("linkCalendarCustomField.studyCalendar", "sc", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("sc.id", studyCalendar.getId())); list = criteria.list();/*from w w w.j av a 2 s.c om*/ return list; }