src/snac/server/neo4j/Neo4JUtil.php
/**
     * Write or Update Resource Node
     *
     * Writes the given resource to a resource node in Neo4J.  If it already exists, the node will be
     * updated. If not, it is inserted.
     *
     * @param \snac\data\Resource $resource The resource object to insert/update in Neo4J
     */
Write or Update Resource Node
Writes the given resource to a resource node in Neo4J.  If it already exists, the node will be
updated. If not, it is inserted.

@param \snac\data\Resource $resource The resource object to insert/update in Neo4J
Write or Update Resource Node Writes the given resource to a resource node in Neo4J . If it already exists the node will be updated . If not it is inserted . @param \ snac \ data \ Resource $resource The resource object to insert / update in Neo4J
public function updateResourceIndex(&$resource) {
        if ($this->connector != null) {
            $this->logger->addDebug("Updating/Inserting Node into Neo4J database");
            $result = $this->connector->run("MATCH (a:Resource {id: {id} }) SET a.title = {title}, a.version = {version}, a.href = {href}
                return a;",
                [
                    'id' => $resource->getID(),
                    'version' => $resource->getVersion(),
                    'title' => $resource->getTitle(),
                    'href' => $resource->getLink()
                ]
            );
            $records = $result->getRecords();
            if (empty($records)) {
                $result = $this->connector->run("CREATE (n:Resource) SET n += {infos};",
                    [
                        "infos" => [
                            'id' => $resource->getID(),
                            'version' => $resource->getVersion(),
                            'title' => $resource->getTitle(),
                            'href' => $resource->getLink()
                        ]
                    ]
                );
            }
            $result = $this->connector->run("MATCH (a:Resource {id: {id} })-[r:HIRELATION]->()
                return r;",
                [
                    'id' => $resource->getID(),
                ]
            );
            $records = $result->getRecords();
            if (!empty($records)) {
                $result = $this->connector->run("MATCH (a:Resource {id: {id}})-[r:HIRELATION]->() delete r;",
                    [
                        'id' => $resource->getID()
                    ]
                );
            }
            if ($resource->getRepository() != null && $resource->getRepository()->getID() != null) {
                $this->connector->run("MATCH (a:Identity {id: {id1} }) MATCH (b:Resource {id: {id2} }) CREATE (b)-[r:HIRELATION]->(a);",
                    [
                        'id1' => (string) $resource->getRepository()->getID(),
                        'id2' => $resource->getID()
                    ]);
            }
        }
    }
public function updateResourceIndex ( & $ resource ) { if ( $ this -> connector != null ) { $ this -> logger -> addDebug ( " Updating/Inserting Node into Neo4J database " ) ; $ result = $ this -> connector -> run ( " MATCH (a:Resource {id: {id} }) SET a.title = {title}, a.version = {version}, a.href = {href}
                return a; " , [ 'id' => $ resource -> getID ( ) , 'version' => $ resource -> getVersion ( ) , 'title' => $ resource -> getTitle ( ) , 'href' => $ resource -> getLink ( ) ] ) ; $ records = $ result -> getRecords ( ) ; if ( empty ( $ records ) ) { $ result = $ this -> connector -> run ( " CREATE (n:Resource) SET n += {infos}; " , [ " infos " => [ 'id' => $ resource -> getID ( ) , 'version' => $ resource -> getVersion ( ) , 'title' => $ resource -> getTitle ( ) , 'href' => $ resource -> getLink ( ) ] ] ) ; } $ result = $ this -> connector -> run ( " MATCH (a:Resource {id: {id} })-[r:HIRELATION]->()
                return r; " , [ 'id' => $ resource -> getID ( ) , ] ) ; $ records = $ result -> getRecords ( ) ; if ( ! empty ( $ records ) ) { $ result = $ this -> connector -> run ( " MATCH (a:Resource {id: {id}})-[r:HIRELATION]->() delete r; " , [ 'id' => $ resource -> getID ( ) ] ) ; } if ( $ resource -> getRepository ( ) != null && $ resource -> getRepository ( ) -> getID ( ) != null ) { $ this -> connector -> run ( " MATCH (a:Identity {id: {id1} }) MATCH (b:Resource {id: {id2} }) CREATE (b)-[r:HIRELATION]->(a); " , [ 'id1' => ( string ) $ resource -> getRepository ( ) -> getID ( ) , 'id2' => $ resource -> getID ( ) ] ) ; } } }
Write or Update Resource Node
 Writes the given resource to a resource node in Neo4J.
Write or Update Resource Node Writes the given resource to a resource node in Neo4J .
// STEP 1: Update or insert this resource as a node: // Check to see if anything was added // Must create this record instead // STEP 2: Update or insert the resource's link to holding repository // delete the one there so that we can add the correct one (just in case) // If resource has a repository, then add a link