---  ~ Licensed to the Apache Software Foundation (ASF) under one
---  ~ or more contributor license agreements.  See the NOTICE file
---  ~ distributed with this work for additional information
---  ~ regarding copyright ownership.  The ASF licenses this file
---  ~ to you 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.

--- start security roles data ---
insert into security_role(name, description, enabled)
values ('UNOFFICIAL_GADGET_DEVELOPER', 'A user who can develop gadgets and upload them to the repository as unofficial gadgets.', 'Y');
insert into security_role(name, description, enabled)
values ('OFFICIAL_GADGET_DEVELOPER', 'A user who can develop gadgets and upload them to the repository as official gadgets.', 'Y');
insert into security_role(name, description, enabled)
values ('ORG_PAGE_TEMPLATE_DEVELOPER', 'A user who can create page templates under the Dept, Center, or Division types and publish them for others to use.', 'Y');
insert into security_role(name, description, enabled)
values ('APPLICATION_ADMIN', 'General application admin tasks like setting up user security.', 'Y');
insert into security_role(name, description, enabled)
values ('REPOSITORY_ADMIN', 'Can perform gadget repository admin tasks like removing gadgets completely from the application.', 'Y');
--- end security roles data ---

--- start person data ---
insert into person (id, username, last_name, first_name, primary_email) values ('canonical', 'canonical', 'Digg', 'Shin', 'dev@shindig.apache.org');
insert into person (id, username, last_name, first_name, primary_email) values ('john.doe', 'john.doe', 'Doe', 'John', 'john.doe@example.com');
insert into person (id, username, last_name, first_name, primary_email) values ('jane.doe', 'jane.doe', 'Doe', 'Jane', 'jane.doe@example.com');
insert into person (id, username, last_name, first_name, primary_email) values ('george.doe', 'george.doe', 'Doe', 'George', 'george.doe@example.com');
insert into person (id, username, last_name, first_name, primary_email) values ('mario.rossi', 'mario.rossi', 'Rossi', 'Mario', 'mario.rossi@example.com');
insert into person (id, username, last_name, first_name, primary_email) values ('maija.m', 'maija.m', 'Meikäläinen', 'Maija', 'maija.m@example.com');
--- end person data ---

--- start security user roles data ---
insert into security_user_role(id, user_id, security_role_name)
select NEXT VALUE FOR security_user_role_id_seq, 'john.doe', name
from security_role;
insert into security_user_role(id, user_id, security_role_name)
select NEXT VALUE FOR security_user_role_id_seq, 'jane.doe', name
from security_role;
--- end security user roles data ----

--- start container data ---
insert into container (container_id, name)
values (set(@container_id, next value for container_id_seq), 'default');
--- end container data ---

--- start wizard records ---
insert into wizard(wizard_id, name, display_name, user_target, url)
values(next value for wizard_id_seq, 'new_user', 'Introduction', 'all', '/portal/static-content/container/content/wizard/new_user.html');
--- end wizard records ---

--- start gadget author type data ---
insert into gadget_author_type(gadget_author_type_id, code, description)
values (next value for gadget_author_type_id_seq, 'CIT', 'CI&T');

insert into gadget_author_type(gadget_author_type_id, code, description)
values (set(@external_author_type_id, next value for gadget_author_type_id_seq), 'EXT', 'External');

insert into gadget_author_type(gadget_author_type_id, code, description)
values (next value for gadget_author_type_id_seq, 'EMP', 'Employee');

insert into gadget_author_type(gadget_author_type_id, code, description)
values (next value for gadget_author_type_id_seq, 'GRP', 'Center/Group');
--- end gadget creator type data ---

--- start gadget support link type data ---
insert into gadget_support_link_type(gadget_support_link_type_id, code, description)
values (set(@hd_support_type_id, next value for gadget_spprt_link_type_id_seq), 'HD', 'Help Desk');

insert into gadget_support_link_type(gadget_support_link_type_id, code, description)
values (next value for gadget_spprt_link_type_id_seq, 'EMAIL', 'Email');

insert into gadget_support_link_type(gadget_support_link_type_id, code, description)
values (next value for gadget_spprt_link_type_id_seq, 'URL', 'Url');

