Search in sources :

Example 16 with EntityNotFoundException

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

the class BioMaterialController method show.

@RequestMapping({ "/showBioMaterial.html", "/" })
public ModelAndView show(HttpServletRequest request, HttpServletResponse response) {
    Long id;
    try {
        id = Long.parseLong(request.getParameter("id"));
    } catch (NumberFormatException e) {
        String message = "Must provide a numeric biomaterial id";
        return new ModelAndView(WebConstants.HOME_PAGE).addObject("message", message);
    }
    BioMaterial bioMaterial = bioMaterialService.load(id);
    if (bioMaterial == null) {
        throw new EntityNotFoundException(id + " not found");
    }
    bioMaterialService.thaw(bioMaterial);
    // / ??
    request.setAttribute("id", id);
    return new ModelAndView("bioMaterial.detail").addObject("bioMaterial", bioMaterial).addObject("expressionExperiment", bioMaterialService.getExpressionExperiment(id));
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) ModelAndView(org.springframework.web.servlet.ModelAndView) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with EntityNotFoundException

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

the class ExperimentalDesignControllerImpl method createFactorValue.

@Override
public void createFactorValue(EntityDelegator e) {
    if (e == null || e.getId() == null)
        return;
    ExperimentalFactor ef = experimentalFactorService.load(e.getId());
    if (ef == null) {
        throw new EntityNotFoundException("Experimental factor with ID=" + e.getId() + " could not be accessed for editing");
    }
    Collection<Characteristic> chars = new HashSet<>();
    for (FactorValue fv : ef.getFactorValues()) {
        // noinspection LoopStatementThatDoesntLoop // No, but its an effective way of doing this
        for (Characteristic c : fv.getCharacteristics()) {
            chars.add(this.createTemplateCharacteristic(c));
            break;
        }
    }
    if (chars.isEmpty()) {
        if (ef.getCategory() == null) {
            throw new IllegalArgumentException("You cannot create new factor values on a experimental factor that is not defined by a formal Category");
        }
        chars.add(this.createTemplateCharacteristic(ef.getCategory()));
    }
    FactorValue fv = FactorValue.Factory.newInstance();
    fv.setExperimentalFactor(ef);
    fv.setCharacteristics(chars);
    ExpressionExperiment ee = experimentalDesignService.getExpressionExperiment(ef.getExperimentalDesign());
    // this is just a placeholder factor value; use has to edit it.
    expressionExperimentService.addFactorValue(ee, fv);
}
Also used : Characteristic(ubic.gemma.model.common.description.Characteristic) VocabCharacteristic(ubic.gemma.model.common.description.VocabCharacteristic) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException)

Example 18 with EntityNotFoundException

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

the class ExpressionExperimentController method showBioMaterials.

@RequestMapping(value = { "/showBioMaterialsFromExpressionExperiment.html", "/bioMaterials" })
public ModelAndView showBioMaterials(HttpServletRequest request, HttpServletResponse response) {
    String idStr = request.getParameter("id");
    if (idStr == null) {
        // should be a validation error, on 'submit'.
        throw new EntityNotFoundException(identifierNotFound);
    }
    Long id = Long.parseLong(idStr);
    ExpressionExperiment expressionExperiment = expressionExperimentService.load(id);
    expressionExperiment = expressionExperimentService.thawLite(expressionExperiment);
    if (expressionExperiment == null) {
        throw new EntityNotFoundException(id + " not found");
    }
    Collection<BioAssay> bioAssays = expressionExperiment.getBioAssays();
    Collection<BioMaterial> bioMaterials = new ArrayList<>();
    for (BioAssay assay : bioAssays) {
        BioMaterial material = assay.getSampleUsed();
        if (material != null) {
            bioMaterials.add(material);
        }
    }
    ModelAndView mav = new ModelAndView("bioMaterials");
    if (ExpressionExperimentController.AJAX) {
        mav.addObject("bioMaterialIdList", bioMaterialService.getBioMaterialIdList(bioMaterials));
    }
    Integer numBioMaterials = bioMaterials.size();
    mav.addObject("numBioMaterials", numBioMaterials);
    mav.addObject("bioMaterials", bioMaterialService.thaw(bioMaterials));
    this.addQCInfo(expressionExperiment, mav);
    return mav;
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) ModelAndView(org.springframework.web.servlet.ModelAndView) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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