/**
  *
  * @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 save()
 {
     if ($this->_is_new) {
         $payload = array('to' => $this->getEndNode()->getUri(), 'type' => $this->_type, 'data' => $this->_data);
         list($response, $http_code) = HTTPUtil::jsonPostRequest($this->getUri(), $payload);
         if ($http_code != 201) {
             throw new HttpException($http_code);
         }
     } else {
         list($response, $http_code) = HTTPUtil::jsonPutRequest($this->getUri() . '/properties', $this->_data);
         if ($http_code != 204) {
             throw new HttpException($http_code);
         }
     }
     if ($this->_is_new) {
         $this->_id = end(explode("/", $response['self']));
         $this->_is_new = FALSE;
     }
 }