Example usage for org.hibernate Criteria list

List of usage examples for org.hibernate Criteria list

Introduction

In this page you can find the example usage for org.hibernate Criteria list.

Prototype

public List list() throws HibernateException;

Source Link

Document

Get the results.

Usage

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

public java.util.Collection<PhenoDataSetCollection> getPhenoCollectionByStudy(Study study) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetCollection.class);

    if (study != null) {
        criteria.add(Restrictions.eq(au.org.theark.phenotypic.web.Constants.PHENO_COLLECTION_STUDY, study));
    }//  w w  w  . j a  v a  2s  .c  o  m
    criteria.addOrder(Order.asc("name"));

    java.util.List<PhenoDataSetCollection> collectionList = criteria.list();
    return collectionList;
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

public java.util.Collection<FileFormat> getFileFormats() {
    Criteria criteria = getSession().createCriteria(FileFormat.class);
    java.util.Collection<FileFormat> fileFormatCollection = criteria.list();
    return fileFormatCollection;
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

public long getCountOfCollectionsInStudy(Study study) {
    int count = 0;

    if (study.getId() != null) {
        Criteria criteria = getSession().createCriteria(PhenoDataSetCollection.class);
        criteria.add(Restrictions.eq("study", study));

        java.util.Collection<PhenoDataSetCollection> phenoCollection = criteria.list();
        count = phenoCollection.size();/*www .  jav  a2 s  .c om*/
    }

    return count;
}

From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java

License:Open Source License

public long getCountOfCollectionsWithDataInStudy(Study study) {
    long count = 0;

    if (study.getId() != null) {
        Collection<PhenoDataSetCollection> phenoCollectionColn = getPhenoCollectionByStudy(study);

        for (Iterator iterator = phenoCollectionColn.iterator(); iterator.hasNext();) {
            PhenoDataSetCollection phenoCollection = (PhenoDataSetCollection) iterator.next();

            Criteria criteria = getSession().createCriteria(PhenoDataSetData.class);
            criteria.add(Restrictions.eq("phenCollection", phenoCollection));
            ProjectionList projList = Projections.projectionList();
            projList.add(Projections.countDistinct("collection"));
            criteria.setProjection(projList);
            List list = criteria.list();
            count = count + ((Long) list.get(0));
        }//from   w  ww. java 2s.  c  o m
    }

    return count;
}

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  .  ja v  a  2  s . 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 w w  w  .  ja v a 2 s  . co 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;//from   ww  w  .j a  va 2  s  .  c  om
    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 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);/*  w w  w.  j av  a2 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

public List<QuestionnaireStatus> getPhenoCollectionStatusList() {
    List<QuestionnaireStatus> resultList = new ArrayList<QuestionnaireStatus>(0);
    Criteria criteria = getSession().createCriteria(QuestionnaireStatus.class);
    resultList = criteria.list();
    return resultList;
}