Example usage for org.hibernate.criterion Projections rowCount

List of usage examples for org.hibernate.criterion Projections rowCount

Introduction

In this page you can find the example usage for org.hibernate.criterion Projections rowCount.

Prototype

public static Projection rowCount() 

Source Link

Document

The query row count, ie.

Usage

From source file:au.org.theark.lims.model.dao.BiospecimenDao.java

License:Open Source License

public long getBiospecimenCount(LimsVO limsVo) {
    Criteria criteria = buildBiospecimenCriteria(limsVo);
    criteria.setProjection(Projections.rowCount());
    Long totalCount = (Long) criteria.uniqueResult();
    return totalCount.intValue();
}

From source file:au.org.theark.lims.model.dao.BiospecimenDao.java

License:Open Source License

public long getBiospecimenCustomFieldDataCount(Biospecimen biospecimenCriteria, ArkFunction arkFunction) {
    Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class);
    criteria.createAlias("customField", "cfield");

    // Allow child studies to inherit parent defined custom fields
    List studyList = new ArrayList();
    studyList.add(biospecimenCriteria.getStudy());
    if (biospecimenCriteria.getStudy().getParentStudy() != null
            && biospecimenCriteria.getStudy().getParentStudy() != biospecimenCriteria.getStudy()) {
        studyList.add(biospecimenCriteria.getStudy().getParentStudy());
    }/*w  w  w .java 2  s  .  com*/

    criteria.add(Restrictions.in("cfield.study", studyList));
    criteria.add(Restrictions.eq("cfield.arkFunction", arkFunction));
    criteria.setProjection(Projections.rowCount());
    return (Long) criteria.uniqueResult();
}

From source file:au.org.theark.lims.model.dao.BioTransactionDao.java

License:Open Source License

public long getBioTransactionCount(BioTransaction bioTransaction) {
    // Handle for biospecimen not in context
    if (bioTransaction.getBiospecimen() == null) {
        return 0L;
    }//ww  w.  j av  a  2s  .  c  om
    Criteria criteria = buildBioTransactionCriteria(bioTransaction);
    criteria.setProjection(Projections.rowCount());

    return (Long) criteria.uniqueResult();
}

From source file:au.org.theark.lims.model.dao.LimsSubjectDao.java

License:Open Source License

public long getSubjectCount(LimsVO limsVo, List<Study> studyList) {
    if (studyList != null && !studyList.isEmpty()) {
        Criteria criteria = buildGeneralSubjectCriteria(limsVo, studyList);
        criteria.setProjection(Projections.rowCount());
        Long totalCount = (Long) criteria.uniqueResult();
        return totalCount.intValue();
    } else {/*  ww  w. j av a 2  s.  co m*/
        // Fixes to handle for if the studyList is empty (i.e. don't bother querying the database)
        return 0;
    }
}

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()));
    }/*from w  w  w .  j  a  v  a  2 s . 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 long getCFDLinkedToQuestionnaireCount(PhenoDataSetGroup phenoDataSetGroup) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class);
    criteria.add(Restrictions.eq("phenoDataSetGroup", phenoDataSetGroup));
    criteria.setProjection(Projections.rowCount());
    return (Long) criteria.uniqueResult();
}

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

License:Open Source License

@Override
public long getPhenoDataSetCategoryCount(PhenoDataSetCategory phenoDataSetCategoryCriteria) {
    // Handle for study or function not in context
    if (phenoDataSetCategoryCriteria.getStudy() == null
            || phenoDataSetCategoryCriteria.getArkFunction() == null) {
        return 0;
    }/*from   w ww .j a va 2s . c  om*/
    Criteria criteria = buildGeneralPhenoDataSetCategoryCritera(phenoDataSetCategoryCriteria);
    criteria.setProjection(Projections.rowCount());
    Long totalCount = (Long) criteria.uniqueResult();
    return totalCount;
}

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

License:Open Source License

public long getPhenoFieldCount(PhenoDataSetField phenofieldcriteria) {
    // Handle for study or function not in context
    if (phenofieldcriteria.getStudy() == null || phenofieldcriteria.getArkFunction() == null) {
        return 0;
    }/*from  w  w  w.j a  v  a 2  s . c om*/
    Criteria criteria = buildGeneralPhenoFieldCritera(phenofieldcriteria);
    criteria.setProjection(Projections.rowCount());
    Long totalCount = (Long) criteria.uniqueResult();
    return totalCount;
}