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.
346 lines
8.7 KiB
346 lines
8.7 KiB
97^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);\ |
|
\ |
|
\ |
|
\ |
|
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>^Makros zum Umgang mit Visualisierungen^ ^1^
|
|
|