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);
}
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);
}
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());
}
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;
}
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());
}
Aggregations