Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b8e2ab

Browse files
committed
Cleanup.
Fix object name length.
1 parent f51cc99 commit 4b8e2ab

3 files changed

Lines changed: 5 additions & 153 deletions

File tree

source/core/ut_suite_cache_manager.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ create or replace package body ut_suite_cache_manager is
268268
if instr(l_tags,',') > 0 or instr(l_tags,'-') > 0 then
269269
l_tags := replace(replace_legacy_tag_notation(l_tags),' ');
270270
end if;
271-
l_tags := ut_utils.convert_postfix_to_infix_where_sql(ut_utils.shunt_logical_expression(l_tags));
271+
l_tags := ut_utils.convert_postfix_to_infix(ut_utils.shunt_logical_expression(l_tags));
272272
l_tags := REPLACE(l_tags, '|',' or ');
273273
l_tags := REPLACE(l_tags ,'&',' and ');
274274
l_tags := REPLACE(l_tags ,'!','not');

source/core/ut_utils.pkb

Lines changed: 3 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,144 +1000,6 @@ create or replace package body ut_utils is
10001000
return l_result;
10011001
end;
10021002

1003-
/*
1004-
Purpose of this function is to break down the tag expressions
1005-
We can separate operators on left and rigth side.
1006-
Left ones are AND and OR as they require an operator on left side to
1007-
be valid. Right side is NOT.
1008-
In each iteration we breakdown string into parts
1009-
1010-
*/
1011-
function valid_tag_expression(a_tags in varchar2) return number is
1012-
l_left_side_expression varchar2(10) := '[|&,]';
1013-
l_left_side_regex varchar2(50) := '([^|&,]*)[|&,](.*)';
1014-
l_left_side varchar2(4000);
1015-
1016-
l_rigth_side_expression varchar2(10) := '[!-]';
1017-
l_right_side_regex varchar2(50) := '([!-])([^!-].*)';
1018-
l_right_side varchar2(4000);
1019-
1020-
l_tags varchar2(4000) := a_tags;
1021-
l_result number :=1;
1022-
begin
1023-
--Validate that we have closed up all brackets
1024-
if regexp_count(l_tags,'\(') <> regexp_count(l_tags,'\)') then
1025-
l_result := 0;
1026-
end if;
1027-
1028-
--Remove brackets as we dont evaluate expression only validate.
1029-
l_tags := replace(replace(l_tags,'('),')');
1030-
1031-
--Check if there are any left side operators for first in order from left to right
1032-
if regexp_count(l_tags,l_left_side_expression) > 0 then
1033-
--Extract left part of operator and remaining of string to right
1034-
l_left_side := regexp_replace(l_tags,l_left_side_regex,'\1');
1035-
l_right_side := regexp_replace(l_tags,l_left_side_regex,'\2');
1036-
1037-
--If left side is null that means that we used left side operator without
1038-
-- left and right e.g. |test
1039-
if l_left_side is null then
1040-
l_result := 0;
1041-
else
1042-
--Extract right side from left side expression if there is any !-
1043-
--Remove first negation tag to see if there is double negation
1044-
l_left_side := regexp_replace(l_left_side,l_right_side_regex,'\2');
1045-
end if;
1046-
1047-
1048-
--check that on right side there is no extra negation
1049-
if regexp_count(l_left_side,l_rigth_side_expression) > 0 then
1050-
l_result := 0;
1051-
end if;
1052-
1053-
--Now process right side of string
1054-
if l_right_side is not null then
1055-
l_result := least(l_result,valid_tag_expression(l_right_side));
1056-
else
1057-
l_result := 0;
1058-
end if;
1059-
else
1060-
--We just process single tag.
1061-
l_left_side := l_tags;
1062-
l_left_side := regexp_replace(l_left_side,l_right_side_regex,'\2');
1063-
if regexp_count(l_left_side,l_rigth_side_expression) > 0 then
1064-
l_result := 0;
1065-
end if;
1066-
end if;
1067-
1068-
return l_result;
1069-
end;
1070-
1071-
procedure build_tag_expression_filter(a_tags in varchar2,a_expression_tab in out t_expression_tab,a_parent_id varchar2 default null) is
1072-
l_left_side_expression varchar2(10) := '[|&,]';
1073-
l_left_side_regex varchar2(50) := '([^|&,]*)([|&,])(.*)';
1074-
l_left_side varchar2(4000);
1075-
1076-
l_rigth_side_expression varchar2(10) := '[!-]';
1077-
l_right_side_regex varchar2(50) := '([!-])([^!-].*)';
1078-
l_right_side varchar2(4000);
1079-
1080-
l_tags varchar2(4000) := a_tags;
1081-
l_result number :=1;
1082-
l_expression_rec t_expression_rec;
1083-
1084-
begin
1085-
if a_expression_tab is null then
1086-
a_expression_tab := t_expression_tab();
1087-
end if;
1088-
1089-
l_expression_rec.id := sys_guid();
1090-
l_expression_rec.parent_id := a_parent_id;
1091-
1092-
if instr(substr(l_tags,1,1),'(',1,1) + instr(substr(l_tags,-1,1),')',-1,1) = 2 then
1093-
1094-
if regexp_count(l_tags,l_right_side_regex) = 1 then
1095-
l_expression_rec.negated :=1;
1096-
l_tags := trim (leading '!' from l_tags);
1097-
end if;
1098-
1099-
l_expression_rec.left_bracket := 1;
1100-
l_tags := trim(leading '(' from l_tags);
1101-
l_expression_rec.right_bracket := 1;
1102-
l_tags := trim(trailing ')' from l_tags);
1103-
end if;
1104-
1105-
1106-
--Check if there are any left side operators for first in order from left to right
1107-
if regexp_count(l_tags,l_left_side_expression) > 0 then
1108-
--Extract left part of operator and remaining of string to right
1109-
1110-
--if there are bracketc extract it and record it
1111-
1112-
l_left_side := regexp_replace(l_tags,l_left_side_regex,'\1');
1113-
l_expression_rec.log_operator := regexp_replace(l_tags,l_left_side_regex,'\2');
1114-
l_right_side := regexp_replace(l_tags,l_left_side_regex,'\3');
1115-
a_expression_tab.extend;
1116-
a_expression_tab(a_expression_tab.last) := l_expression_rec;
1117-
1118-
build_tag_expression_filter(l_left_side,a_expression_tab,l_expression_rec.id);
1119-
build_tag_expression_filter(l_right_side,a_expression_tab,l_expression_rec.id);
1120-
1121-
else
1122-
if instr(substr(l_tags,1,1),'(',1,1) + instr(substr(l_tags,-1,1),')',-1,1) = 2 then
1123-
1124-
if regexp_count(l_tags,l_right_side_regex) = 1 then
1125-
l_expression_rec.negated :=1;
1126-
l_tags := trim (leading '!' from l_tags);
1127-
end if;
1128-
1129-
l_expression_rec.left_bracket := 1;
1130-
l_tags := trim(leading '(' from l_tags);
1131-
l_expression_rec.right_bracket := 1;
1132-
l_tags := trim(trailing ')' from l_tags);
1133-
end if;
1134-
l_expression_rec.expression := l_tags;
1135-
a_expression_tab.extend;
1136-
a_expression_tab(a_expression_tab.last) := l_expression_rec;
1137-
end if;
1138-
1139-
end;
1140-
11411003
/*
11421004
https://stackoverflow.com/questions/29634992/shunting-yard-validate-expression
11431005
*/
@@ -1251,9 +1113,9 @@ create or replace package body ut_utils is
12511113
end loop;
12521114

