Search in sources :

Example 6 with EntityNotFoundException

use of ubic.gemma.web.util.EntityNotFoundException in project Gemma by PavlidisLab.

the class ExperimentalDesignControllerImpl method show.

@Override
@RequestMapping("/showExperimentalDesign.html")
public ModelAndView show(HttpServletRequest request, HttpServletResponse response) {
    String idstr = request.getParameter("eeid");
    String edStr = request.getParameter("edid");
    if (StringUtils.isBlank(idstr) && StringUtils.isBlank(edStr)) {
        throw new IllegalArgumentException("Must supply 'eeid' or 'edid' parameter");
    }
    Long designId;
    ExpressionExperiment ee;
    ExperimentalDesign experimentalDesign;
    if (StringUtils.isNotBlank(idstr)) {
        try {
            Long id = Long.parseLong(idstr);
            ee = expressionExperimentService.load(id);
            if (ee == null) {
                throw new EntityNotFoundException("Expression experiment with id=" + id + " cannot be accessed");
            }
            designId = ee.getExperimentalDesign().getId();
            experimentalDesign = experimentalDesignService.load(designId);
            if (experimentalDesign == null) {
                throw new EntityNotFoundException(designId + " not found");
            }
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("eeid must be a number");
        }
    } else {
        try {
            designId = Long.parseLong(edStr);
            experimentalDesign = experimentalDesignService.load(designId);
            if (experimentalDesign == null) {
                throw new EntityNotFoundException(designId + " not found");
            }
            ee = experimentalDesignService.getExpressionExperiment(experimentalDesign);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("edid must be a number");
        }
    }
    request.setAttribute("id", designId);
    ee = expressionExperimentService.thawLite(ee);
    // strip white spaces
    String desc = ee.getDescription();
    ee.setDescription(StringUtils.strip(desc));
    ModelAndView mnv = new ModelAndView("experimentalDesign.detail");
    mnv.addObject("taxonId", expressionExperimentService.getTaxon(ee).getId());
    mnv.addObject("hasPopulatedDesign", ee.getExperimentalDesign().getExperimentalFactors().size() > 0);
    mnv.addObject("experimentalDesign", ee.getExperimentalDesign());
    mnv.addObject("expressionExperiment", ee);
    mnv.addObject("currentUserCanEdit", securityService.isEditable(ee) ? "true" : "");
    mnv.addObject("expressionExperimentUrl", AnchorTagUtil.getExpressionExperimentUrl(ee.getId()));
    return mnv;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with EntityNotFoundException

use of ubic.gemma.web.util.EntityNotFoundException in project Gemma by PavlidisLab.

the class ArrayDesignControllerImpl method showCompositeSequences.

@Override
@RequestMapping("/showCompositeSequenceSummary.html")
public ModelAndView showCompositeSequences(HttpServletRequest request) {
    String arrayDesignIdStr = request.getParameter("id");
    if (arrayDesignIdStr == null) {
        // should be a validation error, on 'submit'.
        throw new EntityNotFoundException("Must provide a platform name or Id");
    }
    ArrayDesign arrayDesign = arrayDesignService.load(Long.parseLong(arrayDesignIdStr));
    ModelAndView mav = new ModelAndView("compositeSequences.geneMap");
    if (!AJAX) {
        Collection<CompositeSequenceMapValueObject> compositeSequenceSummary = getDesignSummaries(arrayDesign);
        if (compositeSequenceSummary == null || compositeSequenceSummary.size() == 0) {
            throw new RuntimeException("No probes found for " + arrayDesign);
        }
        mav.addObject("sequenceData", compositeSequenceSummary);
        mav.addObject("numCompositeSequences", compositeSequenceSummary.size());
    }
    mav.addObject("arrayDesign", arrayDesign);
    return mav;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ModelAndView(org.springframework.web.servlet.ModelAndView) CompositeSequenceMapValueObject(ubic.gemma.core.analysis.sequence.CompositeSequenceMapValueObject) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with EntityNotFoundException

use of ubic.gemma.web.util.EntityNotFoundException in project Gemma by PavlidisLab.

the class ArrayDesignControllerImpl method downloadAnnotationFile.

@Override
@RequestMapping(value = "/downloadAnnotationFile.html", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public ModelAndView downloadAnnotationFile(HttpServletRequest request, HttpServletResponse response) {
    String arrayDesignIdStr = request.getParameter("id");
    if (arrayDesignIdStr == null) {
        // should be a validation error, on 'submit'.
        throw new EntityNotFoundException("Must provide a platform name or Id");
    }
    String fileType = request.getParameter("fileType");
    if (fileType == null)
        fileType = ArrayDesignAnnotationService.STANDARD_FILE_SUFFIX;
    else if (fileType.equalsIgnoreCase("noParents"))
        fileType = ArrayDesignAnnotationService.NO_PARENTS_FILE_SUFFIX;
    else if (fileType.equalsIgnoreCase("bioProcess"))
        fileType = ArrayDesignAnnotationService.BIO_PROCESS_FILE_SUFFIX;
    else
        fileType = ArrayDesignAnnotationService.STANDARD_FILE_SUFFIX;
    ArrayDesign arrayDesign = arrayDesignService.load(Long.parseLong(arrayDesignIdStr));
    String fileBaseName = ArrayDesignAnnotationServiceImpl.mungeFileName(arrayDesign.getShortName());
    String fileName = fileBaseName + fileType + ArrayDesignAnnotationService.ANNOTATION_FILE_SUFFIX;
    File f = new File(ArrayDesignAnnotationService.ANNOT_DATA_DIR + fileName);
    if (!f.canRead()) {
        throw new RuntimeException("The file could not be found for " + arrayDesign.getShortName() + ". Please contact gemma@chibi.ubc.ca for assistance");
    }
    try (InputStream reader = new BufferedInputStream(new FileInputStream(f))) {
        response.setHeader("Content-disposition", "attachment; filename=" + fileName);
        response.setContentLength((int) f.length());
        try (OutputStream outputStream = response.getOutputStream()) {
            byte[] buf = new byte[1024];
            int len;
            while ((len = reader.read(buf)) > 0) {
                outputStream.write(buf, 0, len);
            }
            reader.close();
        } catch (IOException ioe) {
            log.warn("Failure during streaming of annotation file " + fileName + " Error: " + ioe);
        }
    } catch (FileNotFoundException e) {
        log.warn("Annotation file " + fileName + " can't be found at " + e);
        return null;
    } catch (IOException e) {
        log.warn("Annotation file " + fileName + " could not be read: " + e.getMessage());
        return null;
    }
    return null;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with EntityNotFoundException

use of ubic.gemma.web.util.EntityNotFoundException in project Gemma by PavlidisLab.

the class ArrayDesignControllerImpl method remove.

@Override
public String remove(EntityDelegator ed) {
    ArrayDesign arrayDesign = arrayDesignService.load(ed.getId());
    if (arrayDesign == null) {
        throw new EntityNotFoundException(ed.getId() + " not found");
    }
    Collection<BioAssay> assays = arrayDesignService.getAllAssociatedBioAssays(ed.getId());
    if (assays.size() != 0) {
        throw new IllegalArgumentException("Cannot remove " + arrayDesign + ", it is used by an expression experiment");
    }
    RemoveArrayLocalTask job = new RemoveArrayLocalTask(new TaskCommand(arrayDesign.getId()));
    return taskRunningService.submitLocalTask(job);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) TaskCommand(ubic.gemma.core.job.TaskCommand)

Example 10 with EntityNotFoundException

use of ubic.gemma.web.util.EntityNotFoundException in project Gemma by PavlidisLab.

the class BibliographicReferenceControllerImpl method show.

@Override
public ModelAndView show(HttpServletRequest request, HttpServletResponse response) {
    String pubMedId = request.getParameter("accession");
    String gemmaId = request.getParameter("id");
    if (StringUtils.isBlank(pubMedId) && StringUtils.isBlank(gemmaId)) {
        throw new EntityNotFoundException("Must provide a gamma database id or a PubMed id");
    }
    if (!StringUtils.isBlank(gemmaId)) {
        return new ModelAndView("bibRefView").addObject("bibliographicReferenceId", gemmaId);
    }
    BibliographicReference bibRef = bibliographicReferenceService.findByExternalId(pubMedId);
    if (bibRef == null) {
        bibRef = this.pubMedXmlFetcher.retrieveByHTTP(Integer.parseInt(pubMedId));
        if (bibRef == null) {
            throw new EntityNotFoundException("Could not locate reference with pubmed id=" + pubMedId + ", either in Gemma or at NCBI");
        }
    }
    // bibRef = bibliographicReferenceService.thawRawAndProcessed( bibRef );
    // BibliographicReferenceValueObject bibRefVO = new BibliographicReferenceValueObject( bibRef );
    boolean isIncomplete = bibRef.getPublicationDate() == null;
    this.addMessage(request, "object.found", new Object[] { messagePrefix, pubMedId });
    return new ModelAndView("bibRefView").addObject("bibliographicReferenceId", bibRef.getId()).addObject("existsInSystem", Boolean.TRUE).addObject("incompleteEntry", isIncomplete).addObject("byAccession", Boolean.TRUE).addObject("accession", pubMedId);
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

Aggregations

EntityNotFoundException (ubic.gemma.web.util.EntityNotFoundException)18 ModelAndView (org.springframework.web.servlet.ModelAndView)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)6 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)4 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)3 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)3 ArrayList (java.util.ArrayList)2 TaskCommand (ubic.gemma.core.job.TaskCommand)2 RedirectView (org.springframework.web.servlet.view.RedirectView)1 DiffExpressionSelectedFactorCommand (ubic.gemma.core.analysis.expression.diff.DiffExpressionSelectedFactorCommand)1 CompositeSequenceMapValueObject (ubic.gemma.core.analysis.sequence.CompositeSequenceMapValueObject)1 BibliographicReferenceValueObject (ubic.gemma.model.common.description.BibliographicReferenceValueObject)1 Characteristic (ubic.gemma.model.common.description.Characteristic)1 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)1 BioAssayValueObject (ubic.gemma.model.expression.bioAssay.BioAssayValueObject)1 Gene (ubic.gemma.model.genome.Gene)1 GemmaApiException (ubic.gemma.web.services.rest.util.GemmaApiException)1 WellComposedErrorBody (ubic.gemma.web.services.rest.util.WellComposedErrorBody)1