Base class and the default implementation for the DataContext object, other implementations can be registered as well with higher priorities

Constructors

Properties

DataContextEntity: DataContextEntity

The object holding all the metadata for the data context - this only is in place automatically if you called the LoadMetadata method

ID: string

The ID of the data context in the system

Items: DataContextItem[] = []

The items in the data context

Methods

  • This method will create a new DataContextItem object and add it to the data context. This method will return the newly created DataContextItem object.

    Returns DataContextItem

  • Return a simple object that will have a property for each item in our Items array. We will name each item sequentially as data_item_1, data_item_2, etc, using the itemPrefix parameter

    Parameters

    • itemPrefix: string = 'data_item_'

      defaults to 'data_item_' and can be set to anything desired

    • includeFailedLoadItems: boolean = false

      if true, we will include items that have not been loaded due to loading errors in the output object, if false, we will only include items that have been loaded successfully

    Returns any

  • Return a string that contains a type definition for a simple object for this data context. The object will have a property for each item in our Items array. We will name each item sequentially as data_item_1, data_item_2, etc, using the itemPrefix parameter

    Parameters

    • itemPrefix: string = 'data_item_'

      defaults to 'data_item_' and can be set to anything desired

    • includeFailedLoadItems: boolean = false

      if true, we will include items that have not been loaded due to loading errors in the output object, if false, we will only include items that have been loaded successfully

    Returns string

  • This method will load both the metadata and the data for the data context items associated with the data context. This method will return a promise that will resolve to true if the data was loaded successfully, and false if it was not.

    Parameters

    • DataContextID: string

      the ID of the data context to load

    • dataSource: any

      the data source to use to execute the SQL statement - specified as an any type to allow for any type of data source to be used, but the actual implementation will be specific to the server side only

    • forceRefresh: boolean = false

      (defaults to false) for the LoadData() portion of this routine --- if this param is set to true, the data will be reloaded from the data source even if it is already loaded, if false, the data will only be loaded if it hasn't already been loaded

    • loadRelatedDataOnSingleRecords: boolean = false

      (defaults to false) for the LoadData() portion of this routine --- if this param is set to true, related entity data will be loaded for single record items, if false, related entity data will not be loaded for single record items

    • maxRecordsPerRelationship: number = 0

      (defaults to 0) for the LoadData() portion of this routine --- if this param is set to a value greater than 0, the maximum number of records to load for each relationship will be limited to this value. Applies to single_record items only.

    • Optional contextUser: UserInfo

      the user that is requesting the data context (only required on server side operations, or if you want a different user's permissions to be used for the data context load)

    Returns Promise<boolean>

  • This method will load the data for the data context items associated with the data context. This method must be called ONLY after LoadMetadata(). This method will return a promise that will resolve to true if the data was loaded successfully, and false if it was not.

    Parameters

    • dataSource: any

      the data source to use to execute the SQL statement - specified as an any type to allow for any type of data source to be used, but the actual implementation will be specific to the server side only

    • forceRefresh: boolean = false

      (defaults to false) if true, the data will be reloaded from the data source even if it is already loaded, if false, the data will only be loaded if it hasn't already been loaded

    • loadRelatedDataOnSingleRecords: boolean = false

      (defaults to false) if true, related entity data will be loaded for single record items, if false, related entity data will not be loaded for single record items

    • maxRecordsPerRelationship: number = 0

      (defaults to 0) for the LoadData() portion of this routine --- if this param is set to a value greater than 0, the maximum number of records to load for each relationship will be limited to this value. Applies to single_record items only.

    • Optional contextUser: UserInfo

      the user that is requesting the data context (only required on server side operations, or if you want a different user's permissions to be used for the data context load)

    Returns Promise<boolean>

  • If you already have the data loaded for an entire Data Context you can pass it in as a two dimensional array. The first dimension is the Dataset Item and the second dimension is the array of rows for that given Dataset Item. YOU are responsible for ensuring the ORDER of the first dimension, for the sequence of the Dataset Items, matches the items in the metadata, this method doesn't attempt to do any validation.

    Parameters

    • data: any[][]

    Returns boolean

  • This method will load ONLY the metadata for the data context and data context items associated with the data context. This method will not load any data for the data context items. This method will return a promise that will resolve to true if the metadata was loaded successfully, and false if it was not.

    Parameters

    • DataContextID: string

      the ID of the data context to load

    • Optional contextUser: UserInfo

      the user that is requesting the data context (only required on server side operations, or if you want a different user's permissions to be used for the data context load)

    • Optional provider: IMetadataProvider

      optional, the metadata provider to use to load the metadata. If not provided, the default metadata provider will be used.

    Returns Promise<boolean>

  • Saves the data context items to the database. For each data context item, if it has an existing ID in the database, that database record will be updated. For data context items that don't have an ID (meaning they've not yet been saved), a new record will be created in the database. This method will return a promise that will resolve to true if the data was saved successfully, and false if it was not. IMPORTANT: This method will not save if the ID property of the object is not set to a valid value.

    Parameters

    • Optional contextUser: UserInfo

      optional, the user that is requesting the data context (only required on server side operations, or if you want a different user's permissions to be used for the data context load)

    • persistItemData: boolean = false

      optional, if true, the data for each item will be saved to the database, if false, the data will not be saved to the database. The default is false.

    Returns Promise<boolean>

  • Simple validation method that determines if all of the items in the data context have data set. This doesn't mean the items have data in them as zero-length data is consider valid, it is checking to see if the Data property is set on each item or not

    Parameters

    • ignoreFailedLoadItems: boolean = false

      if set to true, we will ignore individual items that have not been loaded due to loading errors and only validate the data exists in the items that have been loaded. If set to false, we will validate all items regardless of their load state

    Returns boolean

  • This method will clone the data context and all of its items. This method will return a promise that will resolve to a new DataContext object if the cloning was successful, and will reject if the cloning was not successful.

    Parameters

    Returns Promise<DataContext>

  • This method will create a new DataContextItem object. This method is used internally by the AddDataContextItem method, but can also be called directly if you need to create a DataContextItem object for some other purpose. NOTE: this method does NOT add the newly created DataContextItem to the data context, you must do that yourself if you use this method directly.

    Returns DataContextItem

  • Utility method to create a new DataContext object from a raw data object. This method will return a promise that will resolve to a new DataContext object if the raw data was successfully converted, and will reject if the raw data was not successfully converted.

    Parameters

    • rawData: any

    Returns Promise<DataContext>