예제 #1
0
 /**
  *
  * @param type $nodeId
  * @param type $order 
  * possible values
  * breadth_first : http://en.wikipedia.org/wiki/Breadth-first_search
  * depth_first : http://en.wikipedia.org/wiki/Depth-first_search
  * @return type 
  */
 public function getNodes($nodeId = null, $order = "breadth_first")
 {
     $params = array("return_filter" => array("body" => "position.length()<" . $this->max_depth . ";", "language" => "javascript"), "prune_evaluator" => array("name" => "none", "language" => "builtin"), "order" => $order);
     $data = HTTPUtil::jsonPostRequest($this->_neo_db->getBaseUri() . 'node/' . $nodeId . "/traverse/node", $params);
     return $data;
 }
예제 #2
0
 /**
  * traverse
  *
  * @throws \Neo4j\Exception\HttpException
  * @param $node
  * @param $returnType
  * @return array
  */
 public function traverse($node, $returnType)
 {
     $this->_data = $this->_description;
     $uri = $node->getUri() . '/traverse' . '/' . $returnType;
     list($response, $http_code) = HTTPUtil::jsonPostRequest($uri, $this->_data);
     if ($http_code != 200) {
         throw new \Neo4j\Exception\HttpException($http_code);
     }
     $objects = array();
     if ($returnType == Database::TYPE_NODE) {
         $inflateClass = 'Node';
         $inflateFunc = 'inflateFromResponse';
     } elseif ($returnType == Database::TYPE_RELATIONSHIP) {
         $inflateClass = 'Relationship';
         $inflateFunc = 'inflateFromResponse';
     } else {
         $inflateClass = 'Path';
         $inflateFunc = 'inflateFromResponse';
     }
     foreach ($response as $result) {
         $objects[] = $inflateClass::$inflateFunc($this->_db, $result);
     }
     return $objects;
 }
 public function delete()
 {
     if (!$this->_is_new) {
         list($response, $http_code) = HTTPUtil::deleteRequest($this->getUri());
         if ($http_code != 204) {
             throw new HttpException($http_code);
         }
         $this->_id = NULL;
         $this->_id_new = TRUE;
     }
 }