List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<PhenoDataSetFieldDetailsDataRow> getPhenoDataSetFieldDetailsList( PhenoDataSetFieldDetailsReportVO reportVO) { List<PhenoDataSetFieldDetailsDataRow> results = new ArrayList<PhenoDataSetFieldDetailsDataRow>(); if (reportVO.getPhenoDataSetFieldDisplay() != null) { /*// w w w . j av a 2 s .c om * Following query returns customFields whether or not they are * associated with a customFieldGroups (via customFieldDisplay) */ Criteria criteria = getSession().createCriteria(PhenoDataSetField.class, "pf"); criteria.createAlias("phenoDatasetFieldDisplay", "pdfd", JoinType.LEFT_OUTER_JOIN); // Left join to CustomFieldDisplay criteria.createAlias("pdfd.phenoDatasetFieldGroup", "pdfg", JoinType.LEFT_OUTER_JOIN); // Left join to CustomFieldGroup criteria.createAlias("fieldType", "ft", JoinType.LEFT_OUTER_JOIN); // Left join to FieldType criteria.createAlias("unitType", "ut", JoinType.LEFT_OUTER_JOIN); // Left join to UnitType criteria.add(Restrictions.eq("pf.study", reportVO.getStudy())); ArkFunction function = iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION); criteria.add(Restrictions.eq("pf.arkFunction", function)); if (reportVO.getPhenoDataSetFieldDisplay().getPhenoDataSetGroup() != null) { criteria.add(Restrictions.eq("pdfg.id", reportVO.getPhenoDataSetFieldDisplay().getPhenoDataSetGroup().getId())); } if (reportVO.getFieldDataAvailable()) { DetachedCriteria fieldDataCriteria = DetachedCriteria.forClass(PhenoDataSetData.class, "pd"); // Join CustomFieldDisplay and PhenoData on ID FK fieldDataCriteria .add(Property.forName("pdfd.id").eqProperty("pd." + "phenoDatasetFieldDisplay.id")); criteria.add(Subqueries.exists( fieldDataCriteria.setProjection(Projections.property("pd.phenoDatasetFieldDisplay")))); } ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("pdfg.name"), "questionnaire"); projectionList.add(Projections.property("pf.name"), "fieldName"); projectionList.add(Projections.property("pf.description"), "description"); projectionList.add(Projections.property("pf.minValue"), "minValue"); projectionList.add(Projections.property("pf.maxValue"), "maxValue"); projectionList.add(Projections.property("pf.encodedValues"), "encodedValues"); projectionList.add(Projections.property("pf.missingValue"), "missingValue"); projectionList.add(Projections.property("ut.name"), "units"); projectionList.add(Projections.property("ft.name"), "type"); criteria.setProjection(projectionList); // only return fields required for report criteria.setResultTransformer(Transformers.aliasToBean(PhenoDataSetFieldDetailsDataRow.class)); criteria.addOrder(Order.asc("pdfg.id")); criteria.addOrder(Order.asc("pdfd.sequence")); results = criteria.list(); } return results; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<ResearcherCostDataRow> getResearcherBillableItemTypeCostData( final ResearcherCostResportVO researcherCostResportVO) { List<ResearcherCostDataRow> results = new ArrayList<ResearcherCostDataRow>(); Criteria criteria = getSession().createCriteria(BillableItem.class, "bi"); criteria.createAlias("workRequest", "wr", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("billableItemType", "bit", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bit.billableItemTypeStatus", "bitst", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("wr.researcher", "re", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.eq("re.id", researcherCostResportVO.getResearcherId())); criteria.add(Restrictions.eq("bi.studyId", researcherCostResportVO.getStudyId())); criteria.add(Restrictions.eq("bi.invoice", researcherCostResportVO.getInvoice())); criteria.add(Restrictions.le("bi.commenceDate", researcherCostResportVO.getToDate())); criteria.add(Restrictions.ge("bi.commenceDate", researcherCostResportVO.getFromDate())); criteria.add(Restrictions.eq("bitst.name", "ACTIVE")); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.groupProperty("bit.id")); projectionList.add(Projections.property("bit.itemName"), "costType"); projectionList.add(Projections.sum("bi.totalCost"), "totalCost"); projectionList.add(Projections.sum("bi.totalGST"), "totalGST"); criteria.setProjection(projectionList); // only return fields required for report criteria.setResultTransformer(Transformers.aliasToBean(ResearcherCostDataRow.class)); criteria.addOrder(Order.asc("bit.itemName")); results = criteria.list();/* w ww . ja v a2 s .c om*/ return results; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<ResearcherDetailCostDataRow> getBillableItemDetailCostData( ResearcherCostResportVO researcherCostResportVO) { List<ResearcherDetailCostDataRow> results = new ArrayList<ResearcherDetailCostDataRow>(); Criteria criteria = getSession().createCriteria(BillableItem.class, "bi"); criteria.createAlias("workRequest", "wr", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("billableItemType", "bit", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("wr.researcher", "re", JoinType.LEFT_OUTER_JOIN); if (researcherCostResportVO.getResearcherId() != null) { criteria.add(Restrictions.eq("re.id", researcherCostResportVO.getResearcherId())); }/*from w w w .ja va 2s . com*/ criteria.add(Restrictions.eq("bi.studyId", researcherCostResportVO.getStudyId())); criteria.add(Restrictions.eq("bi.invoice", researcherCostResportVO.getInvoice())); criteria.add(Restrictions.le("bi.commenceDate", researcherCostResportVO.getToDate())); criteria.add(Restrictions.ge("bi.commenceDate", researcherCostResportVO.getFromDate())); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("bi.description"), "description"); projectionList.add(Projections.property("bi.commenceDate"), "commencedDate"); projectionList.add(Projections.property("bi.invoice"), "invoice"); projectionList.add(Projections.property("bi.quantity"), "quantity"); projectionList.add(Projections.property("bi.totalCost"), "totalAmount"); projectionList.add(Projections.property("bi.totalGST"), "totalGST"); projectionList.add(Projections.property("bit.itemName"), "itemType"); projectionList.add(Projections.property("bit.id"), "typeId"); projectionList.add(Projections.property("bit.quantityType"), "quantityType"); projectionList.add(Projections.property("wr.gstAllow"), "gstAllowed"); projectionList.add(Projections.property("wr.name"), "requestName"); criteria.setProjection(projectionList); // only return fields required for report criteria.setResultTransformer(Transformers.aliasToBean(ResearcherDetailCostDataRow.class)); criteria.addOrder(Order.asc("bit.id")); criteria.addOrder(Order.asc("bi.commenceDate")); results = criteria.list(); return results; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<BiospecimenSummaryDataRow> getBiospecimenSummaryData( BiospecimenSummaryReportVO biospecimenSummaryReportVO) { List<BiospecimenSummaryDataRow> results = new ArrayList<BiospecimenSummaryDataRow>(); Criteria criteria = getSession().createCriteria(BioTransaction.class, "bt"); criteria.createAlias("status", "bts", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("biospecimen", "bs", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bs.study", "st", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bs.linkSubjectStudy", "lss", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bs.sampleType", "sat", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.eq("st.id", biospecimenSummaryReportVO.getStudy().getId())); if (biospecimenSummaryReportVO.getSubjectUID() != null) { criteria.add(Restrictions.eq("lss.subjectUID", biospecimenSummaryReportVO.getSubjectUID())); }//from w w w. ja v a 2 s .c om ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.min("bt.id")); projectionList.add(Projections.groupProperty("bs.id")); projectionList.add(Projections.property("st.name"), "studyName"); projectionList.add(Projections.property("lss.subjectUID"), "subjectUId"); projectionList.add(Projections.property("bs.id"), "biospecimenId"); projectionList.add(Projections.property("bs.biospecimenUid"), "biospecimenUid"); projectionList.add(Projections.property("bs.parentUid"), "parentId"); projectionList.add(Projections.property("sat.name"), "sampleType"); projectionList.add(Projections.property("bs.quantity"), "quantity"); projectionList.add(Projections.property("bts.name"), "initialStatus"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(BiospecimenSummaryDataRow.class)); criteria.addOrder(Order.asc("lss.subjectUID")); criteria.addOrder(Order.asc("bs.biospecimenUid")); results = criteria.list(); return results; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<BiospecimenDetailsDataRow> getBiospecimenDetailsData( BiospecimenDetailsReportVO biospecimenDetailReportVO) { List<BiospecimenDetailsDataRow> results = new ArrayList<BiospecimenDetailsDataRow>(); Criteria criteria = getSession().createCriteria(BioTransaction.class, "bt"); criteria.createAlias("status", "bts", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("biospecimen", "bs", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bs.study", "st", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bs.bioCollection", "bc", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bs.linkSubjectStudy", "lss", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bs.sampleType", "sat", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("bs.invCell", "inc", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("inc.invBox", "inb", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("inb.invRack", "inr", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("inr.invFreezer", "inf", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("inf.invSite", "ins", JoinType.LEFT_OUTER_JOIN); criteria.add(Restrictions.eq("st.id", biospecimenDetailReportVO.getStudy().getId())); if (biospecimenDetailReportVO.getSubjectUID() != null) { criteria.add(Restrictions.eq("lss.subjectUID", biospecimenDetailReportVO.getSubjectUID())); }/*from ww w . ja v a 2s . co m*/ ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.min("bt.id")); projectionList.add(Projections.groupProperty("bs.id")); projectionList.add(Projections.property("st.name"), "studyName"); projectionList.add(Projections.property("lss.subjectUID"), "subjectUId"); projectionList.add(Projections.property("bs.id"), "biospecimenId"); projectionList.add(Projections.property("bc.biocollectionUid"), "biocollectionUid"); projectionList.add(Projections.property("bs.sampleDate"), "sampleDate"); projectionList.add(Projections.property("bs.biospecimenUid"), "biospecimenUid"); projectionList.add(Projections.property("bs.parentUid"), "parentId"); projectionList.add(Projections.property("sat.name"), "sampleType"); projectionList.add(Projections.property("bs.quantity"), "quantity"); projectionList.add(Projections.property("bts.name"), "initialStatus"); projectionList.add(Projections.property("inb.name"), "box"); projectionList.add(Projections.property("inr.name"), "rack"); projectionList.add(Projections.property("inf.name"), "freezer"); projectionList.add(Projections.property("ins.name"), "site"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(BiospecimenDetailsDataRow.class)); criteria.addOrder(Order.asc("lss.subjectUID")); criteria.addOrder(Order.asc("bs.biospecimenUid")); results = criteria.list(); return results; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<ConsentFile> searchConsentFile(ConsentFile consentFile) throws EntityNotFoundException, ArkSystemException { Criteria criteria = getSession().createCriteria(ConsentFile.class); if (consentFile != null) { if (consentFile.getId() != null) { criteria.add(Restrictions.eq("id", consentFile.getId())); }/*from w ww . j a va 2 s. c o m*/ if (consentFile.getConsent() != null) { criteria.add(Restrictions.eq("consent", consentFile.getConsent())); } if (consentFile.getFilename() != null) { criteria.add(Restrictions.ilike("filename", consentFile.getFilename(), MatchMode.ANYWHERE)); } } criteria.addOrder(Order.desc("id")); @SuppressWarnings("unchecked") List<ConsentFile> list = criteria.list(); return list; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public String getPreviousLastname(Person person) { PersonLastnameHistory personLastameHistory = new PersonLastnameHistory(); // Only get previous lastname if person in context if (person.getId() != null && person.getLastName() != null) { Criteria criteria = getSession().createCriteria(PersonLastnameHistory.class); criteria.add(Restrictions.eq(au.org.theark.core.Constants.PERSON_SURNAME_HISTORY_PERSON, person)); criteria.addOrder(Order.desc("id")); List pastNamesList = criteria.list(); if (!pastNamesList.isEmpty()) { if (pastNamesList.size() > 0) personLastameHistory = (PersonLastnameHistory) pastNamesList.get((pastNamesList.size() - 1)); }//from w w w . ja v a 2 s. c o m } return personLastameHistory.getLastName(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<SubjectFile> searchSubjectFile(SubjectFile subjectFile) throws EntityNotFoundException, ArkSystemException { Criteria criteria = getSession().createCriteria(SubjectFile.class); if (subjectFile != null) { if (subjectFile.getId() != null) { criteria.add(Restrictions.eq("id", subjectFile.getId())); }// w w w. j a va 2 s . c o m if (subjectFile.getLinkSubjectStudy() != null) { criteria.add(Restrictions.eq("linkSubjectStudy", subjectFile.getLinkSubjectStudy())); } if (subjectFile.getStudyComp() != null) { criteria.add(Restrictions.eq("studyComp", subjectFile.getStudyComp())); } if (subjectFile.getFilename() != null) { criteria.add(Restrictions.ilike("filename", subjectFile.getFilename(), MatchMode.ANYWHERE)); } } criteria.addOrder(Order.desc("id")); @SuppressWarnings("unchecked") List<SubjectFile> list = criteria.list(); return list; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<Study> getChildStudyListOfParent(Study study) { Criteria criteria = getStatelessSession().createCriteria(Study.class); criteria.add(Restrictions.ne("id", study.getId())); criteria.add(Restrictions.eq("parentStudy", study)); try {//from w ww . ja v a2 s . com criteria.add(Restrictions.ne("studyStatus", getStudyStatus("Archive"))); } catch (StatusNotAvailableException e) { // TODO Auto-generated catch block e.printStackTrace(); } criteria.addOrder(Order.asc("name")); List<Study> childStudyList = (List<Study>) criteria.list(); return childStudyList; }
From source file:be.redlab.examples.databasetesting.common.AbstractJpaDao.java
License:Apache License
protected List<T> findByCriteria(final int firstResult, final int maxResults, final Order order, final Criterion... criterion) { Session session = (Session) getEntityManager().getDelegate(); Criteria crit = session.createCriteria(getEntityClass()); for (final Criterion c : criterion) { crit.add(c);/*from w ww.j a v a2s.c o m*/ } if (order != null) { crit.addOrder(order); } if (firstResult > 0) { crit.setFirstResult(firstResult); } if (maxResults > 0) { crit.setMaxResults(maxResults); } return crit.list(); }