use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class Dtos method toArraySamples.
private static Map<String, Sample> toArraySamples(List<ArraySampleDto> dtos) {
Map<String, Sample> samples = new HashMap<>();
if (dtos != null) {
for (ArraySampleDto dto : dtos) {
Sample sample = new SampleImpl();
sample.setId(dto.getId());
sample.setAlias(dto.getAlias());
sample.setName(dto.getName());
sample.setIdentificationBarcode(dto.getIdentificationBarcode());
samples.put(dto.getCoordinates(), sample);
}
}
return samples;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class Dtos method to.
public static Transfer to(@Nonnull TransferDto from) {
Transfer to = new Transfer();
setLong(to::setId, from.getId(), false);
setString(to::setTransferRequestName, from.getTransferRequestName());
setDateTime(to::setTransferTime, from.getTransferTime());
setObject(to::setSenderLab, LabImpl::new, from.getSenderLabId());
setObject(to::setSenderGroup, Group::new, from.getSenderGroupId());
setString(to::setRecipient, from.getRecipient());
setObject(to::setRecipientGroup, Group::new, from.getRecipientGroupId());
addTransferItems(to::getSampleTransfers, from.getItems(), EntityType.SAMPLE, TransferSample::new, SampleImpl::new, SampleBoxPosition::new, Sample::setBoxPosition);
addTransferItems(to::getLibraryTransfers, from.getItems(), EntityType.LIBRARY, TransferLibrary::new, LibraryImpl::new, LibraryBoxPosition::new, Library::setBoxPosition);
addTransferItems(to::getLibraryAliquotTransfers, from.getItems(), EntityType.LIBRARY_ALIQUOT, TransferLibraryAliquot::new, LibraryAliquot::new, LibraryAliquotBoxPosition::new, LibraryAliquot::setBoxPosition);
addTransferItems(to::getPoolTransfers, from.getItems(), EntityType.POOL, TransferPool::new, PoolImpl::new, PoolBoxPosition::new, Pool::setBoxPosition);
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class Dtos method asDto.
public static LibraryAliquotDto asDto(@Nonnull LibraryAliquot from, boolean includeBoxPositions) {
LibraryAliquotDto dto = null;
Library library = from.getLibrary();
Sample sample = library == null ? null : library.getSample();
if (isDetailedLibraryAliquot(from)) {
DetailedLibraryAliquotDto detailedDto = asDetailedDto((DetailedLibraryAliquot) from);
DetailedSample detailed = (DetailedSample) sample;
if (detailed.getSubproject() != null) {
detailedDto.setSubprojectAlias(detailed.getSubproject().getAlias());
detailedDto.setSubprojectPriority(detailed.getSubproject().getPriority());
}
if (detailed.getIdentityAttributes() != null) {
ParentIdentityAttributes identity = detailed.getIdentityAttributes();
setString(detailedDto::setIdentityConsentLevel, maybeGetProperty(identity.getConsentLevel(), ConsentLevel::getLabel));
setString(detailedDto::setEffectiveExternalNames, identity.getExternalName());
}
if (detailed.getTissueAttributes() != null) {
ParentTissueAttributes tissue = detailed.getTissueAttributes();
setString(detailedDto::setEffectiveTissueOriginAlias, tissue.getTissueOrigin().getAlias());
setString(detailedDto::setEffectiveTissueOriginDescription, tissue.getTissueOrigin().getDescription());
setString(detailedDto::setEffectiveTissueTypeAlias, tissue.getTissueType().getAlias());
setString(detailedDto::setEffectiveTissueTypeDescription, tissue.getTissueType().getDescription());
}
dto = detailedDto;
} else {
dto = new LibraryAliquotDto();
}
if (library != null) {
setLong(dto::setLibraryId, library.getId(), true);
setString(dto::setLibraryName, library.getName());
setString(dto::setLibraryAlias, library.getAlias());
setBoolean(dto::setLibraryLowQuality, library.isLowQuality(), false);
setString(dto::setLibraryPlatformType, library.getPlatformType().getKey());
if (library.getIndex1() != null) {
List<Index> indices = Stream.of(library.getIndex1(), library.getIndex2()).filter(Objects::nonNull).collect(Collectors.toList());
dto.setIndexIds(indices.stream().sorted(Comparator.comparingInt(Index::getPosition)).map(Index::getId).collect(Collectors.toList()));
dto.setIndexLabels(indices.stream().sorted(Comparator.comparingInt(Index::getPosition)).map(Index::getLabel).collect(Collectors.toList()));
}
if (sample != null) {
setLong(dto::setSampleId, sample.getId(), true);
setString(dto::setSampleName, sample.getName());
setString(dto::setSampleAlias, sample.getAlias());
}
}
if (from.getParentAliquot() != null) {
setLong(dto::setParentAliquotId, from.getParentAliquot().getId(), true);
setString(dto::setParentAliquotAlias, from.getParentAliquot().getAlias());
}
setString(dto::setParentName, maybeGetProperty(from.getParent(), HierarchyEntity::getName));
setString(dto::setParentVolume, maybeGetProperty(from.getParent(), HierarchyEntity::getVolume));
dto.setId(from.getId());
dto.setName(from.getName());
setString(dto::setAlias, from.getAlias());
setString(dto::setDescription, from.getDescription());
dto.setCreatorName(from.getCreator().getFullName());
setString(dto::setConcentration, from.getConcentration());
dto.setConcentrationUnits(from.getConcentrationUnits());
setString(dto::setVolume, from.getVolume());
dto.setVolumeUnits(from.getVolumeUnits());
setString(dto::setNgUsed, from.getNgUsed());
setString(dto::setVolumeUsed, from.getVolumeUsed());
setInteger(dto::setDnaSize, from.getDnaSize(), true);
if (from.getCreationDate() != null) {
dto.setCreationDate(formatDate(from.getCreationDate()));
}
dto.setIdentificationBarcode(from.getIdentificationBarcode());
dto.setLocationLabel(BoxUtils.makeLocationLabel(from));
if (from.getTargetedSequencing() != null) {
dto.setTargetedSequencingId(from.getTargetedSequencing().getId());
}
if (from.getBox() != null) {
dto.setBox(asDto(from.getBox(), includeBoxPositions));
dto.setBoxPosition(from.getBoxPosition());
}
dto.setDiscarded(from.isDiscarded());
setDateTimeString(dto::setLastModified, from.getLastModified());
setId(dto::setDetailedQcStatusId, from.getDetailedQcStatus());
setString(dto::setDetailedQcStatusNote, from.getDetailedQcStatusNote());
setString(dto::setQcUserName, maybeGetProperty(from.getQcUser(), User::getFullName));
setDateString(dto::setQcDate, from.getQcDate());
setEffectiveQcFailure(from, dto);
setId(dto::setKitDescriptorId, from.getKitDescriptor());
setString(dto::setKitLot, from.getKitLot());
Requisition requisition = from.getLibrary().getSample().getRequisition();
if (requisition == null) {
requisition = getParentRequisition(from.getLibrary().getSample());
}
setId(dto::setRequisitionId, requisition);
setString(dto::setRequisitionAlias, maybeGetProperty(requisition, Requisition::getAlias));
return dto;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class Dtos method to.
public static QC to(@Nonnull QcDto dto) {
QC to;
switch(dto.getQcTarget()) {
case "Library":
LibraryQC newLibraryQc = new LibraryQC();
Library ownerLibrary = new LibraryImpl();
ownerLibrary.setId(dto.getEntityId());
newLibraryQc.setLibrary(ownerLibrary);
to = newLibraryQc;
break;
case "Sample":
SampleQC newSampleQc = new SampleQC();
Sample ownerSample = new SampleImpl();
ownerSample.setId(dto.getEntityId());
newSampleQc.setSample(ownerSample);
to = newSampleQc;
break;
case "Pool":
PoolQC newPoolQc = new PoolQC();
Pool ownerPool = new PoolImpl();
ownerPool.setId(dto.getEntityId());
newPoolQc.setPool(ownerPool);
to = newPoolQc;
break;
case "Container":
ContainerQC newContainerQc = new ContainerQC();
SequencerPartitionContainer ownerContainer = new SequencerPartitionContainerImpl();
ownerContainer.setId(dto.getEntityId());
newContainerQc.setContainer(ownerContainer);
to = newContainerQc;
break;
case "Requisition":
RequisitionQC newRequisitionQc = new RequisitionQC();
Requisition ownerRequisition = new Requisition();
ownerRequisition.setId(dto.getEntityId());
newRequisitionQc.setRequisition(ownerRequisition);
to = newRequisitionQc;
break;
default:
throw new IllegalArgumentException("No such QC target: " + dto.getQcTarget());
}
if (dto.getId() != null) {
to.setId(dto.getId());
}
to.setDate(parseDate(dto.getDate()));
setBigDecimal(to::setResults, dto.getResults());
setObject(to::setType, QcType::new, dto.getQcTypeId());
to.setDescription(dto.getDescription());
setObject(to::setInstrument, InstrumentImpl::new, dto.getInstrumentId());
setObject(to::setKit, KitDescriptor::new, dto.getKitDescriptorId());
setString(to::setKitLot, dto.getKitLot());
addQcControlRuns(dto.getControls(), to, QcTarget.valueOf(dto.getQcTarget()));
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class DefaultArrayService method applyChanges.
private void applyChanges(Array from, Array to) throws IOException {
to.setAlias(from.getAlias());
to.setSerialNumber(from.getSerialNumber());
to.setDescription(from.getDescription());
// have to add/remove samples individually to avoid unnecessary "sample removed; sample added" changelogs for non-changes
Map<String, Sample> toSamples = to.getSamples();
Set<String> removePositions = toSamples.keySet().stream().filter(key -> !from.getSamples().containsKey(key)).collect(Collectors.toSet());
for (String key : removePositions) {
recordRemoval(to, toSamples.get(key).getName(), key);
toSamples.remove(key);
}
from.getSamples().forEach((key, val) -> {
Sample current = toSamples.get(key);
if (toSamples.get(key) == null || current.getId() != val.getId()) {
toSamples.put(key, val);
}
});
}
Aggregations