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));
}
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);
}
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;
}
Aggregations