页面树结构

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

...

##

...

<strong>创建SQL查询</strong>

...


-

...

<strong>接口调用-方式1</strong>

...

```java

...


/**

...


 *

...

创建业务视图-SQL查询示例

...


 */

...


public

...

class

...

createBizViewDemo

...

{

...


public

...

static

...

void

...

main(String[]

...

args)

...

{

...


String

...

user

...

=

...

"admin";

...

//

...

用户名

...


String

...

password

...

=

...

"admin";

...

//

...

密码

...


String

...

smartbiURL

...

=

...

"http://10.10.31.49:11000/smartbi";

...

//

...

Smartbi链接

...


ClientConnector

...

conn

...

=

...

null;

...


try

...

{

...


conn

...

=

...

new

...

ClientConnector(smartbiURL);

...

//

...

创建Smartbi链接对象

...


//

...

建立此连接时,就对smartbi进行了登录

...


conn.open(user,

...

password);

...


//

...

POST请求的请求体
// pid必须是数据源中业务视图下的节点,包括业务视图节点和目录节点
String body = "{\r\n"

...

+

...

"\"pid\":

...

\"I8a8a4ca2017a18e018e0a2b3017a19209a7c13a3\",\r\n"

...


+ "    \"name\":

...

\"SQL查询1\",\r\n"

...

+

...

"    \"alias\":

...

\"SQL查询1\",\r\n"

...


+ "    \"sql\":

...

\"select

...

OrderID

...

as

...

a

...

from

...

orders\"\r\n"

...

+

...

"}";

...


JSONObject

...

json

...

=

...

JSONObject.fromString(body);

...


//

...

创建业务视图-SQL查询

...


InvokeResult

...

result

...

=

...

conn.remoteInvoke("AugmentedDataSetForVModule",

...

"createDataModelBizView",

...


new Object[]

...

{

...

json

...

});

...


if

...

(result

...

!=

...

null

...

&&

...

result.isSucceed())

...

{

...


JSONObject

...

object

...

=

...

JSONObject.fromObject(result.getResult());

...


String

...

id

...

=

...

(String)

...

object.optString("id");

...


System.out.println("SQL查询的id:

...

"

...

+

...

id);

...


}
} finally {
if (conn != null) {
conn.close();

...


}
}
}
}

```
- <strong>接口调用-方式2(仅支持在已登录的情况下)</strong>

...

http://host:port/smartbi/smartbix/api/dataModel/createBizView

...

-

...

<strong>接口请求类型</strong>

...

POST

...


-

...

<strong>输入</strong>

...


|

...

<strong>属性</strong>

...

|

...

<strong>类型</strong>

...

|

...

<strong>说明</strong>                    |
| ---------------------

...

|

...

---------------------

...

|

...

----------------------------------------

...

|

...


| pid                    | Stirng                | 业务视图在哪个节点下创建,必须是数据源中业务视图下的节点,包括业务视图节点和目录节点 |
| id | String                | 指定业务视图的id,不传递时自动生成      |
| name            | String                | 业务视图的名称 |
| alias          | String                | 业务视图的别名 |
| sql          | String                | 业务视图的sql |

- <strong>返回值</strong>

CheckResult

| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong>                    |
| ---------------------

...

|

...

---------------------

...

|

...

----------------------------------------

...

|

...


| id                    | Stirng                | SQL查询 id                                  |
| errorCode             | String                | 错误码,成功时错误码、错误信息同时为空   |
| errorMessage          | String                | 错误信息,成功时错误码、错误信息同时为空 |
| detail         | String                | 错误详细信息,成功时错误码、错误信息同时为空 |

### <strong>简单示例</strong>

![]()

```json
{
    "pid": "I8a8a9fdb019623f123f1661a0196241badee0001",
    "id": "I8a8a9fb101963dde3dde87220196425521b7000a",
    "name": "SQL查询",
    "alias": "SQL查询",
    "sql": "select OrderID as a from orders"
}
```