/** * @param string $modelIri The IRI, which identifies the model. * @param boolean $useAc Whether to use access control or not. * @throws Erfurt_Store_Exception if the requested model is not available. * @return Erfurt_Rdf_Model Returns an instance of Erfurt_Rdf_Model or one of its subclasses. */ public function getModel($modelIri, $useAc = true) { // check whether model exists and is visible if (!$this->isModelAvailable($modelIri, $useAc)) { $systemModelUri = $this->getOption('modelUri'); $systemSchemaUri = $this->getOption('schemaUri'); // check whether requested model is one of the schema models if (!$useAc && ($modelIri === $systemModelUri || $modelIri === $systemSchemaUri)) { try { $this->checkSetup(); } catch (Erfurt_Store_Exception $e) { if ($e->getCode() === 20) { // Everything is fine, system models now imported } else { throw $e; } } // still not available? if (!$this->isModelAvailable($modelIri, $useAc)) { throw new Erfurt_Store_Exception('Model "' . $modelIri . '" is not available.'); } } else { throw new Erfurt_Store_Exception('Model "' . $modelIri . '" is not available.'); } } // if backend adapter provides its own implementation if (method_exists($this->_backendAdapter, 'getModel')) { // … use it $modelInstance = $this->_backendAdapter->getModel($modelIri); } else { //add here the userid to the identifier $modelType = null; $identity = null; $identityObject = Erfurt_App::getInstance()->getAuth()->getIdentity(); if (null !== $identityObject) { $identity = Erfurt_App::getInstance()->getAuth()->getIdentity()->getUri(); } if (isset($this->_allowedModels[$identity][$modelIri])) { $modelType = $this->_allowedModels[$identity][$modelIri]; } else { // use generic implementation $owlQuery = new Erfurt_Sparql_SimpleQuery(); $owlQuery->setProloguePart('ASK')->addFrom($modelIri)->setWherePart('{<' . $modelIri . '> <' . EF_RDF_NS . 'type> <' . EF_OWL_ONTOLOGY . '>.}'); if ($this->sparqlAsk($owlQuery, array(Erfurt_Store::USE_AC => $useAc))) { // instantiate OWL model $this->_allowedModels[$identity][$modelIri] = self::MODEL_TYPE_OWL; $modelType = self::MODEL_TYPE_OWL; } else { // instantiate RDF-S model $this->_allowedModels[$identity][$modelIri] = self::MODEL_TYPE_RDFS; $modelType = self::MODEL_TYPE_RDFS; } } switch ($modelType) { case self::MODEL_TYPE_OWL: $modelInstance = new Erfurt_Owl_Model($modelIri); break; case self::MODEL_TYPE_RDFS: $modelInstance = new Erfurt_Rdfs_Model($modelIri); break; default: //should never happen throw new Erfurt_Store_Exception("Model '{$modelIri}' is not available."); } } // check for edit possibility if ($this->_checkAc($modelIri, 'edit', $useAc)) { $modelInstance->setEditable(true); } else { $modelInstance->setEditable(false); } return $modelInstance; }
/** * Resource factory method * * @return Erfurt_Owl_Resource */ public function getResource($resourceIri) { return parent::getResource($resourceIri); }