use of uk.ac.bbsrc.tgac.miso.core.data.Partition 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.Partition in project miso-lims by miso-lims.
the class HibernateSequencerPartitionContainerDao method listAllPartitionsByPoolId.
@Override
public List<Partition> listAllPartitionsByPoolId(long poolId) throws IOException {
Criteria criteria = currentSession().createCriteria(PartitionImpl.class);
criteria.createAlias("pool", "pool");
criteria.add(Restrictions.eq("pool.id", poolId));
@SuppressWarnings("unchecked") List<Partition> records = criteria.list();
return records;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Partition in project miso-lims by miso-lims.
the class HibernateRunPartitionAliquotDaoIT method testSaveCreate.
@Test
public void testSaveCreate() 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.save(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 ExperimentRestController method addPartition.
@PostMapping(value = "/{experimentId}/add", produces = "application/json")
@ResponseBody
public ExperimentDto addPartition(@PathVariable Long experimentId, @RequestParam("runId") Long runId, @RequestParam("partitionId") Long partitionId) throws IOException {
Experiment experiment = experimentService.get(experimentId);
if (experiment == null) {
throw new RestException("No such experiment.", Status.NOT_FOUND);
}
Run run = runService.get(runId);
if (run == null) {
throw new RestException("No such run.", Status.NOT_FOUND);
}
Partition partition = containerService.getPartition(partitionId);
if (partition == null) {
throw new RestException("No such partition.", Status.NOT_FOUND);
}
if (run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).noneMatch(p -> p.getId() == partitionId)) {
throw new RestException("Partition not in run.", Status.BAD_REQUEST);
}
if (experiment.getRunPartitions().stream().noneMatch(rp -> rp.getPartition().getId() == partition.getId() && rp.getRun().getId() == run.getId())) {
RunPartition rp = new RunPartition();
rp.setExperiment(experiment);
rp.setPartition(partition);
rp.setRun(run);
experiment.getRunPartitions().add(rp);
experimentService.update(experiment);
}
return get(experimentId);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Partition in project miso-lims by miso-lims.
the class SequencerPartitionContainerImpl method setPartitions.
@Override
public void setPartitions(List<Partition> partitions) {
this.partitions = partitions;
for (Partition p : partitions) {
p.setSequencerPartitionContainer(this);
}
Collections.sort(partitions, partitionNumberComparator);
}
Aggregations