public function persist($entity)
 {
     $reflection = new \ReflectionClass($entity);
     $originURI = $entity->getOrigin();
     if (!$originURI) {
         throw new \Exception("Cannot persist entity, because origin URI is not defined");
     }
     $sparql = '';
     $annotationReader = new AnnotationReader();
     $iri = $annotationReader->getClassAnnotation($reflection, 'Soil\\DiscoverBundle\\Annotation\\Iri');
     if ($iri) {
         $iri = $iri->value;
         $sparql .= "<{$originURI}> rdf:type {$iri} . " . PHP_EOL;
     }
     $props = $reflection->getProperties();
     foreach ($props as $prop) {
         $matchAnnotation = $annotationReader->getPropertyAnnotation($prop, 'Soil\\DiscoverBundle\\Annotation\\Iri');
         if ($matchAnnotation && $matchAnnotation->persist) {
             $match = $matchAnnotation->value;
             $prop->setAccessible(true);
             $value = $prop->getValue($entity);
             $sparql .= "<{$originURI}> {$match} <{$value}> . " . PHP_EOL;
         }
     }
     if ($sparql) {
         $this->logger->addInfo('Persisting: ');
         $this->logger->addInfo($sparql);
         $num = $this->endpoint->insert($sparql);
         $this->logger->addInfo('Return: ' . print_r($num, true));
         return $num;
     } else {
         return null;
     }
 }
    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();
        }
    }