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 |
---|---|---|
The data source which this data source derives from. | ||
number | The total records count depends on the current query | |
string | The data view id configured in Json. | |
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 | True means the data source is a local data source. | |
string | The local id of the data source. | |
number | Order in the parent data source. | |
The parent data source of this data source, mull means it's a root data source. | ||
string | The type of the data source | |
string | The data source URL |
belongToDataSource optional
count optional
count: number
The total records count depends on the current query
dataViewId optional
dataViewId: string
The data view id configured in Json.
id
id: string
The data source id.
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.
isLocal
isLocal: boolean
True means the data source is a local data source.
localId optional
localId: string
The local id of the data source.
order optional
order: number
Order in the parent data source.
parentDataSource
parentDataSource: DataSource
The parent data source of this data source, mull means it's a root data source.
type
type: string
The type of the data source
url
url: string
The data source URL
Methods
Method | Returns | Notes |
---|---|---|
| void | When current data source is created from an array of records, it will be saved in |
| void | Update data source version. |
| void | This function will clear the loaded records and won't clear the sourceRecords. Once the loaded records cleared, version in data source info will be updated. |
| void | Clear both sourceRecords and loaded records. Both source version and version in data source info will be updated. |
| Promise<IMDataSourceSchema> | Fetch data schema from an actual data source. If it's a statistic data source, we won't fetch schema. |
| Return all child data sources of a parent data source, includes the grandchildren | |
| Return the derived data views and local data sources. | |
| number | If the return value > 0, auto refresh is enabled. |
| Get child data source by | |
| Return child data sources of a parent data source. | |
| Get the user config query parameters. | |
| Return data source count status. | |
| Get the current query parameters. The current query parameters contain all applied queries. | |
| IMDataSourceJson | The data source JSON object in app config. |
| Get data view by data view id. | |
| Override parent interface to get correct type. | |
| string | Return the data source id field. |
| IMDataSourceInfo | Return the data source info in redux store. |
| string | Return data source label. |
| boolean | Return whether listen selection. |
| Get local data source by local Id. | |
| Return all local data sources created from a main data source or data view. | |
| Return the main data source. | |
| number | Null means there is no record count limit, and will return all records from the service. |
| number[] | Get real query page depends on the widget's request page. |
| When do query/load, we do not fire the query request directly. Instead, we'll consider the data source's config/current query parameter.
| |
| Get record by index | |
| Get record by id | |
| Get records | |
| 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. | |
| If selected records are not loaded in the current data source, will concat them to the end of records array. See getRecordsWithSelection for details. | |
| 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. | |
| Get the query parameters configured in remote (not in exb). | |
| Return the root data source. | |
| Get the queries applied in runtime. If the excludeWidgetId is passed in, the queries of this widget will be excluded. | |
| IMDataSourceSchema | The schema returned here is the merged result of the configured schema and the fetched schema. |
| string[] | Get selected record ids |
| number[] | Get selected record indexes |
| Get selected records | |
| Return the source records | |
| number | When current data source is created from an array of records, it will be saved in |
| Return data source status. | |
| number | Return data source version. |
| 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 |
| Promise<DataRecord> | Load record by id, do not consider other queries. |
| Promise<number> | Load the records count. |
| Merge queries by using | |
| Promise<QueryResult> | Execute query against the service only, do NOT update the internal data records.
The actural query parameters are generated by |
| Promise<DataRecord> | Query record by id |
| Promise<QueryResult> | Query count |
| Promise<any> | Ready is resolved means the data source instance is ready for use. |
| 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 |
| 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 |
| void | Update data source count status. |
| void | Update data source JSON in data source instance |
| 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. |
| void | Update the records in the data source object only, does not update the source data. See DataSourceEditSourceOperations.updateRecords |
| void | When current data source is created from an array of records, will save it in |
| void | Update data source status. |
| void | Update the data source query without executing the actual query. |
| void | Update selected record ids in data source info if the current data source listens selection change (see |
addSourceVersion
addSourceVersion(): void
When current data source is created from an array of records, it will be saved in sourceRecords
.
Add the version of sourceRecords
.setSourceRecords
will add the version by default.
Returns
void
addVersion optional
addVersion(): void
Update data source version.
Returns
void
clearRecords optional
clearRecords(): void
This function will clear the loaded records and won't clear the sourceRecords. Once the loaded records cleared, version in data source info will be updated.
Returns
void
clearSourceRecords
clearSourceRecords(): void
Clear both sourceRecords and loaded records. Both source version and version in data source info will be updated.
Returns
void
fetchSchema
fetchSchema(): Promise<IMDataSourceSchema>
Fetch data schema from an actual data source. If it's a statistic data source, we won't fetch schema.
Returns
Promise<IMDataSourceSchema>
getAllChildDataSources optional
getAllChildDataSources(): DataSource[]
Return all child data sources of a parent data source, includes the grandchildren
Returns
DataSource[]
getAllDerivedDataSources
getAllDerivedDataSources(): DataSource[]
Return the derived data views and local data sources.
Returns
DataSource[]
getAutoRefreshInterval
getAutoRefreshInterval(): number
If the return value > 0, auto refresh is enabled.
Returns
number
getChildDataSource optional
getChildDataSource(jimuChildId: string): DataSource
Get child data source by jimuChildId
. You can get jimuChildId
by getJimuChildId()
.
Parameters
Parameter | Type |
---|---|
jimuChildId | string |
Returns
DataSource
getChildDataSources optional
getChildDataSources(): DataSource[]
Return child data sources of a parent data source.
Returns
DataSource[]
getConfigQueryParams
getConfigQueryParams(): QueryParams
Get the user config query parameters.
Returns
QueryParams
getCountStatus
getCountStatus(): DataSourceStatus
Return data source count status.
Returns
DataSourceStatus
getCurrentQueryParams
getCurrentQueryParams(excludeOption?: WidgetDataSourcePair): QueryParams
Get the current query parameters. The current query parameters contain all applied queries.
Parameters
Parameter | Type |
---|---|
excludeOption | WidgetDataSourcePair |
Returns
QueryParams
getDataSourceJson
getDataSourceJson(): IMDataSourceJson
The data source JSON object in app config.
Returns
IMDataSourceJson
getDataView
getDataView(dataViewId: string): QueriableDataSource
Get data view by data view id.
Parameters
Parameter | Type |
---|---|
dataViewId | string |
Returns
QueriableDataSource
getDataViews
getDataViews(): QueriableDataSource[]
Override parent interface to get correct type.
Returns
QueriableDataSource[]
getIdField
getIdField(): string
Return the data source id field.
Returns
string
getInfo
getInfo(): IMDataSourceInfo
Return the data source info in redux store.
Returns
IMDataSourceInfo
getLabel
getLabel(): string
Return data source label.
Returns
string
getListenSelection
getListenSelection(): boolean
Return whether listen selection.
Returns
boolean
getLocalDataSource
getLocalDataSource(localId: string): DataSource
Get local data source by local Id.
Parameters
Parameter | Type |
---|---|
localId | string |
Returns
DataSource
getLocalDataSources
getLocalDataSources(): DataSource[]
Return all local data sources created from a main data source or data view.
Returns
DataSource[]
getMainDataSource
getMainDataSource(): QueriableDataSource
Return the main data source.
Returns
QueriableDataSource
getMaxRecordCount
getMaxRecordCount(): number
Null means there is no record count limit, and will return all records from the service.
Returns
number
getRealQueryPages
getRealQueryPages(pageSize: number, page: number): number[]
Get real query page depends on the widget's request page.
Parameters
Parameter | Type |
---|---|
pageSize | number |
page | number |
Returns
number[]
getRealQueryParams
getRealQueryParams(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.
- 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.
Parameters
Parameter | Type |
---|---|
query | QueryParams |
flag | "query" | "load" |
options | QueryOptions |
Returns
QueryParams
getRecord
getRecord(index: number): DataRecord
Get record by index
Parameters
Parameter | Type |
---|---|
index | number |
Returns
DataRecord
getRecordById
getRecordById(id: string): DataRecord
Get record by id
Parameters
Parameter | Type |
---|---|
id | string |
Returns
DataRecord
getRecordsByPage
getRecordsByPage(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 |
pageSize | number |
Returns
DataRecord[]
getRecordsByPageWithSelection
getRecordsByPageWithSelection(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 |
pageSize | number |
Returns
DataRecord[]
getRecordsWithSelection
getRecordsWithSelection(): 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
getRemoteQueryParams(): QueryParams
Get the query parameters configured in remote (not in exb).
Returns
QueryParams
getRuntimeQueryParams
getRuntimeQueryParams(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 |
---|---|
excludeWidgetId | string |
Returns
QueryParams
getSchema
getSchema(): IMDataSourceSchema
The schema returned here is the merged result of the configured schema and the fetched schema.
Returns
IMDataSourceSchema
getSelectedRecordIds optional
getSelectedRecordIds(): string[]
Get selected record ids
Returns
string[]
getSelectedRecordIndexes optional
getSelectedRecordIndexes(): number[]
Get selected record indexes
Returns
number[]
getSelectedRecords optional
getSelectedRecords(): DataRecord[]
Get selected records
Returns
DataRecord[]
getSourceVersion
getSourceVersion(): 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
getVersion
getVersion(): number
Return data source version.
Returns
number
load
load(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
loadById(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
loadCount(query: QueryParams, options?: QueryOptions): Promise<number>
Load the records count.
Parameters
Parameter | Type |
---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<number>
mergeQueryParams
mergeQueryParams(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
query
query(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
queryById(id: string): Promise<DataRecord>
Query record by id
Parameters
Parameter | Type |
---|---|
id | string |
Returns
Promise<DataRecord>
queryCount
queryCount(query: QueryParams, options?: QueryOptions): Promise<QueryResult>
Query count
Parameters
Parameter | Type |
---|---|
query | QueryParams |
options | QueryOptions |
Returns
Promise<QueryResult>
ready
ready(): Promise<any>
Ready is resolved means the data source instance is ready for use.
Returns
Promise<any>
selectRecordById optional
selectRecordById(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 |
---|---|
id | string |
record | DataRecord |
forceCheck | boolean |
Returns
void
selectRecordsByIds optional
selectRecordsByIds(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 |
---|---|
ids | string[] |
records | DataRecord[] |
forceCheck | boolean |
Returns
void
setCountStatus optional
setCountStatus(status: DataSourceStatus): void
Update data source count status.
Parameters
Parameter | Type |
---|---|
status | DataSourceStatus |
Returns
void
setDataSourceJson
setDataSourceJson(dsJson: IMDataSourceJson): void
Update data source JSON in data source instance
Parameters
Parameter | Type |
---|---|
dsJson | IMDataSourceJson |
Returns
void
setListenSelection
setListenSelection(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
Update the records in the data source object only, does not update the source data. See DataSourceEditSourceOperations.updateRecords
Parameters
Parameter | Type |
---|---|
records | DataRecord[] |
Returns
void
setSourceRecords
setSourceRecords(records: DataRecord[]): void
When current data source is created from an array of records, will save it in sourceRecords
.
These two methods are use to update or get the source data.
Parameters
Parameter | Type |
---|---|
records | DataRecord[] |
Returns
void
setStatus optional
setStatus(status: DataSourceStatus): void
Update data source status.
Parameters
Parameter | Type |
---|---|
status | DataSourceStatus |
Returns
void
updateQueryParams
updateQueryParams(query: QueryParams, widgetId: string): void
Update the data source query without executing the actual query.
Parameters
Parameter | Type |
---|---|
query | QueryParams |
widgetId | string |
Returns
void
updateSelectionInfo optional
updateSelectionInfo(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[] |
triggerDataSource | DataSource |
forceCheck | boolean |
Returns
void
belongToDataSource: DataSource
The data source which this data source derives from.