use of org.nextprot.api.core.dao.impl.StatementSimpleWhereClauseQueryDSL in project nextprot-api by calipho-sib.
the class ConsistencyResourceTest method shouldFindAllPublications.
@Test
public void shouldFindAllPublications() {
boolean missingPublications = false;
List<String> pubmedIds = statementDao.findAllDistinctValuesforFieldWhereFieldEqualsValues(StatementField.REFERENCE_ACCESSION, new StatementSimpleWhereClauseQueryDSL(StatementField.REFERENCE_DATABASE, "PubMed"));
System.out.println("Found " + pubmedIds.size() + " distinct pubmeds");
for (String p : pubmedIds) {
if (p != null) {
String pubmedId = p.replace("(PubMed,", "").replace(")", "");
Publication pub = publicationService.findPublicationByDatabaseAndAccession("PubMed", pubmedId);
// TODO: remove the following line after next release data jan 2018
if (!"23248292".equals(pubmedId)) {
if (pub == null) {
System.err.println("Can t find publication for " + pubmedId);
missingPublications = true;
}
} else {
System.err.println("FOUND EMPTY PUBLICATION " + pubmedId + ", FIX THIS IN NEXT RELEASE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Probably related to: https://issues.isb-sib.ch/browse/NEXTPROT-1369");
}
}
}
;
if (missingPublications)
Assert.fail();
}
use of org.nextprot.api.core.dao.impl.StatementSimpleWhereClauseQueryDSL in project nextprot-api by calipho-sib.
the class PublicationServiceImpl method findPublicationsByEntryName.
// TODO: Publications are already cached in publications-get-by-id - even worse, some publication are linked to more than 10000 entries!!!)
// almost 5GB of cache here !!!
@Override
@Cacheable("publications")
public List<Publication> findPublicationsByEntryName(String uniqueName) {
Long masterId = masterIdentifierService.findIdByUniqueName(uniqueName);
List<Publication> publications = publicationDao.findSortedPublicationsByMasterId(masterId);
Map<Long, List<PublicationDbXref>> npPublicationsXrefs = updateMissingPublicationFields(publications);
// Getting publications from nx flat database
List<Publication> nxflatPublications = new ArrayList<>();
Arrays.asList(XrefDatabase.DOI, XrefDatabase.PUB_MED).forEach(db -> {
List<String> referenceIds = this.statementDao.findAllDistinctValuesforFieldWhereFieldEqualsValues(StatementField.REFERENCE_ACCESSION, new StatementSimpleWhereClauseQueryDSL(StatementField.ENTRY_ACCESSION, uniqueName), new StatementSimpleWhereClauseQueryDSL(StatementField.REFERENCE_DATABASE, db.getName()));
nxflatPublications.addAll(getPublicationsFromDBReferenceIds(referenceIds, db.getName(), npPublicationsXrefs));
});
updateMissingPublicationFields(nxflatPublications);
publications.addAll(nxflatPublications);
Comparator<Publication> comparator = PublicationComparator.StringComparator(Publication::getPublicationYear).reversed().thenComparing(Comparator.comparing(Publication::getPublicationType)).thenComparing(PublicationComparator.StringComparator(Publication::getPublicationLocatorName)).thenComparing(PublicationComparator.FormattedNumberComparator(Publication::getVolume)).thenComparing(PublicationComparator.FormattedNumberComparator(Publication::getFirstPage));
// sort according to order with criteria defined in publication-sorted-for-master.sql
publications.sort(comparator);
// returns a immutable list when the result is cacheable (this prevents modifying the cache, since the cache returns a reference) copy on read and copy on write is too much time consuming
return new ImmutableList.Builder<Publication>().addAll(publications).build();
}
use of org.nextprot.api.core.dao.impl.StatementSimpleWhereClauseQueryDSL in project nextprot-api by calipho-sib.
the class ConsistencyServiceImpl method findMissingPublications.
@Override
public List<String> findMissingPublications() {
List<String> missingPublications = new ArrayList<>();
Arrays.asList(XrefDatabase.PUB_MED, XrefDatabase.DOI).forEach(referenceDB -> {
List<String> ids = statementDao.findAllDistinctValuesforFieldWhereFieldEqualsValues(StatementField.REFERENCE_ACCESSION, new StatementSimpleWhereClauseQueryDSL(StatementField.REFERENCE_DATABASE, referenceDB.getName()));
for (String id : ids) {
if (id != null) {
Publication pub = publicationService.findPublicationByDatabaseAndAccession(referenceDB.getName(), id);
if (pub == null) {
missingPublications.add(referenceDB + id);
}
}
}
;
});
return missingPublications;
}
Aggregations