/**
  * @param string $side
  * @return array
  */
 private function getSpecimenForLonesomeRecords($side)
 {
     $dataNewRecords = [];
     $lonesomeRecords = $this->diffHandler->getLonesomeRecordsFile()->getLonesomeRecordsByBase($side);
     if (count($lonesomeRecords)) {
         $catalogNumbersLonesomeRecords = array_keys($lonesomeRecords);
         $dataNewRecords = $this->genericEntityManager->getEntitiesLinkedToSpecimens($this->exportPrefs->getSideForNewRecords(), $this->collection, $catalogNumbersLonesomeRecords);
     }
     return $dataNewRecords;
 }
 /**
  * @Route("/setChoices/{institutionCode}/{collectionCode}", name="setChoices", options={"expose"=true})
  * @param UserInterface|User $user
  * @param Request $request
  * @param string  $institutionCode
  * @param string  $collectionCode
  * @return JsonResponse
  */
 public function setChoicesAction(UserInterface $user, Request $request, $institutionCode, $collectionCode)
 {
     $collection = $this->get('utility')->getCollection($institutionCode, $collectionCode, $user);
     /* @var $exportManager \AppBundle\Manager\ExportManager */
     $exportManager = $this->get('exportmanager')->init($user)->setCollection($collection);
     $maxItemPerPage = $exportManager->getMaxItemPerPage($request);
     list($inputOrigin, $inputSpecimens, $inputClassesName, $page, $selectedSpecimens, $selectedClassName, $type) = $this->getParamsForSetChoices($request);
     $choices = [];
     $items = [];
     list($specimensWithChoices, $specimensWithoutChoices) = [[], []];
     if ($type == 'choices') {
         $specimensWithChoices = array_keys($exportManager->getSessionHandler()->getChoicesByCatalogNumber());
     }
     if ($type == 'todo') {
         $specimensWithoutChoices = $exportManager->getSessionHandler()->getChoices();
     }
     if (!is_null($inputOrigin) && !is_null($inputSpecimens)) {
         $diffs = $exportManager->getDiffs($request, $selectedClassName, $specimensWithChoices, $specimensWithoutChoices);
         $items = $this->getItemsForSetChoices($inputSpecimens, $diffs, $page, $maxItemPerPage, $selectedSpecimens, $items);
         $choices = DiffHandler::formatItemsToChoices($items, $diffs, $inputClassesName, $inputOrigin, $choices);
     }
     $exportManager->setChoices($choices);
     $response = new JsonResponse();
     $this->setFlashMessageForChoices($choices);
     $response->setData(['choices' => $exportManager->getSessionHandler()->getChoices()]);
     return $response;
 }
 /**
  * @param DiffHandler $diffHandler
  * @param string      $collectionCode
  */
 public function init(DiffHandler $diffHandler, $collectionCode)
 {
     $this->collectionCode = $collectionCode;
     $this->set('choices', $diffHandler->getChoicesFile()->getContent());
 }
 /**
  * @param DiffManager $diffManager
  * @param DiffHandler $diffHandler
  * @return array
  */
 private function createCatalogNumbersFiles(DiffManager $diffManager, DiffHandler $diffHandler)
 {
     $catalogNumbersFiles = [];
     $fs = new Filesystem();
     $this->log('CatalogNumbers');
     foreach ($diffManager::ENTITIES_NAME as $entityName) {
         $catalogNumbers = $diffManager->getResultByClassName($entityName);
         $this->log("\t" . $entityName . ' : ' . count($catalogNumbers));
         $catalogNumbersFilename = $diffHandler->getCollectionPath() . '/catalogNumbers_' . $entityName . '.json';
         $fs->dumpFile($catalogNumbersFilename, \json_encode($catalogNumbers));
         $catalogNumbersFiles[] = $catalogNumbersFilename;
     }
     return $catalogNumbersFiles;
 }