src/snac/server/ServerExecutor.php
/**
     * Read Relations for Constellation
     *
     * Reads the relations for the constellation (both in-edges and out-edges).  Returns the two
     * lists in the response.
     *
     * @param string[] $input Input array from the Server object
     * @return string[] The response to send to the client
     * @throws \snac\exceptions\SNACInputException
     */
Read Relations for Constellation
Reads the relations for the constellation (both in-edges and out-edges).  Returns the two
lists in the response.

@param string[] $input Input array from the Server object
@return string[] The response to send to the client
@throws \snac\exceptions\SNACInputException
Read Relations for Constellation Reads the relations for the constellation ( both in - edges and out - edges ) . Returns the two lists in the response . @param string [] $input Input array from the Server object @return string [] The response to send to the client @throws \ snac \ exceptions \ SNACInputException
public function readConstellationRelations(&$input) {
        $response = array();
        $constellations = $this->readConstellationFromDatabase($input, false, \snac\server\database\DBUtil::$READ_MICRO_SUMMARY);
        if ($constellations === null || count($constellations) > 1) {
            throw new \snac\exceptions\SNACInputException("Constellation not found", 404);
        }
        $constellation = $constellations[0];
        if (\snac\Config::$USE_NEO4J) {
            $return = array("in" => array(), "out" => array());
            $results = $this->neo4J->listConstellationInEdges($constellation);
            foreach ($results as $result) {
                array_push($return["in"],
                    array(
                        "constellation" => $this->cStore->readPublishedConstellationByID(
                            $result["constellation"]->getID(),
                            \snac\server\database\DBUtil::$READ_MICRO_SUMMARY)->toArray(),
                         "relation" => $result["relation"]->toArray()
                     )
                );
            }
            $results = $this->neo4J->listConstellationOutEdges($constellation);
            foreach ($results as $result) {
                array_push($return["out"],
                    array(
                        "constellation" => $this->cStore->readPublishedConstellationByID(
                            $result["constellation"]->getID(),
                            \snac\server\database\DBUtil::$READ_MICRO_SUMMARY)->toArray(),
                         "relation" => $result["relation"]->toArray()
                     )
                );
            }
            $response = $return;
            $response["result"] = "success";
        } else {
            $return = array("in" => array(), "out" => array());
            $this->logger->addDebug("Getting In Edges from Postgres");
            $results = $this->cStore->listConstellationInEdges($constellation);
            foreach ($results as $result) {
                array_push($return["in"], array("constellation" => $result["constellation"]->toArray(),
                                                "relation" => $result["relation"]->toArray()));
            }
            $this->logger->addDebug("Reading full constellation for out edges");
            $fullConstellation = $this->cStore->readPublishedConstellationByID($constellation->getID(),
                                        \snac\server\database\DBUtil::$READ_MICRO_SUMMARY
                                        | \snac\server\database\DBUtil::$READ_RELATIONS);
            $this->logger->addDebug("Parsing out edges and grabbing micro summaries");
            foreach ($fullConstellation->getRelations() as $rel) {
                $target = $this->cStore->readPublishedConstellationByID($rel->getTargetConstellation(),
                                                \snac\server\database\DBUtil::$READ_MICRO_SUMMARY);
                if ($target) {
                    array_push($return["out"], array(
                        "constellation" => $target->toArray(),
                        "relation" => $rel->toArray()
                    ));
                }
            }
            $this->logger->addDebug("Created postgres constellation relations response to the user");
            $response = $return;
            $response["result"] = "success";
        }
        return $response;
    }
public function readConstellationRelations ( & $ input ) { $ response = array ( ) ; $ constellations = $ this -> readConstellationFromDatabase ( $ input , false , \ snac \ server \ database \ DBUtil :: $ READ_MICRO_SUMMARY ) ; if ( $ constellations === null || count ( $ constellations ) > 1 ) { throw new \ snac \ exceptions \ SNACInputException ( " Constellation not found " , 404 ) ; } $ constellation = $ constellations [ 0 ] ; if ( \ snac \ Config :: $ USE_NEO4J ) { $ return = array ( " in " => array ( ) , " out " => array ( ) ) ; $ results = $ this -> neo4J -> listConstellationInEdges ( $ constellation ) ; foreach ( $ results as $ result ) { array_push ( $ return [ " in " ] , array ( " constellation " => $ this -> cStore -> readPublishedConstellationByID ( $ result [ " constellation " ] -> getID ( ) , \ snac \ server \ database \ DBUtil :: $ READ_MICRO_SUMMARY ) -> toArray ( ) , " relation " => $ result [ " relation " ] -> toArray ( ) ) ) ; } $ results = $ this -> neo4J -> listConstellationOutEdges ( $ constellation ) ; foreach ( $ results as $ result ) { array_push ( $ return [ " out " ] , array ( " constellation " => $ this -> cStore -> readPublishedConstellationByID ( $ result [ " constellation " ] -> getID ( ) , \ snac \ server \ database \ DBUtil :: $ READ_MICRO_SUMMARY ) -> toArray ( ) , " relation " => $ result [ " relation " ] -> toArray ( ) ) ) ; } $ response = $ return ; $ response [ " result " ] = " success " ; } else { $ return = array ( " in " => array ( ) , " out " => array ( ) ) ; $ this -> logger -> addDebug ( " Getting In Edges from Postgres " ) ; $ results = $ this -> cStore -> listConstellationInEdges ( $ constellation ) ; foreach ( $ results as $ result ) { array_push ( $ return [ " in " ] , array ( " constellation " => $ result [ " constellation " ] -> toArray ( ) , " relation " => $ result [ " relation " ] -> toArray ( ) ) ) ; } $ this -> logger -> addDebug ( " Reading full constellation for out edges " ) ; $ fullConstellation = $ this -> cStore -> readPublishedConstellationByID ( $ constellation -> getID ( ) , \ snac \ server \ database \ DBUtil :: $ READ_MICRO_SUMMARY | \ snac \ server \ database \ DBUtil :: $ READ_RELATIONS ) ; $ this -> logger -> addDebug ( " Parsing out edges and grabbing micro summaries " ) ; foreach ( $ fullConstellation -> getRelations ( ) as $ rel ) { $ target = $ this -> cStore -> readPublishedConstellationByID ( $ rel -> getTargetConstellation ( ) , \ snac \ server \ database \ DBUtil :: $ READ_MICRO_SUMMARY ) ; if ( $ target ) { array_push ( $ return [ " out " ] , array ( " constellation " => $ target -> toArray ( ) , " relation " => $ rel -> toArray ( ) ) ) ; } } $ this -> logger -> addDebug ( " Created postgres constellation relations response to the user " ) ; $ response = $ return ; $ response [ " result " ] = " success " ; } return $ response ; }
Read Relations for Constellation
 Reads the relations for the constellation (both in-edges and out-edges).
Read Relations for Constellation Reads the relations for the constellation ( both in - edges and out - edges ) .
// Use the first entry in the list // TODO: We need to fully implement Neo4J so that we can ask these questions of that system // For now, we'll hack it out. //if (false) { // If using Neo4J, then ask Neo4J.  It will be a faster response time. // Send the response back to the web client // If not using Neo4J, then we must ask DBUtil to get the information from Postgres.