<commit_before><databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">

	<changeSet author="KFS50" id="UPGRADE_KIM_DATA_RICE_20_mysql" dbms="mysql">
		<stop />
	</changeSet>

	<changeSet author="KFS50" id="UPGRADE_KIM_DATA_RICE_20_oracle" dbms="oracle">
		<comment>Upgrade the permission and responsibility names from previous releases of KFS to have unique names as required by Rice 2.0.</comment>
		<sql splitStatements="false" stripComments="false">
			-- fix permissions
			declare
               v_perm_nm VARCHAR2(4000);
			begin
			    dbms_output.enable(50000);
			               for perm_dtl in (select krim_perm_t.perm_id, NVL( krim_perm_t.nm, krim_perm_tmpl_t.nm ) as perm_nm, krim_perm_tmpl_t.kim_typ_id, krim_perm_tmpl_t.nm as tmpl_nm from krim_perm_t join krim_perm_tmpl_t on krim_perm_t.perm_tmpl_id = krim_perm_tmpl_t.perm_tmpl_id where krim_perm_t.nmspc_cd like 'KFS%')
			               loop
			                              v_perm_nm := perm_dtl.perm_nm;
			        if (perm_dtl.kim_typ_id <> 1) then
			                                             if (perm_dtl.tmpl_nm = 'Use Transactional Document') then
			                                                            for perm_attr_val in (select krim_perm_attr_data_t.attr_val from krim_perm_attr_data_t join krim_typ_attr_t on krim_perm_attr_data_t.kim_attr_defn_id = krim_typ_attr_t.kim_attr_defn_id where krim_typ_attr_t.kim_typ_id = perm_dtl.kim_typ_id and krim_perm_attr_data_t.perm_id = perm_dtl.perm_id order by krim_typ_attr_t.sort_cd desc)
			                                                            loop
			                                                                           v_perm_nm := v_perm_nm || ' ' || perm_attr_val.attr_val;
			                                                            end loop;
			                                             else
			                                                            for perm_attr_val in (select krim_perm_attr_data_t.attr_val from krim_perm_attr_data_t join krim_typ_attr_t on krim_perm_attr_data_t.kim_attr_defn_id = krim_typ_attr_t.kim_attr_defn_id where krim_typ_attr_t.kim_typ_id = perm_dtl.kim_typ_id and krim_perm_attr_data_t.perm_id = perm_dtl.perm_id order by krim_typ_attr_t.sort_cd)
			                                                            loop
			                                                                           v_perm_nm := v_perm_nm || ' ' || perm_attr_val.attr_val;
			                                                            end loop;
			                                             end if;
			            if (length(v_perm_nm) > 100) then
			                                             v_perm_nm := substr(v_perm_nm, 1, 96) || '...';<commit_msg>Added non-functional MySQL version of the KIM upgrade script.<commit_after><databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">

	<changeSet author="KFS50" id="UPGRADE_KIM_DATA_RICE_20_mysql" dbms="mysql">
		<sql>DROP PROCEDURE IF EXISTS kim_upgrade</sql>
		<sql splitStatements="false" stripComments="false">
CREATE PROCEDURE kim_upgrade()
BEGIN
    DECLARE new_perm_nm VARCHAR(4000);
    DECLARE done BOOLEAN;
    DECLARE v_perm_id, v_perm_nm, v_kim_typ_id, v_tmpl_nm VARCHAR(100);
    DECLARE cur_perm CURSOR FOR 
        select KRIM_PERM_T.perm_id, 
                IFNULL( KRIM_PERM_T.nm, KRIM_PERM_TMPL_T.nm ) as perm_nm, 
                KRIM_PERM_TMPL_T.kim_typ_id, 
                KRIM_PERM_TMPL_T.nm as tmpl_nm 
            from KRIM_PERM_T 
                join KRIM_PERM_TMPL_T on KRIM_PERM_T.perm_tmpl_id = KRIM_PERM_TMPL_T.perm_tmpl_id 
            where KRIM_PERM_T.nmspc_cd like 'KFS%';
    DECLARE cur_attrib_desc CURSOR FOR
        SELECT KRIM_PERM_ATTR_DATA_T.attr_val 
            FROM KRIM_PERM_ATTR_DATA_T 
                join KRIM_TYP_ATTR_T on KRIM_PERM_ATTR_DATA_T.kim_attr_defn_id = KRIM_TYP_ATTR_T.kim_attr_defn_id 
                where KRIM_TYP_ATTR_T.kim_typ_id = v_kim_typ_id 
                  and KRIM_PERM_ATTR_DATA_T.perm_id = v_perm_id 
             order by KRIM_TYP_ATTR_T.sort_cd desc;
    DECLARE cur_attrib_asc CURSOR FOR
        SELECT KRIM_PERM_ATTR_DATA_T.attr_val 
            FROM KRIM_PERM_ATTR_DATA_T 
                join KRIM_TYP_ATTR_T on KRIM_PERM_ATTR_DATA_T.kim_attr_defn_id = KRIM_TYP_ATTR_T.kim_attr_defn_id 
                where KRIM_TYP_ATTR_T.kim_typ_id = v_kim_typ_id 
                  and KRIM_PERM_ATTR_DATA_T.perm_id = v_perm_id 
             order by KRIM_TYP_ATTR_T.sort_cd;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; 
    OPEN cur_perm;
    FETCH cur_perm INTO v_perm_id, v_perm_nm, v_kim_typ_id, v_tmpl_nm;
    REPEAT
        SELECT v_perm_id, v_perm_nm, v_kim_typ_id, v_tmpl_nm;
        if v_kim_typ_id != 1 then
            if v_tmpl_nm = 'Use Transactional Document' then
                SET done = FALSE;
