use of uk.ac.bbsrc.tgac.miso.core.data.SampleSlide in project miso-lims by miso-lims.
the class AbstractBulkSampleIT method assertAllForSlide.
protected void assertAllForSlide(Map<String, String> slide, Long sampleId, boolean newlyCreated) {
SampleSlide target = (SampleSlide) getSession().get(SampleSlideImpl.class, sampleId);
assertPlainSampleAttributes(slide, target, newlyCreated);
assertDetailedSampleAttributes(slide, target);
assertSlideAttributes(slide, target);
if (newlyCreated) {
SampleTissue tissueParent = LimsUtils.getParent(SampleTissue.class, target);
assertTissueAttributes(slide, tissueParent);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.SampleSlide in project miso-lims by miso-lims.
the class DefaultSampleService method createGhostParent.
private DetailedSample createGhostParent(DetailedSample parent, DetailedSample child) throws IOException {
parent.setProject(child.getProject());
parent.setSubproject(child.getSubproject());
parent.setSampleType(child.getSampleType());
parent.setScientificName(child.getScientificName());
parent.setVolume(BigDecimal.ZERO);
parent.setVolumeUnits(VolumeUnit.MICROLITRES);
parent.setSynthetic(true);
if (child.getIdentityId() != null)
parent.setIdentityId(child.getIdentityId());
if (isTissuePieceSample(child) && isSampleSlide(parent)) {
SampleSlide parentSlides = (SampleSlide) parent;
Integer slides = parentSlides.getSlides() == null ? 0 : parentSlides.getSlides();
slides += ((SampleTissuePiece) child).getSlidesConsumed();
parentSlides.setSlides(slides);
if (parentSlides.isSaved()) {
update(parentSlides);
}
}
create(parent);
return parent;
}
use of uk.ac.bbsrc.tgac.miso.core.data.SampleSlide in project miso-lims by miso-lims.
the class DefaultSampleService method updateParentSlides.
private void updateParentSlides(Sample child, Sample beforeChange, User changeUser) {
if (child.getParent() == null || !isSampleSlide(child.getParent())) {
return;
}
SampleSlide parent = (SampleSlide) deproxify(child.getParent());
Integer slidesConsumed = null;
if (isTissuePieceSample(child)) {
slidesConsumed = ((SampleTissuePiece) child).getSlidesConsumed();
} else if (isStockSample(child)) {
slidesConsumed = ((SampleStock) child).getSlidesConsumed();
}
if (slidesConsumed == null) {
return;
}
if (beforeChange == null) {
updateParentSlides(parent, parent.getSlides() - slidesConsumed, changeUser);
} else {
Integer beforeSlidesConsumed = null;
if (isTissuePieceSample(beforeChange)) {
beforeSlidesConsumed = ((SampleTissuePiece) beforeChange).getSlidesConsumed();
} else if (isStockSample(beforeChange)) {
beforeSlidesConsumed = ((SampleStock) beforeChange).getSlidesConsumed();
}
if (!slidesConsumed.equals(beforeSlidesConsumed)) {
updateParentSlides(parent, parent.getSlides() + beforeSlidesConsumed - slidesConsumed, changeUser);
}
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.SampleSlide in project miso-lims by miso-lims.
the class Dtos method toSlideSample.
private static SampleSlide toSlideSample(@Nonnull SampleSlideDto from) {
SampleSlide to = new SampleSlideImpl();
setInteger(to::setInitialSlides, from.getInitialSlides(), true);
setInteger(to::setSlides, from.getSlides(), true);
setInteger(to::setThickness, from.getThickness(), true);
setObject(to::setStain, Stain::new, from.getStainId());
setBigDecimal(to::setPercentTumour, from.getPercentTumour());
setBigDecimal(to::setPercentNecrosis, from.getPercentNecrosis());
setBigDecimal(to::setMarkedArea, from.getMarkedArea());
setBigDecimal(to::setMarkedAreaPercentTumour, from.getMarkedAreaPercentTumour());
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.SampleSlide in project miso-lims by miso-lims.
the class Dtos method getParent.
/**
* Extracts parent details from the DTO, according to these possible cases:
*
* <ol>
* <li>parent ID is provided. This implies that the parent exists, so no other parent information will be required</li>
* <li>identity information and parentSampleClassId are provided. This implies that a tissue parent should be created, and that the
* identity may or may not yet exist. If the sampleClassId is an aliquot, a stockClassId must be provided. ParentAliquotClassId may be
* provided to indicate a second aliquot level in the hierarchy</li>
* <li>identity information is provided, but no parentSampleClassId. You must be creating a tissue in this case.</li>
* </ol>
*
* @param childDto
* the DTO to take parent details from
* @return the parent details from the DTO, or null if there are none. A returned sample will also include its own parent if applicable.
*/
private static DetailedSample getParent(@Nonnull DetailedSampleDto childDto) {
DetailedSample parent = null;
if (childDto.getParentId() != null) {
parent = new DetailedSampleImpl();
parent.setId(childDto.getParentId());
} else {
if (childDto instanceof SampleIdentityDto && childDto.getClass() != SampleIdentityDto.class) {
parent = toIdentitySample((SampleIdentityDto) childDto);
}
if (childDto instanceof SampleTissueDto && childDto.getClass() != SampleTissueDto.class) {
if (childDto.getParentSampleClassId() == null) {
throw new IllegalArgumentException("No tissue class specified.");
}
DetailedSample tissue = toTissueSample((SampleTissueDto) childDto);
tissue.setSampleClass(new SampleClassImpl());
tissue.getSampleClass().setId(childDto.getParentSampleClassId());
tissue.setParent(parent);
parent = tissue;
if (childDto instanceof SampleTissuePieceDto) {
SampleTissuePieceDto tissuePieceDto = (SampleTissuePieceDto) childDto;
if (tissuePieceDto.getParentSlideClassId() != null) {
SampleSlide slide = new SampleSlideImpl();
slide.setSampleClass(new SampleClassImpl());
slide.getSampleClass().setId(tissuePieceDto.getParentSlideClassId());
slide.setSlides(0);
slide.setParent(parent);
parent = slide;
}
}
}
if (childDto instanceof SampleSingleCellRelative && childDto.getClass() != SampleSingleCellDto.class) {
SampleStockDto stockDto = (SampleStockDto) childDto;
DetailedSample tissueProcessing = toSingleCellSample((SampleSingleCellRelative) childDto);
tissueProcessing.setSampleClass(new SampleClassImpl());
tissueProcessing.getSampleClass().setId(stockDto.getTissueProcessingClassId());
tissueProcessing.setParent(parent);
parent = tissueProcessing;
}
if (childDto instanceof SampleStockDto && childDto.getClass() != SampleStockDto.class && childDto.getClass() != SampleStockSingleCellDto.class && childDto.getClass() != SampleStockRnaDto.class) {
SampleAliquotDto aliquotDto = (SampleAliquotDto) childDto;
DetailedSample stock = toStockSample((SampleStockDto) childDto);
stock.setSampleClass(new SampleClassImpl());
stock.getSampleClass().setId(aliquotDto.getStockClassId());
stock.setParent(parent);
parent = stock;
if (aliquotDto.getParentAliquotClassId() != null) {
DetailedSample parentAliquot = toAliquotSample(aliquotDto);
parentAliquot.setSampleClass(new SampleClassImpl());
parentAliquot.getSampleClass().setId(aliquotDto.getParentAliquotClassId());
parentAliquot.setParent(parent);
parent = parentAliquot;
}
}
}
return parent;
}
Aggregations