/**
  * Factory for creating object from array
  *
  * @param array $action
  * @return MappingAction
  * @author Daniel Wendlandt
  */
 public static function createFromArray(array $action)
 {
     $mappingAction = new MappingAction();
     $mappingAction->setStrategy($action['strategy']);
     $mappingAction->setSourceIndex($action['source_index']);
     $mappingAction->setSourceType($action['source_type']);
     $mappingAction->setTargetIndex($action['target_index']);
     $mappingAction->setTargetType($action['target_type']);
     return $mappingAction;
 }
 /**
  * Asks for mapping action strategy.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param RestoreStrategy\MappingAction $mappingAction
  * @return RestoreStrategy\MappingAction
  * @author Daniel Wendlandt
  */
 private function askForMappingStrategy(InputInterface $input, OutputInterface $output, RestoreStrategy\MappingAction $mappingAction)
 {
     //ask for strategy
     $strategyQuestions = array('Reset the Index. [Delete Type and create mapping and insert data from Backup]', 'Add data only. [Old type and mapping will be untouched and data will be put on top]');
     $questionStrategy = new ChoiceQuestion('Please select the import strategy', $strategyQuestions);
     $helper = $this->getHelper('question');
     $answerStrategy = $helper->ask($input, $output, $questionStrategy);
     if ($strategyQuestions[0] == $answerStrategy) {
         $mappingAction->setStrategy(RestoreStrategy::STRATEGY_RESET);
     } else {
         $mappingAction->setStrategy(RestoreStrategy::STRATEGY_ADD);
     }
     return $mappingAction;
 }
 /**
  * Process all given indices/types for only one main strategy
  *
  * @param string $strategy
  * @param Mappings $mappings
  * @author Daniel Wendlandt
  */
 public function processMappingsForStrategy($strategy, Mappings $mappings)
 {
     $this->mappings = array();
     /** @var Index $index */
     foreach ($mappings->getIndices() as $index) {
         /** @var Type $type */
         foreach ($index->getTypes() as $type) {
             $mappingAction = new MappingAction();
             $mappingAction->setStrategy($strategy);
             $mappingAction->setSourceIndex($index->getName());
             $mappingAction->setSourceType($type->getName());
             $mappingAction->setTargetIndex($index->getName());
             $mappingAction->setTargetType($type->getName());
             $this->addMappingAction($mappingAction);
         }
     }
 }