use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.
the class EditArrayController method setupForm.
@RequestMapping("/{arrayId}")
public ModelAndView setupForm(@PathVariable(name = "arrayId", required = true) long arrayId, ModelMap model) throws IOException {
model.addAttribute(PageMode.PROPERTY, PageMode.EDIT.getLabel());
Array array = arrayService.get(arrayId);
if (array == null) {
throw new NotFoundException("Array not found");
}
model.addAttribute(MODEL_ATTR_ARRAYRUNS, arrayRunService.listByArrayId(arrayId).stream().map(Dtos::asDto).collect(Collectors.toList()));
ObjectMapper mapper = new ObjectMapper();
model.addAttribute(MODEL_ATTR_JSON, mapper.writer().writeValueAsString(Dtos.asDto(array)));
return new ModelAndView(JSP, model);
}
use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.
the class EditSampleController method setupForm.
@GetMapping(value = "/{sampleId}")
public ModelAndView setupForm(@PathVariable Long sampleId, ModelMap model) throws IOException {
Sample sample = sampleService.get(sampleId);
if (sample == null)
throw new NotFoundException("No sample found for ID " + sampleId.toString());
model.put("title", "Sample " + sampleId);
model.put("previousSample", sampleService.getPreviousInProject(sample));
model.put("nextSample", sampleService.getNextInProject(sample));
model.put("sampleCategory", LimsUtils.isDetailedSample(sample) ? ((DetailedSample) sample).getSampleClass().getSampleCategory() : "plain");
List<LibraryDto> libraries = sample.isSaved() ? libraryService.listBySampleId(sample.getId()).stream().map(lib -> Dtos.asDto(lib, false)).collect(Collectors.toList()) : Collections.emptyList();
model.put("sampleLibraries", libraries);
Set<Pool> pools = libraries.stream().flatMap(WhineyFunction.flatRethrow(library -> poolService.listByLibraryId(library.getId()))).distinct().collect(Collectors.toSet());
List<RunDto> runDtos = pools.stream().flatMap(WhineyFunction.flatRethrow(pool -> runService.listByPoolId(pool.getId()))).map(Dtos::asDto).collect(Collectors.toList());
model.put("samplePools", pools.stream().map(p -> Dtos.asDto(p, false, false, indexChecker)).collect(Collectors.toList()));
model.put("sampleRuns", runDtos);
model.put("sampleRelations", getRelations(sample));
addArrayData(sampleId, model);
model.put("sampleTransfers", sample.getTransferViews().stream().map(Dtos::asDto).collect(Collectors.toList()));
model.put("sample", sample);
SampleDto sampleDto = Dtos.asDto(sample, false, libraries.size());
setRelatedSlideDtos(sample, sampleDto);
model.put("sampleDto", !sample.isSaved() ? "null" : mapper.writeValueAsString(sampleDto));
ObjectNode formConfig = mapper.createObjectNode();
formConfig.put("detailedSample", isDetailedSampleEnabled());
MisoWebUtils.addJsonArray(mapper, formConfig, "projects", projectService.list(), Dtos::asDto);
MisoWebUtils.addJsonArray(mapper, formConfig, Config.SOPS, sopService.listByCategory(SopCategory.SAMPLE), Dtos::asDto);
model.put("formConfig", mapper.writeValueAsString(formConfig));
return new ModelAndView("/WEB-INF/pages/editSample.jsp", model);
}
use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.
the class EditUserController method setupForm.
private ModelAndView setupForm(User user, ModelMap model) throws IOException {
model.put("title", user.isSaved() ? ("User " + user.getId()) : "New User");
model.put("user", user);
ObjectMapper mapper = new ObjectMapper();
model.put("userDto", mapper.writeValueAsString(Dtos.asDto(user)));
if (user.isSaved()) {
model.put("groups", user.getGroups().stream().map(Dtos::asDto).collect(Collectors.toList()));
}
return new ModelAndView("/WEB-INF/pages/editUser.jsp", model);
}
use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.
the class EditExperimentController method setupForm.
@GetMapping(value = "/{experimentId}")
public ModelAndView setupForm(@PathVariable Long experimentId, ModelMap model) throws IOException {
Experiment experiment = experimentService.get(experimentId);
if (experiment == null)
throw new NotFoundException("No experiment found for ID " + experimentId.toString());
ObjectMapper mapper = new ObjectMapper();
ObjectNode consumableConfig = mapper.createObjectNode();
consumableConfig.put("experimentId", experiment.getId());
Stream.<//
KitDescriptor>concat(//
Stream.of(experiment.getLibrary().getKitDescriptor()), //
experiment.getRunPartitions().stream().map(//
RunPartition::getPartition).flatMap(partition -> Stream.of(partition.getSequencerPartitionContainer().getClusteringKit(), //
partition.getSequencerPartitionContainer().getMultiplexingKit()))).filter(//
Objects::nonNull).distinct().map(//
Dtos::asDto).forEach(consumableConfig.putArray("allowedDescriptors")::addPOJO);
model.put("experiment", experiment);
model.put("experimentDto", mapper.writeValueAsString(Dtos.asDto(experiment)));
model.put("consumables", experiment.getKits().stream().map(Dtos::asDto).collect(Collectors.toList()));
model.put("consumableConfig", mapper.writeValueAsString(consumableConfig));
model.put("runPartitions", experiment.getRunPartitions().stream().map(entry -> new ExperimentDto.RunPartitionDto(Dtos.asDto(entry.getRun()), Dtos.asDto(entry.getPartition(), indexChecker))).collect(Collectors.toList()));
model.put("title", "Edit Experiment");
return new ModelAndView("/WEB-INF/pages/editExperiment.jsp", model);
}
use of uk.ac.bbsrc.tgac.miso.dto.Dtos in project miso-lims by miso-lims.
the class EditGroupController method adminSetupForm.
@RequestMapping(value = "/{groupId}", method = RequestMethod.GET)
public ModelAndView adminSetupForm(@PathVariable long groupId, ModelMap model) throws IOException {
model.put("title", "Group " + groupId);
Group group = groupService.get(groupId);
if (group == null) {
throw new NotFoundException("No group found for ID " + groupId);
}
model.put("includedUsers", group.getUsers().stream().map(Dtos::asDto).collect(Collectors.toList()));
model.put("availableUsers", userService.list().stream().map(Dtos::asDto).collect(Collectors.toList()));
return setupForm(group, model);
}
Aggregations