Skip to content

Commit

Permalink
Renaming.
Browse files Browse the repository at this point in the history
  • Loading branch information
mertmetin committed Oct 28, 2020
1 parent 771ba8d commit e5de480
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 68 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ or create a project:
The publication-fetcher imports from bibtex, Google Scholar (bibtex) and endnode files. Sample bibtex and endnodes files are available docs folder.

<pre>
use Proximify\PublicationImporter\PublicationImporter;
use Proximify\PublicationFetcher\PublicationFetcher;

$importer = new PublicationImporter();
$importer = new PublicationFetcher();
$type = 'bibtex';
$source = 'PATH_TO_FILE;
$res = $importer->importPublications($type, $source);
Expand Down Expand Up @@ -83,6 +83,13 @@ You can also use the web interface for testing under the dev folder:
**Note:** Please set the correct path for the autoloader.php under the dev/www/api/index.php and dev/tests/Test.php. Otherwise, the test script will fail.


## Known Issues
Publication fetcher component was created by using UNIWeb's publication importing system which includes features like reference deduplication. Deduplication process involves ignoring references already in user's CV. Features like this requires direct access to the database which is not supported by this component yet.

## Future Work
A possible future work would be creating another component (i.e. publication importer) which both employs publication fetcher and deduplicater components to prevent importing references that currently exists in database.


## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to and actually do, grant us the rights to use your contribution. For details, visit our Contributor License Agreement.

Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"minimum-stability": "dev",
"require": {
"php": ">=7.1.0",
"proximify/foreign-packages": "^1.0",
"symfony/yaml": "5.x-dev"
"proximify/foreign-packages": "^1.0"
},
"authors": [
{
Expand All @@ -15,11 +14,11 @@
],
"autoload": {
"psr-4": {
"Proximify\\PublicationImporter\\": "src/"
"Proximify\\PublicationFetcher\\": "src/"
}
},
"scripts": {
"post-install-cmd": "Proximify\\PublicationImporter\\PublicationImporterCLI::auto",
"import-pubs": "Proximify\\PublicationImporter\\PublicationImporterCLI::auto"
"post-install-cmd": "Proximify\\PublicationFetcher\\PublicationFetcherCLI::auto",
"import-pubs": "Proximify\\PublicationFetcher\\PublicationFetcherCLI::auto"
}
}
6 changes: 2 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dev/tests/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require_once('../../vendor/autoload.php');

use Proximify\PublicationImporter\PublicationImporter;
use Proximify\PublicationFetcher\PublicationFetcher;

$importer = new PublicationImporter();
$importer = new PublicationFetcher();

print('Running tests...');

Expand Down
10 changes: 5 additions & 5 deletions dev/www/api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
require_once __DIR__ . '/../../../vendor/autoload.php';

use Proximify\PublicationImporter;
use Proximify\PublicationFetcher;

$action = $_POST['action'];

Expand All @@ -30,17 +30,17 @@
function importFromURL() {
$type = $_POST['type'];
$source = $_POST['source'];
$importer = new PublicationImporter\PublicationImporter();
$res = $importer->importFromFile($type, $source);
$importer = new PublicationFetcher\PublicationFetcher();
$res = $importer->importPublications($type, $source);

return $res;
}

function importFromFile() {
$type = $_POST['type'];
$source = $_FILES['source']['tmp_name'];
$importer = new PublicationImporter\PublicationImporter();
$res = $importer->importFromFile($type, $source);
$importer = new PublicationFetcher\PublicationFetcher();
$res = $importer->importPublications($type, $source);

return $res;
}
4 changes: 2 additions & 2 deletions dev/www/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Publications Importer - Test</title>
<title>Publication Fetcher - Test</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css">
<style>
#field-file-uploader, #field-text-area, #btn-pub-import {
Expand Down Expand Up @@ -41,7 +41,7 @@
</head>
<body>

<h3 class="text-center mb-3 mt-3">Publications Importer</h3>
<h3 class="text-center mb-3 mt-3">Publication Fetcher</h3>

