MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / addData

Method addData

src/common/iPortal/iPortalUser.js:147–218  ·  view source on GitHub ↗

* @function IPortalUser.prototype.addData * @description 上传/注册数据。 * @version 10.1.0 * @param {IPortalAddDataParam} params - 上传/注册数据所需的参数。 * @param {Object} [formData] - 请求体为文本数据流(上传数据时传入)。 * @returns {Promise} 返回上传/注册数据的 Promise 对象。

(params,formData)

Source from the content-addressed store, hash-verified

145 * @returns {Promise} 返回上传/注册数据的 Promise 对象。
146 */
147 addData(params,formData) {
148 if(!(params instanceof IPortalAddDataParam)){
149 return this.getErrMsgPromise("params is not instanceof iPortalAddDataParam !");
150 }
151 var datasUrl = this.iportalUrl + "/web/mycontent/datas.json";
152 var entity = {
153 fileName:params.fileName,
154 tags:params.tags,
155 type:params.type
156 };
157 var type = params.type.toLowerCase();
158 var dataMetaInfo;
159 if(type === "excel" || type === "csv"){
160 if(!(params.dataMetaInfo instanceof IPortalDataMetaInfoParam)){
161 return this.getErrMsgPromise("params.dataMetaInfo is not instanceof iPortalDataMetaInfoParam !");
162 }
163 dataMetaInfo = {
164 xField:params.dataMetaInfo.xField,
165 yField:params.dataMetaInfo.yField
166 }
167 if(type === 'csv') {
168 dataMetaInfo.fileEncoding = params.dataMetaInfo.fileEncoding
169 }
170 entity.coordType = "WGS84";
171 entity.dataMetaInfo = dataMetaInfo;
172 }else if(type === "hdfs" || type === "hbase") {
173 if(!(params.dataMetaInfo instanceof IPortalDataMetaInfoParam)){
174 return this.getErrMsgPromise("params.dataMetaInfo is not instanceof iPortalDataMetaInfoParam !");
175 }
176 if(!(params.dataMetaInfo.dataStoreInfo instanceof IPortalDataStoreInfoParam)){
177 return this.getErrMsgPromise("params.dataMetaInfo.dataStoreInfo is not instanceof iPortalDataStoreInfoParam !");
178 }
179 var dataStoreInfo = {
180 type:params.dataMetaInfo.dataStoreInfo.type
181 }
182 switch (type) {
183 case "hdfs":
184 dataStoreInfo.url = params.dataMetaInfo.dataStoreInfo.url;
185 dataMetaInfo = {
186 url: params.dataMetaInfo.url,
187 dataStoreInfo:dataStoreInfo
188 }
189 break;
190 case "hbase":
191 if(!(params.dataMetaInfo.dataStoreInfo.connectionInfo instanceof IPortalDataConnectionInfoParam)){
192 return this.getErrMsgPromise("params.dataMetaInfo.dataStoreInfo.connectionInfo is not instanceof iPortalDataConnectionInfoParam !");
193 }
194 dataStoreInfo.connectionInfo = {
195 dataBase:params.dataMetaInfo.dataStoreInfo.connectionInfo.dataBase,
196 server:params.dataMetaInfo.dataStoreInfo.connectionInfo.server,
197 engineType:'HBASE'
198 }
199 dataStoreInfo.datastoreType = "SPATIAL";//该字段SPATIAL表示HBASE注册
200 dataMetaInfo = {
201 dataStoreInfo:dataStoreInfo
202 }
203 break;
204 }

Callers

nothing calls this directly

Calls 3

getErrMsgPromiseMethod · 0.95
uploadDataRequestMethod · 0.95
requestMethod · 0.45

Tested by

no test coverage detected