Skip to content

Commit 5d449a5

Browse files
author
杜美瑶
committed
新增上传/注册数据API --reviewed by huangqh
1 parent 94d4149 commit 5d449a5

File tree

12 files changed

+305
-3
lines changed

12 files changed

+305
-3
lines changed

src/common/REST.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,4 +1463,43 @@ var EntityType = SuperMap.EntityType = {
14631463
}
14641464
export {
14651465
EntityType
1466+
}
1467+
1468+
/**
1469+
* @enum DataItemType
1470+
* @memberOf SuperMap
1471+
* @description iportal数据类型。
1472+
* @version 10.0.1
1473+
* @type {string}
1474+
*/
1475+
var DataItemType = SuperMap.DataItemType = {
1476+
/** 工作空间 sxwu, smwu, sxw, smw */
1477+
WORKSPACE: "WORKSPACE",
1478+
/** udb 数据源 */
1479+
UDB: "UDB",
1480+
/** shp空间数据 */
1481+
SHP: "SHP",
1482+
/** excel数据 */
1483+
EXCEL: "EXCEL",
1484+
/** csv数据 */
1485+
CSV: "CSV",
1486+
/** geojson数据。 */
1487+
GEOJSON: "GEOJSON",
1488+
/** smtiles */
1489+
SMTILES: "SMTILES",
1490+
/** svtiles */
1491+
SVTILES: "SVTILES",
1492+
/** mbtiles */
1493+
MBTILES: "MBTILES",
1494+
/** tpk */
1495+
TPK: "TPK",
1496+
/** ugc v5 */
1497+
UGCV5: "UGCV5",
1498+
/** UGCV5_MVT */
1499+
UGCV5_MVT: "UGCV5_MVT",
1500+
/** json数据 */
1501+
JSON: "JSON"
1502+
}
1503+
export {
1504+
DataItemType
14661505
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
2+
* This program are made available under the terms of the Apache License, Version 2.0
3+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4+
import {SuperMap} from '../SuperMap';
5+
import {Util} from '../commontypes/Util';
6+
7+
/**
8+
* @class SuperMap.iPortalAddDataParam
9+
* @classdesc iPortal 上传/注册数据所需的参数。
10+
* @version 10.0.1
11+
* @category iPortal/Online
12+
* @param {Object} params - iPortal 上传/注册数据所需的具体参数。
13+
* @param {string} params.fileName - 文件名称
14+
* @param {SuperMap.DataItemType} params.type - 数据类型。
15+
* @param {Array} [params.tags] - 数据的标签
16+
* @param {SuperMap.iPortalDataMetaInfoParam} [params.dataMetaInfo] - 数据元信息
17+
*/
18+
export class IPortalAddDataParam {
19+
20+
constructor(params) {
21+
params = params || {};
22+
this.fileName = "";
23+
this.type = "";
24+
this.tags = [];
25+
this.dataMetaInfo = {};
26+
Util.extend(this, params);
27+
}
28+
}
29+
SuperMap.iPortalAddDataParam = IPortalAddDataParam;
30+
31+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
2+
* This program are made available under the terms of the Apache License, Version 2.0
3+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4+
import {SuperMap} from '../SuperMap';
5+
import {Util} from '../commontypes/Util';
6+
7+
/**
8+
* @class SuperMap.iPortalDataConnectionInfoParam
9+
* @classdesc iPortal HBASE数据源连接信息类。
10+
* @version 10.0.1
11+
* @category iPortal/Online
12+
* @param {Object} params - iPortal HBASE数据源连接信息类具体参数。
13+
* @param {string} params.dataBase - 数据源连接的数据库名。
14+
* @param {string} params.server - 服务地址。
15+
*/
16+
export class IPortalDataConnectionInfoParam {
17+
18+
constructor(params) {
19+
params = params || {};
20+
this.dataBase = "";
21+
this.server = "";
22+
Util.extend(this, params);
23+
}
24+
}
25+
SuperMap.iPortalDataConnectionInfoParam = IPortalDataConnectionInfoParam;
26+
27+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
2+
* This program are made available under the terms of the Apache License, Version 2.0
3+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4+
import {SuperMap} from '../SuperMap';
5+
import {Util} from '../commontypes/Util';
6+
7+
/**
8+
* @class SuperMap.iPortalDataMetaInfoParam
9+
* @classdesc iPortal 上传数据/注册数据元信息所需的参数。
10+
* @version 10.0.1
11+
* @category iPortal/Online
12+
* @param {Object} params - iPortal 获取数据项id excel csv类型的数据所需数据元信息具体参数。
13+
* @param {string} params.xField - X 坐标字段
14+
* @param {string} params.yField - Y 坐标字段
15+
* @param {number} params.xIndex - x所在列(关系型存储下CSV或EXCEL数据时必填)
16+
* @param {number} params.yIndex - y所在列(关系型存储下CSV或EXCEL数据时必填)
17+
* @param {array} [params.fieldTypes] - 设置字段类型(关系型存储下CSV或EXCEL数据时可选填)。默认类型为:WTEXT。该参数按照CSV文件字段顺序从左到右依次设置,其中默认字段类型可省略不设置。例如,CSV文件中有10个字段,如果只需设定第1,2,4个字段,可设置为[a,b,,c]。
18+
* @param {string} params.separator - 分隔符(关系型存储下CSV数据时必填)
19+
* @param {boolean} params.firstRowIsHead - 是否带表头(关系型存储下CSV数据时必填)
20+
* @param {boolean} params.url - HDFS注册目录地址
21+
* @param {SuperMap.iPortalDataStoreInfoParam} params.dataStoreInfo - 注册数据时的数据存储信息
22+
*/
23+
export class IPortalDataMetaInfoParam {
24+
25+
constructor(params) {
26+
params = params || {};
27+
this.xField = "";
28+
this.yField = "";
29+
this.fileEncoding = "UTF-8";
30+
31+
this.xIndex = 1;
32+
this.yIndex = 1;
33+
this.fieldTypes = [];
34+
this.separator = "";
35+
this.firstRowIsHead = true;
36+
37+
this.url = "";
38+
this.dataStoreInfo = {};
39+
Util.extend(this, params);
40+
}
41+
}
42+
SuperMap.iPortalDataMetaInfoParam = IPortalDataMetaInfoParam;
43+
44+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
2+
* This program are made available under the terms of the Apache License, Version 2.0
3+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4+
import {SuperMap} from '../SuperMap';
5+
import {Util} from '../commontypes/Util';
6+
7+
/**
8+
* @class SuperMap.iPortalDataStoreInfoParam
9+
* @classdesc iPortal 注册一个HBASE HDFS数据存储类。
10+
* @version 10.0.1
11+
* @category iPortal/Online
12+
* @param {Object} params - iPortal 注册一个HBASE HDFS数据存储类具体参数。
13+
* @param {string} params.type - 大数据文件共享类型和空间数据库类型,包括大数据文件共享HDFS 目录(HDFS)和空间数据库HBASE
14+
* @param {string} params.url - HDFS数据存储目录地址
15+
* @param {SuperMap.iPortalDataConnectionInfoParam} [params.connectionInfo] - HBASE空间数据库服务的连接信息
16+
*/
17+
export class IPortalDataStoreInfoParam {
18+
19+
constructor(params) {
20+
params = params || {};
21+
this.type = "";
22+
this.url = "";
23+
this.connectionInfo = {};
24+
Util.extend(this, params);
25+
}
26+
}
27+
SuperMap.iPortalDataStoreInfoParam = IPortalDataStoreInfoParam;
28+
29+

src/common/iPortal/iPortalUser.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import {SuperMap} from '../SuperMap';
55
import {IPortalServiceBase} from './iPortalServiceBase';
66
import {IPortalAddResourceParam} from './iPortalAddResourceParam';
77
import {IPortalRegisterServiceParam} from "./iPortalRegisterServiceParam";
8+
import { IPortalAddDataParam } from "./iPortalAddDataParam";
9+
import { IPortalDataMetaInfoParam } from "./iPortalDataMetaInfoParam";
10+
import { IPortalDataStoreInfoParam } from "./iPortalDataStoreInfoParam";
11+
import { IPortalDataConnectionInfoParam } from "./iPortalDataConnectionInfoParam";
812
/**
913
* @class SuperMap.iPortalUser
1014
* @classdesc iPortal 门户中用户信息的封装类。用于管理用户资源,包括可删除,添加资源。
@@ -117,6 +121,98 @@ export class IPortalUser extends IPortalServiceBase {
117121
resolve(errMsg);
118122
})
119123
}
124+
125+
/**
126+
* @function SuperMap.iPortalUser.prototype.uploadDataRequest
127+
* @description 上传数据。
128+
* @param {number} id - 上传数据的资源id。
129+
* @param {Object} formData - 请求体为文本数据流。
130+
* @returns {Promise} 返回包含上传数据操作的 Promise 对象。
131+
*/
132+
uploadDataRequest(id,formData) {
133+
var uploadDataUrl = this.iportalUrl + "/web/mycontent/datas/"+id+"/upload.json";
134+
return this.request("POST",uploadDataUrl,formData);
135+
}
136+
137+
/**
138+
* @function SuperMap.iPortalUser.prototype.addData
139+
* @description 上传/注册数据。
140+
* @param {SuperMap.iPortalAddDataParam} params - 上传/注册数据所需的参数。
141+
* @param {Object} [formData] - 请求体为文本数据流(上传数据时传入)。
142+
* @returns {Promise} 返回上传/注册数据的 Promise 对象。
143+
*/
144+
addData(params,formData) {
145+
if(!(params instanceof IPortalAddDataParam)){
146+
this.getErrMsgPromise("params is not instanceof iPortalAddDataParam !");
147+
}
148+
var datasUrl = this.iportalUrl + "/web/mycontent/datas.json";
149+
var entity = {
150+
fileName:params.fileName,
151+
tags:params.tags,
152+
type:params.type
153+
};
154+
var type = params.type.toLowerCase();
155+
var dataMetaInfo;
156+
if(type === "excel" || type === "csv"){
157+
if(!(params.dataMetaInfo instanceof IPortalDataMetaInfoParam)){
158+
this.getErrMsgPromise("params.dataMetaInfo is not instanceof iPortalDataMetaInfoParam !");
159+
}
160+
dataMetaInfo = {
161+
xField:params.dataMetaInfo.xField,
162+
yField:params.dataMetaInfo.yField
163+
}
164+
if(type === 'csv') {
165+
dataMetaInfo.fileEncoding = params.dataMetaInfo.fileEncoding
166+
}
167+
entity.coordType = "WGS84";
168+
entity.dataMetaInfo = dataMetaInfo;
169+
}else if(type === "hdfs" || type === "hbase") {
170+
if(!(params.dataMetaInfo instanceof IPortalDataMetaInfoParam)){
171+
this.getErrMsgPromise("params.dataMetaInfo is not instanceof iPortalDataMetaInfoParam !");
172+
}
173+
if(!(params.dataMetaInfo.dataStoreInfo instanceof IPortalDataStoreInfoParam)){
174+
this.getErrMsgPromise("params.dataMetaInfo.dataStoreInfo is not instanceof iPortalDataStoreInfoParam !");
175+
}
176+
var dataStoreInfo = {
177+
type:params.dataMetaInfo.dataStoreInfo.type
178+
}
179+
switch (type) {
180+
case "hdfs":
181+
dataStoreInfo.url = params.dataMetaInfo.dataStoreInfo.url;
182+
dataMetaInfo = {
183+
url: params.dataMetaInfo.url,
184+
dataStoreInfo:dataStoreInfo
185+
}
186+
break;
187+
case "hbase":
188+
if(!(params.dataMetaInfo.dataStoreInfo.connectionInfo instanceof IPortalDataConnectionInfoParam)){
189+
this.getErrMsgPromise("params.dataMetaInfo.dataStoreInfo.connectionInfo is not instanceof iPortalDataConnectionInfoParam !");
190+
}
191+
dataStoreInfo.connectionInfo = {
192+
dataBase:params.dataMetaInfo.dataStoreInfo.connectionInfo.dataBase,
193+
server:params.dataMetaInfo.dataStoreInfo.connectionInfo.server,
194+
engineType:'HBASE'
195+
}
196+
dataStoreInfo.datastoreType = "SPATIAL";//该字段SPATIAL表示HBASE注册
197+
dataMetaInfo = {
198+
dataStoreInfo:dataStoreInfo
199+
}
200+
break;
201+
}
202+
entity.dataMetaInfo = dataMetaInfo;
203+
}
204+
return this.request("POST",datasUrl,JSON.stringify(entity)).then(res=>{
205+
if(type === "hdfs" || type === "hbase"){
206+
return res;
207+
}else {
208+
if(res.childID) {
209+
return this.uploadDataRequest(res.childID,formData);
210+
}else {
211+
return res.customResult;
212+
}
213+
}
214+
})
215+
}
120216
}
121217

