@Override public int compareTo(Partition t) { if (getId() != 0L && t.getId() != 0L) { if (getId() < t.getId()) return -1; if (getId() > t.getId()) return 1; } else { if (getPartitionNumber() < t.getPartitionNumber()) return -1; if (getPartitionNumber() > t.getPartitionNumber()) return 1; } return 0; }
@Override public void applyChanges(SequencerPartitionContainer source, SequencerPartitionContainer managed) throws IOException { managed.setIdentificationBarcode(source.getIdentificationBarcode()); managed.setDescription(source.getDescription()); managed.setClusteringKit(source.getClusteringKit()); managed.setMultiplexingKit(source.getMultiplexingKit()); if (LimsUtils.isOxfordNanoporeContainer(managed)) { applyOxfordNanoporeChanges((OxfordNanoporeContainer) source, (OxfordNanoporeContainer) managed); } for (Partition sourcePartition : source.getPartitions()) { for (Partition managedPartition : managed.getPartitions()) { if (sourcePartition == null || managedPartition == null) { throw new IOException("Partition from " + (sourcePartition == null ? "client" : "database") + " is null."); } if (sourcePartition.getId() == managedPartition.getId()) { Pool sourcePool = sourcePartition.getPool(); Pool managedPool = managedPartition.getPool(); if (sourcePool == null) { managedPartition.setPool(null); } else if (managedPool == null || sourcePool.getId() != managedPool.getId()) { managedPartition.setPool(poolService.get(sourcePool.getId())); } break; } } } }
public static PartitionDto asDto(@Nonnull Partition from, boolean includePoolContents) { PartitionDto dto = new PartitionDto(); dto.setId(from.getId()); dto.setContainerId(from.getSequencerPartitionContainer().getId()); dto.setContainerName(from.getSequencerPartitionContainer().getIdentificationBarcode()); dto.setPartitionNumber(from.getPartitionNumber()); dto.setPool(from.getPool() == null ? null : asDto(from.getPool(), includePoolContents, false)); setString(dto::setLoadingConcentration, from.getLoadingConcentration()); dto.setLoadingConcentrationUnits(from.getLoadingConcentrationUnits()); return dto; }
@Override public void update(Partition partition) throws IOException { Partition original = containerDao.getPartitionById(partition.getId()); authorizationManager.throwIfNotWritable(original.getSequencerPartitionContainer()); if (partition.getPool() != null) { partition.setPool(poolService.get(partition.getPool().getId())); } validateChange(partition, original); applyChanges(original, partition); original.getSequencerPartitionContainer().setChangeDetails(authorizationManager.getCurrentUser()); containerDao.save(original.getSequencerPartitionContainer()); }
RunPartition to = new RunPartition(); to.setExperiment(experiment); to.setPartition(containerService.getPartition(from.getPartition().getId())); to.setRun(runService.get(from.getRun().getId())); return to;
@Override public void save(PartitionQC qc) throws IOException { PartitionQC managedQc = get(qc.getRun(), qc.getPartition()); Run managedRun = runService.get(qc.getRun().getId()); authorizationManager.throwIfNotWritable(managedRun); Partition managedPartition = containerService.getPartition(qc.getPartition().getId()); // update run and container for accurate lastModified and lastModifier (used in changelogs) runService.update(managedRun); containerService.update(managedPartition.getSequencerPartitionContainer()); if (managedQc == null) { qc.setRun(managedRun); qc.setPartition(managedPartition); qc.setType(getType(qc.getType().getId())); partitionQcDao.create(qc); } else { managedQc.setType(getType(qc.getType().getId())); managedQc.setNotes(qc.getNotes()); partitionQcDao.update(managedQc); } } }