
-----------------------------------------------------------------------------
-- PORTLET_DEFINITION
-----------------------------------------------------------------------------

CREATE TABLE PORTLET_DEFINITION
(
    ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(80),
    CLASS_NAME VARCHAR2(255),
    APPLICATION_ID NUMBER(10,0) NOT NULL,
    PORTLET_IDENTIFIER VARCHAR2(80),
    EXPIRATION_CACHE VARCHAR2(30),
    RESOURCE_BUNDLE VARCHAR2(255),
    PREFERENCE_VALIDATOR VARCHAR2(255),
    SECURITY_REF VARCHAR2(40)
);

ALTER TABLE PORTLET_DEFINITION
    ADD CONSTRAINT PORTLET_DEFINITION_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- PORTLET_APPLICATION
-----------------------------------------------------------------------------

CREATE TABLE PORTLET_APPLICATION
(
    APPLICATION_ID NUMBER(10,0) NOT NULL,
    APP_NAME VARCHAR2(80) NOT NULL,
    APP_IDENTIFIER VARCHAR2(80),
    VERSION VARCHAR2(80),
    APP_TYPE NUMBER(10,0),
    CHECKSUM VARCHAR2(80),
    DESCRIPTION VARCHAR2(80),
    WEB_APP_ID NUMBER(10,0) NOT NULL,
    SECURITY_REF VARCHAR2(40),
    CONSTRAINT UK_APPLICATION UNIQUE (APP_NAME)
);

ALTER TABLE PORTLET_APPLICATION
    ADD CONSTRAINT PORTLET_APPLICATION_PK
PRIMARY KEY (APPLICATION_ID);






-----------------------------------------------------------------------------
-- WEB_APPLICATION
-----------------------------------------------------------------------------

CREATE TABLE WEB_APPLICATION
(
    ID NUMBER(10,0) NOT NULL,
    CONTEXT_ROOT VARCHAR2(255) NOT NULL
);

ALTER TABLE WEB_APPLICATION
    ADD CONSTRAINT WEB_APPLICATION_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- PA_METADATA_FIELDS
-----------------------------------------------------------------------------

CREATE TABLE PA_METADATA_FIELDS
(
    ID NUMBER(10,0) NOT NULL,
    OBJECT_ID NUMBER(10,0) NOT NULL,
    COLUMN_VALUE VARCHAR2(2000) NOT NULL,
    NAME VARCHAR2(100) NOT NULL,
    LOCALE_STRING VARCHAR2(50) NOT NULL
);

ALTER TABLE PA_METADATA_FIELDS
    ADD CONSTRAINT PA_METADATA_FIELDS_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- PD_METADATA_FIELDS
-----------------------------------------------------------------------------

CREATE TABLE PD_METADATA_FIELDS
(
    ID NUMBER(10,0) NOT NULL,
    OBJECT_ID NUMBER(10,0) NOT NULL,
    COLUMN_VALUE VARCHAR2(2000) NOT NULL,
    NAME VARCHAR2(100) NOT NULL,
    LOCALE_STRING VARCHAR2(50) NOT NULL
);

ALTER TABLE PD_METADATA_FIELDS
    ADD CONSTRAINT PD_METADATA_FIELDS_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- LANGUAGE
-----------------------------------------------------------------------------

CREATE TABLE LANGUAGE
(
    ID NUMBER(10,0) NOT NULL,
    PORTLET_ID NUMBER(10,0) NOT NULL,
    TITLE VARCHAR2(100),
    SHORT_TITLE VARCHAR2(100),
    LOCALE_STRING VARCHAR2(50) NOT NULL,
    KEYWORDS VARCHAR2(2000)
);

ALTER TABLE LANGUAGE
    ADD CONSTRAINT LANGUAGE_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- PORTLET_CONTENT_TYPE
-----------------------------------------------------------------------------

CREATE TABLE PORTLET_CONTENT_TYPE
(
    CONTENT_TYPE_ID NUMBER(10,0) NOT NULL,
    PORTLET_ID NUMBER(10,0) NOT NULL,
    CONTENT_TYPE VARCHAR2(30) NOT NULL,
    MODES VARCHAR2(2000)
);

