use of ubic.gemma.model.common.description.BibliographicReference 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);
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceControllerImpl method delete.
@Override
public ModelAndView delete(HttpServletRequest request, HttpServletResponse response) {
String pubMedId = request.getParameter("acc");
if (pubMedId == null) {
// should be a validation error.
throw new EntityNotFoundException("Must provide a PubMed Id");
}
BibliographicReference bibRef = bibliographicReferenceService.findByExternalId(pubMedId);
if (bibRef == null) {
String message = "There is no reference with accession=" + pubMedId + " in the system any more.";
this.saveMessage(request, message);
return new ModelAndView("bibRefView").addObject("errors", message);
}
return this.doDelete(request, bibRef);
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class PubMedQueryControllerImpl method onSubmit.
@Override
@RequestMapping(method = RequestMethod.POST)
public ModelAndView onSubmit(HttpServletRequest request, PubMedSearchCommand command, BindingResult result, SessionStatus status) {
// in the future we can search in other ways.
String accession = command.getAccession();
if (StringUtils.isBlank(accession)) {
result.rejectValue("search", "errors.pubmed.noaccession", "Accession was missing");
return new ModelAndView("bibRefSearch");
}
// first see if we already have it in the system.
BibliographicReference bibRefFound = bibliographicReferenceService.findByExternalId(accession);
if (bibRefFound != null) {
request.setAttribute("existsInSystem", Boolean.TRUE);
this.saveMessage(request, "bibliographicReference.alreadyInSystem", accession, "Already in Gemma");
} else {
request.setAttribute("existsInSystem", Boolean.FALSE);
try {
bibRefFound = this.pubMedXmlFetcher.retrieveByHTTP(Integer.parseInt(accession));
if (bibRefFound == null) {
log.debug(accession + " not found in NCBI");
result.rejectValue("accession", "bibliographicReference.notfoundInNCBI", "Not found in NCBI");
return new ModelAndView("bibRefSearch", result.getModel());
}
this.saveMessage(request, "bibliographicReference.found", accession, "Found");
} catch (NumberFormatException e) {
result.rejectValue("accession", "error.integer", "Not a number");
return new ModelAndView("bibRefSearch", result.getModel());
}
}
status.setComplete();
return new ModelAndView("bibRefView").addObject("bibliographicReference", bibRefFound);
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class SearchServiceImpl method expressionExperimentSearch.
/**
* A general search for expression experiments. This search does both an database search and a compass search.
* A problem with this is that we cap the number of results that can be returned. This could be a limitation for
* applications like building data set groups. Thus MAX_CHARACTERISTIC_SEARCH_RESULTS should not be too low.
*
* @return {@link Collection}
*/
private Collection<SearchResult> expressionExperimentSearch(final SearchSettings settings) {
StopWatch watch = this.startTiming();
SearchServiceImpl.log.info("Starting search for " + settings.getQuery() + " in taxon: " + settings.getTaxon());
Collection<SearchResult> results = new HashSet<>();
if (settings.getUseDatabase()) {
results.addAll(this.databaseExpressionExperimentSearch(settings));
if (watch.getTime() > 1000)
SearchServiceImpl.log.info("Expression Experiment database search for '" + settings + "' took " + watch.getTime() + " ms, " + results.size() + " hits.");
watch.reset();
watch.start();
}
if (settings.getUseIndices() && results.size() < SearchServiceImpl.MAX_CHARACTERISTIC_SEARCH_RESULTS) {
results.addAll(this.compassExpressionSearch(settings));
if (watch.getTime() > 1000)
SearchServiceImpl.log.info("Expression Experiment index search for '" + settings + "' took " + watch.getTime() + " ms, " + results.size() + " hits.");
watch.reset();
watch.start();
}
if (results.size() < SearchServiceImpl.MAX_CHARACTERISTIC_SEARCH_RESULTS) {
/*
* Try a more thorough search. This is slower; calls to ontologySearchAnnotatedObject take a long time
*/
if (settings.getUseCharacteristics()) {
results.addAll(this.characteristicExpressionExperimentSearch(settings));
}
if (watch.getTime() > 1000)
SearchServiceImpl.log.info("Expression Experiment ontology search for '" + settings + "' took " + watch.getTime() + " ms, " + results.size() + " hits.");
watch.reset();
watch.start();
}
/*
* Find data sets that match the platform
*/
if (results.size() == 0) {
Collection<SearchResult> matchingPlatforms = this.arrayDesignSearch(settings, null);
for (SearchResult adRes : matchingPlatforms) {
if (adRes.getResultObject() instanceof ArrayDesign) {
ArrayDesign ad = (ArrayDesign) adRes.getResultObject();
Collection<ExpressionExperiment> expressionExperiments = this.arrayDesignService.getExpressionExperiments(ad);
if (expressionExperiments.size() > 0)
results.addAll(this.dbHitsToSearchResult(expressionExperiments, null));
}
}
if (watch.getTime() > 1000)
SearchServiceImpl.log.info("Expression Experiment platform search for '" + settings + "' took " + watch.getTime() + " ms, " + results.size() + " hits.");
watch.reset();
watch.start();
}
if (results.size() == 0) {
/*
* Search for bib refs
*/
List<BibliographicReferenceValueObject> bibrefs = bibliographicReferenceService.search(settings.getQuery());
if (!bibrefs.isEmpty()) {
Collection<BibliographicReference> refs = new HashSet<>();
Collection<SearchResult> r = this.compassBibliographicReferenceSearch(settings);
for (SearchResult searchResult : r) {
refs.add((BibliographicReference) searchResult.getResultObject());
}
Map<BibliographicReference, Collection<ExpressionExperiment>> relatedExperiments = this.bibliographicReferenceService.getRelatedExperiments(refs);
for (Entry<BibliographicReference, Collection<ExpressionExperiment>> e : relatedExperiments.entrySet()) {
results.addAll(this.dbHitsToSearchResult(e.getValue(), null));
}
if (watch.getTime() > 1000)
SearchServiceImpl.log.info("Expression Experiment publication search for '" + settings + "' took " + watch.getTime() + " ms, " + results.size() + " hits.");
watch.reset();
watch.start();
}
}
watch.stop();
if (watch.getTime() > 1000)
SearchServiceImpl.log.info("Expression Experiment search for '" + settings + "' took " + watch.getTime() + " ms, " + results.size() + " hits.");
return results;
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceDaoImpl method find.
@Override
public BibliographicReference find(BibliographicReference bibliographicReference) {
BusinessKey.checkKey(bibliographicReference);
Criteria queryObject = this.getSessionFactory().getCurrentSession().createCriteria(BibliographicReference.class);
/*
* This syntax allows you to look at an association.
*/
if (bibliographicReference.getPubAccession() != null) {
queryObject.createCriteria("pubAccession").add(Restrictions.eq("accession", bibliographicReference.getPubAccession().getAccession()));
} else {
throw new NullPointerException("PubAccession cannot be null");
}
java.util.List<?> results = queryObject.list();
Object result = null;
if (results != null) {
if (results.size() > 1) {
throw new org.springframework.dao.InvalidDataAccessResourceUsageException("More than one instance of '" + BibliographicReference.class.getName() + "' with accession " + bibliographicReference.getPubAccession().getAccession() + " was found when executing query");
} else if (results.size() == 1) {
result = results.iterator().next();
}
}
return (BibliographicReference) result;
}
Aggregations