use of uk.ac.bbsrc.tgac.miso.core.data.Library in project miso-lims by miso-lims.
the class PoolRestController method assignPool.
@PostMapping(value = "/{poolId}/assign", produces = "application/json")
@ResponseStatus(code = HttpStatus.NO_CONTENT)
public void assignPool(@PathVariable Long poolId, @RequestBody AssignPoolDto request) throws IOException {
Pool pool = poolId == 0 ? null : poolService.get(poolId);
// Determine if this pool transition is allowed for this experiment. If removing a pool, it strictly isn't. If the new pool contains the
// same library as the experiment, it's fine.
Predicate<Experiment> isTransitionValid = pool == null ? experiment -> false : experiment -> pool.getPoolContents().stream().map(pd -> pd.getAliquot().getLibraryId()).anyMatch(id -> id == experiment.getLibrary().getId());
//
request.getPartitionIds().stream().map(//
WhineyFunction.rethrow(containerService::getPartition)).peek(WhineyConsumer.rethrow(partition -> {
for (RunPosition runPos : partition.getSequencerPartitionContainer().getRunPositions()) {
Run run = runPos.getRun();
// Check that we aren't going to hose any existing experiments through this reassignment
boolean relatedExperimentsOkay = //
experimentService.listAllByRunId(run.getId()).stream().flatMap(//
experiment -> experiment.getRunPartitions().stream()).filter(//
rp -> rp.getRun().getId() == run.getId() && rp.getPartition().getId() == partition.getId()).map(//
RunPartition::getExperiment).allMatch(isTransitionValid);
if (!relatedExperimentsOkay) {
throw new RestException(String.format("%s %d is used in an experiment.", partition.getSequencerPartitionContainer().getModel().getPlatformType().getPartitionName(), partition.getPartitionNumber()), Status.BAD_REQUEST);
}
}
if (pool != null && partition.getSequencerPartitionContainer().getModel().getPlatformType() != pool.getPlatformType()) {
throw new RestException(String.format("%s %d in %s is not compatible with pool %s.", partition.getSequencerPartitionContainer().getModel().getPlatformType().getPartitionName(), partition.getPartitionNumber(), partition.getSequencerPartitionContainer().getIdentificationBarcode(), pool.getName()), Status.BAD_REQUEST);
}
partition.setPool(pool);
if (request.getConcentration() != null) {
partition.setLoadingConcentration(new BigDecimal(request.getConcentration()));
partition.setLoadingConcentrationUnits(request.getUnits());
} else {
partition.setLoadingConcentration(null);
partition.setLoadingConcentrationUnits(null);
}
})).forEach(WhineyConsumer.rethrow(containerService::update));
if (pool != null) {
poolService.update(pool);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.Library in project miso-lims by miso-lims.
the class NotificationManager method makeLibraryAliquotTable.
private static ContainerTag makeLibraryAliquotTable(Collection<TransferLibraryAliquot> transferLibraryAliquots) {
ContainerTag headerRow = tr(makeTh("Alias"), makeTh("Barcode"), makeTh("Location"), makeTh("Platform"), makeTh("Type"), makeTh("i7 Index Name"), makeTh("i7 Index"), makeTh("i5 Index Name"), makeTh("i5 Index"), makeTh("Targeted Sequencing"));
List<ContainerTag> rows = new ArrayList<>();
List<TransferLibraryAliquot> sorted = sortByAlias(transferLibraryAliquots);
for (TransferLibraryAliquot transferLibraryAliquot : sorted) {
LibraryAliquot libraryAliquot = transferLibraryAliquot.getItem();
Library library = libraryAliquot.getLibrary();
List<DomContent> cells = new ArrayList<>();
cells.add(makeTd(libraryAliquot.getAlias()));
cells.add(makeTd(libraryAliquot.getIdentificationBarcode()));
cells.add(makeTd(makeLocationLabel(transferLibraryAliquot)));
cells.add(makeTd(library.getPlatformType().getKey()));
cells.add(makeTd(library.getLibraryType().getDescription()));
cells.add(makeTd(library.getIndex1() == null ? null : library.getIndex1().getName()));
cells.add(makeTd(library.getIndex1() == null ? null : library.getIndex1().getSequence()));
cells.add(makeTd(library.getIndex2() == null ? null : library.getIndex2().getName()));
cells.add(makeTd(library.getIndex2() == null ? null : library.getIndex2().getSequence()));
rows.add(tr().with(cells));
}
return makeTable(headerRow, rows);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Library in project miso-lims by miso-lims.
the class HibernateLibraryDao method listBySampleId.
@Override
public List<Library> listBySampleId(long sampleId) throws IOException {
Criteria criteria = currentSession().createCriteria(LibraryImpl.class);
criteria.add(Restrictions.eq("sample.id", sampleId));
@SuppressWarnings("unchecked") List<Library> records = criteria.list();
return records;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Library in project miso-lims by miso-lims.
the class HibernateLibraryDao method listAll.
@Override
public List<Library> listAll() throws IOException {
Criteria criteria = currentSession().createCriteria(LibraryImpl.class);
@SuppressWarnings("unchecked") List<Library> records = criteria.list();
return records;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Library in project miso-lims by miso-lims.
the class HibernateLibraryDao method listByProjectId.
@Override
public List<Library> listByProjectId(long projectId) throws IOException {
Criteria criteria = currentSession().createCriteria(LibraryImpl.class);
criteria.createAlias("sample.project", "project");
criteria.add(Restrictions.eq("project.id", projectId));
@SuppressWarnings("unchecked") List<Library> records = criteria.list();
return records;
}
Aggregations