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