Search in sources :

Example 1 with EntityType

use of uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType in project miso-lims by miso-lims.

the class HibernateBoxDao method queryBoxables.

private List<BoxableView> queryBoxables(Criterion criterion) {
    List<BoxableView> results = new ArrayList<>();
    for (EntityType entityType : EntityType.values()) {
        @SuppressWarnings("unchecked") List<BoxableView> partialResults = currentSession().createCriteria(entityType.getViewClass()).createAlias("boxPosition", "boxPosition", JoinType.LEFT_OUTER_JOIN).createAlias("boxPosition.box", "box", JoinType.LEFT_OUTER_JOIN).add(criterion).list();
        results.addAll(partialResults);
    }
    return results;
}
Also used : BoxableView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.box.BoxableView) EntityType(uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType) ArrayList(java.util.ArrayList)

Example 2 with EntityType

use of uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType in project miso-lims by miso-lims.

the class BoxRestController method parseEntityIdentifier.

private static BoxableId parseEntityIdentifier(String identifier) {
    try {
        String[] pieces = identifier.split(":");
        EntityType et = EntityType.valueOf(pieces[0]);
        long id = Long.parseLong(pieces[1]);
        return new BoxableId(et, id);
    } catch (NullPointerException | IllegalArgumentException e) {
        throw new RestException("Invalid entity identifier: " + identifier, Status.BAD_REQUEST);
    }
}
Also used : EntityType(uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType) BoxableId(uk.ac.bbsrc.tgac.miso.core.data.BoxableId)

Example 3 with EntityType

use of uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType in project miso-lims by miso-lims.

the class HibernateBoxDao method getBoxableViewsByIdList.

@Override
public List<BoxableView> getBoxableViewsByIdList(Collection<BoxableId> ids) throws IOException {
    if (ids.isEmpty()) {
        return Collections.emptyList();
    }
    List<BoxableView> results = new ArrayList<>();
    for (EntityType entityType : EntityType.values()) {
        List<Long> filteredIds = ids.stream().filter(x -> x.getTargetType() == entityType).map(BoxableId::getTargetId).collect(Collectors.toList());
        if (!filteredIds.isEmpty()) {
            @SuppressWarnings("unchecked") List<BoxableView> partialResults = currentSession().createCriteria(entityType.getViewClass()).add(Restrictions.in("id", filteredIds)).list();
            results.addAll(partialResults);
        }
    }
    return results;
}
Also used : BoxableView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.box.BoxableView) EntityType(uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType) ArrayList(java.util.ArrayList)

Aggregations

EntityType (uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType)3 ArrayList (java.util.ArrayList)2 BoxableView (uk.ac.bbsrc.tgac.miso.core.data.impl.view.box.BoxableView)2 BoxableId (uk.ac.bbsrc.tgac.miso.core.data.BoxableId)1