Develop and Download Open Source Software

Browse CVS Repository

Diff of /xoonips/AL/commonal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.113 by orrisroot, Tue Oct 11 16:20:22 2005 UTC revision 1.114 by tani, Wed Nov 16 03:59:06 2005 UTC
# Line 22  Line 22 
22   *   *
23   * $Revision$   * $Revision$
24   * $Log$   * $Log$
25     * Revision 1.114  2005/11/16 03:59:06  tani
26     * XOONIPS_STABLEの分岐点〜MergePnt_20051116間のXooNIps_STABLE上の修正をCURRENTにマージ.
27     *
28     * Revision 1.113.2.3  2005/11/01 10:36:14  tani
29     * _insertItem: dierctフラグによって書き込む日付情報の値を分岐する.
30     *
31     * Revision 1.113.2.2  2005/10/28 07:02:52  aga4096
32     * ・サブインデックスを含むインデックスの削除時にエラーが出ることがあるのを修正.
33     *
34     * Revision 1.113.2.1  2005/10/18 09:19:53  aga4096
35     * ・PubMed補完が正しくないことがあるのを修正.
36     *
37   * Revision 1.113  2005/10/11 16:20:22  orrisroot   * Revision 1.113  2005/10/11 16:20:22  orrisroot
38   * SQLRowCount の戻り値チェックを元にもどした.   * SQLRowCount の戻り値チェックを元にもどした.
39   *   *
# Line 497  static SQLHANDLE henv = NULL; Line 509  static SQLHANDLE henv = NULL;
509  static SQLHANDLE hdbc = NULL;  static SQLHANDLE hdbc = NULL;
510    
511    
512  static bool processEsummary(xmlTextReaderPtr reader, pubmed_t* p);  static void processEsummary(xmlTextReaderPtr reader, string &title, string &title_abbr);
513  static bool processEsearch(xmlTextReaderPtr reader, pubmed_t* p, int* DocID );  static bool processEsearch(xmlTextReaderPtr reader, pubmed_t* p, int* DocID );
514  static void processEfetch(xmlTextReaderPtr reader, pubmed_t* p);  static void processEfetch(xmlTextReaderPtr reader, pubmed_t* p);
515  static int streamPubmedFile(const char *filename, pubmed_t* p);  static int streamPubmedFile(const char *filename, pubmed_t* p);
# Line 546  static string getCsvStr( const itemid_t Line 558  static string getCsvStr( const itemid_t
558      return iids_str;      return iids_str;
559  }  }
560    
561    string urlencode( string str ){
562        int len = str.length();
563        char *buf = new char[len*3+1];
564        char *p = buf;
565        for ( int i = 0; i < len; i++ ){
566            char c = str[i];
567            if ( isalnum(c) || c =='$' || c == '*' || c == '_' || c =='.' )
568                *p++ = c;
569            else {
570                sprintf( p, "%%%02X", c & 0x00ff );
571                p += 3;
572            }
573        }
574        *p = '\0';
575        string encoded(buf);
576        delete[] buf;
577        return encoded;
578    }
579    
580  /**  /**
581   *   *
582   * public_item_target_userの設定値が'all'ならtrueをかえす   * public_item_target_userの設定値が'all'ならtrueをかえす
# Line 3755  static result_t _insertItem( sessionid_t Line 3786  static result_t _insertItem( sessionid_t
3786              strncpy2( (char*)lang, item -> getLang(), XNP_ITEM_LANG_LEN );              strncpy2( (char*)lang, item -> getLang(), XNP_ITEM_LANG_LEN );
3787              item_type_id = item -> getItemTypeID( );              item_type_id = item -> getItemTypeID( );
3788              uid = item -> getContributorUID( );              uid = item -> getContributorUID( );
3789              creation_date = time( NULL );              if( direct ){
3790              last_update_date = time( NULL );                  creation_date = item -> getCreationDate();
3791                    last_update_date = item -> getLastUpdateDate();
3792                }else{
3793                    creation_date = time( NULL );
3794                    last_update_date = time( NULL );
3795                }
3796              publication_year = item -> getPublicationYear();              publication_year = item -> getPublicationYear();
3797              publication_month = item -> getPublicationMonth();              publication_month = item -> getPublicationMonth();
3798              publication_mday = item -> getPublicationMday();              publication_mday = item -> getPublicationMday();
# Line 6435  result_t deleteIndexInternal( sessionid_ Line 6471  result_t deleteIndexInternal( sessionid_
6471                      result = querySimple( functionName, sql );                      result = querySimple( functionName, sql );
6472                  }                  }
6473              }              }
6474                
6475                // SQLFreeStmtについては  http://as400bks.rochester.ibm.com/pubs/html/as400/v4r5/ic2962/info/db2/rzadpmst62.htm#HDRFNFSTMT
6476                SQLFreeStmt( hstmt, SQL_CLOSE );
6477                SQLFreeStmt( hstmt, SQL_UNBIND );
6478          }          }
6479                    
6480          // 影響を受けたはずのアイテムを insertMetadataEventAutoする          // 影響を受けたはずのアイテムを insertMetadataEventAutoする
# Line 6944  static int streamPubmedFile(const char * Line 6984  static int streamPubmedFile(const char *
6984          return ret;          return ret;
6985      }      }
6986            
6987        // processEfetchで得たjournalは省略形なので、それを非省略形に変換する
6988      string url = PUBMED_ESEARCH_URL_BASE;      string url = PUBMED_ESEARCH_URL_BASE;
6989      const char* ptr = p -> getJournal( );      string journal( p -> getJournal() );
6990      while( *ptr != '\0' ){      url += urlencode("\""+journal+"\"[TA]"); // [TA] = [Title Abbreviation]
6991          char buf[ 4 ];      url = urlencode(url);  // libxmlのバグ(?)のため、2回urlencodeする
         sprintf( buf, "%%%02X", ( unsigned char )*( ptr++ ) );  
         url +=  buf;  
     }  
       
6992      reader = xmlNewTextReaderFilename(url.c_str());      reader = xmlNewTextReaderFilename(url.c_str());
6993      if( reader != NULL ){      if( reader != NULL ){
6994          ret = xmlTextReaderRead(reader);          ret = xmlTextReaderRead(reader);
6995          while( ret == 1 ){          while( ret == 1 ){
6996              if( processEsearch(reader, p, &DocID ) ) break;              if( processEsearch(reader, p, &DocID ) ) {
6997              ret = xmlTextReaderRead(reader);                  
6998          }                  string title, title_abbr;
6999          while( ret == 1 ){                  url = PUBMED_ESUMMARY_URL_BASE;
7000                    url += intToString( DocID );
7001                    xmlTextReaderPtr reader2 = xmlNewTextReaderFilename(url.c_str());
7002                    if( reader2 != NULL ){
7003                        ret = xmlTextReaderRead(reader2);
7004                        while( ret == 1 ){
7005                            processEsummary( reader2, title, title_abbr );
7006                            ret = xmlTextReaderRead( reader2 );
7007                        }
7008                        xmlFreeTextReader(reader2);
7009                    }
7010                    err = xmlGetLastError();
7011                    if( err != NULL ){
7012                        setLastErrorString( err -> message );
7013                        //return ret;
7014                    }
7015                    if ( title_abbr == journal )
7016                        p -> setJournal( title.c_str() );
7017                    
7018                }
7019              ret = xmlTextReaderRead(reader);              ret = xmlTextReaderRead(reader);
7020          }          }
         xmlFreeTextReader(reader);  
     }  
     err = xmlGetLastError();  
     if( err != NULL ){  
         setLastErrorString( err -> message );  
         return ret;  
     }  
       
     url = PUBMED_ESUMMARY_URL_BASE;  
     url += intToString( DocID );  
     reader = xmlNewTextReaderFilename(url.c_str());  
     if( reader != NULL ){  
         ret = xmlTextReaderRead(reader);  
         while( ret == 1 ){  
             if( processEsummary( reader, p ) ) break;  
             ret = xmlTextReaderRead( reader );  
         }  
7021          while( ret == 1 ){          while( ret == 1 ){
7022              ret = xmlTextReaderRead(reader);              ret = xmlTextReaderRead(reader);
7023          }          }
# Line 7093  static bool processEsearch(xmlTextReader Line 7132  static bool processEsearch(xmlTextReader
7132                      xmlChar* value = xmlTextReaderValue( reader );                      xmlChar* value = xmlTextReaderValue( reader );
7133                      *DocID = atoi( ( char* )value );                      *DocID = atoi( ( char* )value );
7134                      xmlFree( value );                      xmlFree( value );
7135                                          value = NULL;                      value = NULL;
7136                      return true;                      return true;
7137                  }                  }
7138              }              }
# Line 7107  static bool processEsearch(xmlTextReader Line 7146  static bool processEsearch(xmlTextReader
7146    
7147  /**  /**
7148   *   *
7149   * @return true Journal Titleを取得した.   * Journal Title, Journal Title Abbreviation を取得する.
  * @return false Journal Titleを取得出来なかった.パースの継続を請う.  
7150   */   */
7151  static bool processEsummary(xmlTextReaderPtr reader, pubmed_t* p)  static void processEsummary(xmlTextReaderPtr reader, string &title, string &title_abbr )
7152  {  {
7153      xmlChar* name = NULL;      xmlChar* name = NULL;
7154      xmlChar* value = NULL;      xmlChar* value = NULL;
     bool ret = false;  
7155            
7156      name = xmlTextReaderName(reader);      name = xmlTextReaderName(reader);
7157      if( name == NULL)      if( name == NULL)
# Line 7129  static bool processEsummary(xmlTextReade Line 7166  static bool processEsummary(xmlTextReade
7166                      if( xmlTextReaderRead(reader) == 1 ){                      if( xmlTextReaderRead(reader) == 1 ){
7167                          if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){                          if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){
7168                              xmlChar* value = xmlTextReaderValue( reader );                              xmlChar* value = xmlTextReaderValue( reader );
7169                              p -> setJournal( ( char* )value );                              title = ( char* )value;
7170                                xmlFree( value );
7171                                value = NULL;
7172                            }
7173                        }
7174                    }
7175                    else if( strcmp( "MedAbbr", ( char* )attr_val ) == 0 ){
7176                        if( xmlTextReaderRead(reader) == 1 ){
7177                            if( xmlTextReaderNodeType( reader ) == XML_READER_TYPE_TEXT ){
7178                                xmlChar* value = xmlTextReaderValue( reader );
7179                                title_abbr = ( char* )value;
7180                              xmlFree( value );                              xmlFree( value );
7181                              value = NULL;                              value = NULL;
                             ret = true;  
7182                          }                          }
7183                      }                      }
7184                  }                  }
# Line 7143  static bool processEsummary(xmlTextReade Line 7189  static bool processEsummary(xmlTextReade
7189      xmlFree(name);      xmlFree(name);
7190            
7191      if( value != NULL) xmlFree(value);      if( value != NULL) xmlFree(value);
     return ret;  
7192  }  }
7193    
7194  static void processAsinSearch(xmlTextReaderPtr reader, amazonbook_t* p )  static void processAsinSearch(xmlTextReaderPtr reader, amazonbook_t* p )

Legend:
Removed from v.1.113  
changed lines
  Added in v.1.114

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26