use of ubic.gemma.model.common.description.BibliographicReferenceValueObject in project Gemma by PavlidisLab.
the class BibliographicReferenceServiceImpl method search.
@Override
@Transactional(readOnly = true)
public List<BibliographicReferenceValueObject> search(String query) {
// noinspection unchecked
List<BibliographicReference> resultEntities = (List<BibliographicReference>) searchService.search(SearchSettingsImpl.bibliographicReferenceSearch(query), BibliographicReference.class);
List<BibliographicReferenceValueObject> results = new ArrayList<>();
for (BibliographicReference entity : resultEntities) {
BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(entity);
this.populateBibliographicPhenotypes(vo);
this.populateRelatedExperiments(entity, vo);
results.add(vo);
}
return results;
}
use of ubic.gemma.model.common.description.BibliographicReferenceValueObject in project Gemma by PavlidisLab.
the class BibliographicReferenceServiceImpl method findVOByExternalId.
/**
* @see BibliographicReferenceService#findVOByExternalId(String)
*/
@Override
@Transactional(readOnly = true)
public BibliographicReferenceValueObject findVOByExternalId(final String id) {
try {
BibliographicReference bibref = this.findByExternalId(id);
if (bibref == null) {
return null;
}
BibliographicReferenceValueObject bibrefVO = new BibliographicReferenceValueObject(bibref);
this.populateBibliographicPhenotypes(bibrefVO);
this.populateRelatedExperiments(bibref, bibrefVO);
return bibrefVO;
} catch (Throwable th) {
throw new RuntimeException("Error performing 'BibliographicReferenceService.findByExternalId(String id)' --> " + th, th);
}
}
use of ubic.gemma.model.common.description.BibliographicReferenceValueObject 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.model.common.description.BibliographicReferenceValueObject in project Gemma by PavlidisLab.
the class BibliographicReferenceControllerImpl method browse.
@Override
public JsonReaderResponse<BibliographicReferenceValueObject> browse(ListBatchCommand batch) {
Integer count = this.bibliographicReferenceService.countAll();
List<BibliographicReference> records = this.getBatch(batch);
Map<BibliographicReference, Collection<ExpressionExperiment>> relatedExperiments = this.bibliographicReferenceService.getRelatedExperiments(records);
List<BibliographicReferenceValueObject> valueObjects = new ArrayList<>();
for (BibliographicReference ref : records) {
ref = this.bibliographicReferenceService.thaw(ref);
BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(ref);
if (relatedExperiments.containsKey(ref)) {
vo.setExperiments(expressionExperimentService.loadValueObjects(relatedExperiments.get(ref)));
}
valueObjects.add(vo);
// adding phenotype information to the Bibliographic Reference
Collection<PhenotypeAssociation> phenotypeAssociations = this.phenotypeAssociationService.findPhenotypesForBibliographicReference(vo.getPubAccession());
Collection<BibliographicPhenotypesValueObject> bibliographicPhenotypesValueObjects = BibliographicPhenotypesValueObject.phenotypeAssociations2BibliographicPhenotypesValueObjects(phenotypeAssociations);
vo.setBibliographicPhenotypes(bibliographicPhenotypesValueObjects);
}
return new JsonReaderResponse<>(valueObjects, count);
}
use of ubic.gemma.model.common.description.BibliographicReferenceValueObject 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();
}
Aggregations