コード例 #1
0
 private function isNonRedirectableResource(ExpNsResource $expNsResource)
 {
     return $expNsResource->getNamespaceId() === 'swivt' || $expNsResource->getNamespaceId() === 'rdf' || $expNsResource->getNamespaceId() === 'rdfs' || $expNsResource->getNamespaceId() === 'property' && strrpos($expNsResource->getLocalName(), 'aux') || isset($expNsResource->isUserDefined) && !$expNsResource->isUserDefined;
 }
コード例 #2
0
 /**
  * Add a serialization of the given SMWExpResource to the output,
  * assuming that an opening property tag is alerady there.
  *
  * @param $expResourceProperty SMWExpNsResource the property to use
  * @param $expResource array of (SMWExpResource or SMWExpData)
  * @param $indent string specifying a prefix for indentation (usually a sequence of tabs)
  * @param $isClassTypeProp boolean whether the resource must be declared as a class
  *
  * @bug The $isClassTypeProp parameter is not properly taken into account.
  * @bug Individual resources are not serialised properly.
  */
 protected function serializeExpCollection(SMWExpNsResource $expResourceProperty, array $collection, $indent, $isClassTypeProp)
 {
     $this->post_ns_buffer .= $indent . '<' . $expResourceProperty->getQName() . " rdf:parseType=\"Collection\">\n";
     foreach ($collection as $expElement) {
         if ($expElement instanceof SMWExpData) {
             $this->serializeNestedExpData($expElement, $indent);
         } else {
             // FIXME: the below is not the right thing to do here
             //$this->serializeExpResource( $expResourceProperty, $expElement, $indent );
         }
         if ($isClassTypeProp) {
             // FIXME: $expResource is undefined
             //$this->requireDeclaration( $expResource, SMW_SERIALIZER_DECL_CLASS );
         }
     }
     $this->post_ns_buffer .= "{$indent}</" . $expResourceProperty->getQName() . ">\n";
 }
コード例 #3
0
 /**
  * Store a value for a property identified by its title object. No
  * duplicate elimination as this is usually done in SMWSemanticData
  * already (which is typically used to generate this object).
  *
  * @param SMWExpNsResource $property
  * @param Element $child
  */
 public function addPropertyObjectValue(SMWExpNsResource $property, Element $child)
 {
     $this->hash = null;
     if (!array_key_exists($property->getUri(), $this->m_edges)) {
         $this->m_children[$property->getUri()] = array();
         $this->m_edges[$property->getUri()] = $property;
     }
     $this->m_children[$property->getUri()][] = $child;
 }
コード例 #4
0
ファイル: SMW_SparqlStore.php プロジェクト: Tjorriemorrie/app
 /**
  * Find the redirect target of an SMWExpNsResource.
  * Returns an SMWExpNsResource object the input redirects to,
  * the input itself if there is no redirect (or it cannot be
  * used for making a resource with a prefix).
  *
  * @since 1.6
  * @param $expNsResource string URI to check
  * @param $exists boolean that is set to true if $expNsResource is in the
  * store; always false for blank nodes; always true for subobjects
  * @return SMWExpNsResource
  */
 protected function getSparqlRedirectTarget(SMWExpNsResource $expNsResource, &$exists)
 {
     if ($expNsResource->isBlankNode()) {
         $exists = false;
         return $expNsResource;
     } elseif ($expNsResource->getDataItem() instanceof SMWDIWikiPage && $expNsResource->getDataItem()->getSubobjectName() !== '') {
         $exists = true;
         return $expNsResource;
     }
     $resourceUri = SMWTurtleSerializer::getTurtleNameForExpElement($expNsResource);
     $rediUri = SMWTurtleSerializer::getTurtleNameForExpElement(SMWExporter::getSpecialPropertyResource('_REDI'));
     $skeyUri = SMWTurtleSerializer::getTurtleNameForExpElement(SMWExporter::getSpecialPropertyResource('_SKEY'));
     $sparqlResult = smwfGetSparqlDatabase()->select('*', "{$resourceUri} {$skeyUri} ?s  OPTIONAL { {$resourceUri} {$rediUri} ?r }", array('LIMIT' => 1), array($expNsResource->getNamespaceId() => $expNsResource->getNamespace()));
     $firstRow = $sparqlResult->current();
     if ($firstRow === false) {
         $exists = false;
         return $expNsResource;
     } elseif (count($firstRow) > 1 && !is_null($firstRow[1])) {
         $exists = true;
         $rediTargetElement = $firstRow[1];
         $rediTargetUri = $rediTargetElement->getUri();
         $wikiNamespace = SMWExporter::getNamespaceUri('wiki');
         if (strpos($rediTargetUri, $wikiNamespace) === 0) {
             return new SMWExpNsResource(substr($rediTargetUri, 0, strlen($wikiNamespace)), $wikiNamespace, 'wiki');
         } else {
             return $expNsResource;
         }
     } else {
         $exists = true;
         return $expNsResource;
     }
 }
コード例 #5
0
ファイル: SMW_Serializer.php プロジェクト: whysasse/kmwiki
 /**
  * Check if the given property is one of the special properties of the OWL
  * language that require their values to be classes or RDF lists of
  * classes. In these cases, it is necessary to declare this in the exported
  * data. 
  *  
  * @note The list of properties checked here is not complete for the OWL
  * language but covers what is used in SMW.
  * @note OWL 2 allows URIs to refer to both classes and individual elements
  * in different contexts. We only need declarations for classes that are
  * used as such, hence it is enough to check the property. Moreover, we do
  * not use OWL Datatypes in SMW, so rdf:type, rdfs:domain, etc. always
  * refer to classes.
  * @param SMWExpNsResource $property
  */
 protected function isOWLClassTypeProperty(SMWExpNsResource $property)
 {
     $locname = $property->getLocalName();
     if ($property->getNamespaceID() == 'rdf') {
         return $locname == 'type';
     } elseif ($property->getNamespaceID() == 'owl') {
         return $locname == 'intersectionOf' || $locname == 'unionOf' || $locname == 'equivalentClass' || $locname == 'complementOf' || $locname == 'someValuesFrom' || $locname == 'allValuesFrom' || $locname == 'onClass';
     } elseif ($property->getNamespaceID() == 'rdfs') {
         return $locname == 'subClassOf' || $locname == 'range' || $locname == 'domain';
     } else {
         return false;
     }
 }
コード例 #6
0
 public function testRedirectTargetForCachedLookup()
 {
     $dataItem = new DIWikiPage('Foo', NS_MAIN);
     $expNsResource = new ExpNsResource('Foo', 'Bar', '', $dataItem);
     $cache = $this->getMockBuilder('\\Onoi\\Cache\\Cache')->disableOriginalConstructor()->getMock();
     $cache->expects($this->once())->method('contains')->will($this->returnValue(true));
     $cache->expects($this->once())->method('fetch')->with($this->equalTo($expNsResource->getUri()))->will($this->returnValue($expNsResource));
     $connection = $this->getMockBuilder('\\SMWSparqlDatabase')->disableOriginalConstructor()->getMock();
     $instance = new RedirectLookup($connection, $cache);
     $exists = null;
     $instance->findRedirectTargetResource($expNsResource, $exists);
     $this->assertTrue($exists);
     $instance->clear();
 }