Skip to content

Commit

Permalink
GMP 6. REPORT, us_reporter_gmp -- test case, temporary, will be rever…
Browse files Browse the repository at this point in the history
…ted...
  • Loading branch information
alexsav815 committed Jan 22, 2024
1 parent bfbc1d9 commit 8e0efe0
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 14 deletions.
157 changes: 145 additions & 12 deletions programs/us_reporter_gmp/us_reporter_gmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,137 @@

#define MIN_NTC 25

// Test case(s): Constructor
US_ReporterGMP::US_ReporterGMP( QMap< QString, QString> t_c ) : US_Widgets()
{
QString report_filepath = "/home/alexey/ultrascan/reports/eGFP-DNA-MW-08OCT23-run1981_GMP_DB.tar";
QString html_filePath = "/home/alexey/ultrascan/reports/eGFP-DNA-MW-08OCT23-run1981/html_string.html";
int autolfowGMPReportID = 25;
QString autoStatusID = QString::number(231);
QString autoID = QString::number(1002);

write_gmp_report_DB_test(report_filepath, html_filePath, autolfowGMPReportID,
autoStatusID, autoID);
}

//write GMP report to DB Test
void US_ReporterGMP::write_gmp_report_DB_test( QString report_filepath, QString html_filePath,
int autolfowGMPReportID, QString autoStatusID, QString autoID )
{
qDebug() << "[TEST] Writing .TAR Blob of filePath -- " << report_filepath;

bool clear_GMP_report_record = false;

US_Passwd pw;
US_DB2 db( pw.getPasswd() );

if ( db.lastErrno() != US_DB2::OK )
{
QMessageBox::warning( this, tr( "Connection Problem" ),
tr( "Could not connect to database \n" ) + db.lastError() );
return;
}

//// .Tar Blob
int writeStatus= db.writeBlobToDB(report_filepath,
QString( "upload_gmpReportData" ),
autolfowGMPReportID );

if ( writeStatus == US_DB2::DBERROR )
{
QMessageBox::warning(this, "Error", "Error processing file:\n"
+ report_filepath + "\n" + db.lastError() +
"\n" + "Could not open file or no data \n");
clear_GMP_report_record = true;
}

else if ( writeStatus != US_DB2::OK )
{
QMessageBox::warning(this, "Error", "returned processing file:\n" +
report_filepath + "\n" + db.lastError() + "\n");

clear_GMP_report_record = true;
}

/*************************************************************************/
//Write HTML strign to file & later save to DB withing general archive
qDebug() << "[TEST] Writing HTML Blob of filePath -- " << html_filePath;

int writeStatus_html = db.writeBlobToDB( html_filePath,
QString( "upload_gmpReportData_html" ),
autolfowGMPReportID );

if ( writeStatus_html == US_DB2::DBERROR )
{
QMessageBox::warning(this, "Error", "Error processing html file:\n"
+ html_filePath + "\n" + db.lastError() +
"\n" + "Could not open file or no data \n");
clear_GMP_report_record = true;
}

else if ( writeStatus_html != US_DB2::OK )
{
QMessageBox::warning(this, "Error", "returned processing html file:\n" +
html_filePath + "\n" + db.lastError() + "\n");

clear_GMP_report_record = true;
}

/*************************************************************************/

QStringList qry;
if ( clear_GMP_report_record )
{
qDebug() << "Something went wrong!!";
// qry.clear();
// qry << "clear_autoflowGMPReportRecord" << QString::number( autolfowGMPReportID );
// db.query( qry );

//Maybe revert 'reporting' stage in the autoflowStages??
}
else
{
//Report generated && .PDF GMP report saved to autoflowGMPReport:
//No, we can write information on who/when generated report: ///////////////////////

//get user info
qry.clear();
qry << QString( "get_user_info" );
db.query( qry );
db.next();

int ID = db.value( 0 ).toInt();
QString fname = db.value( 1 ).toString();
QString lname = db.value( 2 ).toString();
QString email = db.value( 4 ).toString();
int level = db.value( 5 ).toInt();

QString reporting_Json;

reporting_Json. clear();
reporting_Json += "{ \"Person\": ";

reporting_Json += "[{";
reporting_Json += "\"ID\":\"" + QString::number( ID ) + "\",";
reporting_Json += "\"fname\":\"" + fname + "\",";
reporting_Json += "\"lname\":\"" + lname + "\",";
reporting_Json += "\"email\":\"" + email + "\",";
reporting_Json += "\"level\":\"" + QString::number( level ) + "\"";
reporting_Json += "}]}";

qry.clear();
qry << "update_autoflowStatusReport_record"
<< autoStatusID
<< autoID
<< reporting_Json;

db.query( qry );
}
}

