use of uk.ac.bbsrc.tgac.miso.core.data.RunPartition in project miso-lims by miso-lims.
the class RunRestController method setPartitionPurposes.
@PutMapping("/{runId}/partition-purposes")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setPartitionPurposes(@PathVariable long runId, @RequestBody RunPartitionPurposeRequest request) throws IOException {
Run run = RestUtils.retrieve("Run", runId, runService);
RunPurpose purpose = RestUtils.retrieve("Run purpose", request.getRunPurposeId(), runPurposeService);
List<Partition> partitions = run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).filter(partition -> request.getPartitionIds().contains(partition.getId())).collect(Collectors.toList());
for (Partition partition : partitions) {
RunPartition runPartition = runPartitionService.get(run, partition);
if (runPartition == null) {
runPartition = new RunPartition();
runPartition.setRunId(run.getId());
runPartition.setPartitionId(partition.getId());
}
runPartition.setPurpose(purpose);
runPartitionService.save(runPartition);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.RunPartition in project miso-lims by miso-lims.
the class HibernateRunPartitionDao method deleteForRunContainer.
@Override
public void deleteForRunContainer(Run run, SequencerPartitionContainer container) throws IOException {
Set<Long> partitionIds = container.getPartitions().stream().map(Partition::getId).collect(Collectors.toSet());
@SuppressWarnings("unchecked") List<RunPartition> items = currentSession().createCriteria(RunPartition.class).add(Restrictions.eq("runId", run.getId())).add(Restrictions.in("partitionId", partitionIds)).list();
for (RunPartition item : items) {
currentSession().delete(item);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.RunPartition in project miso-lims by miso-lims.
the class HibernateRunPartitionDaoIT method testDeleteForRun.
@Test
public void testDeleteForRun() throws Exception {
Run run = (Run) currentSession().get(Run.class, 1L);
List<RunPartition> before = getByRunId(run.getId());
assertEquals(8, before.size());
dao.deleteForRun(run);
clearSession();
List<RunPartition> after = getByRunId(run.getId());
assertEquals(0, after.size());
}
use of uk.ac.bbsrc.tgac.miso.core.data.RunPartition in project miso-lims by miso-lims.
the class HibernateRunPartitionDaoIT method testDeleteForRunContainer.
@Test
public void testDeleteForRunContainer() throws Exception {
Run run = (Run) currentSession().get(Run.class, 2L);
SequencerPartitionContainer container = (SequencerPartitionContainer) currentSession().get(SequencerPartitionContainerImpl.class, 2L);
List<RunPartition> before = getByRunAndContainer(run, container);
assertEquals(8, before.size());
dao.deleteForRunContainer(run, container);
clearSession();
List<RunPartition> after = getByRunAndContainer(run, container);
assertEquals(0, after.size());
}
use of uk.ac.bbsrc.tgac.miso.core.data.RunPartition in project miso-lims by miso-lims.
the class DefaultRunPartitionService method save.
@Override
public void save(RunPartition runPartition) throws IOException {
RunPartition managed = get(runPartition.getRunId(), runPartition.getPartitionId());
User user = authorizationManager.getCurrentUser();
ValidationUtils.loadChildEntity(runPartition::setPurpose, runPartition.getPurpose(), runPurposeService, "runPurposeId");
ValidationUtils.loadChildEntity(runPartition::setQcType, runPartition.getQcType(), partitionQcTypeService, "qcType");
if (runPartition.getQcType() != null && runPartition.getQcType().isNoteRequired() && runPartition.getNotes() == null) {
throw new ValidationException("A note is required for the selected partition QC status");
}
if (managed == null) {
runPartition.setLastModifier(user);
runPartitionDao.create(runPartition);
} else {
managed.setQcType(runPartition.getQcType());
managed.setNotes(runPartition.getNotes());
managed.setPurpose(runPartition.getPurpose());
managed.setLastModifier(user);
runPartitionDao.update(managed);
}
}
Aggregations