public function batchCommand($preset, $parts = '', $batchSize = null, $identifier = null, $force = false)
    {
        try {
            $this->importService->start($identifier, $force);
        } catch (ImportAlreadyExecutedException $e) {
            $this->outputLine($e->getMessage());
            $this->outputLine('Import skipped. You can force running this import again by specifying --force.');
            $this->quit(1);
        }

        $this->startTime = microtime(true);
        $parts = Arrays::trimExplode(',', $parts);

        $identifier = $this->importService->getCurrentImportIdentifier();
        $this->outputLine('Start import with identifier <b>%s</b>', [$identifier]);

        $presetSettings = $this->loadPreset($preset);
        array_walk($presetSettings['parts'], function ($partSetting, $partName) use ($preset, $parts, $batchSize, $identifier) {
            $this->elapsedTime = 0;
            $this->batchCounter = 0;
            $this->outputLine();
            $this->outputPartTitle($partSetting, $partName);

            $partSetting['__currentPresetName'] = $preset;
            $partSetting['__currentPartName'] = $partName;
            if ($batchSize !== null) {
                $partSetting['batchSize'] = $batchSize;
            }

            $partSetting = new PresetPartDefinition($partSetting, $identifier);
            if ($parts !== array() && !in_array($partName, $parts)) {
                $this->outputLine('<error>~</error> Skipped');
                return;
            }

            if ($partSetting->getBatchSize() && $partSetting->isDebug() === false) {
                while (($count = $this->executeCommand($partSetting)) > 0) {
                    $partSetting->nextBatch();
                }
            } else {
                $this->executeCommand($partSetting);
            }
        });


        $this->importService->stop();

        $import = $this->importService->getLastImport();

        $this->outputLine();
        $this->outputLine('<b>Import finished</b>');
        $this->outputLine(sprintf('<info>-</info> Started   %s', $import->getStartTime()->format(DATE_RFC2822)));
        $this->outputLine(sprintf('<info>-</info> Finished  %s', $import->getEndTime()->format(DATE_RFC2822)));
        $this->outputLine(sprintf('<info>-</info> Runtime   %d seconds', $import->getElapsedTime()));
        $this->outputLine();
        $this->outputLine('See log for more details and possible errors.');
    }
public function batchCommand($preset, $parts = '', $batchSize = null, $identifier = null, $force = false)
    {
        try {
            $this->importService->start($identifier, $force);
        } catch (ImportAlreadyExecutedException $e) {
            $this->outputLine($e->getMessage());
            $this->outputLine('Import skipped. You can force running this import again by specifying --force.');
            $this->quit(1);
        }

        $this->startTime = microtime(true);
        $parts = Arrays::trimExplode(',', $parts);

        $identifier = $this->importService->getCurrentImportIdentifier();
        $this->outputLine('Start import with identifier <b>%s</b>', [$identifier]);

        $presetSettings = $this->loadPreset($preset);
        array_walk($presetSettings['parts'], function ($partSetting, $partName) use ($preset, $parts, $batchSize, $identifier) {
            $this->elapsedTime = 0;
            $this->batchCounter = 0;
            $this->outputLine();
            $this->outputPartTitle($partSetting, $partName);

            $partSetting['__currentPresetName'] = $preset;
            $partSetting['__currentPartName'] = $partName;
            if ($batchSize !== null) {
                $partSetting['batchSize'] = $batchSize;
            }

            $partSetting = new PresetPartDefinition($partSetting, $identifier);
            if ($parts !== array() && !in_array($partName, $parts)) {
                $this->outputLine('<error>~</error> Skipped');
                return;
            }

            if ($partSetting->getBatchSize() && $partSetting->isDebug() === false) {
                while (($count = $this->executeCommand($partSetting)) > 0) {
                    $partSetting->nextBatch();
                }
            } else {
                $this->executeCommand($partSetting);
            }
        });


        $this->importService->stop();

        $import = $this->importService->getLastImport();

        $this->outputLine();
        $this->outputLine('<b>Import finished</b>');
        $this->outputLine(sprintf('<info>-</info> Started   %s', $import->getStartTime()->format(DATE_RFC2822)));
        $this->outputLine(sprintf('<info>-</info> Finished  %s', $import->getEndTime()->format(DATE_RFC2822)));
        $this->outputLine(sprintf('<info>-</info> Runtime   %d seconds', $import->getElapsedTime()));
        $this->outputLine();
        $this->outputLine('See log for more details and possible errors.');
    }
