Skip to main content
Pentaho Documentation

CdaQuery

cdf.queries.CdaQuery

 
Static

Class that represents a CDA query. This class will be registered globally using the static dashboard function registerGlobalQuery.

The constructor of this class is created dynamically and registered in the dashboard query container queryFactories.

To create a new CDA query use the dashboard function getQuery.

Source: queries/CdaQuery.js, line 24

Example

dashboard.addDataSource("myCdaQuery", {
 queryType: "cda", dataAccessId: "cdaQuery", path: "/public/myQ.cda"
});
dashboard.getQuery({dataSource: "myCdaQuery"}).doQuery(successCallback, errorCallback);

Members

Name Description
dashboard : cdf.dashboard.Dashboard
 
Protected

A reference to the dashboard instance.

deepProperties : Array.<String>
 
Constant
 
Protected

A list of properties to be extended to the registered queries.

defaults : Object
 
Protected

The default properties.

interfaces : Object
 
Protected

The default interfaces.

label : String
 
Constant
 
Protected

The class label.

name : String
 
Constant
 
Protected

The class name.

Methods

Name Description
buildQueryDefinition(overrides) : Object

Builds the query definition object.

doQuery(successCallback, errorCallback)

Executes a server-side query.

exportData(outputType, overrides, options)

Exports the data, according to a specific output type.

fetchData(params, successCallback, errorCallback) : Object

Fetches the data.

getErrorHandler(callback) : Function

Gets the error callback handler.

getOption(prop) : Object

Gets an option (fallback for when the OptionManager is not available).

getPage(targetPage, outsideCallback) : Boolean | Object

Gets the set of results for the page at index targetPage (0-indexed).

getSuccessHandler(callback) : Function

Gets the success callback handler.

init(opts)

Initializes a CDA query.

initPage(pageSize, outsideCallback) : Boolean | Object

Sets the page size and gets the first page of results.

lastProcessedResults() : Object

Gets the last retrieved result after being processed by postFetch.

lastResults() : Object

Gets the last retrieved result.

nextPage(outsideCallback) : Object

Gets the next page of results, as controlled by the pageSize option.

pageStartingAt(page, outsideCallback) : Boolean | Object

Runs the query, setting a starting page before doing so.

previousPage(outsideCallback) : Object

Gets the previous page of results, as controlled by the pageSize option.

reprocessLastResults(outerCallback) : Object

Reruns the success callback on the last retrieved result set from the server.

reprocessResults(outsideCallback) : Object

Alias for reprocessLastResults.

setAjaxOptions(newOptions)

Sets the jQuery.ajax options for the query.

setCallback(callback)

Sets the success callback for the query.

setErrorCallback(callback)

Sets the error callback for the query.

setOption(prop, value)

Sets an option (fallback for when the OptionManager is not available).

setPageSize(pageSize)

Sets the page size.

setPageStartingAt(targetPage) : Boolean

Sets the starting page for later executions of the query.

setParameters(params)

Sets query parameters.

setSearchPattern(pattern)

Sets the search pattern for the query.

setSortBy(sortBy) : Boolean

Sets the sort by columns.

sortBy(sortBy, outsideCallback) : Boolean | Object

Sorts the result set.

Members Details

dashboard: cdf.dashboard.Dashboard
 
Protected

A reference to the dashboard instance.

Source: queries/BaseQuery.js, line 69

Inherited From: cdf.queries.BaseQuery#dashboard

deepProperties: Array.<String>
 
Constant
 
Protected

A list of properties to be extended to the registered queries that do not provide their own constructor function.

Source: queries/BaseQuery.js, line 60

Inherited From: cdf.queries.BaseQuery#deepProperties

Default Value:

["defaults","interfaces"]

See also:  registerQuery

defaults: Object
 
Protected

The default properties.

Properties:
Name Default Value Description
url : String  

The target endpoint URL.

file : String ""

The target file name.

id : String ""

The target identifier.

outputIdx : String "1"

The default output index.

sortBy : String ""

The default sorting order.

ajaxOptions : Object {async:true,xhrFields:{withCredentials:true}}

The jQuery.ajax options for the query.

searchPattern : String ""

The default search pattern.

Source: queries/CdaQuery.js, line 82

