@Override public void interceptComplete(AnnotatedElement element, EventVO event) { Method method = (Method) element; ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); if (actionEvent != null) { UserContext ctx = UserContext.current(); long userId = ctx.getCallerUserId(); long accountId = ctx.getAccountId(); long startEventId = ctx.getStartEventId(); String eventDescription = actionEvent.eventDescription(); if (ctx.getEventDetails() != null) { eventDescription += ". " + ctx.getEventDetails(); } if (actionEvent.create()) { // This start event has to be used for subsequent events of this action startEventId = EventUtils.saveCreatedEvent( userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully created entity for " + eventDescription); ctx.setStartEventId(startEventId); } else { EventUtils.saveEvent( userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully completed " + eventDescription, startEventId); } } }
@Override public void interceptException(AnnotatedElement element, EventVO event) { Method method = (Method) element; ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); if (actionEvent != null) { UserContext ctx = UserContext.current(); long userId = ctx.getCallerUserId(); long accountId = ctx.getAccountId(); long startEventId = ctx.getStartEventId(); String eventDescription = actionEvent.eventDescription(); if (ctx.getEventDetails() != null) { eventDescription += ". " + ctx.getEventDetails(); } if (actionEvent.create()) { long eventId = EventUtils.saveCreatedEvent( userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while creating entity for " + eventDescription); ctx.setStartEventId(eventId); } else { EventUtils.saveEvent( userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while " + eventDescription, startEventId); } } }
@Override public EventVO interceptStart(AnnotatedElement element) { EventVO event = null; Method method = (Method) element; ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); if (actionEvent != null) { boolean async = actionEvent.async(); if (async) { UserContext ctx = UserContext.current(); long userId = ctx.getCallerUserId(); long accountId = ctx.getAccountId(); long startEventId = ctx.getStartEventId(); String eventDescription = actionEvent.eventDescription(); if (ctx.getEventDetails() != null) { eventDescription += ". " + ctx.getEventDetails(); } EventUtils.saveStartedEvent( userId, accountId, actionEvent.eventType(), eventDescription, startEventId); } } return event; }
/** {@inheritDoc} */ @Override public FocusAdapter onFocusLoss(final FocusEventRunnable runnable) { return EventUtils.onFocusLoss(this, runnable); }
/** {@inheritDoc} */ @Override public KeyAdapter onKeyRelease(final HotkeyData hotkey, final KeyEventRunnable runnable) { return EventUtils.onKeyRelease(this, hotkey, runnable); }
/** {@inheritDoc} */ @Override public KeyAdapter onKeyPress(final KeyEventRunnable runnable) { return EventUtils.onKeyPress(this, runnable); }
/** {@inheritDoc} */ @Override public MouseAdapter onMenuTrigger(final MouseEventRunnable runnable) { return EventUtils.onMenuTrigger(this, runnable); }
/** {@inheritDoc} */ @Override public MouseAdapter onDoubleClick(final MouseEventRunnable runnable) { return EventUtils.onDoubleClick(this, runnable); }
/** {@inheritDoc} */ @Override public MouseAdapter onMouseClick( final MouseButton mouseButton, final MouseEventRunnable runnable) { return EventUtils.onMouseClick(this, mouseButton, runnable); }
/** {@inheritDoc} */ @Override public MouseAdapter onMouseDrag(final MouseEventRunnable runnable) { return EventUtils.onMouseDrag(this, runnable); }
@After public void tearDown() { EventUtils.UnregisterAll(); }