public function importProject(array $project, array &$parentMapping)
    {
        $this->output('Project "' . $project['name'] . '"');

        $row = $this->existsGerritProject($project['name'], $this->getServerId());

        $projectRow = $project;
        $projectRow['server_id'] = $this->getServerId();

        // If we don`t know this project, save this!
        if ($row === false) {
            $projectRow['parent'] = 0;
            $id = $this->getDatabase()->insertRecord(Database::TABLE_PROJECT, $projectRow);

            $this->output('=> Inserted (ID: ' . $id . ')');

            // If we know this project, lets check if there something new
        } else {

            $this->checkIfServersFirstRun('Projects', 1363893021, $row);

            $id = $row['id'];
            unset($row['id']);

            $diff = array_diff($projectRow, $row);

            // If there some new data for us, update it.
            if (count($diff) > 0) {
                $this->getDatabase()->updateRecord(Database::TABLE_PROJECT, $diff, $id);

                $this->output('=> Updated (ID: ' . $id . ')');

            } else {
                $this->output('=> Nothing new. Skip it');
            }
        }

        // We have to save the parent / child relations of projects to execute bulk updates afterwards
        if (isset($project['parent']) === true) {
            $parentMapping[$project['parent']][] = intval($id);
        }

        return $id;
    }
public function importProject(array $project, array &$parentMapping)
    {
        $this->output('Project "' . $project['name'] . '"');

        $row = $this->existsGerritProject($project['name'], $this->getServerId());

        $projectRow = $project;
        $projectRow['server_id'] = $this->getServerId();

        // If we don`t know this project, save this!
        if ($row === false) {
            $projectRow['parent'] = 0;
            $id = $this->getDatabase()->insertRecord(Database::TABLE_PROJECT, $projectRow);

            $this->output('=> Inserted (ID: ' . $id . ')');

            // If we know this project, lets check if there something new
        } else {

            $this->checkIfServersFirstRun('Projects', 1363893021, $row);

            $id = $row['id'];
            unset($row['id']);

            $diff = array_diff($projectRow, $row);

            // If there some new data for us, update it.
            if (count($diff) > 0) {
                $this->getDatabase()->updateRecord(Database::TABLE_PROJECT, $diff, $id);

                $this->output('=> Updated (ID: ' . $id . ')');

            } else {
                $this->output('=> Nothing new. Skip it');
            }
        }

        // We have to save the parent / child relations of projects to execute bulk updates afterwards
        if (isset($project['parent']) === true) {
            $parentMapping[$project['parent']][] = intval($id);
        }

        return $id;
    }
public function importProject ( array $ project , array & $ parentMapping ) { $ this -> output ( 'Project "' . $ project [ 'name' ] . '"' ) ; $ row = $ this -> existsGerritProject ( $ project [ 'name' ] , $ this -> getServerId ( ) ) ; $ projectRow = $ project ; $ projectRow [ 'server_id' ] = $ this -> getServerId ( ) ; // If we don`t know this project, save this! if ( $ row === false ) { $ projectRow [ 'parent' ] = 0 ; $ id = $ this -> getDatabase ( ) -> insertRecord ( Database :: TABLE_PROJECT , $ projectRow ) ; $ this -> output ( '=> Inserted (ID: ' . $ id . ')' ) ; // If we know this project, lets check if there something new } else { $ this -> checkIfServersFirstRun ( 'Projects' , 1363893021 , $ row ) ; $ id = $ row [ 'id' ] ; unset ( $ row [ 'id' ] ) ; $ diff = array_diff ( $ projectRow , $ row ) ; // If there some new data for us, update it. if ( count ( $ diff ) > 0 ) { $ this -> getDatabase ( ) -> updateRecord ( Database :: TABLE_PROJECT , $ diff , $ id ) ; $ this -> output ( '=> Updated (ID: ' . $ id . ')' ) ; } else { $ this -> output ( '=> Nothing new. Skip it' ) ; } } // We have to save the parent / child relations of projects to execute bulk updates afterwards if ( isset ( $ project [ 'parent' ] ) === true ) { $ parentMapping [ $ project [ 'parent' ] ] [ ] = intval ( $ id ) ; } return $ id ; }
Imports a single project.
We save name, description and parent project.

@param array $project Project info like description or parent project
@param array $parentMapping Array where parent / child relation will be saved
@return int
Imports a single project . We save name description and parent project .