예제 #1
0
  public boolean getRelation(
      XRI3Segment[] contributorXris,
      XRI3Segment relativeContextNodeXri,
      XRI3Segment arcXri,
      XRI3Segment targetContextNodeXri,
      XRI3Segment contextNodeXri,
      GetOperation operation,
      MessageResult messageResult,
      ExecutionContext executionContext)
      throws Xdi2MessagingException {

    MessageResult tempMessageResult = new MessageResult();

    this.getContext(
        contributorXris,
        relativeContextNodeXri,
        contextNodeXri,
        operation,
        tempMessageResult,
        executionContext);

    ContextNode tempContextNode =
        tempMessageResult.getGraph().findContextNode(contextNodeXri, false);
    if (tempContextNode == null) return false;

    if (Variables.isVariableSingle(targetContextNodeXri)) {

      Iterator<Relation> relations;

      if (Variables.isVariableSingle(arcXri)) {

        relations = tempContextNode.getRelations();
      } else {

        relations = tempContextNode.getRelations(arcXri);
      }

      while (relations.hasNext())
        CopyUtil.copyRelation(relations.next(), messageResult.getGraph(), null);
    } else {

      Relation relation = tempContextNode.getRelation(arcXri, targetContextNodeXri);
      if (relation == null) return false;

      CopyUtil.copyRelation(relation, messageResult.getGraph(), null);
    }

    return false;
  }