Difference between revisions of "API:bin/import subjects"

From EPrints Documentation
Jump to: navigation, search
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<!-- Pod2Wiki=_preamble_  
 
<!-- Pod2Wiki=_preamble_  
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=bin/import_subjects.pm|package_name=bin/import_subjects}}[[Category:API|BIN/IMPORT_SUBJECTS]][[Category:API:bin/import_subjects|BIN/IMPORT_SUBJECTS]][[Category:API:bin/import_subjects|BIN/IMPORT_SUBJECTS]]<div><!-- Edit below this comment -->
+
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=bin/import_subjects|package_name=bin/import_subjects}}[[Category:API|BIN/IMPORT_SUBJECTS]][[Category:API:bin/import_subjects|BIN/IMPORT_SUBJECTS]][[Category:API:bin/import_subjects|BIN/IMPORT_SUBJECTS]]<div><!-- Edit below this comment -->
  
  
Line 8: Line 8:
 
'''import_subjects''' - rebuild an EPrint repository subjects list from the contents of a file
 
'''import_subjects''' - rebuild an EPrint repository subjects list from the contents of a file
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_synopsis -->
 
<!-- Pod2Wiki=head_synopsis -->
 
==SYNOPSIS==
 
==SYNOPSIS==
 
'''import_subjects''' <em>repository_id</em> ['''options'''] [<em>subjectfile</em>]
 
'''import_subjects''' <em>repository_id</em> ['''options'''] [<em>subjectfile</em>]
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_description -->
 
<!-- Pod2Wiki=head_description -->
 
==DESCRIPTION==
 
==DESCRIPTION==
Line 36: Line 30:
 
Without the '''--force''' option, this script asks for confirmation before actually erasing anything.
 
Without the '''--force''' option, this script asks for confirmation before actually erasing anything.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_arguments -->
 
<!-- Pod2Wiki=head_arguments -->
 
==ARGUMENTS==
 
==ARGUMENTS==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* <em>repository_id</em>  
<span style='display:none'>User Comments</span>
+
: The ID of the EPrint repository to use.
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_i_repository_id -->
 
===<em>repository_id</em> ===
 
 
 
The ID of the EPrint repository to use.
 
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_i_subjectfile -->
 
===<em>subjectfile</em>===
 
  
This is the file to import the subjects from. If you do not specify it then the system will use "subjects" from the given repository cfg directory.  
+
* <em>subjectfile</em>
 +
: This is the file to import the subjects from. If you do not specify it then the system will use "subjects" from the given repository cfg directory.  
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_options -->
 
<!-- Pod2Wiki=head_options -->
 
==OPTIONS==
 
==OPTIONS==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* '''--xml'''
<span style='display:none'>User Comments</span>
+
: Import XML format instead of flat text.
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_b_xml -->
 
==='''--xml'''===
 
 
 
Import XML format instead of flat text.
 
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* '''--help'''
<span style='display:none'>User Comments</span>
+
: Print a brief help message and exit.
<!-- Edit below this comment -->
 
  
 +
* '''--man'''
 +
: Print the full manual page and then exit.
  
<!-- Pod2Wiki= -->
+
* '''--quiet'''
</div>
+
: Be vewwy vewwy quiet. This option will supress all output unless an error occurs.
<!-- Pod2Wiki=item_b_help -->
 
==='''--help'''===
 
  
Print a brief help message and exit.
+
* '''--verbose'''
 +
: Explain in detail what is going on. May be repeated for greater effect.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* '''--version'''
<span style='display:none'>User Comments</span>
+
: Output version information and exit.
<!-- Edit below this comment -->
 
  
 +
* '''--nopurge'''
 +
: Do not purge the existing records from the subject table before importing this file. Rather than do this, it's probably easier to export the current subjects as XML, then combine in your new file and reimport it.
  
<!-- Pod2Wiki= -->
+
* '''--force'''
</div>
+
: Don't ask before making the changes.
<!-- Pod2Wiki=item_b_man -->
 
==='''--man'''===
 
  
Print the full manual page and then exit.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
<!-- Pod2Wiki=item_b_quiet -->
 
