insert into ROLE values ('SuperUser', 'Super User');
insert into ROLE values ('CatalogUser', 'Catalog User');
insert into ROLE values ('StandardUser', 'Standard User');
insert into ROLE values ('AnonymousUser', 'Anon User');

insert into PARTY(ID,PARTY_TYPE,NAME,POSTCODE,ORG_TYPE,PRIMARY_ORG_ID) 
values ( 1, 2, 'Knowledge Integration Ltd', 'S1 2NS', 'Commercial',null);

insert into PARTY(ID,PARTY_TYPE,NAME,POSTCODE,ORG_TYPE,PRIMARY_ORG_ID,ACCOUNT_ACTIVE_FLAG) 
values ( 1001, 1, 'Superuser', null, null, 1, 1 );


insert into AUTH_DETAILS(USER_ID,SHARED_SEC_Q,SHARED_SEC_A,USERNAME,PASSWORD)
values (1001, null, null, 'admin', 't3r1g1');

insert into ROLE_GRANT_PARTY(ID,USERNAME,ROLE) values (1,   'admin',   'SuperUser');
insert into ROLE_GRANT_PARTY(ID,USERNAME,ROLE) values (2,   'admin',   'CatalogUser');

insert into AUTHORITY values ( 1, 'System', 'Internal Categories (Document Type, etc)' );
insert into AUTHORITY values ( 100, 'ITForMe-Category', 'IT 4 Me Category List');

-- Set up some internal categories.

insert into CATEGORY(AUTHORITY_ID,AUTHORITY_CODE,NAME,DESCRIPTION) VALUES ( 1, 'TOP-LEVEL-TERM', 'Top Level Term', 'Category is a browse entry point' );

-- Set up our default collections
insert into COLLECTION (ID,NAME) values ( 1, 'Default' );
insert into COLLECTION (ID,NAME) values ( 2, 'IT4Me' );

-- Set up default agent subscriptions.
-- insert into OAI_COLLECTION(ID,NAME,DESCRIPTION) VALUES ( 1, 'Default', 'The Default Collection');
-- insert into OAI_COLLECTION(ID,NAME,DESCRIPTION) VALUES ( 2, 'IT4Me', 'IT For Me Default Collection');

-- Set up an internal channel pointing at the IT4Me OAI collection
-- An "Internal" channel relates to a local OAI collection, and names the OAI Colleciton we are presenting
insert into CHANNEL ( ID, CHANNEL_TYPE, CHANNEL_NAME, CHANNEL_ID ) VALUES ( 1, 1, 'IT4Me', 'IT4Me');

-- Subscribe the IT4Me System agent to the new internal channel.
insert into AGENT ( ID, AGENT_NAME, DATE_LAST_RUN ) VALUES ( 1, "IT For Me Default Agent", NULL );
insert into SUBSCRIPTION ( ID,CHANNEL_ID,RESUMPTION_TOKEN ) VALUES ( 1, 1, NULL );
insert into AGENT_SUBSCRIPTION_LINK(AGENT_ID,SUBSCIPTION_ID,AGENT_INDEX) VALUES ( 1, 1, 0);

insert into PROPERTY_SET_HEADER(ID,PROPSET_NAME) VALUES (1,'Core System Properties');
insert into PROPERTY_SET(PROP_SET_ID,PROP_NAME,PROP_VALUE) VALUES (1,'ia.core.EditorReview','true');

insert into PROPERTY_SET_HEADER(ID,PROPSET_NAME) VALUES (2,'Default Webapp Properties');
insert into PROPERTY_SET(PROP_SET_ID,PROP_NAME,PROP_VALUE) VALUES (2,'ia.web.DefaultSkinCSS','');
insert into PROPERTY_SET(PROP_SET_ID,PROP_NAME,PROP_VALUE) VALUES (2,'ia.web.home_tile','ia.it4me_welcome');

insert into KIIA_STATUS_CODE(CODE,DESCRIPTION) values ( 'TASM-PENDING', 'Term Is Pending Approval');
insert into KIIA_STATUS_CODE(CODE,DESCRIPTION) values ( 'TASM-APPROVED', 'Term Is Approved');
insert into KIIA_STATUS_CODE(CODE,DESCRIPTION) values ( 'TASM-REJECTED', 'Term Is Rejected');