// END Test Case /////////////////////////////////////////////////////////////////////////////////


// Constructor
US_ReporterGMP::US_ReporterGMP() : US_Widgets()
{
Expand Down Expand Up @@ -3273,18 +3404,7 @@ void US_ReporterGMP::generate_report( void )
************************************************************/

//Update autoflow status to 'E-SIGNATURES':
US_Passwd pw;
US_DB2* db = new US_DB2( pw.getPasswd() );

if ( db->lastErrno() != US_DB2::OK )
{
QApplication::restoreOverrideCursor();
QMessageBox::information( this,
tr( "DB Connection Problem" ),
tr( "AutoflowHistory: there was an error connecting to the database:\n" )
+ db->lastError() );
return;
}


//Compose "{to_sign:["","",...]}" out of operatorListJson, reviewersListJson, approversListJson
//&& update 'eSignStatusJson' of the autoflowGMPReportEsign record with it
Expand Down Expand Up @@ -3313,6 +3433,19 @@ void US_ReporterGMP::generate_report( void )

qDebug() << "operRevToSignJsonObject -- " << eSignStatusJson;


US_Passwd pw;
US_DB2* db = new US_DB2( pw.getPasswd() );

if ( db->lastErrno() != US_DB2::OK )
{
QApplication::restoreOverrideCursor();
QMessageBox::information( this,
tr( "DB Connection Problem" ),
tr( "AutoflowHistory: there was an error connecting to the database:\n" )
+ db->lastError() );
return;
}
QStringList qry;

//Update autoflow record with 'E-SIGNATURES'
Expand Down
3 changes: 3 additions & 0 deletions programs/us_reporter_gmp/us_reporter_gmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class US_ReporterGMP : public US_Widgets
public:
US_ReporterGMP();
US_ReporterGMP( QString );
US_ReporterGMP( QMap<QString, QString> );
void write_gmp_report_DB_test( QString, QString,
int, QString, QString );

// QMap < QString, QString > read_autoflow_record_pub( int );
// int list_all_autoflow_records_pub( QList< QStringList >& );
Expand Down
4 changes: 3 additions & 1 deletion programs/us_reporter_gmp/us_reporter_gmp_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ int main( int argc, char* argv[] )

// License is OK. Start up.

US_ReporterGMP * w = new US_ReporterGMP;
QMap<QString,QString> t_c;
US_ReporterGMP * w = new US_ReporterGMP( t_c );
//US_ReporterGMP * w = new US_ReporterGMP;
//US_ReporterGMP * w = new US_ReporterGMP( "AUTO" );
w->show(); //!< \memberof QWidget
return application.exec(); //!< \memberof QApplication
Expand Down
2 changes: 1 addition & 1 deletion utils/us_db2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ int US_DB2::writeBlobToDB( const QString& filename,

if ( mysql_query( db, sqlQuery.data() ) != 0 )
{
error = QString( "MySQL error: " ) + mysql_error( db );
error = QString( "MySQL error: " ) + mysql_error( db ); // ALEXEY: writing huge blob, MySql server has gone away...

db_errno = DBERROR;
return DBERROR;
Expand Down

0 comments on commit 8e0efe0

Please sign in to comment.