/[PAMELA software]/YodaProfiler/src/GLTables.cpp
ViewVC logotype

Diff of /YodaProfiler/src/GLTables.cpp

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

revision 1.14 by mocchiut, Tue Oct 24 14:24:22 2006 UTC revision 1.15 by mocchiut, Tue Oct 31 15:36:04 2006 UTC
# Line 374  void GL_RUN::Set_GL_RUN(TSQLRow *Row){ Line 374  void GL_RUN::Set_GL_RUN(TSQLRow *Row){
374  }  }
375    
376  /**  /**
377   *   * This method delete the run from the "FromTable" table and store it in the GL_RUN_TRASH table
378   *   * If IDRUN is 0 "this->ID" run is used.
379   *   *
380   **/   **/
381  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){
# Line 429  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 429  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
429    //    //
430    dbc->Query(myquery.str().c_str());    dbc->Query(myquery.str().c_str());
431    //    //
432      // retrieve this ID_TRASH
433      //
434      myquery.str("");
435      myquery << " SELECT ID_TRASH,ID_ROOT_L0,ID_ROOT_L2 FROM GL_RUN_TRASH ORDER BY ID_TRASH DESC LIMIT 1";  
436      pResult = dbc->Query(myquery.str().c_str());
437      //
438      UInt_t idtrash = 0;
439      UInt_t idl0 = 0;
440      UInt_t idl2 = 0;
441      //
442      Row = pResult->Next();      
443      if( Row != NULL ){
444        idtrash = (UInt_t)atoll(Row->GetField(0));
445        idl0 = (UInt_t)atoll(Row->GetField(1));
446        idl2 = (UInt_t)atoll(Row->GetField(2));    
447      };
448      //
449    TString fileL0 = "";    TString fileL0 = "";
450    TString fileL2 = "";    TString fileL2 = "";
451    myquery.str("");    myquery.str("");
452    myquery << " SELECT NAME FROM GL_ROOT WHERE ID=";    myquery << " SELECT NAME FROM GL_ROOT WHERE ID=";
453    myquery <<  (UInt_t)ID_ROOT_L0 << ";";    myquery <<  idl0 << ";";
454    //    //
455    //  printf("2myquery is %s \n",myquery.str().c_str());    //  printf("2myquery is %s \n",myquery.str().c_str());
456    //    //
# Line 448  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 465  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
465    //    //
466    myquery.str("");    myquery.str("");
467    myquery << " SELECT NAME FROM GL_ROOT WHERE ID=";    myquery << " SELECT NAME FROM GL_ROOT WHERE ID=";
468    myquery << (UInt_t)ID_ROOT_L2 << ";";    myquery << idl2 << ";";
469    //    //
470    //  printf("3myquery is %s \n",myquery.str().c_str());    //  printf("3myquery is %s \n",myquery.str().c_str());
471    //    //
# Line 463  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 480  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
480    //    //
481    myquery.str("");    myquery.str("");
482    myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL0='";    myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL0='";
483    myquery <<  fileL0.Data() << "' where ID=";    myquery <<  fileL0.Data() << "' where ID_TRASH=";
484    myquery << IDRUN << ";";    myquery << idtrash << ";";
485    //    //
486    //  printf("4myquery is %s \n",myquery.str().c_str());    //  printf("4myquery is %s \n",myquery.str().c_str());
487    //    //
# Line 472  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 489  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
489    //    //
490    myquery.str("");    myquery.str("");
491    myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='";    myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='";
492    myquery <<  fileL2.Data() << "' where ID=";    myquery <<  fileL2.Data() << "' where ID_TRASH=";
493    myquery << IDRUN << ";";    myquery << idtrash << ";";
494    //    //
495    //  printf("4myquery is %s \n",myquery.str().c_str());    //  printf("4myquery is %s \n",myquery.str().c_str());
496    //    //
# Line 481  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 498  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
498    //    //
499    myquery.str("");    myquery.str("");
500    myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='";    myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='";
501    myquery <<  FromTable.Data() << "' where ID=";    myquery <<  FromTable.Data() << "' where ID_TRASH=";
502    myquery << IDRUN << ";";    myquery << idtrash << ";";
503    //    //
504    //  printf("4myquery is %s \n",myquery.str().c_str());    //  printf("4myquery is %s \n",myquery.str().c_str());
505    //    //
# Line 505  Int_t GL_RUN::DeleteRun(TSQLServer *dbc, Line 522  Int_t GL_RUN::DeleteRun(TSQLServer *dbc,
522    
523    
524  /**  /**
525   *   * This method restore a run from the GL_RUN_TRASH table.
526   *   * If ID is 0 "this->ID" is used; if "ToTable" is empty BELONG_TO field of GL_RUN_TRASH is used.
527   *   *
528   **/   **/
529  Int_t GL_RUN::RestoreRun(TSQLServer *dbc,UInt_t ID,TString FromTable){  Int_t GL_RUN::RestoreRun(TSQLServer *dbc,UInt_t IDRUN,TString ToTable){
530    // insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11;    // insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11;
531    //insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO  , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11;    //insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO  , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11;
532      // MySQL variables
533      TSQLResult *pResult;
534      TSQLRow *Row;
535      stringstream myquery;
536      //
537      if ( !IDRUN ) IDRUN = ID;
538      if ( !IDRUN ) return 1;
539      //
540      if ( !strcmp(ToTable.Data(),"") ){
541        //    
542        myquery.str("");
543        myquery << " SELECT BELONGED_TO FROM GL_RUN_TRASH WHERE ID=";
544        myquery << (UInt_t)IDRUN << ";";
545        //
546        printf(" qui? myquery is %s \n",myquery.str().c_str());
547        //
548        pResult = dbc->Query(myquery.str().c_str());
549        //
550        Row = pResult->Next();      
551        if( Row != NULL ){
552         ToTable = (TString)Row->GetField(0);
553        } else {
554          return 1;
555        };
556      };
557      // ----------------
558      myquery.str("");
559      myquery << " INSERT INTO ";
560      myquery << ToTable.Data();
561      myquery << " (";  
562      myquery << "ID";
563      myquery << ",ID_RUN_FRAG";
564      myquery << ",ID_ROOT_L0";
565      myquery << ",ID_ROOT_L2";
566      myquery << ",RUNHEADER_TIME";
567      myquery << ",RUNTRAILER_TIME";
568      myquery << ",RUNHEADER_OBT";
569      myquery << ",RUNTRAILER_OBT";
570      myquery << ",RUNHEADER_PKT";
571      myquery << ",RUNTRAILER_PKT";
572      myquery << ",BOOT_NUMBER";
573      myquery << ",EV_FROM";
574      myquery << ",EV_TO";
575      myquery << ",NEVENTS";
576      myquery << ",PKT_COUNTER";
577      myquery << ",PKT_READY_COUNTER";
578      myquery << ",COMPILATIONTIMESTAMP";
579      myquery << ",FAV_WRK_SCHEDULE";
580      myquery << ",EFF_WRK_SCHEDULE";
581      myquery << ",PRH_VAR_TRG_MODE_A";
582      myquery << ",PRH_VAR_TRG_MODE_B";
583      myquery << ",ACQ_BUILD_INFO";
584      myquery << ",ACQ_VAR_INFO";
585      myquery << ",RM_ACQ_AFTER_CALIB";
586      myquery << ",RM_ACQ_SETTING_MODE";
587      myquery << ",TRK_CALIB_USED";
588      myquery << ",CAL_DSP_MASK";
589      myquery << ",LAST_TIMESYNC";
590      myquery << ",OBT_TIMESYNC";
591      myquery << ",VALIDATION";
592      myquery << ",INSERT_TIME";
593      myquery << ") SELECT ";
594      myquery << "ID";
595      myquery << ",ID_RUN_FRAG";
596      myquery << ",ID_ROOT_L0";
597      myquery << ",ID_ROOT_L2";
598      myquery << ",RUNHEADER_TIME";
599      myquery << ",RUNTRAILER_TIME";
600      myquery << ",RUNHEADER_OBT";
601      myquery << ",RUNTRAILER_OBT";
602      myquery << ",RUNHEADER_PKT";
603      myquery << ",RUNTRAILER_PKT";
604      myquery << ",BOOT_NUMBER";
605      myquery << ",EV_FROM";
606      myquery << ",EV_TO";
607      myquery << ",NEVENTS";
608      myquery << ",PKT_COUNTER";
609      myquery << ",PKT_READY_COUNTER";
610      myquery << ",COMPILATIONTIMESTAMP";
611      myquery << ",FAV_WRK_SCHEDULE";
612      myquery << ",EFF_WRK_SCHEDULE";
613      myquery << ",PRH_VAR_TRG_MODE_A";
614      myquery << ",PRH_VAR_TRG_MODE_B";
615      myquery << ",ACQ_BUILD_INFO";
616      myquery << ",ACQ_VAR_INFO";
617      myquery << ",RM_ACQ_AFTER_CALIB";
618      myquery << ",RM_ACQ_SETTING_MODE";
619      myquery << ",TRK_CALIB_USED";
620      myquery << ",CAL_DSP_MASK";
621      myquery << ",LAST_TIMESYNC";
622      myquery << ",OBT_TIMESYNC";
623      myquery << ",VALIDATION";
624      myquery << ",INSERT_TIME";
625      myquery << " FROM GL_RUN_TRASH ";
626      myquery << " WHERE BELONGED_TO='GL_RUN_FRAGMENTS' AND ID=";
627      myquery << (UInt_t)IDRUN << ";";
628      //
629      //  printf("5myquery is %s \n",myquery.str().c_str());
630      //
631      dbc->Query(myquery.str().c_str());
632      //
633      //
634      myquery.str("");
635      myquery << " DELETE FROM GL_RUN_TRASH where BELONGED_TO='GL_RUN_FRAGMENTS' AND ID=";
636      myquery << IDRUN << ";";
637      //
638      dbc->Query(myquery.str().c_str());
639      //
640    return 0;    return 0;
641  };  };
642    

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.23