Index: trunk/extensions/Wikidata/php-tools/DataImport.php |
— | — | @@ -19,24 +19,39 @@ |
20 | 20 | global |
21 | 21 | $beginTime, $wgCommandLineMode, $wgUser, $numberOfBytes, $wdDefaultViewDataSet; |
22 | 22 | |
| 23 | +function getUserId($real_name){ |
| 24 | + $dbr = &wfGetDB(DB_SLAVE); |
| 25 | + $queryResult = $dbr->query( "SELECT user_id FROM user where user_real_name = '$real_name'" ); |
| 26 | + if ( $row = $dbr->fetchObject( $queryResult ) ){ |
| 27 | + return( $row->user_id ); |
| 28 | + } |
| 29 | + else{ |
| 30 | + return( -1 ); |
| 31 | + } |
| 32 | +} |
| 33 | + |
23 | 34 | $beginTime = time(); |
24 | 35 | $wgCommandLineMode = true; |
25 | | -$wdDefaultViewDataSet = 'sp'; |
| 36 | +$wdDefaultViewDataSet = 'uw'; |
26 | 37 | |
27 | 38 | /* |
28 | 39 | * User IDs to use during the import of both UMLS and Swiss-Prot |
29 | 40 | */ |
30 | 41 | //$nlmUserID = 8; |
31 | 42 | // check the user ids as provided in the database |
32 | | -$sibUserID = 2; |
33 | | -//$nlmUserID = 1; |
34 | | -//$sibUserID = 1; |
35 | 43 | |
| 44 | +$sibUserID = getUserId( $wdDefaultViewDataSet ); |
| 45 | +if ( $sibUserId == -1 ){ |
| 46 | + echo "Swiss-Prot user not defined in the database.\n"; |
| 47 | + die; |
| 48 | +} |
| 49 | + |
36 | 50 | //$linkEC2GoFileName = "LinksEC2Go.txt"; |
37 | 51 | //$linkSwissProtKeyWord2GoFileName = "LinksSP2Go.txt"; |
38 | 52 | //$swissProtXMLFileName = "C:\Documents and Settings\mulligen\Bureaublad\uniprot_sprot.xml"; |
39 | 53 | //$swissProtXMLFileName = "100000lines.xml"; |
40 | 54 | $swissProtXMLFileName = "C:\Documents and Settings\mulligen\Bureaublad\SPentriesForWPTest.xml"; |
| 55 | +//$swissProtXMLFileName = "C:\Users\mulligen\Desktop\SPentriesForWPTest.xml"; |
41 | 56 | |
42 | 57 | //$wgUser->setID($nlmUserID); |
43 | 58 | //startNewTransaction($nlmUserID, 0, "UMLS Import"); |
Index: trunk/extensions/Wikidata/php-tools/SwissProtImport.php |
— | — | @@ -881,6 +881,7 @@ |
882 | 882 | public function getOrCreateExpression($spelling) { |
883 | 883 | $expression = findExpression($spelling, $this->languageId); |
884 | 884 | if (!$expression) { |
| 885 | + //wfDebug( "create expression $spelling in database"); |
885 | 886 | $expression = createExpression($spelling, $this->languageId); |
886 | 887 | } |
887 | 888 | return $expression; |