/** * Make a new Relationship instance. * * @param string $type * @param \Vinelab\NeoEloquent\Eloquent\Model $startModel * @param \Vinelab\NeoEloquent\Eloquent\Model $endModel * @param array $properties * @return \Everyman\Neo4j\Relationship */ protected function makeRelationship($type, $startModel, $endModel, $properties = array()) { return $this->client->makeRelationship()->setType($this->type)->setStartNode($this->start)->setEndNode($this->end)->setProperties($this->attributes); }
protected static function importRelations($nodeIds, Client $targetClient, $resultSet, $ignoreProperties = null) { $result = array(); $id = null; $batch = new Batch($targetClient); foreach ($resultSet as $row) { $id = $row[0]['metadata']['id']; $type = $row[0]['type']; $properties = $row[0]['data']; if (isset($ignoreProperties)) { foreach ($properties as $key => $propertyName) { if (in_array($propertyName, $ignoreProperties)) { unset($properties[$key]); } } } $leftNode = $targetClient->makeNode(); $leftNodeId = $nodeIds[static::extractIdFromUrl($row[0]['start'])]; $leftNode->setId($leftNodeId); $rightNode = $targetClient->makeNode(); $rightNodeId = $nodeIds[static::extractIdFromUrl($row[0]['end'])]; $rightNode->setId($rightNodeId); $r = $targetClient->makeRelationship($properties); $r->setStartNode($leftNode)->setEndNode($rightNode)->setType($type)->setProperties($properties); $batch->save($r); } $batch->commit(); return array($result, isset($id) ? $id + 1 : null); }