Class: PathInfo

Defined in: src/path.coffee

Overview

A representation of the information contained in a path expression. This class exposes the metadata available for this path, and is aware of class constraints placed upon it.

Instance Method Summary

Constructor Details

- (void) constructor()

Constructor of PathInfo objects. PathInfo objects are constructed by the model. You should not need to call this constructor yourself.

@param options The data used to construct this PathInfo object

Options Hash: (options):

  • root (Table) The root of this path
  • model (Model) the model this path belongs to
  • model (Array<Field>) The descriptor for each non-root path segment
  • descriptors (Array<Field>) The descriptor for each non-root path segment
  • subclasses (Object<String, TableInfo>) The subclass mapping
  • displayName (String) The display name to use in preference to fetching.
  • ident (String) A key used to index this path.

Instance Method Details

- (boolean) isRoot() (bound)

Whether or not this is a root path.

Returns:

  • (boolean) — Whether this is a root path (i.e. has no parent).

- (boolean) isAttribute() (bound)

Whether or not this is a leaf path.

Returns:

  • (boolean) — Whether this path represents a data value.

- (boolean) isClass() (bound)

Whether or not this path represents one or more objects (i.e. is not a leaf).

Returns:

  • (boolean) — Whether or not this path represents a class of objects.

- (boolean) isReference() (bound)

Whether or not this path is a reference field (could be collection).

Returns:

  • (boolean) — True if not root, and not a leaf.

- (boolean) isCollection() (bound)

Whether or not this path refers to a collection.

Returns:

  • (boolean) — True if a reference which is a collection.

- (boolean) containsCollection() (bound)

Whether or not any segment of this path refers to a collection.

Returns:

  • (boolean) — True if this path contains at least one collection.

- (Table) getEndClass() (bound)

Get the Table object for this path (if root or reference, null if leaf).

Returns:

  • (Table) — description of the class this path represents.

- (PathInfo) getParent() (bound)

Get the parent of this path. i.e., for Gene.proteins.name returns Gene.proteins exonSymbols = model.makePath('Gene.exons.symbol') exons = model.makePath('Gene.exons') exons.equals(exonSymbols.getParent()) //=> true

@throws [Error] if this path has not parent.

Returns:

  • (PathInfo) — The parent of this path.

- (PathInfo) append(attr) (bound)

Adds a segment to this path. The segment must conform with the data model.

Parameters:

  • attr (String|Field) The field to add.

Returns:

  • (PathInfo) — a new PathInfo object with the appended segment.

- (boolean) isa(clazz) (bound)

Analyses the inheritance hierarchy to determine if this path represents an instance of the provided class. eg: path = model.makePath('Gene.proteins') path.isa('Protein') //=> true path.isa('BioEntity') //=> true path.isa('Organism') //=> false path.append('name').isa('String') //=> true

Parameters:

  • The (String|Table) purported parent class.

Returns:

  • (boolean) — If the path represents the provided class or one of its subclasses

- (Promise<String>) getDisplayName(cb) (bound)

Fetches the configured display name for this path from the server.

Parameters:

  • cb (Function<Error, String, void>) An optional callback.

Returns:

  • (Promise<String>) — A promise for the display name.

- (Array<PathInfo>) getChildNodes() (bound)

Gets all the sub-paths of this class. eg:

path = model.makePath('Gene') path.getChildNodes() //=> [PathInfo('Gene.name'), PathInfo('Gene.proteins')...]

Returns:

  • (Array<PathInfo>) — The children of this path.

- (Array<Descriptor>) allDescriptors() (bound)

Returns:

  • (Array<Descriptor>) — the root and the segment descriptors in a single array.

- (String) toString()

             to {Model::makePath}

Returns:

  • (String) — The string representation of this path, the same as that passed

- (boolean) equals(other)

Overriden equals.

Returns:

  • (boolean) — true if the other path and this path are the same.

- (String|Table) getType()

Get the type of this path. If the path represents a class or a reference, the class itself is returned, otherwise the name of the attribute type is returned, minus any "java.lang." prefix.

Returns:

  • (String|Table) — A class-descriptor, or an attribute type name.