use of uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition in project miso-lims by miso-lims.
the class RequisitionRestController method addSamples.
@PostMapping("/{requisitionId}/samples")
@ResponseBody
public ObjectNode addSamples(@PathVariable long requisitionId, @RequestBody List<Long> ids) throws IOException {
Requisition requisition = RestUtils.retrieve(TYPE_LABEL, requisitionId, requisitionService, Status.NOT_FOUND);
List<Sample> samples = new ArrayList<>();
for (Long id : ids) {
Sample sample = RestUtils.retrieve("Sample", id, sampleService, Status.BAD_REQUEST);
sample.setRequisition(requisition);
samples.add(sample);
}
return asyncOperationManager.startAsyncBulkUpdate("Sample", samples, sampleService);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition in project miso-lims by miso-lims.
the class DefaultRequisitionService method addNote.
@Override
public void addNote(Requisition entity, Note note) throws IOException {
Requisition managed = requisitionDao.get(entity.getId());
note.setCreationDate(new Date());
note.setOwner(authorizationManager.getCurrentUser());
managed.addNote(note);
managed.setLastModifier(authorizationManager.getCurrentUser());
requisitionDao.update(managed);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition 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.impl.Requisition 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.impl.Requisition in project miso-lims by miso-lims.
the class RequisitionRestController method moveSamples.
@PostMapping("/{requisitionId}/samples/move")
@ResponseBody
public RequisitionDto moveSamples(@PathVariable long requisitionId, @RequestBody MoveSamplesRequest request) throws IOException {
List<Sample> samples = new ArrayList<>();
for (Long id : request.sampleIds) {
Sample sample = RestUtils.retrieve("Sample", id, sampleService, Status.BAD_REQUEST);
samples.add(sample);
}
Requisition requisition = null;
if (request.requisitionId != null) {
requisition = RestUtils.retrieve("Requisition", request.requisitionId, requisitionService, Status.BAD_REQUEST);
} else {
requisition = new Requisition();
requisition.setAlias(request.requisitionAlias);
Assay assay = new Assay();
assay.setId(request.assayId);
requisition.setAssay(assay);
requisition.setStopped(request.stopped);
}
Requisition saved = requisitionService.moveToRequisition(requisition, samples);
return RequisitionDto.from(saved);
}
Aggregations