switch (parts[1].toLowerCase()) { case "fulfilled": return fulfilled(true); case "active": case "order": case "ordered": case "unfulfilled": return fulfilled(false); case "unknown": return health(HealthType.Unknown); case "complete": case "completed": return health(HealthType.Completed); case "failed": return health(HealthType.Failed); case "started": return health(HealthType.Started); case "stopped": return health(HealthType.Stopped); case "running": return health(HealthType.Running); case "incomplete": return health(EnumSet.of(HealthType.Running, HealthType.Started, HealthType.Stopped)); default: errorHandler.accept("No filter for " + x); return parseDate(parts[1], DateType.CREATE); case "changed": case "modified":
public static PaginationFilter pool(final Pool pool) { if (pool.getId() == PoolImpl.UNSAVED_ID) { throw new IllegalArgumentException("Cannot filter by unsaved pool."); } return pool(pool.getId()); }
@Override public Collection<Instrument> listByPlatformType(PlatformType platformType) throws IOException { return instrumentDao.list(0, 0, true, "id", PaginationFilter.platformType(platformType), PaginationFilter.archived(false)); }
filter.apply(this, idCriteria, errorHandler);
public static <M extends Identifiable, D, X extends RuntimeException> List<D> bulkSearch(Collection<String> names, PaginatedDataSource<M> service, Function<M, D> dto, Function<String, X> makeException) { return names.stream()// .filter(name -> !LimsUtils.isStringBlankOrNull(name))// .flatMap(WhineyFunction.flatRethrow(name -> { Collection<M> matches = service.list(0, 0, true, "id", exactQuery(name)); if (matches.isEmpty()) { throw makeException.apply(String.format("Cannot find \"%s\".", name)); } return matches; }))// .collect(Collectors.groupingBy(Identifiable::getId))// .values()// .stream()// .map(list -> list.get(0))// .map(dto).collect(Collectors.toList()); }
return date(start.toDate(), end.toDate(), type);
@Override public default long count(Consumer<String> errorHandler, PaginationFilter... filters) throws IOException { if (filters.length == 0) { // try a quicker approach Table tableAnnotation = getRealClass().getAnnotation(Table.class); if (tableAnnotation != null) { Query query = currentSession().createSQLQuery("SELECT COUNT(*) FROM " + tableAnnotation.name()); return ((BigInteger) query.uniqueResult()).longValueExact(); } } Criteria criteria = createPaginationCriteria(); for (PaginationFilter filter : filters) { filter.apply(this, criteria, errorHandler); } criteria.setProjection(Projections.countDistinct("id")); return (Long) criteria.uniqueResult(); }
@Override public List<PoolOrderCompletion> getByPoolId(Long poolId) throws IOException { return authorizationManager.filterUnreadable(poolOrderCompletionDao.list(0, 100, false, "remaining", PaginationFilter.pool(poolId)), x -> x.getPool()); } }