use of uk.ac.bbsrc.tgac.miso.core.data.Partition in project miso-lims by miso-lims.
the class HibernateRunPartitionAliquotDaoIT method testCreate.
@Test
public void testCreate() throws Exception {
Run run = (Run) currentSession().get(Run.class, 1L);
Partition partition = (Partition) currentSession().get(PartitionImpl.class, 2L);
LibraryAliquot aliquot = (LibraryAliquot) currentSession().get(LibraryAliquot.class, 3L);
RunPartitionAliquotId id = new RunPartitionAliquotId(run, partition, aliquot);
assertNull(currentSession().get(RunPartitionAliquot.class, id));
RunPartitionAliquot rpa = new RunPartitionAliquot(run, partition, aliquot);
User user = (User) currentSession().get(UserImpl.class, 1L);
rpa.setLastModifier(user);
RunLibraryQcStatus qc = (RunLibraryQcStatus) currentSession().get(RunLibraryQcStatus.class, 1L);
rpa.setQcStatus(qc);
rpa.setQcUser(user);
rpa.setQcDate(new Date());
sut.create(rpa);
clearSession();
RunPartitionAliquot saved = (RunPartitionAliquot) currentSession().get(RunPartitionAliquot.class, id);
assertNotNull(saved);
assertEquals(1L, saved.getRun().getId());
assertEquals(2L, saved.getPartition().getId());
assertEquals(3L, saved.getAliquot().getId());
}
use of uk.ac.bbsrc.tgac.miso.core.data.Partition in project miso-lims by miso-lims.
the class DefaultQcStatusService method findPartitionInRun.
private Partition findPartitionInRun(Run run, long partitionId) {
Partition partition = run.getRunPositions().stream().map(RunPosition::getContainer).flatMap(x -> x.getPartitions().stream()).filter(x -> x.getId() == partitionId).findFirst().orElse(null);
throwIfNull("Partition", partition);
return partition;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Partition in project miso-lims by miso-lims.
the class DefaultContainerService method update.
@Override
public void update(Partition partition) throws IOException {
Partition original = containerDao.getPartitionById(partition.getId());
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());
}
use of uk.ac.bbsrc.tgac.miso.core.data.Partition in project miso-lims by miso-lims.
the class DefaultContainerService method applyChanges.
@Override
public void applyChanges(SequencerPartitionContainer source, SequencerPartitionContainer managed) throws IOException {
managed.setIdentificationBarcode(source.getIdentificationBarcode());
managed.setDescription(source.getDescription());
managed.setClusteringKit(source.getClusteringKit());
managed.setClusteringKitLot(source.getClusteringKitLot());
managed.setMultiplexingKit(source.getMultiplexingKit());
managed.setMultiplexingKitLot(source.getMultiplexingKitLot());
managed.setModel(source.getModel());
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;
}
}
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.Partition in project miso-lims by miso-lims.
the class RunRestController method getSpreadsheet.
@PostMapping(value = "/spreadsheet")
@ResponseBody
public HttpEntity<byte[]> getSpreadsheet(@RequestBody SpreadsheetRequest request, HttpServletResponse response, UriComponentsBuilder uriBuilder) throws IOException {
// Note: not retrieving persisted run-libraries, so QC data will be missing
List<Run> runs = runService.listByIdList(request.getIds());
List<RunPartitionAliquot> runLibraries = new ArrayList<>();
for (Run run : runs) {
for (RunPosition runPosition : run.getRunPositions()) {
for (Partition partition : runPosition.getContainer().getPartitions()) {
if (partition.getPool() != null) {
for (PoolElement element : partition.getPool().getPoolContents()) {
LibraryAliquot aliquot = libraryAliquotService.get(element.getAliquot().getId());
runLibraries.add(new RunPartitionAliquot(run, partition, aliquot));
}
}
}
}
}
return MisoWebUtils.generateSpreadsheet(request, runLibraries.stream(), detailedSample, RunLibrarySpreadsheets::valueOf, response);
}
Aggregations