Skip to content

Commit 5ac4ef0

Browse files
committed
1.iPortalUser.js增加-添加场景、添加地图、注册服务接口
2.新增iPortalAddResourceParam和RegisterServiceParam类 --committed by wangzhe,reviewed by huangqh
1 parent 5afaf85 commit 5ac4ef0

File tree

7 files changed

+296
-0
lines changed

7 files changed

+296
-0
lines changed
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.iPortalAddResourceParam
9+
* @classdesc iPortal 添加资源参数。
10+
* @version 10.0.1
11+
* @category iPortal/Online
12+
* @param {Object} params - iPortal 添加资源具体参数。
13+
* @param {String} [params.rootUrl] - 服务地址。
14+
* @param {Array} [params.tags] - 标签。
15+
* @param {SuperMap.iPortalShareEntity} [params.entities] - 资源的实体共享参数
16+
*/
17+
export class IPortalAddResourceParam {
18+
19+
constructor(params) {
20+
params = params || {};
21+
this.rootUrl = "";
22+
this.tags = [];
23+
this.entities = [];
24+
Util.extend(this, params);
25+
}
26+
}
27+
SuperMap.iPortalAddResourceParam = IPortalAddResourceParam;
28+
29+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.iPortalRegisterServiceParam
9+
* @classdesc iPortal 注册服务参数。
10+
* @version 10.0.1
11+
* @category iPortal/Online
12+
* @param {Object} params - iPortal 注册服务具体参数。
13+
* @param {String} [params.type] - 服务类型。
14+
* @param {Array} [params.tags] - 服务标签。
15+
* @param {SuperMap.iPortalShareEntity} [params.entities] - 资源的实体共享参数
16+
* @param {Object} [params.metadata] - 服务元信息。
17+
* @param {Array} [params.addedMapNames] - 地图服务列表。
18+
* @param {Array} [params.addedSceneNames] - 场景服务列表。
19+
*/
20+
export class IPortalRegisterServiceParam {
21+
22+
constructor(params) {
23+
params = params || {};
24+
this.type = ""; // SUPERMAP_REST ARCGIS_REST WMS WFS WCS WPS WMTS OTHERS
25+
this.tags = [];
26+
this.entities = [];
27+
this.metadata = {};
28+
this.addedMapNames = [];
29+
this.addedSceneNames = [];
30+
Util.extend(this, params);
31+
}
32+
}
33+
SuperMap.iPortalRegisterServiceParam = IPortalRegisterServiceParam;
34+
35+

