@Override public ContextNode map(Relation relation) { return relation.getContextNode(); } }
@Override public List<Relation> replaceRelation(Relation relation) { XDIAddress contextNodeXDIAddress = relation.getContextNode().getXDIAddress(); XDIAddress XDIaddress = relation.getXDIAddress(); XDIAddress targetXDIAddress = relation.getTargetXDIAddress(); XDIAddress replacedContextNodeXDIAddress = replaceXDIAddress(contextNodeXDIAddress); XDIAddress replacedTargetXDIAddress = replaceXDIAddress(targetXDIAddress); if (log.isTraceEnabled()) log.trace("Replaced " + contextNodeXDIAddress + " with " + replacedContextNodeXDIAddress); if (log.isTraceEnabled()) log.trace("Replaced " + targetXDIAddress + " with " + replacedTargetXDIAddress); Relation replacedRelation = GraphUtil.relationFromComponents(replacedContextNodeXDIAddress, XDIaddress, replacedTargetXDIAddress); return Collections.singletonList(replacedRelation); }
/** * Checks if a relation is a valid XDI $false operator. * @param relation The relation to check. * @return True if the relation is a valid XDI $false operator. */ public static boolean isValid(Relation relation) { if (! XdiAbstractEntity.isValid(relation.getContextNode())) return false; if (! Policy.isValid(XdiAbstractEntity.fromContextNode(relation.getContextNode()))) return false; if (! XDIConstants.XDI_ADD_FALSE.equals(relation.getXDIAddress())) return false; return true; }
/** * Checks if a relation is a valid XDI $true operator. * @param relation The relation to check. * @return True if the relation is a valid XDI $true operator. */ public static boolean isValid(Relation relation) { if (! XdiAbstractEntity.isValid(relation.getContextNode())) return false; if (! Policy.isValid(XdiAbstractEntity.fromContextNode(relation.getContextNode()))) return false; if (! XDIConstants.XDI_ADD_TRUE.equals(relation.getXDIAddress())) return false; return true; }
/** * Factory method that creates an XDI operation bound to a given relation. * @param relation The relation that is an XDI operation. * @return The XDI operation. */ public static Operation fromRelation(Relation relation) { XdiEntity xdiEntity = XdiAbstractEntity.fromContextNode(relation.getContextNode()); Message message = xdiEntity == null ? null : Message.fromXdiEntity(xdiEntity); if (xdiEntity == null) return null; return fromMessageBaseAndRelation(message, relation); }
@Override public List<Relation> replaceRelation(Relation relation) { XDIAddress contextNodeXDIAddress = relation.getContextNode().getXDIAddress(); XDIAddress XDIaddress = relation.getXDIAddress(); XDIAddress targetXDIAddress = relation.getTargetXDIAddress(); XDIAddress replacedTargetXDIAddress = replaceXDIAddress(targetXDIAddress); Relation replacedRelation = GraphUtil.relationFromComponents(contextNodeXDIAddress, XDIaddress, replacedTargetXDIAddress); return Collections.singletonList(replacedRelation); }
/** * Checks if an relation is a valid XDI $do operation. * @param relation The relation to check. * @return True if the relation is a valid XDI $do operation. */ public static boolean isValid(Relation relation) { if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_DO) == null) return false; if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false; return true; }
/** * When a context node is deleted, all inner roots have to be deleted too. */ protected void delContextNodeDelAllInnerRoots() { for (Relation relation : this.getAllRelations()) { AbstractContextNode contextNode = ((AbstractContextNode) relation.getContextNode()); contextNode.delRelationDelInnerRoot(relation.getXDIAddress(), relation.getTargetXDIAddress()); } }
/** * Checks if an relation is a valid XDI $push operation. * @param relation The relation to check. * @return True if the relation is a valid XDI $push operation. */ public static boolean isValid(Relation relation) { if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_PUSH) == null) return false; if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false; return true; }
/** * Checks if an relation is a valid XDI $del operation. * @param relation The relation to check. * @return True if the relation is a valid XDI $del operation. */ public static boolean isValid(Relation relation) { if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_DEL) == null) return false; if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false; return true; }
/** * Checks if an relation is a valid XDI $set operation. * @param relation The relation to check. * @return True if the relation is a valid XDI $set operation. */ public static boolean isValid(Relation relation) { if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_SET) == null) return false; if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false; return true; }
/** * Checks if an relation is a valid XDI $send operation. * @param relation The relation to check. * @return True if the relation is a valid XDI $send operation. */ public static boolean isValid(Relation relation) { if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_SEND) == null) return false; if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false; return true; }
/** * Checks if an relation is a valid XDI $connect operation. * @param relation The relation to check. * @return True if the relation is a valid XDI $connect operation. */ public static boolean isValid(Relation relation) { if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_CONNECT) == null) return false; if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false; return true; }
/** * Checks if an relation is a valid XDI $get operation. * @param relation The relation to check. * @return True if the relation is a valid XDI $get operation. */ public static boolean isValid(Relation relation) { if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_GET) == null) return false; if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false; return true; }
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()); }
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()); }
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()); }
@Override public boolean equals(Object object) { if (object == null || ! (object instanceof Relation)) return false; if (object == this) return true; Relation other = (Relation) object; // two relations are equal if their context nodes, addresses, and target node addresses are equal return this.getContextNode().equals(other.getContextNode()) && this.getXDIAddress().equals(other.getXDIAddress()) && this.getTargetXDIAddress().equals(other.getTargetXDIAddress()); }
@Override public int compareTo(Relation other) { if (other == null || other == this) return 0; int compare; if ((compare = this.getContextNode().compareTo(other.getContextNode())) != 0) return compare; if ((compare = this.getXDIAddress().compareTo(other.getXDIAddress())) != 0) return compare; if ((compare = this.getTargetXDIAddress().compareTo(other.getTargetXDIAddress())) != 0) return compare; return 0; }