insert into KIIA_STATUS_CODE(CODE,DESCRIPTION) values ( 'RASM-PENDING', 'Resource Is Pending Approval');
insert into KIIA_STATUS_CODE(CODE,DESCRIPTION) values ( 'RASM-APPROVED', 'Resource Is Approved');
insert into KIIA_STATUS_CODE(CODE,DESCRIPTION) values ( 'RASM-REJECTED', 'Resource Is Rejected');

insert into KIIA_STATE_MODEL(NAME,CODE) values ('Resource Approval State Model','RASM');
insert into KIIA_STATE_MODEL(NAME,CODE) values ('Term Approval State Model','TASM');

insert into KIIA_STATE_TRANSITION(DESCRIPTION,FROM_STATE,TO_STATE,MODEL) values ('Approve Term','TASM-PENDING', 'TASM-APPROVED', 'TASM');
insert into KIIA_STATE_TRANSITION(DESCRIPTION,FROM_STATE,TO_STATE,MODEL) values ('Reject Term','TASM-PENDING', 'TASM-REJECTED', 'TASM');
insert into KIIA_STATE_TRANSITION(DESCRIPTION,FROM_STATE,TO_STATE,MODEL) values ('Approve Resource','RASM-PENDING', 'RASM-APPROVED', 'RASM');
insert into KIIA_STATE_TRANSITION(DESCRIPTION,FROM_STATE,TO_STATE,MODEL) values ('Reject Resource','RASM-PENDING', 'RASM-REJECTED', 'RASM');

create index PAF_KEY_IDX_2 on KIIE_PLACE(PAF_KEY,PLACE_TYPE);

create FULLTEXT index RES_TITLE_DESC_FLAG_INDEX on RESOURCE(TITLE,DESCRIPTION,STRING_FLAGS);
create FULLTEXT index RES_TITLE_DESC_INDEX on RESOURCE(TITLE,DESCRIPTION);
create FULLTEXT index RES_TITLE_INDEX on RESOURCE(TITLE);
create FULLTEXT index RES_DESC_INDEX on RESOURCE(DESCRIPTION);

insert into KICE_UI_DEVICE(ID,DEVICE_NAME) VALUES ( 1,'HTTP-BROWSER' );

insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (1,'com.k_int.codbif.core.ui.search.config.QueryModelHDO','Query Model');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (2,'com.k_int.ia.harvest.web.WebSynchronizationTaskHDO','Web Sync Task');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (3,'com.k_int.ia.oai_harvest.data.OAISynchronizationTaskHDO','OAI Sync Task');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (4,'com.k_int.ia.resources.GenericResourceHDO','Generic Resource');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (5,'com.k_int.ia.resources.CollectionHDO','Collection');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (6,'com.k_int.ia.semantics.AuthorityHDO','Authority');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (7,'com.k_int.ia.identity.RegisteredUserHDO','User');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (8,'org.jzkit.ServiceDirectory.CollectionDescriptionDBO','Z3950 Description');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (9,'org.jzkit.search.provider.iface.SearchServiceDescriptionDBO','Z3950 Repository');
insert into KICE_REGISTERED_MODEL ( ID, MODEL_CLASS_NAME, DESCRIPTION ) VALUES (10,'org.jzkit.ServiceDirectory.CollectionInfoTypeDBO','Info Type');

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(1,1,'EDIT_QUERY_MODEL','Query Model', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(1, 'Edit Query Model', '/WEB-INF/jsp/tiles/entity_templates2/querymodel/edit_querymodel.jsp', 0);

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(2,2,'EDIT_WEB_SYNC_TASK','Web Sync Task', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(2, 'Edit Web Sync Task', '/WEB-INF/jsp/tiles/entity_templates2/sync/web_sync_task.jsp', 0);

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(3,2,'EDIT_OAI_SYNC_TASK','OAI Sync Task', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(3, 'Edit OAI Sync Task', '/WEB-INF/jsp/tiles/entity_templates2/sync/oai_sync_task.jsp', 0);

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(4,1,'GenericResource.edit','Generic Resource', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(4, 'Resource', '/WEB-INF/jsp/tiles/entity_templates/generic_resource/resource_edit.jsp', 0);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(4, 'Availability', '/WEB-INF/jsp/tiles/entity_templates/generic_resource/availability.jsp', 1);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(4, 'Categories', '/WEB-INF/jsp/tiles/entity_templates/category_posting.jsp', 2);
insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(5,1,'Collection.edit','Collection', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(5, 'Edit Collection', '/WEB-INF/jsp/tiles/admin/manage_collections/edit_collection_panel.jsp', 0);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(5, 'Statistics', '/WEB-INF/jsp/tiles/admin/manage_collections/collection_stats_panel.jsp', 1);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(5, 'Postings', '/WEB-INF/jsp/tiles/admin/manage_collections/collection_postings_panel.jsp', 2);
insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(6,1,'Collection.new','Collection', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(6, 'New Collection', '/WEB-INF/jsp/tiles/admin/manage_collections/new_collection_panel.jsp', 0);
insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(7,1,'SyncTask.edit','SyncTask', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(7, 'Edit OAI Feed', '/WEB-INF/jsp/tiles/admin/manage_oai_feeds/edit_synctask_panel.jsp', 0);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(7, 'Diagnostics', '/WEB-INF/jsp/tiles/admin/manage_oai_feeds/synctask_diagnostics_panel.jsp', 1);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(7, 'Control', '/WEB-INF/jsp/tiles/admin/manage_oai_feeds/synctask_control_panel.jsp', 2);
insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(8,1,'SyncTask.new','SyncTask', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(8, 'New OAI Feed', '/WEB-INF/jsp/tiles/admin/manage_oai_feeds/new_synctask_with_dropdown.jsp', 0);
insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(9,1,'Authority.new','Authority', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(9, 'New Classification Scheme', '/WEB-INF/jsp/tiles/admin/manage_cats/new_authority_panel.jsp', 0);
insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(10,1,'Authority.edit','Authority', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(10, 'Edit Classification Scheme', '/WEB-INF/jsp/tiles/admin/manage_cats/new_authority_panel.jsp', 0);
insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(11,1,'User.edit','User', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(11, 'Edit User', '/WEB-INF/jsp/tiles/admin/manage_users/edit_user_panel.jsp', 0);

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(12,1,'Z3950.edit','Z3950', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(12, 'Edit Z3950 Collection', '/WEB-INF/jsp/tiles/admin/manage_search/z3950/edit_target_desc.jsp', 0);

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(13,1,'ADD_INST','Instance', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(13, 'Add Instance', '/WEB-INF/jsp/tiles/admin/manage_search/z3950/add_instance.jsp', 0);

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(14,1,'Z3950_rep.edit','Z3950 repository', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(14, 'Edit Z3950 Repository', '/WEB-INF/jsp/tiles/admin/manage_search/z3950/edit_repository.jsp', 0);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(14, 'Edit Properties', '/WEB-INF/jsp/tiles/admin/manage_search/z3950/edit_properties.jsp', 1);

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(15,1,'ADD_POST','Posting', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(15, 'Add Posting', '/WEB-INF/jsp/tiles/admin/manage_search/z3950/add_posting.jsp', 0);

insert into KICE_LAYOUT(ID,LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION,LAYOUT_LABEL) values(16,1,'INFO_TYPE','InfoType', null);
insert into KICE_WEB_LAYOUT_TABS(LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values(16, 'New Collection Type', '/WEB-INF/jsp/tiles/admin/manage_search/z3950/info_type.jsp', 0);

insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (1,1,1,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (2,2,2,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (3,3,7,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (4,4,4,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (5,5,5,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (6,5,6,'NEW_COLLECTION',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (7,6,10,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (8,7,11,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (9,8,12,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (10,9,14,'DEFAULT',1);
insert into KICE_UI_MODEL_LAYOUT(ID,MODEL,LAYOUT,CONTEXT,DEVICE) VALUES (11,10,16,'DEFAULT',1);

