saiku前端query.js
2016-05-30 10:49
567 查看
/* * Copyright 2012 OSBI Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Workspace query */ var Query = Backbone.Model.extend({ formatter: Settings.CELLSET_FORMATTER, properties: null, //初始化 <span style="font-size:18px;color:#ff0000;">initialize:</span> function(args, options) { // Save cube _.extend(this, options); // Bind `this`运行查询,维度移动改变等查询方法 _.bindAll(this, <span style="font-size:18px;">"<span style="color:#ff0000;">run</span>", "<span style="color:#ff0000;">move_dimension</span>", "<span style="color:#ff0000;">reflect_properties</span>"</span>); <span style="font-size:18px;"> <span style="color:#ff0000;">// Generate a unique query id 交互编号ID,查询ID this.uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,</span></span><span style="color:#ff0000;"> </span> function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }).toUpperCase(); <span style="font-size:18px;color:#ff0000;">// Initialize properties, action handler, and result handler查询参数设置和返回程序</span> this.action = new QueryAction({}, { query: this }); this.result = new Result({ limit: Settings.RESULT_LIMIT }, { query: this }); this.scenario = new QueryScenario({}, { query: this }); this.set({type:'QM'}); }, parse: function(response) { // Assign id so Backbone knows to PUT instead of POST this.id = this.uuid; this.set({ connection: response.cube.connectionName, catalog: response.cube.catalogName, schema: response.cube.schemaName, cube: encodeURIComponent(response.cube.name), axes: response.saikuAxes, type: response.type }); if (typeof response.properties != "undefined" && "saiku.ui.formatter" in response.properties) { this.set({formatter : response.properties['saiku.ui.formatter']}); } this.properties = new Properties(response.properties, { query: this }); this.reflect_properties(); }, reflect_properties: function() { this.workspace.trigger('properties:loaded'); }, setProperty: function(key, value) { if (typeof this.properties != "undefined" && this.properties.properties ) { this.properties.properties[key] = value; } }, <span style="font-size:18px;color:#ff0000;">//页面查询绿色箭头执行查询方法 run: function(force, mdx)</span> { // Check for automatic execution Saiku.ui.unblock(); if (typeof this.properties != "undefined" && this.properties.properties['saiku.olap.query.automatic_execution'] === 'false'&& ! (force === true)) { return; } this.workspace.unblock(); $(this.workspace.el).find(".workspace_results_info").empty(); this.workspace.trigger('query:run'); this.result.result = null; // TODO - Validate query // maybe we should sync it with the backend query JSON? // this definitely needs improvement if (this.get('type') != "MDX") { var rows = $(this.workspace.el).find('.rows ul li').size(); var columns = $(this.workspace.el).find('.columns ul li').size(); if ((rows == 0 && columns == 0) && !this.workspace.other_dimension) { var axes = this.get('axes'); if (axes) { for (var axis_iter = 0; axis_iter < axes.length; axis_iter++) { var axis = axes[axis_iter]; if (axis.name && axis.name == "ROWS") { rows = axis.dimensionSelections.length; } if (axis.name && axis.name == "COLUMNS") { columns = axis.dimensionSelections.length; } } } } if (rows == 0 || columns == 0) { $(this.workspace.table.el).html(''); $(this.workspace.processing).html('<span class="i18n">You need to put at least one level or measure on Columns and Rows for a valid query.</span>').show(); this.workspace.adjust(); Saiku.i18n.translate(); return; } } // Run it $(this.workspace.table.el) .html(''); $(this.workspace.processing).html('<span class="processing_image"> </span> <span class="i18n">Running query...</span> [ <a class="cancel i18n" href="#cancel">Cancel</a> ]').show(); this.workspace.adjust(); this.workspace.trigger('query:fetch'); Saiku.i18n.translate(); // <a class="cancel" href="#cancel">x</a> var message = '<span class="processing_image"> </span> <span class="i18n">Running query...</span> [ <a class="cancel i18n" href="#cancel">Cancel</a> ]'; this.workspace.block(message); if (this.get('type') == "MDX" && mdx != null) { this.result.save({ mdx: mdx}); } else { this.result.fetch(); } }, <span style="font-size:18px;color:#ff0000;">//页面维度发生变化时调用该方法查询 move_dimension: function(dimension, target, index)</span> { $(this.workspace.el).find('.run').removeClass('disabled_toolbar'); var url = "/axis/" + target + "/dimension/" + dimension; this.action.post(url, { data: { position: index }, success: function() { if (('MODE' in Settings && (Settings.MODE == 'view' || Settings.MODE == 'table')) || (typeof this.query.properties != "undefined" && this.query.properties .properties['saiku.olap.query.automatic_execution'] === 'true')) { this.query.run(true); } } }); }, <span style="color:#cc0000;"> </span><span style="font-size:18px;color:#ff0000;">url: function() { return encodeURI(Saiku.session.username + "/query/" + this.uuid); }</span> });URL:查询连接串示例:http://localhost:8080/saiku/rest/saiku/anonymousUser/query/4FF7D01E-8A6B-5EB4-991B-C0CE680A4BCA/result/flat
相关文章推荐
- 开源MySQL高效数据仓库解决方案:Infobright详细介绍
- mysql bin_log 日志格式详解
- 基于数据仓库的证券CRM系统建设
- 异地容灾系统和数据仓库中数据同步的设计及其关键技术实现
- BI实战案例第2季:权限控制之“非礼勿视”
- 深入了解当前ETL中用到的一些基本技术
- 维度表和事实表
- 星型模型和雪花模型 .
- 关于ETL
- Infobright高性能数据仓库特点
- BI项目中ETL设计与思考【转】
- SYBASE IQ 相关资料
- 数据仓库构建步骤(上)
- 数据仓库构建步骤(下)
- SQL Server 2012 的12个激动人心的功能
- 急聘数据仓库工程师2人——长春
- javap -s 查看java方法签名
- Big Data for BI - 数据采集常见关键字
- wo cao
- c#大数运算