Search in sources :

Example 1 with InstrumentType

use of uk.ac.bbsrc.tgac.miso.core.data.type.InstrumentType in project miso-lims by miso-lims.

the class ConstantsController method addInstrumentTypes.

private static void addInstrumentTypes(ObjectNode node) {
    ArrayNode instrumentTypes = node.putArray("instrumentTypes");
    for (InstrumentType type : InstrumentType.values()) {
        ObjectNode dto = instrumentTypes.addObject();
        dto.put("label", type.getLabel());
        dto.put("value", type.name());
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) InstrumentType(uk.ac.bbsrc.tgac.miso.core.data.type.InstrumentType) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 2 with InstrumentType

use of uk.ac.bbsrc.tgac.miso.core.data.type.InstrumentType 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);
}
Also used : InstrumentDto(uk.ac.bbsrc.tgac.miso.dto.InstrumentDto) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) InstrumentType(uk.ac.bbsrc.tgac.miso.core.data.type.InstrumentType) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WorkstationDto(uk.ac.bbsrc.tgac.miso.dto.WorkstationDto)

Aggregations

ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 InstrumentType (uk.ac.bbsrc.tgac.miso.core.data.type.InstrumentType)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 Instrument (uk.ac.bbsrc.tgac.miso.core.data.Instrument)1 InstrumentDto (uk.ac.bbsrc.tgac.miso.dto.InstrumentDto)1 WorkstationDto (uk.ac.bbsrc.tgac.miso.dto.WorkstationDto)1