/*
 * insert the type in object_data
 */
update object_data_seq set sequence = sequence + 1;
INSERT INTO `object_data` (`obj_id`, `type`, `title`, `description`, `owner`, `create_date`, `last_update`, `import_id`) VALUES 
  ((select sequence from object_data_seq), 'typ', 'cmes', 'CME settings', -1, NOW(), NOW(), NULL);
/*
 * create rbac entries for the fresh created id 
 */
insert into rbac_ta ( typ_id, ops_id ) values ( (select sequence from object_data_seq), 1);  
insert into rbac_ta ( typ_id, ops_id ) values ( (select sequence from object_data_seq), 2);  
insert into rbac_ta ( typ_id, ops_id ) values ( (select sequence from object_data_seq), 3);  
insert into rbac_ta ( typ_id, ops_id ) values ( (select sequence from object_data_seq), 4);

/*
 * insert the object id in object_data
 */
update object_data_seq set sequence = sequence + 1;
INSERT INTO `object_data` (`obj_id`, `type`, `title`, `description`, `owner`, `create_date`, `last_update`, `import_id`) VALUES 
  ((select sequence from object_data_seq), 'cmes', '__CMESettings', 'CME Settings', -1, NOW(), NOW(), NULL);

/*
 * create an ref_id to the object id from object_data in object_reference 
 */
update object_reference_seq set sequence = sequence + 1;
insert into object_reference (ref_id, obj_id) values ( (select sequence from object_reference_seq), (select sequence from object_data_seq) );

/*
 * create an entry in tree for the administration gui (which is parent = 9) !!!! This may be installation dependent
 * transcripted from the entry belonging to AccessibilitySettings
 */
insert into tree (tree, child, parent, lft, rgt, depth) values 
( 1, (select sequence from object_reference_seq), 9, 
(select max(t1.lft)+1 from tree t1 where t1.parent = 9),
(select max(t2.lft)+2 from tree t2 where t2.parent = 9), 3 );
