页面树结构

版本比较

标识

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

...

Markdown
## 更新数据模型


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

```java
import smartbi.net.sf.json.JSONObject;
import smartbi.sdk.ClientConnector;
import smartbi.sdk.InvokeResult;

public class DataModelDemo {

        public static void main(String[] args) {
        // 用户名
        String user = "admin";
        // 密码
        String password = "admin";
        // Smartbi链接http://10.10.35.85:18080/smartbi
        String smartbiURL = "http://localhost:8080/smartbi";
        // 创建Smartbi链接对象
        ClientConnector conn = new ClientConnector(smartbiURL);
        // 建立此连接时,就对smartbi进行了登录
        boolean ret = conn.open(user, password);
        String str = "参考下面post的内容";
        // post的内容说明,参考接口调用-方式2的说明
        JSONObject obj = JSONObject.fromString(str);
        // 更新模型
		InvokeResult res = conn.remoteInvoke("AugmentedDataSetForVModule", "update", new Object[]{obj});
        conn.close();
        }
}
```
- <strong>接口调用-方式2(仅支持在已登录的情况下)</strong>

<u>http://host:port/smartbi/smartbix/</u><u>api</u><u>/dataModel?_method=PUT</u>

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

POST

- <strong>返回值</strong>

数据模型 CheckResult

### <strong>示例</strong>

![](https://wiki.smartbi.com.cn/download/attachments/115002507/VfVIbeCmOoMy8Rx2agzcoPFrn2e.png)

```json
{  
        "id": "I8a8a9fb601832a882a883ce901832afa40850018",
        "name": "ModelDemo",
        "alias": "模型示例",
        "views": [{
                "name": "orderdetails",
                "alias": "订单明细表",
                "type": "BASIC_TABLE",
                "define": {
                        "tableId": "TAB.northwind.null.orderdetails"
                }
        },{
                "name": "orders",
                "alias": "订单表",
                "type": "BASIC_TABLE",
                "define": {
                        "tableId": "TAB.northwind.null.orders"
                }
        }],
        "hierarchies": [{
            "name":"hierArea",
            "alias": "地区",
            "levels": [
                {
                    "viewName": "orders",
                    "name": "ShipRegionLevel",
                    "alias": "区域",
                    "fieldName": "ShipRegion",
                    "levelType": "LEVEL"
                },
                {
                    "viewName": "orders",
                    "name": "ShipProvinceLevel",
                    "alias": "省份",
                    "fieldName": "ShipProvince",
                    "levelType": "LEVEL"
                },
                {
                    "viewName": "orders",
                    "name": "ShipCityLevel",
                    "alias": "城市",
                    "fieldName": "ShipCity",
                    "levelType": "LEVEL"
                }
            ]
        }],
        "dateHierarchies": [{
            "name":"hierDate",
            "alias": "时间维度",
            "levels": [
                {
                    "viewName": "orders",
                    "name": "orderYear",
                    "alias": "年",
                    "fieldName": "OrderDate",
                    "levelType": "LEVEL_TIME_YEAR"
                },
                {
                    "viewName": "orders",
                    "name": "orderQuarter",
                    "alias": "季",
                    "fieldName": "OrderDate",
                    "levelType": "LEVEL_TIME_QUARTER"
                },
                {
                    "viewName": "orders",
                    "name": "orderMonth",
                    "alias": "月",
                    "fieldName": "OrderDate",
                    "levelType": "LEVEL_TIME_MONTH"
                },
                {
                    "viewName": "orders",
                    "name": "orderWeek",
                    "alias": "周",
                    "fieldName": "OrderDate",
                    "levelType": "LEVEL_TIME_WEEK"
                },
                {
                    "viewName": "orders",
                    "name": "orderDay",
                    "alias": "日",
                    "fieldName": "OrderDate",
                    "levelType": "LEVEL_TIME_DAY"
                }
            ]
        }],
        "dimensions":[{
                "name": "ShipRegion",
                "alias": "区域",
                "viewName": "orders",
                "fieldName": "ShipRegion",
                "valueType": "STRING"
        }],
        "relationGraph": {
                "relations": [{
                        "srcViewName": "orderdetails",
                        "destViewName": "orders",
                        "linkType": "LEFTJOIN",
                        "fieldRelations": [{
                                "srcFieldName": "OrderID",
                                "destFieldName": "OrderID"
                        }]
                }]
        },
        "measures": [{
                "name": "Quantity",
                "alias": "Quantity",
                "viewName": "orderdetails",
                "aggregator": "sum",
                "fieldName": "Quantity"
        },{
                "name": "UnitPrice",
                "alias": "UnitPrice",
                "viewName": "orderdetails",
                "aggregator": "sum",
                "fieldName": "UnitPrice"
        }],
        "calcMeasures": [
            {
                "name":"calc1",
                "alias":"数量加1",
                "expression": "[Measures].[Quantity] + 1"
            }
        ],
        "calcMembers": [
            {
                "name":"north",
                "alias":"北方",
                "expression": "[hierArea].[东北] + [hierArea].[华北]",
                "hierName": "[ShipRegion]"
            }
        ]
}
```

- <strong>接口参数及其说明</strong>

<strong>同创建模型</strong>
https参考(创建模型中的"接口参数及其说明"):https://wiki.smartbi.com.cn/pages/viewpage.action?smt_poid=43&pageId=136905783中的"接口参数及其说明"136905783