src/snac/server/database/DBUtil.php
/**
     * Fill a constellation object from the database
     *
     * Given the id and version number for the Constellation to read, this function does the work of getting
     * that information from the database and populating a Constellation object.  It understands the flags
     * available to read partial constellations, fills out the parts of the constellation requested, and
     * returns the constellation.  This does no checking on the id and version number passed, so if they
     * are not valid, this method will return an empty constellation object.
     *
     * Use the optional flags to get only a partial constellation.  The flags are a bit mask, and can
     * be ORed together.  Certain shortcut flags are available, such as:
     *
     * ```
     * $FULL_CONSTELLATION = $READ_NRD | $READ_ALL_NAMES | $READ_BIOGHIST
     *                       | $READ_BIOGHIST | $READ_RELATIONS
     *                       | $READ_OTHER_EXCEPT_RELATIONS
     * $READ_SHORT_SUMMARY = $READ_NRD | $READ_PREFERRED_NAME | $READ_BIOGHIST
     * ```
     *
     * @param integer[] $vhInfo An associative list with keys 'version', 'ic_id'. Values are integers.
     * @param int $flags optional Flags to indicate which parts of the constellation to read
     *
     * @return \snac\data\Constellation A PHP constellation object.
     *
     */
Fill a constellation object from the database
Given the id and version number for the Constellation to read, this function does the work of getting
that information from the database and populating a Constellation object.  It understands the flags
available to read partial constellations, fills out the parts of the constellation requested, and
returns the constellation.  This does no checking on the id and version number passed, so if they
are not valid, this method will return an empty constellation object.

Use the optional flags to get only a partial constellation.  The flags are a bit mask, and can
be ORed together.  Certain shortcut flags are available, such as.



@param integer[] $vhInfo An associative list with keys 'version', 'ic_id'. Values are integers.
@param int $flags optional Flags to indicate which parts of the constellation to read