//                for perm_attr_val in ()
//                loop
//                    //new_perm_nm := new_perm_nm || ' ' || perm_attr_val.attr_val;
//                end loop;
            else
                SET done = FALSE;
//                for perm_attr_val in (select krim_perm_attr_data_t.attr_val from krim_perm_attr_data_t join krim_typ_attr_t on krim_perm_attr_data_t.kim_attr_defn_id = krim_typ_attr_t.kim_attr_defn_id where krim_typ_attr_t.kim_typ_id = perm_dtl.kim_typ_id and krim_perm_attr_data_t.perm_id = perm_dtl.perm_id order by krim_typ_attr_t.sort_cd)
//                loop
//                    new_perm_nm := new_perm_nm || ' ' || v_attr_val;
//                end loop;
            end if;
//            if length(v_perm_nm) > 100 then
//                //new_perm_nm := substr(v_perm_nm, 1, 96) || '...';
//            end if;
        end if;
        SELECT new_perm_nm;
        //execute immediate 'update krim_perm_t set nm = '''||v_perm_nm||''' where perm_id = '''||perm_dtl.perm_id||''' ';
        FETCH cur_perm INTO v_perm_id, v_perm_nm, v_kim_typ_id, v_tmpl_nm;
        UNTIL done
    END REPEAT;
    CLOSE cur_perm;
END
</sql>
		<sql>call kim_upgrade()</sql>
	</changeSet>

	<changeSet author="KFS50" id="UPGRADE_KIM_DATA_RICE_20_oracle" dbms="oracle">
		<comment>Upgrade the permission and responsibility names from previous releases of KFS to have unique names as required by Rice 2.0.</comment>
		<sql splitStatements="false" stripComments="false">
			-- fix permissions
			declare
               v_perm_nm VARCHAR2(4000);
			begin
			    dbms_output.enable(50000);
			               for perm_dtl in (select krim_perm_t.perm_id, NVL( krim_perm_t.nm, krim_perm_tmpl_t.nm ) as perm_nm, krim_perm_tmpl_t.kim_typ_id, krim_perm_tmpl_t.nm as tmpl_nm from krim_perm_t join krim_perm_tmpl_t on krim_perm_t.perm_tmpl_id = krim_perm_tmpl_t.perm_tmpl_id where krim_perm_t.nmspc_cd like 'KFS%')
			               loop
			                              v_perm_nm := perm_dtl.perm_nm;
			        if (perm_dtl.kim_typ_id <> 1) then
			                                             if (perm_dtl.tmpl_nm = 'Use Transactional Document') then
			                                                            for perm_attr_val in (select krim_perm_attr_data_t.attr_val from krim_perm_attr_data_t join krim_typ_attr_t on krim_perm_attr_data_t.kim_attr_defn_id = krim_typ_attr_t.kim_attr_defn_id where krim_typ_attr_t.kim_typ_id = perm_dtl.kim_typ_id and krim_perm_attr_data_t.perm_id = perm_dtl.perm_id order by krim_typ_attr_t.sort_cd desc)
			                                                            loop
			                                                                           v_perm_nm := v_perm_nm || ' ' || perm_attr_val.attr_val;
			                                                            end loop;
			                                             else
			                                                            for perm_attr_val in (select krim_perm_attr_data_t.attr_val from krim_perm_attr_data_t join krim_typ_attr_t on krim_perm_attr_data_t.kim_attr_defn_id = krim_typ_attr_t.kim_attr_defn_id where krim_typ_attr_t.kim_typ_id = perm_dtl.kim_typ_id and krim_perm_attr_data_t.perm_id = perm_dtl.perm_id order by krim_typ_attr_t.sort_cd)
			                                                            loop
			                                                                           v_perm_nm := v_perm_nm || ' ' || perm_attr_val.attr_val;
			                                                            end loop;
			                                             end if;
			            if (length(v_perm_nm) > 100) then
			                                             v_perm_nm := substr(v_perm_nm, 1, 96) || '...';
{'fraction_non_alphanumeric': 0.07025344597598933, 'fraction_numerical': 0.010004446420631391, 'mean_word_length': 1.8248037676609106, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 52, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2133358', 'n_tokens_mistral': 3278, 'n_tokens_neox': 2952, 'n_words': 520}