Example usage for org.hibernate.criterion Projections projectionList

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

Introduction

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

Prototype

public static ProjectionList projectionList() 

Source Link

Document

Create a new projection list.

Usage

From source file:au.org.theark.core.dao.StudyDao.java

License:Open Source License

@Override
public List<StudyComp> getDifferentStudyComponentsInConsentForSubject(Study study,
        LinkSubjectStudy linkSubjectStudy) {
    Criteria criteria = getSession().createCriteria(Consent.class);
    criteria.add(Restrictions.eq("study", study));
    criteria.add(Restrictions.eq("linkSubjectStudy", linkSubjectStudy));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("studyComp"));
    criteria.setProjection(projectionList);
    criteria.addOrder(Order.asc("id"));
    List<StudyComp> fieldsList = criteria.list();
    return fieldsList;
}

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

License:Open Source License

public List<InvSite> searchInvSite(InvSite invSite, List<Study> studyList) throws ArkSystemException {
    List<InvSite> invSiteList = new ArrayList<InvSite>(0);

    if (studyList == null || studyList.isEmpty()) {
        return invSiteList;
    }/* ww  w  . j  a  v a2s.c  o m*/

    Criteria criteria = getSession().createCriteria(StudyInvSite.class);

    /*
     * if (invSite.getId() != null) { criteria.add(Restrictions.eq("id", invSite.getId())); }
     * 
     * if (invSite.getName() != null) { criteria.add(Restrictions.eq("name", invSite.getName())); }
     * 
     * if (invSite.getContact() != null) { criteria.add(Restrictions.eq("contact", invSite.getContact())); }
     * 
     * if (invSite.getAddress() != null) { criteria.add(Restrictions.eq("address", invSite.getAddress())); }
     * 
     * if (invSite.getPhone() != null) { criteria.add(Restrictions.eq("phone", invSite.getPhone())); }
     */
    /*if you have an empty grouping, hibernate will do this sort of this;
     * select
            this_.INV_SITE_ID as y0_ 
        from
            lims.study_inv_site this_ 
        where
            this_.STUDY_ID in (
            
            ) 
        group by
            this_.INV_SITE_ID
            ...therefore always null check before checking if something is in a group of nothing
             */
    criteria.add(Restrictions.in("study", studyList));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("invSite"), "invSite");
    criteria.setProjection(projectionList);

    // List<StudyInvSite> list = criteria.list();
    invSiteList = criteria.list();
    /*
     * for(StudyInvSite studyInvSite : list){ invSiteList.add(studyInvSite.getInvSite()); }
     */
    return invSiteList;
}

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));
        }//w w w  .j av  a 2 s.  c o  m
    }

    return count;
}

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

/**
 * The method checks if the given questionnaire's fields have data linked to it.
 * /*from   w  w w  .  j  a va  2s . co m*/
 * @param customFieldGroup
 */
public void isDataAvailableForQuestionnaire(CustomFieldGroup customFieldGroup) {

    Criteria criteria = getSession().createCriteria(CustomField.class, "cf");
    criteria.createAlias("customFieldDisplay", "cfd", JoinType.LEFT_OUTER_JOIN); // Left join to CustomFieldDisplay
    criteria.createAlias("cfd.customFieldGroup", "cfg", JoinType.LEFT_OUTER_JOIN); // Left join to CustomFieldGroup
    criteria.add(Restrictions.eq("cf.study", customFieldGroup.getStudy()));

    ArkFunction function = iArkCommonService
            .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY);
    criteria.add(Restrictions.eq("cf.arkFunction", function));
    criteria.add(Restrictions.eq("cfg.id", customFieldGroup.getId()));

    DetachedCriteria fieldDataCriteria = DetachedCriteria.forClass(PhenoDataSetData.class, "pd");
    // Join CustomFieldDisplay and PhenoData on ID FK
    fieldDataCriteria.add(Property.forName("cfd.id").eqProperty("pd." + "customFieldDisplay.id"));
    criteria.add(
            Subqueries.exists(fieldDataCriteria.setProjection(Projections.property("pd.customFieldDisplay"))));

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("cfg.name"), "questionnaire");
    projectionList.add(Projections.property("cf.name"), "fieldName");
    projectionList.add(Projections.property("cf.description"), "description");

}

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

License:Open Source License

