예제 #1
0
파일: schema.php 프로젝트: pkorduan/xmi2db
    function createExternalDataTypes($dbSchema)
    {
        $this->logger->log('<b>Create external data types:</b>');
        #*******************************
        # SC_CRS
        #*******************************
        $dataType = new DataType('SC_CRS', 'DataType', $this->logger);
        $this->logger->log('<br><b>' . $dataType->name . '</b>');
        $dataType->setSchemas($this, $dbSchema);
        $dataType->setId(0);
        # create Attributes
        $dataTypeAttribute = new Attribute('scope', 'CharacterString', $dataType->name);
        $dataTypeAttribute->setStereoType('CharacterString');
        $dataTypeAttribute->attribute_type = 'ISO 19136 GML Type';
        $dataTypeAttribute->setMultiplicity('1', '-1');
        $this->logger->log('<br>attribute: <b>' . $dataTypeAttribute->name . '</b>
			datatype: <b>' . $dataTypeAttribute->datatype . '</b>
			stereotype: <b>' . $dataTypeAttribute->stereotype . '</b>');
        $dataType->addAttribute($dataTypeAttribute);
        # Create Comments
        $comment = $dataTypeAttribute->attribute_type . ': ' . $dataTypeAttribute->name;
        $comment .= ' ' . $dataTypeAttribute->multiplicity;
        $dataType->addComment($comment);
        # Erzeuge SQL und registriere DataType in Liste
        $dataTypeSql = $dataType->asSql();
        $this->logger->log('<pre>' . $dataTypeSql . '</pre>');
        $sql .= $dataTypeSql;
        $this->dataTypes[$dataType->name] = $dataType;
        #*******************************
        # Query
        #*******************************
        $dataType = new DataType('Query', 'DataType', $this->logger);
        $this->logger->log('<br><b>' . $dataType->name . '</b>');
        $dataType->setSchemas($this, $dbSchema);
        $dataType->setId(0);
        # create Attributes
        $dataTypeAttribute = new Attribute('url', 'CharacterString', $dataType->name);
        $dataTypeAttribute->setStereoType('CharacterString');
        $dataTypeAttribute->attribute_type = 'wfs:Query nach Web Feature Service Specifikation, Version 1.0.0';
        $dataTypeAttribute->setMultiplicity('0', '1');
        $this->logger->log('<br>attribute: <b>' . $dataTypeAttribute->name . '</b>
			datatype: <b>' . $dataTypeAttribute->datatype . '</b>
			stereotype: <b>' . $dataTypeAttribute->stereotype . '</b>');
        $dataType->addAttribute($dataTypeAttribute);
        # Create Comments
        $comment = $dataTypeAttribute->attribute_type . ': ' . $dataTypeAttribute->name;
        $comment .= ' ' . $dataTypeAttribute->multiplicity;
        $dataType->addComment($comment);
        # Erzeuge SQL und registriere DataType in Liste
        $dataTypeSql = $dataType->asSql();
        $this->logger->log('<pre>' . $dataTypeSql . '</pre>');
        $sql .= $dataTypeSql;
        $this->dataTypes[$dataType->name] = $dataType;
        #*******************************
        # Transaction
        #*******************************
        $dataType = new DataType('Transaction', 'DataType', $this->logger);
        $this->logger->log('<br><b>' . $dataType->name . '</b>');
        $dataType->setSchemas($this, $dbSchema);
        $dataType->setId(0);
        # create Attributes
        $dataTypeAttribute = new Attribute('content', 'Text', $dataType->name);
        $dataTypeAttribute->setStereoType('CharacterString');
        $dataTypeAttribute->attribute_type = 'wfs:Transaction nach Web Feature Service Specifikation, Version 1.0.0';
        $dataTypeAttribute->setMultiplicity('0', '1');
        $this->logger->log('<br>attribute: <b>' . $dataTypeAttribute->name . '</b>
			datatype: <b>' . $dataTypeAttribute->datatype . '</b>
			stereotype: <b>' . $dataTypeAttribute->stereotype . '</b>');
        $dataType->addAttribute($dataTypeAttribute);
        # Create Comments
        $comment = $dataTypeAttribute->attribute_type . ': ' . $dataTypeAttribute->name;
        $comment .= ' ' . $dataTypeAttribute->multiplicity;
        $dataType->addComment($comment);
        # Erzeuge SQL und registriere DataType in Liste
        $dataTypeSql = $dataType->asSql();
        $this->logger->log('<pre>' . $dataTypeSql . '</pre>');
        $sql .= $dataTypeSql;
        $this->dataTypes[$dataType->name] = $dataType;
        #*******************************
        # doubleList
        #*******************************
        $dataType = new DataType('doubleList', 'DataType', $this->logger);
        $this->logger->log('<br><b>' . $dataType->name . '</b>');
        $dataType->setSchemas($this, $dbSchema);
        $dataType->setId(0);
        # create Attributes
        $dataTypeAttribute = new Attribute('list', 'Sequence', $dataType->name);
        $dataTypeAttribute->setStereoType('Sequence');
        $dataTypeAttribute->attribute_type = 'ISO 19136 GML Type';
        $dataTypeAttribute->setMultiplicity('0', '1');
        $this->logger->log('<br>attribute: <b>' . $dataTypeAttribute->name . '</b>
			datatype: <b>' . $dataTypeAttribute->datatype . '</b>
			stereotype: <b>' . $dataTypeAttribute->stereotype . '</b>');
        $dataType->addAttribute($dataTypeAttribute);
        # Create Comments
        $comment = $dataTypeAttribute->attribute_type . ': ' . $dataTypeAttribute->name;
        $dataType->addComment($comment);
        # Erzeuge SQL und registriere DataType in Liste
        $dataTypeSql = $dataType->asSql();
        $this->logger->log('<pre>' . $dataTypeSql . '</pre>');
        $sql .= $dataTypeSql;
        $this->dataTypes[$dataType->name] = $dataType;
        #*******************************
        # Measure
        #*******************************
        $dataType = new DataType('Measure', 'DataType', $this->logger);
        $this->logger->log('<br><b>' . $dataType->name . '</b>');
        $dataType->setSchemas($umlSchema, $dbSchema);
        $dataType->setId(0);
        # create Attributes
        $dataTypeAttribute = new Attribute('value', 'Integer', $dataType->name);
        $dataTypeAttribute->setStereoType('DataType');
        $dataTypeAttribute->attribute_type = 'ISO 19136 GML Type';
        $dataTypeAttribute->setMultiplicity('0', '1');
        $this->logger->log('<br>attribute: <b>' . $dataTypeAttribute->name . '</b>
			datatype: <b>' . $dataTypeAttribute->datatype . '</b>
			stereotype: <b>' . $dataTypeAttribute->stereotype . '</b>');
        $dataType->addAttribute($dataTypeAttribute);
        # Create Comments
        $comment = $dataTypeAttribute->attribute_type . ': ' . $dataTypeAttribute->name;
        $dataType->addComment($comment);
        # Erzeuge SQL und registriere DataType in Liste
        $dataTypeSql = $dataType->asSql();
        $this->logger->log('<pre>' . $dataTypeSql . '</pre>');
        $sql .= $dataTypeSql;
        $this->dataTypes[$dataType->name] = $dataType;
        return $sql;
    }
예제 #2
0
 function getAttributesUntilLeafs($type, $stereotype, $parts)
 {
     $return_attributes = array();
     if (substr($type, 0, 3) == 'DQ_') {
         /* Damit die DQ_ Elemente gefunden werden mussen Sie in classes existieren.
          * Hier Beispiele zum anlegen der uml_classes
          * INSERT INTO aaa_uml.uml_classes (xmi_id, name, stereotype_id)
          *	values ('eaxmiid51', 'DQ_AbsoluteExternalPositionalAccuracy', 'EAID_BED119C1_311A_4a74_996D_121184388A0F')
          *	INSERT INTO aaa_uml.uml_classes (xmi_id, name, stereotype_id)
          *	values ('eaxmiid47', 'DQ_RelativeInternalPositionalAccuracy', 'EAID_BED119C1_311A_4a74_996D_121184388A0F')
          */
         $attributes = $this->umlSchema->getExternalClassAttributes($type);
     } else {
         $attributes = $this->umlSchema->getClassAttributes($type);
     }
     foreach ($attributes as $attribute) {
         if (!$this->is_filtered('attribute', $type, $attribute['attribute_name'])) {
             if (!empty($attribute['attribute_name'])) {
                 if (empty($parts)) {
                     $parent = $this;
                 } else {
                     #if ($attribute['class_name'] == 'AA_Modellart') echo '<br>  class: ' . $attribute['class_name'] . ' class stereotype: ' . $stereotype . ' attribute name: ' . $attribute['attribute_name'] . ' datatype: ' . $attribute['attribute_datatype'] . ' stereotyp: ' . $attribute['attribute_stereotype'];
                     $parent = new Datatype($attribute['class_name'], $stereotype, $this->logger, $this->enumerations);
                     $parent->ogrSchema = $this->ogrSchema;
                 }
                 $attributeObj = new Attribute(($attribute['attribute_name'] == 'position' and GEOMETRY_COLUMN_NAME != '') ? GEOMETRY_COLUMN_NAME : $attribute['attribute_name'], $attribute['attribute_datatype'], $parent, $parts);
                 $attributeObj->setStereoType($attribute['attribute_stereotype']);
                 # Union Typen können nicht not null sein, weil immer eines der Attribute
                 # des Union Types verwendet wird. Also andere weggelassen werden.
                 # Sonderfall, wenn ein Union Typ nur ein Attribut hätte, aber das wäre
                 # für einen Union Typ sinnlos, weil er ja dafür da ist, dass man ein
                 # Attribut aus verschiedenen auswählt.
                 #if ($type == 'AX_Lagebezeichnung') echo '<br>typ: ' . $type . ' attribute: ' . $attributeObj->name . ' stereotype: ' . $stereotype;
                 $attributeObj->setMultiplicity(($attribute['attribute_name'] == 'position' or $stereotype == 'union') ? 0 : $attribute['multiplicity_range_lower'], $attribute['multiplicity_range_upper']);
                 $new_path = $parts;
                 array_push($new_path, $attributeObj);
                 if (in_array(strtolower($attribute['attribute_stereotype']), array('datatype', 'union'))) {
                     foreach ($this->getAttributesUntilLeafs($attribute['attribute_datatype'], $attribute['attribute_stereotype'], $new_path) as $child_attribute) {
                         $return_attributes[] = $child_attribute;
                     }
                 } else {
                     $return_attributes[] = $new_path;
                 }
             }
         }
     }
     $this->attributes_until_leafs = $return_attributes;
     return $return_attributes;
 }