    import BidEntityRelationsHelper from 'pvbid-sdk/src/domain/services/BidEntityRelationsHelper.js'

public class | source

# BidEntityRelationsHelper

Helper class to manage all bid entities in a bid.

## Constructor Summary

Public Constructor
public | constructor(bid: Bid) Creates an instance of BidEntityRelationsHelper. |

## Member Summary

Public Members
public | bid: Bid |

## Method Summary

Public Methods
public | assemblies(id: number): Assembly | Object<string, Assembly> Gets an assembly entity by id. |
public | assemblyMaps(id: number): AssemblyMap | Object<string, AssemblyMap> Gets a assembly map entity by id. |
public | bidEntityExists(type: string, id: number | string): boolean Determines if bid entity exists based on type and id. |
public | componentGroups(id: number): ComponentGroup | Object<string, ComponentGroup> Gets a component group entity by id. |
public | components(id: number): Component | Object<string, Component> Gets a component entity by id. |
public | datatables(id: number): Datatable | Object<string, Datatable> Gets a datatable entity by id. |
public | dependencyExists(dependencyContract: object): boolean Determines if dependency exists basd on the dependency contract. |
public | fieldGroups(id: number): FieldGroup | Object<string, FieldGroup> Gets a field group entity by id. |
public | fields(id: number): Field | Object<string, Field> Gets a field entity by id. |
public | getBidEntitiesByDefId(type: string, defId: number): BidEntity[] Get bid entities (field or metric) by a definition id |
public | getBidEntity(type: string, id: number | string): BidEntity Gets a bid entity by type and id. |
public | getCollection(type: string): object Returns the full collection of bid entites by type. |
public | getComponentByDefId(defId: number): Component Gets a component by their core definition id. |
public | getDependants(type: string, id: int): * Gets all the dependants for a bid bid entity. |
public | getDependency(dependencyContract: object): BidEntity Gets a bid entity by a dependency contract. |
public | getDependencyValue(dependencyContract: object): string | number | boolean Gets the value of a bid entity by a dependency contract. |
public | getFieldValue(field: *, dataColumnId: *): * |
public | isDependencyFullyDefined(dependencyContract: object): boolean Checks if the dependency used an undefined dependency value when evaluating (dependencies may evaluate to a number even if they rely on an undefined value somewhere in the calc) |
public | lineItems(id: number): LineItem | Object<string, LineItem> Gets a line item entity by id. |
public | metrics(id: number): Metric | Object<string, Metric> Gets a metric entity by id. |
public | searchByTitle(type: string, query: string): BidEntity[] Searches and returns an array of bid entities by their title. |
public | variables(id: string): Component | Object<string, Component> Gets a bid variable entity by id. |

## Public Constructors

### public constructor(bid: Bid) source

Creates an instance of BidEntityRelationsHelper.

#### Params:

Name | Type | Attribute | Description
bid | Bid |  |

## Public Members

### public bid: Bid source

## Public Methods

### public assemblies(id: number): Assembly | Object<string, Assembly> source

Gets an assembly entity by id. If no id is passed, will return an of object of keyed assemblies by their id..

#### Params:

Name | Type | Attribute | Description
id | number |  |

#### Return:

Assembly | Object<string, Assembly> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <Assembly>,
       "103" : <Assembly>
    }

### public assemblyMaps(id: number): AssemblyMap | Object<string, AssemblyMap> source

Gets a assembly map entity by id. If no id is passed, will return an object of keyed assembly maps by their id.

#### Params:

Name | Type | Attribute | Description

id

number

- optional

The id of the assembly map to retrieve.

#### Return:

AssemblyMap | Object<string, AssemblyMap> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <AssemblyMap>,
       "103" : <AssemblyMap>
    }

### public bidEntityExists(type: string, id: number | string): boolean source

Determines if bid entity exists based on type and id.

#### Params:

Name | Type | Attribute | Description
type | string |  |
id | number | string |  |

#### Return:

boolean

### public componentGroups(id: number): ComponentGroup | Object<string, ComponentGroup> source

Gets a component group entity by id. If no id is passed, will return an of object of keyed component groups by their id..

#### Params:

Name | Type | Attribute | Description
id | number |  |

#### Return:

ComponentGroup | Object<string, ComponentGroup> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <ComponentGroup>,
       "103" : <ComponentGroup>
    }

### public components(id: number): Component | Object<string, Component> source

Gets a component entity by id. If no id is passed, will return an object of keyed components by their id.

#### Params:

Name | Type | Attribute | Description

id

number

- optional

The id of the component to retrieve.

#### Return:

Component | Object<string, Component> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <Component>,
       "103" : <Component>
    }

### public datatables(id: number): Datatable | Object<string, Datatable> source

Gets a datatable entity by id. If no id is passed, will return an of object of keyed datatables by their id..

#### Params:

Name | Type | Attribute | Description
id | number |  |

#### Return:

Datatable | Object<string, Datatable> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <Datatable>,
       "103" : <Datatable>
    }

### public dependencyExists(dependencyContract: object): boolean source

Determines if dependency exists basd on the dependency contract.

#### Params:

Name | Type | Attribute | Description
dependencyContract | object |  |
dependencyContract.type | string |  |
dependencyContract.bid_entity_id | string |  |
dependencyContract.field | string |  |

