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

Skip to content

Commit 1454221

Browse files
committed
Adding extra fields.
1 parent f1f6d71 commit 1454221

6 files changed

Lines changed: 126 additions & 66 deletions

File tree

source/core/types/ut_path_item.tpb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,30 @@ create or replace type body ut_path_item as
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
18-
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2) return self as result is
18+
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2, originated_path varchar2) return self as result is
1919
begin
2020
self.schema_name := schema_name;
2121
self.object_name := object_name;
2222
self.procedure_name := procedure_name;
23+
self.originated_path := originated_path;
2324
return;
2425
end;
2526

26-
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2,suite_path varchar2) return self as result is
27+
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2,suite_path varchar2, originated_path varchar2) return self as result is
2728
begin
2829
self.schema_name := schema_name;
2930
self.suite_path := suite_path;
31+
self.originated_path := originated_path;
3032
return;
3133
end;
3234

33-
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2,suite_path varchar2) return self as result is
35+
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2,suite_path varchar2, originated_path varchar2) return self as result is
3436
begin
3537
self.schema_name := schema_name;
3638
self.object_name := object_name;
3739
self.procedure_name := procedure_name;
3840
self.suite_path := suite_path;
41+
self.originated_path := originated_path;
3942
return;
4043
end;
4144
end;

source/core/types/ut_path_item.tps

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ create or replace type ut_path_item as object (
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
18-
schema_name varchar2(4000),
19-
object_name varchar2(250),
20-
procedure_name varchar2(250),
21-
suite_path varchar2(4000),
22-
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2) return self as result,
23-
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2,suite_path varchar2) return self as result,
24-
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2,suite_path varchar2) return self as result
18+
schema_name varchar2(4000),
19+
object_name varchar2(250),
20+
procedure_name varchar2(250),
21+
suite_path varchar2(4000),
22+
originated_path varchar2(4000),
23+
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2, originated_path varchar2) return self as result,
24+
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, suite_path varchar2, originated_path varchar2) return self as result,
25+
constructor function ut_path_item(self in out nocopy ut_path_item, schema_name varchar2, object_name varchar2,procedure_name varchar2,suite_path varchar2, originated_path varchar2) return self as result
2526
)
2627
/

