src/snac/server/neo4j/Neo4JUtil.php
/**
     * Redirect/Delete Constellation Node (and related data)
     *
     * Deletes the constellation data found in the given constellation from neo4j while redirecting some of the
     * edges to the given target.
     *
     * @param \snac\data\Constellation $from The constellation object to delete/redirect from Neo4J
     * @param \snac\data\Constellation $to The constellation object that is the target of any redirects
     * @return boolean True if successful, false otherwise
     */
Redirect/Delete Constellation Node (and related data)
Deletes the constellation data found in the given constellation from neo4j while redirecting some of the
edges to the given target.


Redirect / Delete Constellation Node ( and related data ) Deletes the constellation data found in the given constellation from neo4j while redirecting some of the edges to the given target .
public function redirectConstellation(&$from, &$to) {
        if ($from == null || $from->getID() == null || $to == null || $to->getID() == null) {
            return false;
        }
        if ($this->connector != null) {
            $result = $this->connector->run("MATCH p=()-[]->(b:Identity {id: {icid}}) return p;",
                [
                    'icid' => "{$from->getID()}"
                ]
            );
            foreach ($result->getRecords() as $record) {
                $path = $record->pathValue("p");
                $startID = $path->start()->value("id");
                $startLabels = $path->start()->labels();
                $startType = $startLabels[0] ?? null;
                if ($startType == null) {
                    throw new \snac\exceptions\SNACDatabaseException("Neo4J Node did not have a type");
                }
                if (count($path->relationships()) > 1) {
                    $this->logger->addWarning("Redirected a Constellation, {$from->getID()}, which had two in-relations from the same source.");
                }
                foreach ($path->relationships() as $relation) {
                    $type = $relation->type();
                    $data = [];
                    if ($relation->hasValue('id'))
                        $data["id"] = $relation->value('id');
                    if ($relation->hasValue('version'))
                        $data["version"] = $relation->value('version');
                    if ($relation->hasValue('arcrole'))
                        $data["arcrole"] = $relation->value('arcrole');
                    if ($startID != $to->getID()) {
                        $result = $this->connector->run("MATCH (a:$startType {id: {id1} }),(b:Identity {id: {id2} })
                                                            MERGE (a)-[r:$type]->(b) SET r += {infos}",
                        [
                            'id1' => $startID,
                            'id2' => "{$to->getID()}", 
                            'infos' => $data
                        ]);
                    }
                }
            }
            $this->deleteConstellation($from);
            return true;
        }
        return false;
    }
public function redirectConstellation ( & $ from , & $ to ) { if ( $ from == null || $ from -> getID ( ) == null || $ to == null || $ to -> getID ( ) == null ) { return false ; } if ( $ this -> connector != null ) { $ result = $ this -> connector -> run ( " MATCH p=()-[]->(b:Identity {id: {icid}}) return p; " , [ 'icid' => " { $ from -> getID ( ) } " ] ) ; foreach ( $ result -> getRecords ( ) as $ record ) { $ path = $ record -> pathValue ( " p " ) ; $ startID = $ path -> start ( ) -> value ( " id " ) ; $ startLabels = $ path -> start ( ) -> labels ( ) ; $ startType = $ startLabels [ 0 ] ?? null ; if ( $ startType == null ) { throw new \ snac \ exceptions \ SNACDatabaseException ( " Neo4J Node did not have a type " ) ; } if ( count ( $ path -> relationships ( ) ) > 1 ) { $ this -> logger -> addWarning ( " Redirected a Constellation,  { $ from -> getID ( ) } , which had two in-relations from the same source. " ) ; } foreach ( $ path -> relationships ( ) as $ relation ) { $ type = $ relation -> type ( ) ; $ data = [ ] ; if ( $ relation -> hasValue ( 'id' ) ) $ data [ " id " ] = $ relation -> value ( 'id' ) ; if ( $ relation -> hasValue ( 'version' ) ) $ data [ " version " ] = $ relation -> value ( 'version' ) ; if ( $ relation -> hasValue ( 'arcrole' ) ) $ data [ " arcrole " ] = $ relation -> value ( 'arcrole' ) ; if ( $ startID != $ to -> getID ( ) ) { $ result = $ this -> connector -> run ( " MATCH (a: $ startType  {id: {id1} }),(b:Identity {id: {id2} })
                                                            MERGE (a)-[r: $ type ]->(b) SET r += {infos} " , [ 'id1' => $ startID , 'id2' => " { $ to -> getID ( ) } " , 'infos' => $ data ] ) ; } } } $ this -> deleteConstellation ( $ from ) ; return true ; } return false ; }
Redirect/Delete Constellation Node (and related data)
 Deletes the constellation data found in the given constellation from neo4j while redirecting some of the
 edges to the given target.
Redirect / Delete Constellation Node ( and related data ) Deletes the constellation data found in the given constellation from neo4j while redirecting some of the edges to the given target .
// Find all in-relations to the from constellation // Source of relation // Relationship id/version // Need to know Relation type (ICRELATION, RRELATION, HIRELATION) // Resource Relations have id/version // Constellation Relations have arcrole // Add the relation to the other Constellation if the ids are different // Note: matches the two nodes, and if a relation already exists of this type (ICRELATION, //       RRELATION, HIRELATION) then it will just update that relation and overwrite any //       values in Neo4J.  If the relation doesn't exist, it will instead create the //       relation with the information. // need a string for neo4j