Search in sources :

Example 16 with SampleClass

use of uk.ac.bbsrc.tgac.miso.core.data.SampleClass in project miso-lims by miso-lims.

the class SampleRestController method buildHierarchy.

/**
 * Converts the DTO to a Sample, complete with parents. Parent SampleClasses are inferred where necessary
 *
 * @param sampleDto
 * @return
 * @throws IOException
 */
public Sample buildHierarchy(SampleDto sampleDto) throws IOException {
    if (sampleDto instanceof SampleAliquotDto) {
        SampleAliquotDto dto = (SampleAliquotDto) sampleDto;
        dto.setStockClassId(inferIntermediateSampleClassId(dto, dto.getSampleClassId(), SampleAliquot.CATEGORY_NAME, SampleStock.CATEGORY_NAME, true));
        // Some hierarchies have two Aliquot levels
        if (dto.getStockClassId() == null) {
            dto.setParentAliquotClassId(inferIntermediateSampleClassId(dto, dto.getSampleClassId(), SampleAliquot.CATEGORY_NAME, SampleAliquot.CATEGORY_NAME, false));
            Long topAliquotClassId = dto.getParentAliquotClassId() == null ? dto.getSampleClassId() : dto.getParentAliquotClassId();
            dto.setStockClassId(inferIntermediateSampleClassId(dto, topAliquotClassId, SampleAliquot.CATEGORY_NAME, SampleStock.CATEGORY_NAME, false));
        }
        if (dto.getParentId() == null) {
            // infer tissue processing class if necessary
            SampleClass processingClass = sampleClassService.getRequiredTissueProcessingClass(dto.getStockClassId());
            if (processingClass != null) {
                dto.setTissueProcessingClassId(processingClass.getId());
                // infer tissue class
                dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, dto.getTissueProcessingClassId(), SampleTissueProcessing.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
            } else {
                // infer tissue class
                dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, dto.getStockClassId(), SampleStock.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
            }
        }
    } else if (sampleDto instanceof SampleStockDto) {
        // infer tissue processing class if necessary
        SampleStockDto dto = (SampleStockDto) sampleDto;
        SampleClass processingClass = sampleClassService.getRequiredTissueProcessingClass(dto.getSampleClassId());
        if (processingClass != null) {
            dto.setTissueProcessingClassId(processingClass.getId());
            // infer tissue class
            dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, dto.getTissueProcessingClassId(), SampleTissueProcessing.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
        } else {
            // infer tissue class
            dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, dto.getSampleClassId(), SampleStock.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
        }
    } else if (sampleDto instanceof SampleTissueProcessingDto) {
        DetailedSampleDto dto = (DetailedSampleDto) sampleDto;
        Long topProcessingClassId = dto.getSampleClassId();
        if (sampleDto instanceof SampleTissuePieceDto) {
            SampleTissuePieceDto lcmDto = (SampleTissuePieceDto) dto;
            // Some hierarchies have two Tissue Processing levels
            lcmDto.setParentSlideClassId(inferIntermediateSampleClassId(dto, dto.getSampleClassId(), SampleTissueProcessing.CATEGORY_NAME, SampleTissueProcessing.CATEGORY_NAME, true));
            if (lcmDto.getParentSlideClassId() != null) {
                topProcessingClassId = lcmDto.getParentSlideClassId();
            }
        }
        dto.setParentSampleClassId(inferIntermediateSampleClassId(dto, topProcessingClassId, SampleTissueProcessing.CATEGORY_NAME, SampleTissue.CATEGORY_NAME, false));
    }
    return Dtos.to(sampleDto);
}
Also used : DetailedSampleDto(uk.ac.bbsrc.tgac.miso.dto.DetailedSampleDto) SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) SampleTissueProcessingDto(uk.ac.bbsrc.tgac.miso.dto.SampleTissueProcessingDto) SampleTissuePieceDto(uk.ac.bbsrc.tgac.miso.dto.SampleTissuePieceDto) SampleAliquotDto(uk.ac.bbsrc.tgac.miso.dto.SampleAliquotDto) SampleStockDto(uk.ac.bbsrc.tgac.miso.dto.SampleStockDto)

Example 17 with SampleClass

use of uk.ac.bbsrc.tgac.miso.core.data.SampleClass in project miso-lims by miso-lims.

the class SampleClassController method edit.

