List of usage examples for org.hibernate Criteria add
public Criteria add(Criterion criterion);
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public List<Boolean> getPublishedSatusLst(Study study, ArkFunction arkFunction) { Criteria criteria = getSession().createCriteria(PhenoDataSetGroup.class); criteria.add(Restrictions.eq("study", study)); criteria.add(Restrictions.eq("arkFunction", arkFunction)); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("published"), "published"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(PhenoDataSetGroup.class)); List<PhenoDataSetGroup> phenoDataSetGroups = (List<PhenoDataSetGroup>) criteria.list(); List<Boolean> pubishStatusLst = new ArrayList<Boolean>(); for (PhenoDataSetGroup phenoDataSetGroup : phenoDataSetGroups) { pubishStatusLst.add(phenoDataSetGroup.getPublished()); }/*from w ww .j a v a2 s . co m*/ return pubishStatusLst; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public boolean isPhenoDataSetFieldCategoryBeingUsed(PhenoDataSetCategory phenoDataSetCategory) { Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class); criteria.add(Restrictions.eq("phenoDataSetCategory", phenoDataSetCategory)); return ((List<PhenoDataSetFieldDisplay>) criteria.list()).size() > 0; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public List<PhenoDataSetField> getAllPhenoDataSetFieldsLinkedToPhenoDataSetFieldGroup( PhenoDataSetGroup phenoDataSetGroupCriteria) { Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class); criteria.add(Restrictions.eq("phenoDataSetGroup", phenoDataSetGroupCriteria)); criteria.add(Restrictions.isNotNull("phenoDataSetField")); criteria.addOrder(Order.asc("phenoDataSetCategoryOrderNumber")) .addOrder(Order.asc("phenoDataSetFiledOrderNumber")); List<PhenoDataSetFieldDisplay> phenoDataSetFieldDisplays = (List<PhenoDataSetFieldDisplay>) criteria.list(); List<PhenoDataSetField> phenoDataSetFields = new ArrayList<PhenoDataSetField>(); for (PhenoDataSetFieldDisplay phenoDataSetFieldDisplay : phenoDataSetFieldDisplays) { phenoDataSetFields.add(phenoDataSetFieldDisplay.getPhenoDataSetField()); }/*from ww w. ja v a 2 s. co m*/ return phenoDataSetFields; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public long getTotalSubjectCount(Study study) { Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class); criteria.add(Restrictions.eq("study", study)); criteria.setProjection(Projections.rowCount()); return (Long) criteria.uniqueResult(); }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public Map<String, Long> getSubjectStatusCounts(Study study) { Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class); criteria.add(Restrictions.eq("study", study)); ProjectionList projectionList = Projections.projectionList(); criteria.createAlias("subjectStatus", "subjectStatusAlias"); projectionList.add(Projections.groupProperty("subjectStatusAlias.name")); projectionList.add(Projections.rowCount()); criteria.setProjection(projectionList); List results = criteria.list(); Map<String, Long> statusMap = new HashMap<String, Long>(); for (Object r : results) { Object[] obj = (Object[]) r; String statusName = (String) obj[0]; statusMap.put(statusName, (Long) obj[1]); }//from www . ja v a 2 s .c o m return statusMap; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public Map<String, Long> getStudyConsentCounts(Study study) { Map<String, Long> statusMap = new HashMap<String, Long>(); Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class); criteria.add(Restrictions.eq("study", study)); ProjectionList projectionList = Projections.projectionList(); criteria.createAlias("consentStatus", "consentStatusAlias"); projectionList.add(Projections.groupProperty("consentStatusAlias.name")); projectionList.add(Projections.rowCount()); criteria.setProjection(projectionList); List results = criteria.list(); for (Object r : results) { Object[] obj = (Object[]) r; String statusName = (String) obj[0]; statusMap.put(statusName, (Long) obj[1]); }// w ww .j a v a2s. com // Tack on count of when consentStatus = undefined (NULL) criteria = getSession().createCriteria(LinkSubjectStudy.class); criteria.add(Restrictions.eq("study", study)); criteria.add(Restrictions.isNull("consentStatus")); projectionList = Projections.projectionList(); projectionList.add(Projections.rowCount()); criteria.setProjection(projectionList); Long undefCount = (Long) criteria.uniqueResult(); String statusName = Constants.NOT_CONSENTED; statusMap.put(statusName, undefCount); return statusMap; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public Map<String, Long> getStudyCompConsentCounts(Study study, StudyComp studyComp) { Map<String, Long> statusMap = new HashMap<String, Long>(); Criteria criteria = getSession().createCriteria(Consent.class); criteria.add(Restrictions.eq("study", study)); criteria.add(Restrictions.eq("studyComp", studyComp)); ProjectionList projectionList = Projections.projectionList(); criteria.createAlias("consentStatus", "consentStatusAlias"); projectionList.add(Projections.groupProperty("consentStatusAlias.name")); projectionList.add(Projections.rowCount()); criteria.setProjection(projectionList); List results = criteria.list(); if ((results != null) && (results.size() > 0)) { for (Object r : results) { Object[] obj = (Object[]) r; String statusName = (String) obj[0]; statusMap.put(statusName, (Long) obj[1]); }/*from www. j ava2 s . com*/ } else { statusMap.put("(none found)", new Long(0)); } return statusMap; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<ReportTemplate> getReportsForUser(ArkUser arkUser, Study study) { Criteria criteria = getSession().createCriteria(ReportTemplate.class, "rt"); Collection<ArkModule> modules = iArkCommonService.getArkModulesLinkedWithStudy(study); /*/*from w ww . j a va 2s . co m*/ * TODO : Filter reports based on security criteria For now we will implement security upon the selection of a report * * // The following is not yet designed to work with super admins // criteria.add(Restrictions.eq("arkUser", arkUser)); DetachedCriteria * functionCriteria = DetachedCriteria.forClass(ArkRolePolicyTemplate.class, "arpt"); // Join FieldPhenoCollection and FieldData on ID FK * functionCriteria.add(Property.forName("rt.module").eqProperty("arpt." + "arkModule")); * functionCriteria.add(Property.forName("rt.function").eqProperty("arpt." + "arkFunction")); criteria.createAlias("arpt." + "arkFunction", * "aFn"); ArkFunction reportArkFnType = getArkFunctionByName(RoleConstants.REPORT_FUNCTION_TYPE); * functionCriteria.add(Restrictions.eq("aFn.arkFunctionType", reportArkFnType)); * criteria.add(Subqueries.exists(functionCriteria.setProjection(Projections.property("arpt.id")))); */ if (modules.size() > 0) criteria.add(Restrictions.in("module", modules)); List<ReportTemplate> reportsAvailListing = criteria.list(); return reportsAvailListing; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<LinkSubjectStudy> getStudyLevelConsentDetailsList(ConsentDetailsReportVO cdrVO) { Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class); // Add study in context to criteria first (linkSubjectStudy on the VO should never be null) criteria.add(Restrictions.eq(Constants.LINKSUBJECTSTUDY_STUDY, cdrVO.getLinkSubjectStudy().getStudy())); if (cdrVO.getLinkSubjectStudy().getSubjectUID() != null) { criteria.add(Restrictions.ilike(Constants.LINKSUBJECTSTUDY_SUBJECTUID, cdrVO.getLinkSubjectStudy().getSubjectUID(), MatchMode.ANYWHERE)); }//from w ww. j av a 2s . c o m if (cdrVO.getLinkSubjectStudy().getSubjectStatus() != null) { criteria.add(Restrictions.eq(Constants.LINKSUBJECTSTUDY_SUBJECTSTATUS, cdrVO.getLinkSubjectStudy().getSubjectStatus())); } // we are dealing with study-level consent if (cdrVO.getConsentStatus() != null) { if (cdrVO.getConsentStatus().getName().equals(Constants.NOT_CONSENTED)) { // Special-case: Treat the null FK for consentStatus as "Not Consented" criteria.add(Restrictions.or( Restrictions.eq(Constants.LINKSUBJECTSTUDY_CONSENTSTATUS, cdrVO.getConsentStatus()), Restrictions.isNull(Constants.LINKSUBJECTSTUDY_CONSENTSTATUS))); } else { criteria.add(Restrictions.eq(Constants.LINKSUBJECTSTUDY_CONSENTSTATUS, cdrVO.getConsentStatus())); } } if (cdrVO.getConsentDate() != null) { criteria.add(Restrictions.eq(Constants.LINKSUBJECTSTUDY_CONSENTDATE, cdrVO.getConsentDate())); } criteria.addOrder(Order.asc("consentStatus")); // although MySQL causes NULLs to come first criteria.addOrder(Order.asc("subjectUID")); return (List<LinkSubjectStudy>) criteria.list(); }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<ConsentDetailsDataRow> getStudyLevelConsentDetailsDataRowList(ConsentDetailsReportVO cdrVO) { List<ConsentDetailsDataRow> resultList = new ArrayList<ConsentDetailsDataRow>(0); Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class, "lss"); // Add study in context to criteria first (linkSubjectStudy on the VO should never be null) criteria.add( Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_STUDY, cdrVO.getLinkSubjectStudy().getStudy())); if (cdrVO.getLinkSubjectStudy().getSubjectUID() != null) { criteria.add(Restrictions.ilike("lss." + Constants.LINKSUBJECTSTUDY_SUBJECTUID, cdrVO.getLinkSubjectStudy().getSubjectUID(), MatchMode.ANYWHERE)); }//from ww w .j a v a 2s. c o m if (cdrVO.getLinkSubjectStudy().getSubjectStatus() != null) { criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_SUBJECTSTATUS, cdrVO.getLinkSubjectStudy().getSubjectStatus())); } // we are dealing with study-level consent if (cdrVO.getConsentStatus() != null) { if (cdrVO.getConsentStatus().getName().equals(Constants.NOT_CONSENTED)) { // Special-case: Treat the null FK for consentStatus as "Not Consented" criteria.add(Restrictions.or( Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTSTATUS, cdrVO.getConsentStatus()), Restrictions.isNull(Constants.LINKSUBJECTSTUDY_CONSENTSTATUS))); } else { criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTSTATUS, cdrVO.getConsentStatus())); } } if (cdrVO.getConsentDate() != null) { criteria.add(Restrictions.eq("lss." + Constants.LINKSUBJECTSTUDY_CONSENTDATE, cdrVO.getConsentDate())); } criteria.createAlias("lss.consentStatus", "cs", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("lss.subjectStatus", "ss"); criteria.createAlias("lss.person", "p"); criteria.createAlias("lss.person.genderType", "genderType"); // Restrict any addresses to the preferred mailing address //Criteria addressCriteria = criteria.createAlias("lss.person.addresses", "a", JoinType.LEFT_OUTER_JOIN); // addressCriteria.setMaxResults(1); // addressCriteria.add(Restrictions.or(Restrictions.or(Restrictions.eq("a.preferredMailingAddress", true), Restrictions.isNull("a.preferredMailingAddress"),Restrictions.eq("a.preferredMailingAddress", false)))); criteria.createAlias("lss.person.addresses.country", "c", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("lss.person.addresses.state", "state", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("lss.person.phones", "phone", JoinType.LEFT_OUTER_JOIN); //TODO: Get work phone returned as well //Criteria phoneCriteria = criteria.createAlias("lss.person.phones.phoneType", "phoneType", JoinType.LEFT_OUTER_JOIN);/*.add( Restrictions.or(Restrictions.eq("phoneType.name", "Home"), ( Restrictions.or(Restrictions.or(Restrictions.eq("phoneType.name", "Home"), Restrictions.isNull("phoneType.name"),Restrictions.eq("phoneType.name", "Mobile"))) ) ) ));*/ //phoneCriteria.setMaxResults(1); criteria.createAlias("lss.person.titleType", "title"); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("lss.subjectUID"), "subjectUID"); projectionList.add(Projections.property("cs.name"), "consentStatus"); projectionList.add(Projections.property("ss.name"), "subjectStatus"); projectionList.add(Projections.property("title.name"), "title"); projectionList.add(Projections.property("p.firstName"), "firstName"); projectionList.add(Projections.property("p.lastName"), "lastName"); projectionList.add(Projections.property("a.streetAddress"), "streetAddress"); projectionList.add(Projections.property("a.city"), "suburb"); projectionList.add(Projections.property("a.postCode"), "postcode"); projectionList.add(Projections.property("state.name"), "state"); projectionList.add(Projections.property("c.name"), "country"); projectionList.add(Projections.property("phone.phoneNumber"), "homePhone"); projectionList.add(Projections.property("p.preferredEmail"), "email"); projectionList.add(Projections.property("genderType.name"), "sex"); projectionList.add(Projections.property("lss.consentDate"), "consentDate"); criteria.setProjection(projectionList); // only return fields required for report criteria.addOrder(Order.asc("lss.consentStatus")); // although MySQL causes NULLs to come first criteria.addOrder(Order.asc("lss.subjectUID")); criteria.setResultTransformer(Transformers.aliasToBean(ConsentDetailsDataRow.class)); resultList = (criteria.list()); return resultList; }