Example usage for org.hibernate Criteria createCriteria

List of usage examples for org.hibernate Criteria createCriteria

Introduction

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

Prototype

public Criteria createCriteria(String associationPath) throws HibernateException;

Source Link

Document

Create a new Criteria, "rooted" at the associated entity.

Usage

From source file:edu.monash.merc.dao.TrafficLightDAO.java

License:Open Source License

/**
 * {@inheritDoc}/*from   ww  w .  ja v a  2s .  co m*/
 */
public TrafficLight getTLByChromEnsemblAcVersionToken(ChromType chromType, String ensgAc, long versionId,
        int trackToken) {
    Criteria qCriteria = this.session().createCriteria(this.persistClass);

    Criteria tlGeneCriteria = qCriteria.createCriteria("tlGene");
    tlGeneCriteria.add(Restrictions.eq("chromosome", chromType.chm()));

    Disjunction orConds = Restrictions.disjunction();
    orConds.add(Restrictions.eq("ensgAccession", ensgAc));
    tlGeneCriteria.add(orConds);
    Criteria tpbVCriteria = qCriteria.createCriteria("tpbVersion");
    tpbVCriteria.add(Restrictions.eq("id", versionId));
    tpbVCriteria.add(Restrictions.eq("trackToken", trackToken));
    return (TrafficLight) qCriteria.uniqueResult();
}

From source file:edu.monash.merc.dao.TrafficLightDAO.java

License:Open Source License

/**
 * {@inheritDoc}/*from ww  w.ja  v  a  2 s .c o  m*/
 */
@SuppressWarnings("unchecked")
public Pagination<TrafficLight> getVersionTrafficLight(ChromType chromType, int trackToken, long versionId,
        int startPage, int recordsPerPage, OrderBy[] orderConds) {

    Criteria tlCriteria = this.session().createCriteria(this.persistClass);
    Criteria tlgCriteria = tlCriteria.createCriteria("tlGene");
    Criteria tpbVCriteria = tlCriteria.createCriteria("tpbVersion");
    tlgCriteria.add(Restrictions.eq("chromosome", chromType.chm()));
    // tlgCriteria.add(Restrictions.in("displayName", geneNames));
    tpbVCriteria.add(Restrictions.eq("id", versionId));
    tpbVCriteria.add(Restrictions.eq("trackToken", trackToken));
    tlCriteria.setProjection(Projections.rowCount());
    int total = ((Long) tlCriteria.uniqueResult()).intValue();
    //get all results
    if (recordsPerPage == -1) {
        recordsPerPage = total;
        startPage = 1;
    }
    Pagination<TrafficLight> ptl = new Pagination<TrafficLight>(startPage, recordsPerPage, total);

    Criteria tlQCriteria = this.session().createCriteria(this.persistClass);
    Criteria tlgQCriteria = tlQCriteria.createCriteria("tlGene");
    Criteria tpbVQCriteria = tlQCriteria.createCriteria("tpbVersion");
    tlgQCriteria.add(Restrictions.eq("chromosome", chromType.chm()));
    tpbVQCriteria.add(Restrictions.eq("id", versionId));
    tpbVQCriteria.add(Restrictions.eq("trackToken", trackToken));
    // add orders
    if (orderConds != null && orderConds.length > 0) {
        for (int i = 0; i < orderConds.length; i++) {
            Order order = orderConds[i].getOrder();
            if (order != null) {
                tlgQCriteria.addOrder(order);
            }
        }
    }
    tlQCriteria.setFirstResult(ptl.getFirstResult());
    tlQCriteria.setMaxResults(ptl.getSizePerPage());

    List<TrafficLight> tlList = tlQCriteria.list();
    ptl.setPageResults(tlList);
    return ptl;
}

From source file:edu.monash.merc.dao.TrafficLightDAO.java

License:Open Source License

/**
 * {@inheritDoc}/*  w ww .  j ava2 s . c om*/
 */