src/common/iPortal/iPortalUser.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44
import {SuperMap} from '../SuperMap';
55
import {IPortalServiceBase} from './iPortalServiceBase';
6+
import {IPortalAddResourceParam} from './iPortalAddResourceParam';
7+
import {IPortalRegisterServiceParam} from "./iPortalRegisterServiceParam";
68
/**
79
* @class SuperMap.iPortalUser
810
* @classdesc iPortal 门户中用户信息的封装类。用于管理用户资源,包括可删除,添加资源。
@@ -33,6 +35,88 @@ export class IPortalUser extends IPortalServiceBase {
3335
}
3436
return this.request("DELETE", deleteResourceUrl);
3537
}
38+
39+
/**
40+
* @function SuperMap.iPortal.prototype.addMap
41+
* @description 添加地图。
42+
* @version 10.0.1
43+
* @param {SuperMap.iPortalAddResourceParam} addMapParams - 添加地图的参数。
44+
* @returns {Promise} 返回包含添加地图结果的 Promise 对象。
45+
*/
46+
addMap(addMapParams) {
47+
if (!(addMapParams instanceof IPortalAddResourceParam)) {
48+
this.getErrMsgPromise("addMapParams is not instanceof IPortalAddResourceParam !");
49+
}
50+
let cloneAddMapParams = {
51+
rootUrl: addMapParams.rootUrl,
52+
tags: addMapParams.tags,
53+
authorizeSetting: addMapParams.entities
54+
}
55+
let addMapUrl = this.iportalUrl + "/web/maps/batchaddmaps.json";
56+
return this.request("POST", addMapUrl, JSON.stringify(cloneAddMapParams)).then(function(result) {
57+
return result;
58+
});
59+
}
60+
61+
/**
62+
* @function SuperMap.iPortal.prototype.addScene
63+
* @description 添加场景。
64+
* @version 10.0.1
65+
* @param {SuperMap.iPortalAddResourceParam} addSceneParams - 添加场景的参数。
66+
* @returns {Promise} 返回包含添加场景结果的 Promise 对象。
67+
*/
68+
addScene(addSceneParams) {
69+
if (!(addSceneParams instanceof IPortalAddResourceParam)) {
70+
this.getErrMsgPromise("addSceneParams is not instanceof IPortalAddResourceParam !");
71+
}
72+
let cloneAddSceneParams = {
73+
rootUrl: addSceneParams.rootUrl,
74+
tags: addSceneParams.tags,
75+
authorizeSetting: addSceneParams.entities
76+
}
77+
let addSceneUrl = this.iportalUrl + "/web/scenes/batchaddscenes.json";
78+
return this.request("POST", addSceneUrl, JSON.stringify(cloneAddSceneParams)).then(function(result) {
79+
return result;
80+
});
81+
}
82+
83+
/**
84+
* @function SuperMap.iPortal.prototype.registerService
85+
* @description 注册服务。
86+
* @version 10.0.1
87+
* @param {SuperMap.iPortalRegisterServiceParam} registerParams - 注册服务的参数。
88+
* @returns {Promise} 返回包含注册服务结果的 Promise 对象。
89+
*/
90+
registerService(registerParams) {
91+
if(!(registerParams instanceof IPortalRegisterServiceParam)) {
92+
this.getErrMsgPromise("registerParams is not instanceof IPortalRegisterServiceParam !");
93+
}
94+
let cloneRegisterParams = {
95+
type: registerParams.type,
96+
tags: registerParams.tags,
97+
authorizeSetting: registerParams.entities,
98+
metadata: registerParams.metadata,
99+
addedMapNames: registerParams.addedMapNames,
100+
addedSceneNames: registerParams.addedSceneNames
101+
}
102+
let registerUrl = this.iportalUrl + "/web/services.json";
103+
return this.request("POST", registerUrl, JSON.stringify(cloneRegisterParams)).then(result => {
104+
return result;
105+
});
106+
}
107+
108+
/**
109+
* @function SuperMap.iPortal.prototype.getErrMsgPromise
110+
* @description 获取包含错误信息的Promise对象。
111+
* @version 10.0.1
112+
* @param {String} errMsg - 传入的错误信息。
113+
* @returns {Promise} 返回包含错误信息的 Promise 对象。
114+
*/
115+
getErrMsgPromise(errMsg) {
116+
return new Promise(resolve => {
117+
resolve(errMsg);
118+
})
119+
}
36120
}
37121

38122
SuperMap.iPortalUser = IPortalUser;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {IPortalAddResourceParam} from '../../../src/common/iPortal/iPortalAddResourceParam';
2+
3+
describe('IPortalAddResourceParam', () => {
4+
it('rootUrl', () => {
5+
let param = new IPortalAddResourceParam({rootUrl: "http://rdc.ispeco.com:8080/iserver/services/map-Population/rest"});
6+
expect(param).not.toBeNull();
7+
expect(param.rootUrl).toBe("http://rdc.ispeco.com:8080/iserver/services/map-Population/rest");
8+
});
9+
10+
it('tags', () => {
11+
let param = new IPortalAddResourceParam({tags: ["用户地图"]});
12+
expect(param).not.toBeNull();
13+
expect(param.tags[0]).toBe("用户地图");
14+
});
15+
16+
it('entities', () => {
17+
let param = new IPortalAddResourceParam({entities: [
18+
{
19+
permissionType: "SEARCH",
20+
entityType: "USER",
21+
entityName: "GUEST",
22+
entityId: null
23+
}
24+
]});
25+
expect(param).not.toBeNull();
26+
expect(param.entities[0].permissionType).toBe("SEARCH");
27+
expect(param.entities[0].entityType).toBe("USER");
28+
expect(param.entities[0].entityName).toBe("GUEST");
29+
expect(param.entities[0].entityId).toBeNull();
30+
});
31+
})
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {IPortalRegisterServiceParam} from '../../../src/common/iPortal/iPortalRegisterServiceParam';
2+
3+
describe('IPortalRegisterServiceParam', () => {
4+
it('type', () => {
5+
let param = new IPortalRegisterServiceParam({type: "SUPERMAP_REST"});
6+
expect(param).not.toBeNull();
7+
expect(param.type).toBe("SUPERMAP_REST");
8+
});
9+
10+
it('tags', () => {
11+
let param = new IPortalRegisterServiceParam({tags: ["用户服务"]});
12+
expect(param).not.toBeNull();
13+
expect(param.tags[0]).toBe("用户服务");
14+
});
15+
16+
it('entities', () => {
17+
let param = new IPortalRegisterServiceParam({entities: [
18+
{
19+
permissionType: "SEARCH",
20+
entityType: "USER",
21+
entityName: "GUEST",
22+
entityId: null
23+
}
24+
]});
25+
expect(param).not.toBeNull();
26+
expect(param.entities[0].permissionType).toBe("SEARCH");
27+
expect(param.entities[0].entityType).toBe("USER");
28+
expect(param.entities[0].entityName).toBe("GUEST");
29+
expect(param.entities[0].entityId).toBeNull();
30+
});
31+
32+
it('metadata', () => {
33+
let param = new IPortalRegisterServiceParam({metadata: {}});
34+
expect(param).not.toBeNull();
35+
expect(param.metadata).toEqual({});
36+
});
37+
38+
it("addedMapNames", () => {
39+
let param = new IPortalRegisterServiceParam({addedMapNames: ["中国1981-2010年1月平均气温分布图"]});
40+
expect(param).not.toBeNull();
41+
expect(param.addedMapNames[0]).toBe("中国1981-2010年1月平均气温分布图");
42+
});
43+
44+
it("addedSceneNames", () => {
45+
let param = new IPortalRegisterServiceParam({addedSceneNames: ["CBD"]});
46+
expect(param).not.toBeNull();
47+
expect(param.addedSceneNames[0]).toBe("CBD");
48+
});
49+
})