public List<PhenoDataSetGroup> getPhenoDataSetGroupsByLinkSubjectStudy(LinkSubjectStudy linkSubjectStudy) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetCollection.class);
    criteria.add(Restrictions.eq("linkSubjectStudy", linkSubjectStudy));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("questionnaire"), "questionnaire");
    criteria.setProjection(projectionList);
    criteria.setResultTransformer(Transformers.aliasToBean(PhenoDataSetCollection.class));
    List<PhenoDataSetCollection> phenoDataSetCollections = (List<PhenoDataSetCollection>) criteria.list();
    List<PhenoDataSetGroup> phenoDataSetGroups = new ArrayList<PhenoDataSetGroup>();
    for (PhenoDataSetCollection phenoDataSetCollection : phenoDataSetCollections) {
        phenoDataSetGroups.add(phenoDataSetCollection.getQuestionnaire());
    }/* ww  w  .j av  a 2  s .co m*/
    return phenoDataSetGroups;
}

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

License:Open Source License

@Override
public List<PhenoDataSetField> getPhenoDataSetFieldsLinkedToPhenoDataSetFieldGroup(
        PhenoDataSetGroup phenoDataSetGroupCriteria) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class);
    criteria.add(Restrictions.eq("phenoDataSetGroup", phenoDataSetGroupCriteria));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("phenoDataSetField"));
    criteria.setProjection(projectionList);
    criteria.addOrder(Order.asc("phenoDataSetFiledOrderNumber"));
    List<PhenoDataSetField> fieldsList = criteria.list();
    return fieldsList;
}

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

License:Open Source License

@Override
public List<PhenoDataSetFieldDisplay> getPhenoDataSetFieldDisplayForPhenoDataSetFieldGroupOrderByPhenoDataSetCategory(
        PhenoDataSetGroup phenoDataSetGroup) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetFieldDisplay.class);
    criteria.add(Restrictions.eq("phenoDataSetGroup", phenoDataSetGroup));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("phenoDataSetGroup"), "phenoDataSetGroup");
    projectionList.add(Projections.groupProperty("phenoDataSetCategory"), "phenoDataSetCategory");
    projectionList.add(Projections.groupProperty("parentPhenoDataSetCategory"), "parentPhenoDataSetCategory");
    projectionList.add(Projections.groupProperty("phenoDataSetCategoryOrderNumber"),
            "phenoDataSetCategoryOrderNumber");
    criteria.setProjection(projectionList);
    criteria.addOrder(Order.asc("phenoDataSetCategoryOrderNumber"));
    criteria.setResultTransformer(Transformers.aliasToBean(PhenoDataSetFieldDisplay.class));
    return (List<PhenoDataSetFieldDisplay>) criteria.list();
}

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

License:Open Source License

@Override
public List<Boolean> getPublishedSatusLst(Study study, ArkFunction arkFunction) {
    Criteria criteria = getSession().createCriteria(PhenoDataSetGroup.class);
    criteria.add(Restrictions.eq("study", study));
    criteria.add(Restrictions.eq("arkFunction", arkFunction));
    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.groupProperty("published"), "published");
    criteria.setProjection(projectionList);
    criteria.setResultTransformer(Transformers.aliasToBean(PhenoDataSetGroup.class));
    List<PhenoDataSetGroup> phenoDataSetGroups = (List<PhenoDataSetGroup>) criteria.list();
    List<Boolean> pubishStatusLst = new ArrayList<Boolean>();
    for (PhenoDataSetGroup phenoDataSetGroup : phenoDataSetGroups) {
        pubishStatusLst.add(phenoDataSetGroup.getPublished());
    }// w w  w  . jav  a 2s . co  m
    return pubishStatusLst;
}

From source file:au.org.theark.report.model.dao.ReportDao.java

License:Open Source License

public Map<String, Long> getSubjectStatusCounts(Study study) {
    Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class);
    criteria.add(Restrictions.eq("study", study));
    ProjectionList projectionList = Projections.projectionList();
    criteria.createAlias("subjectStatus", "subjectStatusAlias");
    projectionList.add(Projections.groupProperty("subjectStatusAlias.name"));
    projectionList.add(Projections.rowCount());
    criteria.setProjection(projectionList);
    List results = criteria.list();
    Map<String, Long> statusMap = new HashMap<String, Long>();
    for (Object r : results) {
        Object[] obj = (Object[]) r;
        String statusName = (String) obj[0];
        statusMap.put(statusName, (Long) obj[1]);
    }/*from ww  w .j  av a  2 s .  c  o  m*/
    return statusMap;
}