<commit_before>package org.literacybridge.dashboard.processors;

import org.literacybridge.dashboard.api.EventWriter;
import org.literacybridge.dashboard.api.SyncAggregationWriter;
import org.literacybridge.dashboard.api.SyncOperationLogWriter;
import org.literacybridge.dashboard.api.TalkingBookSyncWriter;
import org.literacybridge.dashboard.model.contentUsage.SyncAggregation;
import org.literacybridge.dashboard.model.syncOperations.SyncOperationLog;
import org.literacybridge.dashboard.model.syncOperations.TalkingBookCorruption;
import org.literacybridge.stats.model.TbDataLine;
import org.literacybridge.stats.model.events.PlayedEvent;
import org.literacybridge.stats.model.events.RecordEvent;
import org.literacybridge.stats.model.events.SurveyEvent;

import java.io.IOException;

/**
 * @author willpugh
 */
public class DbSyncWriter implements TalkingBookSyncWriter {

  protected final EventWriter            eventWriter;
  protected final SyncAggregationWriter  syncAggregationWriter;
  protected final SyncOperationLogWriter syncOperationLogWriter;

  public DbSyncWriter(EventWriter eventWriter, SyncAggregationWriter syncAggregationWriter,
                      SyncOperationLogWriter syncOperationLogWriter) {
    this.eventWriter = eventWriter;
    this.syncAggregationWriter = syncAggregationWriter;
    this.syncOperationLogWriter = syncOperationLogWriter;
  }

  @Override
  public void writePlayEvent(PlayedEvent playEvent) throws IOException {
    eventWriter.writePlayEvent(playEvent);
  }

  @Override
  public void writeRecordEvent(RecordEvent recordEvent) throws IOException {
    eventWriter.writeRecordEvent(recordEvent);<commit_msg>Catch and output Hibernate exception when writing a play event, which was a problem just one time (and could be reproduced) but then it went away.<commit_after>package org.literacybridge.dashboard.processors;

import org.literacybridge.dashboard.api.EventWriter;
import org.literacybridge.dashboard.api.SyncAggregationWriter;
import org.literacybridge.dashboard.api.SyncOperationLogWriter;
import org.literacybridge.dashboard.api.TalkingBookSyncWriter;
import org.literacybridge.dashboard.model.contentUsage.SyncAggregation;
import org.literacybridge.dashboard.model.syncOperations.SyncOperationLog;
import org.literacybridge.dashboard.model.syncOperations.TalkingBookCorruption;
import org.literacybridge.stats.model.TbDataLine;
import org.literacybridge.stats.model.events.PlayedEvent;
import org.literacybridge.stats.model.events.RecordEvent;
import org.literacybridge.stats.model.events.SurveyEvent;

import java.io.IOException;

/**
 * @author willpugh
 */
public class DbSyncWriter implements TalkingBookSyncWriter {

  protected final EventWriter            eventWriter;
  protected final SyncAggregationWriter  syncAggregationWriter;
  protected final SyncOperationLogWriter syncOperationLogWriter;

  public DbSyncWriter(EventWriter eventWriter, SyncAggregationWriter syncAggregationWriter,
                      SyncOperationLogWriter syncOperationLogWriter) {
    this.eventWriter = eventWriter;
    this.syncAggregationWriter = syncAggregationWriter;
    this.syncOperationLogWriter = syncOperationLogWriter;
  }

  @Override
  public void writePlayEvent(PlayedEvent playEvent) throws IOException {
    try {
      eventWriter.writePlayEvent(playEvent);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  @Override
  public void writeRecordEvent(RecordEvent recordEvent) throws IOException {
    eventWriter.writeRecordEvent(recordEvent);
{'fraction_non_alphanumeric': 0.06855524079320113, 'fraction_numerical': 0.0, 'mean_word_length': 5.829787234042553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3634967', 'n_tokens_mistral': 941, 'n_tokens_neox': 938, 'n_words': 177}