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