use of uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl in project miso-lims by miso-lims.
the class DefaultRunService method updateContainerFromNotification.
private boolean updateContainerFromNotification(final Run target, User user, SequencingContainerModel containerModel, String containerSerialNumber, final GetLaneContents getLaneContents, String positionName) throws IOException {
if (LimsUtils.isStringBlankOrNull(containerSerialNumber)) {
return false;
}
final Collection<SequencerPartitionContainer> containers = containerService.listByBarcode(containerSerialNumber);
int laneCount = containerModel.getPartitionCount();
InstrumentPosition position = null;
if (!isStringEmptyOrNull(positionName)) {
position = target.getSequencer().getInstrumentModel().getPositions().stream().filter(pos -> positionName.equals(pos.getAlias())).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("Unknown position '%s' for platform '%s'", positionName, target.getSequencer().getInstrumentModel().getAlias())));
}
switch(containers.size()) {
case 0:
SequencerPartitionContainer newContainer = containerModel.getPlatformType().createContainer();
newContainer.setModel(containerModel);
newContainer.setCreator(user);
newContainer.setIdentificationBarcode(containerSerialNumber);
newContainer.setPartitionLimit(laneCount);
newContainer.setPartitions(IntStream.range(0, laneCount).mapToObj(i -> new PartitionImpl(newContainer, i + 1)).collect(Collectors.toList()));
updatePartitionContents(getLaneContents, newContainer);
RunPosition newRunPos = new RunPosition();
newRunPos.setRun(target);
newRunPos.setContainer(newContainer);
newRunPos.setPosition(position);
target.getRunPositions().clear();
target.getRunPositions().add(newRunPos);
return true;
case 1:
SequencerPartitionContainer container = containers.iterator().next();
boolean isMutated = false;
if (container.getPartitions().size() != laneCount) {
throw new IllegalArgumentException(String.format("The container %s has %d partitions, but %d were detected by the scanner.", containerSerialNumber, container.getPartitions().size(), laneCount));
}
// only update container model from fallback to non-fallback
if (container.getModel().isFallback() && !containerModel.isFallback() && container.getModel().getId() != containerModel.getId()) {
container.setModel(containerModel);
isMutated = true;
}
if (target.getSequencerPartitionContainers().stream().noneMatch(c -> c.getId() == container.getId())) {
target.addSequencerPartitionContainer(container, position);
updatePartitionContents(getLaneContents, container);
isMutated = true;
}
return isMutated;
default:
throw new IllegalArgumentException("Multiple containers with same identifier: " + containerSerialNumber);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl in project miso-lims by miso-lims.
the class Dtos method to.
public static RunPartitionAliquot to(@Nonnull RunPartitionAliquotDto from) {
RunPartitionAliquot to = new RunPartitionAliquot();
PlatformType platform = PlatformType.valueOf(from.getPlatformType());
setObject(to::setRun, platform::createRun, from.getRunId());
setObject(to::setPartition, PartitionImpl::new, from.getPartitionId());
setObject(to::setAliquot, LibraryAliquot::new, from.getAliquotId());
setObject(to::setPurpose, RunPurpose::new, from.getRunPurposeId());
setObject(to::setQcStatus, RunLibraryQcStatus::new, from.getQcStatusId());
setString(to::setQcNote, from.getQcNote());
setBoolean(to::setDataReview, from.getDataReview(), true);
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl in project miso-lims by miso-lims.
the class Dtos method to.
public static Partition to(@Nonnull PartitionDto dto) {
Partition to = new PartitionImpl();
to.setId(dto.getId());
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl in project miso-lims by miso-lims.
the class EditSequencerPartitionContainerController method setupNewForm.
@GetMapping(value = "/new/{modelId}")
public ModelAndView setupNewForm(@PathVariable("modelId") Long modelId, ModelMap model) throws IOException {
SequencingContainerModel containerModel = containerModelService.get(modelId);
if (containerModel == null)
throw new NotFoundException("No container model found for ID " + modelId.toString());
SequencerPartitionContainer container = containerModel.getPlatformType().createContainer();
container.setModel(containerModel);
model.put("title", "New " + containerModel.getPlatformType().getContainerName());
container.setPartitions(IntStream.range(0, containerModel.getPartitionCount()).mapToObj(number -> new PartitionImpl(container, number + 1)).collect(Collectors.toList()));
return setupForm(container, model);
}
Aggregations