Example #1
0
function createOntologyObjectPropertyAndGetId($class_id, $ontology_property_name, $type, $range, $ontology_property_label)
{
    $result = mysql_query('SELECT id FROM class_property where name="' . $ontology_property_name . '" and class_id=' . $class_id);
    if (mysql_num_rows($result) == 0) {
        $strSQL = "INSERT INTO class_property (class_id, name, type, label) VALUES ('" . $class_id . "', '" . $ontology_property_name . "', '" . $type . "', '" . $ontology_property_label . "')";
        if (!mysql_query($strSQL)) {
            if (strpos(mysql_error(), "Duplicate entry") === false) {
                die(__LINE__ . " [DIE] class id: {$class_id}, {$ontology_property_name} - " . mysql_error());
            }
        }
        $ontology_property_id = getOntologyPropertyId($class_id, $ontology_property_name);
        if ($range_class_id = getClassIdFromClassName($range)) {
            $strSQL = "INSERT INTO class_property_range (property_id, range_class_id) VALUES ('" . $ontology_property_id . "', '" . $range_class_id . "')";
            if (!mysql_query($strSQL)) {
                if (strpos(mysql_error(), "Duplicate entry") === false) {
                    die(__LINE__ . " [DIE] class id: {$class_id}, {$ontology_property_name} - " . mysql_error());
                }
            }
        } else {
            die(__LINE__ . " [DIE] class {$range} not found in database!");
        }
    } else {
        while ($row = mysql_fetch_row($result)) {
            return $row[0];
        }
    }
    return getOntologyPropertyId($class_id, $ontology_property_name);
}
Example #2
0
     }
     // subPropertyOf or split
 } elseif ($csvRow[2] == "" && $csvRow[4] != "") {
     //if ($csvRow[3]  != "") {
     if ($run > 1) {
         $firstRow = true;
         $current_csv_row = $csv_row;
         while ($firstRow || $csvRow[1] == "" && $csvRow[3] != "" && $csvRow[4] != "" || $csvRow[1] == "" && $csvRow[4] != "" && $csvRow[5] != "") {
             $firstRow = false;
             $superProperty = $csvRow[4];
             $expectedUnit = $csvRow[6];
             if ($csvRow[3] != "") {
                 // found superClass
                 $superClass = str_replace(" ", "", $csvRow[3]);
                 if (in_array($superClass, $overall_classes)) {
                     $superClassId = getClassIdFromClassName($superClass);
                     if ($superClassId) {
                         $result = mysql_query('SELECT id FROM class_property where name="' . $superProperty . '" and class_id=' . $superClassId);
                         if (mysql_num_rows($result) > 0) {
                             $temp_pid = insertTemplatePropertyAndGetId($template_id, $template_property);
                             while ($row = mysql_fetch_row($result)) {
                                 $class_pid = $row[0];
                                 $strSQL = "INSERT INTO template_property_class_property (template_property_id, class_property_id) VALUES ('" . $temp_pid . "', '" . $class_pid . "')";
                                 if (!mysql_query($strSQL)) {
                                     // die(mysql_error() . " - query: ".$strSQL);
                                 }
                                 if ($expectedUnit != "") {
                                     $result_unit = mysql_query('SELECT parser_type FROM parser_type_rule where class_property_id="' . $class_pid . '"');
                                     if (mysql_num_rows($result_unit) > 0) {
                                         while ($row = mysql_fetch_row($result_unit)) {
                                             if ($row[0] == "unit") {