List of usage examples for org.hibernate.criterion Restrictions eq
public static SimpleExpression eq(String propertyName, Object value)
From source file:au.org.theark.lims.model.dao.BiospecimenUidGenerator.java
License:Open Source License
/** * TODO this should use a real fkey/*from ww w. j a va 2s. c o m*/ * @param studyNameKy * @return */ public Integer getUidAndIncrement(String studyNameKy, int numToInsert) { Criteria criteria = getSession().createCriteria(BiospecimenUidSequence.class); criteria.add(Restrictions.eq("studyNameId", studyNameKy)); BiospecimenUidSequence seqData = (BiospecimenUidSequence) criteria.uniqueResult(); if (seqData == null) { log.warn("sequence does not exist...creating"); BiospecimenUidSequence seq = new BiospecimenUidSequence(); seq.setInsertLock(false); seq.setStudyNameId(studyNameKy); seq.setUidSequence(numToInsert); getSession().persist(seq); getSession().flush(); return new Integer(0); } else { //log.warn("so we hav a seq"); int currentSeqNumber = seqData.getUidSequence(); seqData.setUidSequence((currentSeqNumber + numToInsert)); getSession().update(seqData); getSession().flush(); return currentSeqNumber;//TODO ...perhaps this should be handled transactionally in one class, and probably with generators...although this isnt really even a key } }
From source file:au.org.theark.lims.model.dao.BioTransactionDao.java
License:Open Source License
public BioTransaction getBioTransaction(Long id) throws EntityNotFoundException, ArkSystemException { Criteria criteria = getSession().createCriteria(BioTransaction.class); criteria.add(Restrictions.eq("id", id)); BioTransaction bioTransaction = (BioTransaction) criteria.uniqueResult(); if (bioTransaction.getId() == null) { throw new EntityNotFoundException("The entity with id" + id.toString() + " cannot be found."); }// w w w. j a v a 2 s . c o m return bioTransaction; }
From source file:au.org.theark.lims.model.dao.BioTransactionDao.java
License:Open Source License
private Criteria buildBioTransactionCriteria(BioTransaction bioTransaction) { Criteria criteria = getSession().createCriteria(BioTransaction.class); // All transactions must operate on a given biospecimen criteria.add(Restrictions.eq("biospecimen", bioTransaction.getBiospecimen())); return criteria; }
From source file:au.org.theark.lims.model.dao.BioTransactionDao.java
License:Open Source License
public BioTransactionStatus getBioTransactionStatusByName(String statusName) { Criteria criteria = getSession().createCriteria(BioTransactionStatus.class); criteria.add(Restrictions.eq("name", statusName)); BioTransactionStatus result = (BioTransactionStatus) criteria.uniqueResult(); return result; }
From source file:au.org.theark.lims.model.dao.BioTransactionDao.java
License:Open Source License
public List<BioTransaction> getAllBiotransactionForBiospecimen(Biospecimen biospecimen) { Criteria criteria = getSession().createCriteria(BioTransaction.class); criteria.add(Restrictions.eq("biospecimen", biospecimen)); List<BioTransaction> result = (List<BioTransaction>) criteria.list(); return result; }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public List<InvSite> searchInvSite(InvSite invSite) throws ArkSystemException { Criteria criteria = getSession().createCriteria(InvSite.class); if (invSite.getId() != null) { criteria.add(Restrictions.eq("id", invSite.getId())); }/*from w ww .j av a 2s .co m*/ 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())); } List<InvSite> list = criteria.list(); return list; }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public InvSite getInvSite(Long id) { InvSite invSite = new InvSite(); Criteria criteria = getSession().createCriteria(InvSite.class); if (id != null) { criteria.add(Restrictions.eq("id", id)); }// w ww .j a v a2s .c o m List<InvSite> list = criteria.list(); if (!list.isEmpty()) { invSite = (InvSite) list.get(0); } return invSite; }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public InvCell getInvCell(InvBox invBox, long rowno, long colno) { InvCell invCell = null; //new InvCell(); Criteria criteria = getSession().createCriteria(InvCell.class); if (invBox != null) { criteria.add(Restrictions.eq("invBox", invBox)); }//from ww w .j a va 2 s. c om criteria.add(Restrictions.eq("rowno", rowno)); criteria.add(Restrictions.eq("colno", colno)); List<InvCell> list = criteria.list(); if (!list.isEmpty()) { invCell = (InvCell) list.get(0); } return invCell; }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public Biospecimen getBiospecimenByInvCell(InvCell invCell) { Biospecimen biospecimen = null;/*from w w w. j a v a 2 s. c o m*/ Criteria criteria = getSession().createCriteria(InvCell.class); criteria.add(Restrictions.eq("id", invCell.getId())); List<InvCell> list = criteria.list(); if (!list.isEmpty()) { biospecimen = (Biospecimen) list.get(0).getBiospecimen(); } return biospecimen; }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
License:Open Source License
public InvBox getInvBox(Long id) { InvBox invBox = new InvBox(); Criteria criteria = getSession().createCriteria(InvBox.class); if (id != null) { criteria.add(Restrictions.eq("id", id)); }/*from w w w . j av a2s . com*/ List<InvBox> list = criteria.list(); if (!list.isEmpty()) { invBox = (InvBox) list.get(0); } if (invBox == null) { log.error("InvBox with ID " + id + " is no longer in the database"); } return invBox; }