<?xml version="1.0"?>

<!-- 

    that is a sample ARDB core configuration file.  it's structure
    well may change.

    $Id: configuration.xml,v 1.10 2003/05/13 09:23:01 ivan Exp $

-->

<configuration>


<relation-type name="written-by" reverse="wrote" default-retrieve="record">
    <view name='nothing' retrieve='nothing' />
    <view name='brief' retrieve="name,handle" />
</relation-type>

<relation-type 
	name="wrote"
	reverse="written-by"
	default-retrieve="record">

	<view name="brief" retrieve="title,handle,authors:author/name" />

	<view name="brief-with-creation-date" retrieve="title,handle,authors:author/name,creation-date"/>

</relation-type>

<relation-type 
	name="cited-by"
	reverse="cites" 
    default-retrieve='title,handle,authors:author/name'
	>
</relation-type>

<relation-type 
    name="cites"
    reverse="cited-by" 
    default-retrieve='title,handle,authors:author/name'
	>
</relation-type>

<relation-type
    name='part-of'
    reverse='has-part' 
    default-retrieve='nothing' />

<relation-type
    name='has-part'
    reverse='part-of' 
    default-retrieve='nothing' />

<relation-type
    name='has-shortid'
    default-retrieve='id' />

<!-- reverse='is-shortid-of' -->


<relation-type
    name='classified-under'
    default-retrieve='id,title' />


<relation-type
	name="related"
	undirected="yes"
	default-retrieve="handle"
	 />


<!--
 	A table element configures an SQL table. 

 	It only defines table structure and SQL details.

 	What it does not define is mapping from template data to table
 	records.

-->


<table name="authors">
	<field name="name"   sql-type=" VARCHAR(200) NOT NULL "/>
	<field name="email"  sql-type=" VARCHAR(200) " />
	<field name="handle" sql-type=" VARCHAR(200) NOT NULL PRIMARY KEY " />

	<field name="fname"   sql-type=" VARCHAR(200)  "/>
	<field name="mname"   sql-type=" VARCHAR(200)  "/>
	<field name="lname"   sql-type=" VARCHAR(200)  "/>

 	<!-- 
		upon building create table statement this will be included
	-->
	<create-table-sql line=" "/>

</table>


<field-attribute-mapping name="authors">
	<field-associations
      name="name-full"
      fname='name-first'
      mname='name-middle'
      lname='name-last'
      email='email'
      handle='handle'
      />
</field-attribute-mapping>

<put-processing record-type="ReDIF-Person 1.0">
    <store-to-table table='authors' field-attribute-mapping='authors' />

    <build-forward-relation
      type='wrote'
      attributes='author-paper,author-article,author-book,author-software,author-chapter'/>

</put-processing>


<delete-processing record-type="ReDIF-Person 1.0">
    <delete-from-table table='authors' by='authors' />
</delete-processing>



<!-- ReDIF document template-types -->

<table name="documents">

	<field name="title"    sql-type=" VARCHAR(200) NOT NULL "/>
	<field name="authors"  sql-type=" CHAR(200) NOT NULL "/>
	<field name="authors_emails"  sql-type=" CHAR(200)  "/>
	<field name="subject"  sql-type=" TEXT NOT NULL" />
	<field name="abstract" sql-type=" TEXT " />
	<field name="creation_date"  
			       sql-type=" TIMESTAMP(14) " />
	<field name="handle"   sql-type=" CHAR(200) NOT NULL PRIMARY KEY " />

	<field name="jel"      sql-type=" CHAR(50) " />

	<field name="file"     sql-type=" int " />
	<field name="urls"     sql-type=" text "/>

        <field name='keywords' sql-type=" text "/>

 	<!-- 
		upon composing SQL create table statement
		this will be included:
	-->

	<create-table-sql>
	  INDEX title_i ( title ),
          INDEX authors_i ( authors ),
          INDEX creationdate_i ( creation_date ),
	  FULLTEXT INDEX subj ( title, keywords, abstract ),
          FULLTEXT INDEX authors_ft ( authors )
	</create-table-sql>

