Package com.orchestranetworks.schema.relationships

# Class RelationshipsHelper

java.lang.Object
com.orchestranetworks.schema.relationships.RelationshipsHelper

public final class RelationshipsHelper extends Object
Provides utility methods for accessing directly from a record to the result of a relationship.

Since:
  5.7.1

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RelationshipsHelper()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static RequestResult`
  `getExplicitRelationshipResult(Adaptation aRecord, SchemaNode anExplicitRelationshipNode, Session aSession)`
  Returns the result of the explicit relationship defined by the specified node, in the context of the specified record.
  `static ReverseRelationshipResult`
  `getInterDatasetReferringRecords(Adaptation aReferencedRecord, SchemaNode aReferringNode, Adaptation aReferringDataset, Session aSession)`
  Returns the records in the specified referring dataset that refer to the specified record through the corresponding foreign key constraint, selection link or association link.
  `static ReverseRelationshipResult`
  `getIntraDatasetReferringRecords(Adaptation aReferencedRecord, SchemaNode aReferringNode, Session aSession)`
  Returns the records in the same dataset that refer to the specified record through the corresponding foreign key constraint, selection link or association link.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### RelationshipsHelper

    public RelationshipsHelper()

- ## Method Details

  - ### getExplicitRelationshipResult

    public static RequestResult getExplicitRelationshipResult(Adaptation aRecord, SchemaNode anExplicitRelationshipNode, Session aSession) throws QueryPermissionException
    Returns the result of the explicit relationship defined by the specified node, in the context of the specified record. Returns `null` if the specified node does not define a relationship.

    Permissions are applied according to the specified session. As a consequence:

    - the returned records will be filtered using the access rules on records if any;
    - a `QueryPermissionException` will be thrown on execution if at least one forbidden node is used in the request.
    Throws:
      `IllegalArgumentException` - if the specified `Adaptation` is null.
      `IllegalArgumentException` - if the specified `Adaptation` is not a record.
      `IllegalArgumentException` - if the specified `SchemaNode` is null.
      `IllegalArgumentException` - if the specified `Session` is null.
      `IllegalArgumentException` - if the specified `SchemaNode` does not define a relationship.
      `IllegalArgumentException` - if the specified record is not in a dataset that is an instance of the data model containing the specified node.
      `QueryPermissionException` - if a session is provided and at least one forbidden node is used in the request.

  - ### getIntraDatasetReferringRecords

    public static ReverseRelationshipResult getIntraDatasetReferringRecords(Adaptation aReferencedRecord, SchemaNode aReferringNode, Session aSession) throws QueryPermissionException
    Returns the records in the same dataset that refer to the specified record through the corresponding foreign key constraint, selection link or association link.

    Returns `null` if the node that defines the corresponding explicit relationship is not inside a table.

    Permissions are applied according to the specified session. As a consequence:

    - the returned records will be filtered using the access rules on records if any;
    - a `QueryPermissionException` will be thrown on execution if at least one forbidden node is used in the request.
    Throws:
      `IllegalArgumentException` - if the specified `Adaptation` is null.
      `IllegalArgumentException` - if the specified `Adaptation` is not a record.
      `IllegalArgumentException` - if the specified record is not in a dataset that is an instance of the data model containing the target table node of the associated relationship.
      `IllegalArgumentException` - if the specified record is not in the table that is targeted by the corresponding relationship.
      `IllegalArgumentException` - if the specified `SchemaNode` is null.
      `IllegalArgumentException` - if the specified `SchemaNode` does not define a relationship.
      `IllegalArgumentException` - if the specified `Session` is null.
      `QueryPermissionException` - if a session is provided and at least one forbidden node is used in the request.
    See Also:
      - `SchemaNodeRelationships.getIntraDatasetReverseRelationships()`

  - ### getInterDatasetReferringRecords

    public static ReverseRelationshipResult getInterDatasetReferringRecords(Adaptation aReferencedRecord, SchemaNode aReferringNode, Adaptation aReferringDataset, Session aSession)
    Returns the records in the specified referring dataset that refer to the specified record through the corresponding foreign key constraint, selection link or association link.

    Returns `null` if the node that defines the corresponding explicit relationship is not inside a table. or if there is no result in the context of the specified record.

    Permissions are applied according to the specified session. As a consequence:

    - this method will throw an `Exception` if a forbidden node is involved in the relationship.
    - access rules on records are applied and the result will be filtered accordingly.
    Throws:
      `IllegalArgumentException` - if the specified `Adaptation` is null.
      `IllegalArgumentException` - if the specified `Adaptation` is not a record.
      `IllegalArgumentException` - if the specified record is not in a dataset that is an instance of the data model containing the target table node of the associated relationship.
      `IllegalArgumentException` - if the specified record is not in the table that is targeted by the corresponding relationship.
      `IllegalArgumentException` - if the specified `Session` is null.
      `IllegalArgumentException` - if the specified `SchemaNode` is null.
    See Also:
      - `SchemaNodeRelationships.getInterDatasetReverseRelationships()`