Search in sources :

Example 6 with QC

use of uk.ac.bbsrc.tgac.miso.core.data.qc.QC in project miso-lims by miso-lims.

the class QcRestController method update.

@PutMapping(path = "/{id}")
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public QcDto update(@PathVariable("id") Long id, @RequestBody QcDto qc) throws IOException {
    QC updated = Dtos.to(qc);
    updated.setId(id);
    return Dtos.asDto(qcService.update(updated));
}
Also used : QC(uk.ac.bbsrc.tgac.miso.core.data.qc.QC) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PutMapping(org.springframework.web.bind.annotation.PutMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with QC

use of uk.ac.bbsrc.tgac.miso.core.data.qc.QC in project miso-lims by miso-lims.

the class QcRestController method bulkDelete.

@PostMapping(value = "/bulk-delete")
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public void bulkDelete(@RequestParam String qcTarget, @RequestBody(required = true) List<Long> ids) throws IOException {
    List<QC> items = new ArrayList<>();
    QcTarget target = null;
    try {
        target = QcTarget.valueOf(qcTarget);
    } catch (IllegalArgumentException e) {
        throw new RestException("Unsupported QC target: " + qcTarget, Status.BAD_REQUEST);
    }
    for (Long id : ids) {
        if (id == null) {
            throw new RestException("QC id cannot be null", Status.BAD_REQUEST);
        }
        QC item = qcService.get(target, id);
        if (item == null) {
            throw new RestException(String.format("No %s QC found with ID: %d", qcTarget, id), Status.BAD_REQUEST);
        }
        items.add(item);
    }
    qcService.bulkDelete(items);
}
Also used : QC(uk.ac.bbsrc.tgac.miso.core.data.qc.QC) ArrayList(java.util.ArrayList) QcTarget(uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with QC

use of uk.ac.bbsrc.tgac.miso.core.data.qc.QC in project miso-lims by miso-lims.

the class QcController method editBulk.

@PostMapping("/bulk/edit/{qcTarget}")
public ModelAndView editBulk(@PathVariable("qcTarget") String qcTargetLabel, @RequestParam Map<String, String> form, ModelMap model) throws IOException {
    QcTarget qcTarget = getQcTarget(qcTargetLabel);
    String qcIds = getStringInput("ids", form, true);
    int addControls = getIntegerInput("addControls", form, true);
    return new BulkEditTableBackend<QC, QcDto>("qc", QcDto.class, "QCs") {

        @Override
        protected QcDto asDto(QC model) {
            return Dtos.asDto(model);
        }

        @Override
        protected Stream<QC> load(List<Long> modelIds) throws IOException {
            return modelIds.stream().map(WhineyFunction.rethrow(id -> qcService.get(qcTarget, id)));
        }

        @Override
        protected void writeConfiguration(ObjectMapper mapper, ObjectNode config) throws IOException {
            config.putPOJO("instruments", instrumentService.list().stream().map(Dtos::asDto).collect(Collectors.toList()));
            config.put("addControls", addControls);
            config.put("qcTarget", qcTarget.getLabel());
        }

        @Override
        protected boolean isNewInterface() {
            return true;
        }
    }.edit(qcIds, model);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) QcTarget(uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget) IOException(java.io.IOException) QcDto(uk.ac.bbsrc.tgac.miso.dto.QcDto) QC(uk.ac.bbsrc.tgac.miso.core.data.qc.QC) Stream(java.util.stream.Stream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

QC (uk.ac.bbsrc.tgac.miso.core.data.qc.QC)8 ContainerQC (uk.ac.bbsrc.tgac.miso.core.data.qc.ContainerQC)4 LibraryQC (uk.ac.bbsrc.tgac.miso.core.data.qc.LibraryQC)4 PoolQC (uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQC)4 QcTarget (uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget)4 SampleQC (uk.ac.bbsrc.tgac.miso.core.data.qc.SampleQC)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)2 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)1 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)1 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)1 User (com.eaglegenomics.simlims.core.User)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Stream (java.util.stream.Stream)1 Authentication (org.springframework.security.core.Authentication)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1