Example #1
0
 public static function executeImport(InputInterface $input, OutputInterface $output)
 {
     list($target) = static::makeWriteArguments($input);
     $file = Neo4jTransfer::getWithDefault($input->getOptions(), 'input', null);
     if (isset($file)) {
         if (substr($file, 0, 5) == 'last:') {
             $hostname = substr($file, 5);
             $findFile = DumpCommand::makeDumpFileName($hostname, null, '*-*');
             $file = null;
             $timestamp = null;
             $from = strpos($findFile, '*');
             $rTo = strrpos($findFile, '*') - strlen($findFile) + 1;
             foreach (glob($findFile) as $filename) {
                 $ft = substr($filename, $from, $rTo);
                 if (!isset($timestamp) || $ft > $timestamp) {
                     $file = $filename;
                     $timestamp = $ft;
                 }
             }
             if (isset($file)) {
                 $output->writeln(sprintf("Importing from the latest dump for '%s':", $hostname));
                 $output->writeln($file . "\n");
             } else {
                 $output->writeln(sprintf("Unable to find the latest dump for '%s'.", $hostname));
                 exit(1);
             }
         }
     }
     if (isset($file)) {
         $file = fopen($file, 'r');
     }
     Neo4jTransfer::import($target, $file, $output);
     if (isset($file)) {
         fclose($file);
     }
 }
Example #2
0
 public static function makeReadArguments(InputInterface $input, $readBatchSize = 300, $nodeBatchSize = 150, $relationBatchSize = 25)
 {
     $args = $input->getOptions();
     $source = static::makeSourceConnection($args);
     $importLabel = Neo4jTransfer::getWithDefault($args, 'import-label', '_ilb');
     $importIdKey = Neo4jTransfer::getWithDefault($args, 'import-id-key', '_iid');
     $readBatchSize = intval(Neo4jTransfer::getWithDefault($args, 'read-batch-size', $readBatchSize));
     $nodeBatchSize = intval(Neo4jTransfer::getWithDefault($args, 'node-batch-size', $nodeBatchSize));
     $relationBatchSize = intval(Neo4jTransfer::getWithDefault($args, 'relation-batch-size', $relationBatchSize));
     $clean = Neo4jTransfer::getWithDefault($args, 'clean', 'true') === 'true';
     $transactional = Neo4jTransfer::getWithDefault($args, 'transactional', 'false') === 'true';
     $ignoredRelationProperties = Neo4jTransfer::getWithDefault($args, 'ignore-relation-properties', '');
     $ignoredRelationProperties = explode(',', $ignoredRelationProperties);
     $preserveIdsStr = Neo4jTransfer::getWithDefault($args, 'preserve-ids', '');
     $preserveIds = static::parseLabelAttributes($preserveIdsStr);
     $file = Neo4jTransfer::getWithDefault($args, 'output', null);
     return array($source, $importLabel, $importIdKey, $readBatchSize, $nodeBatchSize, $relationBatchSize, $file, $clean, $transactional, $ignoredRelationProperties, $preserveIds);
 }