aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/org/onap/usecaseui/server/controller/IntentController.java
blob: df6530ce2baadaa978ca16e6899a2cfef9067573 (plain)
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
/*
 * Copyright (C) 2021 CTC, Inc. and others. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onap.usecaseui.server.controller;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jakarta.annotation.Resource;

import com.alibaba.fastjson.JSONArray;
import org.apache.commons.collections.MapUtils;
import org.onap.usecaseui.server.bean.HttpResponseResult;
import org.onap.usecaseui.server.bean.intent.CCVPNInstance;
import org.onap.usecaseui.server.bean.intent.IntentModel;
import org.onap.usecaseui.server.bean.intent.IntentResponseBody;
import org.onap.usecaseui.server.bean.nsmf.common.ServiceResult;
import org.onap.usecaseui.server.constant.IntentConstant;
import org.onap.usecaseui.server.service.csmf.SlicingService;
import org.onap.usecaseui.server.service.intent.IntentApiService;
import org.onap.usecaseui.server.service.intent.IntentInstanceService;
import org.onap.usecaseui.server.service.intent.IntentService;
import org.onap.usecaseui.server.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

@RestController
@org.springframework.context.annotation.Configuration
@EnableAspectJAutoProxy
@CrossOrigin(origins = "*")
@RequestMapping("/intent")
public class IntentController {
    private final Logger logger = LoggerFactory.getLogger(IntentController.class);

    @Resource(name = "IntentService")
    private IntentService intentService;

    @Resource(name = "IntentInstanceService")
    private IntentInstanceService intentInstanceService;

    private IntentApiService intentApiService;

    private ObjectMapper omAlarm = new ObjectMapper();

    @Resource(name = "SlicingService")
    private SlicingService slicingService;

    public IntentController() {
        this(RestfulServices.create(IntentApiService.class));
    }
    public IntentController(IntentApiService intentApiService) {
        this.intentApiService = intentApiService;
    }

    @GetMapping(value="/listModel",produces = "application/json;charset=utf8")
    public String getModels() throws JsonProcessingException {
        List<IntentModel> listModels = intentService.listModels();
        return omAlarm.writeValueAsString(listModels);
    }

    @RequestMapping("/uploadModel")
    @ResponseBody
    public String uploadModel (@RequestParam("file") MultipartFile file,@RequestParam("modelType")String modelType) {
        String fileName = file.getOriginalFilename();

        String filePath = IntentConstant.UPLOADPATH + fileName ;

        File dest = newFile(filePath);

        if(!dest.getParentFile().exists()) {
            dest.getParentFile().mkdirs();
            logger.info("create dir, name=" + dest.getParentFile().getName());
        }
        try {

            file.transferTo(dest);
            logger.info("upload file, name = " + dest.getName());
            IntentModel model = new IntentModel();
            model.setModelName(fileName);
            model.setFilePath(filePath);
            model.setCreateTime(DateUtils.dateToString(new Date()));
            float size = dest.length();
            float sizeM = size/1024;
            model.setSize(sizeM);
            model.setActive(0);
            model.setModelType(modelType);
            Map<String,String> fileMap = new HashMap<>();
            fileMap.put("file", filePath);
            UploadFileUtil.formUpload(IntentConstant.NLP_FILE_URL_BASE + "/uploader", null, fileMap, null);

            intentService.addModel(model);

            logger.info("save model, " + model.toString());
            return "1";
        } catch (Exception e) {
            logger.error("Details:" + e.getMessage());
            return "0";
        }
    }

    private String deleteModelFile(String modelId){
        String result = "0";
        try{
            IntentModel model = intentService.getModel(modelId);
            if( model==null){
                return result;
            }

            String fileName = model.getModelName();
            String filePath = IntentConstant.UPLOADPATH + fileName;
            logger.info("delete model file: " + filePath);
            File dest = newFile(filePath);
            if(dest.exists()){
                dest.delete();
                postDeleteFile(fileName);
                logger.info("delete file OK: " + filePath);
            }{
                logger.info("file not found: " + filePath);
            }
            result = "1";
        }catch (Exception e){
            logger.error("Details:" + e.getMessage());
            return "0";
        }
        return result;
    }


    private String postDeleteFile(String fileName) {

        String url = IntentConstant.NLP_FILE_URL_BASE + "/deleteFile/"+ fileName;
        HashMap<String, String> headers = new HashMap<>();

        HttpResponseResult result = HttpUtil.sendGetRequest(url,headers);
        String respContent = result.getResultContent();

        logger.info("NLP api respond: " + String.valueOf(result.getResultCode()));
        logger.info(respContent);

        return respContent;
    }

    @GetMapping(value = {"/activeModel"}, produces = "application/json")
    public String activeModel(@RequestParam String modelId){
        String result = "0";
        try{
            logger.info("update model record status: id=" + modelId);
            IntentModel model = intentService.activeModel(modelId);

            logger.info("active NLP model, model=" + model.getFilePath());
            String fileName = intentService.activeModelFile(model);
            if (fileName != null) {
                intentService.load(IntentConstant.NLPLOADPATH + fileName);
            }


            result = "1";
        }catch (Exception e) {
            logger.error("Details:" + e.getMessage());
            return "0";
        }

        return result;
    }



    @DeleteMapping(value = {"/deleteModel"}, produces = "application/json")
    public String deleteModel(@RequestParam String modelId){
        String result = "0";
        try{
            result = deleteModelFile(modelId);

            logger.info("delete model record: id=" + modelId);
            result = intentService.deleteModel(modelId);
        }catch (Exception e) {
            logger.error("Details:" + e.getMessage());
            return "0";
        }

        return result;
    }
    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/predict"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Map<String, Object> predict(@RequestBody Object body) throws ParseException {
        String text = (String)((Map)body).get("text");
        text = text.trim();
        String modelType = (String)((Map)body).get("modelType");

        String activeModelType = intentService.getActiveModelType();
        if (modelType == null || !modelType.equals(activeModelType)) {
            throw new RuntimeException("The active model file does not support parsing the current text");
        }
        String[] questions = getQuestions(modelType);

        String url = IntentConstant.NLP_ONLINE_URL_BASE + "/api/online/predict";
        HashMap<String, String> headers = new HashMap<>();
        String bodyStr = "{\"title\": \"predict\", \"text\": \"" + text
                +  "\", \"questions\":" + new JSONArray().toJSONString(Arrays.asList(questions)) + "}";
        logger.info("request body: " + bodyStr);

        HttpResponseResult result = HttpUtil.sendPostRequestByJson(url, headers, bodyStr);
        String respContent = result.getResultContent();

        logger.info("NLP api respond: " + String.valueOf(result.getResultCode()));
        logger.info(respContent);

        JSONObject map = JSON.parseObject(respContent);

        JSONObject map2 = new JSONObject();

        if (IntentConstant.MODEL_TYPE_CCVPN.equals(modelType)) {
            assemblyCCVPNResult(text, map, map2);
        }
        else {
            assemblySlicingResult(map, map2);
        }

        logger.info("translate result: " + map2.toJSONString());

        return map2;
    }

    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/unifyPredict"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Map<String, Object> unifyPredict(@RequestBody Object body) throws ParseException {
        String text = (String)((Map)body).get("text");
        text = text.trim();
        String modelType = intentService.getModelTypeByIntentText(text);

        String activeModelType = intentService.getActiveModelType();
        if (modelType == null || !modelType.equals(activeModelType)) {
            intentService.activeModelByType(modelType);
        }
        String[] questions = getQuestions(modelType);

        String url = IntentConstant.NLP_ONLINE_URL_BASE + "/api/online/predict";
        HashMap<String, String> headers = new HashMap<>();
        String bodyStr = "{\"title\": \"predict\", \"text\": \"" + text
                +  "\", \"questions\":" + new JSONArray().toJSONString(Arrays.asList(questions)) + "}";
        logger.info("request body: " + bodyStr);

        HttpResponseResult result = HttpUtil.sendPostRequestByJson(url, headers, bodyStr);
        String respContent = result.getResultContent();

        logger.info("NLP api respond: " + String.valueOf(result.getResultCode()));
        logger.info(respContent);

        JSONObject map = JSON.parseObject(respContent);

        JSONObject map2 = new JSONObject();
        JSONObject resultMap = new JSONObject();

        if (IntentConstant.MODEL_TYPE_CCVPN.equals(modelType)) {
            assemblyCCVPNResult(text, map, map2);
            resultMap.put("type", IntentConstant.MODEL_TYPE_CCVPN);
        }
        else {
            assemblySlicingResult(map, map2);
            resultMap.put("type", IntentConstant.MODEL_TYPE_5GS);
        }
        resultMap.put("formData",map2);

        logger.info("translate result: " + resultMap.toJSONString());

        return resultMap;
    }

    private void assemblySlicingResult(JSONObject map, JSONObject resultMap) {
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            logger.debug(entry.getKey() + "," + entry.getValue());
            String key = tranlateFieldName(entry.getKey());
            String valueStr = (String) entry.getValue();
            String value = intentService.calcFieldValue(key, valueStr);
            resultMap.put(key, value);
        }
    }

    private void assemblyCCVPNResult(String text, JSONObject map, JSONObject map2) {
        String bandWidth = map.getString("bandwidth");
        String accessPoint = map.getString("access point");
        String cloudPoint = map.getString("cloud point");
        boolean protect = MapUtils.getBooleanValue(map, "protect", false);
        String instanceId = getUUID();
        String accessPointAlias = intentInstanceService.formatAccessPoint(accessPoint);
        if ("".equals(accessPointAlias)) {
            if (text.toLowerCase().contains("access one") || text.toLowerCase().contains("company a")) {
                accessPointAlias = MapUtils.getString(IntentConstant.NetWorkNodeAlias, "tranportEp_src_ID_111_1","tranportEp_src_ID_111_1");
            } else if (text.toLowerCase().contains("access two") || text.toLowerCase().contains("company b")) {
                accessPointAlias = MapUtils.getString(IntentConstant.NetWorkNodeAlias, "tranportEp_src_ID_111_2","tranportEp_src_ID_111_2");
            } else if (text.toLowerCase().contains("access three") || text.toLowerCase().contains("company c")) {
                accessPointAlias = MapUtils.getString(IntentConstant.NetWorkNodeAlias, "tranportEp_src_ID_113_1","tranportEp_src_ID_113_1");
            }
        }
        String bandwidthAlias = null;
        if (bandWidth.matches("\\d+")) {
            bandwidthAlias = intentInstanceService.formatBandwidth(bandWidth);
        } else {
            Pattern pattern = Pattern.compile("(\\d+)(Gbps|Mbps)");
            Matcher matcher = pattern.matcher(text);
            if (matcher.find()) {
                int value = Integer.parseInt(matcher.group(1));
                String unit = matcher.group(2);
                if ("Gbps".equals(unit)) {
                    value = value * 1000;
                }
                bandwidthAlias = value + "";
            }
        }

        String cloudPointAlias = intentInstanceService.formatCloudPoint(cloudPoint);
        if ("".equals(cloudPointAlias)) {
            if (text.indexOf("Cloud one") > -1) {
                cloudPointAlias = MapUtils.getString(IntentConstant.NetWorkNodeAlias, "tranportEp_dst_ID_212_1","tranportEp_dst_ID_212_1");
            }else if (text.indexOf("Cloud two") > -1) {
                cloudPointAlias = MapUtils.getString(IntentConstant.NetWorkNodeAlias, "tranportEp_dst_ID_213_1","tranportEp_dst_ID_213_1");
            }
        }

        Map<String, Object> accessPointOne = new HashMap<>();
        accessPointOne.put("name", accessPointAlias);
        accessPointOne.put("bandwidth", bandwidthAlias);
        map2.put("name", "");
        map2.put("instanceId", instanceId);
        map2.put("accessPointOne", accessPointOne);
        map2.put("cloudPointName", cloudPointAlias);
        map2.put("protect", protect);
    }

    private String[] getQuestions(String modelType) {
        if (IntentConstant.MODEL_TYPE_CCVPN.equals(modelType)) {
            return IntentConstant.QUESTIONS_CCVPN;
        } else {
            return IntentConstant.QUESTIONS_5GS;
        }
    }


    private static String tranlateFieldName(String key){
        String ret = "";
        if(key==null || key.trim().equals(""))
            return ret;

        HashMap<String, String> map = new HashMap<>();
        map.put("Communication Service Name","name");
        map.put("Max Number of UEs","maxNumberofUEs");
        map.put("Data Rate Downlink","expDataRateDL");
        map.put("Latency","latency");
        map.put("Data Rate Uplink","expDataRateUL");
        map.put("Resource Sharing Level","resourceSharingLevel");
        map.put("Mobility","uEMobilityLevel");
        map.put("Area","coverageArea");

        ret = map.get(key.trim());
        return ret;
    }

    @IntentResponseBody
    @ResponseBody
    @GetMapping(value = {"/getInstanceId"},
            produces = "application/json")
    public JSONObject getInstanceId() {
        String instanceId = getUUID();
        JSONObject result = new JSONObject();
        result.put("instanceId", instanceId);
        return result;
    }

    private String getUUID() {
        int first = new Random(10).nextInt(8) + 1;
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if (hashCodeV < 0) {
            hashCodeV = -hashCodeV;
        }
        String instanceId = first + String.format("%015d", hashCodeV);
        return instanceId;
    }

    @IntentResponseBody
    @ResponseBody
    @PostMapping (value = {"/getInstanceList"},consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json")
    public Object getInstanceList(@RequestBody Object body) {
        int currentPage = (int) ((Map)body).get("currentPage");
        int pageSize = (int) ((Map)body).get("pageSize");
        logger.error("getInstanceList --> currentPage:" + currentPage + ",pageSize:" + pageSize);
        Page<CCVPNInstance> ccvpnInstancePage = intentInstanceService.queryIntentInstance(null, currentPage, pageSize);
        for (CCVPNInstance instance : ccvpnInstancePage.getList()) {
            instance.setAccessPointOneName(MapUtils.getString(IntentConstant.NetWorkNodeAlias, instance.getAccessPointOneName(),instance.getAccessPointOneName()));
            instance.setCloudPointName(MapUtils.getString(IntentConstant.NetWorkNodeAlias, instance.getCloudPointName(),instance.getCloudPointName()));
        }
        return ccvpnInstancePage;
    }
    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/createIntentInstance"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Object createCCVPNInstance(@RequestBody Object body) throws IOException {
        String intentInstanceId = (String) ((Map)body).get("instanceId");
        String name = (String) ((Map)body).get("name");
        String lineNum = (String) ((Map)body).get("lineNum");
        String cloudPointName = ((String) ((Map)body).get("cloudPointName")).split("\\(")[0];
        Map<String, Object> accessPointOne = (Map) ((Map)body).get("accessPointOne");
        String accessPointOneName = MapUtils.getString(accessPointOne, "name").split("\\(")[0];
        int accessPointOneBandWidth = MapUtils.getIntValue(accessPointOne, "bandwidth");
        boolean protectStatus = MapUtils.getBooleanValue((Map)body,"protect", false);

        CCVPNInstance instance = new CCVPNInstance();
        instance.setInstanceId(intentInstanceId);
        instance.setName(name);
        instance.setLineNum(lineNum);
        instance.setCloudPointName(cloudPointName);
        instance.setAccessPointOneName(accessPointOneName);
        instance.setAccessPointOneBandWidth(accessPointOneBandWidth);
        instance.setStatus("0");
        instance.setProtectStatus(protectStatus?1:0);
        if (protectStatus) {
            instance.setProtectionType("1+1");
            instance.setProtectionCloudPointName("tranportEp_dst_ID_123_4");
        }

        int flag = intentInstanceService.createCCVPNInstance(instance);

        if(flag == 1) {
            if (((Map) body).containsKey("intentContent")) {
                intentInstanceService.createIntentInstance(body, instance.getInstanceId() + "", instance.getName(), IntentConstant.MODEL_TYPE_CCVPN);
            }
            return "OK";
        }
        else {
            throw new RuntimeException("create Instance error");
        }
    }

    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/updateCCVPNInstance"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Object updateCCVPNInstance(@RequestBody Object body) throws IOException {
        String intentInstanceId = MapUtils.getString((Map)body,"instanceId");
        int accessPointOneBandWidth = MapUtils.getIntValue((Map)body,"bandwidth");

        CCVPNInstance instance = new CCVPNInstance();
        instance.setInstanceId(intentInstanceId);
        instance.setAccessPointOneBandWidth(accessPointOneBandWidth);

        int flag = intentInstanceService.updateCCVPNInstance(instance);

        if(flag == 1) {
            return "OK";
        }
        else {
            throw new RuntimeException("create Instance error");
        }
    }


    @IntentResponseBody
    @GetMapping(value = {"/getFinishedInstanceInfo"},
            produces = "application/json")
    public Object getFinishedInstanceInfo() {
        List<CCVPNInstance> instanceList = intentInstanceService.getFinishedInstanceInfo();
        List<Map<String, Object>> result = new ArrayList<>();
        for (CCVPNInstance instance : instanceList) {
            Map<String, Object> instanceInfo = new HashMap<>();
            instanceInfo.put("instanceId", instance.getInstanceId());
            instanceInfo.put("name", instance.getName());
            result.add(instanceInfo);
        }
        return result;
    }

    @IntentResponseBody
    @DeleteMapping(value = {"/deleteIntentInstance"}, produces = "application/json; charset=utf-8")
    public Object deleteIntentInstance(@RequestParam String instanceId) {
        intentInstanceService.deleteIntentInstance(instanceId);
        return "ok";
    }
    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/activeIntentInstance"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Object activeIntentInstance(@RequestBody Object body) {
        String instanceId= (String) ((Map)body).get("instanceId");
        intentInstanceService.activeIntentInstance(instanceId);
        return "ok";
    }
    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/invalidIntentInstance"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Object invalidIntentInstance(@RequestBody Object body) {
        String instanceId= (String) ((Map)body).get("instanceId");
        intentInstanceService.invalidIntentInstance(instanceId);
        return "ok";
    }

    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/queryInstancePerformanceData"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Object queryInstancePerformanceData(@RequestBody Object body) {
        String instanceId= (String) ((Map)body).get("instanceId");
        return intentInstanceService.queryInstancePerformanceData(instanceId);
    }

    @IntentResponseBody
    @GetMapping(value = {"/queryAccessNodeInfo"},
            produces = "application/json")
    public Object queryAccessNodeInfo() throws IOException{
        return intentInstanceService.queryAccessNodeInfo();
    }


    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/getInstanceStatus"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Object getInstanceStatus(@RequestBody Object body) {
        JSONArray ids= new JSONObject((Map)body).getJSONArray("ids");
        return intentInstanceService.getInstanceStatus(ids);
    }

    public File newFile(String filePath) {
        return new File(filePath);
    }


    @ResponseBody
    @PostMapping(value = {"/csmf/5gSlicing"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public ServiceResult createSlicingServiceWithIntent(@RequestBody Object slicingOrderBody) {
        return intentInstanceService.createSlicingServiceWithIntent(slicingOrderBody);
    }

    @IntentResponseBody
    @DeleteMapping(value = {"/deleteIntent"}, produces = "application/json; charset=utf-8")
    public Object deleteIntent(@RequestParam int id) {
        intentInstanceService.deleteIntent(id);
        return "ok";
    }

    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/verifyIntentInstance"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Object verifyIntentInstance(@RequestBody Object body) {
        int id = MapUtils.getIntValue((Map) body, "id");
        intentInstanceService.verifyIntent(id);
        return "Intent verification passed, Recommended implementation!";
    }

    @IntentResponseBody
    @ResponseBody
    @PostMapping(value = {"/getIntentList"}, consumes = MediaType.APPLICATION_JSON_VALUE,
            produces = "application/json; charset=utf-8")
    public Object getIntentList(@RequestBody Object body) {

        int currentPage = (int) ((Map)body).get("currentPage");
        int pageSize = (int) ((Map)body).get("pageSize");
        logger.error("getInstanceList --> currentPage:" + currentPage + ",pageSize:" + pageSize);
        return intentInstanceService.getIntentInstanceList(currentPage, pageSize);
    }

}