Overrides: cdf.queries.BaseQuery#defaults

interfaces: Object
 
Protected

The default interfaces.

Properties:
Name Default Value Description
params : Object  

Parameter interfaces.

Properties:
Name Default Value Description
reader : String "propertiesObject"

Parameter reader.

validator : String "isObjectOrPropertiesArray"

Parameter validator.

successCallback : Object  

Success callback interfaces.

Properties:
Name Default Value Description
validator : String "isFunction"

Success callback validator.

errorCallback : Object  

Error callback interfaces.

Properties:
Name Default Value Description
validator : String "isFunction"

Error callback validator.

pageSize : Object  

Page size interfaces.

Properties:
Name Default Value Description
validator : String "isPositive"

Page size validator.

Source: queries/BaseQuery.js, line 127

Inherited From: cdf.queries.BaseQuery#interfaces

label: String
 
Constant
 
Protected

The class label.

Source: queries/CdaQuery.js, line 66

Default Value: "CDA Query"

Overrides: cdf.queries.BaseQuery#label

name: String
 
Constant
 
Protected

The class name.

Source: queries/CdaQuery.js, line 54

Default Value: "cda"

Overrides: cdf.queries.BaseQuery#name

Methods Details

buildQueryDefinition(overrides) : Object

Builds the query definition object.

Source: queries/CdaQuery.js, line 136

Overrides: cdf.queries.BaseQuery#buildQueryDefinition

Parameters:
Name Default Value Summary
overrides : Object  

New query definitions to override any existing query definitions.

Returns:
Name Description
Object

Query definition object.

doQuery(successCallback, errorCallback)

Executes a server-side query.

Source: queries/BaseQuery.js, line 257

Inherited From: cdf.queries.BaseQuery#doQuery

Parameters:
Name Default Value Summary
successCallback : Function  

Success callback.

errorCallback : Function  

Error callback.

exportData(outputType, overrides, options)

Exports the data, according to a specific output type.

Source: queries/CdaQuery.js, line 196

Overrides: cdf.queries.BaseQuery#exportData

Parameters:
Name Default Value Summary
outputType : String  

Output type (CSV, XLS, XML, HTML).

overrides : Object  

Overrides for the query definition object.

options : Object  

Export options.

Parameters:
Name Default Value Summary
separator : String  

Separator.

filename : String  

File name.

template : String  

Template name.

columnHeaders : Object  

The column headers.

dtFilter : Object  

Data table filter.

dtSearchableColumns : Object  

Data table searchable columns.

fetchData(params, successCallback, errorCallback) : Object

Fetches the data.

Source: queries/BaseQuery.js, line 331

Inherited From: cdf.queries.BaseQuery#fetchData

Parameters:
Name Default Value Summary
params : Object  

Parameters for the query.

successCallback : Function  

Success callback.

errorCallback : Function  

Error callback.

Returns:
Name Description
Object

The result of calling doQuery with the specified arguments.

Throws:
Name Description
InvalidInput

If the arguments are not correct.

getErrorHandler(callback) : Function

Gets the error callback handler that executes the provided callback when the query fails to execute.

Source: queries/BaseQuery.js, line 242

Inherited From: cdf.queries.BaseQuery#getErrorHandler

Parameters:
Name Default Value Summary
callback : Function  

Callback to call if the query fails.

Returns:
Name Description
Function

Error callback handler.

getOption(prop) : Object

Gets an option (fallback for when the OptionManager is not available).

Source: queries/BaseQuery.js, line 172

Inherited From: cdf.queries.BaseQuery#getOption

Parameters:
Name Default Value Summary
prop : String  

The property from where to get the options.

Returns:
Name Description
Object

Value for the option.

getPage(targetPage, outsideCallback) : Boolean | Object

Gets the set of results for the page at index targetPage (0-indexed).

Source: queries/BaseQuery.js, line 545

Inherited From: cdf.queries.BaseQuery#getPage

Parameters:
Name Default Value Summary
targetPage : Number  

Index of the page to get, starting at index 0.

outsideCallback : Function  

Success callback to execute when the page is retrieved.

Returns:
Name Description
Boolean | Object

false if the page is already the current one, otherwise returns the result of calling doQuery.