@return \snac\data\Constellation A PHP constellation object.
Fill a constellation object from the database Given the id and version number for the Constellation to read this function does the work of getting that information from the database and populating a Constellation object . It understands the flags available to read partial constellations fills out the parts of the constellation requested and returns the constellation . This does no checking on the id and version number passed so if they are not valid this method will return an empty constellation object . Use the optional flags to get only a partial constellation . The flags are a bit mask and can be ORed together . Certain shortcut flags are available such as . @param integer [] $vhInfo An associative list with keys ' version ' ' ic_id ' . Values are integers . @param int $flags optional Flags to indicate which parts of the constellation to read @return \ snac \ data \ Constellation A PHP constellation object .
private function selectConstellation($vhInfo, $flags=0)
    {
        if ($flags == 0)
            $flags = DBUtil::$FULL_CONSTELLATION;
        $this->dataCache = array();
        $tableName = 'version_history';
        $cObj = new \snac\data\Constellation();
        $this->logger->addDebug("The flags are set at " . $flags);
        $this->populateNrd($vhInfo, $cObj);
        if (($flags & (DBUtil::$READ_SCM_METADATA)) != 0) {
            $this->logger->addDebug("Populating Caches: Meta");
            $this->populateMetaCache($vhInfo);
        }
        if (($flags & (DBUtil::$READ_OTHER_EXCEPT_RELATIONS)) != 0) {
            $this->logger->addDebug("Populating Caches: Date");
            $this->populateDateCache($vhInfo);
            $this->logger->addDebug("Populating Caches: Name");
            $this->populateNameCache($vhInfo);
            $this->logger->addDebug("Populating Caches: Language");
            $this->populateLanguageCache($vhInfo);
        }
        if (($flags & (DBUtil::$READ_ALL_NAMES | DBUtil::$READ_PREFERRED_NAME)) != 0) {
            $this->logger->addDebug("The user wants name(s)");
            $getAllNames = false;
            if (($flags & DBUtil::$READ_ALL_NAMES) != 0)
                $getAllNames = true;
            $this->populateNameEntry($vhInfo, $cObj, $getAllNames);
        }
        if (($flags & (DBUtil::$READ_BIOGHIST)) != 0) {
            $this->logger->addDebug("The user wants BiogHist");
            $this->populateBiogHist($vhInfo, $cObj);
        }
        if (($flags & DBUtil::$READ_OTHER_EXCEPT_RELATIONS) != 0 ||
            ($flags & DBUtil::$READ_PLACE_INFORMATION) != 0) {
            $this->logger->addDebug("The user wants place information");
            $this->populatePlace($vhInfo, $cObj, $cObj->getID(), 'version_history'); 
        }
        if (($flags & (DBUtil::$READ_SCM_METADATA)) != 0) {
            $this->logger->addDebug("The user wants metadata information");
            $this->logger->addDebug("  Source");
            $this->populateSourceConstellation($vhInfo, $cObj); 
            $this->logger->addDebug("  CD");
            $this->populateConventionDeclaration($vhInfo, $cObj);
        }
        if (($flags & DBUtil::$READ_OTHER_EXCEPT_RELATIONS) != 0) {
            $this->logger->addDebug("The user wants data except relations");
            $this->logger->addDebug("  Meta");
            $this->populateMeta($vhInfo, $cObj, $tableName);
            $this->logger->addDebug("  Dates");
            $this->populateDate($vhInfo, $cObj, $tableName); 
            $this->logger->addDebug("  Activity");
            $this->populateActivity($vhInfo, $cObj);
            $this->logger->addDebug("  Gender");
            $this->populateGender($vhInfo, $cObj);
            $this->logger->addDebug("  General Context");
            $this->populateGeneralContext($vhInfo, $cObj);
            $this->logger->addDebug("  Languages");
            $this->populateLanguage($vhInfo, $cObj, $cObj->getID(), $tableName); 
            $this->logger->addDebug("  Legal Status");
            $this->populateLegalStatus($vhInfo, $cObj);
            $this->logger->addDebug("  Mandate");
            $this->populateMandate($vhInfo, $cObj);
            $this->logger->addDebug("  Nationality");
            $this->populateNationality($vhInfo, $cObj);
            $this->logger->addDebug("  Occupation");
            $this->populateOccupation($vhInfo, $cObj);
            $this->logger->addDebug("  OtherRecordID");
            $this->populateOtherRecordID($vhInfo, $cObj);
            $this->logger->addDebug("  EntityID");
            $this->populateEntityID($vhInfo, $cObj);
            $this->logger->addDebug("  SoG");
            $this->populateStructureOrGenealogy($vhInfo, $cObj);
            $this->logger->addDebug("  Subject");
            $this->populateSubject($vhInfo, $cObj);
        }
        if (($flags & DBUtil::$READ_RELATIONS) != 0) {
            $this->logger->addDebug("The user wants relations");
            $this->populateRelation($vhInfo, $cObj); 
        }
        if (($flags & DBUtil::$READ_RESOURCE_RELATIONS) != 0) {
            $this->logger->addDebug("The user wants resource relations");
            $this->populateResourceRelation($vhInfo, $cObj); 
        }
        if (($flags & DBUtil::$READ_MAINTENANCE_INFORMATION) != 0) {
            $this->logger->addDebug("The user wants maintenance info");
            $this->populateMaintenanceInformation($vhInfo, $cObj);
            $cObj->setMaintenanceAgency("SNAC: Social Networks and Archival Context");
            $cObj->setMaintenanceStatus(new \snac\data\Term(array("term"=>"revised")));
        }
        return $cObj;
    }
