protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     /** @var PluginManager $processManager */
     $output->writeln('Updating Datamaps...');
     $json = file_get_contents($input->getArgument('url') . '/datamap/list/json');
     if (!$json) {
         throw new \Exception('Wrong JSON response.');
     }
     $datamaps = json_decode($json, true);
     if (count($datamaps)) {
         foreach ($datamaps as $datamap) {
             $output->write('Updating map "' . $datamap['name'] . '... ');
             $localDatamap = $em->getRepository('VRAppBundle:Datamap')->findOneBy(['name' => $datamap['name']]);
             if (!$localDatamap) {
                 $localDatamap = new Datamap();
                 $localDatamap->setName($datamap['name']);
             }
             $localDatamap->setType($datamap['type']);
             $localDatamap->setMap(base64_decode($datamap['map']));
             $localDatamap->setDescription($datamap['description']);
             $em->persist($localDatamap);
             $em->flush();
             $output->writeln('<info>Done</info>');
         }
     }
     $output->writeln('Finished.');
 }
 public function testGetTypeName()
 {
     $datamap = new Datamap();
     $datamap->setType(Datamap::TYPE_DATA);
     $this->assertEquals('Data', $datamap->getTypeName());
     $datamap->setType(Datamap::TYPE_SEARCH);
     $this->assertEquals('Search', $datamap->getTypeName());
     $datamap->setType(Datamap::TYPE_EMAIL);
     $this->assertEquals('Email', $datamap->getTypeName());
     $datamap->setType('test-string-1');
     $this->assertNull($datamap->getTypeName());
     $datamap->setType('test-string-2');
     $this->assertNull($datamap->getTypeName());
 }