source/core/ut_suite_cache_manager.pkb

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,15 @@ create or replace package body ut_suite_cache_manager is
277277
for i in 1 .. a_paths.count loop
278278
l_results.extend;
279279
if a_paths(i) like '%:%' then
280-
l_path_item := ut_path_item(upper(regexp_substr(a_paths(i),'^[^.:]+')),
281-
ltrim(regexp_substr(a_paths(i),'[.:].*$'),':'));
280+
l_path_item := ut_path_item(schema_name => upper(regexp_substr(a_paths(i),'^[^.:]+')),
281+
suite_path => ltrim(regexp_substr(a_paths(i),'[.:].*$'),':'),
282+
originated_path => a_paths(i));
282283
l_results(l_results.last) := l_path_item;
283284
else
284-
l_path_item := ut_path_item(regexp_substr(a_paths(i), c_package_path_regex, subexpression => 1),
285-
regexp_substr(a_paths(i), c_package_path_regex, subexpression => 3),
286-
regexp_substr(a_paths(i), c_package_path_regex, subexpression => 5));
285+
l_path_item := ut_path_item(schema_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 1),
286+
object_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 3),
287+
procedure_name => regexp_substr(a_paths(i), c_package_path_regex, subexpression => 5),
288+
originated_path => a_paths(i));
287289
l_results(l_results.last) := l_path_item;
288290
end if;
289291
end loop;
@@ -359,41 +361,50 @@ create or replace package body ut_suite_cache_manager is
359361
l_schema_paths ut_path_items:= ut_path_items();
360362
begin
361363
with paths_to_expand as (
362-
select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(sp.object_name,c.object_name) as object_name,sp.procedure_name as procedure_name
363-
from ut_suite_cache c,
364-
table(a_schema_paths) sp
365-
where c.object_owner = upper(sp.schema_name)
366-
and c.object_name like nvl(replace(upper(sp.object_name),'*','%'),c.object_name)
367-
and c.name like nvl(replace(upper(sp.procedure_name),'*','%'), c.name)
368-
and sp.suite_path is null
369-
group by sp.schema_name,nvl(sp.object_name,c.object_name),sp.procedure_name
364+
select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(sp.object_name,c.object_name) as object_name,
365+
sp.procedure_name as procedure_name,sp.originated_path
366+
from table(a_schema_paths) sp left outer join ut_suite_cache c
367+
on ( c.object_owner = upper(sp.schema_name)
368+
and c.object_name like replace(upper(sp.object_name),'*','%')
369+
and c.name like nvl(replace(upper(sp.procedure_name),'*','%'), c.name))
370+
where sp.suite_path is null
371+
and sp.object_name is not null
372+
group by sp.schema_name,nvl(sp.object_name,c.object_name),sp.procedure_name,sp.originated_path
370373
union all
371-
select /*+ no_parallel */ c.path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
372-
from
373-
ut_suite_cache c,
374-
table(a_schema_paths) sp
375-
where c.object_owner = upper(sp.schema_name)
376-
and sp.suite_path is not null
377-
and instr(sp.suite_path,'*') > 0
378-
and c.path like replace(sp.suite_path,'*','%')
374+
select /*+ no_parallel */ c.path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name,sp.originated_path
375+
from
376+
table(a_schema_paths) sp left outer join ut_suite_cache c on
377+
( c.object_owner = upper(sp.schema_name)
378+
and sp.suite_path is not null
379+
and instr(sp.suite_path,'*') > 0)
380+
where c.path like replace(sp.suite_path,'*','%')
379381
union all
380-
select /*+ no_parallel */ sp.suite_path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
381-
from table(a_schema_paths) sp
382+
select /*+ no_parallel */ sp.suite_path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name,sp.originated_path
383+
from table(a_schema_paths) sp
382384
where sp.suite_path is not null
383-
and instr(sp.suite_path,'*') = 0
385+
and instr(sp.suite_path,'*') = 0
386+
union all
387+
select /*+ no_parallel */ sp.suite_path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name,sp.originated_path
388+
from table(a_schema_paths) sp
389+
where sp.suite_path is null and sp.object_name is null
384390
)
385-
select ut_path_item(schema_name,object_name,procedure_name,suite_path)
391+
select ut_path_item(schema_name,object_name,procedure_name,suite_path,originated_path)
386392
bulk collect into l_schema_paths
387393
from
388-
(select schema_name,object_name,procedure_name,suite_path,
394+
(select schema_name,object_name,procedure_name,suite_path,originated_path,
389395
row_number() over ( partition by schema_name,object_name,procedure_name,suite_path order by 1) r_num
390396
from paths_to_expand)
391397
where r_num = 1 ;
392398
return l_schema_paths;
393399
end;
394400

401+
function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items is
402+
begin
403+
return expand_paths(group_paths_by_schema(a_paths));
404+
end;
405+
395406
function get_cached_suite_rows(
396-
a_paths ut_varchar2_list,
407+
a_schema_paths ut_path_items,
397408
a_random_seed positive := null,
398409
a_tags ut_varchar2_rows := null
399410
) return ut_suite_cache_rows is
@@ -417,7 +428,7 @@ create or replace package body ut_suite_cache_manager is
417428
from table(l_tags)
418429
where column_value like '-%';
419430

420-
l_schema_paths := expand_paths(group_paths_by_schema(a_paths));
431+
l_schema_paths := a_schema_paths;
421432
--We still need to turn this into qualified SQL name....maybe as part of results ?
422433
l_suite_item_name := case when l_tags.count > 0 then 'suite_items_tags' else 'suite_items' end;
423434

source/core/ut_suite_cache_manager.pks

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ create or replace package ut_suite_cache_manager authid definer is
5454
a_tags ut_varchar2_rows := null
5555
) return ut_suite_cache_rows;
5656

