List of usage examples for org.hibernate Criteria add
public Criteria add(Criterion criterion);
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public boolean phenoCollectionHasData(PhenoDataSetCollection phenoCollection) { Criteria criteria = getSession().createCriteria(PhenoDataSetData.class); if (phenoCollection != null) { criteria.add(Restrictions.eq("phenoCollection", phenoCollection)); }/*from ww w.j a va 2s . c o m*/ return criteria.list().size() > 0; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public String getDelimiterTypeByDelimiterChar(char delimiterCharacter) { String delimiterTypeName = null; Criteria criteria = getSession().createCriteria(DelimiterType.class); criteria.add(Restrictions.eq("delimiterCharacter", delimiterCharacter)); if (criteria.list().size() > 0) { DelimiterType delimiterType = (DelimiterType) criteria.list().get(0); delimiterTypeName = delimiterType.getName(); }//from www. ja va 2s. c o m return delimiterTypeName; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public FileFormat getFileFormatByName(String name) { FileFormat fileFormat = null;// ww w . j av a 2s . c o m Criteria criteria = getSession().createCriteria(FileFormat.class); criteria.add(Restrictions.eq("name", name)); if (criteria.list().size() > 0) { fileFormat = (FileFormat) criteria.list().get(0); } return fileFormat; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public Long isCustomFieldUsed(PhenoDataSetData phenoData) { Long count = new Long("0"); PhenoDataSetField phenoDataSetField = phenoData.getPhenoDataSetFieldDisplay().getPhenoDataSetField(); Study study = phenoDataSetField.getStudy(); ArkFunction arkFunction = phenoDataSetField.getArkFunction(); Criteria criteria = getSession().createCriteria(PhenoDataSetData.class, "pd"); criteria.createAlias("pd.customFieldDisplay", "cfd"); criteria.createAlias("cfd.customField", "cf"); criteria.createAlias("cf.arkFunction", "aF"); criteria.createAlias("cf.study", "s"); criteria.add(Restrictions.eq("aF.id", arkFunction.getId())); criteria.add(Restrictions.eq("cfd.id", phenoData.getPhenoDataSetFieldDisplay().getId())); criteria.add(Restrictions.eq("s.id", study.getId())); count = (Long) criteria.setProjection(Projections.rowCount()).uniqueResult(); return count; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public long getPhenoDataCount(PhenoDataSetCollection phenoCollection, PhenoDataSetCategory phenoDataSetCategory) { Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class); criteria.createAlias("phenoDataSetGroup", "qnaire"); if (phenoCollection.getQuestionnaire() != null) { criteria.add(Restrictions.eq("qnaire.id", phenoCollection.getQuestionnaire().getId())); }/* w w w.j a v a 2s . c o m*/ criteria.setProjection(Projections.rowCount()); Long count = (Long) criteria.uniqueResult(); return count.intValue(); }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public long getPhenoCollectionCount(PhenoDataCollectionVO collectionCriteria) { 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.setProjection(Projections.rowCount()); Long count = (Long) criteria.uniqueResult(); return count; }
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);//from w w w. j ava 2 s .c om 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 List<CustomField> getCustomFieldsLinkedToCustomFieldGroup(CustomFieldGroup customFieldCriteria) { Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class); criteria.add(Restrictions.eq("customFieldGroup", customFieldCriteria)); ProjectionList projectionList = Projections.projectionList(); projectionList.add(Projections.property("customField")); criteria.setProjection(projectionList); criteria.addOrder(Order.asc("sequence")); List<CustomField> fieldsList = criteria.list(); //log.warn("______________customFieldsList = " + fieldsList.size()); return fieldsList; }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
private List<CustomFieldDisplay> getCustomFieldDisplayForCustomFieldGroup(CustomFieldGroup customFieldGroup) { Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class); criteria.add(Restrictions.eq("customFieldGroup", customFieldGroup)); criteria.addOrder(Order.asc("sequence")); return criteria.list(); }
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);//from w ww . jav a2 s .c om criteria.setMaxResults(count); criteria.addOrder(Order.asc("phenoDataSetFiledOrderNumber")); return criteria.list(); }