Search in sources :

Example 31 with WonNodeInformationService

use of won.protocol.service.WonNodeInformationService in project webofneeds by researchstudio-sat.

the class ExecuteConnectCommandAction method createWonMessage.

protected WonMessage createWonMessage(ConnectCommandEvent connectCommandEvent) throws WonMessageBuilderException {
    WonNodeInformationService wonNodeInformationService = getEventListenerContext().getWonNodeInformationService();
    Dataset localNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(connectCommandEvent.getNeedURI());
    Dataset remoteNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(connectCommandEvent.getRemoteNeedURI());
    URI localWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(localNeedRDF, connectCommandEvent.getNeedURI());
    URI remoteWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(remoteNeedRDF, connectCommandEvent.getRemoteNeedURI());
    return WonMessageBuilder.setMessagePropertiesForConnect(wonNodeInformationService.generateEventURI(localWonNode), connectCommandEvent.getLocalFacet(), connectCommandEvent.getNeedURI(), localWonNode, connectCommandEvent.getRemoteFacet(), connectCommandEvent.getRemoteNeedURI(), remoteWonNode, connectCommandEvent.getWelcomeMessage()).build();
}
Also used : Dataset(org.apache.jena.query.Dataset) WonNodeInformationService(won.protocol.service.WonNodeInformationService) URI(java.net.URI)

Example 32 with WonNodeInformationService

use of won.protocol.service.WonNodeInformationService in project webofneeds by researchstudio-sat.

the class ExecuteConnectionMessageCommandAction method createWonMessage.

@Override
protected WonMessage createWonMessage(ConnectionMessageCommandEvent messageCommandEvent) throws WonMessageBuilderException {
    WonNodeInformationService wonNodeInformationService = getEventListenerContext().getWonNodeInformationService();
    Model localMessageModel = RdfUtils.cloneModel(messageCommandEvent.getMessageModel());
    Dataset connectionRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(messageCommandEvent.getConnectionURI());
    URI remoteNeed = WonRdfUtils.ConnectionUtils.getRemoteNeedURIFromConnection(connectionRDF, messageCommandEvent.getConnectionURI());
    URI localNeed = WonRdfUtils.ConnectionUtils.getLocalNeedURIFromConnection(connectionRDF, messageCommandEvent.getConnectionURI());
    URI wonNode = WonRdfUtils.ConnectionUtils.getWonNodeURIFromConnection(connectionRDF, messageCommandEvent.getConnectionURI());
    Dataset remoteNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(remoteNeed);
    URI messageURI = wonNodeInformationService.generateEventURI(wonNode);
    RdfUtils.replaceBaseURI(localMessageModel, messageURI.toString());
    return WonMessageBuilder.setMessagePropertiesForConnectionMessage(messageURI, messageCommandEvent.getConnectionURI(), localNeed, wonNode, WonRdfUtils.ConnectionUtils.getRemoteConnectionURIFromConnection(connectionRDF, messageCommandEvent.getConnectionURI()), remoteNeed, WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(remoteNeedRDF, remoteNeed), localMessageModel).build();
}
Also used : Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model) WonNodeInformationService(won.protocol.service.WonNodeInformationService) URI(java.net.URI)

Example 33 with WonNodeInformationService

use of won.protocol.service.WonNodeInformationService in project webofneeds by researchstudio-sat.

the class CloseConnectionAction method createWonMessage.

private WonMessage createWonMessage(URI connectionURI) throws WonMessageBuilderException {
    WonNodeInformationService wonNodeInformationService = getEventListenerContext().getWonNodeInformationService();
    Dataset connectionRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(connectionURI);
    URI remoteNeed = WonRdfUtils.ConnectionUtils.getRemoteNeedURIFromConnection(connectionRDF, connectionURI);
    URI localNeed = WonRdfUtils.ConnectionUtils.getLocalNeedURIFromConnection(connectionRDF, connectionURI);
    URI wonNode = WonRdfUtils.ConnectionUtils.getWonNodeURIFromConnection(connectionRDF, connectionURI);
    Dataset remoteNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(remoteNeed);
    return WonMessageBuilder.setMessagePropertiesForClose(wonNodeInformationService.generateEventURI(wonNode), connectionURI, localNeed, wonNode, WonRdfUtils.ConnectionUtils.getRemoteConnectionURIFromConnection(connectionRDF, connectionURI), remoteNeed, WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(remoteNeedRDF, remoteNeed), farewellMessage).build();
}
Also used : Dataset(org.apache.jena.query.Dataset) WonNodeInformationService(won.protocol.service.WonNodeInformationService) URI(java.net.URI)

