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
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 . jav a2 s.co 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)); }//from ww w . java2s . c o 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 w w . ja v a 2 s. co 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
/** * Determines if study component with a given name is already present for a Study. * //from w w w . java 2s .c o m * @param studyComponentName * @param study * @return */ public boolean isStudyComponentPresent(String studyComponentName, Study study) { boolean isPresent = false; Criteria criteria = getSession().createCriteria(StudyComp.class); criteria.add(Restrictions.eq("name", studyComponentName)); criteria.add(Restrictions.eq("study", study)); if (criteria.list() != null && criteria.list().size() > 0) { isPresent = true; } return isPresent; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<Study> getChildStudyListOfParent(Study study) { Criteria criteria = getStatelessSession().createCriteria(Study.class); criteria.add(Restrictions.ne("id", study.getId())); criteria.add(Restrictions.eq("parentStudy", study)); try {/* w w w. jav a 2s .co m*/ criteria.add(Restrictions.ne("studyStatus", getStudyStatus("Archive"))); } catch (StatusNotAvailableException e) { // TODO Auto-generated catch block e.printStackTrace(); } criteria.addOrder(Order.asc("name")); List<Study> childStudyList = (List<Study>) criteria.list(); return childStudyList; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<ConsentOption> getConsentOptions() { Criteria criteria = getSession().createCriteria(ConsentOption.class); return criteria.list(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<ConsentType> getConsentType() { Criteria criteria = getSession().createCriteria(ConsentType.class); return criteria.list(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public RelationshipVo getSubjectRelative(final String subjectUID, final Long studyId) { List<RelationshipVo> relatives = new ArrayList<RelationshipVo>(); Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class, "sub"); criteria.createAlias("sub.study", "substudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.person", "subPerson", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("subPerson.genderType", "subGender", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("subPerson.vitalStatus", "subVitStatus", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("substudy.pedigreeConfiguration", "spc", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("spc.customField", "cf", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("cf.customFieldDisplay", "cfd", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.subjectCustomFieldDataSet", "scfd", JoinType.LEFT_OUTER_JOIN, Restrictions.eqProperty("cfd.id", "scfd.customFieldDisplay.id")); criteria.add(Restrictions.eq("sub.subjectUID", subjectUID)); criteria.add(Restrictions.eq("substudy.id", studyId)); criteria.setFetchMode("subject", FetchMode.JOIN); criteria.setFetchMode("relative", FetchMode.JOIN); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("sub.subjectUID"), "individualId"); projectionList.add(Projections.property("subGender.name"), "gender"); projectionList.add(Projections.property("subPerson.dateOfBirth"), "dob"); projectionList.add(Projections.property("subPerson.dateOfDeath"), "dod"); projectionList.add(Projections.property("subVitStatus.name"), "deceased"); projectionList.add(Projections.property("scfd.textDataValue"), "affectedStatus"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(RelationshipVo.class)); relatives = criteria.list(); return relatives.size() > 0 ? relatives.get(0) : null; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<RelationshipVo> getSubjectParentRelatives(final String subjectUID, final Long studyId) { List<RelationshipVo> relatives = new ArrayList<RelationshipVo>(); Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class, "lsp"); criteria.createAlias("subject", "sub", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.study", "substudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relative", "rel", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("rel.study", "relstudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relationship", "type", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("rel.person", "relPerson", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relPerson.genderType", "relGender", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relPerson.vitalStatus", "relVitStatus", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relstudy.pedigreeConfiguration", "spc", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("spc.customField", "cf", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("cf.customFieldDisplay", "cfd", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("rel.subjectCustomFieldDataSet", "scfd", JoinType.LEFT_OUTER_JOIN, Restrictions.eqProperty("cfd.id", "scfd.customFieldDisplay.id")); criteria.add(Restrictions.eq("sub.subjectUID", subjectUID)); criteria.add(Restrictions.eq("substudy.id", studyId)); criteria.add(Restrictions.eq("relstudy.id", studyId)); criteria.setFetchMode("subject", FetchMode.JOIN); criteria.setFetchMode("relative", FetchMode.JOIN); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("lsp.id"), "id"); projectionList.add(Projections.property("rel.subjectUID"), "individualId"); projectionList.add(Projections.property("relGender.name"), "gender"); projectionList.add(Projections.property("relPerson.dateOfBirth"), "dob"); projectionList.add(Projections.property("relPerson.dateOfDeath"), "dod"); projectionList.add(Projections.property("relPerson.firstName"), "firstName"); projectionList.add(Projections.property("relPerson.lastName"), "lastName"); projectionList.add(Projections.property("relVitStatus.name"), "deceased"); projectionList.add(Projections.property("scfd.textDataValue"), "affectedStatus"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(RelationshipVo.class)); relatives = criteria.list(); return relatives; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<RelationshipVo> getSubjectChildRelatives(final String subjectUID, final Long studyId) { List<RelationshipVo> relatives = new ArrayList<RelationshipVo>(); Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class, "lsp"); criteria.createAlias("subject", "sub", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.study", "substudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relative", "rel", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("rel.study", "relstudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relationship", "type", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.person", "subPerson", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("subPerson.genderType", "subGender", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("subPerson.vitalStatus", "subVitStatus", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("substudy.pedigreeConfiguration", "spc", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("spc.customField", "cf", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("cf.customFieldDisplay", "cfd", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.subjectCustomFieldDataSet", "scfd", JoinType.LEFT_OUTER_JOIN, Restrictions.eqProperty("cfd.id", "scfd.customFieldDisplay.id")); criteria.add(Restrictions.eq("rel.subjectUID", subjectUID)); criteria.add(Restrictions.eq("substudy.id", studyId)); criteria.add(Restrictions.eq("relstudy.id", studyId)); criteria.setFetchMode("subject", FetchMode.JOIN); criteria.setFetchMode("relative", FetchMode.JOIN); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("lsp.id"), "id"); projectionList.add(Projections.property("sub.subjectUID"), "individualId"); projectionList.add(Projections.property("subGender.name"), "gender"); projectionList.add(Projections.property("subPerson.dateOfBirth"), "dob"); projectionList.add(Projections.property("subPerson.dateOfDeath"), "dod"); projectionList.add(Projections.property("subPerson.firstName"), "firstName"); projectionList.add(Projections.property("subPerson.lastName"), "lastName"); projectionList.add(Projections.property("subVitStatus.name"), "deceased"); projectionList.add(Projections.property("scfd.textDataValue"), "affectedStatus"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(RelationshipVo.class)); relatives = criteria.list(); return relatives; }