forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatasetService.js
More file actions
163 lines (156 loc) · 6.56 KB
/
DatasetService.js
File metadata and controls
163 lines (156 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
* This program are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
import { SuperMap } from '../SuperMap';
import { CommonServiceBase } from '@supermap/iclient-common/iServer/CommonServiceBase';
import { DatasetService as CommonDatasetService } from '@supermap/iclient-common/iServer/DatasetService';
import { CreateDatasetParameters } from '@supermap/iclient-common/iServer/CreateDatasetParameters';
import { UpdateDatasetParameters } from '@supermap/iclient-common/iServer/UpdateDatasetParameters';
import { Util as CommonUtil } from '@supermap/iclient-common/commontypes/Util';
/**
* @class SuperMap.REST.DatasetService
* @category iServer Data Dataset
* @classdesc 数据集查询。
* @extends {SuperMap.CommonServiceBase}
* @param {string} url - 服务地址。
* @param {Object} options - 参数。
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
* @param {Object} [options.headers] - 请求头。
*/
export class DatasetService extends CommonServiceBase {
constructor(url, options) {
super(url, options);
this.CLASS_NAME = "SuperMap.REST.DatasetService";
}
/**
* @function SuperMap.REST.DatasetService.prototype.getDatasets
* @description 数据集查询服务。
* @example
* new SuperMap.REST.DatasetService(url).getDatasets(datasourceName,function(result){
* //doSomething
* });
* @param {string} datasourceName - 数据源名称。
* @param {RequestCallback} callback - 回调函数。
*/
getDatasets(datasourceName, callback) {
if (!datasourceName) {
return;
}
const me = this;
const datasetService = new CommonDatasetService(me.url, {
proxy: me.proxy,
withCredentials: me.withCredentials,
crossOrigin: me.crossOrigin,
headers: me.headers,
serverType: me.serverType,
eventListeners: {
scope: me,
processCompleted: callback,
processFailed: callback
}
});
datasetService.getDatasetsService(datasourceName);
}
/**
* @function SuperMap.REST.DatasetService.prototype.getDataset
* @description 数据集查询服务。
* @example
* new SuperMap.REST.DatasetService(url).getDataset(datasourceName, datasetName, function(result){
* //doSomething
* });
* @param {string} datasourceName - 数据源名称。
* @param {string} datasetName - 数据集名称。
* @param {RequestCallback} callback - 回调函数。
*/
getDataset(datasourceName, datasetName, callback) {
if (!datasourceName || !datasetName) {
return;
}
const me = this;
const datasetService = new CommonDatasetService(me.url, {
proxy: me.proxy,
withCredentials: me.withCredentials,
crossOrigin: me.crossOrigin,
headers: me.headers,
serverType: me.serverType,
eventListeners: {
scope: me,
processCompleted: callback,
processFailed: callback
}
});
datasetService.getDatasetService(datasourceName, datasetName);
}
/**
* @function SuperMap.REST.DatasetService.prototype.setDataset
* @description 数据集信息设置服务。可实现修改已存在数据集,新增不存在数据集。
* @example
* new SuperMap.REST.DatasetService(url).setDataset(params, function(result){
* //doSomething
* });
* @param {SuperMap.CreateDatasetParameters | SuperMap.UpdateDatasetParameters } params - 数据集设置参数类(当前数据源下的数据集不存在时,新建数据集) || 数据集信息更改参数类。(当前数据源下的数据集存在时,更改数据集信息)
* @param {RequestCallback} callback - 回调函数。
*/
setDataset(params, callback) {
if (!(params instanceof CreateDatasetParameters) && !(params instanceof UpdateDatasetParameters)) {
return;
}
let datasetParams;
if (params instanceof CreateDatasetParameters) {
datasetParams = {
"datasetType": params.datasetType,
"datasetName": params.datasetName
}
} else if (params instanceof UpdateDatasetParameters) {
datasetParams = {
"datasetName": params.datasetName,
"isFileCache": params.isFileCache,
"description": params.description,
"prjCoordSys": params.prjCoordSys,
"charset": params.charset
}
}
const me = this;
const url = CommonUtil.urlPathAppend(me.url, `datasources/name/${params.datasourceName}/datasets/name/${params.datasetName}`);
const datasetService = new CommonDatasetService(url, {
proxy: me.proxy,
withCredentials: me.withCredentials,
crossOrigin: me.crossOrigin,
headers: me.headers,
serverType: me.serverType,
eventListeners: {
processCompleted: callback,
processFailed: callback
}
});
datasetService.setDatasetService(datasetParams);
}
/**
* @function SuperMap.REST.DatasetService.prototype.deleteDataset
* @description 指定数据源下的数据集删除服务。
* @example
* new SuperMap.REST.DatasetService(url).deleteDataset(datasourceName, datasetName, function(result){
* //doSomething
* });
* @param {string} datasourceName - 数据源名称。
* @param {string} datasetName - 数据集名称。
* @param {RequestCallback} callback - 回调函数。
*/
deleteDataset(datasourceName, datasetName, callback) {
const me = this;
const url = CommonUtil.urlPathAppend(me.url, `datasources/name/${datasourceName}/datasets/name/${datasetName}`);
const datasetService = new CommonDatasetService(url, {
proxy: me.proxy,
withCredentials: me.withCredentials,
crossOrigin: me.crossOrigin,
headers: me.headers,
serverType: me.serverType,
eventListeners: {
processCompleted: callback,
processFailed: callback
}
});
datasetService.deleteDatasetService();
}
}
SuperMap.REST.DatasetService = DatasetService;