@Override
  @TransactionalRollbackAllExceptions
  public String create(Event event, EventPreCreateContext context) throws ZepException {
    if (!ZepConstants.CLOSED_STATUSES.contains(event.getStatus())) {
      throw new ZepException("Invalid status for event in event archive: " + event.getStatus());
    }

    TypeConverter<Long> timestampConverter = databaseCompatibility.getTimestampConverter();
    Map<String, Object> occurrenceFields = eventDaoHelper.createOccurrenceFields(event);
    Map<String, Object> fields = new HashMap<String, Object>(occurrenceFields);
    final long created = event.getCreatedTime();
    final long firstSeen = (event.hasFirstSeenTime()) ? event.getFirstSeenTime() : created;
    long updateTime = System.currentTimeMillis();
    final String uuid = this.uuidGenerator.generate().toString();
    fields.put(COLUMN_UUID, uuidConverter.toDatabaseType(uuid));
    fields.put(COLUMN_STATUS_ID, event.getStatus().getNumber());
    fields.put(COLUMN_FIRST_SEEN, timestampConverter.toDatabaseType(firstSeen));
    fields.put(COLUMN_STATUS_CHANGE, timestampConverter.toDatabaseType(created));
    fields.put(COLUMN_LAST_SEEN, timestampConverter.toDatabaseType(created));
    fields.put(COLUMN_EVENT_COUNT, event.getCount());
    fields.put(COLUMN_UPDATE_TIME, timestampConverter.toDatabaseType(updateTime));

    this.template.update(DaoUtils.createNamedInsert(TABLE_EVENT_ARCHIVE, fields.keySet()), fields);
    return uuid;
  }
  @Override
  @TransactionalRollbackAllExceptions
  public void importEvent(EventSummary eventSummary) throws ZepException {
    if (!ZepConstants.CLOSED_STATUSES.contains(eventSummary.getStatus())) {
      throw new ZepException(
          "Invalid status for event in event archive: " + eventSummary.getStatus());
    }

    final long updateTime = System.currentTimeMillis();
    final EventSummary.Builder summaryBuilder = EventSummary.newBuilder(eventSummary);
    final Event.Builder eventBuilder = summaryBuilder.getOccurrenceBuilder(0);
    summaryBuilder.setUpdateTime(updateTime);
    EventDaoHelper.addMigrateUpdateTimeDetail(eventBuilder, updateTime);

    final EventSummary summary = summaryBuilder.build();
    final Map<String, Object> fields = this.eventDaoHelper.createImportedSummaryFields(summary);
    this.template.update(DaoUtils.createNamedInsert(TABLE_EVENT_ARCHIVE, fields.keySet()), fields);
  }