/** * Set a $is# datatype associated with a context node * * @param contextNode * @param dataTypeXDIAddress */ public static void setDataType(ContextNode contextNode, XDIAddress dataTypeXDIAddress) { contextNode.setRelation(XDIDictionaryConstants.XDI_ADD_IS_TYPE, dataTypeXDIAddress); }
@Override public Relation setDeepRelation(XDIAddress relativeContextNodeXDIAddress, XDIAddress XDIaddress, XDIAddress targetXDIAddress) { return this.setDeepContextNode(relativeContextNodeXDIAddress).setRelation(XDIaddress, targetXDIAddress); }
/** * Set this message (template)'s correlation to another message (template). */ public void setCorrelationXDIAddress(XDIAddress correlationXDIAddress) { this.getContextNode().setRelation(XDIMessagingConstants.XDI_ADD_CORRELATION, correlationXDIAddress); }
/** * Creates a new $connect operation and adds it to this XDI message (template). * @param targetXDIAddress The target address to which the operation applies. * @return The newly created $connect operation. */ public ConnectOperation createConnectOperation(XDIAddress targetXDIAddress) { Relation relation = this.getOperationsContextNode().setRelation(XDIMessagingConstants.XDI_ADD_CONNECT, targetXDIAddress); return ConnectOperation.fromMessageBaseAndRelation(this, relation); }
/** * Creates a new $push operation and adds it to this XDI message (template). * @param targetXDIAddress The target address to which the operation applies. * @return The newly created $push operation. */ public PushOperation createPushOperation(XDIAddress targetXDIAddress) { Relation relation = this.getOperationsContextNode().setRelation(XDIMessagingConstants.XDI_ADD_PUSH, targetXDIAddress); return PushOperation.fromMessageBaseAndRelation(this, relation); }
public static void setReplacementContextNode(ContextNode contextNode, XDIAddress replacementContextNodeXDIAddress, boolean inverse) { contextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REF); contextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REP); Relation relation = contextNode.setRelation(XDIDictionaryConstants.XDI_ADD_REP, replacementContextNodeXDIAddress); if (inverse) relation.followContextNode().setRelation(XDIDictionaryConstants.XDI_ADD_IS_REP, relation.getContextNode()); }
/** * Creates a new $send operation and adds it to this XDI message (template). * @param targetXDIAddress The target address to which the operation applies. * @return The newly created $send operation. */ public SendOperation createSendOperation(XDIAddress targetXDIAddress) { Relation relation = this.getOperationsContextNode().setRelation(XDIMessagingConstants.XDI_ADD_SEND, targetXDIAddress); return SendOperation.fromMessageBaseAndRelation(this, relation); }
public static void setReferenceContextNode(ContextNode contextNode, XDIAddress referencecontextNodeXDIAddress, boolean inverse) { contextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REF); contextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REP); Relation relation = contextNode.setRelation(XDIDictionaryConstants.XDI_ADD_REF, referencecontextNodeXDIAddress); if (inverse) relation.followContextNode().setRelation(XDIDictionaryConstants.XDI_ADD_IS_REF, relation.getContextNode()); }
public static void setReplacementContextNode(ContextNode contextNode, ContextNode replacementContextNode, boolean inverse) { contextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REF); contextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REP); Relation relation = contextNode.setRelation(XDIDictionaryConstants.XDI_ADD_REP, replacementContextNode); if (inverse) relation.followContextNode().setRelation(XDIDictionaryConstants.XDI_ADD_IS_REP, relation.getContextNode()); }
/** * Creates a new $do operation and adds it to this XDI message (template). * @param targetXDIAddress The target address to which the operation applies. * @return The newly created $do operation. */ public DoOperation createDoOperation(XDIAddress targetXDIAddress) { Relation relation = this.getOperationsContextNode().setRelation(XDIMessagingConstants.XDI_ADD_DO, targetXDIAddress); return DoOperation.fromMessageBaseAndRelation(this, relation); }
public static void setReferenceContextNode(ContextNode contextNode, ContextNode referenceContextNode, boolean inverse) { contextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REF); contextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REP); Relation relation = contextNode.setRelation(XDIDictionaryConstants.XDI_ADD_REF, referenceContextNode); if (inverse) relation.followContextNode().setRelation(XDIDictionaryConstants.XDI_ADD_IS_REF, relation.getContextNode()); }
/** * Creates a relation from its components. * @param contextNodeXDIAddress The address of the context node containing the relation. * @param XDIaddress The address of the relation. * @param targetXDIAddress The target context node address of the relation. * @return A relation. */ public static Relation relationFromComponents(XDIAddress contextNodeXDIAddress, XDIAddress XDIaddress, XDIAddress targetXDIAddress) { Graph graph = MemoryGraphFactory.getInstance().openGraph(); return graph.setDeepContextNode(contextNodeXDIAddress).setRelation(XDIaddress, targetXDIAddress); }
/** * Set the link contract address. */ public void setLinkContractXDIAddress(XDIAddress linkContractXDIAddress) { this.getContextNode().delRelations(XDILinkContractConstants.XDI_ADD_CONTRACT); if (linkContractXDIAddress != null) { this.getContextNode().setRelation(XDILinkContractConstants.XDI_ADD_CONTRACT, linkContractXDIAddress); } }
/** * Set the FROM peer root arc of the message (template). */ public void setFromPeerRootXDIArc(XDIArc fromPeerRootXDIArc) { this.getContextNode().delRelations(XDIMessagingConstants.XDI_ADD_FROM); if (fromPeerRootXDIArc != null) { this.getContextNode().setRelation(XDIMessagingConstants.XDI_ADD_FROM, XDIAddress.fromComponent(fromPeerRootXDIArc)); } }
/** * Set the TO peer root arc of the message (template). */ public void setToPeerRootXDIArc(XDIArc toPeerRootXDIArc) { this.getContextNode().delRelations(XDIMessagingConstants.XDI_ADD_TO); if (toPeerRootXDIArc != null) { this.getContextNode().setRelation(XDIMessagingConstants.XDI_ADD_TO, XDIAddress.fromComponent(toPeerRootXDIArc)); } }
/** * When a context node is created, check if the inner root subject and predicate have to be created too. */ protected void setContextNodeSetInnerRoot(XDIArc XDIarc, ContextNode contextNode) { if (XdiInnerRoot.isValidXDIArc(XDIarc)) { XDIAddress subjectXDIAddress = XdiInnerRoot.getSubjectOfInnerRootXDIArc(XDIarc); XDIAddress predicateXDIAddress = XdiInnerRoot.getPredicateOfInnerRootXDIArc(XDIarc); ContextNode subjectContextNode = this.setDeepContextNode(subjectXDIAddress); if (predicateXDIAddress.getNumXDIArcs() < 1) return; subjectContextNode.setRelation(predicateXDIAddress, contextNode); } }
@Override public void executeSetOnRelationStatement(XDIStatement relationStatement, SetOperation operation, Graph operationResultGraph, ExecutionContext executionContext) throws Xdi2MessagingException { XDIAddress contextNodeXDIAddress = relationStatement.getContextNodeXDIAddress(); XDIAddress relationXDIaddress = relationStatement.getRelationXDIAddress(); XDIAddress targetXDIAddress = relationStatement.getTargetXDIAddress(); this.getGraph().setDeepContextNode(contextNodeXDIAddress).setRelation(relationXDIaddress, targetXDIAddress); }
public void setupPushPermissionInverseRelations() { ReadOnlyIterator<Relation> pushPermissionRelations = this.getPermissionsContextNode().getRelations(XDILinkContractConstants.XDI_ADD_PUSH); for (Relation pushPermissionRelation : pushPermissionRelations) { pushPermissionRelation.followContextNode().setRelation(XDILinkContractConstants.XDI_ADD_IS_PUSH, this.getContextNode().getXDIAddress()); } }
public void testNoExceptions() throws Exception { Graph graph17 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-17"); graph17.setStatement(XDIStatement.create("=markus<#email>/&/\"Markus Sabadello\"")); graph17.setStatement(XDIStatement.create("=markus/#friend/=neustar=les")); ContextNode root = graph17.getRootContextNode(); ContextNode markus = graph17.getDeepContextNode(XDIAddress.create("=markus")); ContextNode les = graph17.getDeepContextNode(XDIAddress.create("=neustar=les")); root.setContextNode(XDIArc.create("=markus")); markus.setDeepContextNode(XDIAddress.create("<#email>")).setLiteralNode("test"); markus.setRelation(XDIAddress.create("#friend"), les); graph17.close(); }
public void testDeleteDeep() throws Exception { Graph graph12 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-12"); assertEquals(graph12.getRootContextNode(), graph12.getDeepContextNode(XDIConstants.XDI_ADD_ROOT)); assertEquals(graph12.getRootContextNode().getXDIAddress(), XDIConstants.XDI_ADD_ROOT); graph12.setDeepContextNode(XDIAddress.create("=markus")).setRelation(XDIAddress.create("#friend"), XDIAddress.create("=someone")); graph12.getDeepContextNode(XDIAddress.create("=markus")).delete(); graph12.setDeepContextNode(XDIAddress.create("=markus")); assertNull(graph12.getDeepContextNode(XDIAddress.create("=markus")).getRelation(XDIAddress.create("#friend"))); graph12.close(); }