List of usage examples for org.hibernate.criterion Restrictions in
public static Criterion in(String propertyName, Collection values)
From source file:au.org.theark.lims.model.dao.BioCollectionDao.java
License:Open Source License
/** * This count can be based on CustomFieldDisplay alone (i.e. does not need left join to BioCollectionCustomFieldData) *//*from w w w.j a va 2 s . c o m*/ public long getBioCollectionCustomFieldDataCount(BioCollection bioCollectionCriteria, ArkFunction arkFunction) { Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class); criteria.createAlias("customField", "cfield"); // criteria.add(Restrictions.eq("cfield.study", bioCollectionCriteria.getStudy())); // Added to allow child studies to inherit parent defined custom fields List studyList = new ArrayList(); studyList.add(bioCollectionCriteria.getStudy()); if (bioCollectionCriteria.getStudy().getParentStudy() != null && bioCollectionCriteria.getStudy().getParentStudy() != bioCollectionCriteria.getStudy()) { studyList.add(bioCollectionCriteria.getStudy().getParentStudy()); } criteria.add(Restrictions.in("cfield.study", studyList)); criteria.add(Restrictions.eq("cfield.arkFunction", arkFunction)); criteria.setProjection(Projections.rowCount()); return (Long) criteria.uniqueResult(); }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
protected Criteria buildBiospecimenCriteria(LimsVO limsVo) { Criteria criteria = getSession().createCriteria(Biospecimen.class); Biospecimen biospecimen = limsVo.getBiospecimen(); criteria.createAlias("bioCollection", "bc"); criteria.createAlias("linkSubjectStudy", "lss"); // If study chosen, restrict otherwise restrict on users' studyList if (limsVo.getStudy() != null && limsVo.getStudy().getId() != null) { //if(limsVo.getStudy().isParentStudy()) { if (limsVo.getStudy().getParentStudy() != null && limsVo.getStudy().getParentStudy().getId() != null && limsVo.getStudy().getParentStudy().getId().equals(limsVo.getStudy().getId())) { // If parent study, show all children as well criteria.add(Restrictions.in("study", iStudyDao.getChildStudiesForStudy(limsVo.getStudy()))); } else {//from w ww. ja v a2 s .c o m criteria.add(Restrictions.eq("study", limsVo.getStudy())); } } else { criteria.add(Restrictions.in("study", limsVo.getStudyList())); criteria.createAlias("study", "st"); criteria.addOrder(Order.asc("st.name")); criteria.addOrder(Order.asc("lss.subjectUID")); criteria.addOrder(Order.asc("bc.biocollectionUid")); criteria.addOrder(Order.asc("biospecimenUid")); } // Restrict on linkSubjectStudy in the LimsVO (or biospecimen) if (limsVo.getLinkSubjectStudy() != null && limsVo.getLinkSubjectStudy().getId() != null) { criteria.add(Restrictions.eq("linkSubjectStudy", limsVo.getLinkSubjectStudy())); } else if (biospecimen.getLinkSubjectStudy() != null) { criteria.add(Restrictions.eq("linkSubjectStudy", biospecimen.getLinkSubjectStudy())); } if (limsVo.getLinkSubjectStudy() != null) { if (limsVo.getLinkSubjectStudy().getSubjectUID() != null) { criteria.add(Restrictions.ilike("lss.subjectUID", limsVo.getLinkSubjectStudy().getSubjectUID(), MatchMode.ANYWHERE)); } } if (limsVo.getBioCollection() != null && limsVo.getBioCollection().getBiocollectionUid() != null) { criteria.add(Restrictions.ilike("bc.biocollectionUid", limsVo.getBioCollection().getBiocollectionUid(), MatchMode.ANYWHERE)); } if (biospecimen.getId() != null) { criteria.add(Restrictions.eq("id", biospecimen.getId())); } if (biospecimen.getBiospecimenUid() != null) { criteria.add(Restrictions.ilike("biospecimenUid", biospecimen.getBiospecimenUid(), MatchMode.ANYWHERE)); } if (biospecimen.getSampleType() != null) { criteria.add(Restrictions.eq("sampleType", biospecimen.getSampleType())); } if (biospecimen.getSampleDate() != null) { criteria.add(Restrictions.eq("sampleDate", biospecimen.getSampleDate())); } if (biospecimen.getQtyCollected() != null) { criteria.add(Restrictions.eq("qtyCollected", biospecimen.getQtyCollected())); } return criteria; }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public long getBiospecimenCustomFieldDataCount(Biospecimen biospecimenCriteria, ArkFunction arkFunction) { Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class); criteria.createAlias("customField", "cfield"); // Allow child studies to inherit parent defined custom fields List studyList = new ArrayList(); studyList.add(biospecimenCriteria.getStudy()); if (biospecimenCriteria.getStudy().getParentStudy() != null && biospecimenCriteria.getStudy().getParentStudy() != biospecimenCriteria.getStudy()) { studyList.add(biospecimenCriteria.getStudy().getParentStudy()); }/*from w w w . j a va 2 s . co m*/ criteria.add(Restrictions.in("cfield.study", studyList)); criteria.add(Restrictions.eq("cfield.arkFunction", arkFunction)); criteria.setProjection(Projections.rowCount()); return (Long) criteria.uniqueResult(); }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public List<InvSite> searchInvSite(InvSite invSite, List<Study> studyList) throws ArkSystemException { List<InvSite> invSiteList = new ArrayList<InvSite>(0); if (studyList == null || studyList.isEmpty()) { return invSiteList; }/*from w w w . j a v a 2 s. c o m*/ Criteria criteria = getSession().createCriteria(StudyInvSite.class); /* * if (invSite.getId() != null) { criteria.add(Restrictions.eq("id", invSite.getId())); } * * if (invSite.getName() != null) { criteria.add(Restrictions.eq("name", invSite.getName())); } * * if (invSite.getContact() != null) { criteria.add(Restrictions.eq("contact", invSite.getContact())); } * * if (invSite.getAddress() != null) { criteria.add(Restrictions.eq("address", invSite.getAddress())); } * * if (invSite.getPhone() != null) { criteria.add(Restrictions.eq("phone", invSite.getPhone())); } */ /*if you have an empty grouping, hibernate will do this sort of this; * select this_.INV_SITE_ID as y0_ from lims.study_inv_site this_ where this_.STUDY_ID in ( ) group by this_.INV_SITE_ID ...therefore always null check before checking if something is in a group of nothing */ criteria.add(Restrictions.in("study", studyList)); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("invSite"), "invSite"); criteria.setProjection(projectionList); // List<StudyInvSite> list = criteria.list(); invSiteList = criteria.list(); /* * for(StudyInvSite studyInvSite : list){ invSiteList.add(studyInvSite.getInvSite()); } */ return invSiteList; }
From source file:au.org.theark.lims.model.dao.LimsSubjectDao.java
License:Open Source License
private Criteria buildGeneralSubjectCriteria(LimsVO limsVo, List<Study> studyList) { Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class); criteria.createAlias("person", "p"); criteria.add(Restrictions.in("study", studyList)); if (limsVo.getLinkSubjectStudy().getPerson() != null) { if (limsVo.getLinkSubjectStudy().getPerson().getId() != null) { criteria.add(Restrictions.eq("p.id", limsVo.getLinkSubjectStudy().getPerson().getId())); }//from ww w . j a v a 2s. c o m if (limsVo.getLinkSubjectStudy().getPerson().getFirstName() != null) { criteria.add(Restrictions.ilike("p.firstName", limsVo.getLinkSubjectStudy().getPerson().getFirstName(), MatchMode.ANYWHERE)); } if (limsVo.getLinkSubjectStudy().getPerson().getMiddleName() != null) { criteria.add(Restrictions.ilike("p.middleName", limsVo.getLinkSubjectStudy().getPerson().getMiddleName(), MatchMode.ANYWHERE)); } if (limsVo.getLinkSubjectStudy().getPerson().getLastName() != null) { criteria.add(Restrictions.ilike("p.lastName", limsVo.getLinkSubjectStudy().getPerson().getLastName(), MatchMode.ANYWHERE)); } if (limsVo.getLinkSubjectStudy().getPerson().getDateOfBirth() != null) { criteria.add(Restrictions.eq("p.dateOfBirth", limsVo.getLinkSubjectStudy().getPerson().getDateOfBirth())); } if (limsVo.getLinkSubjectStudy().getPerson().getGenderType() != null) { criteria.add(Restrictions.eq("p.genderType.id", limsVo.getLinkSubjectStudy().getPerson().getGenderType().getId())); } if (limsVo.getLinkSubjectStudy().getPerson().getVitalStatus() != null) { criteria.add(Restrictions.eq("p.vitalStatus.id", limsVo.getLinkSubjectStudy().getPerson().getVitalStatus().getId())); } } if (limsVo.getLinkSubjectStudy().getSubjectUID() != null && limsVo.getLinkSubjectStudy().getSubjectUID().length() > 0) { criteria.add(Restrictions.ilike("subjectUID", limsVo.getLinkSubjectStudy().getSubjectUID(), MatchMode.ANYWHERE)); } if (limsVo.getLinkSubjectStudy().getSubjectStatus() != null) { criteria.add(Restrictions.eq("subjectStatus", limsVo.getLinkSubjectStudy().getSubjectStatus())); SubjectStatus subjectStatus = getSubjectStatus("Archive"); if (subjectStatus != null) { criteria.add(Restrictions.ne("subjectStatus", subjectStatus)); } } else { SubjectStatus subjectStatus = getSubjectStatus("Archive"); if (subjectStatus != null) { criteria.add(Restrictions.ne("subjectStatus", subjectStatus)); } } criteria.addOrder(Order.asc("subjectUID")); return criteria; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public List<PhenoDataSetCategory> getAvailablePhenoCategoryListNotPicked(Study study, ArkFunction arkFunctionPhenoCat, ArkFunction arkFunctionPhenoCollection, ArkUser arkUser) throws ArkSystemException { List<PickedPhenoDataSetCategory> pickedPhenoSetCatLst = getPickedPhenoDataSetCategories(study, arkFunctionPhenoCollection, arkUser); List<Long> pickedPhenoDataIdLst = new ArrayList<Long>(); for (PickedPhenoDataSetCategory pickedPhenoDataSetCategory : pickedPhenoSetCatLst) { pickedPhenoDataIdLst.add(pickedPhenoDataSetCategory.getPhenoDataSetCategory().getId()); }//from w w w . ja v a 2 s .c o m Criteria criteria = getSession().createCriteria(PhenoDataSetCategory.class); criteria.add(Restrictions.eq("arkFunction", arkFunctionPhenoCat)); criteria.add(Restrictions.eq("study", study)); if (!pickedPhenoDataIdLst.isEmpty()) { criteria.add(Restrictions.not(Restrictions.in("id", pickedPhenoDataIdLst))); } return criteria.list(); }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
/** * Shows all the available pheno fields which not linked with categories. *//*from w w w .j a v a 2s .co m*/ @Override public List<PhenoDataSetField> getAvailablePhenoFieldListNotInLinked(Study study, ArkFunction arkFunctionPhenoField, ArkFunction arkFunctionPhenoCollection, ArkUser arkUser) throws ArkSystemException { List<LinkPhenoDataSetCategoryField> linkPhenoDataSetCategoryFields = getLinkPhenoDataSetCategoryFieldLst( study, arkFunctionPhenoCollection, arkUser); List<Long> linkedPhenoDataIdLst = new ArrayList<Long>(); for (LinkPhenoDataSetCategoryField linkPhenoDataSetCategoryField : linkPhenoDataSetCategoryFields) { linkedPhenoDataIdLst.add(linkPhenoDataSetCategoryField.getPhenoDataSetField().getId()); } Criteria criteria = getSession().createCriteria(PhenoDataSetField.class); criteria.add(Restrictions.eq("arkFunction", arkFunctionPhenoField)); criteria.add(Restrictions.eq("study", study)); if (!linkedPhenoDataIdLst.isEmpty()) { criteria.add(Restrictions.not(Restrictions.in("id", linkedPhenoDataIdLst))); } return criteria.list(); }
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); /*//w ww. ja v a2s.c o 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.study.model.dao.StudyDao.java
License:Open Source License
public List<LinkSubjectTwin> getTwins(final Set<String> subjectUids, final Long studyId) { List<LinkSubjectTwin> twins = new ArrayList<LinkSubjectTwin>(); Criteria criteria = getSession().createCriteria(LinkSubjectTwin.class, "lst"); criteria.createAlias("firstSubject", "lssa", JoinType.INNER_JOIN); criteria.createAlias("lssa.study", "sta", JoinType.INNER_JOIN); criteria.createAlias("secondSubject", "lssb", JoinType.INNER_JOIN); criteria.createAlias("lssb.study", "stb", JoinType.INNER_JOIN); criteria.setFetchMode("firstSubject", FetchMode.JOIN); criteria.setFetchMode("secondSubject", FetchMode.JOIN); criteria.setFetchMode("twinType", FetchMode.JOIN); criteria.add(Restrictions.eq("sta.id", studyId)); criteria.add(Restrictions.eq("stb.id", studyId)); Disjunction or = Restrictions.disjunction(); or.add(Restrictions.in("lssa.subjectUID", subjectUids)); or.add(Restrictions.in("lssb.subjectUID", subjectUids)); criteria.add(or);//from ww w.ja v a2 s.co m twins = criteria.list(); return twins; }
From source file:br.com.arsmachina.dao.hibernate.ReadableDAOImpl.java
License:Apache License
/** * @see br.com.arsmachina.dao.ReadableDAO#findByIds(K[]) *///from w w w. java2s. co m @SuppressWarnings("unchecked") public List<T> findByIds(K... ids) { Criteria criteria = createCriteria(); criteria.add(Restrictions.in(getPrimaryKeyPropertyName(), ids)); return criteria.list(); }