List of usage examples for org.hibernate Criteria setFirstResult
public Criteria setFirstResult(int firstResult);
From source file:au.org.theark.lims.model.dao.BiospecimenDao.java
License:Open Source License
public List<Biospecimen> searchPageableBiospecimens(LimsVO limsVo, int first, int count) { Criteria criteria = buildBiospecimenCriteria(limsVo); criteria.setFirstResult(first); criteria.setMaxResults(count);// w ww . j a v a 2 s. com List<Biospecimen> list = criteria.list(); return list; }
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); }// w ww .j a v a2 s . c o m 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
@SuppressWarnings("unchecked") public List<LinkSubjectStudy> searchPageableSubjects(LimsVO limsVoCriteria, List<Study> studyList, int first, int count) { Criteria criteria = buildGeneralSubjectCriteria(limsVoCriteria, studyList); criteria.setFirstResult(first); criteria.setMaxResults(count);/* w w w. j av a 2 s .c om*/ List<LinkSubjectStudy> subjectList = criteria.list(); return subjectList; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public List<PhenoDataSetCollection> searchPageablePhenoCollection(PhenoDataCollectionVO collectionCriteria, int first, int count) { List<PhenoDataSetCollection> resultList = new ArrayList<PhenoDataSetCollection>(); StringBuffer sb = new StringBuffer(); sb.append("SELECT qnaire, pc "); sb.append(" FROM " + PhenoDataSetGroup.class.getName() + " AS qnaire "); sb.append(" LEFT JOIN qnaire.phenoDataSetCollections as pc "); sb.append(" WITH pc.linkSubjectStudy.id = :subjectId "); sb.append(" WHERE qnaire.study.id = :studyId "); //sb.append(" AND qnaire.arkFunction.id = :functionId "); sb.append(" AND qnaire.published = true "); Query query = getSession().createQuery(sb.toString()); query.setParameter("subjectId", collectionCriteria.getPhenoDataSetCollection().getLinkSubjectStudy().getId()); query.setParameter("studyId", collectionCriteria.getPhenoDataSetGroup().getStudy().getId()); //log.info("colcrit ark=" + collectionCriteria.getArkFunction()); //long id = collectionCriteria.getArkFunction().getId(); //log.info("id=" + id); //query.setParameter("functionId",id); query.setFirstResult(first);/* www. j ava 2 s . c o m*/ query.setMaxResults(count); List<Object[]> listOfObjects = query.list(); for (Object[] objects : listOfObjects) { //CustomFieldGroup questionnaire = new CustomFieldGroup(); PhenoDataSetGroup questionnaire = new PhenoDataSetGroup(); PhenoDataSetCollection pc = new PhenoDataSetCollection(); if (objects.length > 0 && objects.length >= 1) { questionnaire = (PhenoDataSetGroup) objects[0]; if (objects[1] != null) { pc = (PhenoDataSetCollection) objects[1]; } else { pc.setQuestionnaire(questionnaire); } resultList.add(pc); } } Criteria criteria = getSession().createCriteria(PhenoDataSetCollection.class); criteria.createAlias("questionnaire", "qnaire"); criteria.add(Restrictions.eq("linkSubjectStudy", collectionCriteria.getPhenoDataSetCollection().getLinkSubjectStudy())); // Just a precaution (PhenoCollection to should always map to a CustomFieldGroup where the ArkFunction will correspond to Pheno) criteria.add(Restrictions.eq("qnaire.arkFunction", collectionCriteria.getArkFunction())); criteria.setFirstResult(first); criteria.setMaxResults(count); resultList = criteria.list(); return resultList; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public Collection<PhenoDataSetFieldDisplay> getCFDLinkedToQuestionnaire(PhenoDataSetGroup phenoDataSetGroup, int first, int count) { Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class); criteria.add(Restrictions.eq("phenoDataSetGroup", phenoDataSetGroup)); criteria.setFirstResult(first); criteria.setMaxResults(count);//w w w . j a va2 s. c o m criteria.addOrder(Order.asc("phenoDataSetFiledOrderNumber")); return criteria.list(); }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public List<PhenoDataSetCategory> searchPageablePhenoDataSetCategories( PhenoDataSetCategory phenoDataSetCategoryCriteria, int first, int count) { Criteria criteria = buildGeneralPhenoDataSetCategoryCritera(phenoDataSetCategoryCriteria); criteria.setFirstResult(first); criteria.setMaxResults(count);/*from ww w . j a v a2s . co m*/ criteria.addOrder(Order.asc("name")); List<PhenoDataSetCategory> phenoDataSetCategoryList = (List<PhenoDataSetCategory>) criteria.list(); return phenoDataSetCategoryList; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<PhenoDataSetField> searchPageablePhenoFields(PhenoDataSetField phenoDataSetCriteria, int first, int count) { Criteria criteria = buildGeneralPhenoFieldCritera(phenoDataSetCriteria); criteria.setFirstResult(first); criteria.setMaxResults(count);//from w ww . j ava 2s .c o m criteria.addOrder(Order.asc("name")); List<PhenoDataSetField> phenoDataSetList = (List<PhenoDataSetField>) criteria.list(); return phenoDataSetList; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public List<PhenoDataSetGroup> getPhenoDataSetGroups(PhenoDataSetGroup phenoDataSetGroup, int first, int count) { Criteria criteria = buildGenericPhenoDataSetFieldGroupCriteria(phenoDataSetGroup); criteria.setFirstResult(first); criteria.setMaxResults(count);/* w ww .j a va 2 s .c o m*/ List<PhenoDataSetGroup> list = (List<PhenoDataSetGroup>) criteria.list(); return list; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public PickedPhenoDataSetCategory getSwapOverPickedPhenoDataSetCategoryForUpButton( PickedPhenoDataSetCategory pickedPhenoDataSetCategory) { Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class); criteria.add(Restrictions.eq("arkFunction", pickedPhenoDataSetCategory.getArkFunction())); criteria.add(Restrictions.eq("study", pickedPhenoDataSetCategory.getStudy())); criteria.add(Restrictions.eq("arkUser", pickedPhenoDataSetCategory.getArkUser())); if (pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory() != null) { criteria.add(Restrictions.eq("parentPickedPhenoDataSetCategory", pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory())); } else {/*from w w w .j a va 2s .co m*/ criteria.add(Restrictions.isNull("parentPickedPhenoDataSetCategory")); } criteria.add(Restrictions.lt("orderNumber", pickedPhenoDataSetCategory.getOrderNumber())); criteria.addOrder(Order.desc("orderNumber")); criteria.setFirstResult(0); criteria.setMaxResults(1); List<PickedPhenoDataSetCategory> pickedPhenoDataSetCategories = (List<PickedPhenoDataSetCategory>) criteria .list(); if (pickedPhenoDataSetCategories.size() > 0) { return pickedPhenoDataSetCategories.get(0); } else { return null; } }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
@Override public PickedPhenoDataSetCategory getSwapOverPickedPhenoDataSetCategoryForDownButton( PickedPhenoDataSetCategory pickedPhenoDataSetCategory) { Criteria criteria = getSession().createCriteria(PickedPhenoDataSetCategory.class); criteria.add(Restrictions.eq("arkFunction", pickedPhenoDataSetCategory.getArkFunction())); criteria.add(Restrictions.eq("study", pickedPhenoDataSetCategory.getStudy())); criteria.add(Restrictions.eq("arkUser", pickedPhenoDataSetCategory.getArkUser())); if (pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory() != null) { criteria.add(Restrictions.eq("parentPickedPhenoDataSetCategory", pickedPhenoDataSetCategory.getParentPickedPhenoDataSetCategory())); } else {//from w ww. j a v a 2 s .c om criteria.add(Restrictions.isNull("parentPickedPhenoDataSetCategory")); } criteria.add(Restrictions.gt("orderNumber", pickedPhenoDataSetCategory.getOrderNumber())); criteria.addOrder(Order.asc("orderNumber")); criteria.setFirstResult(0); criteria.setMaxResults(1); List<PickedPhenoDataSetCategory> pickedPhenoDataSetCategories = (List<PickedPhenoDataSetCategory>) criteria .list(); if (pickedPhenoDataSetCategories.size() > 0) { return pickedPhenoDataSetCategories.get(0); } else { return null; } }