private function mergeRebalancedNodes() { if ($this->rebalanceInserter) { $this->logMessage('Finally, MERGE is in progress'); $this->rebalanceInserter->flush(); // merge temp table with location table // there should be more generalized method Location\LocationTable::mergeRelationsFromTemporalTable(self::TREE_REBALANCE_TEMP_TABLE_NAME, false, array('LEFT_MARGIN' => 'L', 'RIGHT_MARGIN' => 'R', 'DEPTH_LEVEL' => 'D', 'ID' => 'I')); } }
private function insertTreeInfo() { // We make temporal table, place margins, parent and lang data into it, then perform an update of the old table from the temporal one. $this->createTemporalTable(self::TABLE_TEMP_TREE, array('ID' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'PARENT_ID' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'TYPE_ID' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'DEPTH_LEVEL' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'LEFT_MARGIN' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')), 'RIGHT_MARGIN' => array('TYPE' => array(self::DB_TYPE_MYSQL => 'int', self::DB_TYPE_MSSQL => 'int', self::DB_TYPE_ORACLE => 'NUMBER(18)')))); $handle = new BlockInserter(array('tableName' => self::TABLE_TEMP_TREE, 'exactFields' => array('ID' => array('data_type' => 'integer'), 'PARENT_ID' => array('data_type' => 'integer'), 'TYPE_ID' => array('data_type' => 'integer'), 'DEPTH_LEVEL' => array('data_type' => 'integer'), 'LEFT_MARGIN' => array('data_type' => 'integer'), 'RIGHT_MARGIN' => array('data_type' => 'integer')), 'parameters' => array('mtu' => 9999))); // fill temporal table if (is_array($this->data['TREE'])) { foreach ($this->data['TREE'] as $id => $node) { $handle->insert(array('ID' => $id, 'PARENT_ID' => $node['PARENT_ID'], 'TYPE_ID' => $node['TYPE_ID'], 'DEPTH_LEVEL' => $node['DEPTH_LEVEL'], 'LEFT_MARGIN' => $node['LEFT_MARGIN'], 'RIGHT_MARGIN' => $node['RIGHT_MARGIN'])); } } $handle->flush(); // merge temp table with location table Location\LocationTable::mergeRelationsFromTemporalTable(self::TABLE_TEMP_TREE, array('TYPE_ID', 'PARENT_ID')); $this->dropTable(self::TABLE_TEMP_TREE); }