* @package tao */ class ImportRdf implements Action { public function __invoke($params) { if (count($params) < 1) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: ImportRdf RDF_FILE [MODEL_ID]')); } $filename = array_shift($params); if (!file_exists($filename) || !is_readable($filename)) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Unable to open file %s', $filename)); } if (empty($params)) { $iterator = new FileIterator($filename); } else { $modelId = array_shift($params); $iterator = new FileIterator($filename, $modelId); } $rdf = ModelManager::getModel()->getRdfInterface(); $triples = 0; foreach ($iterator as $triple) { $triples++; $rdf->add($triple); } return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Successfully imported %s tripples', $triples)); } }