==='''--quiet'''===
 
 
Be vewwy vewwy quiet. This option will supress all output unless an error occurs.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_b_verbose -->
 
==='''--verbose'''===
 
 
Explain in detail what is going on. May be repeated for greater effect.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_b_version -->
 
==='''--version'''===
 
 
Output version information and exit.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_b_nopurge -->
 
==='''--nopurge'''===
 
 
Do not purge the existing records from the subject table before importing this file. Rather than do this, it's probably easier to export the current subjects as XML, then combine in your new file and reimport it.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_b_force -->
 
==='''--force'''===
 
 
Don't ask before making the changes.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
 
<!-- Pod2Wiki=head_file_format -->
 
<!-- Pod2Wiki=head_file_format -->
 
==FILE FORMAT==
 
==FILE FORMAT==
Line 189: Line 84:
 
The XML format can contain any unicode characters and also allows multiple languages for the names of subjects. You may wish to dump the current subjects out of eprints as XML. Edit it. Then re-import it. The downside is that this format is far more verbose.
 
The XML format can contain any unicode characters and also allows multiple languages for the names of subjects. You may wish to dump the current subjects out of eprints as XML. Edit it. Then re-import it. The downside is that this format is far more verbose.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_the_ascii_default_format -->
 
<!-- Pod2Wiki=head_the_ascii_default_format -->
 
===The ASCII Default Format===
 
===The ASCII Default Format===
Line 212: Line 104:
 
Please see the main documentation for the meaning of these fields.
 
Please see the main documentation for the meaning of these fields.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
* '''subjectid'''  
<span style='display:none'>User Comments</span>
+
: An ASCII string which is a unique ID for this subject.
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_b_subjectid -->
 
===='''subjectid''' ====
 
 
 
An ASCII string which is a unique ID for this subject.
 
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_b_name -->
 
===='''name''' ====
 
 
 
The name of this subject, in the default language of the repository.
 
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
* '''name'''
 +
: The name of this subject, in the default language of the repository.
  
<!-- Pod2Wiki= -->
+
* '''parents'''  
</div>
+
: A comma seperated list of the parents of this subject. Be careful not to cause loops. The top level subject id is ROOT and should not be imported as it always exists.
<!-- Pod2Wiki=item_b_parents -->
 
===='''parents''' ====
 
  
A comma seperated list of the parents of this subject. Be careful not to cause loops. The top level subject id is ROOT and should not be imported as it always exists.
+
* '''depositable'''
 +
: A boolean value ( 1 or 0 ) which indicates if this subject may have eprints associated with it.  
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
<!-- Pod2Wiki=item_b_depositable -->
 
===='''depositable''' ====
 
 
A boolean value ( 1 or 0 ) which indicates if this subject may have eprints associated with it.
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
 
<!-- Pod2Wiki=head_the_xml_file_format -->
 
<!-- Pod2Wiki=head_the_xml_file_format -->
 
===The XML File Format===
 
===The XML File Format===
 
This is the standard eprints export format. It looks like this:
 
This is the standard eprints export format. It looks like this:
  
  &lt;eprintsdata&gt;
+
<pre>  &lt;eprintsdata&gt;
 
     &lt;record&gt;
 
     &lt;record&gt;
 
       &lt;field name="subjectid"&gt;phys&lt;/field&gt;
 
       &lt;field name="subjectid"&gt;phys&lt;/field&gt;
Line 281: Line 134:
 
     .
 
     .
 
     .
 
     .
   &lt;/eprintsdata&gt;
+
   &lt;/eprintsdata&gt;</pre>
 
 
The fields have the same meaning as described for the ASCII format, with the following variations. The name field can (and should) have a name for each language supported by the repository. Multiple parents are indicated by multiple <tt>&lt;lt</tt>field name="parents&lt;gt&gt;&gt; elements. Depositable should be either TRUE or FALSE.
 
  
 +
The fields have the same meaning as described for the ASCII format, with the following variations. The name field can (and should) have a name for each language supported by the repository. Multiple parents are indicated by multiple <code>&lt;lt</code>field name="parents&lt;gt&gt;&gt; elements. Depositable should be either TRUE or FALSE.
 +
 +
