public function getNodeById($node_id) { $uri = $this->base_uri . 'node/' . $node_id; list($response, $http_code) = HTTPUtil::jsonGetRequest($uri); switch ($http_code) { case 200: return Node::inflateFromResponse($this, $response); case 404: throw new NotFoundException(); default: throw new HttpException($http_code); } }
public function performPluginCommand($plugin, $command, $data, $inflate_nodes = true) { $uri = $this->base_uri . 'ext/' . $plugin . 'Plugin/graphdb/' . $command; list($response, $http_code) = HTTPUtil::jsonPostRequest($uri, $data); if ($inflate_nodes && $http_code == 200) { // Process results to replace node object with actualy node objects for ($i = 0; $i < count($response['data']); $i++) { for ($j = 0; $j < count($response['data'][$i]); $j++) { if (is_array($response['data'][$i][$j]) && isset($response['data'][$i][$j]['data'])) { $response['data'][$i][$j] = Node::inflateFromResponse($this, $response['data'][$i][$j]); } } } } switch ($http_code) { case 200: return $response; case 404: throw new NotFoundException(); default: throw new HttpException($http_code); } }
/** * get the node by uri * * @throws \Neo4j\Exception\HttpException * @throws \Neo4j\Exception\NotFoundException * @param string $uri The Request URI * @return Neo4j\Node */ public function getNodeByUri($uri) { list($response, $http_code) = Request::get($uri); if ($http_code == 404) { throw new \Neo4j\Exception\NotFoundException(); } if ($http_code != 200) { throw new \Neo4j\Exception\HttpException("http code: " . $http_code . ", response: " . print_r($response, true)); } return Node::inflateFromResponse($this, $response); }
/** * get nodex by key value pair * * @throws \Neo4j\Exception\HttpException * @throws \Neo4j\Exception\NotFoundException * * @param string $key * @param string $value * * @return array */ public function getNodes($key, $value) { $nodes = array(); $this->_uri = $this->_db->getBaseUri() . 'index/node/' . $key . '/' . $value; list($response, $http_code) = Request::get($this->_uri); if ($http_code != 200) { throw new \Neo4j\Exception\HttpException("http code: " . $http_code . ", response: " . print_r($response, true)); } foreach ($response as $nodeData) { $nodes[] = Node::inflateFromResponse($this->_db, $nodeData); } if (empty($nodes)) { throw new \Neo4j\Exception\NotFoundException(); } return $nodes; }