/*==============================================================*/
/* @table: rt_p_case (rt_p_001)                                 */
/*                                                              */
/* @desc:                                                       */
/*                                                              */
/* @created: 2004-4-4 16:02                                     */
/*                                                              */
/* @comment:                                                    */
/*                                                              */
/*==============================================================*/
create table rt_p_case
(
vc_packageid       varchar2(50)    not null,    --package uuid.refers to xpdl_p_package#vc_uuid
vc_processid       varchar2(50)    not null,    --process uuid.refers to xpdl_p_process#vc_uuid,must be main process
vc_uuid            varchar2(50)    not null,    --case uuid
vc_name            varchar2(50)    ,            --case name
vc_primarykey      varchar2(50)    not null,    --case use define primary key
vc_creator         varchar2(50)    ,            --creator of the case
dat_creationtime   date            not null,    --creation time of the case
int_state          number(10)      not null,    --case status
vc_magicid         varchar2(50)    not null,    --case first workflow work uuid.refers to rt_p_work#vc_uuid
vc_description     varchar2(255)           ,    --case description
primary key(vc_uuid)
);

/*==============================================================*/
/* @table: rt_p_work (rt_p_002)                                 */
/*                                                              */
/* @desc:                                                       */
/*                                                              */
/* @created: 2004-4-4 16:02                                     */
/*                                                              */
/* @comment:                                                    */
/*                                                              */
/*==============================================================*/
create table rt_p_work
(
vc_packageid          varchar2(50)    not null,    --package uuid.refers to xpdl_p_package#vc_uuid
vc_processid          varchar2(50)    not null,    --process uuid.refers to xpdl_p_process#vc_uuid (must be main process)
vc_caseid             varchar2(50)    not null,    --case uuid.refers to rt_p_case#vc_uuid
vc_owner_processid    varchar2(50)    ,            --owner process uuid.refers to xpdl_p_process#vc_uuid 
vc_activityid         varchar2(50)    not null,    --activity uuid.refers to xpdl_p_activity#vc_uuid
vc_uuid               varchar2(50)    not null,    --work uuid
vc_performer          varchar2(50)    ,            --work performer.refers to om_p_user#vc_uuid
dat_arriveTime        date            ,            --time that work reach user's intray
dat_acceptTime        date            ,            --time that user starts to handle the case
dat_dispatchTime      date            ,            --time that user finishes the case 
vc_parent_workid      varchar2(50)    ,            --parent work uuid.refers to xpdl_p_work#vc_uuid [used only by subprocess work]    
vc_userobject         varchar2(50)    ,            --data associated with this work
int_priority          number(10)      ,            --work priority
int_weight_flag       number(10,2)    ,            --work is weightable? 
dbl_weight            number(10,2)    ,            --work weight
int_eventType         number(10)      not null,    --event type that generates the work
primary key(vc_uuid)
);

/*==============================================================*/
/* @table: rt_p_path (rt_p_003)                                 */
/*                                                              */
/* @desc:                                                       */
/*                                                              */
/* @created: 2004-4-4 16:02                                     */
/*                                                              */
/* @comment:                                                    */
/*                                                              */
/*==============================================================*/
create table rt_p_path
(
vc_packageid          varchar2(50)    not null,    --package uuid.refers to xpdl_p_package#vc_uuid
vc_processid          varchar2(50)    not null,    --process uuid.refers to xpdl_p_process#vc_uuid
vc_caseid             varchar2(50)    not null,    --case uuid.refers to rt_p_case#vc_uuid
vc_uuid               varchar2(50)    not null,    --path uuid
vc_from               varchar2(50)            ,    --from work id .refers to rt_p_work#vc_uuid
vc_to                 varchar2(50)            ,    --from work id .refers to rt_p_work#vc_uuid
vc_owner_processid    varchar2(50)            ,    --transition's owner process uuid.refers to xpdl_p_process#vc_uuid 
vc_transitionid       varchar2(50)            ,    --transition id which link vc_from with vc_to.refers to xpdl_p_transition#vc_uuid
vc_batchNo            varchar2(50)            ,    --path batch number (a work dispatch can create one or more paths)
int_eventType         number(10)      not null,    --event type that generates the path. 
primary key(vc_uuid)
);

