use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class PubMedXMLFetcherTest method testRetrieveByHTTPBookshelf.
/*
* 23865096 is a NCBI bookshelf article, not a paper
*/
@Test
public final void testRetrieveByHTTPBookshelf() {
try {
BibliographicReference br = pmf.retrieveByHTTP(23865096);
assertNotNull(br);
assertEquals("Tatton-Brown, Katrina; Rahman, Nazneen", br.getAuthorList());
assertEquals("GeneReviews", br.getPublication().substring(0, "GeneReviews".length()));
assertEquals("EZH2-Related Overgrowth", br.getTitle());
SimpleDateFormat f = new SimpleDateFormat("yyyy");
assertEquals("2013", f.format(br.getPublicationDate()));
} catch (RuntimeException e) {
this.checkCause(e);
}
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class ExpressionExperimentDaoImpl method thawReferences.
private void thawReferences(final ExpressionExperiment expressionExperiment) {
if (expressionExperiment.getPrimaryPublication() != null) {
Hibernate.initialize(expressionExperiment.getPrimaryPublication());
Hibernate.initialize(expressionExperiment.getPrimaryPublication().getPubAccession());
Hibernate.initialize(expressionExperiment.getPrimaryPublication().getPubAccession().getExternalDatabase());
Hibernate.initialize(expressionExperiment.getPrimaryPublication().getPublicationTypes());
}
if (expressionExperiment.getOtherRelevantPublications() != null) {
Hibernate.initialize(expressionExperiment.getOtherRelevantPublications());
for (BibliographicReference bf : expressionExperiment.getOtherRelevantPublications()) {
Hibernate.initialize(bf.getPubAccession());
Hibernate.initialize(bf.getPubAccession().getExternalDatabase());
Hibernate.initialize(bf.getPublicationTypes());
}
}
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceServiceImpl method loadMultipleValueObjectsFromObjects.
@Transactional(readOnly = true)
public Collection<BibliographicReferenceValueObject> loadMultipleValueObjectsFromObjects(Collection<BibliographicReference> bibRefs) {
if (bibRefs.isEmpty()) {
return new ArrayList<>();
}
Map<Long, BibliographicReferenceValueObject> idToBibRefVO = new HashMap<>();
for (BibliographicReference bibref : bibRefs) {
BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(bibref);
idToBibRefVO.put(bibref.getId(), vo);
}
this.populateRelatedExperiments(bibRefs, idToBibRefVO);
this.populateBibliographicPhenotypes(idToBibRefVO);
return idToBibRefVO.values();
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceServiceImpl method search.
@Override
@Transactional(readOnly = true)
public List<BibliographicReferenceValueObject> search(SearchSettingsValueObject settings) {
SearchSettings ss = SearchSettingsImpl.bibliographicReferenceSearch(settings.getQuery());
// noinspection unchecked
List<BibliographicReference> resultEntities = (List<BibliographicReference>) searchService.search(ss, BibliographicReference.class);
List<BibliographicReferenceValueObject> results = new ArrayList<>();
// only return associations with the selected entity types.
for (BibliographicReference entity : resultEntities) {
BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(entity);
if (settings.getSearchPhenotypes() || settings.getSearchBibrefs()) {
this.populateBibliographicPhenotypes(vo);
if (!vo.getBibliographicPhenotypes().isEmpty() || settings.getSearchBibrefs()) {
results.add(vo);
}
}
if (settings.getSearchExperiments() || settings.getSearchBibrefs()) {
this.populateRelatedExperiments(entity, vo);
if (!vo.getExperiments().isEmpty() || settings.getSearchBibrefs()) {
results.add(vo);
}
}
if (settings.getSearchBibrefs() && !settings.getSearchPhenotypes() && !settings.getSearchExperiments()) {
results.add(vo);
}
}
return results;
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class PubMedSearch method searchAndRetrieveByHTTP.
/**
* Search based on terms
*
* @param searchTerms search terms
* @return BibliographicReference representing the publication
* @throws IOException IO problems
*/
public Collection<BibliographicReference> searchAndRetrieveByHTTP(Collection<String> searchTerms) throws IOException, SAXException, ParserConfigurationException {
StringBuilder builder = new StringBuilder();
builder.append(uri);
builder.append("&term=");
for (String string : searchTerms) {
builder.append(string);
builder.append("+");
}
URL toBeGotten = new URL(StringUtils.chomp(builder.toString()));
log.info("Fetching " + toBeGotten);
ESearchXMLParser parser = new ESearchXMLParser();
Collection<String> ids = parser.parse(toBeGotten.openStream());
Collection<BibliographicReference> results = fetchById(ids);
log.info("Fetched " + results.size() + " references");
return results;
}
Aggregations