Skip to content

Commit a6c8368

Browse files
CWMS-Vue-745: Reimplementing av_location_level and av_virtual_location_level (#104)
* initial concept for reimplementing av_location_level and av_virtual_location_level -splitting av_location_level_ref and av_location_level_values where av_location_level_ref is designed for pagination via CDA and av_location_level_values are decorated by the paginged location_level_codes in the initially filtered av_location_level_ref - units are handled via _EN and _SI columns instead of having additional rows. This matches av_virtual_location_level, but not av_location_level - sorting is not based on fully concatenated location_level_id, but instead of the constituent parts so that full table scan isn't needed prior to sort. no sorting done within the views * Initial integration test for new level views * Added to documentation * Updated views. Added Git attributes file and normalized line endings. --------- Co-authored-by: Adam Korynta <adam@rmanet.com>
1 parent 2757d20 commit a6c8368

28 files changed

Lines changed: 8960 additions & 7820 deletions

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Shell scripts must be LF to run reliably in Linux containers
2+
*.sh text eol=lf
3+
4+
# Docker-related files are also typically LF
5+
Dockerfile text eol=lf
6+
*.Dockerfile text eol=lf
7+
*.env text eol=lf
8+
9+
# Windows scripts should be CRLF
10+
*.bat text eol=crlf
11+
*.cmd text eol=crlf
12+
*.ps1 text eol=crlf

docs/make.bat

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
@ECHO OFF
2-
3-
pushd %~dp0
4-
5-
REM Command file for Sphinx documentation
6-
7-
if "%SPHINXBUILD%" == "" (
8-
set SPHINXBUILD=sphinx-build
9-
)
10-
set SOURCEDIR=source
11-
set BUILDDIR=build
12-
13-
%SPHINXBUILD% >NUL 2>NUL
14-
if errorlevel 9009 (
15-
echo.
16-
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17-
echo.installed, then set the SPHINXBUILD environment variable to point
18-
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19-
echo.may add the Sphinx directory to PATH.
20-
echo.
21-
echo.If you don't have Sphinx installed, grab it from
22-
echo.https://www.sphinx-doc.org/
23-
exit /b 1
24-
)
25-
26-
if "%1" == "" goto help
27-
28-
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29-
goto end
30-
31-
:help
32-
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33-
34-
:end
35-
popd
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

schema/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@
475475
<echo message=" Running tests" />
476476
<exec executable="utplsql" resultproperty="utreturn">
477477
<arg value="run"/>
478-
<arg value="-p=${oracle.cwms.user}.test_aq_user,${oracle.cwms.user}.test_aaa_normaluserfails,${oracle.cwms.user}.test_cwms_loc_normal_user,${oracle.cwms.user}.test_cwms_prop"/>
478+
<arg value="-p=${oracle.cwms.user}.test_aq_user,${oracle.cwms.user}.test_aaa_normaluserfails,${oracle.cwms.user}.test_cwms_loc_normal_user,${oracle.cwms.user}.test_cwms_prop,${oracle.cwms.user}.test_av_location_level_ref_values"/>
479479
<arg value="-f"/><arg value="UT_COVERAGE_HTML_REPORTER"/><arg value="-o"/><arg value="${coverage.dir}/index.html" />
480480
<arg value="-f"/><arg value="UT_COVERAGE_COBERTURA_REPORTER"/><arg value="-o"/><arg value="${coverage.dir}/coverage_ro.xml" />
481481
<arg value="-f"/><arg value="UT_JUNIT_REPORTER"/><arg value="-o"/><arg value="build/tests_ro.xml" />

schema/cwmsdb_documentor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ def build_item_lists(packages, views) :
14011401
HtmlElem('dd', content=build_item_lists(
14021402
packages = ['cwms_level', 'cwms_pool', 'cwms_rating'],
14031403
views = ['av_loc_lvl_cur_max_ind', 'av_loc_lvl_indicator', 'av_loc_lvl_indicator_2', 'av_loc_lvl_ts_map', 'av_location_level',
1404-
'av_pool_name', 'av_pool',
1404+
'av_pool_name', 'av_pool', 'av_location_level_ref', 'av_location_level_values',
14051405
'av_rating', 'av_rating_local', 'av_rating_spec','av_rating_template', 'av_rating_values', 'av_rating_values_native']))])
14061406
items_list.add_content([
14071407
HtmlElem('a', attrs=[('name', 'Forecasts and Model Runs')]),

schema/src/cwms/at_schema_av.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ BEGIN
135135
FOR i IN view_names.FIRST .. view_names.LAST
136136
LOOP
137137
BEGIN
138-
EXECUTE IMMEDIATE 'drop view' || view_names (i);
138+
EXECUTE IMMEDIATE 'drop view ' || view_names (i);
139139

140140
DBMS_OUTPUT.put_line ('Dropped view ' || view_names (i));
141141
EXCEPTION
@@ -201,6 +201,8 @@ END;
201201
@@cwms/views/av_loc_ts_id_count
202202
@@cwms/views/av_location_kind
203203
@@cwms/views/av_location_level
204+
@@cwms/views/av_location_level_ref
205+
@@cwms/views/av_location_level_values
204206
@@cwms/views/av_location_level_curval
205207
@@cwms/views/av_location_type
206208
@@cwms/views/av_nation

schema/src/cwms/cwms_schema_pkg.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ view_names constant object_tab_t := object_tab_t(
313313
'AV_LOC5_TEST',
314314
'AV_LOCATION_KIND',
315315
'AV_LOCATION_LEVEL',
316+
'AV_LOCATION_LEVEL_REF',
317+
'AV_LOCATION_LEVEL_VALUES',
316318
'AV_LOCATION_LEVEL_CURVAL',
317319
'AV_LOCATION_TYPE',
318320
'AV_LOCK',

schema/src/cwms/tables/at_data_dissem.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ALTER TABLE AT_DATA_DISSEM ADD (
3232
CONSTRAINT AT_DATA_DISSEM_R01
3333
FOREIGN KEY (OFFICE_CODE)
3434
REFERENCES CWMS_OFFICE (OFFICE_CODE)
35-
ENABLE VALIDATE);
35+
ENABLE VALIDATE);
3636
INSERT INTO AT_TS_CATEGORY (TS_CATEGORY_CODE,
3737
TS_CATEGORY_ID,
3838
DB_OFFICE_CODE,
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
begin
2+
delete from at_clob where id = '/VIEWDOCS/AV_LOCATION_LEVEL_REF';
3+
insert into at_clob values (cwms_seq.nextval, 53, '/VIEWDOCS/AV_LOCATION_LEVEL_REF', null,
4+
'
5+
/**
6+
* Displays information about location level IDs
7+
*
8+
* @field office_id Office that owns the location level
9+
* @field location_level_id The unique identifier for the location level
10+
* @field attribute_id The attribute identifier, if any, for the location level
11+
* @field location_level_code The unique numeric code that identifies the location level in the database
12+
* @field location_level_date The effective data for the location level
13+
* @field expiration_date The date/time at which the level expires
14+
* @field base_location_id The base location portion of the location level
15+
* @field sub_location_id The sub-location portion of the location level
16+
* @field location_id The full location portion of the location level
17+
* @field location_code The unique numeric code that identifies the location in the database
18+
* @field base_parameter_id The base parameter portion of the location level
19+
* @field sub_parameter_id The sub-parameter portion of the location level
20+
* @field parameter_id The full parameter portion of the location level
21+
* @field parameter_type_id The parameter type of the location level
22+
* @field location_level_comment The comment associated with the location level
23+
* @field duration_id The duration portion of the location level
24+
* @field specified_level_id The specified level portion of the location level
25+
* @field attribute_parameter_id The attribute of the parameter, if any
26+
* @field attribute_base_parameter_id The base parameter of the attribute, if any
27+
* @field attribute_sub_parameter_id The sub-parameter of the attribute, if any
28+
* @field attribute_parameter_type_id The parameter type of the attribute, if any
29+
* @field attribute_duration_id The duration of the attribute, if any
30+
*/
31+
');
32+
end;
33+
/
34+
create or replace force view av_location_level_ref
35+
(
36+
office_id,
37+
location_level_id,
38+
attribute_id,
39+
location_level_code,
40+
location_level_date,
41+
expiration_date,
42+
base_location_id,
43+
sub_location_id,
44+
location_id,
45+
location_code,
46+
base_parameter_id,
47+
sub_parameter_id,
48+
parameter_id,
49+
parameter_type_id,
50+
location_level_comment,
51+
duration_id,
52+
specified_level_id,
53+
attribute_parameter_id,
54+
attribute_base_parameter_id,
55+
attribute_sub_parameter_id,
56+
attribute_parameter_type_id,
57+
attribute_duration_id
58+
)
59+
as
60+
/* ===========================
61+
* PHYSICAL LOCATION LEVELS
62+
* =========================== */
63+
select
64+
c_o.office_id,
65+
(dash(a_bl.base_location_id, a_pl.sub_location_id) || '.' || dash(c_bp1.base_parameter_id, a_p1.sub_parameter_id) || '.' || c_pt1.parameter_type_id || '.' || c_d1.duration_id || '.' || a_sl.specified_level_id) as location_level_id,
66+
(dash(c_bp2.base_parameter_id, a_p2.sub_parameter_id) || substr ('.', 1, length (c_pt2.parameter_type_id)) || c_pt2.parameter_type_id || substr ('.', 1, length (c_d2.duration_id)) || c_d2.duration_id) as attribute_id,
67+
a_ll.location_level_code,
68+
a_ll.location_level_date,
69+
a_ll.expiration_date,
70+
a_bl.base_location_id,
71+
a_pl.sub_location_id,
72+
dash(a_bl.base_location_id, a_pl.sub_location_id) as location_id,
73+
a_ll.location_code,
74+
c_bp1.base_parameter_id,
75+
a_p1.sub_parameter_id,
76+
dash(c_bp1.base_parameter_id, a_p1.sub_parameter_id) as parameter_id,
77+
c_pt1.parameter_type_id,
78+
a_ll.location_level_comment,
79+
c_d1.duration_id,
80+
a_sl.specified_level_id,
81+
dash(c_bp2.base_parameter_id, a_p2.sub_parameter_id) as parameter_id,
82+
c_bp2.base_parameter_id as attribute_base_parameter_id,
83+
a_p2.sub_parameter_id as attribute_sub_parameter_id,
84+
c_pt2.parameter_type_id as attribute_parameter_type_id,
85+
c_d2.duration_id as attribute_duration_id
86+
from
87+
at_location_level a_ll
88+
join at_physical_location a_pl
89+
on a_pl.location_code = a_ll.location_code
90+
join at_base_location a_bl
91+
on a_bl.base_location_code = a_pl.base_location_code
92+
join cwms_office c_o
93+
on c_o.office_code = a_bl.db_office_code
94+
join at_specified_level a_sl
95+
on a_sl.specified_level_code = a_ll.specified_level_code
96+
join cwms_duration c_d1
97+
on c_d1.duration_code = a_ll.duration_code
98+
join cwms_parameter_type c_pt1
99+
on c_pt1.parameter_type_code = a_ll.parameter_type_code
100+
join at_parameter a_p1
101+
on a_p1.parameter_code = a_ll.parameter_code
102+
join cwms_base_parameter c_bp1
103+
on c_bp1.base_parameter_code = a_p1.base_parameter_code
104+
left join at_parameter a_p2
105+
on a_p2.parameter_code = a_ll.attribute_parameter_code
106+
left join cwms_base_parameter c_bp2
107+
on c_bp2.base_parameter_code = a_p2.base_parameter_code
108+
left join cwms_parameter_type c_pt2
109+
on c_pt2.parameter_type_code = a_ll.attribute_parameter_type_code
110+
left join cwms_duration c_d2
111+
on c_d2.duration_code = a_ll.attribute_duration_code
112+
union all
113+
/* ===========================
114+
* VIRTUAL LOCATION LEVELS
115+
* =========================== */
116+
select
117+
c_o.office_id,
118+
(dash(a_bl.base_location_id, a_pl.sub_location_id) || '.' || dash(c_bp1.base_parameter_id, a_p1.sub_parameter_id) || '.' || c_pt1.parameter_type_id || '.' || c_d1.duration_id || '.' || a_sl.specified_level_id) as location_level_id,
119+
(dash(c_bp2.base_parameter_id, a_p2.sub_parameter_id) || substr ('.', 1, length (c_pt2.parameter_type_id)) || c_pt2.parameter_type_id || substr ('.', 1, length (c_d2.duration_id)) || c_d2.duration_id) as attribute_id,
120+
v_ll.location_level_code,
121+
v_ll.effective_date as location_level_date,
122+
v_ll.expiration_date,
123+
a_bl.base_location_id,
124+
a_pl.sub_location_id,
125+
dash(a_bl.base_location_id, a_pl.sub_location_id) as location_id,
126+
v_ll.location_code,
127+
c_bp1.base_parameter_id,
128+
a_p1.sub_parameter_id,
129+
dash(c_bp1.base_parameter_id, a_p1.sub_parameter_id) as parameter_id,
130+
c_pt1.parameter_type_id,
131+
v_ll.location_level_comment,
132+
c_d1.duration_id,
133+
a_sl.specified_level_id,
134+
dash(c_bp2.base_parameter_id, a_p2.sub_parameter_id) as parameter_id,
135+
c_bp2.base_parameter_id as attribute_base_parameter_id,
136+
a_p2.sub_parameter_id as attribute_sub_parameter_id,
137+
c_pt2.parameter_type_id as attribute_parameter_type_id,
138+
c_d2.duration_id as attribute_duration_id
139+
from
140+
at_virtual_location_level v_ll
141+
join at_physical_location a_pl
142+
on a_pl.location_code = v_ll.location_code
143+
join at_base_location a_bl
144+
on a_bl.base_location_code = a_pl.base_location_code
145+
join cwms_office c_o
146+
on c_o.office_code = a_bl.db_office_code
147+
join at_specified_level a_sl
148+
on a_sl.specified_level_code = v_ll.specified_level_code
149+
join cwms_duration c_d1
150+
on c_d1.duration_code = v_ll.duration_code
151+
join cwms_parameter_type c_pt1
152+
on c_pt1.parameter_type_code = v_ll.parameter_type_code
153+
join at_parameter a_p1
154+
on a_p1.parameter_code = v_ll.parameter_code
155+
join cwms_base_parameter c_bp1
156+
on c_bp1.base_parameter_code = a_p1.base_parameter_code
157+
left join at_parameter a_p2
158+
on a_p2.parameter_code = v_ll.attribute_parameter_code
159+
left join cwms_base_parameter c_bp2
160+
on c_bp2.base_parameter_code = a_p2.base_parameter_code
161+
left join cwms_parameter_type c_pt2
162+
on c_pt2.parameter_type_code = v_ll.attribute_parameter_type_code
163+
left join cwms_duration c_d2
164+
on c_d2.duration_code = v_ll.attribute_duration_code;
165+
/
166+
begin
167+
execute immediate 'grant select on av_location_level_ref to cwms_user';
168+
exception
169+
when others then null;
170+
end;
171+
/
172+
create or replace public synonym cwms_v_location_level_ref for av_location_level_ref;
173+
/

0 commit comments

Comments
 (0)