@Override public int compareTo(PoolableElementView o) { PoolableElementView t = o; if (getDilutionId() < t.getDilutionId()) return -1; if (getDilutionId() > t.getDilutionId()) return 1; return 0; }
public void setDiscarded(boolean discarded) { if (discarded) setVolume(0D); this.discarded = discarded; }
private Predicate<PoolDilution> notInOther(Collection<PoolDilution> otherCollection) { return t -> otherCollection.stream() .noneMatch(other -> other.getPoolableElementView().getDilutionId() == t.getPoolableElementView().getDilutionId()); }
public static BoxableDto asDto(@Nonnull BoxableView from) { BoxableDto dto = new BoxableDto(); dto.setId(from.getId().getTargetId()); dto.setAlias(from.getAlias()); dto.setBoxAlias(from.getBoxAlias()); dto.setBoxPosition(BoxUtils.makeLocationLabel(from)); dto.setCoordinates(from.getBoxPosition()); dto.setDiscarded(from.isDiscarded()); dto.setIdentificationBarcode(from.getIdentificationBarcode()); dto.setName(from.getName()); dto.setVolume(from.getVolume()); dto.setEntityType(from.getId().getTargetType()); dto.setSampleClassId(from.getSampleClassId()); return dto; }
public static String makeLocationLabel(BoxableView boxable) { return makeLocationLabel(boxable.isDiscarded(), boxable.getLocationBarcode(), boxable.getBoxAlias(), boxable.getBoxPosition(), boxable.getBoxLocationBarcode()); }
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 <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; } }
@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()); }
private Set<String> extractDilutionNames(Set<PoolDilution> dilutions) { Set<String> original = new HashSet<>(); for (PoolDilution dilution : dilutions) { original.add(dilution.getPoolableElementView().getDilutionName()); } return original; }
@Override protected void makeColumns(Run run, Partition partition, PoolableElementView dilution, String userName, String[] output) { output[0] = dilution.getDilutionName(); output[1] = dilution.getIndices().stream().findFirst().map(Index::getSequence).orElse(""); output[2] = dilution.getProjectShortName(); } };
@Override public void removeBoxableFromBox(BoxableView boxable) throws IOException { if (boxable.getBoxId() == null) { return; } Box box = get(boxable.getBoxId()); box.getBoxPositions().remove(boxable.getBoxPosition()); currentSession().update(box); // flush required to avoid constraint violation incase item is immediately added to another box or the same one // NOTE: this flush will cause ALL Hibernate-managed items to be saved to the db in their current state, even if their `save` method // hasn't explicitly been called yet currentSession().flush(); }
@Override public String getLongestIndex() { Map<Integer, Integer> lengths = poolDilutions.stream() .flatMap(element -> element.getPoolableElementView().getIndices().stream()) .collect(Collectors.toMap(Index::getPosition, index -> index.getSequence().length(), Integer::max)); if (lengths.isEmpty()) { return "0"; } return lengths.entrySet().stream() .sorted((a, b) -> a.getKey().compareTo(b.getKey())) .map(Entry<Integer, Integer>::getValue) .map(length -> length.toString()) .collect(Collectors.joining(",")); }
private static boolean hasFakeSequence(PoolableElementView view) { return view.getIndices().stream() .map(Index::getFamily) .anyMatch(f -> f.hasFakeSequence()); }
@Override public Set<String> getPrioritySubprojectAliases() { return poolDilutions.stream() .map(PoolDilution::getPoolableElementView).filter(view -> view.getSubprojectPriority() != null && view.getSubprojectPriority()) .map(view -> view.getSubprojectAlias()).collect(Collectors.toSet()); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((pool == null) ? 0 : pool.hashCode()); result = prime * result + ((poolableElementView == null) ? 0 : poolableElementView.hashCode()); return result; }
@Override protected void makeColumns(Run run, Partition partition, PoolableElementView dilution, String userName, String[] output) { SampleSheet.CASAVA_1_7.makeColumns(run, partition, dilution, userName, output); output[9] = dilution.getProjectAlias().replaceAll("\\s", ""); } },
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PoolDilutionId other = (PoolDilutionId) obj; if (pool == null) { if (other.pool != null) return false; } else if (!pool.equals(other.pool)) return false; if (poolableElementView == null) { if (other.poolableElementView != null) return false; } else if (!poolableElementView.equals(other.poolableElementView)) return false; return true; }
@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()); }
@Override public boolean hasLibrariesWithoutIndex() { return getPoolDilutions().stream().map(PoolDilution::getPoolableElementView).anyMatch(v -> v.getIndices().isEmpty()); }
private static String getCombinedIndexSequences(PoolableElementView view) { return view.getIndices().stream() .sorted((i1, i2) -> Integer.compare(i1.getPosition(), i2.getPosition())) .map(Index::getSequence) .collect(Collectors.joining()); }