public static WonMessage forwardReceivedNodeToNodeMessageAsNodeToNodeMessage(final URI newMessageUri, final WonMessage wonMessage, final URI connectionURI, final URI needURI, final URI wonNodeUri, final URI remoteConnectionURI, final URI remoteNeedURI, final URI remoteWonNodeUri) { WonMessageBuilder builder = new WonMessageBuilder(newMessageUri) .setWonMessageType(wonMessage.getMessageType()) .forward(wonMessage) .setForwardedMessageURI(wonMessage.getMessageURI()) .setSenderNeedURI(needURI) .setSenderURI(connectionURI) .setSenderNodeURI(wonNodeUri) .setSentTimestamp(System.currentTimeMillis()) .setReceiverURI(remoteConnectionURI) .setReceiverNeedURI(remoteNeedURI) .setReceiverNodeURI(remoteWonNodeUri) .setIsRemoteResponseToMessageURI(wonMessage.getIsRemoteResponseToMessageURI()) .setIsResponseToMessageURI(wonMessage.getIsResponseToMessageURI()) .setIsResponseToMessageType(wonMessage.getIsResponseToMessageType()) .setWonMessageDirection(WonMessageDirection.FROM_SYSTEM); return builder.build(); }
public static WonMessageBuilder setMessagePropertiesForHintFeedback( URI messageURI, URI connectionURI, URI needURI, URI wonNodeURI, boolean booleanFeedbackValue) { Model contentModel = WonRdfUtils.MessageUtils.binaryFeedbackMessage(connectionURI, booleanFeedbackValue); Resource msgResource = contentModel.createResource(messageURI.toString()); RdfUtils.replaceBaseResource(contentModel, msgResource); return new WonMessageBuilder(messageURI) .setWonMessageDirection(WonMessageDirection.FROM_OWNER) .setWonMessageType(WonMessageType.HINT_FEEDBACK_MESSAGE) .setReceiverNodeURI(wonNodeURI) .setReceiverURI(connectionURI) .setReceiverNeedURI(needURI) .setSenderNodeURI(wonNodeURI) .setSenderNeedURI(needURI) .setSenderURI(connectionURI) .setSentTimestampToNow() .addContent(contentModel); }
public static WonMessageBuilder setMessagePropertiesForClose( URI messageURI, WonMessageDirection direction, URI localConnection, URI localNeed, URI localWonNode, String farewellMessage) { return setMessagePropertiesForClose(messageURI, WonMessageDirection.FROM_OWNER, localConnection, localNeed, localWonNode, localConnection, localNeed, localWonNode, farewellMessage); }
public static WonMessageBuilder setMessagePropertiesForNeedCreatedNotification( URI messageURI, URI localNeed, URI localWonNode) { return new WonMessageBuilder(messageURI) .setWonMessageType(WonMessageType.NEED_CREATED_NOTIFICATION) .setWonMessageDirection(WonMessageDirection.FROM_EXTERNAL) .setSenderNeedURI(localNeed) .setSenderNodeURI(localWonNode) .setSentTimestampToNow(); }
private WonMessage createWonMessage(WonNodeInformationService wonNodeInformationService, URI needURI, URI wonNodeURI) throws WonMessageBuilderException { return WonMessageBuilder .setMessagePropertiesForDeactivateFromOwner( wonNodeInformationService.generateEventURI(wonNodeURI), needURI, wonNodeURI) .build(); } }
public static WonMessageBuilder setPropertiesForNodeResponse(WonMessage originalMessage, boolean isSuccess, URI messageURI){ WonMessageBuilder messageBuilder = new WonMessageBuilder(messageURI) .setWonMessageType(isSuccess? WonMessageType.SUCCESS_RESPONSE : WonMessageType .FAILURE_RESPONSE); .setSenderNodeURI(originalMessage.getReceiverNodeURI()) .setSenderNeedURI(originalMessage.getReceiverNeedURI()) .setSenderURI(originalMessage.getReceiverURI()) .setIsRemoteResponseToMessageURI(originalMessage.getCorrespondingRemoteMessageURI()); } else if (WonMessageDirection.FROM_OWNER == origDirection|| WonMessageDirection.FROM_SYSTEM == origDirection ){ .setSenderNodeURI(originalMessage.getSenderNodeURI()) .setSenderNeedURI(originalMessage.getSenderNeedURI()) .setSenderURI(originalMessage.getSenderURI()); .setReceiverNeedURI(originalMessage.getSenderNeedURI()) .setReceiverNodeURI(originalMessage.getSenderNodeURI()) .setReceiverURI(originalMessage.getSenderURI()) .setIsResponseToMessageURI(originalMessage.getMessageURI()) .setIsResponseToMessageType(originalMessage.getMessageType()) .setWonMessageDirection(WonMessageDirection.FROM_SYSTEM); return messageBuilder;
@Override public WonMessage process(WonMessage message) throws WonMessageProcessingException { //there need not be a remote connection. Don't create a message if this is the case. if (connection.getRemoteConnectionURI() == null) return null; URI remoteNodeURI = wonNodeInformationService.getWonNodeUri(connection.getRemoteConnectionURI()); URI localNodeURI = wonNodeInformationService.getWonNodeUri(connection.getConnectionURI()); //create the message to send to the remote node return WonMessageBuilder .setPropertiesForPassingMessageToRemoteNode( message, getMessageURI()) .setSenderNodeURI(localNodeURI) .setSenderURI(connection.getConnectionURI()) .setSenderNeedURI(connection.getNeedURI()) .setReceiverNodeURI(remoteNodeURI) .setReceiverURI(connection.getRemoteConnectionURI()) .setReceiverNeedURI(connection.getRemoteNeedURI()) .build(); } }
public void closeConnection(final Need need, final Connection con) { //send close from system to each connection //the close message is directed at our local connection. It will //be routed to the owner and forwarded to to remote connection URI messageURI = wonNodeInformationService.generateEventURI(); WonMessage message = WonMessageBuilder .setMessagePropertiesForClose(messageURI, WonMessageDirection.FROM_SYSTEM, con.getConnectionURI(), con.getNeedURI(), need.getWonNodeURI(), con.getConnectionURI(), con.getNeedURI(), need.getWonNodeURI(), "Closed because Need was deactivated").build(); sendSystemMessage(message); }
private WonMessage createWonMessage(URI needURI, URI otherNeedURI, double score, URI originator) throws WonMessageBuilderException { URI wonNode = WonLinkedDataUtils .getWonNodeURIForNeedOrConnection(needURI, linkedDataSource.getDataForResource(needURI)); return WonMessageBuilder .setMessagePropertiesForHint( wonNodeInformationService.generateEventURI( wonNode), needURI, FacetType.OwnerFacet.getURI(), wonNode, otherNeedURI, FacetType.OwnerFacet.getURI(), originator, score) .setWonMessageDirection(WonMessageDirection.FROM_EXTERNAL) .build(); } }
private WonMessage createWonMessageForConnectionMessage(URI fromConUri, URI fromNeedUri, URI toConUri, URI toNeedUri, Model content) throws WonMessageBuilderException { WonNodeInformationService wonNodeInformationService = getEventListenerContext().getWonNodeInformationService(); Dataset localNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(fromNeedUri); Dataset remoteNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(toNeedUri); URI localWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(localNeedRDF, fromNeedUri); URI remoteWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(remoteNeedRDF, toNeedUri); return WonMessageBuilder .setMessagePropertiesForConnectionMessage( wonNodeInformationService.generateEventURI( localWonNode), fromConUri, fromNeedUri, localWonNode, toConUri, toNeedUri, remoteWonNode, content) .build(); }
@Override public WonMessage process(WonMessage message) throws WonMessageProcessingException { //create the message to send to the remote node return WonMessageBuilder .setPropertiesForPassingMessageToRemoteNode( message, getMessageURI()) .build(); } }
private WonMessage createWonMessage(URI needURI, URI otherNeedURI, double score, URI originator) throws WonMessageBuilderException { WonNodeInformationService wonNodeInformationService = getEventListenerContext().getWonNodeInformationService(); URI localWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed( getEventListenerContext().getLinkedDataSource().getDataForResource(needURI), needURI); return WonMessageBuilder .setMessagePropertiesForHint( wonNodeInformationService.generateEventURI( localWonNode), needURI, FacetType.OwnerFacet.getURI(), localWonNode, otherNeedURI, FacetType.OwnerFacet.getURI(), originator, score) .build(); }
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), fromFacet, fromUri, localWonNode, toFacet, toUri, remoteWonNode, welcomeMessage) .build(); }
private WonMessage createWonMessage( WonNodeInformationService wonNodeInformationService, URI needURI, URI wonNodeURI, Dataset needDataset, final boolean usedForTesting, final boolean doNotMatch) throws WonMessageBuilderException { RdfUtils.replaceBaseURI(needDataset, needURI.toString()); NeedModelWrapper needModelWrapper = new NeedModelWrapper(needDataset); if (doNotMatch){ needModelWrapper.addFlag(WON.NO_HINT_FOR_ME); needModelWrapper.addFlag(WON.NO_HINT_FOR_COUNTERPART); } if (usedForTesting){ needModelWrapper.addFlag(WON.USED_FOR_TESTING); } return WonMessageBuilder.setMessagePropertiesForCreate( wonNodeInformationService.generateEventURI(wonNodeURI), needURI, wonNodeURI).addContent(needModelWrapper.copyDataset()).build(); }
private WonMessage makeNeedCreatedMessageForMatcher(final Need need) throws NoSuchNeedException { return WonMessageBuilder .setMessagePropertiesForNeedCreatedNotification(wonNodeInformationService.generateEventURI(), need.getNeedURI(), need.getWonNodeURI()) .setWonMessageDirection(WonMessageDirection.FROM_EXTERNAL) .build(); }
private WonMessage createWonMessageForOpen(URI fromConUri, URI fromNeedUri, URI toConUri, URI toNeedUri) throws WonMessageBuilderException { WonNodeInformationService wonNodeInformationService = getEventListenerContext().getWonNodeInformationService(); Dataset localNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(fromNeedUri); Dataset remoteNeedRDF = getEventListenerContext().getLinkedDataSource().getDataForResource(toNeedUri); URI localWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(localNeedRDF, fromNeedUri); URI remoteWonNode = WonRdfUtils.NeedUtils.getWonNodeURIFromNeed(remoteNeedRDF, toNeedUri); return WonMessageBuilder .setMessagePropertiesForOpen( wonNodeInformationService.generateEventURI( localWonNode), fromConUri, fromNeedUri, localWonNode, toConUri, toNeedUri, remoteWonNode,null) .build(); }
@Override public WonMessage process(WonMessage message) throws WonMessageProcessingException { return WonMessageBuilder .setPropertiesForPassingMessageToRemoteNode( message, getMessageURI()) .setSenderURI(connection.getConnectionURI()) .build(); } }
/** * The message to remote node will contain envelope with sentTimestamp, remoteMessageUri, direction, * as well as exact copy of the local message envelopes and contents. * * @param ownerOrSystemMsg * @param newMessageUri * @return */ private static WonMessageBuilder setPropertiesForPassingMessageToRemoteNodeAndCopyLocalMessage(final WonMessage ownerOrSystemMsg, URI newMessageUri){ return new WonMessageBuilder(newMessageUri) .setSentTimestamp(new Date().getTime()) .forward(ownerOrSystemMsg) // copy .setCorrespondingRemoteMessageURI(ownerOrSystemMsg.getMessageURI()) .setWonMessageDirection(WonMessageDirection.FROM_EXTERNAL); }
RdfUtils.replaceBaseURI(errorMessageContent, newMessageURI.toString()); WonMessage responseMessage = WonMessageBuilder .setPropertiesForNodeResponse(originalMessage, false,newMessageURI) .addContent( errorMessageContent .build();