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;
        }
    }
    public function flush() {
        if (!isset($this->recordsHolder)) {
            return;
        }

        $datasetName = NameSpaceHelper::addNameSpace(DATASOURCE_NAME__HEALTH_MONITORING, 'hm_trails');

        // generating and assigning primary key
        $identifiers = Sequence::getNextSequenceValues($datasetName, count($this->recordsHolder->records));
        foreach ($this->recordsHolder->records as $index => $recordInstance) {
            $recordInstance->setColumnValue(0, $identifiers[$index]);
        }

        // storing data in the database
        $dataManipulationController = data_controller_dml_get_instance();
        $dataManipulationController->insertDatasetRecordBatch($datasetName, $this->recordsHolder);

        $this->recordsHolder = NULL;
    }
    protected function submitRecordBatch(RecordMetaData $recordMetaData) {
        $dataManipulationController = data_controller_dml_get_instance();

        $identifierLoader = new StarSchemaLookupIdentifierLoader();
        $identifierLoader->load($this->datasetName, $recordMetaData, $this->recordsHolder);

        $factsDatasetName = StarSchemaNamingConvention::getFactsRelatedName($this->datasetName);

        if ($recordMetaData->findKeyColumns() == NULL) {
            $this->insertedRecordCount += $dataManipulationController->insertDatasetRecordBatch($factsDatasetName, $this->recordsHolder);
        }
        else {
            // even if we truncate the dataset we still need to support several references to the same record
            list($insertedRecordCount, $updatedRecordCount, $deletedRecordCount) =
                $dataManipulationController->insertOrUpdateOrDeleteDatasetRecordBatch($factsDatasetName, $this->recordsHolder);
            $this->insertedRecordCount += $insertedRecordCount;
            $this->updatedRecordCount += $updatedRecordCount;
            $this->deletedRecordCount += $deletedRecordCount;
        }
    }
    protected function generateAndStoreIdentifiers($lookupDatasetName, array $uniqueSetColumns, array $nonKeyColumns = NULL, $sequenceName, array &$lookupValues) {
        $dataManipulationController = data_controller_dml_get_instance();
        $metamodel = data_controller_get_metamodel();

        $lookupDataset = $metamodel->getDataset($lookupDatasetName);
        $identifierColumnName = $lookupDataset->getKeyColumn()->name;

        $lookupCacheKey = $this->prepareLookupCacheKey($lookupDataset->name);

        // preparing insert operation meta data
        $recordsHolder = new IndexedRecordsHolder();
        $recordsHolder->recordMetaData = new RecordMetaData();
        // registering 'identifier' column
        $column = $recordsHolder->recordMetaData->registerColumn($identifierColumnName);
        $column->initializeTypeFrom(Sequence::getSequenceColumnType());
        // registering columns which represent lookup key
        foreach ($uniqueSetColumns as $uniqueSetColumn) {
            $column = $recordsHolder->recordMetaData->registerColumn($uniqueSetColumn->name);
            $column->initializeTypeFrom($uniqueSetColumn->type);
            $column->key = TRUE;
        }
        // registering non key columns
        if (isset($nonKeyColumns)) {
            foreach ($nonKeyColumns as $nonKeyColumn) {
                $column = $recordsHolder->recordMetaData->registerColumn($nonKeyColumn->name);
                $column->initializeTypeFrom($nonKeyColumn->type);
            }
        }

        // generating identifiers for source table
        $identifiers = Sequence::getNextSequenceValues($sequenceName, count($lookupValues));

        // preparing records for insert operation
        foreach ($lookupValues as $lookupKey => $lookupValue) {
            $identifier = array_pop($identifiers);

            $record = array($identifier);

            foreach ($uniqueSetColumns as $uniqueSetColumn) {
                $columnName = $uniqueSetColumn->name;
                $record[] = $lookupValue->$columnName;
            }

            if (isset($nonKeyColumns)) {
                $lookupValue = $lookupValues[$lookupKey];
                foreach ($nonKeyColumns as $nonKeyColumn) {
                    $record[] = $lookupValue->{$nonKeyColumn->name};
                }
            }

            $recordInstance = $recordsHolder->initiateRecordInstance();
            $recordInstance->initializeFrom($record);
            $recordsHolder->registerRecordInstance($recordInstance);

            $lookupValue->identifier = $identifier;
            $this->cachedIdentifiers[$lookupCacheKey][$lookupKey] = $identifier;
        }

        $this->freeSpaceInIdentifierCache($lookupDataset->name);

        // storing 'missing' records
        $dataManipulationController->insertDatasetRecordBatch($lookupDataset->name, $recordsHolder);
    }