public function batchCommand ( $ preset , $ parts = '' , $ batchSize = null , $ identifier = null , $ force = false ) { try { $ this -> importService -> start ( $ identifier , $ force ) ; } catch ( ImportAlreadyExecutedException $ e ) { $ this -> outputLine ( $ e -> getMessage ( ) ) ; $ this -> outputLine ( 'Import skipped. You can force running this import again by specifying --force.' ) ; $ this -> quit ( 1 ) ; } $ this -> startTime = microtime ( true ) ; $ parts = Arrays :: trimExplode ( ',' , $ parts ) ; $ identifier = $ this -> importService -> getCurrentImportIdentifier ( ) ; $ this -> outputLine ( 'Start import with identifier <b>%s</b>' , [ $ identifier ] ) ; $ presetSettings = $ this -> loadPreset ( $ preset ) ; array_walk ( $ presetSettings [ 'parts' ] , function ( $ partSetting , $ partName ) use ( $ preset , $ parts , $ batchSize , $ identifier ) { $ this -> elapsedTime = 0 ; $ this -> batchCounter = 0 ; $ this -> outputLine ( ) ; $ this -> outputPartTitle ( $ partSetting , $ partName ) ; $ partSetting [ '__currentPresetName' ] = $ preset ; $ partSetting [ '__currentPartName' ] = $ partName ; if ( $ batchSize !== null ) { $ partSetting [ 'batchSize' ] = $ batchSize ; } $ partSetting = new PresetPartDefinition ( $ partSetting , $ identifier ) ; if ( $ parts !== array ( ) && ! in_array ( $ partName , $ parts ) ) { $ this -> outputLine ( '<error>~</error> Skipped' ) ; return ; } if ( $ partSetting -> getBatchSize ( ) && $ partSetting -> isDebug ( ) === false ) { while ( ( $ count = $ this -> executeCommand ( $ partSetting ) ) > 0 ) { $ partSetting -> nextBatch ( ) ; } } else { $ this -> executeCommand ( $ partSetting ) ; } } ) ; $ this -> importService -> stop ( ) ; $ import = $ this -> importService -> getLastImport ( ) ; $ this -> outputLine ( ) ; $ this -> outputLine ( '<b>Import finished</b>' ) ; $ this -> outputLine ( sprintf ( '<info>-</info> Started   %s' , $ import -> getStartTime ( ) -> format ( DATE_RFC2822 ) ) ) ; $ this -> outputLine ( sprintf ( '<info>-</info> Finished  %s' , $ import -> getEndTime ( ) -> format ( DATE_RFC2822 ) ) ) ; $ this -> outputLine ( sprintf ( '<info>-</info> Runtime   %d seconds' , $ import -> getElapsedTime ( ) ) ) ; $ this -> outputLine ( ) ; $ this -> outputLine ( 'See log for more details and possible errors.' ) ; }
Run batch import

This executes a batch import as configured in the settings for the specified preset. Optionally the "parts" can
be specified, separated by comma ",".

Presets and parts need to be configured via settings first. Refer to the documentation for possible options and
example configurations.

You may optionally specify an external import identifier which will be stored as meta data with the import run.
This identifier is used for checking if an import of the given data set (in general) has been executed earlier.
The external import identifier therefore does globally what the external record identifier does on a per record
basis.

If an external import identifier was specified and an import using that identifier has been executed earlier,
this command will stop with a corresponding message. You can force running such an import by specifying the
--force flag.

@param string $preset Name of the preset which holds the configuration for the import
@param string $parts Optional comma separated names of parts. If no parts are specified, all parts will be imported.
@param integer $batchSize Number of records to import at a time. If not specified, the batch size defined in the preset will be used.
@param string $identifier External identifier which is used for checking if an import of the same data has already been executed earlier.
@param boolean $force If set, an import will even be executed if it ran earlier with the same external import identifier.
@return void
Run batch import