Search in sources :

Example 16 with Library

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);
    }
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) RequestParam(org.springframework.web.bind.annotation.RequestParam) LibraryAliquotSpreadSheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.LibraryAliquotSpreadSheets) SampleTissueProcessing(uk.ac.bbsrc.tgac.miso.core.data.SampleTissueProcessing) PoolSpreadSheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.PoolSpreadSheets) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) DataTablesResponseDto(uk.ac.bbsrc.tgac.miso.dto.DataTablesResponseDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) SequencingOrderSummaryViewService(uk.ac.bbsrc.tgac.miso.core.service.SequencingOrderSummaryViewService) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) BigDecimal(java.math.BigDecimal) PutMapping(org.springframework.web.bind.annotation.PutMapping) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Map(java.util.Map) ListPoolView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListPoolView) PostMapping(org.springframework.web.bind.annotation.PostMapping) ListLibraryAliquotViewService(uk.ac.bbsrc.tgac.miso.core.service.ListLibraryAliquotViewService) SampleService(uk.ac.bbsrc.tgac.miso.core.service.SampleService) SequencingOrderCompletionDto(uk.ac.bbsrc.tgac.miso.dto.SequencingOrderCompletionDto) PoolDto(uk.ac.bbsrc.tgac.miso.dto.PoolDto) AdvancedSearchParser(uk.ac.bbsrc.tgac.miso.webapp.controller.component.AdvancedSearchParser) PoolPickerEntry(uk.ac.bbsrc.tgac.miso.webapp.util.PoolPickerResponse.PoolPickerEntry) Predicate(java.util.function.Predicate) ListLibraryAliquotView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListLibraryAliquotView) Collection(java.util.Collection) ListPoolViewService(uk.ac.bbsrc.tgac.miso.core.service.ListPoolViewService) Collectors(java.util.stream.Collectors) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) StandardCharsets(java.nio.charset.StandardCharsets) LibraryDto(uk.ac.bbsrc.tgac.miso.dto.LibraryDto) List(java.util.List) HttpEntity(org.springframework.http.HttpEntity) MisoWebUtils(uk.ac.bbsrc.tgac.miso.webapp.util.MisoWebUtils) Stream(java.util.stream.Stream) SequencingParametersService(uk.ac.bbsrc.tgac.miso.core.service.SequencingParametersService) SampleStock(uk.ac.bbsrc.tgac.miso.core.data.SampleStock) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) Entry(java.util.Map.Entry) LibraryAliquotDto(uk.ac.bbsrc.tgac.miso.dto.LibraryAliquotDto) SampleIdentity(uk.ac.bbsrc.tgac.miso.core.data.SampleIdentity) PoolPickerResponse(uk.ac.bbsrc.tgac.miso.webapp.util.PoolPickerResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) LibraryAliquotService(uk.ac.bbsrc.tgac.miso.core.service.LibraryAliquotService) ArrayList(java.util.ArrayList) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) Value(org.springframework.beans.factory.annotation.Value) RequestBody(org.springframework.web.bind.annotation.RequestBody) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) HttpServletRequest(javax.servlet.http.HttpServletRequest) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) ContainerService(uk.ac.bbsrc.tgac.miso.core.service.ContainerService) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) Status(javax.ws.rs.core.Response.Status) SampleAliquot(uk.ac.bbsrc.tgac.miso.core.data.SampleAliquot) SampleTissue(uk.ac.bbsrc.tgac.miso.core.data.SampleTissue) ConcentrationUnit(uk.ac.bbsrc.tgac.miso.core.data.ConcentrationUnit) LibraryService(uk.ac.bbsrc.tgac.miso.core.service.LibraryService) WhineyFunction(uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction) HttpServletResponse(javax.servlet.http.HttpServletResponse) SpreadsheetRequest(uk.ac.bbsrc.tgac.miso.dto.SpreadsheetRequest) IOException(java.io.IOException) SequencingParameters(uk.ac.bbsrc.tgac.miso.core.data.SequencingParameters) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) WhineyConsumer(uk.ac.bbsrc.tgac.miso.core.util.WhineyConsumer) Consumer(java.util.function.Consumer) HttpStatus(org.springframework.http.HttpStatus) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) ExperimentService(uk.ac.bbsrc.tgac.miso.core.service.ExperimentService) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) PaginatedDataSource(uk.ac.bbsrc.tgac.miso.core.util.PaginatedDataSource) IlluminaExperiment(uk.ac.bbsrc.tgac.miso.core.util.IlluminaExperiment) AsyncOperationManager(uk.ac.bbsrc.tgac.miso.webapp.controller.component.AsyncOperationManager) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) IlluminaExperiment(uk.ac.bbsrc.tgac.miso.core.util.IlluminaExperiment) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) BigDecimal(java.math.BigDecimal) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 17 with Library

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);
}
Also used : TransferLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibraryAliquot) ArrayList(java.util.ArrayList) DomContent(j2html.tags.DomContent) ContainerTag(j2html.tags.ContainerTag) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) TransferLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibraryAliquot) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) TransferLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary)

Example 18 with Library

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;
}
Also used : Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria) Library(uk.ac.bbsrc.tgac.miso.core.data.Library)

Example 19 with Library

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;
}
Also used : Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria) Library(uk.ac.bbsrc.tgac.miso.core.data.Library)

Example 20 with Library

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;
}
Also used : Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria) Library(uk.ac.bbsrc.tgac.miso.core.data.Library)

Aggregations

Library (uk.ac.bbsrc.tgac.miso.core.data.Library)56 Test (org.junit.Test)23 LibraryImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl)20 DetailedLibrary (uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary)14 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)13 TransferLibrary (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary)13 LibraryAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot)11 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)10 Pool (uk.ac.bbsrc.tgac.miso.core.data.Pool)8 ArrayList (java.util.ArrayList)7 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)7 IOException (java.io.IOException)6 PostMapping (org.springframework.web.bind.annotation.PostMapping)6 RunDto (uk.ac.bbsrc.tgac.miso.dto.run.RunDto)6 Collection (java.util.Collection)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 WorksetLibrary (uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibrary)5 Date (java.util.Date)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)4