Datenwürfel für SuperX
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.

230 lines
12 KiB

--Freemarker Template
-- TableFieldExists wird genutzt, um zu prüfen, ob die entsprechende Tabelle existiert
<#if TableFieldExists('aggregierung','ord')>
delete from xcube_dims where id='jahr';
insert into xcube_dims (id, name,apnr,sort1)
select distinct 'jahr',ord::char(6),ord::char(6),ord from aggregierung where kategorie like '%-Jahr%';
delete from xcube_dims where id='cob_jahr';
insert into xcube_dims (id, name,apnr,sort1)
select distinct 'cob_jahr',ord::char(6),ord::char(6),ord from aggregierung where kategorie='COB-Jahr';
</#if>
delete from xcube_dims where id='monat';
INSERT INTO xcube_dims (id,apnr,name,sort1) values
('monat','1','Januar',1),
('monat','2','Februar',2),
('monat','3','März',3),
('monat','4','April',4),
('monat','5','Mai',5),
('monat','6','Juni',6),
('monat','7','Juli',7),
('monat','8','August',8),
('monat','9','September',9),
('monat','10','Oktober',10),
('monat','11','November',11),
('monat','12','Dezember',12);
--TODO: zerlegen in modulweise Dateien
-- priorität: semester, zul_semester, kenn_semester
<#if TableFieldExists('semester','eintrag')>
delete from xcube_dims where id='semester';
insert into xcube_dims (id, name,apnr,sort1)
select 'semester',eintrag ,tid::varchar(50),tid from semester
where tid in (select distinct sem_rueck_beur_ein from sos_stg_aggr);
<#elseif TableFieldExists('zul_semester','eintrag')>
delete from xcube_dims where id='semester';
insert into xcube_dims (id, apnr,sort1)
select 'semester',eintrag ,tid::varchar(50),tid from zul_semester;
<#elseif TableFieldExists('kenn_semester','eintrag')>
delete from xcube_dims where id='semester';
insert into xcube_dims (id, apnr,sort1)
select 'semester',druck ,tid::varchar(50),tid from kenn_semester;
</#if>
<#if TableFieldExists('sos_stg_aggr','fach_sem_zahl')>
delete from xcube_dims where id='fssemzahl';
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'fssemzahl',fach_sem_zahl::varchar(10),fach_sem_zahl||'.FS',fach_sem_zahl from sos_stg_aggr
where fach_sem_zahl <= 10;
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'fssemzahl', '99','FS>10',99 from sos_stg_aggr where fach_sem_zahl>10;
</#if>
<#if TableFieldExists('sos_stg_aggr','hssem')>
delete from xcube_dims where id='hssem';
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'hssemzahl',hssem::varchar(10),hssem||'.HS',hssem from sos_stg_aggr
where hssem <= 10;
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'hssemzahl', '999','HS>10',99 from sos_stg_aggr where hssem>10;
</#if>
<#if TableFieldExists('sos_stg_aggr','hzbart')>
delete from xcube_dims where id='hzbart';
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'hzbart',tid::varchar(10),eintrag,tid from hs_zugangsber;
</#if>
<#if TableFieldExists('sos_stg_aggr','alter')>
delete from xcube_dims where id='alter';
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
values
('alter','gesamt',null,'alle','1=1',1),
('alter', 'a1', 'gesamt', '<20 Jahre','$1::numeric(14,2)<20.00',10),
('alter', 'a2', 'gesamt','20-24 Jahre','$1::numeric(14,2)>=20.00 and $1::numeric(14,2)<25.00',20),
('alter', 'a3', 'gesamt','25-29 Jahre','$1::numeric(14,2)>=25.00 and $1::numeric(14,2)<30.00',30),
('alter', 'a4', 'gesamt','30-34 Jahre','$1::numeric(14,2)>=30.00 and $1::numeric(14,2)<35.00',40),
('alter', 'a5', 'gesamt','35-39 Jahre','$1::numeric(14,2)>=35.00 and $1::numeric(14,2)<40.00',50),
('alter', 'a6', 'gesamt','40-44 Jahre','$1::numeric(14,2)>=40.00 and $1::numeric(14,2)<45.00',60),
('alter', 'a7', 'gesamt','45-49 Jahre','$1::numeric(14,2)>=45.00 and $1::numeric(14,2)<50.00',70),
('alter', 'a8', 'gesamt','50-54 Jahre','$1::numeric(14,2)>=50.00 and $1::numeric(14,2)<55.00',80),
('alter', 'a9', 'gesamt','55-59 Jahre','$1::numeric(14,2)>=55.00 and $1::numeric(14,2)<60.00',90),
('alter', 'a99', 'gesamt','>=60 Jahre','$1::numeric(14,2)>=60.00',100);
</#if>
delete from xcube_dims where id='alter1';
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
values
('alter1','gesamt',null,'alle','1=1',1),
('alter1', 'b2', 'gesamt','16-17 Jahre','$1::numeric(14,2)>=16.00 and $1::numeric(14,2)<18.00',20),
('alter1', 'b3', 'gesamt','18-20 Jahre','$1::numeric(14,2)>=18.00 and $1::numeric(14,2)<21.00',30),
('alter1', 'b4', 'gesamt','21-24 Jahre','$1::numeric(14,2)>=21.00 and $1::numeric(14,2)<25.00',40),
('alter1', 'b5', 'gesamt','25-29 Jahre','$1::numeric(14,2)>=25.00 and $1::numeric(14,2)<30.00',50),
('alter1', 'b6', 'gesamt','30-39 Jahre','$1::numeric(14,2)>=30.00 and $1::numeric(14,2)<40.00',60),
('alter1', 'b7', 'gesamt','40-49 Jahre','$1::numeric(14,2)>=40.00 and $1::numeric(14,2)<50.00',70),
('alter1', 'b8', 'gesamt','50-54 Jahre','$1::numeric(14,2)>=50.00 and $1::numeric(14,2)<55.00',80),
('alter1', 'b9', 'gesamt','55-60 Jahre','$1::numeric(14,2)>=55.00 and $1::numeric(14,2)<61.00',90),
('alter1', 'b90', 'gesamt','61 Jahre','$1::numeric(14,2)>=61.00 and $1::numeric(14,2)<62.00',91),
('alter1', 'b91', 'gesamt','62 Jahre','$1::numeric(14,2)>=62.00 and $1::numeric(14,2)<63.00',92),
('alter1', 'b92', 'gesamt','63 Jahre','$1::numeric(14,2)>=63.00 and $1::numeric(14,2)<64.00',93),
('alter1', 'b93', 'gesamt','64 Jahre','$1::numeric(14,2)>=64.00 and $1::numeric(14,2)<65.00',94),
('alter1', 'b94', 'gesamt','65 Jahre','$1::numeric(14,2)>=65.00 and $1::numeric(14,2)<66.00',95),
('alter1', 'b95', 'gesamt','66 Jahre','$1::numeric(14,2)>=66.00 and $1::numeric(14,2)<67.00',96),
('alter1', 'b96', 'gesamt','67 Jahre','$1::numeric(14,2)>=67.00 and $1::numeric(14,2)<68.00',97),
('alter1', 'b99', 'gesamt','>=68 Jahre','$1::numeric(14,2)>=68.00',100);
<#list 16..17 as i>
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
select 'alter1', ${i}::char(10), 'b2', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i} from xdummy;
</#list>
<#list 18..20 as i>
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
select 'alter1', ${i}::char(10), 'b3', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i} from xdummy;
</#list>
<#list 21..24 as i>
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
select 'alter1', ${i}::char(10), 'b4', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i} from xdummy;
</#list>
<#list 25..29 as i>
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
select 'alter1', ${i}::char(10), 'b5', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i} from xdummy;
</#list>
<#list 30..39 as i>
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
select 'alter1', ${i}::char(10), 'b6', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i} from xdummy;
</#list>
<#list 40..49 as i>
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
select 'alter1', ${i}::char(10), 'b7', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i} from xdummy;
</#list>
<#list 50..54 as i>
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
select 'alter1', ${i}::char(10), 'b8', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i} from xdummy;
</#list>
<#list 55..60 as i>
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
select 'alter1', ${i}::char(10), 'b9', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i} from xdummy;
</#list>
delete from xcube_dims where id='alter3';
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
values
('alter3','gesamt',null,'alle','1=1',1);
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1) values
<#list 16..67 as i>
('alter3', ${i}::char(10), 'gesamt', ${i}::char(2) || ' Jahre' , '$1::numeric(14,2)>=${i}::numeric(14,2) and $1::numeric(14,2)<${i+1}::numeric(14,2)', ${i}),
</#list>
('alter3', '68', 'gesamt','68 Jahre','$1::numeric(14,2)>=68.00',100);
<#if TableFieldExists('sos_stg_aggr','ch27_grund_beurl')>
delete from xcube_dims where id='ch27_grund_beurl';
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'ch27_grund_beurl',apnr,druck,1 from cifx where key=27;
</#if>
<#if TableFieldExists('sos_stg_aggr','aktiv')>
delete from xcube_dims where id='aktiv';
INSERT INTO xcube_dims (id,apnr,name,sort1)
select 'aktiv',0::varchar(10),'inaktiv',2 from xdummy union select 'aktiv',1::varchar(10),'aktiv',1 from xdummy;
</#if>
<#if TableFieldExists('sos_stg_aggr','hzbart_int')>
delete from xcube_dims where id='hzbart_int';
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'hzbart_int',hzbart,dtxt,1 from k_hzbart;
</#if>
<#if TableFieldExists('sos_stg_aggr','hzbnote')>
delete from xcube_dims where id='hzbnote';
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
values
('hzbnote','gesamt',null,'alle','1=1',1),
('hzbnote', 'a1', 'gesamt','Sehr gut <=1,0','$1::numeric(5,2)>=0.00 and $1::numeric(5,2)<=1.00',10),
('hzbnote', 'a2', 'gesamt','Sehr gut 1,1-1,5','$1::numeric(5,2)>1.00 and $1::numeric(5,2)<=1.50',20),
('hzbnote', 'a3', 'gesamt','gut 1,6-2,0','$1::numeric(5,2)>1.50 and $1::numeric(5,2)<=2.00',30),
('hzbnote', 'a4', 'gesamt','gut 2,1-2,5','$1::numeric(5,2)>2.00 and $1::numeric(5,2)<=2.50',40),
('hzbnote', 'a5', 'gesamt','befriedigend 2,6-3,0','$1::numeric(5,2)>2.50 and $1::numeric(5,2)<=3.00',50),
('hzbnote', 'a6', 'gesamt','befriedigend 2,6-3,0','$1::numeric(5,2)>3.00 and $1::numeric(5,2)<=3.50',60),
('hzbnote', 'a7', 'gesamt','ausreichend 3,6-4,5','$1::numeric(5,2)>3.500 and $1::numeric(5,2)<=4.50',70),
('hzbnote', 'a8', 'gesamt','Note unbekannt','$1::numeric(5,2)<0.00 or $1::numeric(5,2)>4.50',80);
</#if>
--wäre eine Möglichkeit, die Werte aus der cifx zu überschreiben. Ist aber nicht notwendig, der Quatsch steht schon
--in dim_studiengang und lehr_stg_ab
--delete from xcube_dims where id='fb';
--INSERT INTO xcube_dims (id,apnr,name,sort1)
--select 'fb',key_apnr,name,0 from organigramm where orgstruktur=20
--and today() between gueltig_seit and gueltig_bis;
--in der cifx stehen unter key=110 alle Institutionen, nicht nur lehreinheiten
delete from xcube_dims where id='lehr';
INSERT INTO xcube_dims (id,apnr,name,sort1)
select 'lehr',key_apnr,name,0 from organigramm where orgstruktur=30
and today() between gueltig_seit and gueltig_bis;
<#if TableFieldExists('sos_lab_aggr','note')>
delete from xcube_dims where id='note';
INSERT INTO xcube_dims (id,apnr,parent, name,strukturstr,sort1)
values
('note','gesamt',null,'alle','1=1',1),
('note', 'a1', 'gesamt','Sehr gut <=1,0','$1::numeric(5,2)>=0.00 and $1::numeric(5,2)<=1.00',10),
('note', 'a2', 'gesamt','Sehr gut 1,1-1,5','$1::numeric(5,2)>1.00 and $1::numeric(5,2)<=1.50',20),
('note', 'a3', 'gesamt','gut 1,6-2,0','$1::numeric(5,2)>1.50 and $1::numeric(5,2)<=2.00',30),
('note', 'a4', 'gesamt','gut 2,1-2,5','$1::numeric(5,2)>2.00 and $1::numeric(5,2)<=2.50',40),
('note', 'a5', 'gesamt','befriedigend 2,6-3,0','$1::numeric(5,2)>2.50 and $1::numeric(5,2)<=3.00',50),
('note', 'a6', 'gesamt','befriedigend 2,6-3,0','$1::numeric(5,2)>3.00 and $1::numeric(5,2)<=3.50',60),
('note', 'a7', 'gesamt','ausreichend 3,6-4,5','$1::numeric(5,2)>3.500 and $1::numeric(5,2)<=4.50',70),
('note', 'a8', 'gesamt','Note unbekannt','$1::numeric(5,2)<0.00 or $1::numeric(5,2)>4.50',80);
</#if>
delete from xcube_dims where id='dauer_rsz';
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'dauer_rsz',(-1)::varchar(10),'Stud.Dauer schneller als RSZ',-1 from xdummy;
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'dauer_rsz',0::varchar(10),'Stud.Dauer in RSZ',0 from xdummy;
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'dauer_rsz',1::varchar(10),'Stud.Dauer in RSZ + 1',1 from xdummy;
INSERT INTO xcube_dims (id,apnr,name,sort1)
select distinct 'dauer_rsz',2::varchar(10),'>= Stud.Dauer in RSZ + 2',2 from xdummy;
--Zum Testen
--INSERT INTO xcube_dims (id,apnr,name,sort1,parent,strukturstr)
--VALUES
-- -('fs4','0','FS<4',1,NULL,NULL),
-- ('fs4','1','FS>=4',2,NULL,NULL);