Git commit d29ab9eb6c5220b5bdef7341b354816e8b699098 by Robby Stephenson. Committed on 28/05/2015 at 02:08. Pushed by rstephenson into branch 'frameworks'.
Remove Citebase fetcher, Citebase no longer exists M +4 -0 ChangeLog M +1 -2 doc/configuration.docbook M +0 -1 src/fetch/CMakeLists.txt D +0 -240 src/fetch/citebasefetcher.cpp D +0 -93 src/fetch/citebasefetcher.h M +1 -1 src/fetch/fetch.h M +0 -2 src/fetch/fetcherinitializer.cpp M +0 -9 src/tests/CMakeLists.txt D +0 -78 src/tests/citebasefetchertest.cpp D +0 -47 src/tests/citebasefetchertest.h http://commits.kde.org/tellico/d29ab9eb6c5220b5bdef7341b354816e8b699098 diff --git a/ChangeLog b/ChangeLog index eb91b15..76460ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-05-27 Robby Stephenson <robby at homebase.mars> + + * Removed the Citebase fetcher. + 2015-03-15 Robby Stephenson <robby at homebase.mars> * Removed the PilotDB exporter. diff --git a/doc/configuration.docbook b/doc/configuration.docbook index e4f0b70..de4f75f 100644 --- a/doc/configuration.docbook +++ b/doc/configuration.docbook @@ -170,7 +170,6 @@ in the Data Sources Dialog. There are many available types and sources:</para> <listitem><para><link linkend="gcstarplugin"><application>GCstar</application> Plugins</link>,</para></listitem> <listitem><para><link linkend="bib-sources">arxiv.org</link>,</para></listitem> <listitem><para><link linkend="bib-sources">bibsonomy.org</link>,</para></listitem> -<listitem><para><link linkend="bib-sources">citebase.org</link>,</para></listitem> <listitem><para><link linkend="bib-sources">crossref.org</link>,</para></listitem> <listitem><para><link linkend="discogs">Discogs.com</link>,</para></listitem> <listitem><para><link linkend="winecom">Wine.com</link>,</para></listitem> @@ -280,7 +279,7 @@ the best known. <sect3 id="bib-sources"> <title>Bibliographic Databases</title> <para> -<ulink url="http://arxiv.org">arXiv.org</ulink>, <ulink url="http://bibsonomy.org">Bibsonomy</ulink>, <ulink url="http://citebase.org">Citebase</ulink>, and <ulink url="http://crossref.org">CrossRef</ulink> are online databases for academic articles and bibliographic information. For access to the CrossRef source, you must <ulink url="http://www.crossref.org/requestaccount/">request an account</ulink> and add your account information to the data source configuration.</para> +<ulink url="http://arxiv.org">arXiv.org</ulink>, <ulink url="http://bibsonomy.org">Bibsonomy</ulink>, and <ulink url="http://crossref.org">CrossRef</ulink> are online databases for academic articles and bibliographic information. For access to the CrossRef source, you must <ulink url="http://www.crossref.org/requestaccount/">request an account</ulink> and add your account information to the data source configuration.</para> </sect3> <sect3 id="ibs"> diff --git a/src/fetch/CMakeLists.txt b/src/fetch/CMakeLists.txt index 1f75a58..5770ec2 100644 --- a/src/fetch/CMakeLists.txt +++ b/src/fetch/CMakeLists.txt @@ -12,7 +12,6 @@ SET(fetch_STAT_SRCS bibliosharefetcher.cpp bibsonomyfetcher.cpp boardgamegeekfetcher.cpp - citebasefetcher.cpp configwidget.cpp crossreffetcher.cpp dblpfetcher.cpp diff --git a/src/fetch/citebasefetcher.cpp b/src/fetch/citebasefetcher.cpp deleted file mode 100644 index cbc9fd2..0000000 --- a/src/fetch/citebasefetcher.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/*************************************************************************** - Copyright (C) 2007-2009 Robby Stephenson <robby at periapsis.org> - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 2 of * - * the License or (at your option) version 3 or any later version * - * accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy * - * defined in Section 14 of version 3 of the license. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * * - ***************************************************************************/ - -#include "citebasefetcher.h" -#include "../translators/bibteximporter.h" -#include "../utils/guiproxy.h" -#include "../utils/string_utils.h" -#include "../collections/bibtexcollection.h" -#include "../entry.h" -#include "../core/netaccess.h" -#include "../tellico_debug.h" - -#include <KLocalizedString> -#include <kio/job.h> -#include <kio/jobuidelegate.h> -#include <KJobWidgets/KJobWidgets> - -#include <QLabel> -#include <QTextStream> -#include <QVBoxLayout> -#include <QFile> - -namespace { - // always bibtex - static const char* CITEBASE_BASE_URL = "http://www.citebase.org/openurl/?url_ver=Z39.88-2004&svc_id=bibtex"; -} - -using namespace Tellico; -using namespace Tellico::Fetch; -using Tellico::Fetch::CitebaseFetcher; - -CitebaseFetcher::CitebaseFetcher(QObject* parent_) - : Fetcher(parent_), m_job(0), m_started(false) { -} - -CitebaseFetcher::~CitebaseFetcher() { -} - -QString CitebaseFetcher::source() const { - return m_name.isEmpty() ? defaultName() : m_name; -} - -bool CitebaseFetcher::canFetch(int type) const { - return type == Data::Collection::Bibtex; -} - -void CitebaseFetcher::readConfigHook(const KConfigGroup&) { -} - -void CitebaseFetcher::search() { - m_started = true; - -// myDebug() << "value = " << value_; - - QUrl u = searchURL(request().key, request().value); - if(u.isEmpty()) { - stop(); - return; - } - - m_job = KIO::storedGet(u, KIO::NoReload, KIO::HideProgressInfo); - KJobWidgets::setWindow(m_job, GUI::Proxy::widget()); - connect(m_job, SIGNAL(result(KJob*)), - SLOT(slotComplete(KJob*))); -} - -void CitebaseFetcher::stop() { - if(!m_started) { - return; - } -// myDebug(); - if(m_job) { - m_job->kill(); - m_job = 0; - } - m_started = false; - emit signalDone(this); -} - -void CitebaseFetcher::slotComplete(KJob*) { -// myDebug(); - - if(m_job->error()) { - m_job->ui()->showErrorMessage(); - stop(); - return; - } - - QByteArray data = m_job->data(); - if(data.isEmpty()) { - myDebug() << "no data"; - stop(); - return; - } - - // since the fetch is done, don't worry about holding the job pointer - m_job = 0; -#if 0 - myWarning() << "Remove debug from citebasefetcher.cpp"; - QFile f(QLatin1String("/tmp/test.bib")); - if(f.open(QIODevice::WriteOnly)) { - QTextStream t(&f); - t.setCodec("UTF-8"); - t << data; - } - f.close(); -#endif - - Import::BibtexImporter imp(QString::fromUtf8(data, data.size())); - // to head off the warnings about using the current collection, a dummy bibtex collection is used for now - imp.setCurrentCollection(Data::CollPtr(new Data::BibtexCollection(true))); - Data::CollPtr coll = imp.collection(); - - if(!coll) { - myDebug() << "no valid result"; - stop(); - return; - } - - Data::EntryList entries = coll->entries(); - foreach(Data::EntryPtr entry, entries) { - if(!m_started) { - // might get aborted - break; - } - - if(request().key == ArxivID && entry->field(QLatin1String("arxiv")).isEmpty()) { - QString url = entry->field(QLatin1String("url")); - QRegExp rx(QLatin1String("id=oai:arXiv\\.org:([^&]+)")); - if(rx.indexIn(url) > -1) { - if(!coll->hasField(QLatin1String("arxiv"))) { - Data::FieldPtr field(new Data::Field(QLatin1String("arxiv"), QLatin1String("arXiv ID"))); - field->setCategory(i18n("Publishing")); - coll->addFields(Data::FieldList() << field); - } - entry->setField(QLatin1String("arxiv"), rx.cap(1)); - } - } - - FetchResult* r = new FetchResult(Fetcher::Ptr(this), entry); - m_entries.insert(r->uid, Data::EntryPtr(entry)); - emit signalResultFound(r); - } - - stop(); // required -} - -Tellico::Data::EntryPtr CitebaseFetcher::fetchEntryHook(uint uid_) { - Data::EntryPtr entry = m_entries[uid_]; - QRegExp versionRx(QLatin1String("v\\d+$")); - // if the original search was not for a versioned ID, remove it - if(request().key != ArxivID || !request().value.contains(versionRx)) { - QString arxiv = entry->field(QLatin1String("arxiv")); - arxiv.remove(versionRx); - entry->setField(QLatin1String("arxiv"), arxiv); - } - return entry; -} - -QUrl CitebaseFetcher::searchURL(FetchKey key_, const QString& value_) const { - QUrl u(QString::fromLatin1(CITEBASE_BASE_URL)); - - switch(key_) { - case ArxivID: - { - // remove prefix and/or version number - QString value = value_; - value.remove(QRegExp(QLatin1String("^arxiv:"), Qt::CaseInsensitive)); - value.remove(QRegExp(QLatin1String("v\\d+$"))); - u.addQueryItem(QLatin1String("rft_id"), QString::fromLatin1("oai:arXiv.org:%1").arg(value)); - } - break; - - default: - myWarning() << "key not recognized: " << key_; - return QUrl(); - } - -// myDebug() << "url: " << u.url(); - return u; -} - -Tellico::Fetch::FetchRequest CitebaseFetcher::updateRequest(Data::EntryPtr entry_) { - QString arxiv = entry_->field(QLatin1String("arxiv")); - if(!arxiv.isEmpty()) { - // remove prefix and/or version number - arxiv.remove(QRegExp(QLatin1String("^arxiv:"), Qt::CaseInsensitive)); - arxiv.remove(QRegExp(QLatin1String("v\\d+$"))); - return FetchRequest(Fetch::ArxivID, arxiv); - } - return FetchRequest(); -} - -Tellico::Fetch::ConfigWidget* CitebaseFetcher::configWidget(QWidget* parent_) const { - return new CitebaseFetcher::ConfigWidget(parent_, this); -} - -QString CitebaseFetcher::defaultName() { - return QLatin1String("Citebase"); -} - -QString CitebaseFetcher::defaultIcon() { - return favIcon("http://citebase.org"); -} - -CitebaseFetcher::ConfigWidget::ConfigWidget(QWidget* parent_, const CitebaseFetcher*) - : Fetch::ConfigWidget(parent_) { - QVBoxLayout* l = new QVBoxLayout(optionsWidget()); - l->addWidget(new QLabel(i18n("This source has no options."), optionsWidget())); - l->addStretch(); -} - -void CitebaseFetcher::ConfigWidget::saveConfigHook(KConfigGroup&) { -} - -QString CitebaseFetcher::ConfigWidget::preferredName() const { - return CitebaseFetcher::defaultName(); -} - diff --git a/src/fetch/citebasefetcher.h b/src/fetch/citebasefetcher.h deleted file mode 100644 index 8ec2f06..0000000 --- a/src/fetch/citebasefetcher.h +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************************************** - Copyright (C) 2007-2009 Robby Stephenson <robby at periapsis.org> - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 2 of * - * the License or (at your option) version 3 or any later version * - * accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy * - * defined in Section 14 of version 3 of the license. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * * - ***************************************************************************/ - -#ifndef TELLICO_FETCH_CITEBASEFETCHER_H -#define TELLICO_FETCH_CITEBASEFETCHER_H - -#include "fetcher.h" -#include "configwidget.h" -#include "../datavectors.h" - -#include <QPointer> - -class QUrl; -class KJob; -namespace KIO { - class StoredTransferJob; -} - -namespace Tellico { - namespace Fetch { - -/** - * @author Robby Stephenson - */ -class CitebaseFetcher : public Fetcher { -Q_OBJECT - -public: - CitebaseFetcher(QObject* parent); - ~CitebaseFetcher(); - - virtual QString source() const; - virtual bool isSearching() const { return m_started; } - - virtual bool canSearch(FetchKey k) const { return k == ArxivID; } - virtual void stop(); - virtual Data::EntryPtr fetchEntryHook(uint uid); - virtual Type type() const { return Citebase; } - virtual bool canFetch(int type) const; - virtual void readConfigHook(const KConfigGroup& config); - - virtual Fetch::ConfigWidget* configWidget(QWidget* parent) const; - - class ConfigWidget : public Fetch::ConfigWidget { - public: - explicit ConfigWidget(QWidget* parent_, const CitebaseFetcher* fetcher = 0); - virtual void saveConfigHook(KConfigGroup& config); - virtual QString preferredName() const; - }; - friend class ConfigWidget; - - static QString defaultName(); - static QString defaultIcon(); - static StringHash allOptionalFields() { return StringHash(); } - -private slots: - void slotComplete(KJob* job); - -private: - virtual void search(); - virtual FetchRequest updateRequest(Data::EntryPtr entry); - QUrl searchURL(FetchKey key, const QString& value) const; - - QHash<int, Data::EntryPtr> m_entries; - QPointer<KIO::StoredTransferJob> m_job; - - bool m_started; -}; - - } -} -#endif diff --git a/src/fetch/fetch.h b/src/fetch/fetch.h index ad05183..a63723b 100644 --- a/src/fetch/fetch.h +++ b/src/fetch/fetch.h @@ -63,7 +63,7 @@ enum Type { ISBNdb, GCstarPlugin, CrossRef, - Citebase, + Citebase, // Removed Arxiv, Bibsonomy, GoogleScholar, diff --git a/src/fetch/fetcherinitializer.cpp b/src/fetch/fetcherinitializer.cpp index baa5c1f..f859398 100644 --- a/src/fetch/fetcherinitializer.cpp +++ b/src/fetch/fetcherinitializer.cpp @@ -39,7 +39,6 @@ #include "gcstarpluginfetcher.h" #include "crossreffetcher.h" #include "arxivfetcher.h" -#include "citebasefetcher.h" #include "bibsonomyfetcher.h" #include "googlescholarfetcher.h" #include "discogsfetcher.h" @@ -94,7 +93,6 @@ Tellico::Fetch::FetcherInitializer::FetcherInitializer() { RegisterFetcher<Fetch::GCstarPluginFetcher> registerGCstar(GCstarPlugin); RegisterFetcher<Fetch::CrossRefFetcher> registerCrossRef(CrossRef); RegisterFetcher<Fetch::ArxivFetcher> registerArxiv(Arxiv); - RegisterFetcher<Fetch::CitebaseFetcher> registerCitebase(Citebase); RegisterFetcher<Fetch::BibsonomyFetcher> registerBibsonomy(Bibsonomy); RegisterFetcher<Fetch::GoogleScholarFetcher> registerGoogle(GoogleScholar); RegisterFetcher<Fetch::WineComFetcher> registerWine(WineCom); diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index e84c6a0..f7bbb84 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -404,15 +404,6 @@ add_test(boardgamegeekfetchertest boardgamegeekfetchertest) ecm_mark_as_test(boardgamegeekfetchertest) TARGET_LINK_LIBRARIES(boardgamegeekfetchertest fetch ${TELLICO_TEST_LIBS}) -add_executable(citebasefetchertest citebasefetchertest.cpp abstractfetchertest.cpp - ../fetch/citebasefetcher.cpp - ../translators/bibteximporter.cpp -) -ecm_mark_nongui_executable(citebasefetchertest) -add_test(citebasefetchertest citebasefetchertest) -ecm_mark_as_test(citebasefetchertest) -TARGET_LINK_LIBRARIES(citebasefetchertest fetcherstest tellicomodels ${TELLICO_BTPARSE_LIBS} ${TELLICO2_TEST_LIBS}) - add_executable(darkhorsefetchertest darkhorsefetchertest.cpp abstractfetchertest.cpp) ecm_mark_nongui_executable(darkhorsefetchertest) add_test(darkhorsefetchertest darkhorsefetchertest) diff --git a/src/tests/citebasefetchertest.cpp b/src/tests/citebasefetchertest.cpp deleted file mode 100644 index 772e4f3..0000000 --- a/src/tests/citebasefetchertest.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - Copyright (C) 2009-2011 Robby Stephenson <robby at periapsis.org> - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 2 of * - * the License or (at your option) version 3 or any later version * - * accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy * - * defined in Section 14 of version 3 of the license. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * * - ***************************************************************************/ - -#undef QT_NO_CAST_FROM_ASCII - -#include "citebasefetchertest.h" - -#include "../fetch/citebasefetcher.h" -#include "../entry.h" -#include "../collections/bibtexcollection.h" -#include "../collectionfactory.h" -#include "../utils/datafileregistry.h" - -#include <QTest> - -QTEST_GUILESS_MAIN( CitebaseFetcherTest ) - -CitebaseFetcherTest::CitebaseFetcherTest() : AbstractFetcherTest() { -} - -void CitebaseFetcherTest::initTestCase() { - Tellico::DataFileRegistry::self()->addDataLocation(QFINDTESTDATA("../../xslt/citebase2tellico.xsl")); - // since citebase uses the bibtex importer -// KGlobal::dirs()->addResourceDir("appdata", QString::fromLatin1(KDESRCDIR) + "/../translators/"); - Tellico::RegisterCollection<Tellico::Data::BibtexCollection> registerBibtex(Tellico::Data::Collection::Bibtex, "bibtex"); - - m_fieldValues.insert(QLatin1String("arxiv"), QLatin1String("hep-lat/0110180")); - m_fieldValues.insert(QLatin1String("entry-type"), QLatin1String("article")); - m_fieldValues.insert(QLatin1String("title"), QLatin1String("Speeding up the Hybrid-Monte-Carlo algorithm for dynamical fermions")); - m_fieldValues.insert(QLatin1String("author"), QString::fromUtf8("M. Hasenbusch; K. Jansen")); -// m_fieldValues.insert(QLatin1String("journal"), QLatin1String("Nuclear Physics B - Proceedings Supplements")); - m_fieldValues.insert(QLatin1String("journal"), QLatin1String("NUCL.PHYS.PROC.")); - m_fieldValues.insert(QLatin1String("year"), QLatin1String("2002")); - m_fieldValues.insert(QLatin1String("volume"), QLatin1String("106")); - // should really be 1076-1078, but citebase seems to have it wrong - m_fieldValues.insert(QLatin1String("pages"), QLatin1String("1076")); -} - -void CitebaseFetcherTest::testArxivID() { - Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::ArxivID, - "arxiv:" + m_fieldValues.value("arxiv")); - Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::CitebaseFetcher(this)); - - Tellico::Data::EntryList results = DO_FETCH(fetcher, request); - - QEXPECT_FAIL("", "Citebase has gone away and redirects to ADS", Abort); - QCOMPARE(results.size(), 1); - - if(!results.isEmpty()) { - Tellico::Data::EntryPtr entry = results.at(0); - QHashIterator<QString, QString> i(m_fieldValues); - while(i.hasNext()) { - i.next(); - QCOMPARE(entry->field(i.key()), i.value()); - } - } -} diff --git a/src/tests/citebasefetchertest.h b/src/tests/citebasefetchertest.h deleted file mode 100644 index 0ccdae5..0000000 --- a/src/tests/citebasefetchertest.h +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - Copyright (C) 2009-2011 Robby Stephenson <robby at periapsis.org> - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 2 of * - * the License or (at your option) version 3 or any later version * - * accepted by the membership of KDE e.V. (or its successor approved * - * by the membership of KDE e.V.), which shall act as a proxy * - * defined in Section 14 of version 3 of the license. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * * - ***************************************************************************/ - -#ifndef CITEBASEFETCHERTEST_H -#define CITEBASEFETCHERTEST_H - -#include "abstractfetchertest.h" - -#include <QHash> - -class KJob; - -class CitebaseFetcherTest : public AbstractFetcherTest { -Q_OBJECT -public: - CitebaseFetcherTest(); - -private Q_SLOTS: - void initTestCase(); - void testArxivID(); - -private: - QHash<QString, QString> m_fieldValues; -}; - -#endif
