function PutModel() { $Model = new TraceModel($this->BaseURI, $this->ModelName); if (!$Model->exist()) { $Model->dump(); } $prefixes[] = "@prefix : <http://liris.cnrs.fr/silex/2009/ktbs#> ."; $prefixes[] = "@prefix skos: <http://www.w3.org/2004/02/skos/core#> ."; $prefixes[] = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> ."; $statements[] = "<.> :contains <" . $Model->name . "> ."; $statements[] = "<" . $Model->name . "> a :TraceModel ."; $statementsAttribute = array(); $statementsType = array(); $Typearray = array(); for ($i = 0; $i < sizeof($this->Obsels); $i++) { foreach ($this->Obsels[$i] as $key => $value) { if ($key == "@type") { if (isset(explode('m:', $value)[1])) { $Type = explode('m:', $value)[1]; } } else { if ($key !== "@type" && $key !== "@id" && $key !== "begin" && $key !== "end" && $key !== "subject") { if (isset(explode('m:', $key)[1])) { $Attribute = explode('m:', $key)[1]; if (strripos($Attribute, '/')) { $HasType = explode('/', $Attribute)[0]; } else { $HasType = "With_" . $Attribute; } $statementsAttribute[] = "<#" . $Attribute . "> a :AttributeType ;"; $statementsAttribute[] = "skos:prefLabel \"" . $Attribute . "\" ;"; $statementsAttribute[] = ":hasAttributeDomain <#" . $HasType . "> ;"; $statementsAttribute[] = ":hasAttributeRange xsd:string . "; $statementsType[] = "<#" . $HasType . "> a :ObselType ."; if ($Type !== $HasType) { $statementsType[] = "<#" . $Type . "> a :ObselType ;"; $statementsType[] = " :hasSuperObselType <#" . $HasType . "> ."; } } } } } } $script = implode("\n", $prefixes) . "\n" . implode("\n", $statements) . "\n" . implode("\n", $statementsType) . "\n" . implode("\n", $statementsAttribute); $Model->put($script); // echo ($Model->getData()); }
function bringListOfTraces($Traces, $modelname) { /* This method allow to bring a list of traces in this base and a create a global model for all traces if the model exists already, it will be updated. use : $Base->bringListOfTraces(array_of_Trace_Object,model_Name); */ $model = new TraceModel($this->uri, $modelname); if ($model->exist()) { $s = $model->getDefTypes(); } else { $model->dump(); $s = ""; } if (is_array($Traces)) { foreach ($Traces as $trace) { $rrr = $trace->getModel(); $m = new TraceModel($rrr); $s = $s . $m->getDefTypes(); } } $prefixes[] = "@prefix : <http://liris.cnrs.fr/silex/2009/ktbs#> ."; $prefixes[] = "@prefix skos: <http://www.w3.org/2004/02/skos/core#> ."; $prefixes[] = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> ."; $statements[] = "<" . $this->uri . "> :contains <> ."; $statements[] = "<> a :TraceModel ."; $script = implode("\n", $prefixes) . "\n" . implode("\n", $statements) . "\n" . $s; $model->put($script); $model_uri = $model->getUri(); if (is_array($Traces)) { foreach ($Traces as $trace) { $this->bringTrace($trace, $model_uri); } } }