USE SALCAL;

/* default users */
INSERT INTO CAL_USER (USERNAME, PASSWORD) VALUES 
  ("Admin","admin_pass");

INSERT INTO CAL_PERSON(FIRST_NAME, LAST_NAME, TITLE, USER_NAME, LOCATION_FK, CONTACT_DETAILS_FK) VALUES
  ("System", "Administrator", null, "Admin", null, 1);

INSERT INTO CAL_CONTACT_DETAILS(PUBPHONE, PRIPHONE, FAX, EMAIL, ADDRESS_FK) VALUES
  (NULL, NULL, NULL, "example@fake-email.com", 1);

INSERT INTO CAL_ADDRESS(ID, HOUSE, STREET, AREA, TOWN, COUNTY, POSTCODE) VALUES 
  (1, " ", " ", " ", " ", " ", " ");

INSERT INTO CAL_ROLE (USERNAME, ROLE) VALUES
  ("Admin","CalAdmin");

/*
INSERT INTO CAL_ROLE (USERNAME, ROLE) VALUES 
  ("Admin","CalWorker"), 
  ("Admin","CalReferrer"),
  ("Admin","CalCentre"), 
  ("Admin","CalAdmin");
*/

/* codbif entries */
INSERT INTO KICE_UI_DEVICE (DEVICE_NAME) values ("HTTP-BROWSER");
INSERT INTO KICE_REGISTERED_MODEL (ID, MODEL_CLASS_NAME,DESCRIPTION) values 
  (1, "com.k_int.salcal.hdo.LocationHDO",    "Advice Centre"),
  (2, "com.k_int.salcal.hdo.SubjectAreaHDO", "Subject Area"),
  (3, "com.k_int.salcal.hdo.PersonHDO",      "Person"),
  (4, "com.k_int.salcal.hdo.LanguageHDO",    "Language");

INSERT INTO KICE_LAYOUT (ID, LAYOUT_TYPE,LAYOUT_CODE,DESCRIPTION) values 
  (1, 1, "Centre.new",     "Advice Centre"), 
  (2, 1, "Centre.edit",    "Advice Centre"),
  (3, 1, "Subject.edit",   "Subject Area"),
  (4, 1, "Person.edit",    "Person"),
  (5, 1, "Language.edit",  "Language"),
  (6, 1, "Centre.users",   "Person"),
  (7, 1, "Referrer.users", "Person"),
  (8, 1, "Worker.users",   "Person"),
  (9, 1, "Admin.centre",   "Advice Centre");


INSERT INTO KICE_UI_MODEL_LAYOUT (ID, MODEL,LAYOUT,CONTEXT,DEVICE) values 
  (1, 1, 1,"NEW",     1),
  (2, 1, 2,"DEFAULT", 1),
  (3, 2, 3,"DEFAULT", 1),
  (4, 3, 4,"DEFAULT", 1),
  (5, 4, 5,"DEFAULT", 1);


INSERT INTO KICE_WEB_LAYOUT_TABS (LAYOUT_ID,TAB_LABEL,TILE_PATH,IND) values 
  (1,  "Name",            "/WEB-INF/jsp/entity_templates/advice_centre/name.jsp",       0),
  (2,  "Name",            "/WEB-INF/jsp/entity_templates/advice_centre/name.jsp",       0),
  (2,  "Address",         "/WEB-INF/jsp/entity_templates/advice_centre/address.jsp",    1),
  (3,  "Subject Area",    "/WEB-INF/jsp/entity_templates/subject_area/subject.jsp",     0),
  (2,  "Extra Info",      "/WEB-INF/jsp/entity_templates/advice_centre/extra_info.jsp", 2),
  (4,  "Person Info",     "/WEB-INF/jsp/entity_templates/user/user.jsp",                0),
  (4,  "Contact Details", "/WEB-INF/jsp/entity_templates/user/contact.jsp",             1),
  (5,  "Language",        "/WEB-INF/jsp/entity_templates/language/name.jsp",            0),
  (6,  "Person",          "/WEB-INF/jsp/entity_templates/user/ctr_name.jsp",            0),
  (6,  "Person Address",  "/WEB-INF/jsp/entity_templates/user/ctr_contact.jsp",         1),
  (7,  "Person",          "/WEB-INF/jsp/entity_templates/user/ref_name.jsp",            0),
  (7,  "Person Address",  "/WEB-INF/jsp/entity_templates/user/ref_contact.jsp",         1),
  (8,  "Person",          "/WEB-INF/jsp/entity_templates/user/worker_name.jsp",         0),
  (8,  "Person Address",  "/WEB-INF/jsp/entity_templates/user/worker_contact.jsp",      1),
  (9,  "Name",            "/WEB-INF/jsp/entity_templates/advice_centre/admin_name.jsp",       0),
  (9,  "Address",         "/WEB-INF/jsp/entity_templates/advice_centre/admin_address.jsp",    1),
  (9,  "Extra Info",      "/WEB-INF/jsp/entity_templates/advice_centre/admin_extra_info.jsp", 2);



  
