Index: trunk/extensions/Wikidata/php-tools/UMLSMainImport.php |
— | — | @@ -0,0 +1,61 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +define('MEDIAWIKI', true ); |
| 5 | + |
| 6 | +require_once("../../../includes/Defines.php"); |
| 7 | +require_once("../../../includes/ProfilerStub.php"); |
| 8 | +require_once("../../../LocalSettings.php"); |
| 9 | +require_once("Setup.php"); |
| 10 | +require_once("../OmegaWiki/WikiDataAPI.php"); |
| 11 | +require_once("../OmegaWiki/Transaction.php"); |
| 12 | +require_once('XMLImport.php'); |
| 13 | +require_once('2GoMappingImport.php'); |
| 14 | +require_once("UMLSImport.php"); |
| 15 | +require_once("../../../includes/Namespace.php"); |
| 16 | + |
| 17 | +ob_end_flush(); |
| 18 | + |
| 19 | +global |
| 20 | + $beginTime, $wgCommandLineMode, $wgUser, $numberOfBytes, $wdDefaultViewDataSet; |
| 21 | + |
| 22 | +function getUserId($real_name){ |
| 23 | + $dbr = &wfGetDB(DB_SLAVE); |
| 24 | + $queryResult = $dbr->query( "SELECT user_id FROM user where user_real_name = '$real_name'" ); |
| 25 | + if ( $row = $dbr->fetchObject( $queryResult ) ){ |
| 26 | + return( $row->user_id ); |
| 27 | + } |
| 28 | + else{ |
| 29 | + return( -1 ); |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +$beginTime = time(); |
| 34 | +$wgCommandLineMode = true; |
| 35 | +$wdDefaultViewDataSet = 'umls'; |
| 36 | + |
| 37 | +$arg = reset( $argv ); |
| 38 | +if ( $arg !== false ){ |
| 39 | + $wdDefaultViewDataSet = next( $argv ); |
| 40 | +} |
| 41 | + |
| 42 | +/* |
| 43 | + * User IDs to use during the import of both UMLS and Swiss-Prot |
| 44 | + */ |
| 45 | +$nlmUserID = getUserId( $wdDefaultViewDataSet ); |
| 46 | +if ( $nlmUserId == -1 ){ |
| 47 | + echo "Swiss-Prot user not defined in the database.\n"; |
| 48 | + die; |
| 49 | +} |
| 50 | + |
| 51 | +$wgUser->setID($nlmUserID); |
| 52 | +startNewTransaction($nlmUserID, 0, "UMLS Import"); |
| 53 | +echo "Importing UMLS\n"; |
| 54 | +$umlsImport = importUMLSFromDatabase("localhost", "umls2007aa", "root", "crosby9");//, array("NCI", "GO")); |
| 55 | +//$umlsImport = importUMLSFromDatabase("localhost", "umls", "root", "nicheGod", array("GO", "SRC", "NCI", "HUGO")); |
| 56 | +//$umlsImport = importUMLSFromDatabase("localhost", "umls", "root", NULL, array("GO", "SRC", "NCI", "HUGO")); |
| 57 | + |
| 58 | + |
| 59 | +$endTime = time(); |
| 60 | +echo "\n\nTime elapsed: " . durationToString($endTime - $beginTime); |
| 61 | + |
| 62 | +?> |
Property changes on: trunk/extensions/Wikidata/php-tools/UMLSMainImport.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 63 | + native |