コード例 #1
0
/**
 * Loads a log chunk from the database.
 *
 */
function fetchLogChunk($jobId, $fileId, $startOffset, $endOffset)
{
    log::doLog($endOffset);
    //    include_once INIT::$MODEL_ROOT . "/LogEvent.class.php";
    $db = Database::obtain();
    $queryId = $db->query("SELECT * FROM log_event_header h WHERE h.job_id = '{$jobId}' AND h.file_id = '{$fileId}'" . " AND h.type != 'gaze'" . " ORDER BY h.time, h.id ASC LIMIT {$startOffset}, {$endOffset}");
    $err = $db->get_error();
    $errno = $err["error_code"];
    if ($errno != 0) {
        log::doLog("CASMACAT: fetchLogChunk(): " . print_r($err, true));
        throw new Exception("CASMACAT: fetchLogChunk(): " . print_r($err, true));
        //        return $errno * -1;
    }
    //    log::doLog("CASMACAT: fetchLogChunk(): Event headers found: '$db->affected_rows'");
    $logListChunk = array();
    $headerRow = null;
    while (($headerRow = $db->fetch($queryId)) != false) {
        $headerRowAsObject = snakeToCamel($headerRow);
        //        log::doLog("CASMACAT: fetchLogChunk(): Next headerRow: " . print_r($headerRowAsObject, true));
        $logEvent = new LogEvent($jobId, $fileId, $headerRowAsObject);
        //        log::doLog("CASMACAT: fetchLogChunk(): Processing header id: '$logEvent->id'");
        switch ($logEvent->type) {
            case LogEvent::START_SESSION:
                break;
            case LogEvent::STOP_SESSION:
                break;
            case LogEvent::RESIZE:
                $eventRow = fetchEventRow($logEvent->id, "resize_event");
                $logEvent->resizeData($eventRow);
                break;
            case LogEvent::TEXT:
                $eventRow = fetchEventRow($logEvent->id, "text_event");
                $logEvent->textData($eventRow);
                break;
            case LogEvent::SELECTION:
                $eventRow = fetchEventRow($logEvent->id, "selection_event");
                $logEvent->selectionData($eventRow);
                break;
            case LogEvent::SCROLL:
                $eventRow = fetchEventRow($logEvent->id, "scroll_event");
                $logEvent->scrollData($eventRow);
                break;
                //            case LogEvent::GAZE:
                //                $eventRow = fetchEventRow($logEvent->id, "gaze_event");
                //                $logEvent->gazeData($eventRow);
                //                break;
            //            case LogEvent::GAZE:
            //                $eventRow = fetchEventRow($logEvent->id, "gaze_event");
            //                $logEvent->gazeData($eventRow);
            //                break;
            case LogEvent::FIXATION:
                $eventRow = fetchEventRow($logEvent->id, "fixation_event");
                $logEvent->fixationData($eventRow);
                break;
            case LogEvent::DRAFTED:
            case LogEvent::TRANSLATED:
            case LogEvent::APPROVED:
            case LogEvent::REJECTED:
                break;
            case LogEvent::VIEWPORT_TO_SEGMENT:
                break;
            case LogEvent::SOURCE_COPIED:
                break;
            case LogEvent::SEGMENT_OPENED:
                break;
            case LogEvent::SEGMENT_CLOSED:
                break;
            case LogEvent::LOADING_SUGGESTIONS:
                break;
            case LogEvent::SUGGESTIONS_LOADED:
                $eventRow = fetchEventRow($logEvent->id, "suggestions_loaded_event");
                $logEvent->suggestionsLoadedData($eventRow);
                break;
            case LogEvent::SUGGESTION_CHOSEN:
                $eventRow = fetchEventRow($logEvent->id, "suggestion_chosen_event");
                $logEvent->suggestionChosenData($eventRow);
                break;
            case LogEvent::DELETING_SUGGESTION:
                $eventRow = fetchEventRow($logEvent->id, "deleting_suggestion_event");
                $logEvent->deletingSuggestionData($eventRow);
                break;
            case LogEvent::SUGGESTION_DELETED:
                break;
            case LogEvent::STATS_UPDATED:
                $eventRow = fetchEventRow($logEvent->id, "stats_event");
                $logEvent->statsUpdatedData($eventRow);
                break;
            case LogEvent::DECODE:
            case LogEvent::ALIGNMENTS:
            case LogEvent::SUFFIX_CHANGE:
            case LogEvent::CONFIDENCES:
            case LogEvent::TOKENS:
            case LogEvent::SHOW_ALIGNMENT_BY_KEY:
            case LogEvent::HIDE_ALIGNMENT_BY_KEY:
                $eventRow = fetchEventRow($logEvent->id, "itp_event");
                $logEvent->itpData($eventRow);
                break;
            case LogEvent::SHOW_ALIGNMENT_BY_MOUSE:
            case LogEvent::HIDE_ALIGNMENT_BY_MOUSE:
                break;
            case LogEvent::KEY_DOWN:
            case LogEvent::KEY_UP:
                $eventRow = fetchEventRow($logEvent->id, "key_event");
                $logEvent->keyData($eventRow);
                break;
            case LogEvent::MOUSE_DOWN:
            case LogEvent::MOUSE_UP:
            case LogEvent::MOUSE_CLICK:
            case LogEvent::MOUSE_MOVE:
                $eventRow = fetchEventRow($logEvent->id, "mouse_event");
                $logEvent->mouseData($eventRow);
                break;
            case LogEvent::BEFORE_CUT:
            case LogEvent::BEFORE_COPY:
            case LogEvent::BEFORE_PASTE:
                break;
            case LogEvent::VIS_MENU_DISPLAYED:
            case LogEvent::VIS_MENU_HIDDEN:
                break;
            case LogEvent::INITIAL_CONFIG:
            case LogEvent::CONFIG_CHANGED:
                $eventRow = fetchEventRow($logEvent->id, "config_event");
                $logEvent->configData($eventRow);
                break;
            case LogEvent::MOUSE_WHEEL_DOWN:
            case LogEvent::MOUSE_WHEEL_UP:
            case LogEvent::MOUSE_WHEEL_INVALIDATE:
                break;
            case LogEvent::MEMENTO_UNDO:
            case LogEvent::MEMENTO_REDO:
            case LogEvent::MEMENTO_INVALIDATE:
                break;
            case LogEvent::SR_MENU_DISPLAYED:
            case LogEvent::SR_MENU_HIDDEN:
            case LogEvent::SR_MATCH_CASE_ON:
            case LogEvent::SR_MATCH_CASE_OFF:
            case LogEvent::SR_REG_EXP_ON:
            case LogEvent::SR_REG_EXP_OFF:
            case LogEvent::SR_RULES_SETTING:
                break;
            case LogEvent::SR_RULES_SET:
                $eventRow = fetchEventRow($logEvent->id, "sr_event");
                $logEvent->srRulesSetData($eventRow);
                break;
            case LogEvent::SR_RULES_APPLIED:
            case LogEvent::SR_RULE_DELETED:
                break;
                // merc - adding floatPrediction, biconcordancer and translationOption
            // merc - adding floatPrediction, biconcordancer and translationOption
            case LogEvent::FLOAT_PREDICTION:
                break;
            case LogEvent::BICONCOR:
                $eventRow = fetchEventRow($logEvent->id, "biconcor_event");
                $logEvent->biconcorData($eventRow);
                break;
            case LogEvent::BICONCOR_CLOSED:
                break;
            case LogEvent::TRANSLATION_OPTION:
                break;
                // merc - adding epen
            // merc - adding epen
            case LogEvent::EPEN_OPENED:
                break;
            case LogEvent::EPEN_CLOSED:
                break;
            case LogEvent::HTR_RESULT:
                $eventRow = fetchEventRow($logEvent->id, "epen_event");
                $logEvent->epenData($eventRow);
                break;
            case LogEvent::HTR_UPDATE:
                $eventRow = fetchEventRow($logEvent->id, "epen_event");
                $logEvent->epenData($eventRow);
                break;
            case LogEvent::HTR_NBEST_CLICK:
                $eventRow = fetchEventRow($logEvent->id, "epen_event");
                $logEvent->epenData($eventRow);
                break;
            case LogEvent::HTR_TEXT_CHANGE:
                $eventRow = fetchEventRow($logEvent->id, "epen_event");
                $logEvent->epenData($eventRow);
                break;
            case LogEvent::HTR_START:
                $eventRow = fetchEventRow($logEvent->id, "epen_event");
                $logEvent->epenData($eventRow);
                break;
            case LogEvent::HTR_ADD_STROKE:
                $eventRow = fetchEventRow($logEvent->id, "epen_event");
                $logEvent->epenData($eventRow);
                break;
            case LogEvent::HTR_END:
                $eventRow = fetchEventRow($logEvent->id, "epen_event");
                $logEvent->epenData($eventRow);
                break;
            case LogEvent::HTR_GESTURE:
                $eventRow = fetchEventRow($logEvent->id, "epen_event");
                $logEvent->epenData($eventRow);
                break;
                // merc - blur/focus
            // merc - blur/focus
            case LogEvent::BLUR:
                break;
            case LogEvent::FOCUS:
                break;
            default:
                log::doLog("CASMACAT: fetchLogChunk(): Unknown log event type: '{$logEvent->type}', header id: '{$logEvent->id}'");
                throw new Exception("CASMACAT: fetchLogChunk(): Unknown log event type: '{$logEvent->type}', header id: '{$logEvent->id}'");
                //                return -1;
        }
        $logListChunk[] = $logEvent;
        //        log::doLog("CASMACAT: fetchLogChunk(): Loaded: '" . $logEvent->toString() . "'");
    }
    if (empty($logListChunk)) {
        return false;
    } else {
        return $logListChunk;
    }
}
コード例 #2
0
ファイル: exportLog.php プロジェクト: Tucev/casmacat-frontend
 //-------------------------------------------------------------------------------------------
 //stats_event
 $queryId = $db->query("SELECT h.id as id, h.job_id, h.file_id, h.element_id, h.x_path, h.time, h.type" . ", s.stats" . " FROM log_event_header h, stats_event s WHERE h.job_id = '{$jobId}' AND h.file_id = '{$fileId}' AND h.id = s.header_id ORDER BY h.time, h.id ASC");
 $err = $db->get_error();
 $errno = $err["error_code"];
 if ($errno != 0) {
     log::doLog("CASMACAT: fetchLogChunk(): " . print_r($err, true));
     throw new Exception("CASMACAT: fetchLogChunk(): " . print_r($err, true));
 }
 $statsRow = null;
 $statsEvents = array();
 while (($statsRow = $db->fetch($queryId)) != false) {
     $statsRowAsObject = snakeToCamel($statsRow);
     //log::doLog("CASMACAT: fetchLogChunk(): Next headerRow: " . print_r($statsRowAsObject, true));
     $statsEvent = new LogEvent($jobId, $fileId, $statsRowAsObject);
     $statsEvent->statsUpdatedData($statsRowAsObject);
     array_push($statsEvents, $statsEvent);
 }
 if (!empty($statsEvents)) {
     //log::doLog("CASMACAT: statsEvents: " . print_r($statsEvents, true));
     $count_statss = 0;
     $len_statss = count($statsEvents);
     //print "len_statss: ".$len_statss."\n";
 } else {
     $len_statss = 0;
 }
 //-------------------------------------------------------------------------------------------
 //suggestions_loaded_event
 $queryId = $db->query("SELECT h.id as id, h.job_id, h.file_id, h.element_id, h.x_path, h.time, h.type" . ", s.matches" . " FROM log_event_header h, suggestions_loaded_event s WHERE h.job_id = '{$jobId}' AND h.file_id = '{$fileId}' AND h.id = s.header_id ORDER BY h.time, h.id ASC");
 $err = $db->get_error();
 $errno = $err["error_code"];