122218
SuperMap.iPortalUser = IPortalUser;

src/common/iPortal/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import {IPortalServiceBase} from './iPortalServiceBase';
1111
import {IPortalUser} from "./iPortalUser";
1212
import {IPortalAddResourceParam} from "./iPortalAddResourceParam";
1313
import {IPortalRegisterServiceParam} from "./iPortalRegisterServiceParam";
14+
import {IPortalAddDataParam} from "./iPortalAddDataParam";
15+
import {IPortalDataMetaInfoParam} from "./iPortalDataMetaInfoParam";
16+
import {IPortalDataStoreInfoParam} from "./iPortalDataStoreInfoParam";
17+
import {IPortalDataConnectionInfoParam} from "./iPortalDataConnectionInfoParam";
1418

1519
export {IPortal} ;
1620
export {IPortalQueryParam};
@@ -21,4 +25,8 @@ export {IPortalShareEntity};
2125
export {IPortalServiceBase};
2226
export {IPortalUser};
2327
export {IPortalAddResourceParam};
24-
export {IPortalRegisterServiceParam};
28+
export {IPortalRegisterServiceParam};
29+
export {IPortalAddDataParam};
30+
export {IPortalDataMetaInfoParam};
31+
export {IPortalDataStoreInfoParam};
32+
export {IPortalDataConnectionInfoParam};