#### Return:

boolean

### public fieldGroups(id: number): FieldGroup | Object<string, FieldGroup> source

Gets a field group entity by id. If no id is passed, will return an of object of keyed field groups by their id..

#### Params:

Name | Type | Attribute | Description
id | number |  |

#### Return:

FieldGroup | Object<string, FieldGroup> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <FieldGroup>,
       "103" : <FieldGroup>
    }

### public fields(id: number): Field | Object<string, Field> source

Gets a field entity by id. If no id is passed, will return an of object of keyed fields by their id..

#### Params:

Name | Type | Attribute | Description
id | number |  |

#### Return:

Field | Object<string, Field> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <Field>,
       "103" : <Field>
    }

### public getBidEntitiesByDefId(type: string, defId: number): BidEntity[] source

Get bid entities (field or metric) by a definition id

#### Params:

Name | Type | Attribute | Description
type | string |  | The type of bid entity ('metric'|'field')
defId | number |  | The definition id to lookup by

#### Return:

BidEntity[] | list of bid entities with the given def id

### public getBidEntity(type: string, id: number | string): BidEntity source

Gets a bid entity by type and id.

#### Params:

Name | Type | Attribute | Description
type | string |  |
id | number | string |  |

#### Return:

BidEntity

### public getCollection(type: string): object source

Returns the full collection of bid entites by type. Returned is a keyed object by the bid entity id.

#### Params:

Name | Type | Attribute | Description
type | string |  |

#### Return:

object

### public getComponentByDefId(defId: number): Component source

Gets a component by their core definition id. Note, this function will be removed once

#### Params:

Name | Type | Attribute | Description
defId | number |  |

#### Return:

Component

### public getDependants(type: string, id: int): * source

Gets all the dependants for a bid bid entity.

#### Params:

Name | Type | Attribute | Description
type | string |  | The type of bid enity. IE. line_item, field, metric, component, etc.
id | int |  | The id of the bid entity.

#### Return:

* | [BidEntity[]]

### public getDependency(dependencyContract: object): BidEntity source

Gets a bid entity by a dependency contract.

#### Params:

Name | Type | Attribute | Description
dependencyContract | object |  |
dependencyContract.type | string |  | The type of bid entity, ie: line_item, metric, field, component, compnent_group, assembly, etc
dependencyContract.bid_entity_id | string |  | The id of the bid entity. Note, this will eventual be converted to simply "id".
dependencyContract.field | string |  | The bid entity property that holds the needed value.

#### Return:

BidEntity | Returns the bid entity requested determined by the dependency contract.

#### Example:

Example a dependency contract.

    {
       "type" : <string>,
       "bid_entity_id" : <string>,
       "field" : <string>
    }

### public getDependencyValue(dependencyContract: object): string | number | boolean source

Gets the value of a bid entity by a dependency contract.

#### Params:

Name | Type | Attribute | Description
dependencyContract | object |  |
dependencyContract.type | string |  | The type of bid entity, ie: line_item, metric, field, component, compnent_group, assembly, etc
dependencyContract.bid_entity_id | string |  | The id of the bid entity. Note, this will eventual be converted to simply "id".
dependencyContract.field | string |  | The bid entity property that holds the needed value.

#### Return:

string | number | boolean | Returns the bid entity value.

### public getFieldValue(field: *, dataColumnId: *): * source

#### Params:

Name | Type | Attribute | Description
field | * |  |
dataColumnId | * |  |

#### Return:

*

### public isDependencyFullyDefined(dependencyContract: object): boolean source

Checks if the dependency used an undefined dependency value when evaluating (dependencies may evaluate to a number even if they rely on an undefined value somewhere in the calc)

#### Params:

Name | Type | Attribute | Description
dependencyContract | object |  |

#### Return:

boolean | If the dependency is fully defined / not relient on any unefined dependencies

### public lineItems(id: number): LineItem | Object<string, LineItem> source

Gets a line item entity by id. If no id is passed, will return an of object of keyed line items by their id..

#### Params:

Name | Type | Attribute | Description
id | number |  |

#### Return:

LineItem | Object<string, LineItem> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <LineItem>,
       "103" : <LineItem>
    }

### public metrics(id: number): Metric | Object<string, Metric> source

Gets a metric entity by id. If no id is passed, will return an of object of keyed metrics by their id..

#### Params:

Name | Type | Attribute | Description
id | number |  |

#### Return:

Metric | Object<string, Metric> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "92" : <Metric>,
       "103" : <Metric>
    }

### public searchByTitle(type: string, query: string): BidEntity[] source

Searches and returns an array of bid entities by their title. Results are case-insensitive.

#### Params:

Name | Type | Attribute | Description
type | string |  | The type of bid entity to search for: line_item, field, metric, component, assembly, etc.
query | string |  |

#### Return:

BidEntity[]

### public variables(id: string): Component | Object<string, Component> source

Gets a bid variable entity by id. If no id is passed, will return an object of keyed bid variables by their id.

#### Params:

Name | Type | Attribute | Description

id

string

- optional

The id of the component to retrieve.

#### Return:

Component | Object<string, Component> (nullable: true)

#### Example:

Example of returned keyed object.

    {
       "xyg4" : <BidVariable>,
       "burden" : <BidVariable>
    }