Example usage for org.hibernate.criterion Restrictions eq

List of usage examples for org.hibernate.criterion Restrictions eq

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions eq.

Prototype

public static SimpleExpression eq(String propertyName, Object value) 

Source Link

Document

Apply an "equal" constraint to the named property

Usage

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

License:Open Source License

@Override
public List<StudyComp> getStudyComponentsNeverUsedInThisSubject(Study study,
        LinkSubjectStudy linkSubjectStudy) {
    List<StudyComp> consentStudyCompLst = getDifferentStudyComponentsInConsentForSubject(study,
            linkSubjectStudy);/*  ww w  .  j a v a 2s .  c om*/
    List<Long> consentStudyCompIdLst = new ArrayList<Long>();
    for (StudyComp studyComp : consentStudyCompLst) {
        consentStudyCompIdLst.add(studyComp.getId());
    }
    Criteria criteria = getSession().createCriteria(StudyComp.class);
    criteria.add(Restrictions.eq("study", study));
    if (!consentStudyCompIdLst.isEmpty()) {
        criteria.add(Restrictions.not(Restrictions.in("id", consentStudyCompIdLst)));
    }
    return criteria.list();
}

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.BioCollectionDao.java

License:Open Source License

public BioCollection getBioCollection(Long id) throws EntityNotFoundException {
    Criteria criteria = getSession().createCriteria(BioCollection.class);
    criteria.add(Restrictions.eq("id", id));

    BioCollection bioCollection = (BioCollection) criteria.uniqueResult();
    if (bioCollection == null) {
        throw new EntityNotFoundException("The BioCollection entity cannot be found.");
    }// w  w w.j av a2s . c o  m

    return bioCollection;
}

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

License:Open Source License

public java.util.List<BioCollection> searchBioCollection(BioCollection bioCollection)
        throws ArkSystemException {
    Criteria criteria = getSession().createCriteria(BioCollection.class);

    if (bioCollection.getId() != null)
        criteria.add(Restrictions.eq("id", bioCollection.getId()));

    if (bioCollection.getBiocollectionUid() != null)
        criteria.add(Restrictions.eq("biocollectionUid", bioCollection.getBiocollectionUid()));

    if (bioCollection.getName() != null)
        criteria.add(Restrictions.eq("name", bioCollection.getName()));

    if (bioCollection.getLinkSubjectStudy() != null)
        criteria.add(Restrictions.eq("linkSubjectStudy", bioCollection.getLinkSubjectStudy()));

    if (bioCollection.getStudy() != null)
        criteria.add(Restrictions.eq("study", bioCollection.getStudy()));

    if (bioCollection.getCollectionDate() != null)
        criteria.add(Restrictions.eq("collectionDate", bioCollection.getCollectionDate()));

    if (bioCollection.getSurgeryDate() != null)
        criteria.add(Restrictions.eq("surgeryDate", bioCollection.getSurgeryDate()));

    List<BioCollection> list = criteria.list();
    return list;// w ww.  j  av a2s .  co  m
}

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

License:Open Source License

public boolean doesSomeoneElseHaveThisUid(String biocollectionUid, final Study study,
        Long idToExcludeFromSearch) {
    Criteria criteria = getSession().createCriteria(BioCollection.class);
    criteria.add(Restrictions.eq("biocollectionUid", biocollectionUid));
    if (idToExcludeFromSearch != null) {
        criteria.add(Restrictions.ne("id", idToExcludeFromSearch));
    }//w  w  w . j  a  va  2s  .  com

    if (study != null) {
        criteria.add(Restrictions.eq("study", study));
    }
    return (criteria.list().size() > 0);
}

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

License:Open Source License

public BioCollectionUidTemplate getBioCollectionUidTemplate(Study study) {
    Criteria criteria = getSession().createCriteria(BioCollectionUidTemplate.class);
    criteria.add(Restrictions.eq("study", study));
    BioCollectionUidTemplate biocollectionUidTemplate = (BioCollectionUidTemplate) criteria.uniqueResult();
    return biocollectionUidTemplate;
}

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

License:Open Source License