Throws:
Name Description
InvalidPage

If targetPage is not a positive number.

getSuccessHandler(callback) : Function

Gets the success callback handler that executes the provided callback when the query executes successfully.

Source: queries/BaseQuery.js, line 219

Inherited From: cdf.queries.BaseQuery#getSuccessHandler

Parameters:
Name Default Value Summary
callback : Function  

Callback to call after the query is successful.

Returns:
Name Description
Function

Success callback handler.

init(opts)

Initializes a CDA query.

Source: queries/CdaQuery.js, line 110

Overrides: cdf.queries.BaseQuery#init

Parameters:
Name Default Value Summary
opts : Object  

The query definition object.

Parameters:
Name Default Value Summary
path : String  

The path to the CDA file.

dataAccessId : String  

The Data access identifier.

sortBy : String
 
Optional
 

The sorting order.

pageSize : Number
 
Optional
 

The page size.

outputIndexId : Number
 
Optional
 

The output index identifier.

Throws:
Name Description
InvalidQuery

If the opts parameter does not contain a path nor a data access identifier.

initPage(pageSize, outsideCallback) : Boolean | Object

Sets the page size and gets the first page of results.

Source: queries/BaseQuery.js, line 617

Inherited From: cdf.queries.BaseQuery#initPage

Parameters:
Name Default Value Summary
pageSize : Number  

Page Size.

outsideCallback : Function  

Success callback to execute after query is retrieved.

Returns:
Name Description
Boolean | Object

false if pageSize is invalid, otherwise the result of calling doQuery.

Throws:
Name Description
InvalidPageSize

If the page size is not a positive number.

lastProcessedResults() : Object

Gets the last retrieved result after being processed by postFetch.

Source: queries/BaseQuery.js, line 397

Inherited From: cdf.queries.BaseQuery#lastProcessedResults

Returns:
Name Description
Object

A deep copy of the the last result set obtained from the server after being processed by postFetch.

Throws:
Name Description
NoCachedResults

If there have not been previous calls to the server.

lastResults() : Object

Gets the last retrieved result.

Source: queries/BaseQuery.js, line 381

Inherited From: cdf.queries.BaseQuery#lastResults

Returns:
Name Description
Object

A deep copy of the last result set obtained from the server.

Throws:
Name Description
NoCachedResults

If there have not been previous calls to the server.

nextPage(outsideCallback) : Object

Gets the next page of results, as controlled by the pageSize option.

Source: queries/BaseQuery.js, line 499

Inherited From: cdf.queries.BaseQuery#nextPage

Parameters:
Name Default Value Summary
outsideCallback : Function  

Success callback to execute when the next page of results is retrieved.

Returns:
Name Description
Object

The result of calling doQuery.

Throws:
Name Description
InvalidPageSize

If the page size option is not a positive number.

pageStartingAt(page, outsideCallback) : Boolean | Object

Runs the query, setting a starting page before doing so. If the starting page matches the already selected one, the query run is canceled and false is returned.

Source: queries/BaseQuery.js, line 589

Inherited From: cdf.queries.BaseQuery#pageStartingAt

Parameters:
Name Default Value Summary
page : Number  

Starting page index.

outsideCallback : Function  

Success callback to execute after the server-side query is processed.

Returns:
Name Description
Boolean | Object

false if the query run is canceled, otherwise the result of calling doQuery.

previousPage(outsideCallback) : Object

Gets the previous page of results, as controlled by the pageSize option.

Source: queries/BaseQuery.js, line 520

Inherited From: cdf.queries.BaseQuery#previousPage

Parameters:
Name Default Value Summary
outsideCallback : Function  

Success callback to execute when the previous page of results is retrieved.

Returns:
Name Description
Object

The result of calling doQuery.

Throws:
Name Description
AtBeginning

If current page is the first one.

reprocessLastResults(outerCallback) : Object

Reruns the success callback on the last retrieved result set from the server.

Source: queries/BaseQuery.js, line 414

Inherited From: cdf.queries.BaseQuery#reprocessLastResults

Parameters:
Name Default Value Summary
outerCallback : Function  

Success callback.

Returns:
Name Description
Object

The result of calling the specified callback.

Throws:
Name Description
NoCachedResults

