public function createRedlandNodeFromNode(Node $node) { if ($node instanceof NamedNode || $node instanceof Literal || $node instanceof BlankNode) { return $node->getRedlandNode(); } elseif ($node->isNamed()) { return $this->createNamedNode($node->getUri())->getRedlandNode(); } elseif ($node->isLiteral()) { return $this->createLiteral($node->getValue(), $node->getDatatype(), $node->getLanguage())->getRedlandNode(); } elseif ($node->isBlank()) { return $this->createBlankNode($node->getBlankId())->getRedlandNode(); } throw new \Exception("This node type (" . get_class($node) . ") is not supported by Redland backend"); }
/** * Returns true or false depending on whether or not the statements pattern * has any matches in the given graph. * * @param Statement $Statement It can be either a concrete or pattern-statement. * @param Node $graph optional Overrides target graph. * @param array $options optional It contains key-value pairs and should provide additional * introductions for the store and/or its adapter(s). * @return boolean Returns true if at least one match was found, false otherwise. */ public function hasMatchingStatement(Statement $statement, Node $graph = null, array $options = array()) { // if $graph was given, but its not a named node, set it to null. if (null !== $graph && false === $graph->isNamed()) { $graph = null; } // otherwise check, if graph was set in the statement and it is a named node and use it, if so. if (null === $graph && null !== $statement->getGraph() && true === $statement->getGraph()->isNamed()) { $graph = $statement->getGraph(); } $statementIterator = $this->statementIteratorFactory->createIteratorFromArray(array($statement)); $result = $this->query('ASK { ' . $this->sparqlFormat($statementIterator, $graph) . '}', $options); if (true === is_object($result)) { return $result->getValue(); } else { return $result; } }