src/common/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ import {
105105
IPortalServiceBase,
106106
IPortalUser,
107107
IPortalAddResourceParam,
108-
IPortalRegisterServiceParam
108+
IPortalRegisterServiceParam,
109+
IPortalAddDataParam,
110+
IPortalDataMetaInfoParam,
111+
IPortalDataStoreInfoParam,
112+
IPortalDataConnectionInfoParam
109113
} from './iPortal';
110114
import {
111115
AddressMatchService,
@@ -570,7 +574,11 @@ export {
570574
IPortalServiceBase,
571575
IPortalUser,
572576
IPortalAddResourceParam,
573-
IPortalRegisterServiceParam
577+
IPortalRegisterServiceParam,
578+
IPortalAddDataParam,
579+
IPortalDataMetaInfoParam,
580+
IPortalDataStoreInfoParam,
581+
IPortalDataConnectionInfoParam
574582
};
575583
export {
576584
AddressMatchService,

src/leaflet/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ import {
7777
IPortalUser,
7878
IPortalAddResourceParam,
7979
IPortalRegisterServiceParam,
80+
IPortalAddDataParam,
81+
IPortalDataMetaInfoParam,
82+
IPortalDataStoreInfoParam,
83+
IPortalDataConnectionInfoParam,
8084
//Online
8185
Online,
8286
OnlineData,
@@ -534,6 +538,10 @@ export {
534538
IPortalUser,
535539
IPortalAddResourceParam,
536540
IPortalRegisterServiceParam,
541+
IPortalAddDataParam,
542+
IPortalDataMetaInfoParam,
543+
IPortalDataStoreInfoParam,
544+
IPortalDataConnectionInfoParam,
537545
//Online
538546
Online,
539547
OnlineData,

src/mapboxgl/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ export {
7777
IPortalUser,
7878
IPortalAddResourceParam,
7979
IPortalRegisterServiceParam,
80+
IPortalAddDataParam,
81+
IPortalDataMetaInfoParam,
82+
IPortalDataStoreInfoParam,
83+
IPortalDataConnectionInfoParam,
8084
//Online
8185
Online,
8286
OnlineData,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy