function insertTemplatePropertyAndGetId($template_id, $template_property) { if ($template_property_id = getTemplatePropertyId($template_id, $template_property)) { return $template_property_id; } else { $strSQL = "INSERT INTO template_property (template_id, name) VALUES ('" . $template_id . "', '" . $template_property . "')"; mysql_query($strSQL); if ($template_property_id = getTemplatePropertyId($template_id, $template_property)) { return $template_property_id; } } die("couldn't insert or find template property '{$template_property}' on template '{$template_id}' - " . mysql_error()); return null; }
if (!mysql_query($strSQL)) { if (strpos(mysql_error(), "Duplicate entry") === false) { echo "{$csvRow['1']} foaf:homepage property not properly added (" . mysql_error() . ")\n"; $foaf_property_at_class_wo_template[] = "{$superClass}.{$superProperty}"; } } } else { echo "{$superClass}(.{$superProperty}) ({$class}.{$template_property}) not found \n"; } } elseif ($csvRow[4] != "" && $csvRow[5] != "") { if (!getOntologyPropertyId($class_id, $superProperty) && $splitted[$template_id][$template_property][getOntologyPropertyId($class_id, getCamelCasePropertyNameFromLabel($csvRow[4]))] == null) { echo ""; $temp_pid = insertTemplatePropertyAndGetId($template_id, $template_property); $ontology_property_id = createOntologyProperty($class_id, null, $csvRow[4], $csvRow[5]); createRelationFromTemplatePropertyToClassProperty($template_id, $temp_pid, $ontology_property_id); if (getTemplatePropertyId($template_id, $template_property)) { $splitted[$template_id][$template_property][$ontology_property_id] = true; //echo ("[SPLIT] on same class: [$class] $csvRow[1] -> [E] $csvRow[4] - [F] $csvRow[5] \n"); } } elseif (getOntologyPropertyId($class_id, $superProperty) && $splitted[$template_id][$template_property][getOntologyPropertyId($class_id, getCamelCasePropertyNameFromLabel($csvRow[4]))] == null) { echo "Can't split: {$class}.{$template_property} - {$superProperty} already defined on {$class}, check ranges first\n"; } } else { $wrong_mappings[] = "{$class}.{$csvRow['1']}\t|\t{$csvRow['4']}\t|\t{$csvRow['5']}"; } $current_csv_row = $current_csv_row + 1; $csvRow = $mapping_csv_content[$current_csv_row]; } } } }