<div class="container">
<h4>Select data source</h4>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion settings/cli-actions/import-pubs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class: Proximify\PublicationImporter\PublicationImporterCLI
class: Proximify\PublicationFetcher\PublicationFetcherCLI
method: outputPublicationImport
isStatic: false
askConfirm: false
Expand Down
2 changes: 1 addition & 1 deletion settings/cli-actions/post-install-cmd.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
class: Proximify\PublicationImporter\DependencyInstaller
class: Proximify\PublicationFetcher\PublicationFetcherCLI
method: checkDependencies
2 changes: 1 addition & 1 deletion src/DependencyInstaller.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

/**
* File for class DependencyInstaller.
Expand Down
2 changes: 1 addition & 1 deletion src/DomWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// ==========================================================================
// require_once('debug_utils.php');

namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

use \DOMDocument;
use \DOMXpath;
Expand Down
4 changes: 2 additions & 2 deletions src/EndNoteImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// UniWeb by Proximify is proprietary software.
// ==========================================================================

namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

use Proximify\PublicationImporter\PublicationSource;
use Proximify\PublicationFetcher\PublicationSource;
use \Exception;

/**
Expand Down
7 changes: 4 additions & 3 deletions src/ModsImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
// All Rights Reserved
// UniWeb by Proximify is proprietary software.
// ==========================================================================
namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

use Proximify\PublicationImporter\DOMWalker;
use Proximify\PublicationImporter\PublicationSource;
use Proximify\PublicationFetcher\DOMWalker;
use Proximify\PublicationFetcher\PublicationSource;
use \Exception;

/**
* See http://www.loc.gov/standards/mods/mods-outline-3-7.htm
Expand Down
45 changes: 16 additions & 29 deletions src/PublicationImporter.php → src/PublicationFetcher.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

use Proximify\PublicationImporter\EndNoteImport;
use Proximify\PublicationImporter\PubMedImport;
use Proximify\PublicationImporter\ModsImporter;
use Symfony\Component\Yaml\Yaml;
use Proximify\PublicationFetcher\EndNoteImport;
use Proximify\PublicationFetcher\PubMedImport;
use Proximify\PublicationFetcher\ModsImporter;
use \Exception;

/**
Expand All @@ -16,12 +15,12 @@
* @version 1.0 UNIWeb Module
*/