private function selectConstellation ( $ vhInfo , $ flags = 0 ) { if ( $ flags == 0 ) $ flags = DBUtil :: $ FULL_CONSTELLATION ; $ this -> dataCache = array ( ) ; $ tableName = 'version_history' ; $ cObj = new \ snac \ data \ Constellation ( ) ; $ this -> logger -> addDebug ( " The flags are set at  " . $ flags ) ; $ this -> populateNrd ( $ vhInfo , $ cObj ) ; if ( ( $ flags & ( DBUtil :: $ READ_SCM_METADATA ) ) != 0 ) { $ this -> logger -> addDebug ( " Populating Caches: Meta " ) ; $ this -> populateMetaCache ( $ vhInfo ) ; } if ( ( $ flags & ( DBUtil :: $ READ_OTHER_EXCEPT_RELATIONS ) ) != 0 ) { $ this -> logger -> addDebug ( " Populating Caches: Date " ) ; $ this -> populateDateCache ( $ vhInfo ) ; $ this -> logger -> addDebug ( " Populating Caches: Name " ) ; $ this -> populateNameCache ( $ vhInfo ) ; $ this -> logger -> addDebug ( " Populating Caches: Language " ) ; $ this -> populateLanguageCache ( $ vhInfo ) ; } if ( ( $ flags & ( DBUtil :: $ READ_ALL_NAMES | DBUtil :: $ READ_PREFERRED_NAME ) ) != 0 ) { $ this -> logger -> addDebug ( " The user wants name(s) " ) ; $ getAllNames = false ; if ( ( $ flags & DBUtil :: $ READ_ALL_NAMES ) != 0 ) $ getAllNames = true ; $ this -> populateNameEntry ( $ vhInfo , $ cObj , $ getAllNames ) ; } if ( ( $ flags & ( DBUtil :: $ READ_BIOGHIST ) ) != 0 ) { $ this -> logger -> addDebug ( " The user wants BiogHist " ) ; $ this -> populateBiogHist ( $ vhInfo , $ cObj ) ; } if ( ( $ flags & DBUtil :: $ READ_OTHER_EXCEPT_RELATIONS ) != 0 || ( $ flags & DBUtil :: $ READ_PLACE_INFORMATION ) != 0 ) { $ this -> logger -> addDebug ( " The user wants place information " ) ; $ this -> populatePlace ( $ vhInfo , $ cObj , $ cObj -> getID ( ) , 'version_history' ) ; } if ( ( $ flags & ( DBUtil :: $ READ_SCM_METADATA ) ) != 0 ) { $ this -> logger -> addDebug ( " The user wants metadata information " ) ; $ this -> logger -> addDebug ( "   Source " ) ; $ this -> populateSourceConstellation ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   CD " ) ; $ this -> populateConventionDeclaration ( $ vhInfo , $ cObj ) ; } if ( ( $ flags & DBUtil :: $ READ_OTHER_EXCEPT_RELATIONS ) != 0 ) { $ this -> logger -> addDebug ( " The user wants data except relations " ) ; $ this -> logger -> addDebug ( "   Meta " ) ; $ this -> populateMeta ( $ vhInfo , $ cObj , $ tableName ) ; $ this -> logger -> addDebug ( "   Dates " ) ; $ this -> populateDate ( $ vhInfo , $ cObj , $ tableName ) ; $ this -> logger -> addDebug ( "   Activity " ) ; $ this -> populateActivity ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   Gender " ) ; $ this -> populateGender ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   General Context " ) ; $ this -> populateGeneralContext ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   Languages " ) ; $ this -> populateLanguage ( $ vhInfo , $ cObj , $ cObj -> getID ( ) , $ tableName ) ; $ this -> logger -> addDebug ( "   Legal Status " ) ; $ this -> populateLegalStatus ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   Mandate " ) ; $ this -> populateMandate ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   Nationality " ) ; $ this -> populateNationality ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   Occupation " ) ; $ this -> populateOccupation ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   OtherRecordID " ) ; $ this -> populateOtherRecordID ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   EntityID " ) ; $ this -> populateEntityID ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   SoG " ) ; $ this -> populateStructureOrGenealogy ( $ vhInfo , $ cObj ) ; $ this -> logger -> addDebug ( "   Subject " ) ; $ this -> populateSubject ( $ vhInfo , $ cObj ) ; } if ( ( $ flags & DBUtil :: $ READ_RELATIONS ) != 0 ) { $ this -> logger -> addDebug ( " The user wants relations " ) ; $ this -> populateRelation ( $ vhInfo , $ cObj ) ; } if ( ( $ flags & DBUtil :: $ READ_RESOURCE_RELATIONS ) != 0 ) { $ this -> logger -> addDebug ( " The user wants resource relations " ) ; $ this -> populateResourceRelation ( $ vhInfo , $ cObj ) ; } if ( ( $ flags & DBUtil :: $ READ_MAINTENANCE_INFORMATION ) != 0 ) { $ this -> logger -> addDebug ( " The user wants maintenance info " ) ; $ this -> populateMaintenanceInformation ( $ vhInfo , $ cObj ) ; $ cObj -> setMaintenanceAgency ( " SNAC: Social Networks and Archival Context " ) ; $ cObj -> setMaintenanceStatus ( new \ snac \ data \ Term ( array ( " term " => " revised " ) ) ) ; } return $ cObj ; }
Fill a constellation object from the database
 Given the id and version number for the Constellation to read, this function does the work of getting
 that information from the database and populating a Constellation object.
Fill a constellation object from the database Given the id and version number for the Constellation to read this function does the work of getting that information from the database and populating a Constellation object .
// Update the flags, if needed, to be the full constellation // empty data cache // Log what completeness of constellation we're getting // Always populating the NRD information // IF the user wants metadata, then populate the cache for it // If getting more than a "summary," then populate the caches.  If not, then we can ignore them // If the caller has requested any names, then we should pull them out // Constellation->getID() returns ic_id aka nrd.ic_id // If the user wants metadata, then include sources and convention declarations // "Constellation Source" in the order of statements here // "Constellation Date" in SQL these dates are linked to table nrd. // Constellation->getID() returns ic_id aka nrd.ic_id // aka cpfRelation // resourceRelation // If the user requested maintenance history be added to the constellation, then add it.