Search in sources :

Example 1 with EntityNotFoundException

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

the class ArrayDesignControllerImpl method delete.

@Override
@RequestMapping("/deleteArrayDesign.html")
public ModelAndView delete(HttpServletRequest request, HttpServletResponse response) {
    String stringId = request.getParameter("id");
    if (stringId == null) {
        // should be a validation error.
        throw new EntityNotFoundException("Must provide an id");
    }
    Long id;
    try {
        id = Long.parseLong(stringId);
    } catch (NumberFormatException e) {
        throw new EntityNotFoundException("Identifier was invalid");
    }
    ArrayDesign arrayDesign = arrayDesignService.load(id);
    if (arrayDesign == null) {
        throw new EntityNotFoundException("Platform with id=" + id + " not found");
    }
    // check that no EE depend on the arraydesign we want to remove
    // Do this by checking if there are any bioassays that depend this AD
    Collection<BioAssay> assays = arrayDesignService.getAllAssociatedBioAssays(id);
    if (assays.size() != 0) {
        return new ModelAndView(new RedirectView("/arrays/showAllArrayDesigns.html", true)).addObject("message", "Array  " + arrayDesign.getName() + " can't be deleted. Dataset has a dependency on this Array.");
    }
    String taskId = taskRunningService.submitLocalTask(new TaskCommand(arrayDesign.getId()));
    return new ModelAndView().addObject("taskId", taskId);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) TaskCommand(ubic.gemma.core.job.TaskCommand) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with EntityNotFoundException

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

the class MutableArg method throwNotFound.

/**
 * Throws a GemmaApiException informing that the object this argument represents was not found.
 */
void throwNotFound() {
    WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, ERROR_MSG_ENTITY_NOT_FOUND);
    WellComposedErrorBody.addExceptionFields(errorBody, new EntityNotFoundException(this.nullCause));
    throw new GemmaApiException(errorBody);
}
Also used : WellComposedErrorBody(ubic.gemma.web.services.rest.util.WellComposedErrorBody) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) GemmaApiException(ubic.gemma.web.services.rest.util.GemmaApiException)

Example 3 with EntityNotFoundException

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

the class BibliographicReferenceControllerImpl method add.

@Override
public ModelAndView add(HttpServletRequest request, HttpServletResponse response) {
    // FIXME: allow use of the primary key as well.
    String pubMedId = request.getParameter("accession");
    if (StringUtils.isBlank(pubMedId)) {
        throw new EntityNotFoundException("Must provide a PubMed Id");
    }
    BibliographicReference bibRef = bibliographicReferenceService.findByExternalId(pubMedId);
    BibliographicReferenceValueObject vo;
    if (bibRef == null) {
        bibRef = this.pubMedXmlFetcher.retrieveByHTTP(Integer.parseInt(pubMedId));
        if (bibRef == null) {
            throw new EntityNotFoundException("Could not locate reference with pubmed id=" + pubMedId);
        }
        vo = new BibliographicReferenceValueObject((BibliographicReference) persisterHelper.persist(bibRef));
        this.saveMessage(request, "Added " + pubMedId + " to the system.");
    } else if (StringUtils.isNotBlank(request.getParameter("refresh"))) {
        vo = this.update(pubMedId);
        this.saveMessage(request, "Updated record for pubmed id " + pubMedId);
    } else {
        throw new IllegalArgumentException("Action not understood");
    }
    return new ModelAndView("bibRefView").addObject("bibliographicReferenceId", vo.getId()).addObject("existsInSystem", Boolean.TRUE).addObject("bibliographicReference", vo);
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

Example 4 with EntityNotFoundException

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

the class DifferentialExpressionSearchController method getDifferentialExpressionMetaAnalysis.

/**
 * Returns the results of the meta-analysis.
 */
private DifferentialExpressionMetaAnalysisValueObject getDifferentialExpressionMetaAnalysis(Long geneId, Collection<DiffExpressionSelectedFactorCommand> selectedFactors, double threshold) {
    Gene g = geneService.load(geneId);
    if (g == null) {
        log.warn("No Gene with id=" + geneId);
        return null;
    }
    /* find experiments that have had the diff cli run on it and have the gene g (analyzed) - security filtered. */
    Collection<BioAssaySet> experimentsAnalyzed = differentialExpressionAnalysisService.findExperimentsWithAnalyses(g);
    if (experimentsAnalyzed.size() == 0) {
        throw new EntityNotFoundException("No results were found: no experiment analyzed those genes");
    }
    /* the 'chosen' factors (and their associated experiments) */
    Map<Long, Long> eeFactorsMap = new HashMap<>();
    for (DiffExpressionSelectedFactorCommand selectedFactor : selectedFactors) {
        Long eeId = selectedFactor.getEeId();
        eeFactorsMap.put(eeId, selectedFactor.getEfId());
        if (log.isDebugEnabled())
            log.debug(eeId + " --> " + selectedFactor.getEfId());
    }
    /*
         * filter experiments that had the diff cli run on it and are in the scope of eeFactorsMap eeIds
         * (active/available to the user).
         */
    Collection<BioAssaySet> activeExperiments;
    if (eeFactorsMap.keySet() == null || eeFactorsMap.isEmpty()) {
        activeExperiments = experimentsAnalyzed;
    } else {
        activeExperiments = new ArrayList<>();
        for (BioAssaySet ee : experimentsAnalyzed) {
            if (eeFactorsMap.keySet().contains(ee.getId())) {
                activeExperiments.add(ee);
            }
        }
    }
    if (activeExperiments.isEmpty()) {
        throw new EntityNotFoundException("No results were found: none of the experiments selected analyzed those genes");
    }
    return geneDifferentialExpressionService.getDifferentialExpressionMetaAnalysis(threshold, g, eeFactorsMap, activeExperiments);
}
Also used : DiffExpressionSelectedFactorCommand(ubic.gemma.core.analysis.expression.diff.DiffExpressionSelectedFactorCommand) Gene(ubic.gemma.model.genome.Gene) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException)

Example 5 with EntityNotFoundException

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

the class BioMaterialController method getBioMaterialsForEE.

/**
 * @param id of experiment
 */
public Collection<BioMaterial> getBioMaterialsForEE(Long id) {
    ExpressionExperiment expressionExperiment = expressionExperimentService.load(id);
    if (expressionExperiment == null) {
        throw new EntityNotFoundException("Expression experiment with id=" + id + " not found");
    }
    expressionExperiment = expressionExperimentService.thawLite(expressionExperiment);
    Collection<BioAssay> bioAssays = expressionExperiment.getBioAssays();
    Collection<BioMaterial> bioMaterials = new ArrayList<>();
    for (BioAssay assay : bioAssays) {
        BioMaterial material = assay.getSampleUsed();
        if (material != null) {
            bioMaterials.add(material);
        }
    }
    return bioMaterials;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) ArrayList(java.util.ArrayList) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

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