use of uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibraryAliquot in project miso-lims by miso-lims.
the class Dtos method to.
public static Workset to(@Nonnull WorksetDto from) {
Workset workset = new Workset();
setLong(workset::setId, from.getId(), false);
setString(workset::setAlias, from.getAlias());
setString(workset::setDescription, from.getDescription());
setObject(workset::setCategory, WorksetCategory::new, from.getCategoryId());
setObject(workset::setStage, WorksetStage::new, from.getStageId());
setWorksetItems(workset::setWorksetSamples, from.getSampleIds(), WorksetSample::new, SampleImpl::new);
setWorksetItems(workset::setWorksetLibraries, from.getLibraryIds(), WorksetLibrary::new, LibraryImpl::new);
setWorksetItems(workset::setWorksetLibraryAliquots, from.getLibraryAliquotIds(), WorksetLibraryAliquot::new, LibraryAliquot::new);
return workset;
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibraryAliquot in project miso-lims by miso-lims.
the class WorksetRestController method mergeWorksets.
@PostMapping("/merge")
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
public WorksetDto mergeWorksets(@RequestBody(required = true) MergeWorksetsRequestData data) throws IOException {
Workset workset = new Workset();
if (LimsUtils.isStringEmptyOrNull(data.getAlias())) {
throw new RestException("No alias provided for new workset", Status.BAD_REQUEST);
}
workset.setAlias(data.getAlias());
if (!LimsUtils.isStringEmptyOrNull(data.getDescription())) {
workset.setDescription(data.getDescription());
}
for (Long id : data.getIds()) {
Workset child = worksetService.get(id);
if (child == null) {
throw new RestException("No workset found with ID: " + id, Status.BAD_REQUEST);
}
copyWorksetItems(child.getWorksetSamples(), workset.getWorksetSamples(), WorksetSample::new);
copyWorksetItems(child.getWorksetLibraries(), workset.getWorksetLibraries(), WorksetLibrary::new);
copyWorksetItems(child.getWorksetLibraryAliquots(), workset.getWorksetLibraryAliquots(), WorksetLibraryAliquot::new);
}
worksetService.create(workset);
return Dtos.asDto(workset);
}
Aggregations