57+
function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items;
58+
5759
function get_cached_suite_rows(
58-
a_paths ut_varchar2_list,
60+
a_schema_paths ut_path_items,
5961
a_random_seed positive := null,
6062
a_tags ut_varchar2_rows := null
6163
) return ut_suite_cache_rows;

source/core/ut_suite_manager.pkb

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ create or replace package body ut_suite_manager is
1818

1919
gc_suitpath_error_message constant varchar2(100) := 'Suitepath exceeds 1000 CHAR on: ';
2020

21-
cursor c_cached_suites_cursor is select * from table(ut_suite_cache_rows());
22-
type tt_cached_suites is table of c_cached_suites_cursor%rowtype;
2321
type t_cached_suites_cursor is ref cursor return c_cached_suites_cursor%rowtype;
24-
2522
type t_item_levels is table of ut_suite_items index by binary_integer;
2623
------------------
2724

@@ -339,30 +336,20 @@ create or replace package body ut_suite_manager is
339336

340337
return l_result;
341338
end;
342-
343-
function get_cached_suite_data(
344-
a_paths ut_varchar2_list,
345-
a_random_seed positive,
346-
a_tags ut_varchar2_rows := null
347-
) return t_cached_suites_cursor is
348-
l_unfiltered_rows ut_suite_cache_rows;
339+
340+
function get_filtered_cursor(a_unfiltered_rows in ut_suite_cache_rows)
341+
return t_cached_suites_cursor is
349342
l_result t_cached_suites_cursor;
350343
begin
351-
l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_rows(
352-
a_paths,
353-
a_random_seed,
354-
a_tags
355-
);
356-
357344
if ut_metadata.user_has_execute_any_proc() then
358345
open l_result for
359-
select /*+ no_parallel */ c.* from table(l_unfiltered_rows) c;
346+
select /*+ no_parallel */ c.* from table(a_unfiltered_rows) c;
360347
else
361348
open l_result for
362-
select /*+ no_parallel */ c.* from table(l_unfiltered_rows) c
349+
select /*+ no_parallel */ c.* from table(a_unfiltered_rows) c
363350
where sys_context( 'userenv', 'current_user' ) = upper(c.object_owner)
364351
union all
365-
select /*+ no_parallel */ c.* from table(l_unfiltered_rows) c
352+
select /*+ no_parallel */ c.* from table(a_unfiltered_rows) c
366353
where sys_context( 'userenv', 'current_user' ) != upper(c.object_owner)
367354
and ( exists
368355
( select 1
@@ -371,13 +358,61 @@ create or replace package body ut_suite_manager is
371358
and a.owner = c.object_owner
372359
and a.object_type = 'PACKAGE'
373360
)
374-
or c.self_type = 'UT_LOGICAL_SUITE');
375-
376-
end if;
377-
return l_result;
378-
361+
or c.self_type = 'UT_LOGICAL_SUITE');
362+
end if;
379363
return l_result;
380364
end;
365+
366+
procedure reconcile_paths_and_suites(
367+
a_schema_paths ut_path_items,
368+
a_filtered_rows t_cached_suites_cursor
369+
) is
370+
l_rows_tmp tt_cached_suites:= tt_cached_suites();
371+
l_rows tt_cached_suites := tt_cached_suites();
372+
l_limit number := 5000;
373+
begin
374+
loop
375+
fetch a_filtered_rows bulk collect into l_rows_tmp limit l_limit;
376+
l_rows := l_rows multiset union l_rows_tmp;
377+
exit when a_filtered_rows%NOTFOUND;
378+
end loop;
379+
close a_filtered_rows;
380+
381+
for i in ( select /*+ no_parallel */sp.schema_name,sp.object_name,sp.procedure_name,
382+
sp.suite_path,sp.originated_path,sc.path
383+
from table(a_schema_paths) sp left outer join
384+
table(l_rows) sc on
385+
(( upper(sp.schema_name) = upper(sc.object_owner) and upper(sp.object_name) = upper(sc.object_name)
386+
and nvl(upper(sp.procedure_name),sc.name) = sc.name )
387+
or (sc.path = sp.suite_path))
388+
where sc.path is null)
389+
loop
390+
if i.suite_path is not null then
391+
raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||i.schema_name||':'||i.suite_path|| '.');
392+
elsif i.procedure_name is not null then
393+
raise_application_error(ut_utils.gc_suite_package_not_found,'Suite test '||i.schema_name||'.'||i.object_name|| '.'||i.procedure_name||' does not exist');
394+
elsif i.object_name is not null then
395+
raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||i.schema_name||'.'||i.object_name|| ' does not exist');
396+
end if;
397+
end loop;
398+
end;
399+
400+
function get_cached_suite_data(
401+
a_schema_paths ut_path_items,
402+
a_random_seed positive,
403+
a_tags ut_varchar2_rows := null
404+
) return t_cached_suites_cursor is
405+
l_unfiltered_rows ut_suite_cache_rows;
406+
l_result t_cached_suites_cursor;
407+
begin
408+
l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_rows(
409+
a_schema_paths,
410+
a_random_seed,
411+
a_tags
412+
);
413+
reconcile_paths_and_suites(a_schema_paths,get_filtered_cursor(l_unfiltered_rows));
414+
return get_filtered_cursor(l_unfiltered_rows);
415+
end;
381416

