Source:
private void validateChange(SequencerPartitionContainer container, SequencerPartitionContainer beforeChange) throws IOException { if (container.getModel().getPartitionCount() != container.getPartitions().size()) { throw new IllegalArgumentException("Number of partitions does not match container model specifications"); } List<ValidationError> errors = new ArrayList<>(); if ((beforeChange == null || !container.getIdentificationBarcode().equals(beforeChange.getIdentificationBarcode())) && !listByBarcode(container.getIdentificationBarcode()).isEmpty()) { errors.add(new ValidationError("identificationBarcode", "There is already a container with this serial number")); } if (beforeChange != null && ValidationUtils.isSetAndChanged(SequencerPartitionContainer::getModel, container, beforeChange)) { SequencingContainerModel before = beforeChange.getModel(); SequencingContainerModel after = container.getModel(); if (after.getPlatformType() != before.getPlatformType()) { errors.add(new ValidationError("model.id", String.format("Can only be changed to a model of the same platform (%s)", before.getPlatformType().getKey()))); } else if (after.getPartitionCount() != before.getPartitionCount()) { errors.add(new ValidationError("model.id", String.format("Can only be changed to a model with the same number of partitions (%d)", before.getPartitionCount()))); } if (beforeChange.getRunPositions() != null) { Stream<InstrumentModel> requiredInstrumentModels = beforeChange.getRunPositions().stream() .map(RunPosition::getRun) .map(Run::getSequencer) .map(Instrument::getInstrumentModel); if (requiredInstrumentModels.anyMatch(required -> after.getInstrumentModels().stream() .map(InstrumentModel::getId) .noneMatch(id -> id == required.getId()))) { errors.add(new ValidationError("model.id", String.format("Can only change to a model compatible with the linked runs' instrument models (%s)", LimsUtils.joinWithConjunction(requiredInstrumentModels.map(InstrumentModel::getAlias).collect(Collectors.toSet()), "and")))); } } } if (!errors.isEmpty()) { throw new ValidationException(errors); } }

Target:
private void validateChange(SequencerPartitionContainer container, SequencerPartitionContainer beforeChange) throws IOException { if (container.getModel().getPartitionCount() != container.getPartitions().size()) { throw new IllegalArgumentException("Number of partitions does not match container model specifications"); } List<ValidationError> errors = new ArrayList<>(); if ((beforeChange == null || !container.getIdentificationBarcode().equals(beforeChange.getIdentificationBarcode())) && !listByBarcode(container.getIdentificationBarcode()).isEmpty()) { errors.add(new ValidationError("identificationBarcode", "There is already a container with this serial number")); } if (beforeChange != null && ValidationUtils.isSetAndChanged(SequencerPartitionContainer::getModel, container, beforeChange)) { SequencingContainerModel before = beforeChange.getModel(); SequencingContainerModel after = container.getModel(); if (after.getPlatformType() != before.getPlatformType()) { errors.add(new ValidationError("model.id", String.format("Can only be changed to a model of the same platform (%s)", before.getPlatformType().getKey()))); } else if (after.getPartitionCount() != before.getPartitionCount()) { errors.add(new ValidationError("model.id", String.format("Can only be changed to a model with the same number of partitions (%d)", before.getPartitionCount()))); } if (beforeChange.getRunPositions() != null) { Set<InstrumentModel> requiredInstrumentModels = beforeChange.getRunPositions().stream() .map(RunPosition::getRun) .map(Run::getSequencer) .map(Instrument::getInstrumentModel) .collect(Collectors.toSet()); if (requiredInstrumentModels.stream().anyMatch(required -> after.getInstrumentModels().stream() .map(InstrumentModel::getId) .noneMatch(id -> id == required.getId()))) { errors.add(new ValidationError("model.id", String.format("Can only change to a model compatible with the linked runs' instrument models (%s)", LimsUtils.joinWithConjunction( requiredInstrumentModels.stream().map(InstrumentModel::getAlias).collect(Collectors.toSet()), "and")))); } } } if (!errors.isEmpty()) { throw new ValidationException(errors); } }