class PublicationImporter {
class PublicationFetcher {
const DEFAULT_LIBRARY = 'bibutils';
const AVAILABLE_LIBRARIES = ['BibUtils'];
const HASH_KEYS_PATH = __DIR__ . '/../settings/publicationHashKeys.yaml'; // was .ini before
const FIELD_MAP_PATH = __DIR__ . '/../settings/publicationFieldMap.yaml'; // was .ini before
const SETTINGS_FILE = '../settings/PublicationImporter.json';
const SETTINGS_FILE = '../settings/PublicationFetcher.json';
const TITLE_KEY = 'TITLE_KEY';
const PUB_DATE_KEY = 'PUBDATE_KEY';
const UNDEFINED_SECTION = 'undefined';
Expand Down Expand Up @@ -180,6 +179,9 @@ function importPublications($type, $source, $checkAuthor = false, $deleteAfterIm
$doiList = [];
}

if ($type == 'gscholar')
$type = 'bibtex';

// $this->loadPublicationAndIntelectualPropertyProfileData();


Expand All @@ -196,7 +198,7 @@ function importPublications($type, $source, $checkAuthor = false, $deleteAfterIm
'oldPubs' => []
];

$this->sectionFieldMap = $this->loadSectionFieldMap($type);
// $this->sectionFieldMap = $this->loadSectionFieldMap($type);

switch ($type) {
case 'pubmed':
Expand All @@ -210,25 +212,10 @@ function importPublications($type, $source, $checkAuthor = false, $deleteAfterIm
$pubsInfo = $this->importFromFile($source, $type, $pubsInfo, $checkAuthor);
$currentProgress = 30;
break;
case 'gscholar':
case 'bibtex':
if ($doiList) {
if ($doiList)
$source = $this->fetchDOI($doiList);
} else {
try {
$source = $source;

// $source = $this->getUploadedFilePath();
} catch (Exception $e) {
// $rawInput = $this->getRequestParam('rawInput');

// if (!$rawInput)
// throw new Exception('Invalid empty file');

// $source = $this->createSourceFile($rawInput);
}
}


$pubsInfo = $this->importFromFile($source, $type, $pubsInfo, $checkAuthor);
$currentProgress = 30;

Expand All @@ -238,7 +225,7 @@ function importPublications($type, $source, $checkAuthor = false, $deleteAfterIm
}


$this->getOtherPubInfo($pubsInfo, $currentProgress, $duplicateCriteria);
// $this->getOtherPubInfo($pubsInfo, $currentProgress, $duplicateCriteria);

return $pubsInfo;

Expand All @@ -255,7 +242,7 @@ function importFromFile($path, $type, $pubsInfo, $checkAuthor)

// Try with the old method if we run into a problem
if (is_null($imported)) {
$imp = new EndNoteImport($this->modelParams(), $this->progress, $pubsInfo);
$imp = new EndNoteImport($this->progress, $pubsInfo);
$imported = $imp->importFromFile($path, $type, $encoding, $checkAuthor);
}

Expand Down Expand Up @@ -801,13 +788,13 @@ static function getKeyValue($node, $key)

function getHashKeys ()
{
return Yaml::parseFile(self::HASH_KEYS_PATH);
// return Yaml::parseFile(self::HASH_KEYS_PATH);
}


function loadSectionFieldMap($type)
{
$fieldMap = Yaml::parseFile(self::FIELD_MAP_PATH);
// $fieldMap = Yaml::parseFile(self::FIELD_MAP_PATH);
$keys = $this->getHashKeys();

// Get the UNIWeb field names
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

use Proximify\PublicationImporter\PublicationImporter;
use Proximify\PublicationFetcher\PublicationFetcher;

/**
*
* Extend the base class in order to add an additional
* location for the settings folder.
*/
class PublicationImporterCLI extends \Proximify\ForeignPackages
class PublicationFetcherCLI extends \Proximify\ForeignPackages
{
const TEST_BIBTEX = __DIR__ . '/../dev/tests/assets/sample.bib';
const TEST_GSCHOLAR = __DIR__ . '/../dev/tests/assets/sample.bib';
Expand Down Expand Up @@ -54,7 +54,7 @@ function outputPublicationImport($params)
$source = $params['source'];
}

$importer = new PublicationImporter();
$importer = new PublicationFetcher();
print_r($importer->importPublications($type, $source));
}

Expand Down
2 changes: 1 addition & 1 deletion src/PublicationSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// UniWeb by Proximify is proprietary software.
// ==========================================================================

namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

use \Exception;

Expand Down
8 changes: 4 additions & 4 deletions src/PubmedImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// All Rights Reserved
// UniWeb by Proximify is proprietary software.
// ==========================================================================
namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

use Proximify\PublicationImporter\PublicationSource;
use Proximify\PublicationImporter\RemoteConnection;
use Proximify\PublicationImporter\DomWalker;
use Proximify\PublicationFetcher\PublicationSource;
use Proximify\PublicationFetcher\RemoteConnection;
use Proximify\PublicationFetcher\DomWalker;
use \Exception;
use \DOMElement;

Expand Down
4 changes: 3 additions & 1 deletion src/RemoteConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
// UniWeb by Proximify is proprietary software.
// ==========================================================================

namespace Proximify\PublicationImporter;
namespace Proximify\PublicationFetcher;

use \Exception;

/**
* Connects to a remote server and fetches assets from it.
Expand Down

0 comments on commit e5de480

Please sign in to comment.