QueriableDataSource
Interface
QueriableDataSource
extends DataSource
and add query capability. A queriable data source must
have an URL
to execute the query.
The current default query implementation supports pagination. It allows mulitple widgets to apply queries on the same data source,
all of which are merged by using the AND
logic operator.
When execute a query, in addition to the passed in query parameters, all configured queries and
all other widgets applied queries are merged by using the AND
logic operator.
When a query is executed against a data view, the query from its main data source is used as well.
Properties
Property | Type | Notes |
---|---|---|
() => void | ||
() => void | ||
() => boolean | ||
The data source which this data source derives from. | ||
(data: any) => DataRecord | ||
() => Promise<DataSource[]> | ||
() => void | ||
() => void | ||
number | The total records count depends on the current query | |
(dataSourceId: string) => Promise<DataSource> | ||
string | The data view ID configured in Json. | |
() => Promise<IMDataSourceSchema> | ||
() => DataSource[] | ||
() => DataSource[] | ||
() => number | ||
(jimuChildId: string) => DataSource | ||
() => DataSource[] | ||
() => QueryParams | ||
() => DataSourceStatus | ||
(options?: GetCurrentQueryParamsOptions) => QueryParams | ||
() => IMDataSourceJson | ||
() => QueriableDataSource[] | ||
() => string | ||
() => IMDataSourceInfo | ||
() => string | ||
() => boolean | ||
(localId: string) => DataSource | ||
() => DataSource[] | ||
() => number | ||
(pageSize: number, page: number) => number[] | ||
(query: QueryParams, flag: "query" | "load", options?: QueryOptions) => QueryParams | ||
(index: number) => DataRecord | ||
(id: string) => DataRecord | ||
() => DataRecord[] | ||
(page: number, pageSize: number) => DataRecord[] | ||
(page: number, pageSize: number) => DataRecord[] | ||
() => DataRecord[] | ||
() => QueryParams | ||
() => DataSource | ||
(excludeWidgetId?: string) => QueryParams | ||
() => IMDataSourceSchema | ||
() => string[] | ||
() => number[] | ||
() => DataRecord[] | ||
() => DataRecord[] | ||
() => number | ||
() => DataSourceStatus | ||
() => number | ||
string | The data source ID. | |
boolean | Whether a data source contains child data sources.
A dataset data source should create all its child data sources before | |
boolean | True means the data source is a data view. For local data source, this is false even the local data source is created from a data view. | |
() => boolean | ||
boolean | True means the data source is a local data source. | |
boolean | Whether the data source is case-sensitive when doing query by SQL clauses. | |
(query: QueryParams, options?: QueryOptions) => Promise<DataRecord[]> | ||
(id: string, refresh?: boolean) => Promise<DataRecord> | ||
(query: QueryParams, options?: QueryOptions) => Promise<number> | ||
string | The local ID of the data source. | |
(queries: QueryParams[]) => QueryParams | ||
number | Order in the parent data source. | |
The parent data source of this data source, mull means it's a root data source. | ||
(query: QueryParams, options?: QueryOptions) => Promise<QueryResult> | ||
(id: string) => Promise<DataRecord> | ||
(query: QueryParams, options?: QueryOptions) => Promise<QueryResult> | ||
() => Promise<any> | ||
(id: string, record?: DataRecord, forceCheck?: boolean) => void | ||
(ids: string[], records?: DataRecord[], forceCheck?: boolean) => void | ||
(status: DataSourceStatus) => void | ||
(dsJson: IMDataSourceJson) => void | ||
(listen: boolean) => void | ||
(records: DataRecord[]) => void | ||
(records: DataRecord[]) => void | ||
(status: DataSourceStatus) => void | ||
string | The type of the data source | |
(query: QueryParams, widgetId: string) => void | ||
(ids: string[], triggerDataSource: DataSource, forceCheck?: boolean) => void | ||
string | The data source URL |
addVersion
addVersion: () => void
Type declaration
function(): void
Update data source version.
Returns
void
areChildDataSourcesCreated
areChildDataSourcesCreated: () => boolean
Type declaration
function(): boolean
Return whether all child data sources (including descendant data sources) are created.
Data source has this method only if it is data source set ( dataSource.isDataSourceSet
is true).
Returns
boolean
belongToDataSource
belongToDataSource: DataSource
The data source which this data source derives from.
buildRecord
buildRecord: (data: any) => DataRecord
Type declaration
function(data: any): DataRecord
Builds a data record only -- does not add the record into data source.
Parameters
Parameter | Type |
---|---|
data | any |
Returns
DataRecord
childDataSourcesReady
childDataSourcesReady: () => Promise<DataSource[]>
Type declaration
function(): Promise<DataSource[]>
All child data sources (including descendant data sources) are ready for use.
Data source has this method only if it is data source set ( dataSource.isDataSourceSet
is true).
Returns
Promise<DataSource[]>
clearRecords
clearRecords: () => void
Type declaration
function(): void
This function will clear the loaded records and won't clear the sourceRecords. Once the loaded records are cleared, the version in the data source info will be updated.
Returns
void
clearSourceRecords
clearSourceRecords: () => void
Type declaration
function(): void
Clear both sourceRecords and loaded records. Both source version and version in data source info will be updated.
Returns
void
createDataSourceById
createDataSourceById: (dataSourceId: string) => Promise<DataSource>
Type declaration
function(dataSourceId: string): Promise<DataSource>
Create a child or a descendant data source by id.
Data source has this method only if it is data source set ( dataSource.isDataSourceSet
is true).
Please note will only create the specific data source, won't create descendant data sources of it.
Parameters
Parameter | Type |
---|---|
data | string |
Returns
Promise<DataSource>
fetchSchema
fetchSchema: () => Promise<IMDataSourceSchema>
Type declaration
function(): Promise<IMDataSourceSchema>
Fetch the data schema from an actual data source. If it's a statistic data source, the schema will not be fetched.
Returns
Promise<IMDataSourceSchema>
getAllChildDataSources
getAllChildDataSources: () => DataSource[]
Type declaration
function(): DataSource[]
Return all child data sources of a parent data source, includes the grandchildren
Returns
DataSource[]
getAllDerivedDataSources
getAllDerivedDataSources: () => DataSource[]
Type declaration
function(): DataSource[]
Return the derived data views and local data sources.
Returns
DataSource[]
getAutoRefreshInterval
Interface PropertygetAutoRefreshInterval: () => number
Type declaration
function(): number
If the return value > 0, auto refresh is enabled.
Returns
number
getChildDataSource
getChildDataSource: (jimuChildId: string) => DataSource
Type declaration
function(jimuChildId: string): DataSource
Get child data source by jimuChildId
. You can get jimuChildId
by getJimuChildId()
.
Parameters
Parameter | Type |
---|---|
jimu | string |
Returns
DataSource
getChildDataSources
getChildDataSources: () => DataSource[]
Type declaration
function(): DataSource[]
Return child data sources of a parent data source.
Returns
DataSource[]
getConfigQueryParams
Interface PropertygetConfigQueryParams: () => QueryParams
Type declaration
function(): QueryParams
Get the user config query parameters.
Returns
QueryParams
getCountStatus
getCountStatus: () => DataSourceStatus
Type declaration
function(): DataSourceStatus
Return data source count status.
Returns
DataSourceStatus
getCurrentQueryParams
Interface PropertygetCurrentQueryParams: (options?: GetCurrentQueryParamsOptions) => QueryParams
Type declaration
function(options?: GetCurrentQueryParamsOptions): QueryParams
Get the current query parameters. The current query parameters contain all applied queries.
Parameters
Parameter | Type |
---|---|
options | GetCurrentQueryParamsOptions |
Returns
QueryParams
getDataSourceJson
getDataSourceJson: () => IMDataSourceJson
Type declaration
function(): IMDataSourceJson
The data source JSON object in app config.
Returns
IMDataSourceJson
getDataViews
Interface PropertygetDataViews: () => QueriableDataSource[]
Type declaration
function(): QueriableDataSource[]
Override parent interface to get correct type.
Returns
QueriableDataSource[]
getIdField
getIdField: () => string
Type declaration
function(): string
Return the data source ID field.
Returns
string
getInfo
getInfo: () => IMDataSourceInfo
Type declaration
function(): IMDataSourceInfo
Return the data source info in redux store.
Returns
IMDataSourceInfo
getLabel
getLabel: () => string
Type declaration
function(): string
Return data source label.
Returns
string
getListenSelection
getListenSelection: () => boolean
Type declaration
function(): boolean
Return whether listen selection.
Returns
boolean
getLocalDataSource
getLocalDataSource: (localId: string) => DataSource
Type declaration
function(localId: string): DataSource
Get local data source by local ID.
Parameters
Parameter | Type |
---|---|
local | string |
Returns
DataSource
getLocalDataSources
getLocalDataSources: () => DataSource[]
Type declaration
function(): DataSource[]
Return all local data sources created from a main data source or data view.
Returns
DataSource[]
getMaxRecordCount
Interface PropertygetMaxRecordCount: () => number
Type declaration
function(): number
Null means there is no record count limit, and will return all records from the service.
Returns
number
getRealQueryPages
Interface PropertygetRealQueryPages: (pageSize: number, page: number) => number[]
Type declaration
function(pageSize: number, page: number): number[]
Get real query page depends on the widget's request page.
Parameters
Parameter | Type |
---|---|
page | number |
page | number |
Returns
number[]
getRealQueryParams
Interface PropertygetRealQueryParams: (query: QueryParams, flag: "query" | "load", options?: QueryOptions) => QueryParams
Type declaration
- For load: we'll merge the configured query parameter if it has, and all widget applied queries.
- For query, we'll merge the current query parameter and the configured query parameter it has.
function(query: QueryParams, flag: "query" | "load", options?: QueryOptions): QueryParams
When do query/load, we do not fire the query request directly. Instead, we'll consider the data source's config/current query parameter.
Parameters
Parameter | Type |
---|---|
query | QueryParams |
flag | "query" | "load" |
options | QueryOptions |
Returns
QueryParams
getRecord
getRecord: (index: number) => DataRecord
Type declaration
function(index: number): DataRecord
Get record by index
Parameters
Parameter | Type |
---|---|
index | number |
Returns
DataRecord
getRecordById
getRecordById: (id: string) => DataRecord
Type declaration
function(id: string): DataRecord
Get record by ID
Parameters
Parameter | Type |
---|---|
id | string |
Returns
DataRecord
getRecords
getRecords: () => DataRecord[]
Type declaration
function(): DataRecord[]
Get records
Returns
DataRecord[]
getRecordsByPage
Interface PropertygetRecordsByPage: (page: number, pageSize: number) => DataRecord[]
Type declaration
function(page: number, pageSize: number): DataRecord[]
The page size here defines the records this method returns, which are not the actual query pageSize. Will use a fixed pageSize to query and cache data.
Parameters
Parameter | Type |
---|---|
page | number |
page | number |
Returns
DataRecord[]
getRecordsByPageWithSelection
Interface PropertygetRecordsByPageWithSelection: (page: number, pageSize: number) => DataRecord[]
Type declaration
function(page: number, pageSize: number): DataRecord[]
If selected records are not loaded in the current data source, will concat them to the end of records array. See getRecordsWithSelection for details.
Parameters
Parameter | Type |
---|---|
page | number |
page | number |
Returns
DataRecord[]
getRecordsWithSelection
getRecordsWithSelection: () => DataRecord[]
Type declaration
function(): DataRecord[]
If selected records are not loaded in the current data source, they will be concatenated to the end of records array. For example, record 1 is selected in data view 1 and it is not loaded in data view 2 (record 1 actually matches query params of data view 2), dataView2.getRecordsWithSelection() will return all loaded records in data view 2 and record 1.
Returns
DataRecord[]
getRemoteQueryParams
Interface PropertygetRemoteQueryParams: () => QueryParams
Type declaration
function(): QueryParams
Get the query parameters configured in remote (not in exb).
Returns
QueryParams
getRootDataSource
getRootDataSource: () => DataSource
Type declaration
function(): DataSource
Return the root data source.
Returns
DataSource
getRuntimeQueryParams
Interface PropertygetRuntimeQueryParams: (excludeWidgetId?: string) => QueryParams
Type declaration
function(excludeWidgetId?: string): QueryParams
Get the queries applied in runtime. If the excludeWidgetId is passed in, the queries of this widget will be excluded.
Parameters
Parameter | Type |
---|---|
exclude | string |
Returns
QueryParams
getSchema
getSchema: () => IMDataSourceSchema
Type declaration
function(): IMDataSourceSchema
The schema returned here is the merged result of the configured schema and the fetched schema.
Returns
IMDataSourceSchema
getSelectedRecordIds
getSelectedRecordIds: () => string[]
Type declaration
function(): string[]
Get selected record IDs
Returns
string[]
getSelectedRecordIndexes
getSelectedRecordIndexes: () => number[]
Type declaration
function(): number[]
Get selected record indexes
Returns
number[]
getSelectedRecords
getSelectedRecords: () => DataRecord[]
Type declaration
function(): DataRecord[]
Get selected records
Returns
DataRecord[]
getSourceRecords
getSourceRecords: () => DataRecord[]
Type declaration
function(): DataRecord[]
Return the source records
Returns
DataRecord[]
getSourceVersion
getSourceVersion: () => number
Type declaration
function(): number
When current data source is created from an array of records, it will be saved in sourceRecords
.
Return the version of sourceRecords
.
Returns
number
getStatus
getStatus: () => DataSourceStatus
Type declaration
function(): DataSourceStatus
Return data source status.
Returns
DataSourceStatus
getVersion
getVersion: () => number
Type declaration
function(): number
Return data source version.
Returns
number
isDataSourceSet
isDataSourceSet: boolean
Whether a data source contains child data sources.
A dataset data source should create all its child data sources before ready()
is resolved.
isDataView
isDataView: boolean
True means the data source is a data view. For local data source, this is false even the local data source is created from a data view.
isInAppConfig
isInAppConfig: () => boolean
Type declaration
function(): boolean
Return whether the data source is added in builder and is saved in app config.
Returns
boolean
isSqlCaseSensitive
Interface PropertyisSqlCaseSensitive: boolean
Whether the data source is case-sensitive when doing query by SQL clauses.
load
Interface Propertyload: (query: QueryParams, options?: QueryOptions) => Promise<DataRecord[]>
Type declaration
function(query: QueryParams, options?: QueryOptions): Promise<DataRecord[]>
Execute the query against the service and update the internal data records, pagination is supported.
When call this method, the real query is returnd by getRealQueryParams
.
Pagination: The pagination properties in the passed in query parameter may be not the same as the real query pagination that is sent to the service. The real query pagination is defined in the data source setting.
Parameters
Parameter | Type |
---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<DataRecord[]>
loadById
Interface PropertyloadById: (id: string, refresh?: boolean) => Promise<DataRecord>
Type declaration
function(id: string, refresh?: boolean): Promise<DataRecord>
Load record by ID, do not consider other queries.
Parameters
Parameter | Type |
---|---|
id | string |
refresh | boolean |
Returns
Promise<DataRecord>
loadCount
Interface PropertyloadCount: (query: QueryParams, options?: QueryOptions) => Promise<number>
Type declaration
function(query: QueryParams, options?: QueryOptions): Promise<number>
Load the records count.
Parameters
Parameter | Type |
---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<number>
mergeQueryParams
Interface PropertymergeQueryParams: (queries: QueryParams[]) => QueryParams
Type declaration
function(queries: QueryParams[]): QueryParams
Merge queries by using AND
, and return the merged result.
If any query is undefined/null, it will be ignored.
Parameters
Parameter | Type |
---|---|
queries | QueryParams[] |
Returns
QueryParams
parentDataSource
parentDataSource: DataSource
The parent data source of this data source, mull means it's a root data source.
query
Interface Propertyquery: (query: QueryParams, options?: QueryOptions) => Promise<QueryResult>
Type declaration
function(query: QueryParams, options?: QueryOptions): Promise<QueryResult>
Execute query against the service only, do NOT update the internal data records.
The actural query parameters are generated by getRealQueryParams
.
To query count, please use queryCount
.
Parameters
Parameter | Type |
---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<QueryResult>
queryById
Interface PropertyqueryById: (id: string) => Promise<DataRecord>
Type declaration
function(id: string): Promise<DataRecord>
Query record by ID
Parameters
Parameter | Type |
---|---|
id | string |
Returns
Promise<DataRecord>
queryCount
Interface PropertyqueryCount: (query: QueryParams, options?: QueryOptions) => Promise<QueryResult>
Type declaration
function(query: QueryParams, options?: QueryOptions): Promise<QueryResult>
Query count
Parameters
Parameter | Type |
---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<QueryResult>
ready
ready: () => Promise<any>
Type declaration
function(): Promise<any>
Ready is resolved means the data source instance is ready for use.
Returns
Promise<any>
selectRecordById
selectRecordById: (id: string, record?: DataRecord, forceCheck?: boolean) => void
Type declaration
function(id: string, record?: DataRecord, forceCheck?: boolean): void
Select a record by ID.
When select record by ID, we can pass in the record. So when the selected record is not loaded, we can add it in.
If forceCheck
is true, will check whether the record match filters of the data source or not. Will select the record only if the check is passed.
Parameters
Parameter | Type | Notes |
---|---|---|
id | string | The ID to be selected. The selection will be cleared if the ID is null. |
record | DataRecord | |
force | boolean |
Returns
void
selectRecordsByIds
selectRecordsByIds: (ids: string[], records?: DataRecord[], forceCheck?: boolean) => void
Type declaration
function(ids: string[], records?: DataRecord[], forceCheck?: boolean): void
Select records by IDs.
When select records by IDs, we can pass in the records. So when the selected records are not loaded, we can add them in.
If forceCheck
is true, will check whether these records match filters of the data source or not. Will select the records which check is passed.
Parameters
Parameter | Type | Notes |
---|---|---|
ids | string[] | The IDs to be selected. The selection will be cleared if the IDs are null. |
records | DataRecord[] | |
force | boolean |
Returns
void
setCountStatus
setCountStatus: (status: DataSourceStatus) => void
Type declaration
function(status: DataSourceStatus): void
Update data source count status.
Parameters
Parameter | Type |
---|---|
status | DataSourceStatus |
Returns
void
setDataSourceJson
setDataSourceJson: (dsJson: IMDataSourceJson) => void
Type declaration
function(dsJson: IMDataSourceJson): void
Update data source JSON in data source instance
Parameters
Parameter | Type |
---|---|
d | IMDataSourceJson |
Returns
void
setListenSelection
setListenSelection: (listen: boolean) => void
Type declaration
function(listen: boolean): void
Whether listen selected records from other data sources which are derived from the same main data source. If true, will update selected record IDs of current data source info when selecting records via other derived data sources. Will also update selected record IDs when selecting records via current data source itself. If false, won't change selected record IDs when selecting records via other derived data sources. Will update selected record IDs only when selecting records via current data source itself.
Main data source and its data views will listen selected records by default, local data source does not listen selected records by default.
Parameters
Parameter | Type |
---|---|
listen | boolean |
Returns
void
setRecords
setRecords: (records: DataRecord[]) => void
Type declaration
function(records: DataRecord[]): void
Update the records in the data source object only, does not update the source data.
Parameters
Parameter | Type |
---|---|
records | DataRecord[] |
Returns
void
setSourceRecords
setSourceRecords: (records: DataRecord[]) => void
Type declaration
function(records: DataRecord[]): void
When current data source is created from an array of records, will save it in sourceRecords
.
These two methods are used to update or get the source data.
Parameters
Parameter | Type |
---|---|
records | DataRecord[] |
Returns
void
setStatus
setStatus: (status: DataSourceStatus) => void
Type declaration
function(status: DataSourceStatus): void
Update data source status.
Parameters
Parameter | Type |
---|---|
status | DataSourceStatus |
Returns
void
updateQueryParams
Interface PropertyupdateQueryParams: (query: QueryParams, widgetId: string) => void
Type declaration
function(query: QueryParams, widgetId: string): void
Update the data source query without executing the actual query.
Parameters
Parameter | Type |
---|---|
query | QueryParams |
widget | string |
Returns
void
updateSelectionInfo
updateSelectionInfo: (ids: string[], triggerDataSource: DataSource, forceCheck?: boolean) => void
Type declaration
function(ids: string[], triggerDataSource: DataSource, forceCheck?: boolean): void
Update selected record IDs in data source info if the current data source listens selection change (see setListenSelection
) or the current data source is the trigger data source (that is to say, select via it).
Before update info, will check whether these selected records match filters of the current data source firstly, and then only set the matched selected records to info.
Will skip the check in some cases to improve performance if the forceCheck
is not passed in or is false. For example, if the curren data source is main data source (we suppose that main data source contains all records, no need to check).
But if the forceCheck
is true, won't skip the check.
Parameters
Parameter | Type |
---|---|
ids | string[] |
trigger | DataSource |
force | boolean |
Returns
void
addSourceVersion: () => void
Type declaration
function(): void
When current data source is created from an array of records, it will be saved in
sourceRecords
. Add the version ofsourceRecords
.setSourceRecords
will add the version by default.Returns
void