src/snac/server/database/DBUtil.php
/**
     * Save Activity
     *
     *  | php activity        | sql               | cpf                             |
     *  |---------------------+-------------------+---------------------------------|
     *  | getType             | activity_type     | activity/@localType             |
     *  | getTerm             | activity_id       | activity/term                   |
     *  | getVocabularySource | vocabulary_source | activity/term/@vocabularySource |
     *  | getNote             | note              | activity/descriptiveNote        |
     *  | getDateList         | table date_range  | activity/dateRange              |
     *
     *
     * I considered adding keys for the second arg, but is not clear that using them for sanity checking
     * would gain anything. The low level code would become more fragile, and would break "separation of
     * concerns". The sanity check would require that the low level code have knowledge about the
     * structure of things that aren't really low level. Remember: SQL code only knows how to put data in
     * the database. Any sanity check should happen up here.
     *
     *
     * Activities have a type (Term object) derived from function/@localType. The function/term is a Term object.
     *
     * prototype: insertActivity($vhInfo, $id, $type, $vocabularySource, $note, $term)
     *
     * Example files: /data/extract/anf/FRAN_NP_050744.xml
     *
     *
     * @param integer[] $vhInfo list with keys version, ic_id.
     *
     * @param $cObj \snac\data\Constellation object
     */


I considered adding keys for the second arg, but is not clear that using them for sanity checking
would gain anything. The low level code would become more fragile, and would break "separation of
concerns". The sanity check would require that the low level code have knowledge about the
structure of things that aren't really low level. Remember: SQL code only knows how to put data in
the database. Any sanity check should happen up here.

Activities have a type (Term object) derived from function/@localType. The function/term is a Term object.





@param integer[] $vhInfo list with keys version, ic_id.

@param $cObj \snac\data\Constellation object
I considered adding keys for the second arg but is not clear that using them for sanity checking would gain anything . The low level code would become more fragile and would break " separation of concerns " . The sanity check would require that the low level code have knowledge about the structure of things that aren ' t really low level . Remember : SQL code only knows how to put data in the database . Any sanity check should happen up here . Activities have a type ( Term object ) derived from function / @localType . The function / term is a Term object . @param integer [] $vhInfo list with keys version ic_id . @param $cObj \ snac \ data \ Constellation object
private function saveActivity($vhInfo, $cObj)
    {
        foreach ($cObj->getActivities() as $activityData)
        {
            $activityID = $activityData->getID();
            if ($this->prepOperation($vhInfo, $activityData))
            {
                $activityID = $this->sql->insertActivity($vhInfo,
                                                    $activityData->getID(), 
                                                    $this->termID($activityData->getType()), 
                                                    $activityData->getVocabularySource(),
                                                    $activityData->getNote(),
                                                    $this->termID($activityData->getTerm())); 
                $activityData->setID($activityID);
                $activityData->setVersion($vhInfo['version']);
            }
            $this->saveMeta($vhInfo, $activityData, 'activity', $activityID);
            foreach ($activityData->getDateList() as $date)
            {
                $this->saveDate($vhInfo, $date, 'activity', $activityID);
            }
        }
    }
private function saveActivity ( $ vhInfo , $ cObj ) { foreach ( $ cObj -> getActivities ( ) as $ activityData ) { $ activityID = $ activityData -> getID ( ) ; if ( $ this -> prepOperation ( $ vhInfo , $ activityData ) ) { $ activityID = $ this -> sql -> insertActivity ( $ vhInfo , $ activityData -> getID ( ) , $ this -> termID ( $ activityData -> getType ( ) ) , $ activityData -> getVocabularySource ( ) , $ activityData -> getNote ( ) , $ this -> termID ( $ activityData -> getTerm ( ) ) ) ; $ activityData -> setID ( $ activityID ) ; $ activityData -> setVersion ( $ vhInfo [ 'version' ] ) ; } $ this -> saveMeta ( $ vhInfo , $ activityData , 'activity' , $ activityID ) ; foreach ( $ activityData -> getDateList ( ) as $ date ) { $ this -> saveDate ( $ vhInfo , $ date , 'activity' , $ activityID ) ; } } }
Save Activity
  | php activity        | sql               | cpf                             |
  |---------------------+-------------------+---------------------------------|
  | getType             | activity_type     | activity/@localType             |
  | getTerm             | activity_id       | activity/term                   |
  | getVocabularySource | vocabulary_source | activity/term/@vocabularySource |
  | getNote             | note              | activity/descriptiveNote        |
  | getDateList         | table date_range  | activity/dateRange              |
Save Activity | php activity | sql | cpf | | --------------------- + ------------------- + --------------------------------- | | getType | activity_type | activity / @localType | | getTerm | activity_id | activity / term | | getVocabularySource | vocabulary_source | activity / term / @vocabularySource | | getNote | note | activity / descriptiveNote | | getDateList | table date_range | activity / dateRange |
// record id // activity type, aka localType, Term object // function term id aka vocabulary.id, Term object /*
             * getDateList() always returns a list of SNACDate objects. If no dates then list is empty, but it
             * is still a list that we can foreach on without testing for null and count>0. All of which
             * should go without saying.
             */