Search in sources :

Example 61 with Box

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;
}
Also used : Box(uk.ac.bbsrc.tgac.miso.core.data.Box) Criteria(org.hibernate.Criteria)

Example 62 with Box

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;
}
Also used : Box(uk.ac.bbsrc.tgac.miso.core.data.Box) Criteria(org.hibernate.Criteria)

Example 63 with Box

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;
}
Also used : Box(uk.ac.bbsrc.tgac.miso.core.data.Box) Criteria(org.hibernate.Criteria)

Example 64 with Box

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();
}
Also used : Box(uk.ac.bbsrc.tgac.miso.core.data.Box) Criteria(org.hibernate.Criteria)

Example 65 with Box

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;
}
Also used : Box(uk.ac.bbsrc.tgac.miso.core.data.Box) Criteria(org.hibernate.Criteria)

Aggregations

Box (uk.ac.bbsrc.tgac.miso.core.data.Box)65 Test (org.junit.Test)23 BoxPosition (uk.ac.bbsrc.tgac.miso.core.data.BoxPosition)21 BoxImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.BoxImpl)17 BoxableId (uk.ac.bbsrc.tgac.miso.core.data.BoxableId)16 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 PostMapping (org.springframework.web.bind.annotation.PostMapping)11 BoxPage (uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxPage)11 BoxableView (uk.ac.bbsrc.tgac.miso.core.data.impl.view.box.BoxableView)10 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)9 BoxVisualization (uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxVisualization)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 List (java.util.List)8 IOException (java.io.IOException)7 Set (java.util.Set)7 Collectors (java.util.stream.Collectors)7 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)7 Autowired (org.springframework.beans.factory.annotation.Autowired)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)6