If there have not been previous calls to the server.

See also:  reprocessResults

reprocessResults(outsideCallback) : Object

Alias for reprocessLastResults.

Source: queries/BaseQuery.js, line 439

Inherited From: cdf.queries.BaseQuery#reprocessResults

Parameters:
Name Default Value Summary
outsideCallback : Function  

Success callback.

Returns:
Name Description
Object

The result of calling the specified callback.

Throws:
Name Description
NoCachedResults

If there have not been previous calls to the server.

See also:  reprocessLastResults

setAjaxOptions(newOptions)

Sets the jQuery.ajax options for the query.

Source: queries/BaseQuery.js, line 294

Inherited From: cdf.queries.BaseQuery#setAjaxOptions

Parameters:
Name Default Value Summary
newOptions : Object  

Ajax options to be added.

setCallback(callback)

Sets the success callback for the query.

Source: queries/BaseQuery.js, line 459

Inherited From: cdf.queries.BaseQuery#setCallback

Parameters:
Name Default Value Summary
callback : Function  

The success callback function.

setErrorCallback(callback)

Sets the error callback for the query.

Source: queries/BaseQuery.js, line 469

Inherited From: cdf.queries.BaseQuery#setErrorCallback

Parameters:
Name Default Value Summary
callback : Function  

The error callback function.

setOption(prop, value)

Sets an option (fallback for when the OptionManager is not available).

Source: queries/BaseQuery.js, line 183

Inherited From: cdf.queries.BaseQuery#setOption

Parameters:
Name Default Value Summary
prop : String  

The property for which the value will be set.

value : Object  

Value for the property.

setPageSize(pageSize)

Sets the page size.

Source: queries/BaseQuery.js, line 603

Inherited From: cdf.queries.BaseQuery#setPageSize

Parameters:
Name Default Value Summary
pageSize : Number  

Page size to set.

setPageStartingAt(targetPage) : Boolean

Sets the starting page for later executions of the query.

Source: queries/BaseQuery.js, line 567

Inherited From: cdf.queries.BaseQuery#setPageStartingAt

Parameters:
Name Default Value Summary
targetPage : Number  

Index of the page to get.

Returns:
Name Description
Boolean

true if the page is correctly set, false if the target page is already the selected one.

Throws:
Name Description
InvalidPage

If the page number is not a positive number.

setParameters(params)

Sets query parameters.

Source: queries/BaseQuery.js, line 449

Inherited From: cdf.queries.BaseQuery#setParameters

Parameters:
Name Default Value Summary
params : Object  

The query parameters.

setSearchPattern(pattern)

Sets the search pattern for the query.

Source: queries/BaseQuery.js, line 479

Inherited From: cdf.queries.BaseQuery#setSearchPattern

Parameters:
Name Default Value Summary
pattern : String  

The search pattern.

setSortBy(sortBy) : Boolean

Sets the sort by columns.

CDA expects an array of terms consisting of a number and a letter that's either "A" or "D". Each term denotes, in order, a column number and a sort direction: "0A" would then be sorting the first column ascending, and "1D" would sort the second column in descending order. This function accepts either an array with the search terms, or a comma-separated string with the terms: "0A,1D" would then mean the same as the array ["0A","1D"], which would sort the results first by the first column (ascending), and then by the second column (descending).

Source: queries/CdaQuery.js, line 260

Overrides: cdf.queries.BaseQuery#setSortBy

Parameters:
Name Default Value Summary
sortBy : String | Array.<String>  

Sorting columns order.

Returns:
Name Description
Boolean

true if the sort by condition has changed, false if it remained the same.

Throws:
Name Description
InvalidSortExpression

If the sort by columns are not correctly defined.

sortBy(sortBy, outsideCallback) : Boolean | Object

Sorts the result set. See the notes on sort columns on the setSortBy method.

Source: queries/CdaQuery.js, line 324

Overrides: cdf.queries.BaseQuery#sortBy

Parameters:
Name Default Value Summary
sortBy : String  

Sorting columns order.

outsideCallback : Function  

Callback to call after the sorting has been processed.

Returns:
Name Description
Boolean | Object

false if the sort by conditions have not changed, the result of calling doQuery otherwise.