This commit is contained in:
Christian Paminger
2009-05-05 15:48:46 +00:00
parent 7ec38552fb
commit 1455dccb10
5 changed files with 186652 additions and 0 deletions
+140282
View File
File diff suppressed because it is too large Load Diff
+293
View File
@@ -0,0 +1,293 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2><xsl:value-of select="MODEL/PROPERTIES/PROJECTNAME"/> Database to PHP Array</h2>
<pre><code>
&lt;?php
$datatypes=array
(
<xsl:for-each select="PERModelPG83/UserDataTypes/PERUserDataTypePG83">
'<xsl:value-of select="Id"/>' => array
(
"id" => "<xsl:value-of select="Id"/>" ,
"name" => "<xsl:value-of select="Name"/>" ,
"caption" => "<xsl:value-of select="Caption"/>" ,
"length" => "<xsl:value-of select="InternalLength"/>" ,
"default" => "<xsl:value-of select="Default"/>" ,
"comments" => "<xsl:value-of select="Comments"/>" ,
"ordinal" => "<xsl:value-of select="Ordinal"/>"
),
</xsl:for-each>
);
$schemas=array
(
<xsl:for-each select="PERModelPG83/Schemas/PERSchemaPG83">
'<xsl:value-of select="Id"/>' => array
(
"id" => "<xsl:value-of select="Id"/>" ,
"name" => "<xsl:value-of select="Name"/>" ,
"caption" => "<xsl:value-of select="Caption"/>" ,
"comments" => "<xsl:value-of select="Comments"/>" ,
"ordinal" => "<xsl:value-of select="Ordinal"/>"
),
</xsl:for-each>
);
$tabellen=array
(
<xsl:for-each select="PERModelPG83/Entities/PEREntityPG83">
'<xsl:value-of select="Id"/>' => array
(
"id" => "<xsl:value-of select="Id"/>" ,
"name" => "<xsl:value-of select="Name"/>" ,
"caption" => "<xsl:value-of select="Caption"/>" ,
"comments" => "<xsl:value-of select="Comments"/>" ,
"storage" => "<xsl:value-of select="STORAGE"/>" ,
"schemaid" => "<xsl:value-of select="Schema/Id"/>" ,
"attribute" => array
(
<xsl:for-each select="Attributes/PERAttributePG83">
'<xsl:value-of select="Id"/>' => array
(
"id" => "<xsl:value-of select="Id"/>" ,
"name" => "<xsl:value-of select="Name"/>" ,
"caption" => "<xsl:value-of select="Caption"/>" ,
"ordinal" => "<xsl:value-of select="Ordinal"/>" ,
"pk" => "<xsl:value-of select="PKForeignKeys/Id"/>" ,
"datatypeid" => "<xsl:value-of select="DataType/Id"/><xsl:value-of select="UserDataType/Id"/>" ,
"datatypeparam1" => "<xsl:value-of select="DataTypeParam1"/>" ,
"datatypeparam2" => "<xsl:value-of select="DataTypeParam2"/>" ,
"length" => "<xsl:value-of select="DataTypeParam1"/>",
"unique" => "<xsl:value-of select="Unique"/>",
"notnull" => "<xsl:value-of select="NotNull"/>",
"defaultvalue" => "<xsl:value-of select="DefaultValue"/>",
"checkconstraintname" => "<xsl:value-of select="CheckConstraintName"/>",
"checkconstraint" => "<xsl:value-of select="CheckConstraint"/>",
"description" => "<xsl:value-of select="DESCRIPTION"/>"
),
</xsl:for-each>
),
"keyconstraint" => array
(
<xsl:for-each select="Keys/PERKeyConstraintPG83">
'<xsl:value-of select="Id"/>' => array
(
"id" => "<xsl:value-of select="Id"/>" ,
"name" => "<xsl:value-of select="Name"/>" ,
"caption" => "<xsl:value-of select="Caption"/>" ,
"ordinal" => "<xsl:value-of select="Ordinal"/>" ,
"comments" => "<xsl:value-of select="Comments"/>" ,
"keyconstraintitem" => array
(
<xsl:for-each select="KeyItems/PERKeyConstraintItemPG83">
'<xsl:value-of select="Id"/>' => array
(
"id" => "<xsl:value-of select="Id"/>" ,
"name" => "<xsl:value-of select="Name"/>" ,
"caption" => "<xsl:value-of select="Caption"/>" ,
"ordinal" => "<xsl:value-of select="Ordinal"/>" ,
"comments" => "<xsl:value-of select="Comments"/>" ,
"description" => "<xsl:value-of select="DESCRIPTION"/>",
"attribute" => array
(
<xsl:for-each select="Attribute/Id">"id" => "<xsl:value-of select="."/>",</xsl:for-each>
),
"foreignkeys" => array
(
<xsl:for-each select="ForeignKeys/Id">"id" => "<xsl:value-of select="."/>",</xsl:for-each>
)
),
</xsl:for-each>
),
),
</xsl:for-each>
),
),
</xsl:for-each>
);
$relations=array
(
<xsl:for-each select="PERModelPG83/Relations/PERRelationPG83">
'<xsl:value-of select="Id"/>' => array
(
"id" => "<xsl:value-of select="Id"/>" ,
"name" => "<xsl:value-of select="Name"/>" ,
"caption" => "<xsl:value-of select="Caption"/>" ,
"comments" => "<xsl:value-of select="Comments"/>" ,
"notes" => "<xsl:value-of select="Notes"/>",
"identifying" => "<xsl:value-of select="Identifying"/>",
"mandatoryparent" => "<xsl:value-of select="MandatoryParent"/>",
"mandatorychild" => "<xsl:value-of select="MandatoryChild"/>",
"cardinalitychild" => "<xsl:value-of select="CardinalityChild"/>",
"refintegrityparentupdate" => "<xsl:value-of select="RefIntegrityParentUpdate"/>" ,
"refintegrityparentdelete" => "<xsl:value-of select="RefIntegrityParentDelete"/>" ,
"refintegritychildupdate" => "<xsl:value-of select="RefIntegrityChildUpdate"/>" ,
"refintegritychildinsert" => "<xsl:value-of select="RefIntegrityChildInsert"/>" ,
"key" => array
(
<xsl:for-each select="Key/Id">"id" => "<xsl:value-of select="."/>",</xsl:for-each>
),
"foreignkeys" => array
(
<xsl:for-each select="ForeignKeys/PERForeignKeyPG83">
'<xsl:value-of select="Id"/>' => array
(
"id" => "<xsl:value-of select="Id"/>",
"name" => "<xsl:value-of select="Name"/>",
"comments" => "<xsl:value-of select="Comments"/>",
"notes" => "<xsl:value-of select="Notes"/>",
"deferred" => "<xsl:value-of select="Deferred"/>",
"deferrable" => "<xsl:value-of select="Deferrable"/>",
"matchtype" => "<xsl:value-of select="MatchType"/>",
"createindextofk" => "<xsl:value-of select="CreateIndexToFK"/>",
"attrparent" => array
(
<xsl:for-each select="AttrParent/Id">"id" => "<xsl:value-of select="."/>",</xsl:for-each>
),
"attrchild" => array
(
<xsl:for-each select="AttrChild/Id">"id" => "<xsl:value-of select="."/>",</xsl:for-each>
),
"KeyConstraintItem" => array
(
<xsl:for-each select="KeyConstraintItem/Id">"id" => "<xsl:value-of select="."/>",</xsl:for-each>
)
),
</xsl:for-each>
)
),
</xsl:for-each>
);
$datatypes['{ECB8F02F-B683-4252-8508-ED9D064C9AF3}']=array
(
"id" => "{ECB8F02F-B683-4252-8508-ED9D064C9AF3}",
"name" => "Character Varying",
"caption" => "varchar",
"length" => "1",
"default" => "''" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{5F0FB0CB-62A1-4BDC-A4DA-882CACFC296A}']=array
(
"id" => "{5F0FB0CB-62A1-4BDC-A4DA-882CACFC296A}",
"name" => "Serial",
"caption" => "serial",
"length" => "0",
"default" => "0" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{342E3F36-138D-40F7-B1B2-D9489C848835}']=array
(
"id" => "{342E3F36-138D-40F7-B1B2-D9489C848835}",
"name" => "Timestamp",
"caption" => "timestamp",
"length" => "0",
"default" => "0" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{F6C99ABF-677B-48C6-920E-F375B79C336D}']=array
(
"id" => "{F6C99ABF-677B-48C6-920E-F375B79C336D}",
"name" => "Big Integer",
"caption" => "bigint",
"length" => "0",
"default" => "0" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{8D91E2A4-12F5-40E3-BAC2-BFCF7BE1C8B7}']=array
(
"id" => "{8D91E2A4-12F5-40E3-BAC2-BFCF7BE1C8B7}",
"name" => "Text",
"caption" => "text",
"length" => "0",
"default" => "''" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{361EF147-269D-4247-8F7C-5A3876A3999A}']=array
(
"id" => "{361EF147-269D-4247-8F7C-5A3876A3999A}",
"name" => "Integer",
"caption" => "integer",
"length" => "0",
"default" => "0" ,
"comments" => "" ,
"ordinal" => "0"
);
$datatypes['{3AA5E900-D254-4FBD-AD67-AD230407284C}']=array
(
"id" => "{3AA5E900-D254-4FBD-AD67-AD230407284C}",
"name" => "Small Integer",
"caption" => "smallint",
"length" => "0",
"default" => "0" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{D64069A5-B04A-490B-B0A2-5144DEA81A2E}']=array
(
"id" => "{D64069A5-B04A-490B-B0A2-5144DEA81A2E}",
"name" => "Boolean",
"caption" => "boolean",
"length" => "0",
"default" => "true" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{E12D6C2A-E13A-4877-B9C4-AA7BA668C316}']=array
(
"id" => "{E12D6C2A-E13A-4877-B9C4-AA7BA668C316}",
"name" => "Character",
"caption" => "char",
"length" => "1",
"default" => "''" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{5EBD99F4-5263-4410-9892-11DB7C2DF84B}']=array
(
"id" => "{5EBD99F4-5263-4410-9892-11DB7C2DF84B}",
"name" => "Date",
"caption" => "date",
"length" => "0",
"default" => "'1970-01-01'" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['{3DD56C5A-B10A-4E02-8CB2-C7B4880B63DD}']=array
(
"id" => "{3DD56C5A-B10A-4E02-8CB2-C7B4880B63DD}",
"name" => "Time",
"caption" => "time",
"length" => "0",
"default" => "'00:00:00'" ,
"comments" => "",
"ordinal" => "0"
);
$datatypes['']=array
(
"id" => "",
"name" => "",
"caption" => "",
"length" => "0",
"default" => "" ,
"comments" => "",
"ordinal" => "0"
);
?&gt;
</code></pre>
</body>
</html>
</xsl:template>
</xsl:transform>
+45
View File
@@ -0,0 +1,45 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Roadmap</title>
</head>
<body>
<h1>Roadmap FH-Complete</h1>
<br>
<h2>Version 2.0</h2>
<ul>
<li>Erweiterte Architektur mit Basisklasse und DB-Abstraktion<br>
Einsatz von anderen DBMS wie Oracle oder Sybase (MSSQL) wird
m&ouml;glich</li>
<li>Rollenkonzept<br>
Berrechtigungen werden auf Rollen vergeben. Rollen k&ouml;nnen selbst
definiert werden.</li>
<li>Organisationseinheiten<br>
Als Basisstruktur wird eine rekursive Tabelle f&uuml;r
Organisationseinheiten eingef&uuml;hrt. Somit kann jede beliebige
Organisationsstruktur abgebildet werden. Studieng&auml;nge, Institute,
Kostenstellen, etc. werden dann auf OEen geh&auml;ngt.</li>
</ul>
Release: 1. Sept. 2009<br>
<br>
<h2>Version 2.2</h2>
<ul>
<li>einfache Modularchitektur</li>
<li>Projektverwaltungsmodul (F&amp;E BIS-Meldung)<br>
</li>
<li>einfaches mehrsprachiges CMS f&uuml;r CIS</li>
<li>XML/XSLT-Architektur f&uuml;r CIS<br>
</li>
</ul>
Release: 1. Sept. 2010<br>
<h2>Version 2.4</h2>
<ul>
<li>Ausbau LV-Plan (Schnittstellen, evtl. mehrere Zeitraster)<br>
</li>
<li>Integration von eGroupware<br>
</li>
</ul>
Release: 1. Sept. 2011<br>
<br>
</body>
</html>
+211
View File
@@ -0,0 +1,211 @@
<?php
require ('../config.inc.php');
require ('database.inc.php');
// Datenbank Verbindung
//if (!$conn = pg_pconnect("host=localhost dbname=conquearth user=pam password="))
if (!$conn = pg_pconnect(CONN_STRING))
die('Es konnte keine Verbindung zum Server aufgebaut werden!'.pg_last_error($conn));
echo '<H1>Systemcheck!</H1>';
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
//var_dump($datatypes);
$tabs=array_keys($tabellen);
//print_r($tabs);
$i=0;
foreach ($tabellen AS $tabelle)
{
$sql_query2='';
$pk='';
// Tabelle pruefen
//var_dump($tabelle);
$sql_query="SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='".$schemas[$tabelle['schemaid']]['caption']."' AND tablename='".$tabelle['caption']."';";
if (!$result=pg_query($conn,$sql_query))
echo '<BR><strong>'.$tabs[$i].': '.pg_last_error($conn).' </strong><BR>';
else
{
if (pg_num_rows($result)==0)
{
$sql_query= 'CREATE TABLE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption']." (";
foreach ($tabelle['attribute'] AS $attribut)
{
if ($datatypes[$attribut['datatypeid']]['caption']!='geometry')
{
//echo $datatypes[$attribut['datatypeid']]['caption'];
$sql_query.= $attribut['caption'].' ';
if ($attribut['pk'])
$pk.=$attribut['caption'].',';
$sql_query.=$datatypes[$attribut['datatypeid']]['caption'];
if ($datatypes[$attribut['datatypeid']]['length']==1)
$sql_query.='('.$attribut['datatypeparam1'].')';
if ($datatypes[$attribut['datatypeid']]['length']==2)
$sql_query.='('.$attribut['datatypeparam1'].','.$attribut['datatypeparam2'].')';
if ($attribut['notnull'])
$sql_query.=' NOT NULL';
if ($attribut['unique'])
$sql_query.=' UNIQUE';
if ($attribut['defaultvalue']!="")
$sql_query.=' DEFAULT '.$attribut['defaultvalue'];
if ($attribut['checkconstraint']!="")
$sql_query.=' CHECK ('.$attribut['checkconstraint'].')';
$sql_query.=', ';
}
else
$sql_query2.="SELECT AddGeometryColumn('','".$tabelle['caption']."','".$attribut['caption']."',-1,'POINT',2);";
}
$sql_query=substr($sql_query,0,-2);
if ($pk!="")
$sql_query.=', CONSTRAINT "pk_'.$schemas[$tabelle['schemaid']]['caption'].'_'.$tabelle['caption'].'" PRIMARY KEY ('.substr($pk,0,-1).')';
$sql_query.=');';
//echo $sql_query.'<BR>'.$sql_query2;
if (!$res_attr=pg_query($conn,$sql_query.$sql_query2))
echo '<BR><strong>'.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].': '.pg_last_error($conn).' </strong><BR>'.$sql_query.'<BR>'.$sql_query_nn.'<BR>';
else
echo 'Tabelle '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].' wurde erfolgreich angelegt!<BR>';
}
else
{
// Attribute pruefen
foreach ($tabelle['attribute'] AS $attribut)
{
//var_dump($attribut);
$sql_query="SELECT nspname AS schemaname, relname AS tablename, pg_get_userbyid(relowner) AS tableowner, attname AS attribute
FROM pg_catalog.pg_attribute JOIN pg_catalog.pg_class ON (attrelid=relfilenode) JOIN pg_namespace ON (oid=relnamespace)
WHERE relkind='r' AND nspname='".$schemas[$tabelle['schemaid']]['caption']."' AND relname='".$tabelle['caption']."'
AND attname='".$attribut['caption']."'; ";
if (!$res_attr=pg_query($conn,$sql_query))
echo '<BR><strong>'.$attribut['caption'].': '.pg_last_error($conn).' </strong><BR>';
else
if (pg_num_rows($res_attr)==1)
echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].': OK - ';
else if (pg_num_rows($res_attr)==0)
{
$sql_query_nn='';
echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' ist nicht angelegt!<BR>';
$sql_query='ALTER TABLE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'
ADD COLUMN '.$attribut['caption'].' ';
$sql_query.=$datatypes[$attribut['datatypeid']]['caption'];
if ($datatypes[$attribut['datatypeid']]['length']==1)
$sql_query.='('.$attribut['datatypeparam1'].')';
if ($datatypes[$attribut['datatypeid']]['length']==2)
$sql_query.='('.$attribut['datatypeparam1'].','.$attribut['datatypeparam2'].')';
if ($attribut['unique'])
$sql_query.=' UNIQUE';
if ($attribut['defaultvalue']!="")
$sql_query.=' DEFAULT '.$attribut['defaultvalue'];
else
$attribut['defaultvalue']=$datatypes[$attribut['datatypeid']]['default'];
if ($attribut['checkconstraint']!="")
$sql_query.=' CHECK ('.$attribut['checkconstraint'].')';
if ($attribut['notnull'])
{
$sql_query_nn.='UPDATE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'
SET '.$attribut['caption'].'='.$attribut['defaultvalue'].';';
$sql_query_nn.='ALTER TABLE '.$schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'
ALTER COLUMN '.$attribut['caption'].' SET NOT NULL;';
}
$sql_query.=';';
//echo $sql_query;
if (!$res_attr=pg_query($conn,$sql_query.$sql_query_nn))
echo '<BR><strong>'.$attribut['caption'].': '.pg_last_error($conn).' </strong><BR>'.$sql_query.'<BR>'.$sql_query_nn.'<BR>';
else
echo $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'].'.'.$attribut['caption'].' wurde erfolgreich hinzugefuegt!<BR>';
}
}
}
}
flush();
$i++;
}
echo '<H2>Pruefe Constraints!</H2>';
function getTablenameFromAttributIDs($attr)
{
global $tabellen;
global $schemas;
$attributid=null;
foreach ($attr AS $attribut)
$attributid=$attribut;
foreach ($tabellen AS $tabelle)
foreach ($tabelle['attribute'] AS $attribut)
if ($attribut['id']==$attributid)
return $schemas[$tabelle['schemaid']]['caption'].'.'.$tabelle['caption'];
return false;
}
function getAttributesnameFromAttributIDs($attr)
{
global $tabellen;
global $schemas;
$attributes='';
foreach ($attr AS $attributid)
foreach ($tabellen AS $tabelle)
foreach ($tabelle['attribute'] AS $attribute)
if ($attribute['id']==$attributid)
$attributes.=$attribute['caption'].', ';
return substr($attributes,0,-2);
}
//Alter table campus.tbl_paabgabe add Constraint projektarbeit_paabgabe foreign key (projektarbeit_id) references lehre.tbl_projektarbeit (projektarbeit_id) on update cascade on delete restrict;
foreach ($relations AS $relation)
{
$sql_query='';
$pk='';
// Auf Foreign Key pruefen
//var_dump($relation);
if (count($relation['foreignkeys'])>0)
{
foreach ($relation['foreignkeys'] AS $foreignkey)
{
$parenttable=getTablenameFromAttributIDs($foreignkey['attrparent']);
$childtable=getTablenameFromAttributIDs($foreignkey['attrchild']);
$parentattr=getAttributesnameFromAttributIDs($foreignkey['attrparent']);
$childattr=getAttributesnameFromAttributIDs($foreignkey['attrchild']);
//$constrname=str_replace('.','_',);
$sql_query='ALTER TABLE '.$childtable.' ADD CONSTRAINT '.$relation['caption'].' FOREIGN KEY ('.$childattr.') REFERENCES '.$parenttable.' ('.$parentattr.') ';
$sql_query.='ON UPDATE CASCADE ON DELETE RESTRICT;';
//if (refintegritychildupdate)
// $sql_query.='
echo $sql_query.'<BR>';
}
}
flush();
$i++;
}
echo '<H2>Gegenpruefung!</H2>';
$sql_query="SELECT schemaname,tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema' AND schemaname != 'sync' AND schemaname != 'papaya';";
if (!$result=@pg_query($conn,$sql_query))
echo '<BR><strong>'.pg_last_error($conn).' </strong><BR>';
else
while ($row=pg_fetch_object($result))
{
$fulltablename=$row->schemaname.'.'.$row->tablename;
if (!isset($tabellen[$fulltablename]))
echo 'Tabelle '.$fulltablename.' existiert in der DB, aber nicht in diesem Skript!<BR>';
else
if (!$result_fields=@pg_query($conn,"SELECT * FROM $fulltablename LIMIT 1;"))
echo '<BR><strong>'.pg_last_error($conn).' </strong><BR>';
else
for ($i=0; $i<pg_num_fields($result_fields); $i++)
{
$found=false;
$fieldnameDB=pg_field_name($result_fields,$i);
foreach ($tabellen[$fulltablename] AS $fieldnameARRAY)
if ($fieldnameDB==$fieldnameARRAY)
{
$found=true;
break;
}
if (!$found)
echo 'Attribut '.$fulltablename.'.<strong>'.$fieldnameDB.'</strong> existiert in der DB, aber nicht in diesem Skript!<BR>';
}
}
?>
File diff suppressed because it is too large Load Diff