@@ -370,8 +370,9 @@ void Controller::importPluginXML(const QString& file_path) {
370370 types[" vscode" ] = " vscode_plugin" ;
371371 types[" chrome" ] = " chrome_plugin" ;
372372 ide_plugin_type = plugin_file.getElementAttribute (" plugin_type" ).toLower ();
373+ QString file_type = types.find (ide_plugin_type) == types.end () ? " unsupported_plugin" : types.at (ide_plugin_type);
373374 // Insert file
374- idb.insertFile (QCryptographicHash::hash (plugin_file.getFilePath ().toUtf8 ().constData (),QCryptographicHash::Sha1).toHex (),session_id,plugin_file.getFilePath (),types. at (ide_plugin_type) );
375+ idb.insertFile (QCryptographicHash::hash (plugin_file.getFilePath ().toUtf8 ().constData (),QCryptographicHash::Sha1).toHex (),session_id,plugin_file.getFilePath (),file_type );
375376 }
376377 else if (element == " response" ) {
377378 // Insert ide_context
@@ -719,16 +720,16 @@ QString Controller::generateQuery(QString targets, QString token_types, QString
719720 // Add in Targets
720721 if (targets != " " ) {
721722 QStringList target_list = targets.split (' ,' );
722- query += QString (" fixation_target = \" %1\" " ).arg (target_list[0 ]);
723+ query += QString (" ( fixation_target = \" %1\" " ).arg (target_list[0 ]);
723724 for (auto i = target_list.begin ()+1 ; i != target_list.end (); ++i) {
724725 query += QString (" OR fixation_target = \" %1\" " ).arg (*i);
725726 }
726- query += " AND " ;
727+ query += " ) AND " ;
727728 }
728729 // Add in Tokens
729730 if (token_types != " " ) {
730731 QStringList token_list = token_types.split (' ,' );
731- query += QString (" (fixation_target = \" %1\" " ).arg (token_list[0 ]);
732+ query += QString (" (token = \" %1\" " ).arg (token_list[0 ]);
732733 for (auto i = token_list.begin ()+1 ; i != token_list.end (); ++i) {
733734 query += QString (" OR token = \" %1\" " ).arg (*i);
734735 }
@@ -775,7 +776,8 @@ void Controller::saveQueryFile(QString query, QString file_path) {
775776
776777void Controller::generateQueriedData (QString query, QString output_type, QString output_url) {
777778 QVector<QVector<QString>> data = idb.runFilterQuery (query);
778- QString safeQuery = query.replace (" \" " , " \\\" " );
779+ QString safeQuery = query;// .replace("\"", "\\\"");
780+ // QString safeQuery = "'" + query.mid(1,query.length()-2) + "'";
779781 QString savename = output_url+" /fixation_query_" +QString::number (std::time (nullptr ))+output_type;
780782 changeFilePathOS (savename);
781783 std::cout << savename << std::endl;
@@ -786,7 +788,7 @@ void Controller::generateQueriedData(QString query, QString output_type, QString
786788 output.open ();
787789 output.exec (" CREATE TABLE IF NOT EXISTS fixation(fixation_id TEXT PRIMARY KEY,fixation_run_id INTEGER,fixation_start_event_time INTEGER,fixation_order_number INTEGER,x INTEGER,y INTEGER,fixation_target TEXT,source_file_line INTEGER, source_file_col INTEGER,token TEXT,syntactic_category TEXT,xpath TEXT,left_pupil_diameter REAL,right_pupil_diameter REAL,duration INTEGER, query TEXT)" );
788790 for (auto i : data) {
789- output.exec (QString (" INSERT INTO fixation(fixation_id,fixation_run_id,fixation_start_event_time,fixation_order_number,x,y,fixation_target,source_file_line,source_file_col,token,syntactic_category,xpath,left_pupil_diameter,right_pupil_diameter,duration,query) VALUES(\" %1\" ,%2,%3,%4,%5,%6,\" %7\" ,%8,%9,%10,%11,%12,%13,%14,%15,\" %16\" )" ).arg (i[0 ]).arg (i[1 ]).arg (i[2 ]).arg (i[3 ]).arg (i[4 ]).arg (i[5 ]).arg (i[6 ]).arg (i[7 ]).arg (i[8 ]).arg (i[9 ] == " null" ? " null" : " \" " +i[9 ]+" \" " ).arg (i[10 ] == " null" ? " null" : " \" " +i[10 ]+" \" " ).arg (i[11 ] == " null" ? " null" : " \" " +i[11 ]+" \" " ).arg (i[12 ]).arg (i[13 ]).arg (i[14 ]).arg (safeQuery). replace ( " \"\" " , " \" " ));
791+ output.exec (QString (" INSERT INTO fixation(fixation_id,fixation_run_id,fixation_start_event_time,fixation_order_number,x,y,fixation_target,source_file_line,source_file_col,token,syntactic_category,xpath,left_pupil_diameter,right_pupil_diameter,duration,query) VALUES(\" %1\" ,%2,%3,%4,%5,%6,\" %7\" ,%8,%9,%10,%11,%12,%13,%14,%15,' %16' )" ).arg (i[0 ]).arg (i[1 ]).arg (i[2 ]).arg (i[3 ]).arg (i[4 ]).arg (i[5 ]).arg (i[6 ]).arg (i[7 ]).arg (i[8 ]).arg (i[9 ] == " null" ? " null" : " \" " +i[9 ]+" \" " ).arg (i[10 ] == " null" ? " null" : " \" " +i[10 ]+" \" " ).arg (i[11 ] == " null" ? " null" : " \" " +i[11 ]+" \" " ).arg (i[12 ]).arg (i[13 ]).arg (i[14 ]).arg (safeQuery));
790792 }
791793 output.close ();
792794 QSqlDatabase::removeDatabase (" output" );
@@ -801,6 +803,7 @@ void Controller::generateQueriedData(QString query, QString output_type, QString
801803 // ///// XML
802804 else if (output_type == " .xml" ) {
803805 std::ofstream output (savename.toUtf8 ().constData ());
806+ safeQuery = safeQuery.replace (" \" " ," "" );
804807 output << " <?xml version=\" 1.0\" encoding=\" utf-8\" ?>\n <itrace_fixation_query query=\" " << safeQuery << " \" >\n " ;
805808 for (auto fix : data) {
806809 output << " \t " << (QString (" <fixation fixation_id=\" %1\" fixation_run_id=\" %2\" fixation_start_event_time=\" %3\" fixation_order_number=\" %4\" x=\" %5\" y=\" %6\" fixation_target=\" %7\" source_file_line=\" %8\" source_file_col=\" %9\" token=\" %10\" syntactic_category=\" %11\" xpath=\" %12\" left_pupil_diameter=\" %13\" right_pupil_diameter=\" %14\" duration=\" %15\" />" ).arg (fix[0 ]).arg (fix[1 ]).arg (fix[2 ]).arg (fix[3 ]).arg (fix[4 ]).arg (fix[5 ]).arg (fix[6 ]).arg (fix[7 ]).arg (fix[8 ]).arg (fix[9 ]).arg (fix[10 ]).arg (fix[11 ]).arg (fix[12 ]).arg (fix[13 ]).arg (fix[14 ])).toUtf8 ().constData () << " \n " ;
@@ -811,6 +814,7 @@ void Controller::generateQueriedData(QString query, QString output_type, QString
811814 // ///// JSON
812815 else if (output_type == " .json" ) {
813816 std::ofstream output (savename.toUtf8 ().constData ());
817+ safeQuery = safeQuery.replace (" \" " ," \\\" " );
814818 output << " {\n\t\" query\" : \" " << safeQuery << " \" ,\n " ;
815819 output << " \t\" fixations\" : [\n " ;
816820 for (auto fix : data) {
0 commit comments