// DEBT should be spring loaded (metadatarepository should be passed in and
 // we should not have private methods
 private void saveEvent(
     Class objectClass,
     int containerOid,
     int oid,
     String action,
     String description,
     int personId,
     Date when) {
   try {
     History History =
         new History(
             when,
             containerOid,
             oid,
             DomainMetaDataRepository.getInstance().classToTypeName(objectClass),
             action,
             description,
             personId);
     if (!isEventThrottled(getSession(), History)) {
       getSession().save(History);
     }
     if (action.equals(History.DELETED)) {
       // Set name in event descriptions for deleted objects
       List events = getEvents(oid);
       for (int i = 0; i < events.size(); i++) {
         History event = (History) events.get(i);
         if (StringUtils.isEmpty(event.getDescription())) {
           event.setDescription(description);
         }
       }
     }
   } catch (HibernateException e) {
     log.error("history error", e);
   }
 }
 public Object getHistoricalObject(History event) throws HibernateException {
   if (event.getAction().equals(History.DELETED)) {
     return null;
   }
   return DomainMetaDataRepository.getInstance()
       .getObject(event.getObjectType(), event.getTargetId());
 }
 private boolean isEventThrottled(Session session, History event) throws HibernateException {
   if (event.getAction().equals(History.UPDATED)) {
     History previousEvent =
         (History)
             session
                 .createQuery(
                     "from event in "
                         + History.class
                         + " where event.targetId = :oid and event.action = :action order by event.whenHappened desc")
                 .setInteger("oid", event.getTargetId())
                 .setString("action", History.UPDATED)
                 .setMaxResults(1)
                 .uniqueResult();
     return previousEvent != null
         && (event.getWhenHappened().getTime() - previousEvent.getWhenHappened().getTime())
             < FIFTEEN_MINUTES;
   } else {
     return false;
   }
 }