382417
function can_skip_all_objects_scan(
383418
a_owner_name varchar2
@@ -452,7 +487,7 @@ create or replace package body ut_suite_manager is
452487
end;
453488

454489
procedure add_suites_for_paths(
455-
a_paths ut_varchar2_list,
490+
a_schema_paths ut_path_items,
456491
a_suites in out nocopy ut_suite_items,
457492
a_random_seed positive,
458493
a_tags ut_varchar2_rows := null
@@ -461,7 +496,7 @@ create or replace package body ut_suite_manager is
461496
reconstruct_from_cache(
462497
a_suites,
463498
get_cached_suite_data(
464-
a_paths,
499+
a_schema_paths,
465500
a_random_seed,
466501
a_tags
467502
)
@@ -530,6 +565,8 @@ create or replace package body ut_suite_manager is
530565
) is
531566
l_paths ut_varchar2_list := a_paths;
532567
l_schema_names ut_varchar2_rows;
568+
l_schema_paths ut_path_items;
569+
l_reconcile_paths ut_path_items;
533570
l_schema varchar2(4000);
534571
l_suites_count pls_integer := 0;
535572
l_index varchar2(4000 char);
@@ -546,9 +583,11 @@ create or replace package body ut_suite_manager is
546583
l_schema := l_schema_names.next(l_schema);
547584
end loop;
548585

586+
l_schema_paths := ut_suite_cache_manager.get_schema_paths(l_paths);
587+
549588
--We will get a single list of paths rather than loop by loop.
550589
add_suites_for_paths(
551-
l_paths,
590+
l_schema_paths,
552591
a_suites,
553592
a_random_seed,
554593
a_tags

source/core/ut_suite_manager.pks

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ create or replace package ut_suite_manager authid current_user is
2020
* Resposible for building hierarhy of sutes from individual suites created by suite_builder
2121
*/
2222

23+
cursor c_cached_suites_cursor is select * from table(ut_suite_cache_rows());
24+
type tt_cached_suites is table of c_cached_suites_cursor%rowtype;
25+
26+
2327
/**
2428
* @private
2529
*

0 commit comments

Comments
 (0)