List of usage examples for org.hibernate Query list
List<R> list();
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@Override public List<FamilyCustomFieldData> getfamilyCustomFieldDataFor(Study study, Collection customFieldDisplaysThatWeNeed, List familyUidsToBeIncluded) { if (customFieldDisplaysThatWeNeed == null || customFieldDisplaysThatWeNeed.isEmpty() || familyUidsToBeIncluded == null || familyUidsToBeIncluded.isEmpty()) { return new ArrayList<FamilyCustomFieldData>(); } else {//from www.j a v a 2 s . c o m String queryString = "select fcfd from FamilyCustomFieldData fcfd where fcfd.familyUid in (:familyUidsToBeIncluded) " + " and fcfd.customFieldDisplay in (:customFieldDisplaysThatWeNeed) and fcfd.study=:study"; Query query = getSession().createQuery(queryString); query.setParameterList("familyUidsToBeIncluded", familyUidsToBeIncluded); query.setParameterList("customFieldDisplaysThatWeNeed", customFieldDisplaysThatWeNeed); query.setParameter("study", study); return query.list(); } }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
@Override public List<CustomFieldDisplay> getCustomFieldDisplaysInWithCustomFieldType(List<String> fieldNameCollection, Study study, ArkFunction arkFunction, CustomFieldType customFieldType) { if (fieldNameCollection == null || fieldNameCollection.isEmpty()) { return new ArrayList<CustomFieldDisplay>(); } else {//from w w w . j a v a 2 s . com List<String> lowerCaseNames = new ArrayList<String>(); for (String name : fieldNameCollection) { lowerCaseNames.add(name.toLowerCase()); } String queryString = "select cfd " + "from CustomFieldDisplay cfd " + "where customField.id in ( " + " SELECT id from CustomField cf " + " where cf.study =:study " + " and lower(cf.name) in (:names) " + " and cf.arkFunction =:arkFunction and cf.customFieldType=:customFieldType )"; Query query = getSession().createQuery(queryString); query.setParameter("study", study); // query.setParameterList("names", fieldNameCollection); query.setParameterList("names", lowerCaseNames); query.setParameter("arkFunction", arkFunction); query.setParameter("customFieldType", customFieldType); return query.list(); } }
From source file:au.org.theark.lims.model.dao.BioCollectionDao.java
License:Open Source License
public List<BioCollectionCustomFieldData> getBioCollectionCustomFieldDataList( BioCollection bioCollectionCriteria, ArkFunction arkFunction, int first, int count) { List<BioCollectionCustomFieldData> bioCollectionCustomFieldDataList = new ArrayList<BioCollectionCustomFieldData>(); StringBuffer sb = new StringBuffer(); sb.append(" FROM CustomFieldDisplay AS cfd "); sb.append("LEFT JOIN cfd.bioCollectionCustomFieldData as fieldList "); sb.append(" with fieldList.bioCollection.id = :bioCollectionId "); sb.append(" WHERE cfd.customField.study.id IN (:studyId)"); sb.append(" AND cfd.customField.arkFunction.id = :functionId"); sb.append(" ORDER BY cfd.sequence"); Query query = getSession().createQuery(sb.toString()); query.setParameter("bioCollectionId", bioCollectionCriteria.getId()); // Allow child studies to inherit parent defined custom fields List studyList = new ArrayList(); studyList.add(bioCollectionCriteria.getStudy().getId()); if (bioCollectionCriteria.getStudy().getParentStudy() != null && bioCollectionCriteria.getStudy().getParentStudy() != bioCollectionCriteria.getStudy()) { studyList.add(bioCollectionCriteria.getStudy().getParentStudy().getId()); }//from www . j av a 2 s.c o m query.setParameterList("studyId", studyList); query.setParameter("functionId", arkFunction.getId()); query.setFirstResult(first); query.setMaxResults(count); List<Object[]> listOfObjects = query.list(); for (Object[] objects : listOfObjects) { CustomFieldDisplay cfd = new CustomFieldDisplay(); BioCollectionCustomFieldData bccfd = new BioCollectionCustomFieldData(); if (objects.length > 0 && objects.length >= 1) { cfd = (CustomFieldDisplay) objects[0]; if (objects[1] != null) { bccfd = (BioCollectionCustomFieldData) objects[1]; } else { bccfd.setCustomFieldDisplay(cfd); } bioCollectionCustomFieldDataList.add(bccfd); } } return bioCollectionCustomFieldDataList; }
From source file:au.org.theark.lims.model.dao.BioCollectionDao.java
License:Open Source License
public BioCollectionCustomFieldData getBioCollectionCustomFieldData(BioCollection bioCollectionCriteria, ArkFunction arkFunction, String customFieldName) { StringBuffer sb = new StringBuffer(); sb.append(" FROM CustomFieldDisplay AS cfd "); sb.append("LEFT JOIN cfd.bioCollectionCustomFieldData as fieldList "); sb.append(" WITH fieldList.bioCollection.id = :bioCollectionId "); sb.append(" WHERE cfd.customField.study.id IN (:studyId)"); sb.append(" AND cfd.customField.arkFunction.id = :functionId"); sb.append(" AND cfd.customField.name = :customFieldName"); sb.append(" ORDER BY cfd.sequence"); Query query = getSession().createQuery(sb.toString()); query.setParameter("bioCollectionId", bioCollectionCriteria.getId()); // Allow child studies to inherit parent defined custom fields List studyList = new ArrayList(); studyList.add(bioCollectionCriteria.getStudy().getId()); if (bioCollectionCriteria.getStudy().getParentStudy() != null && bioCollectionCriteria.getStudy().getParentStudy() != bioCollectionCriteria.getStudy()) { studyList.add(bioCollectionCriteria.getStudy().getParentStudy().getId()); }/*ww w . j av a2 s . c om*/ query.setParameterList("studyId", studyList); query.setParameter("functionId", arkFunction.getId()); query.setParameter("customFieldName", customFieldName); BioCollectionCustomFieldData bccfd = new BioCollectionCustomFieldData(); List<Object[]> listOfObjects = query.list(); for (Object[] objects : listOfObjects) { CustomFieldDisplay cfd = new CustomFieldDisplay(); if (objects.length > 0 && objects.length >= 1) { cfd = (CustomFieldDisplay) objects[0]; if (objects[1] != null) { bccfd = (BioCollectionCustomFieldData) objects[1]; } else { bccfd.setCustomFieldDisplay(cfd); } } } return bccfd; }
From source file:au.org.theark.lims.model.dao.BioCollectionDao.java
License:Open Source License
public List<String> getAllBiocollectionUIDs(Study study) { String queryString = "select bio.biocollectionUid " + "from BioCollection bio " + "where study =:study " + "order by biocollectionUid "; Query query = getSession().createQuery(queryString); query.setParameter("study", study); return query.list(); }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public List<BiospecimenCustomFieldData> getBiospecimenCustomFieldDataList(Biospecimen biospecimenCriteria, ArkFunction arkFunction, int first, int count) { List<BiospecimenCustomFieldData> biospecimenCustomFieldDataList = new ArrayList<BiospecimenCustomFieldData>(); StringBuffer sb = new StringBuffer(); sb.append(" FROM CustomFieldDisplay AS cfd "); sb.append("LEFT JOIN cfd.biospecimenCustomFieldData as fieldList "); sb.append(" with fieldList.biospecimen.id = :biospecimenId "); sb.append(" where cfd.customField.study.id IN (:studyId)"); sb.append(" and cfd.customField.arkFunction.id = :functionId"); sb.append(" order by cfd.sequence"); Query query = getSession().createQuery(sb.toString()); query.setParameter("biospecimenId", biospecimenCriteria.getId()); // Allow child studies to inherit parent defined custom fields List studyList = new ArrayList(); studyList.add(biospecimenCriteria.getStudy().getId()); if (biospecimenCriteria.getStudy().getParentStudy() != null && biospecimenCriteria.getStudy().getParentStudy() != biospecimenCriteria.getStudy()) { studyList.add(biospecimenCriteria.getStudy().getParentStudy().getId()); }/* w w w. j a v a 2 s. c o m*/ query.setParameterList("studyId", studyList); query.setParameter("functionId", arkFunction.getId()); query.setFirstResult(first); query.setMaxResults(count); List<Object[]> listOfObjects = query.list(); for (Object[] objects : listOfObjects) { CustomFieldDisplay cfd = new CustomFieldDisplay(); BiospecimenCustomFieldData bscfd = new BiospecimenCustomFieldData(); if (objects.length > 0 && objects.length >= 1) { cfd = (CustomFieldDisplay) objects[0]; if (objects[1] != null) { bscfd = (BiospecimenCustomFieldData) objects[1]; } else { bscfd.setCustomFieldDisplay(cfd); } biospecimenCustomFieldDataList.add(bscfd); } } return biospecimenCustomFieldDataList; }
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public List<String> getAllBiospecimenUIDs(Study study) { String queryString = "select bio.biospecimenUid " + "from Biospecimen bio " + "where study =:study " + "order by biospecimenUid "; Query query = getSession().createQuery(queryString); query.setParameter("study", study); return query.list(); }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
/** TODO ASAP TEST THIS */ public List<InvCell> getCellAndBiospecimenListByBox(InvBox invBox) { StringBuffer sb = new StringBuffer(); sb.append(" select cell FROM InvCell AS cell "); sb.append(" LEFT JOIN fetch cell.biospecimen "); sb.append(" WHERE cell.invBox.id = :invBoxId "); sb.append(" ORDER BY cell.rowno, cell.colno "); Query query = getSession().createQuery(sb.toString()); query.setParameter("invBoxId", invBox.getId()); List<InvCell> invCellList = query.list(); return invCellList; /*/*from w w w . ja v a 2s. c om*/ List<InvCell> invCellList = new ArrayList<InvCell>(); StringBuffer sb = new StringBuffer(); sb.append(" FROM InvCell AS cell "); sb.append("LEFT JOIN cell.biospecimen as biospecimenList "); sb.append(" WHERE cell.invBox.id = :invBoxId"); sb.append(" ORDER BY cell.rowno, cell.colno"); Query query = getSession().createQuery(sb.toString()); query.setParameter("invBoxId", invBox.getId()); List<Object[]> listOfObjects = query.list(); for (Object[] objects : listOfObjects) { InvCell invCell = new InvCell(); Biospecimen biospecimen = new Biospecimen(); if (objects.length > 0 && objects.length >= 1) { invCell = (InvCell) objects[0]; if (objects[1] != null) { biospecimen = (Biospecimen) objects[1]; invCell.setBiospecimen(biospecimen); } invCellList.add(invCell); } } return invCellList;*/ }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public List<InvRack> searchInvRack(InvRack invRack, List<Study> studyListForUser) throws ArkSystemException { StringBuilder hqlString = new StringBuilder(); hqlString.append("FROM InvRack AS rack \n"); //Added new condition to not showing the fully occupied racks to change the box. //hqlString.append("WHERE invFreezer.id IN (SELECT id FROM InvFreezer AS freezer \n"); hqlString.append("WHERE rack.available <> 0 AND invFreezer.id IN (SELECT id FROM InvFreezer AS freezer \n"); hqlString.append(/* www . ja v a 2 s .c om*/ " WHERE freezer.invSite.id IN (SELECT invSite.id FROM StudyInvSite \n"); hqlString.append(" WHERE study IN (:studies)))"); Query q = getSession().createQuery(hqlString.toString()); q.setParameterList("studies", studyListForUser); List<InvRack> list = q.list(); return list; }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public List<InvFreezer> searchInvFreezer(InvFreezer invFreezer, List<Study> studyListForUser) throws ArkSystemException { StringBuilder hqlString = new StringBuilder(); hqlString.append("FROM InvFreezer AS freezer \n"); hqlString.append("WHERE freezer.invSite.id IN (SELECT invSite.id FROM StudyInvSite \n"); hqlString.append(" WHERE study IN (:studies))"); Query q = getSession().createQuery(hqlString.toString()); q.setParameterList("studies", studyListForUser); List<InvFreezer> list = q.list(); return list;/* w w w . ja v a 2 s . c o m*/ }