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.lims.model.dao.InventoryDao.java

License:Open Source License

public InvFreezer getInvFreezer(Long id) {
    InvFreezer invFreezer = new InvFreezer();
    Criteria criteria = getSession().createCriteria(InvFreezer.class);

    if (id != null) {
        criteria.add(Restrictions.eq("id", id));
    }//w  ww .  j a  v  a2s.c o  m

    List<InvFreezer> list = criteria.list();
    if (!list.isEmpty()) {
        invFreezer = (InvFreezer) list.get(0);
    }

    if (invFreezer == null) {
        log.error("InvFreezer with ID " + id + " is no longer in the database");
    }
    return invFreezer;
}

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

License:Open Source License

public InvRack getInvRack(Long id) {
    InvRack invRack = new InvRack();
    Criteria criteria = getSession().createCriteria(InvRack.class);

    if (id != null) {
        criteria.add(Restrictions.eq("id", id));
    }/* w  w w. j  a  v a2s  .c  o m*/

    List<InvRack> list = criteria.list();
    if (!list.isEmpty()) {
        invRack = (InvRack) list.get(0);
    }

    if (invRack == null) {
        log.error("InvRack with ID " + id + " is no longer in the database");
    }
    return invRack;
}

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

License:Open Source License

public InvCell getInvCellByBiospecimen(Biospecimen biospecimen) {
    InvCell invCell = new InvCell();
    Criteria criteria = getSession().createCriteria(InvCell.class);

    if (biospecimen != null) {
        criteria.add(Restrictions.eq("biospecimen", biospecimen));
    }//from   w w w.  j av  a  2s  . c  o  m

    List<InvCell> list = criteria.list();
    if (!list.isEmpty()) {
        invCell = (InvCell) list.get(0);
    }

    if (invCell == null) {
        log.error("InvCell with biospecimen " + biospecimen.getId() + " is no longer in the database");
    }
    return invCell;
}

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

License:Open Source License

public InvCell getInvCell(Long id) {
    InvCell invCell = new InvCell();
    Criteria criteria = getSession().createCriteria(InvCell.class);

    if (id != null) {
        criteria.add(Restrictions.eq("id", id));
    }/*from   w  w w .j av a 2s  .com*/

    List<InvCell> list = criteria.list();
    if (!list.isEmpty()) {
        invCell = (InvCell) list.get(0);
    }

    if (invCell == null) {
        log.error("InvRack with ID " + id + " is no longer in the database");
    }
    return invCell;
}

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

License:Open Source License

public List<InvBox> searchInvBox(InvBox invBox) throws ArkSystemException {
    Criteria criteria = getSession().createCriteria(InvBox.class);

    if (invBox.getId() != null) {
        criteria.add(Restrictions.eq("id", invBox.getId()));
    }/*from w ww . ja  va 2 s  . c  om*/

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

    List<InvBox> list = criteria.list();
    return list;
}

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

License:Open Source License

public boolean hasAllocatedCells(InvBox invBox) {
    Criteria criteria = getSession().createCriteria(InvCell.class);
    criteria.add(Restrictions.eq("invBox", invBox));
    criteria.add(Restrictions.isNotNull("biospecimen"));
    criteria.setProjection(Projections.count("id"));
    Long count = (Long) criteria.uniqueResult();
    return count > 0L;
}

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

License:Open Source License

public InvCell getInvCellByLocationNames(String siteName, String freezerName, String rackName, String boxName,
        String row, String column) throws ArkSystemException {
    InvCell invCell = new InvCell();
    if ((siteName == null || freezerName == null || rackName == null || boxName == null || row == null
            || column == null)//from w w  w .  j  av a2  s .c o m
            || (siteName.isEmpty() || freezerName.isEmpty() || rackName.isEmpty() || boxName.isEmpty()
                    || row.isEmpty() || column.isEmpty())) {
        return invCell;
    }
    Long rowno;
    Long colno;

    if (StringUtils.isNumeric(row)) {
        rowno = new Long(row);
    } else {
        row = row.toUpperCase();
        char c = (char) row.charAt(0);
        rowno = (long) ((char) row.charAt(0) - 64);
    }

    if (StringUtils.isNumeric(column)) {
        colno = new Long(column);
    } else {
        column = column.toUpperCase();
        char c = (char) column.charAt(0);
        colno = (long) ((char) column.charAt(0) - 64);
    }

    Criteria criteria = getSession().createCriteria(InvCell.class);
    criteria.createAlias("invBox", "box", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("box.invRack", "rack", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("rack.invFreezer", "freezer", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("freezer.invSite", "site", JoinType.LEFT_OUTER_JOIN);
    criteria.createAlias("biospecimen", "b", JoinType.LEFT_OUTER_JOIN);
    criteria.add(Restrictions.eq("site.name", siteName));
    criteria.add(Restrictions.eq("freezer.name", freezerName));
    criteria.add(Restrictions.eq("rack.name", rackName));
    criteria.add(Restrictions.eq("box.name", boxName));
    criteria.add(Restrictions.eq("rowno", rowno));
    criteria.add(Restrictions.eq("colno", colno));

    invCell = (InvCell) criteria.uniqueResult();
    return invCell;
}

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

License:Open Source License

public InvCell getNextAvailableInvCell(InvBox invBox) {
    Criteria criteria = getSession().createCriteria(InvCell.class);
    criteria.add(Restrictions.eq("invBox", invBox));
    criteria.add(Restrictions.isNull("biospecimen"));
    criteria.setMaxResults(1);/*from  w ww  . jav a 2 s. c  om*/
    return (InvCell) criteria.list().get(0);
}

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

License:Open Source License

/**
 * Get invSite by name/*from w  ww  .j  a v a2 s  .  c om*/
 * @param siteName
 * @return
 */
public InvSite getInvSiteByname(String siteName) {
    Criteria criteria = getSession().createCriteria(InvSite.class);
    if (siteName != null && !siteName.isEmpty()) {
        criteria.add(Restrictions.eq("name", siteName));
    }
    return (InvSite) criteria.uniqueResult();
}

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

License:Open Source License

public InvFreezer getFreezerByNameForSite(InvSite invSite, String freezerName) {
    Criteria criteria = getSession().createCriteria(InvFreezer.class);
    if (invSite != null) {
        criteria.add(Restrictions.eq("invSite", invSite));
    }// w ww  . ja va  2 s  .c om
    if (freezerName != null && !freezerName.isEmpty()) {
        criteria.add(Restrictions.eq("name", freezerName));
    }
    return (InvFreezer) criteria.uniqueResult();
}