/*==============================================================*/
/* @table: rt_p_datafield (rt_p_004)                            */
/*                                                              */
/* @desc:                                                       */
/*                                                              */
/* @created: 2004-4-4 16:02                                     */
/*                                                              */
/* @comment:                                                    */
/*                                                              */
/*==============================================================*/
create table rt_p_datafield
(
vc_packageid     varchar2(50)    not null, --package uuid.refers to xpdl_p_package#vc_uuid
vc_processid     varchar2(50)    not null, --process uuid.refers to xpdl_p_process#vc_uuid
vc_caseid        varchar2(50)    not null, --case uuid.refers to rt_p_case#vc_uuid
vc_uuid          varchar2(50)    not null, --datafield uuid.refers to xpdl_p_datafield#vc_uuid
vc_type          varchar2(50)    not null, --datafield type (basictype or javaclass name)
vc_value         varchar2(50)    ,         --datafield value
primary key(vc_packageid,vc_processid,vc_caseid,vc_uuid)
);


/*==============================================================*/
/* @table: rt_p_caseevent (rt_p_005)                            */
/*                                                              */
/* @desc:                                                       */
/*                                                              */
/* @created: 2004-4-4 17:40                                     */
/*                                                              */
/* @comment: EVENT TYPE                                         */
/*                                                              */
/*==============================================================*/
create table rt_p_caseevent
(
vc_packageid     varchar2(50)    not null, --package uuid.refers to xpdl_p_package#vc_uuid
vc_processid     varchar2(50)    not null, --process uuid.refers to xpdl_p_process#vc_uuid
vc_caseid        varchar2(50)    not null, --case uuid.refers to rt_p_case#vc_uuid
int_type         number(10)      not null, --case event type. 
vc_operator      varchar2(50)    not null, --who causes the event
dat_optime       date            not null, --when the event is raised
vc_description   varchar2(255)             --event description
);

/*==============================================================*/
/* @table: rt_p_workevent (rt_p_006)                            */
/*                                                              */
/* @desc:                                                       */
/*                                                              */
/* @created: 2004-4-5 9:07                                      */
/*                                                              */
/* @comment: EVENT TYPE                                         */
/*                                                              */
/*==============================================================*/
create table rt_p_workevent
(
vc_packageid     varchar2(50)    not null, --package uuid.refers to xpdl_p_package#vc_uuid
vc_processid     varchar2(50)    not null, --process uuid.refers to xpdl_p_process#vc_uuid
vc_caseid        varchar2(50)    not null, --case uuid.refers to rt_p_case#vc_uuid
vc_workid        varchar2(50)    not null, --work uuid.refers to rt_p_work#vc_uuid
int_type         number(10)      not null, --work event type. 
vc_operator      varchar2(50)    not null, --who causes the event
dat_optime       date            not null, --when the event is raised
vc_description   varchar2(255)             --event description
);

/*==============================================================*/
/* @table: rt_p_activity_dispatch (rt_p_007)                      */
/*--------------------------------------------------------------*/
/* only used internally                                         */
/*--------------------------------------------------------------*/
/*                                                              */
/* @desc:  WorkflowActivity submit batch history                */
/*         only used by Join WorkflowActivity                   */
/*         and it's former  WorkflowActivity                    */
/*                                                              */
/* @created: 2004-4-5 9:07                                      */
/*                                                              */
/*==============================================================*/
create table rt_p_activity_dispatch
(
vc_packageid           varchar2(50)    not null, --package uuid.refers to xpdl_p_package#vc_uuid
vc_processid           varchar2(50)    not null, --process uuid.refers to xpdl_p_process#vc_uuid
vc_caseid              varchar2(50)    not null, --case uuid.refers to rt_p_case#vc_uuid
vc_owner_processid     varchar2(50)    ,         --owner process uuid.refers to xpdl_p_process#vc_uuid 
vc_activityid          varchar2(50)    not null, --activity uuid.refers to xpdl_p_activity#vc_uuid
int_dispatch_count     number(10)      not null, --activity submit batch history
int_join_monitor       number(10)      null,     --counter how many former work complete?[VIP]
dbl_join_monitor       number(10,2)    null,     --weight counter how many former work complete?[VIP]
int_dispatch_eventType number(10)                --Token Type [VIP]  
);