@SuppressWarnings("unchecked")
public Pagination<TrafficLight> getVersionTrafficLight(TLSearchBean tlSearchBean, int startPage,
        int recordsPerPage, OrderBy[] orderConds) {

    String chromType = tlSearchBean.getSelectedChromType();
    int token = tlSearchBean.getCombinatedToken();
    long versionId = tlSearchBean.getSelectedVersion();
    boolean chromRegionProvided = tlSearchBean.isRegionProvided();
    boolean geneListProvided = tlSearchBean.isGeneListProvided();

    boolean typeLevelProvided = tlSearchBean.isTypeLevelProvided();

    Criteria tlCrt = this.session().createCriteria(this.persistClass);

    if (typeLevelProvided) {
        addTypeColorLevelConditions(tlCrt, tlSearchBean);
    }

    Criteria tlGeneCrt = tlCrt.createCriteria("tlGene");

    Criteria tpbVersionCrt = tlCrt.createCriteria("tpbVersion");
    tlGeneCrt.add(Restrictions.eq("chromosome", chromType));
    //chromosome region provided
    if (chromRegionProvided) {
        addChromRegionConditions(tlGeneCrt, tlSearchBean);
    }
    //gene list provided
    if (geneListProvided) {
        addGeneListConditions(tlGeneCrt, tlSearchBean);
    }

    tpbVersionCrt.add(Restrictions.eq("id", versionId));
    tpbVersionCrt.add(Restrictions.eq("trackToken", token));
    tlCrt.setProjection(Projections.rowCount());

    int total = ((Long) tlCrt.uniqueResult()).intValue();
    //get all results
    if (recordsPerPage == -1) {
        recordsPerPage = total;
        startPage = 1;
    }

    Pagination<TrafficLight> paginationTl = new Pagination<TrafficLight>(startPage, recordsPerPage, total);

    Criteria tlCriteria = this.session().createCriteria(this.persistClass);

    if (typeLevelProvided) {
        addTypeColorLevelConditions(tlCriteria, tlSearchBean);
    }

    Criteria tlGeneCriteria = tlCriteria.createCriteria("tlGene");

    Criteria tpbVersionCriteria = tlCriteria.createCriteria("tpbVersion");
    tlGeneCriteria.add(Restrictions.eq("chromosome", chromType));

    //chromosome region provided
    if (chromRegionProvided) {
        addChromRegionConditions(tlGeneCriteria, tlSearchBean);
    }
    //gene list provided
    if (geneListProvided) {
        addGeneListConditions(tlGeneCriteria, tlSearchBean);
    }

    //tpb version
    tpbVersionCriteria.add(Restrictions.eq("id", versionId));
    tpbVersionCriteria.add(Restrictions.eq("trackToken", token));
    // add orders
    if (orderConds != null && orderConds.length > 0) {
        for (int i = 0; i < orderConds.length; i++) {
            Order order = orderConds[i].getOrder();
            if (order != null) {
                tlGeneCriteria.addOrder(order);
            }
        }
    }
    tlCriteria.setFirstResult(paginationTl.getFirstResult());
    tlCriteria.setMaxResults(paginationTl.getSizePerPage());

    List<TrafficLight> tlList = tlCriteria.list();
    paginationTl.setPageResults(tlList);

    return paginationTl;
}

From source file:edu.monash.merc.dao.TrafficLightDAO.java

License:Open Source License

