List of usage examples for org.hibernate Criteria setProjection
public Criteria setProjection(Projection projection);
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
/** * The count can be based on CustomFieldDisplay only instead of a left join with it using SubjectCustomFieldData *///from ww w . ja v a 2s. c om public long getSubjectCustomFieldDataCount(LinkSubjectStudy linkSubjectStudyCriteria, ArkFunction arkFunction) { Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class); criteria.createAlias("customField", "cfield", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("cfield.customFieldType", "cfieldType", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.eq("cfield.study", linkSubjectStudyCriteria.getStudy())); criteria.add(Restrictions.eq("cfield.arkFunction", arkFunction)); criteria.add(Restrictions.or(Restrictions.isNull("cfield.customFieldType"), Restrictions.eq("cfieldType.name", "SUBJECT"))); criteria.setProjection(Projections.rowCount()); return (Long) criteria.uniqueResult(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
/** * The count can be based on CustomFieldDisplay only instead of a left join with it using FamilyCustomFieldData *///ww w. j a v a2 s . c o m public long getFamilyCustomFieldDataCount(LinkSubjectStudy linkSubjectStudyCriteria, ArkFunction arkFunction) { Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class); criteria.createAlias("customField", "cfield", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("cfield.customFieldType", "cfieldType", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.eq("cfield.study", linkSubjectStudyCriteria.getStudy())); criteria.add(Restrictions.eq("cfield.arkFunction", arkFunction)); criteria.add(Restrictions.eq("cfieldType.name", "FAMILY")); criteria.setProjection(Projections.rowCount()); return (Long) criteria.uniqueResult(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public boolean isStudyComponentHasAttachments(StudyComp studyComp) { boolean isFlag = false; Criteria criteria = getStatelessSession().createCriteria(SubjectFile.class); criteria.add(Restrictions.eq("studyComp", studyComp)); criteria.setProjection(Projections.rowCount()); Long i = (Long) criteria.uniqueResult(); if (i > 0L) { isFlag = true;/*w w w . ja v a 2 s. c o m*/ } return isFlag; }
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();/*ww w .j a v a 2 s .com*/ 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();//from w ww . java 2 s .c o m 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();/*from w w w . j a v a 2 s . c om*/ return relatives; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public Integer getSubjectParentCount(final LinkSubjectStudy subject) { Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class); criteria.add(Restrictions.eq("subject", subject)); criteria.setProjection(Projections.rowCount()); return ((Integer) criteria.list().get(0)).intValue(); }
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);// w ww .java 2s . c o m 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.UserDao.java
License:Open Source License
/** * Checks if the Ark User is present in the system. IT does no compare with a particular Study. If a person existed in the system this will return * true. This must be used only during create operation. If you want to add a ArkUser to another study then another method with study must be * passed in.// w w w . j a v a 2 s .com */ public boolean isArkUserPresent(String userName) { boolean isPresent = false; Criteria criteria = getSession().createCriteria(ArkUser.class); if (userName != null) { criteria.add(Restrictions.eq("ldapUserName", userName)); } criteria.setProjection(Projections.rowCount()); Long count = (Long) criteria.uniqueResult(); if (count > 0) { isPresent = true; } return isPresent; }
From source file:bank.DAO.OperationsDAO.java
public Long countOperations() { Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction();// w w w .j a v a 2s. c o m ///////////int result = session.createSQLQuery("select count(*) from Operations").executeUpdate(); Criteria criteria = session.createCriteria(Operations.class); criteria.setProjection(Projections.rowCount()); Long result = (Long) criteria.list().get(0); session.getTransaction().commit(); session.close(); return result; }