15 if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
17 QXmlStreamReader xml( &file );
19 while ( ! xml.atEnd() )
23 if ( xml.isStartElement() )
25 QXmlStreamAttributes atts = xml.attributes();
26 QString name = atts.value(
"name" ).toString();
27 QString label = atts.value(
"label" ).toString();
29 if ( xml.name() ==
"application" )
34 else if ( xml.name() ==
"report" )
39 else if ( xml.name() ==
"extension" )
42 extMTypes[ name ] = atts.value(
"mimetype" ).toString();
52 qDebug() <<
"Application (analysis) mappings:";
53 foreach ( QString label, appLabels.keys() )
54 qDebug() << label <<
": " << appLabels.value( label );
58 qDebug() <<
"Report (subAnalysis) mappings:";
59 foreach ( QString label, rptLabels.keys() )
60 qDebug() << label <<
": " << rptLabels.value( label );
64 qDebug() <<
"Extension (documentType) mappings:";
65 foreach ( QString label, extLabels.keys() )
66 qDebug() << label <<
": " << extLabels.value( label );
70 qDebug() <<
"Extension (mime-type) mappings:";
71 foreach ( QString label, extMTypes.keys() )
72 qDebug() << label <<
": " << extMTypes.value( label );
85 int tripleID, QString dir,
US_DB2* db )
87 QRegExp rx(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" );
91 if ( ! rx.exactMatch( this->documentGUID ) )
93 DbgLv(1) <<
"Doc::saveDB - GUID" << this->documentGUID;
96 QStringList q(
"get_reportDocumentID" );
97 q << this->documentGUID;
104 DbgLv(1) <<
"Doc::saveDB - UPD ID(old)" << this->documentID;
106 QString docID = db->
value( 0 ).toString();
107 this->documentID = docID.toInt();
108 DbgLv(1) <<
"Doc::saveDB - UPD ID" << this->documentID;
110 QStringList q(
"update_reportDocument" );
112 << QString::number( this->editedDataID )
117 << this->documentType;
124 qDebug() <<
"update_reportDocument error"
132 DbgLv(1) <<
"Doc::saveDB - NEW ID" << this->documentID <<
"tripID" << tripleID;
133 DbgLv(1) <<
"Doc::saveDB - NEW editID" << this->editedDataID;
135 QStringList q(
"new_reportDocument" );
136 q << QString::number( tripleID )
137 << this->documentGUID
138 << QString::number( this->editedDataID )
143 << this->documentType;
150 qDebug() <<
"new_reportDocument error"
160 qDebug() <<
"get_reportDocumentID error"
166 QString fpath = ( dir.endsWith(
"/" ) ? dir : dir +
"/" ) + this->filename;
168 QString(
"upload_reportContents" ), this->documentID );
172 qDebug() <<
"upload_reportContents error"
184 QStringList q(
"get_reportDocument_info" );
185 q << QString::number( this->documentID );
192 qDebug() <<
"get_reportDocument_info NOT_FOUND error" << status;
198 qDebug() <<
"get_reportDocument_info error" << status;
202 int docID = this->documentID;
206 this->documentID = docID;
207 this->documentGUID = db->
value(0).toString();
208 this->editedDataID = db->
value(1).toInt();
209 this->label = db->
value(2).toString();
210 this->filename = db->
value(3).toString();
211 this->analysis = db->
value(4).toString();
212 this->subAnalysis = db->
value(5).toString();
213 this->documentType = db->
value(6).toString();
216 QString fpath = ( dir.endsWith(
"/" ) ? dir : dir +
"/" ) + this->filename;
218 QString(
"download_reportContents" ), this->documentID );
222 qDebug() <<
"download_reportContents error"
247 qDebug() <<
" documentID = " << documentID ;
248 qDebug() <<
" documentGUID = " << documentGUID ;
249 qDebug() <<
" editedDataID = " << editedDataID ;
250 qDebug() <<
" label = " << label ;
251 qDebug() <<
" filename = " << filename ;
252 qDebug() <<
" analysis = " << analysis ;
253 qDebug() <<
" subAnalysis = " << subAnalysis ;
254 qDebug() <<
" documentType = " << documentType ;
268 QRegExp rx(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" );
272 if ( ! rx.exactMatch( this->tripleGUID ) )
276 QStringList q(
"get_reportTripleID" );
277 q << this->tripleGUID;
285 QStringList q(
"update_reportTriple" );
286 q << QString::number( this->tripleID )
287 << QString::number( -1 )
289 << this->dataDescription;
296 qDebug() <<
"update_reportTriple error"
305 QStringList q(
"new_reportTriple" );
306 q << this->tripleGUID
307 << QString::number( reportID )
308 << QString::number( -1 )
310 << this->dataDescription;
317 qDebug() <<
"new_reportTriple error"
327 qDebug() <<
"get_reportTripleID error"
339 QStringList q(
"get_reportDocument_desc" );
340 q << QString::number( tripleID );
377 QString documentType,
389 return this->addDocument( d, dir, db );
399 DbgLv(1) <<
"Trip::addDoc - ndx" << ndx <<
"ana,subA,Type"
406 DbgLv(1) <<
"Trip::addDoc - remove Doc";
407 this->removeDocument( ndx, db );
413 ndx = this->findDocument( d.analysis, d.subAnalysis, d.documentType );
414 DbgLv(1) <<
"Trip::addDoc - ndx aft list add" << ndx;
416 return this->docs[ndx].saveDB( this->tripleID, dir, db );
423 QStringList q(
"delete_reportDocument" );
424 q << QString::number( this->docs[ndx].documentID );
432 this->docs.remove( ndx );
439 QString searchAnal, QString searchSubanal, QString searchType )
441 for (
int i = 0; i < this->docs.size(); i++ )
443 if ( ( this->docs[i].analysis == searchAnal ) &&
444 ( this->docs[i].subAnalysis == searchSubanal ) &&
445 ( this->docs[i].documentType == searchType ) )
461 dataDescription =
"";
470 qDebug() <<
" tripleID = " << tripleID ;
471 qDebug() <<
" tripleGUID = " << tripleGUID ;
472 qDebug() <<
" resultID = " << resultID ;
473 qDebug() <<
" triple = " << triple ;
474 qDebug() <<
" dataDescription = " << dataDescription ;
477 if ( docs.size() > 0 )
479 qDebug() <<
" Documents:";
495 QStringList q(
"get_report_info_by_runID" );
511 this->
ID = db->
value(0).toInt();
517 bool edittr = ! new_triple.isEmpty();
522 q <<
"get_reportTriple_desc"
523 << QString::number(
ID );
539 if ( edittr && t.
triple != new_triple )
550 for (
int i = 0; i <
triples.size(); i++ )
563 QRegExp rx(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" );
565 QString now = QDateTime::currentDateTime().toString();
568 if ( ! rx.exactMatch( this->GUID ) )
573 QStringList q(
"get_reportID_by_runID" );
579 ? this->runID +
" Report"
588 this->
ID = db->
value( 0 ).toInt();
589 this->
html =
"<p>Report updated " + now +
"</p>";
593 << QString::number( this->
ID )
602 qDebug() <<
"update_report error"
611 this->
html =
"<p>Report created " + now +
"</p>";
626 qDebug() <<
"new_report error"
636 qDebug() <<
"get_reportID error"
643 q <<
"get_report_info"
644 << QString::number( this->
ID );
656 QString dataDescription,
683 return this->
triples[ndx].saveDB( this->
ID, db );
691 QStringList q(
"delete_reportTriple" );
692 q << QString::number( this->
triples[ ndx ].tripleID );
708 for (
int i = 0; i < this->
triples.size(); i++ )
710 if ( this->
triples[i].triple == searchTriple )
723 const QString& filename,
US_DB2* db,
int idEdit,
724 const QString dataDescription )
727 QStringList parts = dir.split(
"/" );
728 if ( parts.size() < 2 )
731 QString new_runID = parts.last();
732 if ( new_runID.isEmpty() )
733 new_runID = parts[ parts.size() - 2 ];
737 parts = filename.split(
'.' );
738 if ( parts.size() != 4 )
741 QString newAnal = parts[0];
743 QString newSubanal = parts[2];
744 QString newDoctype = parts[3];
752 QString now = QDateTime::currentDateTime().toString();
760 qDebug() <<
"report.saveDB error"
772 status = this->
addTriple( newTriple, dataDescription, db );
775 qDebug() <<
"saveDocumentFromFile.addTriple error"
783 else if ( this->
triples[tripNdx].dataDescription != dataDescription )
786 this->
triples[tripNdx].dataDescription = dataDescription;
787 this->
triples[tripNdx].saveDB( this->
ID, db );
795 int docNdx = t.
findDocument( newAnal, newSubanal, newDoctype );
798 DbgLv(1) <<
"Doc::saveDB: NOT FOUND newDoctype" << newDoctype;
799 if ( docNdx < 0 && newDoctype.endsWith(
"svgz" ) )
801 docNdx = t.
findDocument( newAnal, newSubanal, QString(
"svg" ) );
802 DbgLv(1) <<
"Doc::saveDB: NOT FOUND svg docNdx" << docNdx;
820 DbgLv(1) <<
"Doc::saveDB: Replace ndx label" << docNdx << newLabel;
821 t.
docs[ docNdx ].editedDataID = idEdit;
822 t.
docs[ docNdx ].label = newLabel;
823 t.
docs[ docNdx ].filename = filename;
824 t.
docs[ docNdx ].documentType = newDoctype;
826 status = t.
docs[ docNdx ].saveDB( t.
tripleID, dir, db );
829 qDebug() <<
"saveDocumentFromFile.docs.saveDB error"
838 docNdx = t.
findDocument( newAnal, newSubanal, newDoctype );
853 const QStringList& filepaths,
US_DB2* db,
int idEdit,
854 const QString dataDescription )
857 QString new_runID = QString( dir ).section(
"/", -1, -1 );
858 if ( new_runID.isEmpty() )
862 int nfiles = filepaths.count();
867 QStringList filenames;
868 for (
int jj = 0; jj < nfiles; jj++ )
869 filenames << QString( filepaths[ jj ] ).section(
"/", -1, -1 );
871 QString filename = filenames[ 0 ];
872 QString newTriple = filename.section(
'.', -3, -3 );
877 QString now = QDateTime::currentDateTime().toString();
885 qDebug() <<
"report.saveDB error"
897 status = this->
addTriple( newTriple, dataDescription, db );
900 qDebug() <<
"saveDocumentFromFile.addTriple error"
909 else if ( this->
triples[ tripNdx ].dataDescription != dataDescription )
911 this->
triples[ tripNdx ].dataDescription = dataDescription;
912 this->
triples[ tripNdx ].saveDB( this->
ID, db );
921 QString dirfile = dir.endsWith(
"/" ) ? dir : ( dir +
"/" );
922 int ntdocs = trip->
docs.count();
925 for (
int ii = 0; ii < ntdocs; ii++ )
927 filename = trip->
docs[ ii ].filename;
928 int tidEdit = trip->
docs[ ii ].editedDataID;
930 if ( tidEdit == idEdit && filenames.contains( filename ) )
938 if ( tdNdxs.count() < nfiles )
940 for (
int ii = 0; ii < nfiles; ii++ )
942 filename = filenames[ ii ];
944 if ( !tdnames.contains( filename ) )
947 QString newAnal = filename.section(
".", -4, -4 );
948 QString newSubanal = filename.section(
".", -2, -2 );
949 QString newDoctype = filename.section(
".", -1, -1 );
956 rdoc.
label = newLabel;
963 QStringList qry(
"new_reportDocument" );
964 qry << QString::number( idTrip )
966 << QString::number( idEdit )
977 qDebug() <<
"new_reportDocument error"
994 for (
int ii = 0; ii < nfiles; ii++ )
996 filepath = filepaths[ ii ];
997 filename = filenames[ ii ];
998 int tdnamx = tdnames.indexOf( filename );
1002 qDebug() <<
"upload_reportContents TDNAMX error"
1007 int tdndx = tdNdxs[ tdnamx ];
1008 int idDoc = trip->
docs[ tdndx ].documentID;
1011 QString(
"upload_reportContents" ), idDoc );
1015 qDebug() <<
"upload_reportContents error"
1029 QStringList q(
"delete_report" );
1030 q << QString::number( reportID );
1048 qDebug() <<
"report.saveDB error"
1054 status = triple.
saveDB( this->
ID, db );
1057 qDebug() <<
"triple.saveDB error"
1066 qDebug() <<
"document.saveDB error"
1092 qDebug() <<
"ID = " <<
ID ;
1093 qDebug() <<
"GUID = " <<
GUID ;
1095 qDebug() <<
"runID = " <<
runID ;
1096 qDebug() <<
"title = " <<
title ;
1097 qDebug() <<
"html = " <<
html ;
1102 qDebug() <<
"Triples:";