Class
The DataSourceManager
is used to manage data source, including create/get/destroy data source instance.
Please always use DataSourceManager.getInstance()
to use this class. For example, to get a data source, you can use DataSourceManager.getInstance().getDataSource(dsId)
.
For widget developer, DataSourceManager.getInstance()
return the same instance for both widget and widget's settings.
To use data source, the recommended way is to use DataSourceComponent
, which is more handy.
Methods
Method | Returns | Notes |
---|---|---|
Promise<DataSource[]> | Return the successfully created data sources only. For the failed created data sources, return null. | |
createDataSource(mainDataSourceId, dataViewId?, localId?) | Promise<DataSource> | This method is used to create data source instance. Main data source, data view or local data source are created as data source instance. |
createDataSourceByUseDataSource(useDs, localId?) | Promise<DataSource> | Create data source according to the used data source info, and will create a local data source if localId is passed in. |
createAllDataSources
Class MethodcreateAllDataSources(): Promise<DataSource[]>
Return the successfully created data sources only. For the failed created data sources, return null.
Returns
Promise<DataSource[]>
createDataSource
Class MethodcreateDataSource(mainDataSourceId: string, dataViewId?: string, localId?: string): Promise<DataSource>
This method is used to create data source instance. Main data source, data view or local data source are created as data source instance.
The parameter can be a data source id, data source config JSON or DataSourceConstructorOptions
.
If pass in dataViewId
, this method will create a data view.
If pass in dataViewId
and localId
, this method will create a local data view.
If pass in localId
, this method will create a local data source.
To create a main data source instance, this method do the followings:
- Create the data source object.
- Call the object's
ready()
method. - Call the object's
fetchSchema()
method.
When start to create the data source instance, this method will set the data source instanceStatus as NotCreated
at first.
The instanceStatus will be set as Created
when the creation process is done. The instanceStatus will be set as CreateError
if an error occurs.
Parameters
Parameter | Type |
---|---|
main | string |
data | string |
local | string |
Returns
Promise<DataSource>
createDataSourceByUseDataSource
Class MethodcreateDataSourceByUseDataSource(useDs: IMUseDataSource, localId?: string): Promise<DataSource>
Create data source according to the used data source info, and will create a local data source if localId is passed in.
Parameters
Parameter | Type |
---|---|
use | IMUseDataSource |
local | string |
Returns
Promise<DataSource>