use of won.bot.framework.extensions.serviceatom.ServiceAtomContext in project webofneeds by researchstudio-sat.
the class ServiceAtomCreatedAtomRelationFilter method accept.
@Override
public boolean accept(Event event) {
BotContextWrapper botContextWrapper = getContext().getBotContextWrapper();
if (botContextWrapper instanceof ServiceAtomContext && event instanceof MessageEvent) {
ServiceAtomContext serviceAtomContext = (ServiceAtomContext) botContextWrapper;
URI serviceAtomUri = serviceAtomContext.getServiceAtomUri();
if (Objects.nonNull(serviceAtomUri)) {
MessageEvent messageEvent = (MessageEvent) event;
WonMessage wonMessage = messageEvent.getWonMessage();
if (Objects.equals(wonMessage.getRecipientAtomURI(), serviceAtomUri)) {
URI senderAtomUri = wonMessage.getSenderAtomURI();
return getContext().getBotContextWrapper().isAtomKnown(senderAtomUri);
} else if (Objects.equals(wonMessage.getSenderAtomURI(), serviceAtomUri)) {
URI recipientAtomUri = wonMessage.getRecipientAtomURI();
return getContext().getBotContextWrapper().isAtomKnown(recipientAtomUri);
}
return false;
}
}
return false;
}
use of won.bot.framework.extensions.serviceatom.ServiceAtomContext in project webofneeds by researchstudio-sat.
the class ServiceAtomFilter method accept.
@Override
public boolean accept(Event event) {
BotContextWrapper botContextWrapper = getContext().getBotContextWrapper();
if (botContextWrapper instanceof ServiceAtomContext) {
ServiceAtomContext serviceAtomContext = (ServiceAtomContext) botContextWrapper;
URI serviceAtomUri = serviceAtomContext.getServiceAtomUri();
if (Objects.nonNull(serviceAtomUri)) {
if (event instanceof MessageEvent) {
MessageEvent messageEvent = (MessageEvent) event;
WonMessage wonMessage = messageEvent.getWonMessage();
return Objects.equals(wonMessage.getSenderAtomURI(), serviceAtomUri) || Objects.equals(wonMessage.getRecipientAtomURI(), serviceAtomUri);
}
boolean accept = false;
if (event instanceof AtomSpecificEvent) {
AtomSpecificEvent specificEvent = (AtomSpecificEvent) event;
accept = Objects.equals(specificEvent.getAtomURI(), serviceAtomUri);
}
if (!accept && event instanceof TargetAtomSpecificEvent) {
TargetAtomSpecificEvent specificEvent = (TargetAtomSpecificEvent) event;
accept = Objects.equals(specificEvent.getTargetAtomURI(), serviceAtomUri);
}
return accept;
}
}
return false;
}
Aggregations