/** * {@inheritdoc} */ public function perform() { $destinationDocument = $this->destination->getDocument(self::CONFIG_TABLE_NAME_DESTINATION); $recordsCountSource = $this->source->getRecordsCount(self::CONFIG_TABLE_NAME_SOURCE); $recordsCountDestination = $this->destination->getRecordsCount(self::CONFIG_TABLE_NAME_DESTINATION); $this->progress->start($recordsCountSource); $sourceRecords = $this->source->getRecords(self::CONFIG_TABLE_NAME_SOURCE, 0, $recordsCountSource); $destinationRecords = $this->destination->getRecords(self::CONFIG_TABLE_NAME_DESTINATION, 0, $recordsCountDestination); foreach ($sourceRecords as $sourceRecord) { $this->progress->advance(); if (!$this->readerSettings->isNodeIgnored($sourceRecord[self::CONFIG_FIELD_PATH])) { $sourceRecordPathMapped = $this->readerSettings->getNodeMap($sourceRecord[self::CONFIG_FIELD_PATH]); foreach ($destinationRecords as &$destinationRecord) { if ($destinationRecord[self::CONFIG_FIELD_SCOPE] == $sourceRecord[self::CONFIG_FIELD_SCOPE] && $destinationRecord[self::CONFIG_FIELD_SCOPE_ID] == $sourceRecord[self::CONFIG_FIELD_SCOPE_ID] && $destinationRecord[self::CONFIG_FIELD_PATH] == $sourceRecordPathMapped) { $record = $this->applyHandler($destinationDocument, $sourceRecord, $destinationRecord); $destinationRecord[self::CONFIG_FIELD_VALUE] = $record->getValue(self::CONFIG_FIELD_VALUE); continue 2; } } $record = $this->applyHandler($destinationDocument, $sourceRecord, []); $record->setValue(self::CONFIG_FIELD_PATH, $sourceRecordPathMapped); $destinationRecords[] = $record->getData(); } } foreach ($destinationRecords as &$destinationRecord) { unset($destinationRecord[self::CONFIG_FIELD_CONFIG_ID]); } $this->destination->clearDocument(self::CONFIG_TABLE_NAME_DESTINATION); $this->destination->saveRecords(self::CONFIG_TABLE_NAME_DESTINATION, $destinationRecords); $this->progress->finish(); return true; }
/** * @return void */ public function testGetRecordsCount() { $sourceCount = $this->source->getRecordsCount('table_with_data'); $destinationCount = $this->destination->getRecordsCount('table_without_data'); $this->assertEquals(7, $sourceCount); $this->assertEquals(0, $destinationCount); }
/** * {@inheritdoc} */ public function perform() { $this->progress->start(count($this->helper->getDocumentList())); foreach ($this->helper->getDocumentList() as $sourceName => $destinationName) { $this->progress->advance(); if ($this->source->getRecordsCount($sourceName) != $this->destination->getRecordsCount($destinationName)) { $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName; } } $this->progress->finish(); return $this->checkForErrors(Logger::ERROR); }
/** * @return bool */ public function perform() { $documents = $this->helper->getDocumentList(); $this->progressBar->start(1); $oldDestinationRecordsCount = $this->helper->getDestinationRecordsCount(); $newDestinationRecordsCount = $this->destination->getRecordsCount($documents[MapInterface::TYPE_DEST]) - $oldDestinationRecordsCount; if ($newDestinationRecordsCount != 0) { $this->errors[] = 'Mismatch of entities in the document: ' . $documents[MapInterface::TYPE_DEST]; } $this->progressBar->finish(); return $this->checkForErrors(Logger::ERROR); }
/** * @return bool */ public function perform() { $this->progressBar->start($this->getIterationsCount()); foreach ($this->helper->getDocumentList() as $sourceDocumentName => $destinationDocumentName) { $this->progressBar->advance(); $sourceRecordsCount = $this->source->getRecordsCount($sourceDocumentName); $destinationRecordsCount = $this->destination->getRecordsCount($destinationDocumentName); if ($sourceRecordsCount != $destinationRecordsCount) { $this->errors[] = 'Mismatch of entities in the document: ' . $destinationDocumentName; } } $this->progressBar->finish(); return $this->checkForErrors(); }
/** * {@inheritdoc} */ public function perform() { $this->progress->start(count($this->helper->getSourceDocumentFields())); $sourceTotal = 0; $destinationTotal = $this->destination->getRecordsCount($this->helper->getDestinationName()); foreach (array_keys($this->helper->getSourceDocumentFields()) as $sourceName) { $sourceTotal += $this->source->getRecordsCount($sourceName); $this->progress->advance(); } if ($sourceTotal != $destinationTotal) { $this->errors[] = 'Mismatch of amount of entities in documents'; } $this->progress->finish(); return $this->checkForErrors(Logger::ERROR); }
/** * @return void */ public function testGetRecordsCount() { $prefix = 'prefix_'; $this->config->expects($this->any())->method('getOption')->with('dest_prefix')->will($this->returnValue($prefix)); $resourceName = 'core_config_data'; $this->adapter->expects($this->any())->method('getRecordsCount')->with($prefix . $resourceName)->willReturn(10); $this->assertEquals(10, $this->resourceDestination->getRecordsCount($resourceName)); }
/** * @param string $sourceDocName * @param array $keyFields * @return array */ public function getDestinationRecords($sourceDocName, $keyFields = []) { $destinationDocumentName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE); $data = []; $count = $this->destination->getRecordsCount($destinationDocumentName); foreach ($this->destination->getRecords($destinationDocumentName, 0, $count) as $row) { if ($keyFields) { $key = []; foreach ($keyFields as $keyField) { $key[] = $row[$keyField]; } $data[implode('-', $key)] = $row; } else { $data[] = $row; } } return $data; }
/** * @return bool */ public function perform() { $sourceDocuments = $this->source->getDocumentList(); $this->progressBar->start(count($sourceDocuments)); foreach ($sourceDocuments as $sourceDocName) { $this->progressBar->advance(); $destinationName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE); if (!$destinationName) { continue; } $sourceCount = $this->source->getRecordsCount($sourceDocName); $destinationCount = $this->destination->getRecordsCount($destinationName); if ($sourceCount != $destinationCount) { $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName; } } $this->progressBar->finish(); return $this->checkForErrors(); }
/** * Volume check * * @return bool */ public function perform() { $sourceDocuments = array_keys($this->groups->getGroup('source_documents')); $this->progress->start(count($sourceDocuments)); foreach ($sourceDocuments as $sourceName) { $this->progress->advance(); $destinationName = $this->map->getDocumentMap($sourceName, MapInterface::TYPE_SOURCE); $sourceFields = $this->source->getDocument($sourceName)->getStructure()->getFields(); $destinationFields = $this->destination->getDocument($destinationName)->getStructure()->getFields(); if (!empty(array_diff_key($sourceFields, $destinationFields))) { $this->errors[] = 'Mismatch of fields in the document: ' . $destinationName; } if ($this->source->getRecordsCount($sourceName) != $this->destination->getRecordsCount($destinationName)) { $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName; } } $this->progress->finish(); return $this->checkForErrors(); }
/** * @return bool */ public function perform() { $sourceDocuments = array_keys($this->readerGroups->getGroup('source_documents')); $this->progress->start($this->getIterationsCount()); foreach ($sourceDocuments as $sourceDocName) { $this->progress->advance(); $destinationName = $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE); if (!$destinationName) { continue; } $sourceCount = $this->helper->getSourceRecordsCount($sourceDocName); $destinationCount = $this->destination->getRecordsCount($destinationName); if ($sourceCount != $destinationCount) { $this->errors[] = 'Mismatch of entities in the document: ' . $destinationName; } } $this->progress->finish(); return $this->checkForErrors(); }
/** * @return void */ protected function checkEavEntities() { $countBeforeRun = $this->initialData->getDestEavAttributesCount($this->helper->getDestEavDocument()); $countAfterRun = $this->destination->getRecordsCount($this->helper->getDestEavDocument()); $countEavAttributes = null; foreach ($this->helper->getEavAttributes() as $eavAttribute) { $countEavAttributes += count($this->helper->getSourceAttributes($eavAttribute)); } if ($countBeforeRun + $countEavAttributes != $countAfterRun) { $this->errors[] = sprintf('Mismatch of entities in the document: %s', $this->helper->getDestEavDocument()); } }
/** * {@inheritdoc} */ protected function volume() { $this->progress->start(1); $this->getRewritesSelect(); $this->progress->advance(); $result = $this->source->getRecordsCount($this->tableName) == $this->destination->getRecordsCount('url_rewrite'); if (!$result) { $this->logger->error('Mismatch of entities in the document: url_rewrite'); } $this->progress->finish(); return $result; }
/** * Volume check * * @return bool */ protected function volume() { $result = true; $this->progress->start(1); $result &= $this->source->getRecordsCount(self::SOURCE) + $this->countCmsPageRewrites(true) == $this->destination->getRecordsCount(self::DESTINATION); if (!$result) { $this->logger->error('Mismatch of entities in the document: url_rewrite'); } $this->progress->advance(); $this->progress->finish(); return (bool) $result; }
/** * @param array $documents * @return bool */ protected function checkCleared($documents) { $documentsAreEmpty = true; foreach ($documents as $documentName) { $this->progress->advance(); $destinationCount = $this->destination->getRecordsCount($documentName); if ($destinationCount > 0) { $documentsAreEmpty = false; break; } $destinationCount = null; } return $documentsAreEmpty; }
/** * @return void */ public function init() { if (!$this->getDestinationRecordsCount()) { $this->destinationRecordsCount = $this->destination->getRecordsCount($this->getDocumentList()['destination']); } }
/** * @param string $eavEntity * @return void */ protected function initDestAttributes($eavEntity) { if (!isset($this->destEavAttributesCount[$eavEntity])) { $this->destEavAttributesCount[$eavEntity] = (int) $this->destination->getRecordsCount($eavEntity); } }