use of won.bot.framework.eventbot.event.impl.factory.FactoryHintEvent in project webofneeds by researchstudio-sat.
the class FactoryHintCheckAction method doRun.
@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
if (!(event instanceof HintFromMatcherEvent) || !(getEventListenerContext().getBotContextWrapper() instanceof FactoryBotContextWrapper)) {
logger.error("FactoryHintCheckAction can only handle HintFromMatcherEvent with FactoryBotContextWrapper");
return;
}
FactoryBotContextWrapper botContextWrapper = (FactoryBotContextWrapper) getEventListenerContext().getBotContextWrapper();
Match match = ((HintFromMatcherEvent) event).getMatch();
URI ownUri = match.getFromNeed();
URI requesterUri = match.getToNeed();
if (botContextWrapper.isFactoryNeed(ownUri)) {
logger.debug("FactoryHint for factoryURI: " + ownUri + " from the requesterUri: " + requesterUri);
EventBus bus = getEventListenerContext().getEventBus();
bus.publish(new FactoryHintEvent(requesterUri, ownUri));
} else {
logger.warn("NON FactoryHint for URI: " + ownUri + " from the requesterUri: " + requesterUri + " ignore the hint");
}
}
Aggregations