Ejemplo n.º 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;
    }
}
Ejemplo n.º 2
0
 //-------------------------------------------------------------------------------
 //epen_event
 $queryId = $db->query("SELECT h.id as id, h.job_id as job_id, h.file_id as file_id, h.element_id as element_id, h.x_path as x_path, h.time as time, h.type as type, " . "e.info" . " FROM log_event_header h, epen_event e WHERE h.job_id = '{$jobId}' AND h.file_id = '{$fileId}' AND h.id = e.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));
 }
 $epenRow = null;
 $epenEvents = array();
 while (($epenRow = $db->fetch($queryId)) != false) {
     $epenRowAsObject = snakeToCamel($epenRow);
     //log::doLog("CASMACAT: fetchLogChunk(): Next headerRow: " . print_r($deleteRowAsObject, true));
     $epenEvent = new LogEvent($jobId, $fileId, $epenRowAsObject);
     $epenEvent->epenData($epenRowAsObject);
     array_push($epenEvents, $epenEvent);
 }
 if (!empty($epenEvents)) {
     //log::doLog("CASMACAT: deleteEvents: " . print_r($deleteEvents, true));
     $countEpen = 0;
     $lenEpen = count($epenEvents);
     //print $lenDeletes;
 } else {
     $lenEpen = 0;
 }
 //-------------------------------------------------------------------------------
 //fixation_event
 $queryId = $db->query("SELECT h.id as id, h.job_id as job_id, h.file_id as file_id, h.element_id as element_id, h.x_path as x_path, h.time as time, h.type as type, " . "f.t_time as t_time, f.x as x, f.y as y, f.duration as duration, f.character, f.offset as offset, f.above_char as aboveChar, f.below_char as belowChar, f.above_offset as aboveOffset, f.below_offset as belowOffset, f.gold_offset as goldOffset" . " FROM log_event_header h, fixation_event f WHERE h.job_id = '{$jobId}' AND h.file_id = '{$fileId}' AND h.id = f.header_id ORDER BY h.time, h.id ASC");
 //dan: added f.above_char, f.below_char, f.above_offset, f.below_offset, f.gold_offset
 $err = $db->get_error();