12 #define timeFmt QString("hh:mm:ss")
13 #define nowTime() "T="+QDateTime::currentDateTime().toString(timeFmt)
87 query <<
"get_experiment_desc" <<
invID;
92 QString runID =
db->
value( 1 ).toString();
94 if ( ! runIDs.contains( runID ) )
97 DbgLv(1) <<
"gRI: db runs" << runIDs.size();
102 QStringList aucdirs = QDir( rdir )
103 .entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name );
107 DbgLv(1) <<
"gRI: aucdirs" << aucdirs.size();
109 for (
int ii = 0; ii < aucdirs.size(); ii++ )
111 QString aucdir = aucdirs.at( ii );
112 QString subdir = rdir + aucdir;
113 QStringList aucfiles = QDir( subdir )
114 .entryList( aucfilt, QDir::Files, QDir::Name );
115 int naucf = aucfiles.size();
116 QString runID = aucdir.section(
".", 0, 0 );
118 if ( naucf > 0 && ! runIDs.contains( runID ) )
121 DbgLv(1) <<
"gRI: db+local runs" << runIDs.size();
133 query <<
"get_experiment_info_by_runID" << runID <<
invID;
136 QString expID =
db->
value( 1 ).toString();
139 query <<
"get_rawDataIDs" << expID;
141 DbgLv(1) <<
"gTr: runID" << runID <<
"expID" << expID;
145 QString fname =
db->
value( 2 ).toString().section(
"/", -1, -1 );
146 QString rrID = fname.section(
".", 0, 0 );
151 QString triple = fname.section(
".", -4, -2 );
153 if ( ! triples.contains( triple ) )
157 DbgLv(1) <<
"gTr: db triples" << triples.size();
161 DbgLv(1) <<
"gTr: aucdir" << aucdir;
164 aucfilt << runID +
"*.auc";
165 QStringList aucfiles = QDir( aucdir )
166 .entryList( aucfilt, QDir::Files, QDir::Name );
167 int naucf = aucfiles.size();
168 DbgLv(1) <<
"gTr: naucf" << naucf;
170 for (
int ii = 0; ii < naucf; ii++ )
172 QString fname = aucfiles.at( ii );
173 QString triple = fname.section(
".", -4, -2 );
175 if ( ! triples.contains( triple ) )
178 DbgLv(1) <<
"gTr: db+local triples" << triples.size();
268 const int max_qrec = 200;
273 QStringList modDescs;
275 QMap< QString, int > edtMap;
276 QMap< QString, QString > rawGUIDs;
277 QString dmyGUID =
"00000000-0000-0000-0000-000000000000";
299 lb_status->setText( tr(
"Reading DataBase Data..." ) );
300 qApp->processEvents();
306 query <<
"get_experiment_desc" <<
invID;
312 QString expID =
db->
value( 0 ).toString();
313 QString runID =
db->
value( 1 ).toString();
314 QString etype =
db->
value( 2 ).toString();
316 DbgLv(2) <<
" expID runID type" << expID << runID << etype;
319 lb_status->setText( tr(
"Reading Experiments" ) );
320 DbgLv(2) <<
" expID expGUID runID label comment date";
321 qApp->processEvents();
323 for (
int ii = 0; ii < expIDs.size(); ii++ )
325 QString expID = expIDs[ ii ];
327 query <<
"get_experiment_info" << expID;
330 QString expGUID =
db->
value( 0 ).toString();
331 QString runID =
db->
value( 2 ).toString();
332 QString label =
db->
value( 9 ).toString();
333 QString comment =
db->
value( 10 ).toString();
335 .toDateTime().toString( Qt::ISODate ), true );
336 DbgLv(2) <<
" " << expID << expGUID << runID << label << comment << date;
339 QDateTime basetime=QDateTime::currentDateTime();
360 query <<
"get_experiment_info_by_runID" <<
filt_run <<
invID;
363 expID =
db->
value( 1 ).toString();
364 expGUID =
db->
value( 2 ).toString();
367 query <<
"count_rawData_by_experiment" << expID;
369 DbgLv(1) <<
"BrDb: nraws" << nraws;
370 rawIDs .reserve( nraws );
374 query <<
"get_rawDataIDs" << expID;
379 QString rawID =
db->
value( 0 ).toString();
380 QString filename =
db->
value( 2 ).toString().replace(
"\\",
"/" );
381 QString filebase = filename.section(
"/", -1, -1 );
382 QString triple = filebase.section(
".", -4, -2 );
387 DbgLv(1) <<
"BrDb: nraws" << nraws;
390 if ( nraws < max_qrec )
392 for (
int ii = 0; ii < nraws; ii++ )
394 QString rawID = rawIDs[ ii ];
396 query <<
"get_editedDataIDs" << rawID;
400 QString edtID =
db->
value( 0 ).toString();
401 QString filename =
db->
value( 2 ).toString()
402 .replace(
"\\",
"/" );
403 QString filebase = filename.section(
"/", -1, -1 );
404 QString triple = filebase.section(
".", -4, -2 );
415 query <<
"all_editedDataIDs" <<
invID;
419 QString edtID =
db->
value( 0 ).toString();
420 QString expIDed =
db->
value( 4 ).toString();
421 if ( expIDed != expID )
continue;
422 QString filename =
db->
value( 2 ).toString().replace(
"\\",
"/" );
423 QString filebase = filename.section(
"/", -1, -1 );
424 QString triple = filebase.section(
".", -4, -2 );
430 DbgLv(1) <<
"BrDb: nedts" << nedts;
433 if ( nedts < max_qrec )
435 for (
int ii = 0; ii < nedts; ii++ )
437 QString edtID = edtIDs[ ii ];
439 query <<
"get_model_desc_by_editID" << invID << edtID;
443 QString modID =
db->
value( 0 ).toString();
448 query <<
"get_noise_desc_by_editID" << invID << edtID;
452 QString noiID =
db->
value( 0 ).toString();
462 query <<
"get_model_desc" <<
invID;
466 QString modID =
db->
value( 0 ).toString();
467 QString edtID =
db->
value( 6 ).toString();
468 if ( edtIDs.contains( edtID ) )
475 query <<
"get_noise_desc" <<
invID;
479 QString noiID =
db->
value( 0 ).toString();
480 QString edtID =
db->
value( 2 ).toString();
481 if ( edtIDs.contains( edtID ) )
488 DbgLv(1) <<
"BrDb: nmods" << nmods <<
"nnois" << nnois;
494 query <<
"count_rawData" <<
invID;
496 DbgLv(1) <<
"BrDb: nraws" << nraws;
499 query <<
"count_editedData" <<
invID;
501 DbgLv(1) <<
"BrDb: nedts" << nedts;
504 query <<
"count_models" <<
invID;
506 DbgLv(1) <<
"BrDb: nmods" << nmods;
509 query <<
"count_noise" <<
invID;
511 DbgLv(1) <<
"BrDb: nnois" << nnois;
514 nstep = nraws + nedts + nmods + nnois;
515 int incre = nraws + nedts;
516 DbgLv(1) <<
"BrDb: nstep" << nstep <<
"incre" << incre;
517 incre = qMax( incre, 1 );
518 incre = ( nmods + nnois + incre - 1 ) / ( incre * 4 );
519 incre = qMax( incre, 1 );
520 DbgLv(1) <<
"BrDb: incre" << incre;
521 nstep += ( nraws + nedts ) * ( incre - 1 );
522 nstep = qMax( nstep, 1 );
524 DbgLv(1) <<
"BrDb: nstep" << nstep;
528 qApp->processEvents();
529 DbgLv(1) <<
"BrDb: # steps raws edts mods nois" << nstep << nraws << nedts
530 << nmods << nnois <<
"incre" << incre;
531 DbgLv(1) <<
"BrDb: count time:"
532 << basetime.msecsTo(QDateTime::currentDateTime())/1000.0;
536 rawIDs .reserve( nraws );
537 edtIDs .reserve( nedts );
538 modIDs .reserve( nmods );
539 noiIDs .reserve( nnois );
542 modDescs.reserve( nmods );
545 lb_status->setText( tr(
"Reading Raws" ) );
546 qApp->processEvents();
547 int nqry = rfilt ? rawIDs.size() : qMin( nraws, 1 );
548 bool rfilt_q = rfilt && ( nqry < max_qrec );
549 nqry = rfilt_q ? nqry : qMin( nraws, 1 );
551 DbgLv(1) <<
"BrDb: Query Raws" <<
nowTime() <<
"nqry" << nqry;
552 for (
int jq = 0; jq < nqry; jq++ )
558 rawID = rawIDs[ jq ];
559 query <<
"get_rawData" << rawID;
563 query <<
"all_rawDataIDs" <<
invID;
569 recID =
db->
value( 0 ).toString();
570 QString label =
db->
value( 1 ).toString();
571 QString filename =
db->
value( 2 ).toString().replace(
"\\",
"/" );
572 QString filebase = filename.section(
"/", -1, -1 );
573 QString runID = filebase.section(
".", 0, 0 );
574 QString triple = filebase.section(
".", -4, -2 );
576 if ( rfilt && runID !=
filt_run )
continue;
588 experID =
db->
value( 4 ).toString();
590 .toDateTime().toString( Qt::ISODate ), true );
591 cksum =
db->
value( 8 ).toString();
592 recsize =
db->
value( 9 ).toString();
593 rawGUID =
db->
value( 0 ).toString();
594 comment =
db->
value( 3 ).toString();
599 experID =
db->
value( 3 ).toString();
601 .toDateTime().toString( Qt::ISODate ), true );
602 cksum =
db->
value( 6 ).toString();
603 recsize =
db->
value( 7 ).toString();
604 rawGUID =
db->
value( 9 ).toString();
605 comment =
db->
value( 10 ).toString();
606 expGUID =
db->
value( 11 ).toString();
609 rawGUIDs[ recID ] = rawGUID;
610 irecID = recID.toInt();
611 DbgLv(1) <<
"BrDb: RAW id" << recID <<
" expID" << experID;
612 QString subType =
"";
613 contents = cksum +
" " + recsize;
615 if ( comment.isEmpty() )
616 comment = filename.section(
".", 0, -2 );
618 if ( ! label.contains(
"." ) )
619 label = filename.section(
".", 0, -2 );
624 DbgLv(2) <<
"BrDb: raw expGid" << expGUID;
625 DbgLv(2) <<
"BrDb: label filename comment" << label << filename << comment;
652 qApp->processEvents();
656 int kraw = rawIDs.size();
657 if ( rfilt && kraw == 1 )
659 nstep /= qMax( nraws, 1 );
663 lb_status->setText( tr(
"Reading Edits" ) );
664 qApp->processEvents();
665 nqry = rfilt ? edtIDs.size() : qMin( nedts, 1 );
666 rfilt_q = rfilt && ( nqry < max_qrec );
667 nqry = rfilt_q ? nqry : qMin( nedts, 1 );
669 DbgLv(1) <<
"BrDb: Query Edits" <<
nowTime() <<
"nqry" << nqry;
670 for (
int jq = 0; jq < nqry; jq++ )
676 edtID = edtIDs[ jq ];
677 query <<
"get_editedData" << edtID;
681 query <<
"all_editedDataIDs" <<
invID;
703 rawID =
db->
value( 0 ).toString();
704 editGUID =
db->
value( 1 ).toString();
705 label =
db->
value( 2 ).toString();
706 filename =
db->
value( 3 ).toString().replace(
"\\",
"/" );
707 filebase = filename.section(
"/", -1, -1 );
709 .toDateTime().toString( Qt::ISODate ), true );
710 comment =
db->
value( 4 ).toString();
711 cksum =
db->
value( 6 ).toString();
712 recsize =
db->
value( 7 ).toString();
713 runID = filebase.section(
".", 0, 0 );
714 triple = filebase.section(
".", -4, -2 );
720 recID =
db->
value( 0 ).toString();
721 label =
db->
value( 1 ).toString();
722 filename =
db->
value( 2 ).toString().replace(
"\\",
"/" );
723 filebase = filename.section(
"/", -1, -1 );
724 rawID =
db->
value( 3 ).toString();
725 expID =
db->
value( 4 ).toString();
727 .toDateTime().toString( Qt::ISODate ), true );
728 cksum =
db->
value( 6 ).toString();
729 recsize =
db->
value( 7 ).toString();
730 editGUID =
db->
value( 9 ).toString();
732 runID = filebase.section(
".", 0, 0 );
733 triple = filebase.section(
".", -4, -2 );
734 if ( rfilt && runID !=
filt_run )
continue;
738 irecID = recID.toInt();
739 DbgLv(2) <<
"BrDb: EDT id" << recID <<
" raID" <<
db->
value(3).toString()
740 <<
" expID" <<
db->
value(4).toString();
741 rawGUID = rawGUIDs[ rawID ];
746 QString subType = filebase.section(
".", 2, 2 );
747 contents = cksum +
" " + recsize;
748 DbgLv(2) <<
"BrDb: edt id eGID rGID label date"
749 << irecID << editGUID << rawGUID << label << date;
752 if ( ! filename.contains(
"/" ) )
754 + filename.section(
".", 0, 0 ) +
"/"
768 filebase.section(
".", 0, 2 ) :
784 qApp->processEvents();
787 DbgLv(1) <<
"BrDb: EDT loop done";
790 const int _M_LARGE_ = 65000;
792 QList< int > tmodnxs;
793 lb_status->setText ( tr(
"Reading Models" ) );
795 qApp->processEvents();
796 DbgLv(1) <<
"BrDb: Reading Models";
797 nqry = rfilt ? edtIDs.size() : 1;
798 rfilt_q = rfilt && ( nqry < max_qrec );
799 nqry = rfilt_q ? nqry : qMin( nedts, 1 );
802 for (
int jq = 0; jq < nqry; jq++ )
807 query <<
"get_model_desc_by_editID" <<
invID << edtIDs[ jq ];
809 query <<
"get_model_desc" <<
invID;
818 recID =
db->
value( 0 ).toString();
819 QString editID =
db->
value( 6 ).toString();
824 if ( ! edtIDs.contains( editID ) )
continue;
829 irecID = recID.toInt();
830 QString modelGUID =
db->
value( 1 ).toString();
831 QString descript =
db->
value( 2 ).toString();
832 modDescs << descript;
834 if ( descript.length() == 80 )
840 QString editGUID =
db->
value( 5 ).toString();
841 DbgLv(2) <<
"BrDb: MOD id" << recID <<
" edID" << editID <<
" edGID" << editGUID;
842 DbgLv(2) <<
"BrDb: MOD id" << recID <<
" desc" << descript;
844 .toDateTime().toString( Qt::ISODate ), true );
845 QString cksum =
db->
value( 8 ).toString();
846 QString recsize =
db->
value( 9 ).toString();
847 QString label = descript.section(
".", 0, -2 );
849 if ( label.length() > 40 )
850 label = label.left( 13 ) +
"..." + label.right( 24 );
853 QString subType = descript.section(
".", -2, -2 ).section(
"_",2,2 );
856 if ( descript.contains(
"CustomGrid" ) ||
857 ( !descript.contains(
"_mc" ) && recsize.toInt() > _M_LARGE_ ) )
858 subType =
"CUSTOMGRID";
861 else if ( subType.isEmpty() )
864 contents = cksum +
" " + recsize;
888 qApp->processEvents();
895 QList< int > tnoinxs;
896 lb_status->setText( tr(
"Reading Noises" ) );
897 qApp->processEvents();
899 for (
int jq = 0; jq < nqry; jq++ )
904 query <<
"get_noise_desc_by_editID" <<
invID << edtIDs[ jq ];
906 query <<
"get_noise_desc" <<
invID;
913 recID =
db->
value( 0 ).toString();
914 irecID = recID.toInt();
915 QString editID =
db->
value( 2 ).toString();
918 if ( ! edtIDs.contains( editID ) )
continue;
923 QString noiseGUID =
db->
value( 1 ).toString();
924 QString modelID =
db->
value( 3 ).toString();
925 QString noiseType =
db->
value( 4 ).toString();
926 QString modelGUID =
db->
value( 5 ).toString();
928 .toDateTime().toString( Qt::ISODate ), true );
929 QString cksum =
db->
value( 7 ).toString();
930 QString recsize =
db->
value( 8 ).toString();
931 QString descript =
db->
value( 9 ).toString();
932 DbgLv(2) <<
"BrDb: NOI id" << recID <<
" edID" << editID <<
" moID" << modelID
933 <<
" descript" << descript;
935 if ( descript.isEmpty() || descript.length() == 80 )
937 int jmod = modIDs.indexOf( modelID );
940 descript = modDescs.at( jmod );
942 if ( descript.length() == 80 )
948 descript = descript.replace(
".model",
"." + noiseType );
949 DbgLv(2) <<
"BrDb: jmod" << jmod <<
" descript" << descript;
956 contents = cksum +
" " + recsize;
957 QString label = descript.section(
".", 0, -2 );
959 if ( label.length() > 40 )
960 label = label.left( 13 ) +
"..." + label.right( 24 );
964 cdesc.
subType = ( noiseType ==
"ti_noise" ) ?
"TI" :
"RI";
975 DbgLv(2) <<
"BrDb: noi id nGID dsc typ noityp"
976 << irecID << noiseGUID << descript <<
cdesc.
subType << noiseType;
986 qApp->processEvents();
988 DbgLv(2) <<
"BrDb: Noise IDs" <<
nowTime() <<
"size" << noiIDs.size();
991 for (
int ii = 0; ii < tmodels.size(); ii++ )
993 recID = tmodels[ ii ];
994 int jdsc = tmodnxs[ ii ];
999 QString label = descript.section(
".", 0, -2 );
1001 if ( label.length() > 40 )
1002 label = label.left( 13 ) +
"..." + label.right( 24 );
1005 <<
"dsc2" << descript;
1011 for (
int ii = 0; ii < tnoises.size(); ii++ )
1013 recID = tnoises[ ii ];
1014 int jdsc = tnoinxs[ ii ];
1017 noise1.
load( recID,
db );
1019 QString label = descript.section(
".", 0, -2 );
1021 if ( label.length() > 40 )
1022 label = label.left( 13 ) +
"..." + label.right( 24 );
1025 <<
"dsc2" << descript;
1033 qApp->processEvents();
1034 DbgLv(1) <<
"BrDb: kr ke km kn"
1035 << rawIDs.size() << edtIDs.size() << modIDs.size() << noiIDs.size();
1036 DbgLv(1) <<
"BrDb: scan time:"
1037 << basetime.msecsTo(QDateTime::currentDateTime())/1000.0;
1040 lb_status->setText( tr(
"Database Review Complete" ) );
1041 qApp->processEvents();
1061 QString dirm = ddir +
"/models";
1062 QString dirn = ddir +
"/noises";
1063 QString contents =
"";
1064 QString dmyGUID =
"00000000-0000-0000-0000-000000000000";
1065 QStringList aucdirs = rfilt ? QStringList(
filt_run )
1067 .entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name );
1069 QStringList aucfilt;
1070 QStringList edtfilt;
1073 QStringList modfilt(
"M*xml" );
1074 QStringList noifilt(
"N*xml" );
1075 QStringList modfils = QDir( dirm )
1076 .entryList( modfilt, QDir::Files, QDir::Name );
1077 QStringList noifils = QDir( dirn )
1078 .entryList( noifilt, QDir::Files, QDir::Name );
1080 int naucd = aucdirs.size();
1081 int nedtf = naucd * 3;
1082 int nmodf = modfils.size();
1083 int nnoif = noifils.size();
1084 QString aucpatt =
"*.auc";
1085 QString edtpatt =
"*.xml";
1093 for (
int ii = 0; ii < naucd; ii++ )
1095 QString subdir = rdir + aucdirs.at( ii );
1101 QStringList edtfiles = QDir( subdir )
1102 .entryList( edtfilt, QDir::Files, QDir::Name );
1103 nedtf += edtfiles.size();
1109 for (
int ii = 0; ii < modfils.size(); ii++ )
1112 QString modfil = dirm +
"/" + modfils.at( ii );
1113 model.
load( modfil );
1115 if ( ! mdesc.startsWith(
filt_run ) )
continue;
1116 if ( tfilt && ! mdesc.contains(
filt_triple ) )
continue;
1120 for (
int ii = 0; ii < noifils.size(); ii++ )
1123 QString noifil = dirn +
"/" + noifils.at( ii );
1124 noise.
load( noifil );
1126 if ( ! ndesc.startsWith(
filt_run ) )
continue;
1127 if ( tfilt && ! ndesc.contains(
filt_triple ) )
continue;
1132 int nstep = naucd + nedtf + nmodf + nnoif;
1133 DbgLv(1) <<
"BrLoc: naucd nedtf nmodf nnoif nstep"
1134 << naucd << nedtf << nmodf << nnoif << nstep;
1139 DbgLv(1) <<
"BrLoc: aucfilt" << aucfilt <<
"edtfilt" << edtfilt;
1141 lb_status->setText( tr(
"Reading Local-Disk Data..." ) );
1143 qApp->processEvents();
1145 for (
int ii = 0; ii < naucd; ii++ )
1147 QString subdir = rdir + aucdirs.at( ii );
1148 QStringList aucfiles = QDir( subdir )
1149 .entryList( aucfilt, QDir::Files, QDir::Name );
1150 int naucf = aucfiles.size();
1151 DbgLv(1) <<
"BrLoc: ii naucf" << ii << naucf <<
"subdir" << subdir;
1155 for (
int jj = 0; jj < naucf; jj++ )
1157 QString fname = aucfiles.at( jj );
1158 QString runid = fname.section(
".", 0, 0 );
1159 QString tripl = fname.section(
".", -5, -2 );
1160 QString aucfile = subdir +
"/" + fname;
1163 DbgLv(2) <<
"BrLoc: ii jj file" << ii << jj << aucfile;
1169 DbgLv(2) <<
"BrLoc: contents" << contents;
1172 QString rawGUID = uuid;
1186 .lastModified().toUTC().toString( Qt::ISODate )
1200 edtfilt << runid +
".*." + tripl +
".xml";
1201 DbgLv(2) <<
"BrLoc: edtfilt" << edtfilt;
1203 QStringList edtfiles = QDir( subdir )
1204 .entryList( edtfilt, QDir::Files, QDir::Name );
1206 for (
int kk = 0; kk < edtfiles.size(); kk++ )
1208 QString efname = edtfiles.at( kk );
1209 QString editid = efname.section(
".", 1, 3 );
1210 QString edtfile = subdir +
"/" + efname;
1220 cdesc.recordID = -1;
1222 cdesc.subType = efname.section(
".", 2, 2 );
1224 cdesc.dataGUID = edval.
editGUID.simplified();
1225 cdesc.parentGUID = edval.
dataGUID.simplified();
1226 cdesc.parentID = -1;
1227 cdesc.filename = edtfile;
1228 cdesc.contents = contents;
1229 cdesc.label = runid +
"." + editid;
1230 cdesc.description = efname.section(
".", 0, -2 );
1232 .lastModified().toUTC().toString( Qt::ISODate )
1234 cdesc.lastmodDate =
"";
1236 if ( cdesc.dataGUID.length() != 36 || cdesc.dataGUID == dmyGUID )
1239 cdesc.parentGUID = cdesc.parentGUID.simplified().length() == 36 ?
1240 cdesc.parentGUID.simplified() : dmyGUID;
1245 if ( ii == ( naucd / 2 ) && jj == ( naucf / 2 ) )
1248 qApp->processEvents();
1252 qApp->processEvents();
1255 qApp->processEvents();
1257 for (
int ii = 0; ii < nmodf; ii++ )
1260 QString modfil = dirm +
"/" + modfils.at( ii );
1263 model.
load( modfil );
1281 .lastModified().toUTC().toString( Qt::ISODate )
1289 QString label = model.
description.section(
".", 0, -2 );
1290 cdesc.
label = ( label.length() < 41 ) ? label :
1291 ( label.left( 13 ) +
"..." + label.right( 24 ) );
1297 qApp->processEvents();
1300 for (
int ii = 0; ii < nnoif; ii++ )
1303 QString noifil = dirn +
"/" + noifils.at( ii );
1305 noise.
load( noifil );
1323 .lastModified().toUTC().toString( Qt::ISODate )
1333 cdesc.
label = ( label.length() < 41 ) ? label :
1334 ( label.left( 9 ) +
"..." + label.right( 28 ) );
1339 qApp->processEvents();
1343 lb_status->setText( tr(
"Local Data Review Complete" ) );
1344 qApp->processEvents();
1350 int nddes =
ddescs.size();
1351 int nldes =
ldescs.size();
1352 int nstep = ( ( nddes + nldes ) * 5 ) / 8;
1360 DbgLv(1) <<
"MERGE: nd nl dlab llab"
1361 << nddes << nldes << descd.
label << descl.
label;
1363 lb_status->setText( tr(
"Merging Data ..." ) );
1365 qApp->processEvents();
1367 while ( jdr < nddes && jlr < nldes )
1374 nstep = ( kar * 9 ) / 8;
1377 qApp->processEvents();
1397 DbgLv(2) <<
"MERGE: kar jdr jlr (1)GID" << kar << jdr << jlr << descd.dataGUID;
1400 if ( ++jdr < nddes )
1401 descd =
ddescs.at( jdr );
1405 if ( ++jlr < nldes )
1406 descl =
ldescs.at( jlr );
1411 if ( ++jlr < nldes )
1412 descl =
ldescs.at( jlr );
1417 if ( jdr >= nddes || jlr >= nldes )
1423 DbgLv(2) <<
"MERGE: kar jdr jlr (2)GID" << kar << jdr << jlr << descd.dataGUID;
1426 if ( ++jdr < nddes )
1427 descd =
ddescs.at( jdr );
1432 if ( jdr >= nddes || jlr >= nldes )
1438 DbgLv(2) <<
"MERGE: kar jdr jlr (3)GID" << kar << jdr << jlr << descl.dataGUID;
1441 if ( ++jlr < nldes )
1442 descl =
ldescs.at( jlr );
1447 if ( jdr >= nddes || jlr >= nldes )
1460 QString dlabel = descd.
label;
1461 QString llabel = descl.
label;
1467 DbgLv(2) <<
"MERGE: rtype dlabel llabel" << descd.
recType << dlabel << llabel;
1469 if ( dlabel < llabel )
1472 DbgLv(2) <<
"MERGE: kar jdr jlr (4)GID" << kar << jdr << jlr << descd.dataGUID;
1475 if ( ++jdr < nddes )
1476 descd =
ddescs.at( jdr );
1484 DbgLv(2) <<
"MERGE: kar jdr jlr (5)GID" << kar << jdr << jlr << descl.dataGUID;
1487 if ( ++jlr < nldes )
1488 descl =
ldescs.at( jlr );
1497 nstep += ( nddes - jdr + nldes - jlr );
1499 qApp->processEvents();
1501 while ( jdr < nddes )
1505 DbgLv(2) <<
"MERGE: kar jdr jlr (8)GID" << kar << jdr << jlr << descd.
dataGUID;
1507 qApp->processEvents();
1510 while ( jlr < nldes )
1514 DbgLv(2) <<
"MERGE: kar jdr jlr (9)GID" << kar << jdr << jlr << descl.
dataGUID;
1516 qApp->processEvents();
1519 DbgLv(2) <<
"MERGE: nddes nldes kar" << nddes << nldes << --kar;
1523 lb_status->setText( tr(
"Data Merge Complete" ) );
1524 qApp->processEvents();
1530 QVector< DataDesc > tdess =
adescs;
1532 int krecs = tdess.size();
1538 for (
int ii = 0; ii < krecs; ii++ )
1540 desct = tdess[ ii ];
1547 if ( isDba && isLoc )
1577 QVector< DataDesc > tdess;
1583 int nrecs = descs.size();
1585 lb_status->setText( tr(
"Sorting Descriptions..." ) );
1586 qApp->processEvents();
1587 DbgLv(1) <<
"sort_desc: nrecs" << nrecs;
1591 tdess.resize( nrecs );
1594 for (
int ii = 0; ii < nrecs; ii++ )
1597 for (
int ii = 0; ii < nrecs; ii++ )
1599 desct = descs[ ii ];
1604 else if ( desct.
recType == 2 )
1607 else if ( desct.
recType == 3 )
1610 else if ( desct.
recType == 4 )
1613 tdess[ ii ] = desct;
1624 lb_status->setText( tr(
"Finding Duplicates..." ) );
1625 qApp->processEvents();
1640 lb_status->setText( tr(
"Finding Orphans..." ) );
1641 qApp->processEvents();
1649 QString dmyGUID =
"00000000-0000-0000-0000-000000000000";
1656 int kndx = tdess.size();
1666 for (
int ii = 0; ii < sortr.size(); ii++ )
1667 guidsr << sortr.at( ii ).section(
":", 2, 2 ).simplified();
1669 for (
int ii = 0; ii < sorte.size(); ii++ )
1670 guidse << sorte.at( ii ).section(
":", 2, 2 ).simplified();
1672 for (
int ii = 0; ii < sortm.size(); ii++ )
1673 guidsm << sortm.at( ii ).section(
":", 2, 2 ).simplified();
1677 int nstep = orphn.size() + orphm.size() + orphe.size();
1681 qApp->processEvents();
1682 DbgLv(2) <<
"(1) orphan: N size M size" << orphn.size() << orphm.size();
1683 for (
int ii = 0; ii < orphn.size(); ii++ )
1685 dsorts = orphn.at( ii );
1686 dlabel = dsorts.section(
":", 0, 0 );
1687 dindex = dsorts.section(
":", 1, 1 );
1688 ddGUID = dsorts.section(
":", 2, 2 ).simplified();
1689 dpGUID = dsorts.section(
":", 3, 3 ).simplified();
1690 jndx = dindex.toInt();
1691 cdesc = tdess[ jndx ];
1693 if ( dpGUID.length() < 2 || dpGUID == dmyGUID )
1700 kk = sortn.indexOf( dsorts );
1701 dsorts = dlabel +
":" + dindex +
":" + ddGUID +
":" + dpGUID;
1705 sortn.replace( kk, dsorts );
1707 tdess[ jndx ] =
cdesc;
1718 if ( guidsm.indexOf( dpGUID ) >= 0 )
1721 if ( dpGUID == dmyGUID )
1737 QDateTime::currentDateTime().toUTC()
1738 .toString( Qt::ISODate ),
true );
1741 dlabel = dlabel.section(
".", 0, 0 );
1742 dindex = QString().sprintf(
"%4.4d", kndx++ );
1745 dsorts = dlabel +
":" + dindex +
":" + ddGUID +
":" + dpGUID;
1751 DbgLv(2) <<
"N orphan:" << orphn.at( ii ) << ii;
1752 DbgLv(2) <<
" M dummy:" << dsorts;
1754 qApp->processEvents();
1756 DbgLv(2) <<
"(2) orphan: N size M size" << orphn.size() << orphm.size();
1761 for (
int ii = 0; ii < orphm.size(); ii++ )
1763 dsorts = orphm.at( ii );
1764 dlabel = dsorts.section(
":", 0, 0 );
1765 dindex = dsorts.section(
":", 1, 1 );
1766 ddGUID = dsorts.section(
":", 2, 2 ).simplified();
1767 dpGUID = dsorts.section(
":", 3, 3 ).simplified();
1768 jndx = dindex.toInt();
1769 cdesc = tdess[ jndx ];
1771 if ( dpGUID.length() < 16 || dpGUID == dmyGUID )
1778 kk = sortm.indexOf( dsorts );
1779 dsorts = dlabel +
":" + dindex +
":" + ddGUID +
":" + dpGUID;
1783 sortm.replace( kk, dsorts );
1785 tdess[ jndx ] =
cdesc;
1796 if ( guidse.indexOf( dpGUID ) >= 0 )
1799 if ( dpGUID == dmyGUID )
1815 QDateTime::currentDateTime().toUTC()
1816 .toString( Qt::ISODate ),
true );
1819 dlabel = dlabel.section(
".", 0, 0 );
1820 dindex = QString().sprintf(
"%4.4d", kndx++ );
1823 dsorts = dlabel +
":" + dindex +
":" + ddGUID +
":" + dpGUID;
1829 DbgLv(2) <<
"M orphan:" << orphm.at( ii ) << ii;
1830 DbgLv(2) <<
" E dummy:" << dsorts;
1832 qApp->processEvents();
1835 DbgLv(2) <<
"(3) orphan: N size M size" << orphn.size() << orphm.size();
1838 DbgLv(2) <<
"(4) orphan: M size E size" << orphm.size() << orphe.size();
1840 for (
int ii = 0; ii < orphe.size(); ii++ )
1842 dsorts = orphe.at( ii );
1843 dlabel = dsorts.section(
":", 0, 0 );
1844 dindex = dsorts.section(
":", 1, 1 );
1845 ddGUID = dsorts.section(
":", 2, 2 ).simplified();
1846 dpGUID = dsorts.section(
":", 3, 3 ).simplified();
1847 jndx = dindex.toInt();
1848 cdesc = tdess[ jndx ];
1850 if ( dpGUID.length() < 2 )
1857 kk = sorte.indexOf( dsorts );
1858 dsorts = dlabel +
":" + dindex +
":" + ddGUID +
":" + dpGUID;
1862 sorte.replace( kk, dsorts );
1864 tdess[ jndx ] =
cdesc;
1875 if ( guidsr.indexOf( dpGUID ) >= 0 )
1878 if ( dpGUID == dmyGUID )
1894 QDateTime::currentDateTime().toUTC()
1895 .toString( Qt::ISODate ),
true );
1898 dlabel = dlabel.section(
".", 0, 0 );
1899 dindex = QString().sprintf(
"%4.4d", kndx++ );
1902 dsorts = dlabel +
":" + dindex +
":" + ddGUID +
":" + dpGUID;
1907 DbgLv(2) <<
"E orphan:" << orphe.at( ii );
1908 DbgLv(2) <<
" R dummy:" << dsorts;
1910 qApp->processEvents();
1912 DbgLv(2) <<
"(5) orphan: M size E size" << orphm.size() << orphe.size();
1917 int countR = sortr.size();
1918 int countE = sorte.size();
1919 int countM = sortm.size();
1920 int countN = sortn.size();
1926 DbgLv(1) <<
"sort/dumy: count REMN" << countR << countE << countM << countN;
1937 lb_status->setText( tr(
"Building Sorted Trees..." ) );
1941 qApp->processEvents();
1944 for (
int ii = 0; ii < countR; ii++ )
1946 QString recr = sortr[ ii ];
1947 QString didr = recr.section(
":", 2, 2 );
1948 QString pidr = recr.section(
":", 3, 3 );
1949 indx = recr.section(
":", 1, 1 ).toInt();
1950 cdesc = tdess.at( indx );
1954 pstate = ( pstate &
REC_DB ) != 0 ? ( pstate |
PAR_DB ) : pstate;
1955 pstate = ( pstate &
REC_LO ) != 0 ? ( pstate |
PAR_LO ) : pstate;
1966 for (
int jj = 0; jj < countE; jj++ )
1968 QString rece = sorte[ jj ];
1969 QString pide = rece.section(
":", 3, 3 );
1974 QString dide = rece.section(
":", 2, 2 );
1975 indx = rece.section(
":", 1, 1 ).toInt();
1976 cdesc = tdess.at( indx );
1985 for (
int mm = 0; mm < countM; mm++ )
1987 QString recm = sortm[ mm ];
1988 QString pidm = recm.section(
":", 3, 3 );
1993 QString didm = recm.section(
":", 2, 2 );
1994 indx = recm.section(
":", 1, 1 ).toInt();
1995 cdesc = tdess.at( indx );
2005 for (
int nn = 0; nn < countN; nn++ )
2007 QString recn = sortn[ nn ];
2008 QString pidn = recn.section(
":", 3, 3 );
2013 indx = recn.section(
":", 1, 1 ).toInt();
2014 cdesc = tdess.at( indx );
2024 qApp->processEvents();
2028 if ( noutR != countR || noutE != countE ||
2029 noutM != countM || noutN != countN )
2031 DbgLv(1) <<
"sort_desc: count REMN"
2032 << countR << countE << countM << countN;
2033 DbgLv(1) <<
"sort_desc: nout REMN"
2034 << noutR << noutE << noutM << noutN;
2040 QVector< DataDesc >& descv )
2043 int nrecs = sorts.size();
2050 QVector< int > multis;
2051 const char* rtyps[] = {
"RawData",
"EditedData",
"Model",
"Noise" };
2057 int ii = sorts[ 0 ].section(
":", 1, 1 ).toInt();
2058 ityp = descv[ ii ].recType;
2059 rtyp = QString( rtyps[ ityp - 1 ] );
2061 if ( descv[ ii ].recordID >= 0 )
2062 rtyp =
"DB " + rtyp;
2064 rtyp =
"Local " + rtyp;
2065 DbgLv(2) <<
"RvwD: ii ityp rtyp nrecs" << ii << ityp << rtyp << nrecs;
2066 cGUID = sorts[ 0 ].section(
":", 2, 2 );
2069 for (
int ii = 1; ii < nrecs; ii++ )
2071 cGUID = sorts[ ii ].section(
":", 2, 2 );
2074 int jj = tGUIDs.indexOf( cGUID );
2079 if ( ! multis.contains( jj ) )
2090 DbgLv(1) <<
"RvwD: nmult" << nmult <<
"ii,jj" << ii << jj
2091 <<
"cGUID,pGUID" << cGUID << tGUIDs[jj];
2106 tr(
"There are %1 %2 records that have\n" ).arg( nmult ).arg( rtyp ) +
2107 tr(
"the same GUID as another.\n" ) +
2108 tr(
"You should correct the situation before proceeding.\n" ) +
2109 tr(
" Click \"Ok\" to see details, then abort.\n" ) +
2110 tr(
" Click \"Ignore\" to proceed to further review.\n" );
2111 msgBox.setWindowTitle( tr(
"Duplicate %1 Records" ).arg( rtyp ) );
2112 msgBox.setText( msg );
2113 msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::Ignore );
2114 msgBox.setDefaultButton( QMessageBox::Ok );
2116 if ( msgBox.exec() == QMessageBox::Ok )
2118 QString fileexts = tr(
"Text,Log files (*.txt *.log);;" )
2119 + tr(
"All files (*)" );
2125 tr(
"Review the details below on duplicate records.\n" ) +
2126 tr(
"Save or Print the contents of this message.\n" ) +
2127 tr(
"Decide which of the duplicates should be removed.\n" ) +
2128 tr(
"Close the main US_DataModel window after exiting here.\n" ) +
2129 tr(
"\nSummary of Duplicates:\n\n" );
2131 for (
int ii = 0; ii < nmult; ii++ )
2133 int jj = multis.at( ii );
2134 cGUID = sorts.at( jj ).section(
":", 2, 2 );
2135 label = sorts.at( jj ).section(
":", 0, 0 );
2137 if ( cGUID != pGUID )
2139 msg += tr(
"GUID: " ) + cGUID +
"\n";
2144 msg += tr(
" Label: " ) + label +
"\n";
2147 msg += tr(
"\nDetails of Duplicates:\n\n" );
2149 for (
int ii = 0; ii < nmult; ii++ )
2151 int jj = multis.at( ii );
2152 cGUID = sorts.at( jj ).section(
":", 2, 2 );
2153 pGUID = sorts.at( jj ).section(
":", 3, 3 );
2154 label = sorts.at( jj ).section(
":", 0, 0 );
2155 int kk = sorts.at( jj ).section(
":", 1, 1 ).toInt();
2156 cdesc = descv[ kk ];
2158 msg += tr(
"GUID: " ) + cGUID +
"\n" +
2159 tr(
" ParentGUID: " ) + pGUID +
"\n" +
2160 tr(
" Label: " ) + label +
"\n" +
2163 tr(
" File Directory: " ) +
2165 tr(
" File Name: " ) +
2167 tr(
" File Last Mod: " ) +
2169 tr(
" Last Mod Date: " ) +
2175 editd->setWindowTitle( tr(
"Data Set Duplicate GUID Details" ) );
2176 editd->move( QCursor::pos() + QPoint( 200, 200 ) );
2177 editd->resize( 600, 500 );
2180 editd->
e->setText( msg );
2190 DbgLv(2) <<
"review_descs abort flag:" << abort;
2199 QString sexp =
"XXX";
2205 else if ( ixs == 1 || ixs == 2 )
2206 sexp =
"*:" + ss +
":*";
2208 else if ( ixs == 3 )
2211 rexp = QRegExp( sexp, Qt::CaseSensitive, QRegExp::Wildcard );
2213 return sl.indexOf( rexp );
2224 subl = sl.filter( QRegExp(
"^" + ss +
":" ) );
2226 else if ( ixs == 1 || ixs == 2 )
2228 subl = sl.filter(
":" + ss +
":" );
2230 else if ( ixs == 3 )
2232 subl = sl.filter( QRegExp(
":" + ss +
"$" ) );
2239 QStringList& plist )
2244 for (
int ii = 0; ii < plist.size(); ii++ )
2246 tlist << plist.at( ii ).section(
":", 2, 2 );
2249 for (
int ii = 0; ii < rlist.size(); ii++ )
2251 QString pReco = rlist.at( ii );
2252 QString pGUID = pReco.section(
":", 3, 3 );
2255 if ( ! tlist.contains( pGUID ) )
2273 if ( ( pstate &
REC_DB ) != 0 )
2276 if ( ( pstate &
REC_LO ) != 0 )
2287 int lablen = label.length();
2289 label = label.leftJustified(
maxdlen,
' ' );
2291 QString ostr = label
2292 +
":" + QString().sprintf(
"%4.4d", indx )
2332 mtype =
"CUSTOMGRID";
2338 mtype = mtype +
"-RA";
2342 mtype = mtype +
"-FM";
2345 mtype = mtype +
"-GL";
2348 mtype = mtype +
"-SG";
2352 mtype = mtype +
"-MC";
2376 jj = modxml.indexOf(
" analysisType=" );
2377 imtype = ( jj < 1 ) ? 0 : modxml.mid( jj ).section( quo, 1, 1 ).toInt();
2380 nassoc = modxml.count(
"K_d=" );
2381 nassoc = ( nassoc == 0 ) ? modxml.count(
"k_assoc=" ) : nassoc;
2382 nassoc = ( nassoc == 0 ) ? modxml.count(
"k_eq=" ) : nassoc;
2385 jj = modxml.indexOf(
" globalType=" );
2386 gtype = ( jj < 1 ) ? 0 : modxml.mid( jj ).section( quo, 1, 1 ).toInt();
2389 jj = modxml.indexOf(
" MonteCarlo=\"1" );
2393 return model_type( imtype, nassoc, gtype, isMC );
2416 cdesc.subType =
"RA";
2417 cdesc.label =
"item_2_2";
2418 cdesc.description =
"demo1_veloc";
2419 cdesc.contents =
"AA 12 AA 12";
2422 cdesc.filename =
"demo1_veloc_edit.xml";
2429 cdesc.subType =
"2DSA";
2430 cdesc.label =
"item_3_2";
2431 cdesc.description =
"demo1_veloc.sa2d.model.11";
2433 cdesc.recordID = -1;
2434 cdesc.filename =
"demo1_veloc_model.xml";
2440 cdesc.subType =
"TI";
2441 cdesc.label =
"item_4_2";
2442 cdesc.description =
"demo1_veloc.ti_noise";
2443 cdesc.contents =
"BB 12 AA 13";
2446 cdesc.filename =
"demo1_veloc_noise.xml";
2453 cdesc.subType =
"RA";
2454 cdesc.label =
"item_5_2";
2455 cdesc.description =
"demo1_veloc";
2456 cdesc.contents =
"CC 15";
2457 cdesc.recordID = -1;
2458 cdesc.filename =
"";
2464 QString expGUID =
"00000000-0000-0000-0000-000000000000";
2465 QString expfnam = aucfile.section(
"/", -1, -1 )
2466 .section(
".", 0, 1 ) +
".xml";
2467 QString expfile = aucfile.section(
"/", 0, -2 ) +
"/" + expfnam;
2469 QFile file( expfile );
2471 if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
2473 QXmlStreamReader xml( &file );
2475 while( ! xml.atEnd() )
2479 if ( xml.isStartElement() && xml.name() ==
"experiment" )
2481 QXmlStreamAttributes a = xml.attributes();
2482 expGUID = a.value(
"guid" ).toString();
2499 for (
int row = 0; row <
adescs.size(); row++ )
2503 if (
chgrows.contains( row ) )
2518 contdb = contdb.section(
" ", 0, 0 ) +
" " +
2519 contdb.section(
" ", 1, 1 );
2529 lb_status->setText( tr(
"Database Review Complete" ) );