insert into gadget_support_link_type(gadget_support_link_type_id, code, description)
values (set(@none_support_type_id, next value for gadget_spprt_link_type_id_seq), 'NONE', 'None');
--- end gadget support link type data ---

--- start gadget audience data ---
insert into gadget_audience(gadget_audience_id, code, description)
values (set(@all_audience_id, next value for gadget_audience_id_seq), 'ALL', 'Everyone');

insert into gadget_audience(gadget_audience_id, code, description)
values (next value for gadget_audience_id_seq, 'MGR', 'Managers');

insert into gadget_audience(gadget_audience_id, code, description)
values (next value for gadget_audience_id_seq, 'DEV', 'Developers');
--- end gadget audience data ---

--- gadget data ---
-- wikipedia gadget
insert into gadget (gadget_id, title, description, author, url, thumbnail_url, screenshot_url, use_custom_edit_ui, gadget_author_type_id, version, featured, created_date, created_by, modified_date, modified_by, gadget_support_link_type_id, scrolling, hidden, send_comment_emails, height)
values(set(@wikipedia_gadget_id, next value for gadget_id_seq), 'Wikipedia', 'A Wikipedia search gadget', 'James Lee', 'http://www.google.com/ig/modules/wikipedia.xml', 'http://www.google.com/ig/modules/wikipedia_content/wpicon.png', 'http://www.google.com/ig/modules/wikipedia_content/wpscreenshot.png','N', @external_author_type_id,'1.0','N',sysdate, 'john.doe', sysdate, 'john.doe', @none_support_type_id, 'N', 'N', 'Y', 46);

insert into gadget_audience_map (gadget_id, gadget_audience_id)
values (@wikipedia_gadget_id, @all_audience_id);

insert into gadget_tag (gadget_tag_id, gadget_id, tag_name)
values (next value for gadget_tag_id_seq, @wikipedia_gadget_id, 'search');

-- translate gadget
insert into gadget (gadget_id, title, description, author, url, thumbnail_url, screenshot_url, use_custom_edit_ui, gadget_author_type_id, version, featured, created_date, created_by, modified_date, modified_by, gadget_support_link_type_id, scrolling, hidden, send_comment_emails)
values(set(@translate_gadget_id, next value for gadget_id_seq), 'Translate Gadget', 'A translation gadget', 'Google Taiwan', 'http://www.google.com/ig/modules/dictionary.xml', '', '','N', @external_author_type_id,'1.0','N',sysdate, 'john.doe', sysdate, 'john.doe', @none_support_type_id, 'N', 'N', 'Y');

insert into gadget_audience_map (gadget_id, gadget_audience_id)
values (@translate_gadget_id, @all_audience_id);

insert into gadget_tag (gadget_tag_id, gadget_id, tag_name)
values (next value for gadget_tag_id_seq, @translate_gadget_id, 'language');

-- nytimes gadget
insert into gadget (gadget_id, title, description, author, url, thumbnail_url, screenshot_url, use_custom_edit_ui, gadget_author_type_id, version, featured, created_date, created_by, modified_date, modified_by, gadget_support_link_type_id, scrolling, hidden, send_comment_emails)
values(set(@nyt_gadget_id, next value for gadget_id_seq), 'NYTimes.com - Top Stories', 'All the news you need to know online from the most authoritative source of news in the world', 'The New York Times', 'http://widgets.nytimes.com/packages/html/igoogle/topstories.xml', 'http://www.nytimes.com/packages/html/igoogle/thumb.png', 'http://www.nytimes.com/packages/html/igoogle/screenshot.png','N', @external_author_type_id,'1.0','N',sysdate, 'john.doe', sysdate, 'john.doe', @none_support_type_id, 'N', 'N', 'Y');

insert into gadget_audience_map (gadget_id, gadget_audience_id)
values (@nyt_gadget_id, @all_audience_id);

insert into gadget_tag (gadget_tag_id, gadget_id, tag_name)
values (next value for gadget_tag_id_seq, @nyt_gadget_id, 'news');

-- google tabbed news gadget
insert into gadget (gadget_id, title, description, author, url, thumbnail_url, screenshot_url, use_custom_edit_ui, gadget_author_type_id, version, featured, created_date, created_by, modified_date, modified_by, gadget_support_link_type_id, scrolling, hidden, send_comment_emails)
values(set(@tabnews_gadget_id, next value for gadget_id_seq), 'Google News Gadget', 'A tabbed news gadget', 'Google Taiwan', 'http://www.gstatic.com/ig/modules/tabnews/tabnews.xml', '', '','N', @external_author_type_id,'1.0','Y',sysdate, 'john.doe', sysdate, 'john.doe', @none_support_type_id, 'N', 'N', 'Y');