public Boolean hasBioCollections(LinkSubjectStudy linkSubjectStudy) {
    // Use WHERE EXIST to optimise query even further
    StatelessSession session = getStatelessSession();
    Criteria criteria = session.createCriteria(LinkSubjectStudy.class, "lss");
    DetachedCriteria sizeCriteria = DetachedCriteria.forClass(BioCollection.class, "bc");
    criteria.add(Restrictions.eq("lss.id", linkSubjectStudy.getId()));
    sizeCriteria.add(Property.forName("lss.id").eqProperty("bc.linkSubjectStudy.id"));
    criteria.add(Subqueries.exists(sizeCriteria.setProjection(Projections.property("bc.id"))));
    criteria.setProjection(Projections.rowCount());
    Boolean result = ((Long) criteria.uniqueResult()) > 0L;
    session.close();//from  w w w .  j a  va  2s.  c o  m

    return result;
}

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

License:Open Source License

public Boolean hasBiospecimens(BioCollection bioCollection) {
    // Use WHERE EXIST to optimise query even further
    StatelessSession session = getStatelessSession();
    Criteria criteria = session.createCriteria(BioCollection.class, "bc");
    DetachedCriteria sizeCriteria = DetachedCriteria.forClass(Biospecimen.class, "b");
    criteria.add(Restrictions.eq("bc.id", bioCollection.getId()));
    sizeCriteria.add(Property.forName("bc.id").eqProperty("b.bioCollection.id"));
    criteria.add(Subqueries.exists(sizeCriteria.setProjection(Projections.property("b.id"))));
    criteria.setProjection(Projections.rowCount());
    Boolean result = ((Long) criteria.uniqueResult()) > 0L;
    session.close();/* w ww  . ja v a2 s. c om*/

    return result;
}

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

License:Open Source License

protected Criteria buildBioCollectionCriteria(BioCollection bioCollectionCriteria) {
    Criteria criteria = getSession().createCriteria(BioCollection.class);

    if (bioCollectionCriteria.getId() != null) {
        criteria.add(Restrictions.eq("id", bioCollectionCriteria.getId()));
    }/*w  ww .j av  a  2  s  .  c o  m*/

    if (bioCollectionCriteria.getBiocollectionUid() != null) {
        criteria.add(Restrictions.eq("biocollectionUid", bioCollectionCriteria.getBiocollectionUid()));
    }

    if (bioCollectionCriteria.getName() != null) {
        criteria.add(Restrictions.eq("name", bioCollectionCriteria.getName()));
    }

    if (bioCollectionCriteria.getLinkSubjectStudy() != null) {
        criteria.add(Restrictions.eq("linkSubjectStudy", bioCollectionCriteria.getLinkSubjectStudy()));
    }

    if (bioCollectionCriteria.getStudy() != null) {
        criteria.add(Restrictions.eq("study", bioCollectionCriteria.getStudy()));
    }

    if (bioCollectionCriteria.getCollectionDate() != null) {
        criteria.add(Restrictions.eq("collectionDate", bioCollectionCriteria.getCollectionDate()));
    }

    if (bioCollectionCriteria.getSurgeryDate() != null) {
        criteria.add(Restrictions.eq("surgeryDate", bioCollectionCriteria.getSurgeryDate()));
    }

    return criteria;
}

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

License:Open Source License

/**
 * This count can be based on CustomFieldDisplay alone (i.e. does not need left join to BioCollectionCustomFieldData)
 *///from   w  w w . j  a v a2s .co m
public long getBioCollectionCustomFieldDataCount(BioCollection bioCollectionCriteria, ArkFunction arkFunction) {
    Criteria criteria = getSession().createCriteria(CustomFieldDisplay.class);
    criteria.createAlias("customField", "cfield");
    //      criteria.add(Restrictions.eq("cfield.study", bioCollectionCriteria.getStudy()));

    // Added to allow child studies to inherit parent defined custom fields
    List studyList = new ArrayList();
    studyList.add(bioCollectionCriteria.getStudy());
    if (bioCollectionCriteria.getStudy().getParentStudy() != null
            && bioCollectionCriteria.getStudy().getParentStudy() != bioCollectionCriteria.getStudy()) {
        studyList.add(bioCollectionCriteria.getStudy().getParentStudy());
    }
    criteria.add(Restrictions.in("cfield.study", studyList));
    criteria.add(Restrictions.eq("cfield.arkFunction", arkFunction));
    criteria.setProjection(Projections.rowCount());
    return (Long) criteria.uniqueResult();
}