@GetMapping("/{id}")
public ModelAndView edit(@PathVariable("id") long id, ModelMap model) throws IOException {
    SampleClass sampleClass = sampleClassService.get(id);
    if (sampleClass == null) {
        throw new NotFoundException("No sample class found for ID: " + id);
    }
    model.put(PageMode.PROPERTY, PageMode.EDIT.getLabel());
    model.put("title", "Sample Class " + id);
    return sampleClassPage(sampleClass, model);
}
Also used : SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) NotFoundException(org.springframework.security.acls.model.NotFoundException) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 18 with SampleClass

use of uk.ac.bbsrc.tgac.miso.core.data.SampleClass in project miso-lims by miso-lims.

the class HibernateLibraryDesignDaoIT method testGetByNameAndSampleClass.

@Test
public void testGetByNameAndSampleClass() throws IOException {
    String name = "DESIGN2";
    SampleClass sampleClass = (SampleClass) currentSession().get(SampleClassImpl.class, 2L);
    LibraryDesign design = dao.getByNameAndSampleClass(name, sampleClass);
    assertNotNull(design);
    assertEquals(name, design.getName());
    assertEquals(2L, design.getSampleClass().getId());
}
Also used : LibraryDesign(uk.ac.bbsrc.tgac.miso.core.data.LibraryDesign) SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) SampleClassImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleClassImpl) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Example 19 with SampleClass

use of uk.ac.bbsrc.tgac.miso.core.data.SampleClass in project miso-lims by miso-lims.

the class HibernateAssayTestDaoIT method getCreateItem.

@Override
public AssayTest getCreateItem() {
    AssayTest test = new AssayTest();
    test.setAlias("Test test");
    TissueType tissueType = (TissueType) currentSession().get(TissueTypeImpl.class, 1L);
    test.setTissueType(tissueType);
    SampleClass extractionClass = (SampleClass) currentSession().get(SampleClassImpl.class, 3L);
    test.setExtractionClass(extractionClass);
    LibraryDesignCode code = (LibraryDesignCode) currentSession().get(LibraryDesignCode.class, 2L);
    test.setLibraryDesignCode(code);
    test.setLibraryQualificationMethod(AssayTest.LibraryQualificationMethod.LOW_DEPTH_SEQUENCING);
    return test;
}
Also used : LibraryDesignCode(uk.ac.bbsrc.tgac.miso.core.data.LibraryDesignCode) AssayTest(uk.ac.bbsrc.tgac.miso.core.data.impl.AssayTest) TissueType(uk.ac.bbsrc.tgac.miso.core.data.TissueType) SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) SampleClassImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleClassImpl) TissueTypeImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.TissueTypeImpl)

Example 20 with SampleClass

use of uk.ac.bbsrc.tgac.miso.core.data.SampleClass in project miso-lims by miso-lims.

the class HibernateSampleClassDaoIT method testUpdate.

@Test
public void testUpdate() throws IOException {
    long id = 1L;
    String alias = "New Alias";
    SampleClass sampleClass = (SampleClass) getSessionFactory().getCurrentSession().get(SampleClassImpl.class, id);
    assertNotEquals(alias, sampleClass.getAlias());
    sampleClass.setAlias(alias);
    sut.update(sampleClass);
    clearSession();
    SampleClass saved = (SampleClass) getSessionFactory().getCurrentSession().get(SampleClassImpl.class, id);
    assertEquals(alias, saved.getAlias());
}
Also used : SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) SampleClassImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleClassImpl) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Aggregations

SampleClass (uk.ac.bbsrc.tgac.miso.core.data.SampleClass)41 SampleClassImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleClassImpl)27 SampleStock (uk.ac.bbsrc.tgac.miso.core.data.SampleStock)10 SampleTissue (uk.ac.bbsrc.tgac.miso.core.data.SampleTissue)10 Test (org.junit.Test)8 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)8 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)8 SampleStockImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleStockImpl)8 SampleAliquot (uk.ac.bbsrc.tgac.miso.core.data.SampleAliquot)6 SampleIdentity (uk.ac.bbsrc.tgac.miso.core.data.SampleIdentity)5 SampleValidRelationship (uk.ac.bbsrc.tgac.miso.core.data.SampleValidRelationship)5 SampleTissueImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleTissueImpl)4 User (com.eaglegenomics.simlims.core.User)3 HashSet (java.util.HashSet)3 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)3 SampleTissuePiece (uk.ac.bbsrc.tgac.miso.core.data.SampleTissuePiece)3 SampleAliquotImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleAliquotImpl)3 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)2 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)2 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)2