示例#1
0
 /** @group slow */
 public function testUpdater()
 {
     $addressObjectConfig = $this->container->getAddressObjectsImportConfig();
     $addressObjectConfig['fields']['PREVIOUSID'] = ['name' => 'previous_id', 'type' => 'uuid'];
     $updater = new AddressObjectsUpdater($this->db, $addressObjectConfig['table_name'], $addressObjectConfig['fields']);
     $updater->update($this->reader);
     $this->assertEquals('г Москваа', $this->db->execute('SELECT full_title FROM address_objects WHERE address_id = ?q', ['0c5b2444-70a0-4932-980c-b4dc0d3f02b5'])->fetchResult());
     $this->assertEquals('г Москваа, пл Все вы, питерские, идиоты какие-то', $this->db->execute('SELECT full_title FROM address_objects WHERE address_id = ?q', ['00000000-0000-0000-0000-000000000000'])->fetchResult());
 }
示例#2
0
文件: update.php 项目: apolev/fias
}
$oldVersionId = UpdateLogHelper::getLastVersionId($db);
$newVersionId = $directory->getVersionId();
if ($newVersionId != $oldVersionId + 1) {
    throw new \LogicException("Попытка обновления с версии {$oldVersionId} на версию {$newVersionId}.");
}
$db->execute('SET CONSTRAINTS "address_objects_parent_id_fkey", "houses_parent_id_fkey" DEFERRED');
$housesConfig = $container->getHousesImportConfig();
$addressObjectsConfig = $container->getAddressObjectsImportConfig();
$deletedHouseFile = $directory->getDeletedHouseFile();
if ($deletedHouseFile && $housesConfig) {
    $houseRemover = new Remover($db, $housesConfig['table_name'], $housesConfig['xml_key'], $housesConfig['database_key']);
    $houseRemover->remove(new XmlReader($deletedHouseFile, $housesConfig['node_name'], [$housesConfig['primary_key']], []));
}
$deletedAddressObjectsFile = $directory->getDeletedAddressObjectFile();
if ($deletedAddressObjectsFile) {
    $addressObjectsRemover = new Remover($db, $addressObjectsConfig['table_name'], $addressObjectsConfig['xml_key'], $addressObjectsConfig['database_key']);
    $addressObjectsRemover->remove(new XmlReader($deletedAddressObjectsFile, $addressObjectsConfig['node_name'], [$addressObjectsConfig['xml_key']], []));
}
$addressObjectFields = $addressObjectsConfig['fields'];
$addressObjectFields['PREVID'] = ['name' => 'previous_id', 'type' => 'uuid'];
$addressObjectsUpdater = new AddressObjectsUpdater($db, $addressObjectsConfig['table_name'], $addressObjectFields);
$addressObjectsUpdater->update(new XmlReader($directory->getAddressObjectFile(), $addressObjectsConfig['node_name'], array_keys($addressObjectFields), $addressObjectsConfig['filters']));
if ($housesConfig) {
    $houseFields = $housesConfig['fields'];
    $houseFields['PREVID'] = ['name' => 'previous_id', 'type' => 'uuid'];
    $housesUpdater = new HousesUpdater($db, $housesConfig['table_name'], $houseFields);
    $housesUpdater->update(new XmlReader($directory->getHouseFile(), $housesConfig['node_name'], array_keys($houseFields), []));
}
UpdateLogHelper::addVersionIdToLog($db, $directory->getVersionId());
$db->commit();