test/common/iPortal/iPortalUserSpec.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,70 @@ describe('IPortalUser', () => {
1212
var iPortalUser = new IPortalUser(iportalUrl);
1313
expect(iPortalUser.deleteResources({ids: [], resourceType: "MAP"}) instanceof Promise).toBeTruthy();
1414
});
15+
16+
it('addMap', () => {
17+
let iportalUrl = 'https://iptl.supermap.io/iportal';
18+
let iPortalUser = new IPortalUser(iportalUrl);
19+
// 传入错误的参数
20+
let addMapParams = {
21+
rootUrl: "http://rdc.ispeco.com:8080/iserver/services/map-Population/rest",
22+
tags: ["用户地图"],
23+
authorizeSetting: [
24+
{
25+
permissionType: "SEARCH",
26+
entityType: "USER",
27+
entityName: "GUEST",
28+
entityId: null
29+
}
30+
]
31+
};
32+
iPortalUser.addMap(addMapParams).then(res => {
33+
expect(res).toBe("addMapParams is not instanceof IPortalAddMapParam !");
34+
})
35+
});
36+
37+
it('addScene', () => {
38+
let iportalUrl = 'https://iptl.supermap.io/iportal';
39+
let iPortalUser = new IPortalUser(iportalUrl);
40+
// 传入错误的参数
41+
let addSceneParams = {
42+
rootUrl: "http://rdc.ispeco.com:8080/iserver/services/3D-CBD/rest",
43+
tags: ["用户场景"],
44+
authorizeSetting: [
45+
{
46+
permissionType: "SEARCH",
47+
entityType: "USER",
48+
entityName: "GUEST",
49+
entityId: null
50+
}
51+
]
52+
};
53+
iPortalUser.addScene(addSceneParams).then(res => {
54+
expect(res).toBe("addSceneParams is not instanceof IPortalAddSceneParam !");
55+
})
56+
});
57+
58+
it('registerService', () => {
59+
let iportalUrl = 'https://iptl.supermap.io/iportal';
60+
let iPortalUser = new IPortalUser(iportalUrl);
61+
// 传入错误的参数
62+
let registerServiceParams = {
63+
type: "SUPERMAP_REST",
64+
tags: [],
65+
authorizeSetting: [
66+
{
67+
permissionType: "SEARCH",
68+
entityType: "USER",
69+
entityName: "GUEST",
70+
entityId: null
71+
}
72+
],
73+
metadata: [],
74+
addedMapNames: [],
75+
addedSceneNames: []
76+
}
77+
iPortalUser.registerService(registerServiceParams).then(res => {
78+
expect(res).toBe("registerParams is not instanceof iPortalRegisterServiceParam !");
79+
})
80+
})
1581
});

test/test-main-common.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ import './common/iPortal/iPortalShareParamSpec.js';
164164
import './common/iPortal/iPortalResourceSpec.js';
165165
import './common/iPortal/iPortalQueryResultSpec.js';
166166
import './common/iPortal/iPortalSpec.js';
167+
import './common/iPortal/iPortalAddResourceParamSpec';
168+
import './common/iPortal/iPortalRegisterServiceParamSpec';
167169

168170
/**common -- thirdparty**/
169171
import './common/thirdparty/elasticsearch/ElasticSearchSpec.js';

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