Example 34 with WonNodeInformationService

use of won.protocol.service.WonNodeInformationService in project webofneeds by researchstudio-sat.

the class ConnectTwoNeedsAction method createWonMessage.

private WonMessage createWonMessage(URI fromUri, URI toUri) throws WonMessageBuilderException {
    WonNodeInformationService wonNodeInformationService = getEventListenerContext().getWonNodeInformationService();
    Dataset localNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(fromUri);
    Dataset remoteNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(toUri);
    URI localWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(localNeedRDF, fromUri);
    URI remoteWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(remoteNeedRDF, toUri);
    return WonMessageBuilder.setMessagePropertiesForConnect(wonNodeInformationService.generateEventURI(localWonNode), localFacet, fromUri, localWonNode, remoteFacet, toUri, remoteWonNode, welcomeMessage).build();
}
Also used : Dataset(org.apache.jena.query.Dataset) WonNodeInformationService(won.protocol.service.WonNodeInformationService) URI(java.net.URI)

Example 35 with WonNodeInformationService

use of won.protocol.service.WonNodeInformationService in project webofneeds by researchstudio-sat.

the class AutomaticMessageResponderListener method createWonMessage.

private WonMessage createWonMessage(URI connectionURI, String message) throws WonMessageBuilderException {
    WonNodeInformationService wonNodeInformationService = getEventListenerContext().getWonNodeInformationService();
    Dataset connectionRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(connectionURI);
    URI remoteNeed = WonRdfUtils.ConnectionUtils.getRemoteNeedURIFromConnection(connectionRDF, connectionURI);
    URI localNeed = WonRdfUtils.ConnectionUtils.getLocalNeedURIFromConnection(connectionRDF, connectionURI);
    URI wonNode = WonRdfUtils.ConnectionUtils.getWonNodeURIFromConnection(connectionRDF, connectionURI);
    Dataset remoteNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(remoteNeed);
    URI messageURI = wonNodeInformationService.generateEventURI(wonNode);
    return WonMessageBuilder.setMessagePropertiesForConnectionMessage(messageURI, connectionURI, localNeed, wonNode, WonRdfUtils.ConnectionUtils.getRemoteConnectionURIFromConnection(connectionRDF, connectionURI), remoteNeed, WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(remoteNeedRDF, remoteNeed), message).build();
}
Also used : Dataset(org.apache.jena.query.Dataset) WonNodeInformationService(won.protocol.service.WonNodeInformationService) URI(java.net.URI)

Aggregations

URI (java.net.URI)35 WonNodeInformationService (won.protocol.service.WonNodeInformationService)35 Dataset (org.apache.jena.query.Dataset)28 Event (won.bot.framework.eventbot.event.Event)7 FailureResponseEvent (won.bot.framework.eventbot.event.impl.wonmessage.FailureResponseEvent)7 EventListener (won.bot.framework.eventbot.listener.EventListener)7 WonMessage (won.protocol.message.WonMessage)7 EventListenerContext (won.bot.framework.eventbot.EventListenerContext)6 DefaultNeedModelWrapper (won.protocol.util.DefaultNeedModelWrapper)4 NeedCreationFailedEvent (won.bot.framework.eventbot.event.NeedCreationFailedEvent)3 NeedCreatedEvent (won.bot.framework.eventbot.event.impl.needlifecycle.NeedCreatedEvent)3 Resource (org.apache.jena.rdf.model.Resource)2 WonURI (won.bot.framework.eventbot.action.impl.mail.model.WonURI)2 EventBus (won.bot.framework.eventbot.bus.EventBus)2 NeedCreatedEventForMatcher (won.bot.framework.eventbot.event.impl.matcher.NeedCreatedEventForMatcher)2 NeedContentPropertyType (won.protocol.model.NeedContentPropertyType)2 NeedModelWrapper (won.protocol.util.NeedModelWrapper)2 InvalidParameterException (java.security.InvalidParameterException)1 MessagingException (javax.mail.MessagingException)1 MimeMessage (javax.mail.internet.MimeMessage)1