Home Manual Reference Source
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

Creates an instance of BidEntityRelationsHelper.

Member Summary

Public Members
public

bid: Bid

Method Summary

Public Methods
public

Gets an assembly entity by id.

public

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

Gets a assembly map entity by id.

public

Determines if bid entity exists based on type and id.

public

Gets a component group entity by id.

public

Gets a component entity by id.

public

Gets a datatable entity by id.

public

dependencyExists(dependencyContract: object): boolean

Determines if dependency exists basd on the dependency contract.

public

dynamicGroups(id: string): DynamicGroup | Object<string, DynamicGroup>

Gets a dynamic group entity by id.

public

Gets a field group entity by id.

public

Gets a field entity by id.

public

Get bid entities by a definition id

public

Gets a bid entity by type and id.

public

Returns the full collection of bid entites by type.

public

Gets a component by their core definition id.

public

Gets a datatable by 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

Gets a line item entity by id.

public

Gets a metric entity by id.

public

parseBoolean(value: *): *

public

searchByTitle(type: string, query: string, exactMatch: boolean): BidEntity[]

Searches and returns an array of bid entities by their title.

public

Gets a bid variable entity by id.

Public Constructors

public constructor(bid: Bid) source

Creates an instance of BidEntityRelationsHelper.

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
dependencyContract object
dependencyContract.type string
dependencyContract.bid_entity_id string
dependencyContract.field string

Return:

boolean

public dynamicGroups(id: string): DynamicGroup | Object<string, DynamicGroup> source

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

Params:

NameTypeAttributeDescription
id string

Return:

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

Example:

Example of returned keyed object.
{
   "92" : <DynamicGroup>,
   "103" : <DynamicGroup>
}

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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 by a definition id

Params:

NameTypeAttributeDescription
type string

The type of bid entity ('metric'|'field'|'line_item'|'datatable'|'component')

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
defId number

Return:

Component

public getDatatableByDefId(defId: number): Datatable source

Gets a datatable by definition id

Params:

NameTypeAttributeDescription
defId number

Return:

Datatable

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

Gets all the dependants for a bid bid entity.

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
dependencyContract object
dependencyContract.type string

The type of bid entity, ie: line_item, metric, field, component, component_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 (nullable: true)

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
id number
  • nullable: true

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:

NameTypeAttributeDescription
id number

Return:

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

Example:

Example of returned keyed object.
{
   "92" : <Metric>,
   "103" : <Metric>
}

public parseBoolean(value: *): * source

Params:

NameTypeAttributeDescription
value *

Return:

*

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

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

Params:

NameTypeAttributeDescription
type string

The type of bid entity to search for: line_item, field, metric, component, assembly, etc.

query string
exactMatch boolean
  • optional
  • default: false

By default, the search will match any title that contains the search term. If this flag is set to true, the title search will perform a case-insensitive exact match

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:

NameTypeAttributeDescription
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>
}