コード例 #1
0
ファイル: Rdfa.php プロジェクト: johnulist/easyrdf
 protected function generateList($subject, $property, $list)
 {
     $current = $subject;
     $prop = $property;
     // Output a blank node for each item in the list
     foreach ($list as $item) {
         $newNode = $this->graph->newBNodeId();
         $this->addTriple($current, $prop, array('type' => 'bnode', 'value' => $newNode));
         $this->addTriple($newNode, 'rdf:first', $item);
         $current = $newNode;
         $prop = 'rdf:rest';
     }
     // Finally, terminate the list
     $this->addTriple($current, $prop, array('type' => 'uri', 'value' => RdfNamespace::expand('rdf:nil')));
 }
コード例 #2
0
    public function subscribe($agentURI, $digestSubscriptionURI, $period)
    {
        $index = 1;
        $query = <<<INSERT
            <{$agentURI}> tal:subscriptionApplied _:b{$index} .
            _:b{$index} tal:subscriptionType <{$digestSubscriptionURI}> .
            _:b{$index} tal:subscriptionPeriod {$period} .
INSERT;
        $graphIRI = 'tal:SubscriptionGraph';
        $graphURI = RdfNamespace::expand($graphIRI);
        echo $query;
        try {
            $this->endpoint->insert($query, $graphURI);
        } catch (\EasyRdf\Http\Exception $e) {
            echo $e->getBody();
        }
    }
コード例 #3
0
 /**
  * @param $shortUri
  *
  * @return string
  */
 public function expand($shortUri)
 {
     return RdfNamespace::expand($shortUri);
 }
コード例 #4
0
 /**
  * If a types resource has changed and the new type is mapped to another document type, then the old document is removed
  * @param $uri
  * @param $types
  * @param $oldType
  * @return bool
  */
 protected function deleteOldDocument($uri, $types, $oldType)
 {
     $newTypes = array();
     foreach ($types as $type) {
         $type = (string) $type;
         if ($type && !empty($type)) {
             $newTypes[] = RdfNamespace::shorten($type);
         }
     }
     // Get most accurtype of oldtype
     $mostAccurateTypes = $this->filiationBuilder->getMostAccurateType(array(RdfNamespace::expand($oldType)), $this->serializerHelper->getAllTypes());
     $mostAccurateType = null;
     // not specified in project ontology description
     if (count($mostAccurateTypes) == 1) {
         $mostAccurateType = $mostAccurateTypes[0];
     } else {
         //            echo "Seems to not have to be indexed";
     }
     if (!in_array($mostAccurateType, $newTypes)) {
         $typesConfig = $this->configManager->getTypesConfigurationByClass($mostAccurateType);
         foreach ($typesConfig as $typeConfig) {
             $indexConfig = $typeConfig->getIndex();
             $index = $indexConfig->getName();
             $this->container->get('nemrod.elastica.jsonld.frame.loader')->setEsIndex($index);
             if ($index !== null) {
                 $esType = $this->indexRegistry->getIndex($index)->getType($typeConfig->getType());
                 // Trow an exeption if document does not exist
                 try {
                     $esType->deleteDocument(new Document($uri, array(), $mostAccurateType, $indexConfig->getElasticSearchName()));
                     return true;
                 } catch (\Exception $e) {
                 }
             }
         }
     }
     return false;
 }