List of usage examples for org.hibernate Criteria setResultTransformer
public Criteria setResultTransformer(ResultTransformer resultTransformer);
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 ww w. jav a 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();/* w w w. j a v a2s . co 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())); }/*from w w w . j a v a 2s.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())); }//from w ww. j a va 2s . 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("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())); }/* w w w. j av 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 RelationshipVo getSubjectRelative(final String subjectUID, final Long studyId) { List<RelationshipVo> relatives = new ArrayList<RelationshipVo>(); Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class, "sub"); criteria.createAlias("sub.study", "substudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.person", "subPerson", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("subPerson.genderType", "subGender", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("subPerson.vitalStatus", "subVitStatus", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("substudy.pedigreeConfiguration", "spc", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("spc.customField", "cf", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("cf.customFieldDisplay", "cfd", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.subjectCustomFieldDataSet", "scfd", JoinType.LEFT_OUTER_JOIN, Restrictions.eqProperty("cfd.id", "scfd.customFieldDisplay.id")); criteria.add(Restrictions.eq("sub.subjectUID", subjectUID)); criteria.add(Restrictions.eq("substudy.id", studyId)); criteria.setFetchMode("subject", FetchMode.JOIN); criteria.setFetchMode("relative", FetchMode.JOIN); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("sub.subjectUID"), "individualId"); projectionList.add(Projections.property("subGender.name"), "gender"); projectionList.add(Projections.property("subPerson.dateOfBirth"), "dob"); projectionList.add(Projections.property("subPerson.dateOfDeath"), "dod"); projectionList.add(Projections.property("subVitStatus.name"), "deceased"); projectionList.add(Projections.property("scfd.textDataValue"), "affectedStatus"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(RelationshipVo.class)); relatives = criteria.list();//from ww w . j av a 2 s .c om return relatives.size() > 0 ? relatives.get(0) : null; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<RelationshipVo> getSubjectParentRelatives(final String subjectUID, final Long studyId) { List<RelationshipVo> relatives = new ArrayList<RelationshipVo>(); Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class, "lsp"); criteria.createAlias("subject", "sub", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.study", "substudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relative", "rel", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("rel.study", "relstudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relationship", "type", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("rel.person", "relPerson", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relPerson.genderType", "relGender", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relPerson.vitalStatus", "relVitStatus", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relstudy.pedigreeConfiguration", "spc", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("spc.customField", "cf", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("cf.customFieldDisplay", "cfd", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("rel.subjectCustomFieldDataSet", "scfd", JoinType.LEFT_OUTER_JOIN, Restrictions.eqProperty("cfd.id", "scfd.customFieldDisplay.id")); criteria.add(Restrictions.eq("sub.subjectUID", subjectUID)); criteria.add(Restrictions.eq("substudy.id", studyId)); criteria.add(Restrictions.eq("relstudy.id", studyId)); criteria.setFetchMode("subject", FetchMode.JOIN); criteria.setFetchMode("relative", FetchMode.JOIN); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("lsp.id"), "id"); projectionList.add(Projections.property("rel.subjectUID"), "individualId"); projectionList.add(Projections.property("relGender.name"), "gender"); projectionList.add(Projections.property("relPerson.dateOfBirth"), "dob"); projectionList.add(Projections.property("relPerson.dateOfDeath"), "dod"); projectionList.add(Projections.property("relPerson.firstName"), "firstName"); projectionList.add(Projections.property("relPerson.lastName"), "lastName"); projectionList.add(Projections.property("relVitStatus.name"), "deceased"); projectionList.add(Projections.property("scfd.textDataValue"), "affectedStatus"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(RelationshipVo.class)); relatives = criteria.list();//from w w w . j a v a2 s .c om return relatives; }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
public List<RelationshipVo> getSubjectChildRelatives(final String subjectUID, final Long studyId) { List<RelationshipVo> relatives = new ArrayList<RelationshipVo>(); Criteria criteria = getSession().createCriteria(LinkSubjectPedigree.class, "lsp"); criteria.createAlias("subject", "sub", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.study", "substudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relative", "rel", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("rel.study", "relstudy", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("relationship", "type", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.person", "subPerson", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("subPerson.genderType", "subGender", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("subPerson.vitalStatus", "subVitStatus", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("substudy.pedigreeConfiguration", "spc", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("spc.customField", "cf", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("cf.customFieldDisplay", "cfd", JoinType.LEFT_OUTER_JOIN); criteria.createAlias("sub.subjectCustomFieldDataSet", "scfd", JoinType.LEFT_OUTER_JOIN, Restrictions.eqProperty("cfd.id", "scfd.customFieldDisplay.id")); criteria.add(Restrictions.eq("rel.subjectUID", subjectUID)); criteria.add(Restrictions.eq("substudy.id", studyId)); criteria.add(Restrictions.eq("relstudy.id", studyId)); criteria.setFetchMode("subject", FetchMode.JOIN); criteria.setFetchMode("relative", FetchMode.JOIN); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("lsp.id"), "id"); projectionList.add(Projections.property("sub.subjectUID"), "individualId"); projectionList.add(Projections.property("subGender.name"), "gender"); projectionList.add(Projections.property("subPerson.dateOfBirth"), "dob"); projectionList.add(Projections.property("subPerson.dateOfDeath"), "dod"); projectionList.add(Projections.property("subPerson.firstName"), "firstName"); projectionList.add(Projections.property("subPerson.lastName"), "lastName"); projectionList.add(Projections.property("subVitStatus.name"), "deceased"); projectionList.add(Projections.property("scfd.textDataValue"), "affectedStatus"); criteria.setProjection(projectionList); criteria.setResultTransformer(Transformers.aliasToBean(RelationshipVo.class)); relatives = criteria.list();//w ww . j a v a 2 s . co m return relatives; }
From source file:br.com.bean.RestControllers.faculdadeController.java
@RequestMapping(value = "busca-faculdades", method = RequestMethod.GET) public String get() throws ParseException { Session sessao = HibernateUtility.getSession(); Transaction transacao = sessao.beginTransaction(); try {//w w w.j a v a 2s. co m Criteria query = sessao.createCriteria(Faculdade.class); Criterion ativo = Restrictions.eq("ativo", 1); query.setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE); query.add(ativo); List<Faculdade> listaDeFaculdades = query.list(); // Retira Referencia Circular for (Faculdade f : listaDeFaculdades) { f.setTurmas(null); } Type TipolistaDeFaculdades = new TypeToken<List<Faculdade>>() { }.getType(); Gson gson = new GsonBuilder().registerTypeAdapter(Collection.class, new CollectionDeserializer()) .create(); String faculdades = gson.toJson(listaDeFaculdades, TipolistaDeFaculdades); return faculdades; } catch (HibernateException e) { transacao.rollback(); return null; } catch (Exception e) { String erro = e.getMessage(); return null; } finally { sessao.close(); } }
From source file:br.com.bean.RestControllers.turmaController.java
@RequestMapping(value = "busca-turmas", method = RequestMethod.GET) @ResponseBody/*from w w w . j av a 2 s. c o m*/ public String buscaTurmas(long faculdadeId) throws ParseException { Session sessao = HibernateUtility.getSession(); Transaction transacao = sessao.beginTransaction(); try { Criteria turmaCrit = sessao.createCriteria(Turma.class); turmaCrit.add(Restrictions.eq("ativo", 1)); Criteria faculdadeCrit = turmaCrit.createCriteria("faculdade"); faculdadeCrit.add(Restrictions.eq("faculdadeId", faculdadeId)); turmaCrit.setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE); List<Turma> listaDeTurmas = turmaCrit.list(); for (Turma t : listaDeTurmas) { t.setFaculdade(null); } Type TipolistaDeTurmas = new TypeToken<List<Turma>>() { }.getType(); Gson gson = new GsonBuilder().registerTypeAdapter(Collection.class, new CollectionDeserializer()) .create(); return gson.toJson(listaDeTurmas, TipolistaDeTurmas); } catch (HibernateException e) { transacao.rollback(); return null; } finally { sessao.close(); } }