List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<UploadType> getUploadTypesForLims() { Criteria criteria = getSession().createCriteria(UploadType.class); criteria.add(Restrictions.eq("arkModule", getArkModuleForLims())); criteria.addOrder(Order.asc("order")); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<Study> getParentAndChildStudies(Long id) { Criteria studyCriteria = getSession().createCriteria(Study.class); Study study = getStudy(id);//from ww w . j a v a2 s. com if (study.getStudyStatus() != null) { studyCriteria.add(Restrictions.eq(Constants.STUDY_STATUS, study.getStudyStatus())); try { StudyStatus status = getStudyStatus("Archive"); studyCriteria.add(Restrictions.ne(Constants.STUDY_STATUS, status)); } catch (StatusNotAvailableException notAvailable) { log.error("Cannot look up and filter on archive status. Reference data could be missing"); } } else { try { StudyStatus status = getStudyStatus("Archive"); studyCriteria.add(Restrictions.ne(Constants.STUDY_STATUS, status)); } catch (StatusNotAvailableException notAvailable) { log.error("Cannot look up and filter on archive status. Reference data could be missing"); } } if (study.getParentStudy() != null && !study.getParentStudy().equals(study)) { studyCriteria.add( Restrictions.or(Restrictions.idEq(id), Restrictions.eq("parentStudy", study.getParentStudy()))); } else { studyCriteria.add(Restrictions.or(Restrictions.idEq(id), Restrictions.eq("parentStudy", study))); } studyCriteria.addOrder(Order.asc("id")); studyCriteria.addOrder(Order.asc(Constants.STUDY_NAME)); return studyCriteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@Override public List<StudyComp> getDifferentStudyComponentsInConsentForSubject(Study study, LinkSubjectStudy linkSubjectStudy) { Criteria criteria = getSession().createCriteria(Consent.class); criteria.add(Restrictions.eq("study", study)); criteria.add(Restrictions.eq("linkSubjectStudy", linkSubjectStudy)); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("studyComp")); criteria.setProjection(projectionList); criteria.addOrder(Order.asc("id")); List<StudyComp> fieldsList = criteria.list(); return fieldsList; }
From source file:au.org.theark.lims.model.dao.BioCollectionDao.java
License:Open Source License
public List<BioSampletype> getSampleTypes() { Criteria criteria = getStatelessSession().createCriteria(BioSampletype.class); criteria.addOrder(Order.asc("orderId")); List<BioSampletype> list = criteria.list(); return list;// www . j a v a 2 s . c o m }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public List<Biospecimen> searchPageableBiospecimens(Biospecimen biospecimenCriteria, int first, int count) { Criteria criteria = buildBiospecimenCriteria(biospecimenCriteria); criteria.setFirstResult(first);//from w w w .j a v a 2 s .co m criteria.setMaxResults(count); criteria.addOrder(Order.asc("id")); List<Biospecimen> list = criteria.list(); return list; }
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 www . ja va 2 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 List<Unit> getUnits() { Criteria criteria = getSession().createCriteria(Unit.class); criteria.addOrder(Order.asc("order")); List<Unit> list = criteria.list(); return list;/* w w w . j a v a2s.c o m*/ }
From source file:au.org.theark.lims.model.dao.BioTransactionDao.java
License:Open Source License
public List<BioTransaction> searchPageableBioTransactions(BioTransaction bioTransaction, int first, int count) { // Handle for biospecimen not in context if (bioTransaction.getBiospecimen() == null) { return new ArrayList<BioTransaction>(0); }//from www . j a v a2 s . com Criteria criteria = buildBioTransactionCriteria(bioTransaction); // sort by most recent first criteria.addOrder(Order.desc("transactionDate")); criteria.addOrder(Order.desc("id")); // support pageable results list criteria.setFirstResult(first); criteria.setMaxResults(count); List<BioTransaction> list = criteria.list(); return list; }
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 w w w . j a v a 2 s .co 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.lims.model.dao.LimsSubjectDao.java
License:Open Source License
public String getPreviousLastname(Person person) { Criteria criteria = getSession().createCriteria(PersonLastnameHistory.class); if (person.getId() != null) { criteria.add(Restrictions.eq(Constants.PERSON_SURNAME_HISTORY_PERSON, person)); }//from w w w. j av a 2 s. co m criteria.addOrder(Order.desc("id")); PersonLastnameHistory personLastameHistory = null; List<PersonLastnameHistory> results = criteria.list(); if (!results.isEmpty()) { personLastameHistory = (PersonLastnameHistory) results.get(1); } return personLastameHistory.getLastName(); }