ALTER TABLE PORTLET_CONTENT_TYPE
    ADD CONSTRAINT PORTLET_CONTENT_TYPE_PK
PRIMARY KEY (CONTENT_TYPE_ID);






-----------------------------------------------------------------------------
-- PARAMETER
-----------------------------------------------------------------------------

CREATE TABLE PARAMETER
(
    PARAMETER_ID NUMBER(10,0) NOT NULL,
    PARENT_ID NUMBER(10,0) NOT NULL,
    CLASS_NAME VARCHAR2(255) NOT NULL,
    NAME VARCHAR2(80) NOT NULL,
    PARAMETER_VALUE VARCHAR2(2000) NOT NULL
);

ALTER TABLE PARAMETER
    ADD CONSTRAINT PARAMETER_PK
PRIMARY KEY (PARAMETER_ID);






-----------------------------------------------------------------------------
-- PORTLET_ENTITY
-----------------------------------------------------------------------------

CREATE TABLE PORTLET_ENTITY
(
    PEID NUMBER(10,0) NOT NULL,
    ID VARCHAR2(255) NOT NULL,
    APP_NAME VARCHAR2(255) NOT NULL,
    PORTLET_NAME VARCHAR2(255) NOT NULL,
    CONSTRAINT UK_ENTITY_ID UNIQUE (ID)
);

ALTER TABLE PORTLET_ENTITY
    ADD CONSTRAINT PORTLET_ENTITY_PK
PRIMARY KEY (PEID);






-----------------------------------------------------------------------------
-- SECURITY_ROLE_REFERENCE
-----------------------------------------------------------------------------

CREATE TABLE SECURITY_ROLE_REFERENCE
(
    ID NUMBER(10,0) NOT NULL,
    PORTLET_DEFINITION_ID NUMBER(10,0) NOT NULL,
    ROLE_NAME VARCHAR2(150) NOT NULL,
    ROLE_LINK VARCHAR2(150)
);

ALTER TABLE SECURITY_ROLE_REFERENCE
    ADD CONSTRAINT SECURITY_ROLE_REFERENCE_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- SECURITY_ROLE
-----------------------------------------------------------------------------

CREATE TABLE SECURITY_ROLE
(
    ID NUMBER(10,0) NOT NULL,
    WEB_APPLICATION_ID NUMBER(10,0) NOT NULL,
    ROLE_NAME VARCHAR2(150) NOT NULL,
    DESCRIPTION VARCHAR2(150)
);

ALTER TABLE SECURITY_ROLE
    ADD CONSTRAINT SECURITY_ROLE_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- USER_ATTRIBUTE_REF
-----------------------------------------------------------------------------

CREATE TABLE USER_ATTRIBUTE_REF
(
    ID NUMBER(10,0) NOT NULL,
    APPLICATION_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(150),
    NAME_LINK VARCHAR2(150)
);

ALTER TABLE USER_ATTRIBUTE_REF
    ADD CONSTRAINT USER_ATTRIBUTE_REF_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- USER_ATTRIBUTE
-----------------------------------------------------------------------------

CREATE TABLE USER_ATTRIBUTE
(
    ID NUMBER(10,0) NOT NULL,
    APPLICATION_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(150),
    DESCRIPTION VARCHAR2(150)
);

ALTER TABLE USER_ATTRIBUTE
    ADD CONSTRAINT USER_ATTRIBUTE_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- JETSPEED_SERVICE
-----------------------------------------------------------------------------

CREATE TABLE JETSPEED_SERVICE
(
    ID NUMBER(10,0) NOT NULL,
    APPLICATION_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(150)
);

ALTER TABLE JETSPEED_SERVICE
    ADD CONSTRAINT JETSPEED_SERVICE_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- LOCALIZED_DESCRIPTION
-----------------------------------------------------------------------------

