@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return PropertyUtils.getProperty(event.getSession(), "properties." + valueAsString); } });
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return PropertyUtils.getProperty(event.getSession(), "properties." + valueAsString); } });
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return event.getSession().getProperty(valueAsString); } });
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { return event.getSession().getProperty(valueAsString); } });
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); if (!mvelExpressions.containsKey(valueAsString)) { ParserConfiguration parserConfiguration = new ParserConfiguration(); parserConfiguration.setClassLoader(getClass().getClassLoader()); mvelExpressions.put(valueAsString, MVEL.compileExpression(valueAsString, new ParserContext(parserConfiguration))); } Map<String, Object> ctx = new HashMap<>(); ctx.put("event", event); ctx.put("session", event.getSession()); ctx.put("profile", event.getProfile()); return MVEL.executeExpression(mvelExpressions.get(valueAsString), ctx); } finally { Thread.currentThread().setContextClassLoader(tccl); } } });
@Override public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); if (!mvelExpressions.containsKey(valueAsString)) { ParserConfiguration parserConfiguration = new ParserConfiguration(); parserConfiguration.setClassLoader(getClass().getClassLoader()); mvelExpressions.put(valueAsString, MVEL.compileExpression(valueAsString, new ParserContext(parserConfiguration))); } Map<String, Object> ctx = new HashMap<>(); ctx.put("event", event); ctx.put("session", event.getSession()); ctx.put("profile", event.getProfile()); return MVEL.executeExpression(mvelExpressions.get(valueAsString), ctx); } finally { Thread.currentThread().setContextClassLoader(tccl); } } });
Session session = event.getSession(); if (weatherApiKey == null || weatherUrlBase == null || weatherUrlAttributes == null) { logger.warn("Configuration incomplete.");
public int execute(Action action, Event event) { boolean changed = false; HttpServletRequest httpServletRequest = (HttpServletRequest) event.getAttributes().get(Event.HTTP_REQUEST_ATTRIBUTE); if (httpServletRequest == null) { return EventService.NO_CHANGE; } String requestParameterName = (String) action.getParameterValues().get("requestParameterName"); String profilePropertyName = (String) action.getParameterValues().get("profilePropertyName"); String sessionPropertyName = (String) action.getParameterValues().get("sessionPropertyName"); String requestParameterValue = httpServletRequest.getParameter(requestParameterName); if (requestParameterValue != null) { if (profilePropertyName != null) { if (event.getProfile().getProperty(profilePropertyName) == null || !event.getProfile().getProperty(profilePropertyName).equals(requestParameterValue)) { event.getProfile().setProperty(profilePropertyName, requestParameterValue); return EventService.PROFILE_UPDATED; } } else if (sessionPropertyName != null) { if (event.getSession().getProperty(sessionPropertyName) == null || !event.getSession().getProperty(sessionPropertyName).equals(requestParameterValue)) { event.getSession().setProperty(sessionPropertyName, requestParameterValue); return EventService.SESSION_UPDATED; } } } return EventService.NO_CHANGE; } }
public int execute(Action action, Event event) { boolean changed = false; HttpServletRequest httpServletRequest = (HttpServletRequest) event.getAttributes().get(Event.HTTP_REQUEST_ATTRIBUTE); if (httpServletRequest == null) { return EventService.NO_CHANGE; } String requestHeaderName = (String) action.getParameterValues().get("requestHeaderName"); String profilePropertyName = (String) action.getParameterValues().get("profilePropertyName"); String sessionPropertyName = (String) action.getParameterValues().get("sessionPropertyName"); String requestHeaderValue = httpServletRequest.getHeader(requestHeaderName); if (requestHeaderValue != null) { if (profilePropertyName != null) { if (event.getProfile().getProperty(profilePropertyName) == null || !event.getProfile().getProperty(profilePropertyName).equals(requestHeaderValue)) { event.getProfile().setProperty(profilePropertyName, requestHeaderValue); return EventService.PROFILE_UPDATED; } } else if (sessionPropertyName != null) { if (event.getSession().getProperty(sessionPropertyName) == null || !event.getSession().getProperty(sessionPropertyName).equals(requestHeaderValue)) { event.getSession().setProperty(sessionPropertyName, requestHeaderValue); return EventService.SESSION_UPDATED; } } } return EventService.NO_CHANGE; } }
@Override public int execute(Action action, Event event) { String eventType = (String) action.getParameterValues().get("eventType"); @SuppressWarnings("unchecked") Map<String, Object> eventProperties = (Map<String, Object>) action.getParameterValues().get("eventProperties"); Item target = (Item) action.getParameterValues().get("eventTarget"); // String type = (String) target.get("type"); // Item targetItem = new CustomItem(); // BeanUtils.populate(targetItem, target); Event subEvent = new Event(eventType, event.getSession(), event.getProfile(), event.getScope(), event, target, event.getTimeStamp()); subEvent.setProfileId(event.getProfileId()); subEvent.getAttributes().putAll(event.getAttributes()); subEvent.getProperties().putAll(eventProperties); return eventService.send(subEvent); } }
if (PropertyHelper.setProperty(event.getSession(), propertyName, propertyValue, (String) action.getParameterValues().get("setPropertyStrategy"))) { return EventService.SESSION_UPDATED; propertyToUpdate.put(propertyName, propertyValue); Event updateProperties = new Event("updateProperties", event.getSession(), event.getProfile(), event.getScope(), null, event.getProfile(), new Date()); updateProperties.setPersistent(false);
return EventService.NO_CHANGE; Session session = event.getSession(); if (session == null) { return EventService.NO_CHANGE;
public int onEvent(Event event) { Set<Rule> rules = getMatchingRules(event); int changes = EventService.NO_CHANGE; for (Rule rule : rules) { logger.debug("Fired rule " + rule.getMetadata().getId() + " for " + event.getEventType() + " - " + event.getItemId()); long actionsStartTime = System.currentTimeMillis(); for (Action action : rule.getActions()) { changes |= actionExecutorDispatcher.execute(action, event); } long totalActionsTime = System.currentTimeMillis() - actionsStartTime; Event ruleFired = new Event("ruleFired", event.getSession(), event.getProfile(), event.getScope(), event, rule, event.getTimeStamp()); ruleFired.getAttributes().putAll(event.getAttributes()); ruleFired.setPersistent(false); changes |= eventService.send(ruleFired); RuleStatistics ruleStatistics = getLocalRuleStatistics(rule); ruleStatistics.setLocalExecutionCount(ruleStatistics.getLocalExecutionCount()+1); ruleStatistics.setLocalActionsTime(ruleStatistics.getLocalActionsTime() + totalActionsTime); this.allRuleStatistics.put(rule.getItemId(), ruleStatistics); } return changes; }
public int onEvent(Event event) { Set<Rule> rules = getMatchingRules(event); int changes = EventService.NO_CHANGE; for (Rule rule : rules) { logger.debug("Fired rule " + rule.getMetadata().getId() + " for " + event.getEventType() + " - " + event.getItemId()); fireExecuteActions(rule, event); long actionsStartTime = System.currentTimeMillis(); for (Action action : rule.getActions()) { changes |= actionExecutorDispatcher.execute(action, event); } long totalActionsTime = System.currentTimeMillis() - actionsStartTime; Event ruleFired = new Event("ruleFired", event.getSession(), event.getProfile(), event.getScope(), event, rule, event.getTimeStamp()); ruleFired.getAttributes().putAll(event.getAttributes()); ruleFired.setPersistent(false); changes |= eventService.send(ruleFired); RuleStatistics ruleStatistics = getLocalRuleStatistics(rule); ruleStatistics.setLocalExecutionCount(ruleStatistics.getLocalExecutionCount()+1); ruleStatistics.setLocalActionsTime(ruleStatistics.getLocalActionsTime() + totalActionsTime); this.allRuleStatistics.put(rule.getItemId(), ruleStatistics); } return changes; }
final Session currentSession = event.getSession();
if (sessionCondition != null && !persistenceService.testMatch(sessionCondition, event.getSession())) { updateRuleStatistics(ruleStatistics, ruleConditionStartTime); continue;
final Session session = event.getSession(); if (event.isPersistent() && session != null) { session.setLastEventDate(event.getTimeStamp());
if (sessionCondition != null && !persistenceService.testMatch(sessionCondition, event.getSession())) { updateRuleStatistics(ruleStatistics, ruleConditionStartTime); continue;
final Session session = event.getSession(); if (event.isPersistent() && session != null) { session.setLastEventDate(event.getTimeStamp());