<?xml version="1.0"?>
<!--
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database_3_1.dtd">
<!-- Autogenerated by JDBCToXMLSchema! -->
<database>

    <!--
       Create Portlet Definition Table
    -->
    <table name="PORTLET_DEFINITION">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="NAME" size="80" type="VARCHAR"/>
        <column name="CLASS_NAME" size="255" type="VARCHAR"/>
        <column name="APPLICATION_ID" required="true" type="INTEGER"/>
        <column name="PORTLET_IDENTIFIER" size="80" type="VARCHAR"/>
        <column name="EXPIRATION_CACHE" size="30" type="VARCHAR"/>
        <column name="RESOURCE_BUNDLE" size="255" type="VARCHAR"/>
        <column name="PREFERENCE_VALIDATOR" size="255" type="VARCHAR"/>
        <!-- This breaks some tests since portlet identifier is not required
        <unique name="UK_PORTLET_IDENT">
            <unique-column name="PORTLET_IDENTIFIER"/>
        </unique>
        -->
    </table>

    <!--
       Create Portlet Application Table
    -->
    <table name="PORTLET_APPLICATION">
        <column name="APPLICATION_ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="APP_NAME" required="true" size="80" type="VARCHAR"/>
        <column name="APP_IDENTIFIER" size="80" type="VARCHAR"/>
        <column name="VERSION" size="80" type="VARCHAR"/>
        <column name="APP_TYPE" type="INTEGER"/>
		<column name="CHECKSUM" size="80" type="VARCHAR"/>
        <column name="DESCRIPTION" size="80" type="VARCHAR"/>
        <column name="WEB_APP_ID" required="true" type="INTEGER"/>
        <unique name="UK_APPLICATION">
            <unique-column name="APP_NAME"/>
        </unique>
    </table>                                                               

    <!--
       Create Web Application Table
    -->
    <table name="WEB_APPLICATION">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="CONTEXT_ROOT" required="true" size="255" type="VARCHAR"/>
    </table>
    
    <!--
       Create Portlet Application Metadata Fields Table
    -->    
    <table name="PA_METADATA_FIELDS">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="OBJECT_ID" required="true" type="INTEGER"/>
        <column name="VALUE" required="true" type="LONGVARCHAR"/>
        <column name="NAME" required="true" size="100" type="VARCHAR"/>
        <column name="LOCALE_STRING" required="true" size="50" type="VARCHAR"/>
        <foreign-key foreignTable="PORTLET_APPLICATION" onDelete="cascade">                        
            <reference foreign="APPLICATION_ID" local="OBJECT_ID"/>            
        </foreign-key>        
    </table>
    
    <!--
       Create Portlet Definition Metadata Fields Table
    -->    
    <table name="PD_METADATA_FIELDS">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="OBJECT_ID" required="true" type="INTEGER"/>
        <column name="VALUE" required="true" type="LONGVARCHAR"/>
        <column name="NAME" required="true" size="100" type="VARCHAR"/>
        <column name="LOCALE_STRING" required="true" size="50" type="VARCHAR"/>
        <foreign-key foreignTable="PORTLET_DEFINITION" onDelete="cascade">                        
            <reference foreign="ID" local="OBJECT_ID"/>            
        </foreign-key>                
    </table>

    <!--
       Create Language Table
    -->
    <table name="LANGUAGE">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="PORTLET_ID" required="true" type="INTEGER"/>
        <column name="TITLE" size="100" type="VARCHAR"/>
        <column name="SHORT_TITLE" size="50" type="VARCHAR"/>
        <column name="LOCALE_STRING" required="true" size="50" type="VARCHAR"/>
        <column name="KEYWORDS" type="LONGVARCHAR"/>
    </table>
    
    <!--
       Create Content Type Table
    -->
    <table name="PORTLET_CONTENT_TYPE">
        <column name="CONTENT_TYPE_ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="PORTLET_ID" required="true" type="INTEGER"/>
        <column name="CONTENT_TYPE" required="true" size="30" type="VARCHAR"/>
        <column name="MODES" type="LONGVARCHAR"/>
    </table>
    
    <!--
       Create Parameter Table
       NOTE : This table supports both Servlet and Portlet parameters
       Class Name is required to decide if this is a portlet or servlet parameter
    -->
    <table name="PARAMETER">
        <column name="PARAMETER_ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="PARENT_ID" required="true" type="INTEGER"/>
        <column name="CLASS_NAME" required="true" size="255" type="VARCHAR"/>
        <column name="NAME" required="true" size="80" type="VARCHAR"/>
        <column name="PARAMETER_VALUE" required="true" type="LONGVARCHAR"/>
    </table>
    
    <!--
      Preference and Preference Values
    -->
    
    <table name="PREFERENCE_VALUE">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="PREFERENCE_ID" type="INTEGER"/>
        <column name="VALUE" type="LONGVARCHAR"/>
    </table>
    
    <table name="PORTLET_PREFERENCE">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="PARENT_ID" required="true" type="INTEGER"/>
        <column name="NAME" required="true" size="80" type="VARCHAR"/>
        <column name="CLASS_NAME" required="true" size="255" type="VARCHAR"/>
        <column default="1" name="READ_ONLY" size="1" type="CHAR"/>
    </table>

    <!--
       Portlet Entity
       Represents the managed state of individual portlet instance within a "page"
       The instance within a "page" key is based on Window ID + principal
       Without the principal, the key represents the default preferences for the window
    -->
    <table name="PORTLET_ENTITY">
        <column name="PEID" primaryKey="true" required="true" type="INTEGER"/>
       <!-- <column name="PORTLET_DEFINITION_ID" required="true" type="INTEGER"/> -->
        <column name="ID" required="true" size="255" type="VARCHAR"/>
        <column name="APP_NAME" required="true" size="255" type="VARCHAR"/>
        <column name="PORTLET_NAME" required="true" size="255" type="VARCHAR"/>
        <unique name="UK_ENTITY_ID">
            <unique-column name="ID"/>
        </unique>
    </table>
    
    <!--
       Security Role Reference
    -->
    <table name="SECURITY_ROLE_REFERENCE">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="PORTLET_DEFINITION_ID" required="true" type="INTEGER"/>
        <column name="ROLE_NAME" required="true" size="150" type="VARCHAR"/>
        <column name="ROLE_LINK" size="150" type="VARCHAR"/>
    </table>
    
    <!--                                                                   
       Security Role                                                        
    -->                                                                     
    <table name="SECURITY_ROLE">                                            
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="WEB_APPLICATION_ID" required="true" type="INTEGER"/>  
        <column name="ROLE_NAME" required="true" size="150" type="VARCHAR"/>
        <column name="DESCRIPTION" size="150" type="VARCHAR"/>              
        <!-- This is causing removing portlet application to fail with OJB RC4.
        <foreign-key foreignTable="WEB_APPLICATION" onDelete="cascade">                        
            <reference foreign="ID" local="WEB_APPLICATION_ID"/>            
        </foreign-key>
        -->                                                   
    </table> 

    <!--
       User Attribute Reference
    -->
    <table name="USER_ATTRIBUTE_REF">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="APPLICATION_ID" required="true" type="INTEGER"/>
        <column name="NAME" size="150" type="VARCHAR"/>
        <column name="NAME_LINK" size="150" type="VARCHAR"/>
        <foreign-key foreignTable="PORTLET_APPLICATION" onDelete="cascade">
            <reference foreign="APPLICATION_ID" local="APPLICATION_ID"/>
        </foreign-key>                
    </table>

	<!--
       User Attribute
    -->
    <table name="USER_ATTRIBUTE">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="APPLICATION_ID" required="true" type="INTEGER"/>
        <column name="NAME" size="150" type="VARCHAR"/>
        <column name="DESCRIPTION" size="150" type="VARCHAR"/>
        <foreign-key foreignTable="PORTLET_APPLICATION" onDelete="cascade">
            <reference foreign="APPLICATION_ID" local="APPLICATION_ID"/>
        </foreign-key>        
    </table>

	<!--
       Jetspeed Service
    -->
    <table name="JETSPEED_SERVICE">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="APPLICATION_ID" required="true" type="INTEGER"/>
        <column name="NAME" size="150" type="VARCHAR"/>
    </table>

    
    <!-- 
       Localized Descriptions
    -->
    <table name="LOCALIZED_DESCRIPTION">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="OBJECT_ID" required="true" type="INTEGER"/>
        <column name="CLASS_NAME" required="true" size="255" type="VARCHAR"/>
        <column name="DESCRIPTION" required="true" type="LONGVARCHAR"/>
        <column name="LOCALE_STRING" required="true" size="50" type="VARCHAR"/>
    </table>
    
    <!--
       Localized Display Names
    -->
    <table name="LOCALIZED_DISPLAY_NAME">
        <column name="ID" primaryKey="true" required="true" type="INTEGER"/>
        <column name="OBJECT_ID" required="true" type="INTEGER"/>
        <column name="CLASS_NAME" size="255" type="VARCHAR"/>
        <column name="DISPLAY_NAME" required="true" type="LONGVARCHAR"/>
        <column name="LOCALE_STRING" required="true" size="50" type="VARCHAR"/>
    </table>
    
                         
</database>
