List of usage examples for org.hibernate.criterion Restrictions isNull
public static Criterion isNull(String propertyName)
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public InvCell getNextAvailableInvCell(InvBox invBox) { Criteria criteria = getSession().createCriteria(InvCell.class); criteria.add(Restrictions.eq("invBox", invBox)); criteria.add(Restrictions.isNull("biospecimen")); criteria.setMaxResults(1);/*www .jav a 2s .co m*/ return (InvCell) criteria.list().get(0); }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public PickedPhenoDataSetCategory getSwapOverPickedPhenoDataSetCategoryForUpButton( PickedPhenoDataSetCategory pickedPhenoDataSetCategory) { Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class); criteria.add(Restrictions.eq("arkFunction", pickedPhenoDataSetCategory.getArkFunction())); criteria.add(Restrictions.eq("study", pickedPhenoDataSetCategory.getStudy())); criteria.add(Restrictions.eq("arkUser", pickedPhenoDataSetCategory.getArkUser())); if (pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory() != null) { criteria.add(Restrictions.eq("parentPickedPhenoDataSetCategory", pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory())); } else {//from w w w . j av a 2s . c o m criteria.add(Restrictions.isNull("parentPickedPhenoDataSetCategory")); } criteria.add(Restrictions.lt("orderNumber", pickedPhenoDataSetCategory.getOrderNumber())); criteria.addOrder(Order.desc("orderNumber")); criteria.setFirstResult(0); criteria.setMaxResults(1); List<PickedPhenoDataSetCategory> pickedPhenoDataSetCategories = (List<PickedPhenoDataSetCategory>) criteria .list(); if (pickedPhenoDataSetCategories.size() > 0) { return pickedPhenoDataSetCategories.get(0); } else { return null; } }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public PickedPhenoDataSetCategory getSwapOverPickedPhenoDataSetCategoryForDownButton( PickedPhenoDataSetCategory pickedPhenoDataSetCategory) { Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class); criteria.add(Restrictions.eq("arkFunction", pickedPhenoDataSetCategory.getArkFunction())); criteria.add(Restrictions.eq("study", pickedPhenoDataSetCategory.getStudy())); criteria.add(Restrictions.eq("arkUser", pickedPhenoDataSetCategory.getArkUser())); if (pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory() != null) { criteria.add(Restrictions.eq("parentPickedPhenoDataSetCategory", pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory())); } else {/*from w w w . j a va 2 s . c o m*/ criteria.add(Restrictions.isNull("parentPickedPhenoDataSetCategory")); } criteria.add(Restrictions.gt("orderNumber", pickedPhenoDataSetCategory.getOrderNumber())); criteria.addOrder(Order.asc("orderNumber")); criteria.setFirstResult(0); criteria.setMaxResults(1); List<PickedPhenoDataSetCategory> pickedPhenoDataSetCategories = (List<PickedPhenoDataSetCategory>) criteria .list(); if (pickedPhenoDataSetCategories.size() > 0) { return pickedPhenoDataSetCategories.get(0); } else { return null; } }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public List<PickedPhenoDataSetCategory> getAllParentPickedPhenoDataSetCategories(Study study, ArkFunction arkFunction, ArkUser arkUser) { Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class); criteria.add(Restrictions.eq("arkFunction", arkFunction)); criteria.add(Restrictions.eq("study", study)); criteria.add(Restrictions.eq("arkUser", arkUser)); criteria.add(Restrictions.isNull("parentPickedPhenoDataSetCategory")); criteria.addOrder(Order.asc("orderNumber")); return (List<PickedPhenoDataSetCategory>) criteria.list(); }
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 .c o m // 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 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)); }// w w w .ja va 2s . c om 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(/*from w ww . j a v a 2s.com*/ 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)); } 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; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<ConsentDetailsDataRow> getStudyLevelConsentOtherIDDetailsDataRowList(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(//w w w. j a v a2 s . c o m 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)); } 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()); //removing duplicate entries from resultList List<ConsentDetailsDataRow> uniqueResults = new ArrayList(); Iterator<ConsentDetailsDataRow> iterator = resultList.iterator(); while (iterator.hasNext()) { ConsentDetailsDataRow o = iterator.next(); if (!uniqueResults.contains(o)) uniqueResults.add(o); } resultList.clear(); resultList.addAll(uniqueResults); for (int j = 0; j < resultList.size(); j++) { ConsentDetailsDataRow c = resultList.get(j); if (c.getOtherID() == null && c.getOtherIDSource() == null) { List<OtherID> otherIDs = null; try { otherIDs = iArkCommonService.getOtherIDs(iArkCommonService .getSubjectByUID(c.getSubjectUID(), cdrVO.getLinkSubjectStudy().getStudy()) .getPerson()); if (otherIDs.size() >= 1) { c.setOtherID(otherIDs.get(0).getOtherID()); c.setOtherIDSource(otherIDs.get(0).getOtherID_Source()); } if (otherIDs.size() > 1) { for (int i = 1; i < otherIDs.size(); i++) { OtherID o = otherIDs.get(i); ConsentDetailsDataRow clone = new ConsentDetailsDataRow(c.getSubjectUID(), o.getOtherID_Source(), o.getOtherID(), null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); resultList.add(clone); } } } catch (EntityNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return resultList; }
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 w w w .j a v a 2 s.com*/ 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
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 v a 2 s. c o m*/ 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; }