protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption('remove-before')) { $this->get('library.indexation')->deleteIndexes(); foreach (\LibraryDocumentCollectionPeer::doSelect(new \Criteria()) as $documentCollection) { $this->get('library.documentCollection')->map($this->get('library.documentCollection')->export($documentCollection)); } } $vocabularyService = $this->get('library.vocabulary'); foreach ($this->get('library.documentCollection')->getList() as $documentCollection) { $documents = $documentCollection->getLibraryDocuments(); if (count($documents)) { $output->writeln($documentCollection->getName() . ':'); $progress = new ProgressBar($output, count($documents)); $progress->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%'); foreach ($documents as $document) { $elasticaDocument = $this->get('library.indexation')->getDocument($document->getId()); if (false !== $elasticaDocument && !$input->getOption('update-image')) { $this->get('library.indexation')->refreshDocument($document, $vocabularyService, false); } else { $this->get('library.indexation')->refreshDocument($document, $vocabularyService, !$input->getOption('ignore-image')); } $progress->advance(); } $progress->finish(); $output->writeln("\n"); } } }
function importUMLSRelations( $umlsCollectionId, $relationCollectionContents, $query ) { global $db; $queryResult = mysql_query( $query, $db ); $progressBar = new ProgressBar( mysql_num_rows( $queryResult ), 100 ); while ( $relation = mysql_fetch_row( $queryResult ) ) { $relationType = $relation[2]; if ( strcmp( $relationType, 'CHD' ) == 0 ) { $relationType = 'RN'; } elseif ( strcmp( $relationType, 'PAR' ) == 0 ) { $relationType = 'RB'; } // echo "$definedMeaningId1 = $relation[0]\n"; $definedMeaningId1 = getDefinedMeaningFromCollection( $umlsCollectionId, $relation[0] ); $definedMeaningId2 = getDefinedMeaningFromCollection( $umlsCollectionId, $relation[1] ); $relationMeaningId = $relationCollectionContents[$relationType]; // echo "$definedMeaningId1 = $relation[0]\n"; // echo "$definedMeaningId1 = $relation[1]\n"; // echo "umlsCollectionId = $umlsCollectionId\n"; if ( !$definedMeaningId1 ) { echo "Unknown cui $relation[0]\n"; print_r( $relation ); } if ( !$definedMeaningId2 ) { echo "Unknown cui $relation[1]\n"; print_r( $relation ); } if ( !$relationMeaningId ) { echo "Unknown relation $relationType\n"; print_r( $relationCollectionContents ); print_r( $relation ); } if ( $definedMeaningId2 > 0 && $definedMeaningId1 > 0 && $relationMeaningId > 0 ) addRelation( $definedMeaningId2, $relationMeaningId, $definedMeaningId1 ); $progressBar->advance( 1 ); } $progressBar->clear(); }