public function synchronizeSurveyBatch(\Gems_Task_TaskRunnerBatch $batch, $userId)
    {
        // Surveys in Gems
        $select = $this->_gemsDb->select();
        $select->from('gems__surveys', array('gsu_id_survey', 'gsu_surveyor_id'))
                ->where('gsu_id_source = ?', $this->getId())
                ->order('gsu_surveyor_id');

        $gemsSurveys = $this->_gemsDb->fetchPairs($select);
        if (!$gemsSurveys) {
            $gemsSurveys = array();
        }

        // Surveys in Source
        $sourceSurveys = $this->_getSourceSurveysForSynchronisation();
        if ($sourceSurveys) {
            $sourceSurveys = array_combine($sourceSurveys, $sourceSurveys);
        } else {
            $sourceSurveys = array();
        }

        // Always those already in the database
        foreach ($gemsSurveys as $surveyId => $sourceSurveyId) {

            if (isset($sourceSurveys[$sourceSurveyId])) {
                $batch->addTask('Tracker_CheckSurvey', $this->getId(), $sourceSurveyId, $surveyId, $userId);
                $batch->addTask('Tracker_AddRefreshQuestions', $this->getId(), $sourceSurveyId, $surveyId);
            } else {
                // Do not pass the source id when it no longer exists
                $batch->addTask('Tracker_CheckSurvey', $this->getId(), null, $surveyId, $userId);
            }
        }

        // Now add the new ones
        foreach (array_diff($sourceSurveys, $gemsSurveys) as $sourceSurveyId) {
            $batch->addTask('Tracker_CheckSurvey', $this->getId(), $sourceSurveyId, null, $userId);
            $batch->addTask('Tracker_AddRefreshQuestions', $this->getId(), $sourceSurveyId, null);
        }
    }
public function synchronizeSurveyBatch(\Gems_Task_TaskRunnerBatch $batch, $userId)
    {
        // Surveys in Gems
        $select = $this->_gemsDb->select();
        $select->from('gems__surveys', array('gsu_id_survey', 'gsu_surveyor_id'))
                ->where('gsu_id_source = ?', $this->getId())
                ->order('gsu_surveyor_id');

        $gemsSurveys = $this->_gemsDb->fetchPairs($select);
        if (!$gemsSurveys) {
            $gemsSurveys = array();
        }

        // Surveys in Source
        $sourceSurveys = $this->_getSourceSurveysForSynchronisation();
        if ($sourceSurveys) {
            $sourceSurveys = array_combine($sourceSurveys, $sourceSurveys);
        } else {
            $sourceSurveys = array();
        }

        // Always those already in the database
        foreach ($gemsSurveys as $surveyId => $sourceSurveyId) {

            if (isset($sourceSurveys[$sourceSurveyId])) {
                $batch->addTask('Tracker_CheckSurvey', $this->getId(), $sourceSurveyId, $surveyId, $userId);
                $batch->addTask('Tracker_AddRefreshQuestions', $this->getId(), $sourceSurveyId, $surveyId);
            } else {
                // Do not pass the source id when it no longer exists
                $batch->addTask('Tracker_CheckSurvey', $this->getId(), null, $surveyId, $userId);
            }
        }

        // Now add the new ones
        foreach (array_diff($sourceSurveys, $gemsSurveys) as $sourceSurveyId) {
            $batch->addTask('Tracker_CheckSurvey', $this->getId(), $sourceSurveyId, null, $userId);
            $batch->addTask('Tracker_AddRefreshQuestions', $this->getId(), $sourceSurveyId, null);
        }
    }
public function synchronizeSurveyBatch ( \ Gems_Task_TaskRunnerBatch $ batch , $ userId ) { // Surveys in Gems $ select = $ this -> _gemsDb -> select ( ) ; $ select -> from ( 'gems__surveys' , array ( 'gsu_id_survey' , 'gsu_surveyor_id' ) ) -> where ( 'gsu_id_source = ?' , $ this -> getId ( ) ) -> order ( 'gsu_surveyor_id' ) ; $ gemsSurveys = $ this -> _gemsDb -> fetchPairs ( $ select ) ; if ( ! $ gemsSurveys ) { $ gemsSurveys = array ( ) ; } // Surveys in Source $ sourceSurveys = $ this -> _getSourceSurveysForSynchronisation ( ) ; if ( $ sourceSurveys ) { $ sourceSurveys = array_combine ( $ sourceSurveys , $ sourceSurveys ) ; } else { $ sourceSurveys = array ( ) ; } // Always those already in the database foreach ( $ gemsSurveys as $ surveyId => $ sourceSurveyId ) { if ( isset ( $ sourceSurveys [ $ sourceSurveyId ] ) ) { $ batch -> addTask ( 'Tracker_CheckSurvey' , $ this -> getId ( ) , $ sourceSurveyId , $ surveyId , $ userId ) ; $ batch -> addTask ( 'Tracker_AddRefreshQuestions' , $ this -> getId ( ) , $ sourceSurveyId , $ surveyId ) ; } else { // Do not pass the source id when it no longer exists $ batch -> addTask ( 'Tracker_CheckSurvey' , $ this -> getId ( ) , null , $ surveyId , $ userId ) ; } } // Now add the new ones foreach ( array_diff ( $ sourceSurveys , $ gemsSurveys ) as $ sourceSurveyId ) { $ batch -> addTask ( 'Tracker_CheckSurvey' , $ this -> getId ( ) , $ sourceSurveyId , null , $ userId ) ; $ batch -> addTask ( 'Tracker_AddRefreshQuestions' , $ this -> getId ( ) , $ sourceSurveyId , null ) ; } }
Updates the gems database with the latest information about the surveys in this source adapter

@param \Gems_Task_TaskRunnerBatch $batch
@param int $userId    Id of the user who takes the action (for logging)
@return array Returns an array of messages
Updates the gems database with the latest information about the surveys in this source adapter