insert into gadget_audience_map (gadget_id, gadget_audience_id)
values (@tabnews_gadget_id, @all_audience_id);

insert into gadget_tag (gadget_tag_id, gadget_id, tag_name)
values (next value for gadget_tag_id_seq, @tabnews_gadget_id, 'news');


-- container registry (load all gadgets)
insert into container_registry (container_registry_id, container_id, gadget_id)
select next value for container_registry_id_seq, @container_id, gadget_id
from gadget;

-- end gadget data ----


--- start page layout data ---
insert into page_layout (page_layout_id, layout_name, display_name, render_seq, num_regions, user_selectable)
values (next value for page_layout_id_seq, 'columns_1', 'One Column', 1, 1, 'Y');
insert into page_layout (page_layout_id, layout_name, display_name, render_seq, num_regions, user_selectable)
values (set(@two_col_page_layout_id, next value for page_layout_id_seq), 'columns_2', 'Two Columns', 2, 2, 'Y');
insert into page_layout (page_layout_id, layout_name, display_name, render_seq, num_regions, user_selectable)
values (next value for page_layout_id_seq, 'columns_2wn', 'Two Columns - WN', 3, 2, 'Y');
insert into page_layout (page_layout_id, layout_name, display_name, render_seq, num_regions, user_selectable)
values (next value for page_layout_id_seq, 'columns_3', 'Three Columns', 4, 3, 'Y');
insert into page_layout (page_layout_id, layout_name, display_name, render_seq, num_regions, user_selectable)
values (next value for page_layout_id_seq, 'columns_3nwn', 'Three Columns - NWN', 5, 3, 'Y');
insert into page_layout (page_layout_id, layout_name, display_name, render_seq, num_regions, user_selectable)
values (next value for page_layout_id_seq, 'columns_4', 'Four Columns', 6, 4, 'Y');
--- end page layout data ----

--- start page template owner types ---
insert into page_template_owner_type (name, code)
values ('Organization','ORG');
insert into page_template_owner_type (name, code)
values ('Employee', 'EMP');
--- end page template owner types ---

--- start page templates and page template gadgets ---

--- blank page template ---
insert into page_template (page_template_id, container_id, name, page_layout_id, default_template, fixed_layout, description,
            owner_type_code, owner_type_value, owner_type_url, owner_type_logo, render_seq, fixed_name)
values (next value for page_template_id_seq, @container_id, 'Empty',  null, 'N','N', 'A blank page with no gadgets. Choose the layout you want and start adding gadgets from the repository.',
        'ORG', 'IT','', '', 1, 'N');

--- home template (default) ----
insert into page_template (page_template_id, container_id, name,  page_layout_id, default_template, fixed_layout, description,
                           owner_type_code, owner_type_value, owner_type_url, owner_type_logo, render_seq, fixed_name)
values (set(@home_page_template_id, next value for page_template_id_seq), @container_id,  'Home',  @two_col_page_layout_id, 'Y','N', 'The default home page.', 'ORG', 'IT','','', 2, 'N');

insert into page_template_region (page_template_region_id, page_template_id, region_name)
values (set(@home_page_template_region1_id, next value for page_template_region_id_seq), @home_page_template_id, 'region_1');

insert into page_template_region (page_template_region_id, page_template_id, region_name)
values (set(@home_page_template_region2_id, next value for page_template_region_id_seq), @home_page_template_id, 'region_2');

-- region 1 gadgets
insert into page_template_gadget(page_template_gadget_id, page_template_region_id, gadget_id, render_seq)
values (next value for page_template_gadget_id_seq, @home_page_template_region1_id, @wikipedia_gadget_id, 1);

-- region 2 gadgets
insert into page_template_gadget(page_template_gadget_id, page_template_region_id, gadget_id, render_seq)
values (next value for page_template_gadget_id_seq, @home_page_template_region2_id, @tabnews_gadget_id, 1);
-- end home template

-- end page templates ---