Пример #1
0
 // 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);
   }
 }
Пример #2
0
 public Object getHistoricalObject(History event) throws HibernateException {
   if (event.getAction().equals(History.DELETED)) {
     return null;
   }
   return DomainMetaDataRepository.getInstance()
       .getObject(event.getObjectType(), event.getTargetId());
 }
Пример #3
0
 public void saveEvent(
     Identifiable object, String action, String description, int personId, Date when) {
   try {
     Integer id = (Integer) PropertyUtils.getProperty(object, "id");
     saveEvent(
         object.getClass(),
         DomainMetaDataRepository.getInstance().getParentId(object),
         id.intValue(),
         action,
         description,
         personId,
         when);
   } catch (Exception e) {
     log.error("history error", e);
   }
 }