src/snac/server/ServerExecutor.php
/**
     * Merge Constellations
     *
     * Given a constellation object and two constellation ids, this method will create a new Constellation
     * object and store it in the database (as the merged version of the two ids).  Then, it will tombstone
     * the Constellations at each of those IDs and point them to the merged version.
     *
     * @param string[] $input Input array from the Server object
     * @throws \snac\exceptions\SNACPermissionException
     * @throws \snac\exceptions\SNACInputException
     * @throws \snac\exceptions\SNACDatabaseException
     * @return string[] The response to send to the client
     */
Merge Constellations
Given a constellation object and two constellation ids, this method will create a new Constellation
object and store it in the database (as the merged version of the two ids).  Then, it will tombstone
the Constellations at each of those IDs and point them to the merged version.


Merge Constellations Given a constellation object and two constellation ids this method will create a new Constellation object and store it in the database ( as the merged version of the two ids ) . Then it will tombstone the Constellations at each of those IDs and point them to the merged version .
function mergeConstellations(&$input) {
        $response = array();
        $this->logger->addDebug("Merging constellations");
        if (isset($input["constellationids"]) && is_array($input["constellationids"]) && isset($input["constellation"])) {
            if (count($input["constellationids"]) < 2) {
                throw new \snac\exceptions\SNACInputException("Must merge at least 2 Constellations", 400);
            }
            $constellation = new \snac\data\Constellation($input["constellation"]);
            if ($constellation->isEmpty()) {
                throw new \snac\exceptions\SNACInputException("Merged constellation is empty", 400);
            }
            $info = array();
            foreach ($input["constellationids"] as $cId) {
                if (!is_numeric($cId)) {
                    throw new \snac\exceptions\SNACInputException("Constellation ID $cId is not correctly formatted", 400);
                }
                $info[$cId] = $this->cStore->readConstellationUserStatus($cId);
                if (!is_array($info[$cId])) {
                    throw new \snac\exceptions\SNACInputException("Constellation $cId does not have a current version", 404);
                }
                if ($this->user->getUserID() !== $info[$cId]["userid"]) {
                    throw new \snac\exceptions\SNACPermissionException("User trying to merge constellations not checked out to them", 403);
                }
            }
            $originals = array();
            foreach ($input["constellationids"] as $cId) {
                $originals[$cId] = $this->cStore->readConstellation($cId, null,
                        \snac\server\database\DBUtil::$READ_NRD | \snac\server\database\DBUtil::$READ_OTHER_EXCEPT_RELATIONS
                        | \snac\server\database\DBUtil::$READ_ALL_NAMES);
            }
            return $this->coreMerge($constellation, $originals);
        } else {
            throw new \snac\exceptions\SNACInputException("Merge requires two constellation IDs and a merged constellation", 400);
        }
    }
function mergeConstellations ( & $ input ) { $ response = array ( ) ; $ this -> logger -> addDebug ( " Merging constellations " ) ; if ( isset ( $ input [ " constellationids " ] ) && is_array ( $ input [ " constellationids " ] ) && isset ( $ input [ " constellation " ] ) ) { if ( count ( $ input [ " constellationids " ] ) < 2 ) { throw new \ snac \ exceptions \ SNACInputException ( " Must merge at least 2 Constellations " , 400 ) ; } $ constellation = new \ snac \ data \ Constellation ( $ input [ " constellation " ] ) ; if ( $ constellation -> isEmpty ( ) ) { throw new \ snac \ exceptions \ SNACInputException ( " Merged constellation is empty " , 400 ) ; } $ info = array ( ) ; foreach ( $ input [ " constellationids " ] as $ cId ) { if ( ! is_numeric ( $ cId ) ) { throw new \ snac \ exceptions \ SNACInputException ( " Constellation ID  $ cId  is not correctly formatted " , 400 ) ; } $ info [ $ cId ] = $ this -> cStore -> readConstellationUserStatus ( $ cId ) ; if ( ! is_array ( $ info [ $ cId ] ) ) { throw new \ snac \ exceptions \ SNACInputException ( " Constellation  $ cId  does not have a current version " , 404 ) ; } if ( $ this -> user -> getUserID ( ) !== $ info [ $ cId ] [ " userid " ] ) { throw new \ snac \ exceptions \ SNACPermissionException ( " User trying to merge constellations not checked out to them " , 403 ) ; } } $ originals = array ( ) ; foreach ( $ input [ " constellationids " ] as $ cId ) { $ originals [ $ cId ] = $ this -> cStore -> readConstellation ( $ cId , null , \ snac \ server \ database \ DBUtil :: $ READ_NRD | \ snac \ server \ database \ DBUtil :: $ READ_OTHER_EXCEPT_RELATIONS | \ snac \ server \ database \ DBUtil :: $ READ_ALL_NAMES ) ; } return $ this -> coreMerge ( $ constellation , $ originals ) ; } else { throw new \ snac \ exceptions \ SNACInputException ( " Merge requires two constellation IDs and a merged constellation " , 400 ) ; } }
Merge Constellations
 Given a constellation object and two constellation ids, this method will create a new Constellation
 object and store it in the database (as the merged version of the two ids).
Merge Constellations Given a constellation object and two constellation ids this method will create a new Constellation object and store it in the database ( as the merged version of the two ids ) .
// This constellation is NOT checked out to this user, and so we cannot allow the merge // to continue // We have multiple constellation ids that should be merged and the "merged" copy of the constellation // ACTUALLY DOING THE MERGING STEPS IN THE SYSTEM // Read parts of the to-merge constellations (need NRD and Sources and NameEntries)