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;
}
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);
}
}
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;
}
Aggregations