List of usage examples for org.hibernate Criteria setProjection
public Criteria setProjection(Projection projection);
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public Phone getHomePhone(LinkSubjectStudy subject) { Phone result = null;// w w w. j av a2 s .c om Criteria criteria = getSession().createCriteria(Phone.class); criteria.add(Restrictions.eq("person", subject.getPerson())); criteria.createAlias("phoneType", "pt"); criteria.add(Restrictions.eq("pt.name", "Home")); criteria.setMaxResults(1); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("areaCode"), "areaCode"); projectionList.add(Projections.property("phoneNumber"), "phoneNumber"); criteria.setProjection(projectionList); // only return fields required for report criteria.setResultTransformer(Transformers.aliasToBean(Phone.class)); if (criteria.uniqueResult() != null) { result = (Phone) criteria.uniqueResult(); } return result; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public Consent getStudyCompConsent(Consent consent) { // Note: Should never be possible to have more than one Consent record for a // given a particular subject and study component Criteria criteria = getSession().createCriteria(Consent.class); if (consent != null) { criteria.add(Restrictions.eq("study.id", consent.getStudy().getId())); // must only get consents for subject in context criteria.add(Restrictions.eq("linkSubjectStudy.id", consent.getLinkSubjectStudy().getId())); // must only get consents for specific studyComp criteria.add(Restrictions.eq("studyComp.id", consent.getStudyComp().getId())); // Do NOT constrain against consentStatus or consentDate here, because we want to be able to // tell if they are "Not Consented" vs "Consented" with different consentStatus or consentDate. // if (consent.getConsentStatus() != null) // {/*w ww .j av a 2 s. c om*/ // criteria.add(Restrictions.eq("consentStatus.id", consent.getConsentStatus().getId())); // } // // if (consent.getConsentDate() != null) // { // criteria.add(Restrictions.eq("consentDate", consent.getConsentDate())); // } } ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("studyComp"), "studyComp"); projectionList.add(Projections.property("consentStatus"), "consentStatus"); projectionList.add(Projections.property("consentDate"), "consentDate"); criteria.setProjection(projectionList); criteria.setMaxResults(1); criteria.setResultTransformer(Transformers.aliasToBean(Consent.class)); Consent result = (Consent) criteria.uniqueResult(); return result; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<FieldDetailsDataRow> getPhenoFieldDetailsList(FieldDetailsReportVO fdrVO) { List<FieldDetailsDataRow> results = new ArrayList<FieldDetailsDataRow>(); Criteria criteria = getSession().createCriteria(PhenoDataSetCollection.class, "fpc"); criteria.createAlias("phenoCollection", "pc"); // Inner join to Field criteria.createAlias("field", "f"); // Inner join to Field criteria.createAlias("f.fieldType", "ft"); // Inner join to FieldType criteria.add(Restrictions.eq("study", fdrVO.getStudy())); if (fdrVO.getPhenoCollection() != null) { criteria.add(Restrictions.eq("phenoCollection", fdrVO.getPhenoCollection())); }//w w w. ja v a 2 s.c o m if (fdrVO.getFieldDataAvailable()) { DetachedCriteria fieldDataCriteria = DetachedCriteria.forClass(PhenoDataSetData.class, "fd"); // Join FieldPhenoCollection and FieldData on ID FK fieldDataCriteria.add(Property.forName("f.id").eqProperty("fd." + "field.id")); fieldDataCriteria.add(Property.forName("pc.id").eqProperty("fd." + "collection.id")); criteria.add(Subqueries.exists(fieldDataCriteria.setProjection(Projections.property("fd.id")))); } ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("pc.name"), "collection"); projectionList.add(Projections.property("f.name"), "fieldName"); projectionList.add(Projections.property("f.description"), "description"); projectionList.add(Projections.property("f.minValue"), "minValue"); projectionList.add(Projections.property("f.maxValue"), "maxValue"); projectionList.add(Projections.property("f.encodedValues"), "encodedValues"); projectionList.add(Projections.property("f.missingValue"), "missingValue"); projectionList.add(Projections.property("f.units"), "units"); projectionList.add(Projections.property("ft.name"), "type"); criteria.setProjection(projectionList); // only return fields required for report criteria.setResultTransformer(Transformers.aliasToBean(FieldDetailsDataRow.class)); criteria.addOrder(Order.asc("pc.id")); criteria.addOrder(Order.asc("f.name")); results = criteria.list(); return results; }
From source file:au.org.theark.report.model.dao.ReportDao.java
License:Open Source License
public List<CustomFieldDetailsDataRow> getPhenoCustomFieldDetailsList(CustomFieldDetailsReportVO fdrVO) { List<CustomFieldDetailsDataRow> results = new ArrayList<CustomFieldDetailsDataRow>(); if (fdrVO.getCustomFieldDisplay() != null) { /*/* w ww . ja va2s.co m*/ * Following query returns customFields whether or not they are * associated with a customFieldGroups (via customFieldDisplay) */ Criteria criteria = getSession().createCriteria(CustomField.class, "cf"); criteria.createAlias("customFieldDisplay", "cfd", JoinType.LEFT_OUTER_JOIN); // Left join to CustomFieldDisplay criteria.createAlias("cfd.customFieldGroup", "cfg", 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("cf.study", fdrVO.getStudy())); ArkFunction function = iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION); criteria.add(Restrictions.eq("cf.arkFunction", function)); if (fdrVO.getCustomFieldDisplay().getCustomFieldGroup() != null) { criteria.add( Restrictions.eq("cfg.id", fdrVO.getCustomFieldDisplay().getCustomFieldGroup().getId())); } if (fdrVO.getFieldDataAvailable()) { DetachedCriteria fieldDataCriteria = DetachedCriteria.forClass(PhenoDataSetData.class, "pd"); // Join CustomFieldDisplay and PhenoData on ID FK fieldDataCriteria.add(Property.forName("cfd.id").eqProperty("pd." + "customFieldDisplay.id")); criteria.add(Subqueries .exists(fieldDataCriteria.setProjection(Projections.property("pd.customFieldDisplay")))); } ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("cfg.name"), "questionnaire"); projectionList.add(Projections.property("cf.name"), "fieldName"); projectionList.add(Projections.property("cf.description"), "description"); projectionList.add(Projections.property("cf.minValue"), "minValue"); projectionList.add(Projections.property("cf.maxValue"), "maxValue"); projectionList.add(Projections.property("cf.encodedValues"), "encodedValues"); projectionList.add(Projections.property("cf.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(CustomFieldDetailsDataRow.class)); criteria.addOrder(Order.asc("cfg.id")); criteria.addOrder(Order.asc("cfd.sequence")); results = criteria.list(); } return results; }
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) { /*/*from w ww . j ava 2s . c o m*/ * 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();/*from w w w .j a v a 2s. c o m*/ 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())); }// w ww . java 2 s . c o m 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())); }/* w w w . j a 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 w w w.j a v a2 s . c o 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 boolean isStudyComponentUsed(StudyComp studyComp) { boolean flag = false; Criteria criteria = getSession().createCriteria(Consent.class); criteria.add(Restrictions.eq("studyComp", studyComp)); criteria.setProjection(Projections.rowCount()); Long i = (Long) criteria.uniqueResult(); if (i > 0L) { flag = true;/* ww w .ja va 2 s . c om*/ } return flag; }