/**
  * Prepares import
  *
  * @return array
  */
 public function prepareImport()
 {
     $this->sessionId = null;
     $postData = array('sessionId' => $this->sessionId, 'profileId' => (int) $this->profileEntity->getId(), 'type' => 'import', 'format' => $this->format, 'file' => $this->filePath);
     //get file format
     $inputFileName = $postData['file'];
     //get profile type
     $postData['adapter'] = $this->profileEntity->getType();
     // we create the file reader that will read the result file
     /** @var FileReader $fileReader */
     $fileReader = $this->Plugin()->getFileIOFactory()->createFileReader($postData['format']);
     if ($this->format === 'xml') {
         $tree = json_decode($this->profileEntity->getTree(), true);
         $fileReader->setTree($tree);
     }
     /** @var DataFactory $dataFactory */
     $dataFactory = $this->Plugin()->getDataFactory();
     $dbAdapter = $dataFactory->createDbAdapter($this->profileEntity->getType());
     $dataSession = $dataFactory->loadSession($postData);
     //create dataIO
     $dataIO = $dataFactory->createDataIO($dbAdapter, $dataSession, $this->getLogger());
     $position = $dataIO->getSessionPosition();
     $position = $position == null ? 0 : $position;
     $totalCount = $fileReader->getTotalCount($inputFileName);
     return array('success' => true, 'position' => $position, 'count' => $totalCount);
 }
 /**
  * @param Profile $profile
  */
 public function __construct(Profile $profile)
 {
     $this->name = $profile->getName();
     $this->type = $profile->getType();
     $this->tree = json_decode($profile->getTree(), true);
 }