Search in sources :

Example 1 with BibliographicReferenceValueObject

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;
}
Also used : BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with BibliographicReferenceValueObject

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);
    }
}
Also used : BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with BibliographicReferenceValueObject

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);
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

Example 4 with BibliographicReferenceValueObject

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);
}
Also used : PhenotypeAssociation(ubic.gemma.model.association.phenotype.PhenotypeAssociation) BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) JsonReaderResponse(ubic.gemma.web.remote.JsonReaderResponse) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) BibliographicPhenotypesValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.BibliographicPhenotypesValueObject)

Example 5 with BibliographicReferenceValueObject

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();
}
Also used : BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

BibliographicReferenceValueObject (ubic.gemma.model.common.description.BibliographicReferenceValueObject)8 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)7 Transactional (org.springframework.transaction.annotation.Transactional)4 StopWatch (org.apache.commons.lang3.time.StopWatch)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 PhenotypeAssociation (ubic.gemma.model.association.phenotype.PhenotypeAssociation)1 SearchSettings (ubic.gemma.model.common.search.SearchSettings)1 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)1 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)1 BibliographicPhenotypesValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.BibliographicPhenotypesValueObject)1 JsonReaderResponse (ubic.gemma.web.remote.JsonReaderResponse)1 EntityNotFoundException (ubic.gemma.web.util.EntityNotFoundException)1