use of uk.ac.bbsrc.tgac.miso.dto.WorkstationDto in project miso-lims by miso-lims.
the class EditInstrumentController method setupForm.
private ModelAndView setupForm(Instrument instrument, ModelMap model) throws IOException {
InstrumentDto instrumentDto = Dtos.asDto(instrument);
if (instrument.isSaved()) {
Instrument preUpgrade = instrumentService.getByUpgradedInstrumentId(instrument.getId());
if (preUpgrade != null) {
instrumentDto.setPreUpgradeInstrumentId(preUpgrade.getId());
instrumentDto.setPreUpgradeInstrumentName(preUpgrade.getName());
}
}
ObjectMapper mapper = new ObjectMapper();
model.put("instrument", instrument);
model.put("instrumentDto", mapper.writeValueAsString(instrumentDto));
List<InstrumentDto> otherInstruments = instrumentService.list().stream().filter(other -> other.getId() != instrument.getId()).map(Dtos::asDto).collect(Collectors.toList());
model.put("otherInstruments", mapper.writeValueAsString(otherInstruments));
ArrayNode instrumentTypes = mapper.createArrayNode();
for (InstrumentType type : InstrumentType.values()) {
ObjectNode dto = instrumentTypes.addObject();
dto.put("label", type.getLabel());
dto.put("value", type.name());
}
model.put("instrumentTypes", mapper.writeValueAsString(instrumentTypes));
List<WorkstationDto> workstationDtos = workstationService.list().stream().map(Dtos::asDto).collect(Collectors.toList());
model.put("workstations", mapper.writeValueAsString(workstationDtos));
return new ModelAndView("/WEB-INF/pages/editInstrument.jsp", model);
}
Aggregations