12531115
return l_infix_stack.pop;
1254-
end;
1116+
end convert_postfix_to_infix;
12551117

1256-
function convert_postfix_to_infix_where_sql(a_postfix_exp in ut_varchar2_list)
1118+
function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list)
12571119
return varchar2 is
12581120
l_infix_stack ut_stack := ut_stack();
12591121
l_right_side varchar2(32767);
@@ -1285,7 +1147,7 @@ create or replace package body ut_utils is
12851147
end loop;
12861148

12871149
return l_infix_stack.pop;
1288-
end;
1150+
end conv_postfix_to_infix_sql;
12891151

12901152
begin
12911153
--Define operator precedence

source/core/ut_utils.pks

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -477,16 +477,6 @@ create or replace package ut_utils authid definer is
477477
*/
478478
function interval_to_text(a_interval yminterval_unconstrained) return varchar2;
479479

480-
/*
481-
* Return number 1 or 0 if the list of tags is valid expression
482-
*/
483-
function valid_tag_expression(a_tags in varchar2) return number;
484-
485-
/*
486-
* Return number 1 or 0 if the list of tags is valid expression
487-
*/
488-
procedure build_tag_expression_filter(a_tags in varchar2,a_expression_tab in out t_expression_tab,a_parent_id varchar2 default null);
489-
490480
/*
491481
* Function that uses Dijkstra algorithm to parse mathematical and logical expression
492482
* and return a list of elements in Reverse Polish Notation ( postfix )
@@ -505,7 +495,7 @@ create or replace package ut_utils authid definer is
505495
* Function that converts postfix notation into infix and creating a string of sql filter
506496
* that checking a tags collections for tags according to posted logic.
507497
*/
508-
function convert_postfix_to_infix_where_sql(a_postfix_exp in ut_varchar2_list) return varchar2;
498+
function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list) return varchar2;
509499

510500
end ut_utils;
511501
/

0 commit comments

Comments
 (0)