INSERT INTO KICE_QUERY_MODEL (CODE,DESCRIPTION,DESCRIPTOR) VALUES 
('ADM.Centre', 'Advice Centres', '
<QueryDescriptor name="Centre Search" defaultElementSetName="Default" baseClassName="com.k_int.salcal.hdo.LocationHDO">
  <RootScope className="com.k_int.salcal.hdo.LocationHDO" scopeName="centre" />
  <Bool id="Bool1" op="0">
    <Expression id="attrname.title" name="loc.title" scope="centre" accessPath="name" typeCode="VARCHAR" editingInfo="text" />
  </Bool>
  <ElementSet name="Default">
    <ScopeElement scope="centre" name="colhead.resource.id" visibility="false" />
    <ScopedElement scope="centre" name="colhead.resource.name" accessPath="name" visibility="true" actionCode="EDIT:0:Admin.centre"/>
  </ElementSet>
  <ElementSet name="Count">
    <CountElement scope="centre" name="id" accessPath="id">id</CountElement>
  </ElementSet>
  <RowActions>
    <EditRowAction/>
    <DeleteRowAction/>
  </RowActions>
</QueryDescriptor>'),

('ADM.Subject', 'Subject Areas', '
<QueryDescriptor name="Subject Area Search" defaultElementSetName="Default" baseClassName="com.k_int.salcal.hdo.SubjectAreaHDO">
  <RootScope className="com.k_int.salcal.hdo.SubjectAreaHDO" scopeName="subject" />
  <Bool id="Bool1" op="0">
    <Expression id="attrname.title" name="subj.title" scope="subject" accessPath="name" typeCode="VARCHAR" editingInfo="text" />
  </Bool>
  <ElementSet name="Default">
    <ScopeElement scope="subject" name="colhead.resource.id" visibility="false" />
    <ScopedElement scope="subject" name="colhead.resource.name" accessPath="name" visibility="true" actionCode="EDIT:0"/>
  </ElementSet>
  <ElementSet name="Count">
    <CountElement scope="subject" name="id" accessPath="id">id</CountElement>
  </ElementSet>
  <RowActions>
    <EditRowAction/>
    <DeleteRowAction/>
  </RowActions>
</QueryDescriptor>'),

('CTR.User', 'System Users', '
<QueryDescriptor name="System User Search" defaultElementSetName="Default" baseClassName="com.k_int.salcal.hdo.PersonHDO">
  <RootScope className="com.k_int.salcal.hdo.PersonHDO" scopeName="person" />
  <Bool id="Bool1" op="0">
    <Expression id="attrname.title" name="user.title" scope="person" accessPath="userName" typeCode="VARCHAR" editingInfo="text" />
    <Expression id="attrname.locid" name="user.locid" scope="person" accessPath="location.id" typeCode="LONG" />
  </Bool>
  <ElementSet name="Default">
    <ScopeElement scope="person" name="colhead.resource.id" visibility="false" />
    <ScopedElement scope="person" name="colhead.resource.name" accessPath="userName" visibility="true" actionCode="EDIT:0:Centre.users"/>
  </ElementSet>
  <ElementSet name="Count">
    <CountElement scope="person" name="id" accessPath="id">id</CountElement>
  </ElementSet>
  <RowActions>
    <EditRowAction/>
    <DeleteRowAction/>
  </RowActions>
</QueryDescriptor>'),


('ADM.User', 'System Users', '
<QueryDescriptor name="System User Search" defaultElementSetName="Default" baseClassName="com.k_int.salcal.hdo.PersonHDO">
  <RootScope className="com.k_int.salcal.hdo.PersonHDO" scopeName="person" />
  <Bool id="Bool1" op="0">
    <Expression id="attrname.title" name="user.title" scope="person" accessPath="userName" typeCode="VARCHAR" editingInfo="text" />
    <Expression id="attrname.locid" name="user.locid" scope="person" accessPath="location.id" typeCode="LONG" />
  </Bool>
  <ElementSet name="Default">
    <ScopeElement scope="person" name="colhead.resource.id" visibility="false" />
    <ScopedElement scope="person" name="colhead.resource.name" accessPath="userName" visibility="true" actionCode="EDIT:0"/>
  </ElementSet>
  <ElementSet name="Count">
    <CountElement scope="person" name="id" accessPath="id">id</CountElement>
  </ElementSet>
  <RowActions>
    <EditRowAction/>
    <DeleteRowAction/>
  </RowActions>
</QueryDescriptor>'),

('ADM.Language', 'Languages', '
<QueryDescriptor name="Language" defaultElementSetName="Default" baseClassName="com.k_int.salcal.hdo.LanguageHDO">
  <RootScope className="com.k_int.salcal.hdo.LanguageHDO" scopeName="language" />
  <Bool id="Bool1" op="0">
    <Expression id="attrname.title" name="lang.title" scope="language" accessPath="name" typeCode="VARCHAR" editingInfo="text" />
  </Bool>
  <ElementSet name="Default">
    <ScopeElement scope="language" name="colhead.resource.id" visibility="false" />
    <ScopedElement scope="language" name="colhead.resource.name" accessPath="name" visibility="true" actionCode="EDIT:0"/>
  </ElementSet>
  <ElementSet name="Count">
    <CountElement scope="language" name="id" accessPath="id">id</CountElement>
  </ElementSet>
  <RowActions>
    <EditRowAction/>
    <DeleteRowAction/>
  </RowActions>
</QueryDescriptor>');