</table>


<field-attribute-mapping name="documents">
	<field-associations
		title="title"
		subject="title,abstract,keywords"
		authors="author/name"
		authors_emails="author/email"
		keywords="keywords"
		abstract="abstract"
		creation_date="creation-date"
      urls='file/url'
      jel='classification-jel'
      handle="handle"
      />

<!-- XXX: file='ARDB::RePEc::tools::is_there_file'  -->

</field-attribute-mapping>


<put-processing 
record-type="ReDIF-Paper 1.0,ReDIF-Article 1.0,ReDIF-Book 1.0,ReDIF-Chapter 1.0,ReDIF-Software 1.0">

    <store-to-table 
      table="documents"
      field-attribute-mapping="documents"/>
    
    <build-forward-relation 
      type="written-by" 
      attributes="author/handle"
      />

    <build-forward-relation
      type='classified-under'
      attributes="classification-jel" />

</put-processing>

<delete-processing 
 record-type="ReDIF-Paper 1.0,ReDIF-Article 1.0,ReDIF-Book 1.0,ReDIF-Chapter 1.0,ReDIF-Software 1.0">
  <delete-from-table table='documents' by='handle'/>
</delete-processing>




<!-- ReDIF-Institution 1.0 processing -->

<!-- institutions table -->

<table name='institutions'>
    <field name='handle' sql-type="CHAR(200) NOT NULL PRIMARY KEY" />
    <field name='name' sql-type="CHAR(255) NOT NULL" />
    <field name='email' sql-type='VARCHAR(100)' />
    <field name='postal' sql-type="VARCHAR(150)" />
    <field name='phone'  sql-type="VARCHAR(30)" />
    <field name='fax'    sql-type="VARCHAR(30)" />
    <field name='homepage' sql-type="VARCHAR(100)" />
    <field name='location' sql-type="VARCHAR(100)" />

    <create-table-sql>
      INDEX ( name ),
      FULLTEXT INDEX ( location )
    </create-table-sql>

</table>

<field-attribute-mapping name="institutions">
    <field-associations
      name="primary/name,secondary/name,tertiary/name"
      email="primary/email,secondary/email"
      postal="primary/postal,secondary/postal"
      phone='primary/phone,secondary/phone'
      fax="primary/fax,secondary/fax"
      homepage="primary/homepage,secondary/homepage"
      location="primary/location,secondary/location"
      handle="handle"
      />
</field-attribute-mapping>

<put-processing
    record-type='ReDIF-Institution 1.0'>
    <store-to-table
      table="institutions"
      field-attribute-mapping="institutions" />
</put-processing>

<delete-processing record-type="ReDIF-Institution 1.0">
  <delete-from-table table='institutions' by='handle'/>
</delete-processing>




<!-- collections table -->

<table name='collections'>
    <field name='handle' sql-type="CHAR(200) NOT NULL PRIMARY KEY" />
    <field name='type' sql-type="CHAR(25)" />/>
    <field name='name' sql-type="CHAR(255) NOT NULL" />
    <field name='maintainer-email' sql-type='VARCHAR(100)' />
    <field name='maintainer-name'  sql-type="VARCHAR(100)" />
    <field name='URL'  sql-type="VARCHAR(100)" />
    <field name='homepage' sql-type="VARCHAR(100)" />

    <create-table-sql>
      INDEX ( name )
    </create-table-sql>

</table>

<field-attribute-mapping name="collections">
    <field-associations
      name="name"
      maintainer-email="maintainer-email"
      maintainer-name="maintainer-name"
      homepage="homepage"
      URL="url"
      handle="handle"
      />
</field-attribute-mapping>

<put-processing
    record-type='ReDIF-Archive 1.0,ReDIF-Series 1.0'>
    <store-to-table
      table="collections"
      field-attribute-mapping="collections" />
</put-processing>

<delete-processing record-type="ReDIF-Archive 1.0,ReDIF-Series 1.0">
  <delete-from-table table='collections' by='handle'/>
</delete-processing>



</configuration>





