/** * Retrieves one of the possibly multiple Models that does not have a signature yet. If there is none * (all are signed or none is found at all), a new model is created, added to the internal contentMap * and returned here. * */ public Model getUnsignedContentGraph(){ if (contentMap.isEmpty()){ //no content graphs yet. Make one and return it. Model contentGraph = ModelFactory.createDefaultModel(); RdfUtils.replaceBaseURI(contentGraph, this.messageURI.toString()); addContent(contentGraph); return contentGraph; } //content map is not empty. find one without a signature: for (Map.Entry<URI, Model> entry: contentMap.entrySet()){ if (!signatureMap.containsKey(entry.getKey())) return entry.getValue(); } //all content graphs are signed. add a new one. Model contentGraph = ModelFactory.createDefaultModel(); RdfUtils.replaceBaseURI(contentGraph, this.messageURI.toString()); addContent(contentGraph); return contentGraph; }
WonMessage responseMessage = WonMessageBuilder .setPropertiesForNodeResponse(originalMessage, false,newMessageURI) .addContent( errorMessageContent
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(); }
protected WonMessage createWonMessage(WonNodeInformationService wonNodeInformationService, URI needURI, URI wonNodeURI, Dataset needDataset, final boolean usedForTesting, final boolean doNotMatch ) throws WonMessageBuilderException { 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); } RdfUtils.replaceBaseURI(needDataset, needURI.toString()); return WonMessageBuilder.setMessagePropertiesForCreate( wonNodeInformationService.generateEventURI(wonNodeURI), needURI, wonNodeURI).addContent(needModelWrapper.copyDataset()).build(); }
public static WonMessageBuilder setMessagePropertiesForHint( URI messageURI, URI needURI, URI needFacetURI, URI wonNodeURI, URI otherNeedURI, URI otherNeedFacet, URI matcherURI, double score) { Model contentModel = WonRdfUtils.FacetUtils.createFacetModelForHintOrConnect(needFacetURI, otherNeedFacet); Resource msgResource = contentModel.createResource(messageURI.toString()); RdfUtils.replaceBaseResource(contentModel, msgResource); contentModel.add(msgResource, WON.HAS_MATCH_SCORE, contentModel.createTypedLiteral(score)); contentModel.add(msgResource, WON.HAS_MATCH_COUNTERPART, contentModel.createResource(otherNeedURI.toString())); return new WonMessageBuilder(messageURI) .setWonMessageDirection(WonMessageDirection.FROM_EXTERNAL) .setWonMessageType(WonMessageType.HINT_MESSAGE) .setSenderNodeURI(matcherURI) .setReceiverNeedURI(needURI) .setReceiverNodeURI(wonNodeURI) .setSentTimestampToNow() .addContent(contentModel); }
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 setMessagePropertiesForHintNotification( URI messageURI, URI needURI, URI needFacetURI, URI needConnectionURI, URI wonNodeURI, URI otherNeedURI, URI otherNeedFacet, URI matcherURI, double score) { Model contentModel = WonRdfUtils.FacetUtils.createFacetModelForHintOrConnect(needFacetURI, otherNeedFacet); Resource msgResource = contentModel.createResource(messageURI.toString()); RdfUtils.replaceBaseResource(contentModel, msgResource); contentModel.add(msgResource, WON.HAS_MATCH_SCORE, contentModel.createTypedLiteral(score)); contentModel.add(msgResource, WON.HAS_MATCH_COUNTERPART, contentModel.createResource(otherNeedURI.toString())); return new WonMessageBuilder(messageURI) .setWonMessageDirection(WonMessageDirection.FROM_EXTERNAL) .setWonMessageType(WonMessageType.HINT_MESSAGE) .setSenderNodeURI(matcherURI) .setReceiverURI(needConnectionURI) .setReceiverNeedURI(needURI) .setReceiverNodeURI(wonNodeURI) .addContent(contentModel) .setSentTimestampToNow(); }
public static WonMessageBuilder setMessagePropertiesForConnect( URI messageURI, URI localFacet, URI localNeed, URI localWonNode, URI remoteFacet, URI remoteNeed, URI remoteWonNode, String welcomeMessage) { // create facet model Model facetModel = WonRdfUtils.FacetUtils.createFacetModelForHintOrConnect(localFacet, remoteFacet); RdfUtils.replaceBaseResource(facetModel, facetModel.createResource(messageURI.toString())); if (welcomeMessage != null){ WonRdfUtils.MessageUtils.addMessage(facetModel, welcomeMessage); } return new WonMessageBuilder(messageURI) .setWonMessageDirection(WonMessageDirection.FROM_OWNER) .setWonMessageType(WonMessageType.CONNECT) .setSenderNeedURI(localNeed) .setSenderNodeURI(localWonNode) .setReceiverNeedURI(remoteNeed) .setReceiverNodeURI(remoteWonNode) .addContent(facetModel) .setSentTimestampToNow(); }
.setReceiverNeedURI(remoteNeed) .setReceiverNodeURI(remoteWonNode) .addContent(content) .setSentTimestampToNow();