@Override public List<BarcodableView> searchByAlias(String alias, Collection<EntityType> typeFilter) { if (alias == null) throw new IllegalArgumentException("Alias cannot be null!"); Predicate<BarcodableView> matchesTypeFilter = barcodableView -> typeFilter.contains(barcodableView.getId().getTargetType()); return searchByAlias(alias).stream().filter(matchesTypeFilter).collect(toList()); }
public static BarcodableDto asDto(@Nonnull BarcodableView from) { BarcodableDto dto = new BarcodableDto(); dto.setId(from.getId().getTargetId()); dto.setEntityType(from.getId().getTargetType().toString()); dto.setAlias(from.getAlias()); dto.setName(from.getName()); dto.setIdentificationBarcode(from.getIdentificationBarcode()); return dto; }
@Override public List<BarcodableView> searchByBarcode(String barcode, Collection<EntityType> typeFilter) { if (barcode == null) throw new IllegalArgumentException("Barcode cannot be null!"); Predicate<BarcodableView> matchesTypeFilter = barcodableView -> typeFilter.contains(barcodableView.getId().getTargetType()); return searchByBarcode(barcode).stream().filter(matchesTypeFilter).collect(toList()); }
@Override public <T extends Barcodable> T getEntity(BarcodableView view) throws IOException { EntityType entityType = view.getId().getTargetType(); long id = view.getId().getTargetId(); @SuppressWarnings("unchecked") T barcodable = (T) barcodableServicesMap.get(entityType).get(id); return barcodable; } }
private ProgressStep makeProgressStep(BarcodableView view) throws IOException { switch (view.getId().getTargetType()) { case POOL: PoolProgressStep poolStep = new PoolProgressStep(); poolStep.setInput(barcodableViewService.getEntity(view)); return poolStep; case CONTAINER: SequencerPartitionContainerProgressStep spcStep = new SequencerPartitionContainerProgressStep(); spcStep.setInput(barcodableViewService.getEntity(view)); return spcStep; case CONTAINER_MODEL: SequencingContainerModelProgressStep modelStep = new SequencingContainerModelProgressStep(); modelStep.setInput(barcodableViewService.getEntity(view)); return modelStep; case SAMPLE: SampleProgressStep sampleStep = new SampleProgressStep(); sampleStep.setInput(barcodableViewService.getEntity(view)); return sampleStep; case BOX: BoxProgressStep boxStep = new BoxProgressStep(); boxStep.setInput(barcodableViewService.getEntity(view)); return boxStep; default: throw new UnsupportedOperationException("Unsupported entity type"); } }