<?php require_once '../pascoul.php'; $pascoul = new Pascoul(); $pascoul->client_reconnect = 1; //the time for the client to reconnect after the connection has lost in seconds. Default: 1. $pascoul->allow_cors = true; //Allow cross-domain access? Default: false. If you want others to access this must set to true. $pascoul->start(); if (isset($_REQUEST['truncate'])) { $pascoul->send_message(0, $_REQUEST['truncate'], 5); } if (isset($_REQUEST['schema'])) { $pascoul->send_message(0, $_REQUEST['schema'], 5); } //LONG RUNNING TASK for ($i = 1; $i <= 10; $i++) { $pascoul->send_message($i, 'on iteration ' . $i . ' of 10', $i * 10); sleep(1); } $pascoul->send_message('CLOSE', 'Process complete');
/** * Build the query - Main Function * ("classes" => "uml_classes",++ * "attributes" => "uml_attributes",+ * "association_classes" => "association_classes",+ * "class_generalizations" => "class_generalizations",+ * "packages" => "packages",+ * "stereotypes" => "stereotypes"));+ */ function getQueries() { Pascoul::send_message(0, '#Lade XMI-Datei: ' . $this->xmi_file, $progress++); if (!file_exists($this->xmi_file)) { echo "File " . $this->xmi_file . " not found."; return false; } $xmi = simplexml_load_file($this->xmi_file); Pascoul::send_message(0, '#XMI-Datei erfolgreich geladen', $progress++); $namespaces = $xmi->getNamespaces(true); Pascoul::send_message(0, '#Namespace' . $namespace, $progress++); //echo "<pre>"; //analyse everything top-level echo "<h3>Übergeordnetes: " . $idPackage_sub . "</h3><br>"; $progress++; Pascoul::send_message(0, '#Beginn Übergeordnetes', $progress); //1. Stereotypes //echo "<h2>Stereotypes</h2>"; $i_stereotypes = 0; foreach ($xmi->{$this->root_element}->children($namespaces["UML"])->Model->{'Namespace.ownedElement'}->Stereotype as $stereotypes) { $stereotypesArray = $this->getAttributeInfos($stereotypes); $stereotypesArray['baseClass'] = (string) $stereotypes->{'Stereotype.baseClass'}; $this->buildQueryForStereotype($stereotypesArray); //echo $stereotypes->attributes()->name."<br>"; //echo "baseClass: ".$stereotypes->{'Stereotype.baseClass'}."<br>"; //print_r($stereotypesArray); $i_stereotypes++; } echo $i_stereotypes . " Stereotypes in die DB geschrieben.<br>"; $progress++; Pascoul::send_message(0, $i_stereotypes . " Stereotypes in die DB geschrieben.", $progress); //2. TagDefinitions $i_TagDefinitions = 0; //echo "<h2>TagDefinitions</h2>"; foreach ($xmi->{$this->root_element}->children($namespaces["UML"])->Model->{'Namespace.ownedElement'}->TagDefinition as $tagDefinition) { $tagDefinitionArray = $this->getAttributeInfos($tagDefinition); $this->buildQueryForTagDefinition($tagDefinitionArray); //print_r($tagDefinitionArray); //echo $tagDefinition->attributes()->name."<br>"; $i_TagDefinitions++; } echo $i_TagDefinitions . " TagDefinitions in die DB geschrieben.<br>"; $progress++; Pascoul::send_message(0, $i_TagDefinitions . " TagDefinitions in die DB geschrieben.", $progress); //3. DataTypes //echo "<h2>DataTypes</h2>"; $i_DataTypes = 0; foreach ($xmi->{$this->root_element}->children($namespaces["UML"])->Model->{'Namespace.ownedElement'}->DataType as $dataType) { $dataTypeArray = $this->getAttributeInfos($dataType); $this->buildQueryForDataType($dataTypeArray); //print_r($dataTypeArray); //echo $dataType->attributes()->name."<br>"; $i_DataTypes++; } echo $i_DataTypes . " DataTypes in die DB geschrieben.<br>"; $progress++; Pascoul::send_message(0, $i_DataTypes . " DataTypes in die DB geschrieben.", $progress); $progress++; Pascoul::send_message(0, '#Ende Übergeordnetes', $progress); if (!isset($this->basePackage) or $this->basePackage == '') { Pascoul::send_message(0, 'Iterate through the model', $progress++); $this->iterateModel($xmi->{$this->root_element}->children($namespaces["UML"])->Model); } else { //look for package that contains most of the model //das müsste für INSPIRE-Kompatibilität angepasst werden foreach ($xmi->{$this->root_element}->children($namespaces["UML"])->Model->{'Namespace.ownedElement'}->Package as $package_top) { //Only use "XPlanGML 4.1" and ignore the other two ("XPlanung-Operationen" and "Weitere Diagramme") //Gilt nur für den EA Export, sonst sollen alle Packages durchgegangen werden! (dann ist basePackage nicht gesetzt bzw. leer!) //echo "basePackage: ".$this->basePackage."<br>"; //echo "aktuelles Package: ".$package_top->attributes()->name."<br>"; //if ($package_top->attributes()->name == $this->basePackage) echo "true"; //else echo "false"; //echo "basePackage: ".$this->basePackage."<br>"; //echo "aktuelles Package: ".$package_top->attributes()->name."<br>"; if (isset($this->basePackage) and $package_top->attributes()->name == $this->basePackage and $this->basePackage !== '') { $this->iterateModel($package_top); } else { if (!isset($this->basePackage) or $this->basePackage == '') { $this->iterateModel($package_top); } } } } Pascoul::send_message('CLOSE', 'Process complete'); //Now use this to convert the model //iterate through packages //echo "</pre>"; /* foreach ($xmi->{$this->root_element} as $item) { reset($this->data); $ic=1; $sql[$c] = "INSERT INTO " . $this->table ." SET "; foreach($this->data as $d_array) { $sql[$c] .= $d_array[2] . " = '"; // node root attribuite if ($d_array[1]=="attr" and empty($d_array[0]) and isset($item[ $d_array[3] ])) { $sql[$c] .= utf8_decode($item[ $d_array[3] ]); } // node attribuite elseif ($d_array[1]=="attr" and !empty( $item->{$d_array[0]}[ $d_array[3] ] )) { $sql[$c] .= utf8_decode($item->{$d_array[0]}[ $d_array[3] ]); } // node contents elseif ($d_array[1]=="node") { $sql[$c] .= utf8_decode($item->$d_array[0]); } $sql[$c] .= "'"; if($ic < count($this->data) ) { $sql[$c] .= ", "; } $ic++; } $sql[$c] .= "\n"; $c++; } return $sql; */ }