r23008 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23007‎ | r23008 | r23009 >
Date:11:45, 15 June 2007
Author:mulligen
Status:old
Tags:
Comment:
automatically retrieve the user id and some changes to work with datasets
Modified paths:
  • /trunk/extensions/Wikidata/php-tools/DataImport.php (modified) (history)
  • /trunk/extensions/Wikidata/php-tools/SwissProtImport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/php-tools/DataImport.php
@@ -19,24 +19,39 @@
2020 global
2121 $beginTime, $wgCommandLineMode, $wgUser, $numberOfBytes, $wdDefaultViewDataSet;
2222
 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+
2334 $beginTime = time();
2435 $wgCommandLineMode = true;
25 -$wdDefaultViewDataSet = 'sp';
 36+$wdDefaultViewDataSet = 'uw';
2637
2738 /*
2839 * User IDs to use during the import of both UMLS and Swiss-Prot
2940 */
3041 //$nlmUserID = 8;
3142 // check the user ids as provided in the database
32 -$sibUserID = 2;
33 -//$nlmUserID = 1;
34 -//$sibUserID = 1;
3543
 44+$sibUserID = getUserId( $wdDefaultViewDataSet );
 45+if ( $sibUserId == -1 ){
 46+ echo "Swiss-Prot user not defined in the database.\n";
 47+ die;
 48+}
 49+
3650 //$linkEC2GoFileName = "LinksEC2Go.txt";
3751 //$linkSwissProtKeyWord2GoFileName = "LinksSP2Go.txt";
3852 //$swissProtXMLFileName = "C:\Documents and Settings\mulligen\Bureaublad\uniprot_sprot.xml";
3953 //$swissProtXMLFileName = "100000lines.xml";
4054 $swissProtXMLFileName = "C:\Documents and Settings\mulligen\Bureaublad\SPentriesForWPTest.xml";
 55+//$swissProtXMLFileName = "C:\Users\mulligen\Desktop\SPentriesForWPTest.xml";
4156
4257 //$wgUser->setID($nlmUserID);
4358 //startNewTransaction($nlmUserID, 0, "UMLS Import");
Index: trunk/extensions/Wikidata/php-tools/SwissProtImport.php
@@ -881,6 +881,7 @@
882882 public function getOrCreateExpression($spelling) {
883883 $expression = findExpression($spelling, $this->languageId);
884884 if (!$expression) {
 885+ //wfDebug( "create expression $spelling in database");
885886 $expression = createExpression($spelling, $this->languageId);
886887 }
887888 return $expression;

Status & tagging log