<pre></pre>
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_copyright -->
 
<!-- Pod2Wiki=head_copyright -->
 
==COPYRIGHT==
 
==COPYRIGHT==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #ccepadding: 0em 1em 0em 1em; font-size: 80%; '>
+
Copyright 2000-2011 University of Southampton.
<span style='display:none'>User Comments</span>
+
 
 +
This file is part of EPrints http://www.eprints.org/.
 +
 
 +
EPrints 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 3 of the License, or (at your option) any later version.
 +
 
 +
EPrints 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 EPrints.  If not, see http://www.gnu.org/licenses/.
 +
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=_postamble_ -->
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->
+
<!-- Edit below this comment -->

Latest revision as of 09:57, 22 January 2013

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

import_subjects - rebuild an EPrint repository subjects list from the contents of a file


SYNOPSIS

import_subjects repository_id [options] [subjectfile]


DESCRIPTION

Import a set of subjects into an EPrints repository. The subjects are the heirarchical tree of options for "subject" type metadata fields in an eprint repository.

Use the staff admin subject editor for little tweaks. Use this command for the initial setup or bulk editing subjects. Use the exporter to dump the current subjects if you (an administrator) have edited them online.

This script should also be run after create_tables.

Without the --force option, this script asks for confirmation before actually erasing anything.


ARGUMENTS

  • repository_id
The ID of the EPrint repository to use.
  • subjectfile
This is the file to import the subjects from. If you do not specify it then the system will use "subjects" from the given repository cfg directory.


OPTIONS

  • --xml
Import XML format instead of flat text.
  • --help
Print a brief help message and exit.
  • --man
Print the full manual page and then exit.
  • --quiet
Be vewwy vewwy quiet. This option will supress all output unless an error occurs.
  • --verbose
Explain in detail what is going on. May be repeated for greater effect.
  • --version
Output version information and exit.
  • --nopurge
Do not purge the existing records from the subject table before importing this file. Rather than do this, it's probably easier to export the current subjects as XML, then combine in your new file and reimport it.
  • --force
Don't ask before making the changes.


FILE FORMAT

There are two different file formats excepted, the default colon seperated file and XML in the eprints export format.

The colon seperated ASCII is easier to edit, but is more limited. It is not intended for UTF-8 encoded characters and can only specify subject names in the default language.

The XML format can contain any unicode characters and also allows multiple languages for the names of subjects. You may wish to dump the current subjects out of eprints as XML. Edit it. Then re-import it. The downside is that this format is far more verbose.


The ASCII Default Format

This is the default format.

Comments may be placed on lines begining with a hash (#)

Each (non-comment) line of the file should be in the following format:

subjectid:name:parents:depositable

eg.

blgc-bphy:Biophysics:blgc,phys:1

Please see the main documentation for the meaning of these fields.

  • subjectid
An ASCII string which is a unique ID for this subject.
  • name
The name of this subject, in the default language of the repository.
  • parents
A comma seperated list of the parents of this subject. Be careful not to cause loops. The top level subject id is ROOT and should not be imported as it always exists.
  • depositable
A boolean value ( 1 or 0 ) which indicates if this subject may have eprints associated with it.


The XML File Format

This is the standard eprints export format. It looks like this:

  <eprintsdata>
    <record>
      <field name="subjectid">phys</field>
      <field name="name"><lang id="en">Physical Sciences &amp; Mathematics</lang></field>
      <field name="parents">subjects</field>
      <field name="depositable">FALSE!/field!
    </record>
    .
    .
    .
  </eprintsdata>

The fields have the same meaning as described for the ASCII format, with the following variations. The name field can (and should) have a name for each language supported by the repository. Multiple parents are indicated by multiple <ltfield name="parents<gt>> elements. Depositable should be either TRUE or FALSE.



COPYRIGHT

Copyright 2000-2011 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints 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 3 of the License, or (at your option) any later version.

EPrints 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 EPrints. If not, see http://www.gnu.org/licenses/.