use of org.nextprot.api.core.domain.PublicationDbXref in project nextprot-api by calipho-sib.
the class PublicationServiceIntegrationTest method testPublicationXrefs.
@Test
@Ignore
public void testPublicationXrefs() {
Publication publication = publicationService.findPublicationById(690405);
// check that publication bug NEXTPROT-989 is fixed (pmid 12631268), should have 2 xrefs
List<PublicationDbXref> xrefs = publication.getDbXrefs();
// System.err.println(TerminologyUtils.convertXrefsToSolrString(new ArrayList<DbXref>(xrefs)));
Assert.assertTrue(xrefs.size() > 1);
}
use of org.nextprot.api.core.domain.PublicationDbXref in project nextprot-api by calipho-sib.
the class PublicationServiceImpl method getPublicationsFromDBReferenceIds.
/**
* Get all publications not found in npPublication from pubmedids
* @param npPublicationXrefs needed to avoid loading pubmed id publication multiple times
* @return
*/
private List<Publication> getPublicationsFromDBReferenceIds(List<String> nxflatReferenceIds, String referenceDatabase, Map<Long, List<PublicationDbXref>> npPublicationXrefs) {
List<Publication> nxflatPublications = new ArrayList<>();
// Filtering publications which pubmed was not already found in np publications
List<Long> foundPublicationIds = npPublicationXrefs.keySet().stream().filter(pubid -> npPublicationXrefs.get(pubid).stream().anyMatch(xref -> nxflatReferenceIds.contains(xref.getAccession()))).collect(Collectors.toList());
nxflatReferenceIds.stream().filter(Objects::nonNull).forEach(pubmed -> {
Publication pub = this.publicationDao.findPublicationByDatabaseAndAccession(referenceDatabase, pubmed);
if (pub == null) {
LOGGER.warn("Pubmed " + pubmed + " cannot be found");
} else if (!foundPublicationIds.contains(pub.getPublicationId())) {
nxflatPublications.add(pub);
}
});
return nxflatPublications;
}
use of org.nextprot.api.core.domain.PublicationDbXref in project nextprot-api by calipho-sib.
the class PublicationSolrindexer method convertToSolrDocument.
@Override
public SolrInputDocument convertToSolrDocument(Publication publi) {
GlobalPublicationStatistics.PublicationStatistics publicationStats = publicationService.getPublicationStatistics(publi.getPublicationId());
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", publi.getPublicationId());
List<PublicationDbXref> xrefs = publi.getDbXrefs();
// TODO: this 'ac' field should be renamed 'xrefs'
if (xrefs != null) // The format is slightly different in current publication indexes vs terminology indexes, check if justified
// if yes create an adhoc Publication.convertXrefsToSolrString method
{
doc.addField("ac", TerminologyUtils.convertXrefsToSolrString(new ArrayList<>(xrefs)));
}
String filters = "";
filters += ((publicationStats.isComputed()) ? " computed" : "");
// Change getIsCurated or set here to 'curated' if computed is false
filters += ((publicationStats.isCurated()) ? " curated" : "");
filters += ((publicationStats.isLargeScale()) ? " largescale" : "");
doc.addField("filters", filters);
doc.addField("title", publi.getTitle());
doc.addField("title_s", publi.getTitle());
if (publi.getPublicationDate() != null) {
doc.addField("date", publi.getPublicationDate());
doc.addField("year", publi.getPublicationYear());
}
doc.addField("first_page", publi.getFirstPage());
doc.addField("last_page", publi.getLastPage());
doc.addField("volume", publi.getVolume());
doc.addField("volume_s", publi.getVolume());
doc.addField("abstract", publi.getAbstractText());
doc.addField("type", publi.getPublicationType().name());
if (publi.isLocatedInScientificJournal()) {
JournalResourceLocator journal = publi.getJournalResourceLocator();
String jfield = journal.getName();
if (journal.hasJournalId()) {
String jabbrev = journal.getAbbrev();
jfield += " " + jabbrev;
// TODO: rename "pretty_journal" to "abbrev_journal"
doc.addField("pretty_journal", jabbrev);
}
doc.addField("journal", jfield);
}
// no need the following anymore as journal name is now accessible from journal
// else if(publi.getJournal_from_properties() != null)
// doc.addField("journal", publi.getJournal_from_properties());
SortedSet<PublicationAuthor> authorset = publi.getAuthors();
if (authorset != null) {
String toIndex = "";
String inidotted = "";
int i = authorset.size();
StringBuilder sb = new StringBuilder();
for (PublicationAuthor author : authorset) {
// replace each character by itself plus a dot
inidotted = author.getInitials().replaceAll("(.)", "$1\\.");
// System.err.println("LastName: " + author.getLastName() + " ForeName: " + author.getForeName() + " Initials: " + author.getInitials() + " inidotted: " + inidotted);
toIndex = author.getLastName() + " " + author.getForeName() + " " + inidotted;
doc.addField("authors", toIndex.trim().replaceAll(" ", " "));
sb.append(author.getLastName() + " " + inidotted.replaceAll("\\.\\.\\.", "."));
if (--i != 0)
sb.append(" | ");
}
// for display only
doc.addField("pretty_authors", sb.toString());
}
return doc;
}
Aggregations