Search in sources :

Example 1 with Partition

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());
}
Also used : Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) RunPartitionAliquotId(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot.RunPartitionAliquotId) User(com.eaglegenomics.simlims.core.User) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) RunLibraryQcStatus(uk.ac.bbsrc.tgac.miso.core.data.RunLibraryQcStatus) Date(java.util.Date) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 2 with Partition

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;
}
Also used : AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) Date(java.util.Date) DetailedQcStatus(uk.ac.bbsrc.tgac.miso.core.data.DetailedQcStatus) Autowired(org.springframework.beans.factory.annotation.Autowired) DetailedQcItem(uk.ac.bbsrc.tgac.miso.core.data.qc.DetailedQcItem) RunLibraryQcStatusService(uk.ac.bbsrc.tgac.miso.core.service.RunLibraryQcStatusService) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) LibraryAliquotService(uk.ac.bbsrc.tgac.miso.core.service.LibraryAliquotService) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) DetailedQcStatusService(uk.ac.bbsrc.tgac.miso.core.service.DetailedQcStatusService) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Service(org.springframework.stereotype.Service) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) PartitionQCType(uk.ac.bbsrc.tgac.miso.core.data.PartitionQCType) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) RunPartitionService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionService) QcStatusService(uk.ac.bbsrc.tgac.miso.core.service.QcStatusService) RunPartitionAliquotService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) SampleService(uk.ac.bbsrc.tgac.miso.core.service.SampleService) QcStatusUpdate(uk.ac.bbsrc.tgac.miso.core.data.impl.view.qc.QcStatusUpdate) LibraryService(uk.ac.bbsrc.tgac.miso.core.service.LibraryService) ListLibraryAliquotView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListLibraryAliquotView) Collection(java.util.Collection) IOException(java.io.IOException) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) PartitionQcTypeService(uk.ac.bbsrc.tgac.miso.core.service.PartitionQcTypeService) RunLibraryQcStatus(uk.ac.bbsrc.tgac.miso.core.data.RunLibraryQcStatus) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) Transactional(org.springframework.transaction.annotation.Transactional) EntityType(uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition)

Example 3 with 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());
}
Also used : Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition)

Example 4 with Partition

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;
            }
        }
    }
}
Also used : Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) IOException(java.io.IOException)

Example 5 with Partition

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);
}
Also used : RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) RunLibrarySpreadsheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.RunLibrarySpreadsheets) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) ArrayList(java.util.ArrayList) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Partition (uk.ac.bbsrc.tgac.miso.core.data.Partition)27 Run (uk.ac.bbsrc.tgac.miso.core.data.Run)21 RunPartitionAliquot (uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot)14 LibraryAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot)13 RunPartition (uk.ac.bbsrc.tgac.miso.core.data.RunPartition)12 Test (org.junit.Test)10 Pool (uk.ac.bbsrc.tgac.miso.core.data.Pool)10 IOException (java.io.IOException)9 List (java.util.List)9 PartitionImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl)9 User (com.eaglegenomics.simlims.core.User)8 Collectors (java.util.stream.Collectors)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 PoolElement (uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement)8 RunService (uk.ac.bbsrc.tgac.miso.core.service.RunService)8 Collection (java.util.Collection)7 Map (java.util.Map)7 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)7 AuthorizationManager (uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager)7 RunPartitionAliquotService (uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService)7