CREATE TABLE LOCALIZED_DESCRIPTION
(
    ID NUMBER(10,0) NOT NULL,
    OBJECT_ID NUMBER(10,0) NOT NULL,
    CLASS_NAME VARCHAR2(255) NOT NULL,
    DESCRIPTION VARCHAR2(2000) NOT NULL,
    LOCALE_STRING VARCHAR2(50) NOT NULL
);

ALTER TABLE LOCALIZED_DESCRIPTION
    ADD CONSTRAINT LOCALIZED_DESCRIPTION_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- LOCALIZED_DISPLAY_NAME
-----------------------------------------------------------------------------

CREATE TABLE LOCALIZED_DISPLAY_NAME
(
    ID NUMBER(10,0) NOT NULL,
    OBJECT_ID NUMBER(10,0) NOT NULL,
    CLASS_NAME VARCHAR2(255),
    DISPLAY_NAME VARCHAR2(2000) NOT NULL,
    LOCALE_STRING VARCHAR2(50) NOT NULL
);

ALTER TABLE LOCALIZED_DISPLAY_NAME
    ADD CONSTRAINT LOCALIZED_DISPLAY_NAME_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- CUSTOM_PORTLET_MODE
-----------------------------------------------------------------------------

CREATE TABLE CUSTOM_PORTLET_MODE
(
    ID NUMBER(10,0) NOT NULL,
    APPLICATION_ID NUMBER(10,0) NOT NULL,
    CUSTOM_NAME VARCHAR2(150) NOT NULL,
    MAPPED_NAME VARCHAR2(150),
    DESCRIPTION VARCHAR2(2000)
);

ALTER TABLE CUSTOM_PORTLET_MODE
    ADD CONSTRAINT CUSTOM_PORTLET_MODE_PK
PRIMARY KEY (ID);






-----------------------------------------------------------------------------
-- CUSTOM_WINDOW_STATE
-----------------------------------------------------------------------------

CREATE TABLE CUSTOM_WINDOW_STATE
(
    ID NUMBER(10,0) NOT NULL,
    APPLICATION_ID NUMBER(10,0) NOT NULL,
    CUSTOM_NAME VARCHAR2(150) NOT NULL,
    MAPPED_NAME VARCHAR2(150),
    DESCRIPTION VARCHAR2(2000)
);

ALTER TABLE CUSTOM_WINDOW_STATE
    ADD CONSTRAINT CUSTOM_WINDOW_STATE_PK
PRIMARY KEY (ID);











ALTER TABLE PA_METADATA_FIELDS
    ADD CONSTRAINT FK_PA_METADATA_FIELDS_1 FOREIGN KEY (OBJECT_ID)
    REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
ON DELETE CASCADE
;



ALTER TABLE PD_METADATA_FIELDS
    ADD CONSTRAINT FK_PD_METADATA_FIELDS_1 FOREIGN KEY (OBJECT_ID)
    REFERENCES PORTLET_DEFINITION (ID)
ON DELETE CASCADE
;















ALTER TABLE USER_ATTRIBUTE_REF
    ADD CONSTRAINT FK_USER_ATTRIBUTE_REF_1 FOREIGN KEY (APPLICATION_ID)
    REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
ON DELETE CASCADE
;



ALTER TABLE USER_ATTRIBUTE
    ADD CONSTRAINT FK_USER_ATTRIBUTE_1 FOREIGN KEY (APPLICATION_ID)
    REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
ON DELETE CASCADE
;









ALTER TABLE CUSTOM_PORTLET_MODE
    ADD CONSTRAINT FK_CUSTOM_PORTLET_MODE_1 FOREIGN KEY (APPLICATION_ID)
    REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
ON DELETE CASCADE
;



ALTER TABLE CUSTOM_WINDOW_STATE
    ADD CONSTRAINT FK_CUSTOM_WINDOW_STATE_1 FOREIGN KEY (APPLICATION_ID)
    REFERENCES PORTLET_APPLICATION (APPLICATION_ID)
ON DELETE CASCADE
;



