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

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