public function selectLookupableColumns(RecordMetaData $recordMetaData) { $lookupableColumns = NULL; foreach ($recordMetaData->getColumns() as $column) { if ($column->isPhysical()) { $lookupableColumns[$column->columnIndex] = $column; } } return $lookupableColumns; }
protected function doAfterProcessingRecordsImpl(RecordMetaData $recordMetaData, $fileProcessedCompletely) { if (isset($this->columnUniqueValues[self::$PRIMARY_KEY_COLUMN_INDEX]) && ($this->columnUniqueValues[self::$PRIMARY_KEY_COLUMN_INDEX] !== FALSE)) { $column = $recordMetaData->getColumnByIndex(self::$PRIMARY_KEY_COLUMN_INDEX); // checking if the column type is acceptable if (isset($column->type->applicationType) && in_array($column->type->applicationType, $this->acceptableDataTypes)) { $column->key = TRUE; } } }
protected function checkIfRecordEmpty(RecordMetaData $recordMetaData, array &$record) { // checking if the record has values for at least one column foreach ($recordMetaData->getColumns() as $column) { if (isset($record[$column->columnIndex])) { return FALSE; } } return TRUE; }
protected function submitRecordBatch(RecordMetaData $recordMetaData) { $dataManipulationController = data_controller_dml_get_instance(); if ($recordMetaData->findKeyColumns() == NULL) { $this->insertedRecordCount += $dataManipulationController->insertDatasetRecordBatch($this->datasetName, $this->recordsHolder); } else { // even if we truncate the dataset we still need to support several instances of the same record list($insertedRecordCount, $updatedRecordCount, $deletedRecordCount) = $dataManipulationController->insertOrUpdateOrDeleteDatasetRecordBatch($this->datasetName, $this->recordsHolder); $this->insertedRecordCount += $insertedRecordCount; $this->updatedRecordCount += $updatedRecordCount; $this->deletedRecordCount += $deletedRecordCount; } }
protected function doAfterProcessingRecordsImpl(RecordMetaData $recordMetaData, $fileProcessedCompletely) { // 'fixing' values of some type definition properties foreach ($recordMetaData->getColumns(FALSE) as $column) { switch ($column->type->applicationType) { case CurrencyDataTypeHandler::DATA_TYPE: $defaultCurrencyScale = 2; if (!isset($column->type->scale) || ($column->type->scale < $defaultCurrencyScale)) { $column->type->scale = $defaultCurrencyScale; } break; case PercentDataTypeHandler::DATA_TYPE: if (isset($column->type->scale)) { $column->type->scale -= 2; if ($column->type->scale < 0) { $column->type->scale = 0; } } break; } } }
public function initializeFrom($sourceDataset) { parent::initializeFrom($sourceDataset); $sourceSource = ObjectHelper::getPropertyValue($sourceDataset, 'source'); if (isset($sourceSource)) { $this->initializeSourceFrom($sourceSource); } $sourceAssembler = ObjectHelper::getPropertyValue($sourceDataset, 'assembler'); if (isset($sourceAssembler)) { $this->initializeAssemblerFrom($sourceAssembler); } }
protected function submitRecordImpl(RecordMetaData $recordMetaData, $recordNumber, array &$record) { foreach ($recordMetaData->getColumns(FALSE) as $columnIndex => $column) { // we do not need to work with the column. It does not contain unique values if (isset($this->columnUniqueValues[$columnIndex]) && ($this->columnUniqueValues[$columnIndex] === FALSE)) { continue; } $unique = FALSE; // if the column contains NULL we should not consider it as containing unique values if (isset($record[$columnIndex])) { $columnValue = $record[$columnIndex]; if ($this->checkColumnUniqueness($recordMetaData, $columnIndex, $columnValue)) { $this->columnUniqueValues[$columnIndex][$columnValue] = TRUE; $unique = TRUE; } } // we do not need further processing for the column if (!$unique) { $this->columnUniqueValues[$columnIndex] = FALSE; } } }
public function findColumn($columnName) { $column = parent::findColumn($columnName); if (isset($column)) { return $column; } foreach ($this->columns as $c) { $column = $c->findBranch($columnName); if (isset($column)) { return $column; } } return NULL; }
protected function adjustColumnName(RecordMetaData $recordMetaData, $columnName) { if (!isset($columnName)) { return FALSE; } $adjustedColumnName = $columnName; // trimming the column name a bit ... if necessary if (isset($this->maximumColumnNameLength)) { if (strlen($adjustedColumnName) > $this->maximumColumnNameLength) { $adjustedColumnName = ColumnNameTruncator::shortenName($adjustedColumnName, strlen($adjustedColumnName) - $this->maximumColumnNameLength); } if (strlen($adjustedColumnName) > $this->maximumColumnNameLength) { return FALSE; } } // checking if the name already exists ... and it should not to successfully proceed further if ($recordMetaData->findColumn($adjustedColumnName) != NULL) { return NULL; } return $adjustedColumnName; }