private void addSpecificTPBTypeColorLevelConditions(Criteria criteria, String dataType,
        List<Integer> colorLevels) {
    //convert the dataType into DataType
    DataType tpbDataType = DataType.fromType(dataType);
    //PE//from ww w  . j av a2s  .  c  o m
    if (DataType.PE.equals(tpbDataType)) {
        Criteria peColorCriteria = criteria.createCriteria("tlPEColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            peColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE MS
    if (DataType.PE_MS.equals(tpbDataType)) {
        Criteria peMsColorCriteria = criteria.createCriteria("tlPEMSColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peMsColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peMsColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE MS Ann
    if (DataType.PE_MS_ANN.equals(tpbDataType)) {
        Criteria peMsAnnColorCriteria = criteria.createCriteria("tlPEMSANNColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peMsAnnColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peMsAnnColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE MS Prob
    if (DataType.PE_MS_PROB.equals(tpbDataType)) {
        Criteria peMsProbColorCriteria = criteria.createCriteria("tlPEMSPROBColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peMsProbColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peMsProbColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE MS Sam
    if (DataType.PE_MS_SAM.equals(tpbDataType)) {
        Criteria peMsSamColorCriteria = criteria.createCriteria("tlPEMSSAMColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peMsSamColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peMsSamColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE ANTI
    if (DataType.PE_ANTI.equals(tpbDataType)) {
        Criteria peAntiColorCriteria = criteria.createCriteria("tlPEANTIColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peAntiColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peAntiColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE ANTI ANN
    if (DataType.PE_ANTI_ANN.equals(tpbDataType)) {
        Criteria peAntiAnnColorCriteria = criteria.createCriteria("tlPEANTIANNColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peAntiAnnColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peAntiAnnColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE ANTI IHC
    if (DataType.PE_ANTI_IHC.equals(tpbDataType)) {
        Criteria peAntiIhcColorCriteria = criteria.createCriteria("tlPEANTIIHCColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peAntiIhcColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peAntiIhcColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE ANTI IHC Norm
    if (DataType.PE_ANTI_IHC_NORM.equals(tpbDataType)) {
        Criteria peAntiIhcNormColorCriteria = criteria.createCriteria("tlPEANTIIHCNORMColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peAntiIhcNormColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peAntiIhcNormColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE OTH
    if (DataType.PE_OTH.equals(tpbDataType)) {
        Criteria peOthColorCriteria = criteria.createCriteria("tlPEOTHColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peOthColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peOthColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PE OTH Cur
    if (DataType.PE_OTH_CUR.equals(tpbDataType)) {
        Criteria peOthCurColorCriteria = criteria.createCriteria("tlPEOTHCURColor");
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            peOthCurColorCriteria.add(colorLevelOr);
        }
        if (colorLevels != null && colorLevels.size() == 1) {
            peOthCurColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PTM
    if (DataType.PTM.equals(tpbDataType)) {
        Criteria ptmColorCriteria = criteria.createCriteria("tlPTMColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            ptmColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            ptmColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PTM PHS
    if (DataType.PTM_PHS.equals(tpbDataType)) {
        Criteria ptmPhsColorCriteria = criteria.createCriteria("tlPTMPHSColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            ptmPhsColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            ptmPhsColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PTM PHS SER
    if (DataType.PTM_PHS_SER.equals(tpbDataType)) {
        Criteria ptmPhsSerColorCriteria = criteria.createCriteria("tlPTMPHSSERColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            ptmPhsSerColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            ptmPhsSerColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PTM PHS THR
    if (DataType.PTM_PHS_THR.equals(tpbDataType)) {
        Criteria ptmPhsThrColorCriteria = criteria.createCriteria("tlPTMPHSTHRColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            ptmPhsThrColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            ptmPhsThrColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PTM PHS TYR
    if (DataType.PTM_PHS_TYR.equals(tpbDataType)) {
        Criteria ptmPhsTyrColorCriteria = criteria.createCriteria("tlPTMPHSTYRColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            ptmPhsTyrColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            ptmPhsTyrColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PTM ACE
    if (DataType.PTM_ACE.equals(tpbDataType)) {
        Criteria ptmAceColorCriteria = criteria.createCriteria("tlPTMACEColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            ptmAceColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            ptmAceColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PTM ACE LYS
    if (DataType.PTM_ACE_LYS.equals(tpbDataType)) {
        Criteria ptmAceLysColorCriteria = criteria.createCriteria("tlPTMACELYSColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            ptmAceLysColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            ptmAceLysColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //PTM ACE NTA
    if (DataType.PTM_ACE_NTA.equals(tpbDataType)) {
        Criteria ptmAceNtaColorCriteria = criteria.createCriteria("tlPTMACENTAColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            ptmAceNtaColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            ptmAceNtaColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //TE
    if (DataType.TE.equals(tpbDataType)) {
        Criteria teColorCriteria = criteria.createCriteria("tlTEColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            teColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            teColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //TE MA
    if (DataType.TE_MA.equals(tpbDataType)) {
        Criteria teMaColorCriteria = criteria.createCriteria("tlTEMAColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            teMaColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            teMaColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //TE MA PROP
    if (DataType.TE_MA_PROP.equals(tpbDataType)) {
        Criteria teMaPropColorCriteria = criteria.createCriteria("tlTEMAPROPColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            teMaPropColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            teMaPropColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //TE OTH
    if (DataType.TE_OTH.equals(tpbDataType)) {
        Criteria teOthColorCriteria = criteria.createCriteria("tlTEOTHColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            teOthColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            teOthColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

    //TE OTH CUR
    if (DataType.TE_OTH_CUR.equals(tpbDataType)) {
        Criteria teOthCurColorCriteria = criteria.createCriteria("tlTEOTHCURColor");
        //color level size is great than one. we use or condition
        if (colorLevels != null && colorLevels.size() > 1) {
            Disjunction colorLevelOr = Restrictions.disjunction();
            for (Integer level : colorLevels) {
                colorLevelOr.add(Restrictions.eq("colorLevel", level.intValue()));
            }
            teOthCurColorCriteria.add(colorLevelOr);
        }
        //if only on color level, we just use eq condition
        if (colorLevels != null && colorLevels.size() == 1) {
            teOthCurColorCriteria.add(Restrictions.eq("colorLevel", colorLevels.get(0).intValue()));
        }
    }

}

From source file:edu.monash.merc.dao.TrafficLightDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
private List<Long> getAllTrafficLight(TLSearchBean tlSearchBean) {

    String chromType = tlSearchBean.getSelectedChromType();
    int token = tlSearchBean.getCombinatedToken();
    long versionId = tlSearchBean.getSelectedVersion();
    boolean chromRegionProvided = tlSearchBean.isRegionProvided();
    boolean geneListProvided = tlSearchBean.isGeneListProvided();

    boolean typeLevelProvided = tlSearchBean.isTypeLevelProvided();

    Criteria tlCriteria = this.session().createCriteria(this.persistClass);

    if (typeLevelProvided) {
        addTypeColorLevelConditions(tlCriteria, tlSearchBean);
    }/*ww w. ja v  a  2  s.co  m*/

    Criteria tlGeneCriteria = tlCriteria.createCriteria("tlGene");

    Criteria tpbVersionCriteria = tlCriteria.createCriteria("tpbVersion");
    tlGeneCriteria.add(Restrictions.eq("chromosome", chromType));

    //chromosome region provided
    if (chromRegionProvided) {
        addChromRegionConditions(tlGeneCriteria, tlSearchBean);
    }

    //gene list provided
    if (geneListProvided) {
        addGeneListConditions(tlGeneCriteria, tlSearchBean);
    }

    //tpb version
    tpbVersionCriteria.add(Restrictions.eq("id", versionId));

    tpbVersionCriteria.add(Restrictions.eq("trackToken", token));
    tlCriteria.setProjection(Projections.property("id"));
    return tlCriteria.list();
}

From source file:edu.monash.merc.dao.TrafficLightDAO.java

License:Open Source License

private int countEvidenceNumByLevel(List<Long> tlIds, DataType dataType, int level) {
    Criteria tlCrt = this.session().createCriteria(this.persistClass);
    tlCrt.add(Restrictions.in("id", tlIds));
    String tlColor = null;//from  w  w w.  j  a va2s .  c o  m

    //PE
    if (DataType.PE.equals(dataType)) {
        tlColor = "tlPEColor";
    }
    if (DataType.PE_MS.equals(dataType)) {
        tlColor = "tlPEMSColor";
    }
    if (DataType.PE_MS_ANN.equals(dataType)) {
        tlColor = "tlPEMSANNColor";
    }
    if (DataType.PE_MS_PROB.equals(dataType)) {
        tlColor = "tlPEMSPROBColor";
    }
    if (DataType.PE_MS_SAM.equals(dataType)) {
        tlColor = "tlPEMSSAMColor";
    }
    if (DataType.PE_ANTI.equals(dataType)) {
        tlColor = "tlPEANTIColor";
    }
    if (DataType.PE_ANTI_ANN.equals(dataType)) {
        tlColor = "tlPEANTIANNColor";
    }
    if (DataType.PE_ANTI_IHC.equals(dataType)) {
        tlColor = "tlPEANTIIHCColor";
    }
    if (DataType.PE_ANTI_IHC_NORM.equals(dataType)) {
        tlColor = "tlPEANTIIHCNORMColor";
    }
    if (DataType.PE_OTH.equals(dataType)) {
        tlColor = "tlPEOTHColor";
    }
    if (DataType.PE_OTH_CUR.equals(dataType)) {
        tlColor = "tlPEOTHCURColor";
    }
    //PTM
    if (DataType.PTM.equals(dataType)) {
        tlColor = "tlPTMColor";
    }
    if (DataType.PTM_PHS.equals(dataType)) {
        tlColor = "tlPTMPHSColor";
    }
    if (DataType.PTM_PHS_SER.equals(dataType)) {
        tlColor = "tlPTMPHSSERColor";
    }
    if (DataType.PTM_PHS_THR.equals(dataType)) {
        tlColor = "tlPTMPHSTHRColor";
    }
    if (DataType.PTM_PHS_TYR.equals(dataType)) {
        tlColor = "tlPTMPHSTYRColor";
    }
    if (DataType.PTM_ACE.equals(dataType)) {
        tlColor = "tlPTMACEColor";
    }
    if (DataType.PTM_ACE_LYS.equals(dataType)) {
        tlColor = "tlPTMACELYSColor";
    }
    if (DataType.PTM_ACE_NTA.equals(dataType)) {
        tlColor = "tlPTMACENTAColor";
    }

    //TE
    if (DataType.TE.equals(dataType)) {
        tlColor = "tlTEColor";
    }
    //TE MA
    if (DataType.TE_MA.equals(dataType)) {
        tlColor = "tlTEMAColor";
    }
    //TE MA PROP
    if (DataType.TE_MA_PROP.equals(dataType)) {
        tlColor = "tlTEMAPROPColor";
    }
    //TE OTH
    if (DataType.TE_OTH.equals(dataType)) {
        tlColor = "tlTEOTHColor";
    }
    //TE OTH CUR
    if (DataType.TE_OTH_CUR.equals(dataType)) {
        tlColor = "tlTEOTHCURColor";
    }

    Criteria levelCriteria = tlCrt.createCriteria(tlColor);
    levelCriteria.add((Restrictions.eq("colorLevel", level)));
    tlCrt.setProjection(Projections.rowCount());
    return ((Long) tlCrt.uniqueResult()).intValue();
}

From source file:edu.monash.merc.dao.TrafficLightDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from  w w w .j  a  va2s.  c o m*/
public List<TrafficLight> getTrafficLightsByChromAndTPBVersion(ChromType chromType, TPBVersion tpbVersion) {
    Criteria tlQCriteria = this.session().createCriteria(this.persistClass);
    Criteria tlgQCriteria = tlQCriteria.createCriteria("tlGene");
    Criteria tpbVQCriteria = tlQCriteria.createCriteria("tpbVersion");
    tlgQCriteria.add(Restrictions.eq("chromosome", chromType.chm()));
    tpbVQCriteria.add(Restrictions.eq("id", tpbVersion.getId()));
    tpbVQCriteria.add(Restrictions.eq("trackToken", tpbVersion.getTrackToken()));
    return tlQCriteria.list();
}

From source file:edu.northwestern.bioinformatics.studycalendar.dao.ActivityDao.java

License:BSD License

private Criteria defaultCriteria() {
    Criteria base = getSession().createCriteria(Activity.class);
    base.createCriteria("type").addOrder(Order.asc("name").ignoreCase());
    base.addOrder(Order.asc("name").ignoreCase());
    return base;//from  ww w .j  ava 2  s  . c  o m
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardChainTree.java

License:Open Source License

@SuppressWarnings("unchecked")
private void loadAllCardsTL() {
    Criteria crit = HSess.get().createCriteria(Card.class).add(Restrictions.eq("factCard", false))
            .add(Restrictions.eq("hidden", false)).addOrder(Order.desc("creationDate"));
    crit = crit.createCriteria("cardType").add(Restrictions.eq("cardClass", CardType.CardClass.POSITIVEIDEA));

    User me = Mmowgli2UI.getGlobals().getUserTL();

    Card.adjustCriteriaToOmitCardsTL(crit, me);

    List<Card> resourceCards = (List<Card>) crit.list();
    for (Card c : resourceCards)
        loadRootTL(c);/*ww  w . ja  va2  s.  co m*/

    // Second root card type
    CardType riskTyp = CardType.getCurrentNegativeIdeaCardTypeTL();
    crit = HSess.get().createCriteria(Card.class).add(Restrictions.eq("cardType", riskTyp))
            .add(Restrictions.eq("factCard", false)).add(Restrictions.eq("hidden", false))
            .addOrder(Order.desc("creationDate"));
    crit = crit.createCriteria("cardType").add(Restrictions.eq("cardClass", CardType.CardClass.NEGATIVEIDEA));

    Card.adjustCriteriaToOmitCardsTL(crit, me);

    List<Card> riskCards = (List<Card>) crit.list();
    for (Card c : riskCards)
        loadRootTL(c);
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardDbHelper.java

License:Open Source License

@SuppressWarnings("unchecked")
public static List<Card> getCardsByCardClass(Session sess, CardType.CardClass cls) {
    Criteria crit = sess.createCriteria(Card.class).add(Restrictions.eq("factCard", false))
            .addOrder(Order.desc("creationDate"));
    crit = crit.createCriteria("cardType").add(Restrictions.eq("cardClass", cls));
    return (List<Card>) crit.list();
}