/* (non-Javadoc)
   * @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
   */
  @Override
  public Event mapRow(ResultSet rs, int rowNum) throws SQLException {
    Event event = new Event();
    event.setPersistedId(rs.getLong("ID"));
    event.setTimestamp(rs.getTimestamp("EI_TIMESTAMP"));
    event.setEventType(EventTypeEnum.valueOf(rs.getString("EI_EVENT_TYPE")));

    Originator originator = new Originator();
    originator.setProcessId(rs.getString("ORIG_PROCESS_ID"));
    originator.setIp(rs.getString("ORIG_IP"));
    originator.setHostname(rs.getString("ORIG_HOSTNAME"));
    originator.setCustomId(rs.getString("ORIG_CUSTOM_ID"));
    originator.setPrincipal(rs.getString("ORIG_PRINCIPAL"));
    event.setOriginator(originator);

    MessageInfo messageInfo = new MessageInfo();
    messageInfo.setMessageId(rs.getString("MI_MESSAGE_ID"));
    messageInfo.setFlowId(rs.getString("MI_FLOW_ID"));
    messageInfo.setPortType(rs.getString("MI_PORT_TYPE"));
    messageInfo.setOperationName(rs.getString("MI_OPERATION_NAME"));
    messageInfo.setTransportType(rs.getString("MI_TRANSPORT_TYPE"));
    event.setMessageInfo(messageInfo);
    event.setContentCut(rs.getBoolean("CONTENT_CUT"));
    try {
      event.setContent(IOUtils.toString(rs.getClob("MESSAGE_CONTENT").getAsciiStream()));
    } catch (IOException e) {
      throw new RuntimeException("Error reading content", e);
    }
    return event;
  }