Visualisierungsmodul für SuperX http://www.superx-projekt.de/doku/viz_modul/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

505 lines
13 KiB

171^VIZ-Makros^<#macro create_temp_tables>\
\
CREATE temp TABLE tmp_viz_property_renderer\
(\
tid serial NOT NULL,\
renderer_id integer NOT NULL,\
property_id integer NOT NULL,\
variable_name varchar(255)\
);\
\
\
CREATE temp TABLE tmp_viz_property\
(\
tid integer,\
caption varchar(255),\
prop_uniquename varchar(255),\
prop_default varchar(255),\
prop_unit varchar(255),\
is_generic smallint DEFAULT 1,\
static_values text,\
is_mandatory smallint DEFAULT 0,\
input_type_id integer DEFAULT 1,\
input_type_uniquename varchar(255),\
property_group_id integer,\
property_group_uniquename varchar(255),\
property_group_variable_name varchar(255),\
explanation text,\
sortnr integer,\
range_from integer,\
range_to integer,\
prop_value_type varchar(255) DEFAULT 'STRING'::character varying,\
variable_name varchar(255),\
parent_property_uniquename varchar(255)\
\
);\
\
create temp table tmp_viz_property_tree_node(\
tid SERIAL not null, \
viz_type_id INTEGER , \
property_id INTEGER , \
parent_property_uniquename varchar(255),\
parent_property_id INTEGER , \
sortnr SMALLINT default 0 , \
is_mandatory SMALLINT default 0 \
\
) \
;\
\
CREATE temp TABLE tmp_viz_type\
(\
tid INTEGER ,\
uniquename varchar(255) NOT NULL,\
caption varchar(255),\
renderer_id integer,\
srcpath varchar(255),\
method varchar(255),\
orientation char(1),\
description text,\
explanation text\
);\
\
CREATE temp TABLE tmp_viz_type_property\
(\
tid serial NOT NULL,\
viz_type_id integer,\
viz_property_id integer,\
is_mandatory smallint DEFAULT 0,\
sortnr smallint DEFAULT 0\
);\
</#macro>\
\
<#macro drop_temp_tables>\
\
drop table if exists tmp_viz_property;\
drop table if exists tmp_viz_property_renderer;\
drop table if exists tmp_viz_property_tree_node;\
drop table if exists tmp_viz_type;\
drop table if exists tmp_viz_type_property;\
\
</#macro>\
\
\
<#macro fill_viz_properties>\
\
\
<#assign sortnr=0 />\
<#foreach viz_prop in viz_properties>\
<#assign sortnr=sortnr+100 />\
insert into tmp_viz_property(tid,\
caption,\
prop_uniquename,\
prop_default,\
prop_unit,\
is_generic,\
static_values,\
is_mandatory,\
input_type_uniquename,\
property_group_uniquename,\
explanation,\
sortnr,\
range_from,\
range_to,\
prop_value_type,\
variable_name,\
parent_property_uniquename)\
select P.tid,\
'${viz_prop.caption}',\
'${viz_prop.prop_uniquename}',\
'${viz_prop.prop_default}',\
'${viz_prop.prop_unit}',\
${viz_prop.is_generic},\
'${viz_prop.static_values}',\
${viz_prop.is_mandatory},\
'${viz_prop.input_type_uniquename}',\
<#if viz_prop.property_group_uniquename?exists> '${viz_prop.property_group_uniquename}' <#else>''</#if>,\
'${viz_prop.explanation}',\
${sortnr},\
val('${viz_prop.range_from}'),\
val('${viz_prop.range_to}'),\
'${viz_prop.prop_value_type}',\
<#if viz_prop.variable_name?exists>\
'${viz_prop.variable_name}',\
<#else>\
'',\
</#if>\
'${viz_prop.parent_property_uniquename}' as parent_prop_uniquename\
from xdummy left outer join viz_property P\
on (P.prop_uniquename='${viz_prop.prop_uniquename}')\
;\
</#foreach>\
update tmp_viz_property set input_type_id=T.tid\
from viz_property_input_type T\
where T.uniquename=tmp_viz_property.input_type_uniquename;\
\
select 'Warnung: Property ohne input_type: ' || prop_uniquename\
from tmp_viz_property\
where input_type_id is null;\
\
update tmp_viz_property set property_group_id=T.tid\
from viz_property_group T\
where T.uniquename=tmp_viz_property.property_group_uniquename;\
\
\
--neue Datensätze:\
insert into viz_property(\
caption,\
prop_uniquename,\
prop_default,\
prop_unit,\
is_generic,\
static_values,\
is_mandatory,\
input_type_id,\
property_group_id,\
explanation,\
sortnr,\
range_from,\
range_to,\
prop_value_type)\
select \
caption,\
prop_uniquename,\
prop_default,\
prop_unit,\
is_generic,\
static_values,\
is_mandatory,\
input_type_id,\
property_group_id,\
explanation,\
sortnr,\
range_from,\
range_to,\
prop_value_type\
from tmp_viz_property P\
where P.tid is null;\
\
update viz_property \
set caption=T.caption,\
--prop_uniquename,\
prop_default=T.prop_default,\
prop_unit=T.prop_unit,\
is_generic=T.is_generic,\
static_values=T.static_values,\
is_mandatory=T.is_mandatory,\
input_type_id=T.input_type_id,\
property_group_id=T.property_group_id,\
explanation=T.explanation,\
sortnr=T.sortnr,\
range_from=T.range_from,\
range_to=T.range_to,\
prop_value_type=T.prop_value_type\
from tmp_viz_property T\
where T.tid=viz_property.tid\
and viz_property.tid in (select T.tid from tmp_viz_property T);\
\
\
--renderer: \
delete from viz_property_renderer\
where (renderer_id, property_id)\
in (select ${renderer},P.tid\
from viz_property P, tmp_viz_property T\
where P.prop_uniquename=T.prop_uniquename);\
\
select sp_update_sequence('viz_property_renderer');\
\
insert into viz_property_renderer(\
renderer_id,\
property_id,\
variable_name)\
select ${renderer},\
P.tid,\
case when T.variable_name !='' then T.variable_name else P.prop_uniquename end\
from viz_property P, tmp_viz_property T\
where P.prop_uniquename=T.prop_uniquename;\
\
\
--Hierarchie:\
insert into tmp_viz_property_tree_node(\
property_id,\
parent_property_uniquename,\
--parent_property_id,\
sortnr,\
is_mandatory)\
select P.tid as property_id,\
T.parent_property_uniquename,\
--parent_property_id,\
T.sortnr,\
T.is_mandatory\
from tmp_viz_property T, viz_property P\
where P.prop_uniquename=T.prop_uniquename\
; \
update tmp_viz_property_tree_node set parent_property_id=(select P.tid\
from viz_property P\
where P.prop_uniquename=tmp_viz_property_tree_node.parent_property_uniquename)\
;\
\
delete from viz_property_tree_node\
where renderer_id=${renderer};\
\
insert into viz_property_tree_node( renderer_id,\
property_id,\
parent_property_id,\
sortnr,\
is_mandatory)\
select ${renderer},\
T.property_id,\
T.parent_property_id,\
T.sortnr,\
T.is_mandatory\
from tmp_viz_property_tree_node T; \
\
\
</#macro>\
\
<#macro fill_viz_types viz_type_p>\
select 'Befülle Grafikelement ${viz_type_p.caption}' from xdummy;\
\
delete from tmp_viz_type;\
\
insert into tmp_viz_type(tid,\
uniquename,\
caption,\
renderer_id,\
-- srcpath,\
-- method,\
orientation,\
explanation)\
select T.tid,\
'${viz_type_p.uniquename}',\
'${viz_type_p.caption}',\
${renderer},\
'${viz_type_p.orientation}',\
'${viz_type_p.explanation}'\
from xdummy left outer join viz_type T on (\
T.uniquename='${viz_type_p.uniquename}'\
and T.renderer_id=${renderer}\
)\
;\
\
insert into viz_type(\
uniquename,\
caption,\
renderer_id,\
-- srcpath,\
-- method,\
orientation)\
select uniquename,\
caption,\
renderer_id,\
-- srcpath,\
-- method,\
orientation\
from tmp_viz_type T\
where T.tid is null;\
\
\
\
update viz_type set \
uniquename=T.uniquename,\
caption=T.caption,\
renderer_id=T.renderer_id,\
-- srcpath,\
-- method,\
orientation=T.orientation,\
explanation=T.explanation\
from tmp_viz_type T\
where T.tid=viz_type.tid\
and viz_type.tid in (select distinct T.tid from tmp_viz_type);\
\
\
</#macro>\
\
<#macro fill_viz_type_properties viz_type_p>\
\
delete from viz_type_property\
where (viz_type_id)\
in (select Y.tid as viz_type_id\
from viz_type Y\
where Y.uniquename='${viz_type_p.uniquename}'\
and Y.renderer_id=${renderer}) ;\
\
<#assign sortnr=1 />\
\
<#foreach viz_prop in viz_type_properties>\
\
<#assign sortnr=sortnr +10 />\
\
\
insert into viz_type_property(\
viz_type_id,\
viz_property_id,\
is_mandatory,\
sortnr)\
select Y.tid as viz_type_id,\
P.tid as viz_property_id,\
<#if viz_prop.is_mandatory?exists > ${viz_prop.is_mandatory} <#else> 0</#if>,\
${sortnr}\
from viz_type Y, viz_property P\
where Y.uniquename='${viz_type_p.uniquename}'\
and Y.renderer_id=${renderer}\
and P.prop_uniquename='${viz_prop.viz_property_uniquename}'\
;\
</#foreach>\
\
</#macro>\
\
\
<#macro viz_dashboard_fuellen>\
insert into tmp_dashboard ( uniquename,\
caption,\
maskeninfo_id,\
booklet_stylesheet,\
gridtitle_felderinfo_id)\
select '${viz_dashboard.uniquename}',\
'${viz_dashboard.caption}',\
${viz_dashboard.maskeninfo_id},\
'${viz_dashboard.booklet_stylesheet}',\
${viz_dashboard.gridtitle_felderinfo_id}\
from xdummy;\
\
update tmp_dashboard T set tid=(select D.tid\
from viz_dashboard D\
where D.uniquename=T.uniquename);\
\
update viz_dashboard D set caption=T.caption,\
maskeninfo_id=T.maskeninfo_id,\
booklet_stylesheet=T.booklet_stylesheet,\
gridtitle_felderinfo_id=T.gridtitle_felderinfo_id\
from tmp_dashboard T\
where T.tid=D.tid;\
insert into viz_dashboard ( uniquename,\
caption,\
maskeninfo_id,\
booklet_stylesheet,\
gridtitle_felderinfo_id)\
select uniquename,\
caption,\
maskeninfo_id,\
booklet_stylesheet,\
gridtitle_felderinfo_id\
from tmp_dashboard T\
where T.tid is null;\
update tmp_dashboard T set tid=(select D.tid\
from viz_dashboard D\
where D.uniquename=T.uniquename)\
where T.tid is null;\
\
delete from viz_dashboard_tab\
where dashboard_id in (select T.tid\
from tmp_dashboard T);\
delete from viz_dashboard_element\
where dashboard_id in (select T.tid\
from tmp_dashboard T);\
\
\
<#foreach tab in viz_dashboard_tabs>\
insert into viz_dashboard_tab(dashboard_id,\
caption,\
maskeninfo_id,\
sortnr,\
select_clause,\
fact_table,\
where_clause,\
optional_filter_name,\
optional_filter_value,\
booklet_stylesheet)\
select\
T.tid as dashboard_id,\
'${tab.caption}' as caption,\
${tab.maskeninfo_id},\
${tab.sortnr},\
'${tab.select_clause}',\
'${tab.fact_table}',\
'${tab.where_clause}',\
'${tab.optional_filter_name}',\
'${tab.optional_filter_value}',\
'${tab.booklet_stylesheet}'\
from tmp_dashboard T;\
\
</#foreach>\
<#foreach elem in viz_dashboard_elements>\
insert into viz_dashboard_element(dashboard_id,\
datasource_type,\
datasource,\
chart_id,\
onclick_event,\
sortnr,\
caption,\
open_modal_card_detail,\
link_maskennummer,\
link_chart_uniquename,\
link_tablestylesheet, \
active)\
select\
T.tid as dashboard_id,\
${elem.datasource_type},\
'${elem.datasource}',\
V.tid as chart_id,\
'${elem.onclick_event}',\
${elem.sortnr},\
'${elem.caption}',\
${open_modal_card_detail},\
V.maskeninfo_id as link_maskennummer,\
V.uniquename as link_chart_uniquename,\
'${link_tablestylesheet}',\
${elem.active}\
from tmp_dashboard T, viz_chart V\
where V.uniquename='${elem.chart_uniquename}';\
\
</#foreach>\
</#macro>\
\
<#macro create_temp_tables_dashboard>\
\
create temp table tmp_dashboard(\
tid integer, \
uniquename VARCHAR(255) not null, \
caption VARCHAR(255) , \
maskeninfo_id INTEGER , \
booklet_stylesheet VARCHAR(255) , \
gridtitle_felderinfo_id INTEGER \
\
) \
;\
create temp table tmp_dashboard_tab(\
\
dashboard_id INTEGER not null, \
caption VARCHAR(255) , \
maskeninfo_id INTEGER , \
sortnr SMALLINT default 0 , \
select_clause VARCHAR(255) , \
fact_table VARCHAR(255) , \
where_clause TEXT , \
optional_filter_name VARCHAR(255) , \
optional_filter_value VARCHAR(255) , \
booklet_stylesheet VARCHAR(255) \
\
) \
;\
\
create temp table tmp_dashboard_element(\
dashboard_id INTEGER not null, \
datasource_type INTEGER default 1 , \
datasource VARCHAR(255) , \
chart_id INTEGER , \
onclick_event VARCHAR(255) , \
sortnr SMALLINT default 0 , \
caption VARCHAR(255) , \
open_modal_card_detail SMALLINT default 1 , \
link_maskennummer INTEGER , \
link_chart_uniquename VARCHAR(255) , \
link_tablestylesheet VARCHAR(255) , \
active SMALLINT default 1 not null\
) \
;\
\
</#macro>\
\
<#macro drop_temp_tables_dashboard>\
drop table if exists tmp_dashboard;\
drop table if exists tmp_dashboard_tab;\
drop table if exists tmp_dashboard_element;\
\
</#macro>^Makros zum Umgang mit Visualisierungen^ ^1^