OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Importing an External non-OJS Journal

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

Importing an External non-OJS Journal

Postby thiessenp » Thu Nov 29, 2007 7:55 am

Hi,

I'm new to OJS and still ramping up. I've read through the online documentation. I'm very impressed with the amount of detail in the OJS docs for an OS project. I'll be developing plugins etc. for the next couple of years for my University. My first task is to import an external Journal thats housed on a completely different system. I noticed in the Support discussion a similar post and the response to create a mapping tool which in the case of the post was from Dublin Core to the OJS format.

Would anyone have any examples or could share any code for mapping an external format to the OJS format? (also any tips, hard learned lessons would be really appreciated)

Finally, as a new developer to OJS I'd like to get developing as quickly as possible. Beyond the OJS Technical Document (OJSTechnicalReference.pdf) and OJS in an Hour (OJSinanHour.pdf) would anyone have any other reading to suggest?

Thanks in advance,
-peter
thiessenp
 
Posts: 26
Joined: Wed Nov 28, 2007 1:08 pm
Location: Toronto

Re: Importing an External non-OJS Journal

Postby asmecher » Thu Nov 29, 2007 12:29 pm

Hi Peter,

Thanks for the feedback!

I tend to hack together custom scripts to get data into OJS's import format, since data typically comes from a number of sources, e.g. CSV files, flat-files, etc, and a single-format text processing solution often isn't flexible enough. If you've got data in an XML format, I'd suggest using XSL to transform the data; I've done this successfully to convert OJS 1.x import data into OJS 2.x's import format. (See http://pkp.sfu.ca/cvs/cvsweb.cgi/ojs2/plugins/importexport/native/ojs1-to-ojs2.xsl for this file's CVS entry.)

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8833
Joined: Wed Aug 10, 2005 12:56 pm

Re: Importing an External non-OJS Journal

Postby thiessenp » Fri Nov 30, 2007 1:58 pm

Hi Alec,

thanks for the reply. The XSLT example is quite helpful. I'm sure I'll have questions in the near future :)

Thanks again
-peter
thiessenp
 
Posts: 26
Joined: Wed Nov 28, 2007 1:08 pm
Location: Toronto

Re: Importing an External non-OJS Journal

Postby thiessenp » Thu Dec 06, 2007 8:25 am

Hi Alec,

forgot to ask, could I see an example of one of your hacked together custom scripts? Would you have any that convert CVS to OJS XML?

Thanks,
-peter
thiessenp
 
Posts: 26
Joined: Wed Nov 28, 2007 1:08 pm
Location: Toronto

Re: Importing an External non-OJS Journal

Postby asmecher » Thu Dec 06, 2007 10:34 am

Hi Peter,

Unfortunately, these are far too task-specific and full of specific cases to be of any general use, but as a general pattern, they usually look something like:
Code: Select all
<?php

// Escape a string that will be used in XML.
function fix($string) {
    return htmlspecialchars($string, ENT_NOQUOTES);
}

// Load article data for the export
function loadArticles ($filename) {
    // Add code here to load the input file into a structure that looks like:
    $data = array(
        array(
            'title' => 'First Article Title',
            'abstract' => 'First Article Abstract',
            'authors' => array(
                'firstName' => 'Joe',
                'lastName' => 'Public'
            )
        ),
        array(
            'title' => 'Second Article Title',
            'abstract' => 'Second Article Abstract',
            'authors' => array(
                'firstName' => 'Jane',
                'lastName' => 'Doe'
            )
        )
    );

    return $data;
}

$articles = loadArticles('input.csv');

$issueTitle = 'Issue Title';
$volume = 1;
$number = 1;
$year = 1;

$out = fopen('output.xml', 'w');
if (!$out) die ('Cannot open output file.');

fwrite($out, "<?xml version=\"1.0\" ?>\n");
fwrite($out, "<issue published=\"true\">\n");
fwrite($out, "\t<title>" . fix($issueTitle) . "</title>\n");
fwrite($out, "\t<volume>" . $volume  . "</volume>\n");
fwrite($out, "\t<number>" . $number . "</number>\n");
fwrite($out, "\t<year>" . $year . "</year>\n");

// For this sample script, put all articles in the same section
fwrite($out, "\t<section>\n");
fwrite($out, "\t<section>\n");
fwrite ($out, "\t\t<title>Articles</title>\n");

foreach ($articles as $article) {
    fwrite ($out, "\t\t<article>\n");
    fwrite ($out, "\t\t\t<title>" . fix($article['title']) . "</title>\n");
    fwrite ($out, "\t\t\t<abstract>" . fix($article['abstract']) . "</abstract>\n");

    foreach ($article['authors'] as $author) {
        // ...etc...
    }

    // ...etc...

    fwrite ($out, "\t\t</article>\n");
}

fwrite($out, "\t</section>\n");
fwrite($out, "</issue>\n");

fclose($out);

?>
If you want to get data from CSV (I assume you mean CSV, not CVS), you can use the fgetcsv function e.g. in your loadArticles function.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8833
Joined: Wed Aug 10, 2005 12:56 pm

Re: Importing an External non-OJS Journal

Postby thiessenp » Thu Dec 06, 2007 12:26 pm

very helpful - thanks!

-peter
thiessenp
 
Posts: 26
Joined: Wed Nov 28, 2007 1:08 pm
Location: Toronto

Re: Importing an External non-OJS Journal

Postby Owen » Tue Dec 11, 2007 4:50 pm

What about using phpMyAdmin to import?

(I think I asked this as part of another thread but didn't get an answer).
Owen
 
Posts: 44
Joined: Mon Nov 05, 2007 8:07 pm

Re: Importing an External non-OJS Journal

Postby asmecher » Tue Dec 11, 2007 6:58 pm

Hi Owen,

phpMyAdmin will only import batches of SQL statements or, possibly, something like CSV-formatted data that corresponds exactly to a table layout; I suspect none of these will be helpful for bringing in back-issues unless e.g. you're moving an OJS installation from one server to another.

Rergards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8833
Joined: Wed Aug 10, 2005 12:56 pm

Re: Importing an External non-OJS Journal

Postby Owen » Tue Dec 11, 2007 9:55 pm

Keeping to the existing schema for a particular table would be no problem. It's just whether you've got to fiddle with other tables in the process: is there only 1 table involved in journal archive imports?
Owen
 
Posts: 44
Joined: Mon Nov 05, 2007 8:07 pm

Re: Importing an External non-OJS Journal

Postby asmecher » Tue Dec 11, 2007 11:24 pm

Hi Owen,

Doing an issue import will probably affect 5-10 tables when all is said and done.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8833
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 2 guests