-
Notifications
You must be signed in to change notification settings - Fork 135
Spatial #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Spatial #147
Changes from all commits
d6a1846
bb49839
dc2f70e
ec98f6b
36112d3
bcc54dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| { | ||
| "name": "everyman/neo4jphp", | ||
| "name": "tomcorbett/neo4jphp", | ||
| "type": "library", | ||
| "description": "Wrapper for the Neo4j graph database REST interface", | ||
| "keywords": ["neo4j","graph","database"], | ||
| "homepage": "http://github.com/jadell/neo4jphp/wiki", | ||
| "license": "MIT", | ||
| "authors": [ | ||
| {"name": "Josh Adell", "email": "josh.adell@gmail.com", "homepage": "http://joshadell.com"} | ||
| {"name": "Josh Adell", "email": "josh.adell@gmail.com", "homepage": "http://joshadell.com"}, | ||
| {"name": "Thomas Corbett", "email": "thomas.michael.corbett@gmail.com"} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe provide a contributors name that link to the repository contributors : https://github.com/jadell/neo4jphp/graphs/contributors
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Kwattro Yes I did mean to do that, all of this was done pretty quickly but completely agree! |
||
| ], | ||
| "require": { | ||
| "php": ">=5.3.0", | ||
|
|
@@ -19,5 +20,6 @@ | |
| }, | ||
| "autoload": { | ||
| "psr-0": {"Everyman\\Neo4j":"lib/"} | ||
| } | ||
| }, | ||
| "version": "1.0.1-beta" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Latest tag is 0.1.0, so should be 0.1.1 IMO |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| <?php | ||
| namespace Everyman\Neo4j\Command; | ||
|
|
||
| use Everyman\Neo4j\Command, | ||
| Everyman\Neo4j\Client, | ||
| Everyman\Neo4j\Exception, | ||
| Everyman\Neo4j\PropertyContainer, | ||
| Everyman\Neo4j\SpatialLayer; | ||
|
|
||
| /** | ||
| * Add an entity to an a spatial layer | ||
| */ | ||
| class AddToLayer extends Command | ||
| { | ||
| protected $layer = null; | ||
| protected $entity = null; | ||
| protected $key = null; | ||
| protected $value = null; | ||
|
|
||
| /** | ||
| * Set the layer to drive the command | ||
| * | ||
| * @param Client $client | ||
| * @param SpatialLayer $layer | ||
| * @param PropertyContainer $entity | ||
| * @param string $key | ||
| * @param string $value | ||
| */ | ||
| public function __construct(Client $client, SpatialLayer $layer, PropertyContainer $entity) | ||
| { | ||
| parent::__construct($client); | ||
| $this->layer = $layer; | ||
| $this->entity = $entity; | ||
| } | ||
|
|
||
| /** | ||
| * Return the data to pass | ||
| * | ||
| * @return mixed | ||
| */ | ||
| protected function getData() | ||
| { | ||
| if (!$this->entity || !$this->entity->hasId()) { | ||
| throw new Exception('No entity to add to layer specified'); | ||
| } | ||
|
|
||
| return array( | ||
| 'node' => $this->getTransport()->getEndpoint().'/'. 'node' .'/'.$this->entity->getId(), | ||
| 'layer' => $this->layer->getName() | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Return the transport method to call | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getMethod() | ||
| { | ||
| return 'post'; | ||
| } | ||
|
|
||
| /** | ||
| * Return the path to use | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getPath() | ||
| { | ||
| return '/ext/SpatialPlugin/graphdb/addNodeToLayer'; | ||
| } | ||
|
|
||
| /** | ||
| * Use the results | ||
| * | ||
| * @param integer $code | ||
| * @param array $headers | ||
| * @param array $data | ||
| * @return integer on failure | ||
| */ | ||
| protected function handleResult($code, $headers, $data) | ||
| { | ||
| if ((int)($code / 100) != 2) { | ||
| $this->throwException('Unable to add entity to spatial layer', $code, $headers, $data); | ||
| } | ||
| return true; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| <?php | ||
| namespace Everyman\Neo4j\Command; | ||
|
|
||
| use Everyman\Neo4j\Command, | ||
| Everyman\Neo4j\Client, | ||
| Everyman\Neo4j\SpatialLayer\SimplePointLayer; | ||
|
|
||
| /** | ||
| * Create a SimplePointLayer | ||
| */ | ||
| class CreateSimplePointLayer extends Command | ||
| { | ||
| protected $simplePointLayer = null; | ||
|
|
||
| /** | ||
| * Set the simplePointLayer to drive the command | ||
| * | ||
| * @param Client $client | ||
| * @param Node $node | ||
| */ | ||
| public function __construct(Client $client, SimplePointLayer $simplePointLayer) | ||
| { | ||
| parent::__construct($client); | ||
| $this->simplePointLayer = $simplePointLayer; | ||
| } | ||
|
|
||
| protected function getData() | ||
| { | ||
| return array( | ||
| 'layer' => $this->getName(), | ||
| 'lat' => $this->getLat(), | ||
| 'lon' => $this->getLon(), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Return the name of the layer | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getName() | ||
| { | ||
| return $this->simplePointLayer->getName() ?: null; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getLat() | ||
| { | ||
| return $this->simplePointLayer->getLat() ?: null; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getLon() | ||
| { | ||
| return $this->simplePointLayer->getLon() ?: null; | ||
| } | ||
|
|
||
| /** | ||
| * Return the transport method to call | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getMethod() | ||
| { | ||
| return 'post'; | ||
| } | ||
|
|
||
| /** | ||
| * Return the path to use | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getPath() | ||
| { | ||
| return '/ext/SpatialPlugin/graphdb/addSimplePointLayer'; | ||
| } | ||
|
|
||
| /** | ||
| * Use the results | ||
| * | ||
| * @param integer $code | ||
| * @param array $headers | ||
| * @param array $data | ||
| * @return boolean true on success | ||
| * @throws Exception on failure | ||
| */ | ||
| protected function handleResult($code, $headers, $data) | ||
| { | ||
| if ((int)($code / 100) != 2) { | ||
| $this->throwException('Unable to create SimplePointLayer', $code, $headers, $data); | ||
| } | ||
|
|
||
| //$nodeId = $this->getEntityMapper()->getIdFromUri($headers['Location']); | ||
| //$this->node->setId($nodeId); | ||
| //$this->getEntityCache()->setCachedEntity($this->node); | ||
| return true; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why changing package name ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Kwattro sorry I have been away for 2 weeks so just seeing this now. Anything I changed was because I was branching off of this project as after speaking to @jadell he didn't have time to review and advised I just forked and continued using my fork, so I am for now as I am actively using this library in one of my own projects.
If we do get some people to review my changes of course I will go through all changes with them and happy to change everything back.