use of uk.ac.bbsrc.tgac.miso.core.data.Box in project miso-lims by miso-lims.
the class HibernateBoxDao method getByPartialSearch.
@Override
public List<Box> getByPartialSearch(String search, boolean onlyMatchBeginning) {
if (search == null) {
throw new NullPointerException("No search String provided");
}
Criteria criteria = currentSession().createCriteria(BoxImpl.class);
criteria.add(Restrictions.or(Restrictions.like("identificationBarcode", search, onlyMatchBeginning ? MatchMode.START : MatchMode.ANYWHERE), Restrictions.like("name", search, onlyMatchBeginning ? MatchMode.START : MatchMode.ANYWHERE), Restrictions.like(FIELD_ALIAS, search, onlyMatchBeginning ? MatchMode.START : MatchMode.ANYWHERE)));
@SuppressWarnings("unchecked") List<Box> results = criteria.list();
results.sort((Box b1, Box b2) -> {
String p1 = getMostSimilarProperty(b1, search.toLowerCase());
String p2 = getMostSimilarProperty(b2, search.toLowerCase());
if (p1.indexOf(search.toLowerCase()) == p2.indexOf(search.toLowerCase())) {
if (p1.length() == p2.length()) {
return b1.getAlias().compareTo(b2.getAlias());
}
return p1.length() - p2.length();
}
return p1.indexOf(search.toLowerCase()) - p2.indexOf(search.toLowerCase());
});
return results;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Box in project miso-lims by miso-lims.
the class HibernateBoxDao method getBySearch.
@Override
public List<Box> getBySearch(String search) {
if (search == null) {
throw new NullPointerException("No search String provided");
}
Criteria criteria = currentSession().createCriteria(BoxImpl.class);
criteria.add(Restrictions.or(Restrictions.eq("identificationBarcode", search), Restrictions.eq("name", search), Restrictions.eq(FIELD_ALIAS, search)));
@SuppressWarnings("unchecked") List<Box> results = criteria.list();
return results;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Box in project miso-lims by miso-lims.
the class HibernateBoxDao method listAll.
@Override
public List<Box> listAll() throws IOException {
Criteria criteria = currentSession().createCriteria(BoxImpl.class);
@SuppressWarnings("unchecked") List<Box> results = criteria.list();
return results;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Box in project miso-lims by miso-lims.
the class HibernateBoxDao method getBoxByAlias.
@Override
public Box getBoxByAlias(String alias) throws IOException {
Criteria criteria = currentSession().createCriteria(BoxImpl.class);
criteria.add(Restrictions.eq(FIELD_ALIAS, alias));
return (Box) criteria.uniqueResult();
}
use of uk.ac.bbsrc.tgac.miso.core.data.Box in project miso-lims by miso-lims.
the class HibernateBoxDao method listByIdList.
@Override
public List<Box> listByIdList(List<Long> idList) throws IOException {
if (idList == null || idList.isEmpty()) {
return Collections.emptyList();
}
Criteria criteria = currentSession().createCriteria(BoxImpl.class);
criteria.add(Restrictions.in("boxId", idList));
@SuppressWarnings("unchecked") List<Box> records = criteria.list();
return records;
}
Aggregations