summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhekeguang <hekeguang@chinamobile.com>2022-11-22 11:11:52 +0800
committerhekeguang <hekeguang@chinamobile.com>2022-11-22 11:12:08 +0800
commit2f871e98fa6e94cc41ed1f12205030b117dd1569 (patch)
tree2f8ee93033d7e5e78c9ad926e40d22ca3f413697
parent89039c53eae5a28678e23aa42cadc3b61204330d (diff)
Add logs for intentAnalysisServer.
Issue-ID: USECASEUI-762 Change-Id: I22df538103455df4ccc886eab3d06acc899279c4 Signed-off-by: hekeguang <hekeguang@chinamobile.com>
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java3
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentGenerateType.java31
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java3
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ResultHeader.java35
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ServiceResult.java39
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java35
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java14
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IMFRegInfoController.java13
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java103
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java3
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/IntentInputException.java30
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java20
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/IMFRegInfoService.java7
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/impl/IMFRegInfoServiceImpl.java46
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java8
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java13
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java12
-rw-r--r--intentanalysis/src/main/resources/intent-analysis-init.sql3
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml21
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml15
25 files changed, 401 insertions, 71 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java
index c2a0ec2..573749d 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java
@@ -19,8 +19,11 @@ package org.onap.usecaseui.intentanalysis;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
@MapperScan("org.onap.usecaseui.intentanalysis.mapper")
@SpringBootApplication
+@EnableTransactionManagement
public class IntentAnalysisApplication {
public static void main(String[] args) {
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentGenerateType.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentGenerateType.java
new file mode 100644
index 0000000..11d76ba
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/enums/IntentGenerateType.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2022 CMCC, 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.intentanalysis.bean.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum IntentGenerateType {
+ USERINPUT(0, "userInput"),
+ SYSTEMGENARATE(1, "systemGenerate");
+ private int type;
+ private String generateType;
+
+ IntentGenerateType(int type, String generateType) {
+ this.type = type;
+ this.generateType = generateType;
+ }
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java
index 8f649e9..46c4acb 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java
@@ -19,6 +19,7 @@ package org.onap.usecaseui.intentanalysis.bean.models;
import java.util.List;
import lombok.Data;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGenerateType;
@Data
@@ -34,4 +35,6 @@ public class Intent {
private FulfilmentInfo intentFulfilmentInfo;
+ private IntentGenerateType intentGenerateType;
+
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ResultHeader.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ResultHeader.java
new file mode 100644
index 0000000..c130288
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ResultHeader.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2022 CMCC, 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.intentanalysis.bean.models;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ResultHeader {
+ private int result_code;
+
+ private String result_message;
+
+ public ResultHeader() {
+ }
+
+ public ResultHeader(int result_code, String result_message) {
+ this.result_code = result_code;
+ this.result_message = result_message;
+ }
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ServiceResult.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ServiceResult.java
new file mode 100644
index 0000000..e0053e4
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/ServiceResult.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2022 CMCC, 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.intentanalysis.bean.models;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ServiceResult {
+
+ private ResultHeader result_header;
+ private Object result_body;
+
+ public ServiceResult() {
+ }
+
+ public ServiceResult(ResultHeader result_header, Object result_body) {
+ this.result_header = result_header;
+ this.result_body = result_body;
+ }
+
+ public ServiceResult(ResultHeader result_header) {
+ this.result_header = result_header;
+ }
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java
index b9e48ed..4ec76e7 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllBusinessIntentMgt/cllBusinessModule/CLLBusinessDecisionModule.java
@@ -17,23 +17,28 @@ package org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.cllBusinessModule
import lombok.extern.log4j.Log4j2;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.bean.enums.ExpectationType;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGenerateType;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.enums.ObjectType;
-import org.onap.usecaseui.intentanalysis.bean.models.*;
+import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
+import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService;
import org.onap.usecaseui.intentanalysis.service.IntentService;
-import org.onap.usecaseui.intentanalysis.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
@Log4j2
@@ -102,8 +107,7 @@ public class CLLBusinessDecisionModule extends DecisionModule {
Intent subIntent = new Intent();
subIntent.setIntentName(objEntry.getValue().get(0).getExpectationName().replace("Expectation", "Intent"));
subIntent.setIntentExpectations(objEntry.getValue());
- //List<Expectation> newExpectationList = getNewExpectationList(objEntry.getValue());
- //subIntent.setIntentExpectations(newExpectationList);
+ subIntent.setIntentGenerateType(IntentGenerateType.SYSTEMGENARATE);
//TODO intentFulfilmentInfo intentContexts
subIntentGoalBean.setIntentGoalType(intentGoalType);
subIntentGoalBean.setIntent(subIntent);
@@ -134,7 +138,9 @@ public class CLLBusinessDecisionModule extends DecisionModule {
@Override
public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationCreateProcess(IntentGoalBean intentGoalBean) {
+ log.info("CLLBusinessIntentManagementFunction investigation create process start");
boolean needDecompostion = needDecompostion(intentGoalBean);
+ log.debug("CLLBusinessIntentManagementFunction need decompose :" + needDecompostion);
LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>();
if (needDecompostion) {
List<IntentGoalBean> subIntentGoalList = intentDecomposition(intentGoalBean);
@@ -146,6 +152,10 @@ public class CLLBusinessDecisionModule extends DecisionModule {
} else {
intentMap.put(intentGoalBean, exploreIntentHandlers(intentGoalBean));
}
+ log.info("CLLBusinessIntentManagementFunction investigation create process finished");
+ log.debug("CLLBusinessIntentManagementFunction decomposed subIntent list name :"
+ + StringUtils.join(intentMap.keySet().stream().map(IntentGoalBean::getIntent)
+ .map(Intent::getIntentName).collect(Collectors.toList()), ","));
return intentMap;
}
@@ -153,6 +163,7 @@ public class CLLBusinessDecisionModule extends DecisionModule {
@Override
//format is
public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean) {
+ log.info("CLLBusinessIntentManagementFunction investigation update process start");
//get cll-delivery cll-assurance intent
Intent originIntent = intentGoalBean.getIntent();
List<Expectation> originIntentExpectationList = originIntent.getIntentExpectations();
@@ -163,22 +174,26 @@ public class CLLBusinessDecisionModule extends DecisionModule {
IntentManagementFunction intentHandlerInfo = intentContextService.getHandlerInfo(intent);
boolean bFindIntent = false;
for (Expectation originExpectation : originIntentExpectationList) {
- if (intent.getIntentName().replace("Intent","")
- .equals(originExpectation.getExpectationName().replace("Expectation",""))){
+ if (intent.getIntentName().replace("Intent", "")
+ .equals(originExpectation.getExpectationName().replace("Expectation", ""))) {
bFindIntent = true;
break;
}
}
- if (false == bFindIntent){
+ if (false == bFindIntent) {
intentContextService.deleteSubIntentContext(originIntent, intent.getIntentId());
IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.DELETE);
intentMap.put(subIntentGoalBean, intentHandlerInfo);
- }else{
+ } else {
IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.UPDATE);
intentMap.put(subIntentGoalBean, intentHandlerInfo);
}
}
+ log.info("CLLBusinessIntentManagementFunction investigation update process finished");
+ log.debug("CLLBusinessIntentManagementFunction investigation update process intent list name "
+ + StringUtils.join(intentMap.keySet().stream().map(IntentGoalBean::getIntent)
+ .map(Intent::getIntentName).collect(Collectors.toList()), ","));
return intentMap;
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java
index fd63581..1a53be5 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java
@@ -39,4 +39,18 @@ public final class ResponseConsts {
* delete data from database failed.
*/
public static final int RET_DELETE_DATA_FAIL = 10004;
+
+ /**
+ * obtain the corresponding IntentManagementFunction failed
+ */
+ public static final int RET_FIND_CORRESPONDING_FAIL = 10005;
+ /**
+ * response success
+ */
+ public static final int RSEPONSE_SUCCESS = 200;
+
+ /**
+ * response error
+ */
+ public static final int RESPONSE_ERROR = 500;
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IMFRegInfoController.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IMFRegInfoController.java
index c00103a..73c3cb1 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IMFRegInfoController.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IMFRegInfoController.java
@@ -19,6 +19,7 @@
package org.onap.usecaseui.intentanalysis.controller;
import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo;
+import org.onap.usecaseui.intentanalysis.bean.models.ServiceResult;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentFunctionManageService.IMFRegInfoService;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -38,15 +39,15 @@ public class IMFRegInfoController {
return ResponseEntity.ok(IMFRegInfoService.createFunctionManage(intentManage));
}
- @DeleteMapping(produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity deleteIntentManage(@PathVariable(value = "id") String id) {
- return ResponseEntity.ok(IMFRegInfoService.deleteFunctionManage(id));
+ @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ServiceResult deleteIntentManage(@PathVariable(value = "id") String id) {
+ return IMFRegInfoService.deleteFunctionManage(id);
}
- @PutMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity updateIntentManageById(
+ @PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ServiceResult updateIntentManageById(
@PathVariable(value = "id") String id, @RequestBody IntentManagementFunctionRegInfo intentManage) {
- return ResponseEntity.ok(IMFRegInfoService.updateIntentManageById(id, intentManage));
+ return IMFRegInfoService.updateIntentManageById(id, intentManage);
}
@GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java
index fcbee7c..0272e3f 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java
@@ -17,10 +17,14 @@
package org.onap.usecaseui.intentanalysis.controller;
-import io.swagger.models.auth.In;
+import lombok.extern.log4j.Log4j2;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGenerateType;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
+import org.onap.usecaseui.intentanalysis.bean.models.ResultHeader;
+import org.onap.usecaseui.intentanalysis.bean.models.ServiceResult;
+import org.onap.usecaseui.intentanalysis.exception.CommonException;
import org.onap.usecaseui.intentanalysis.formatintentinputMgt.FormatIntentInputManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService.IntentProcessService;
import org.onap.usecaseui.intentanalysis.service.IntentService;
@@ -31,7 +35,10 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
+import static org.onap.usecaseui.intentanalysis.common.ResponseConsts.RESPONSE_ERROR;
+import static org.onap.usecaseui.intentanalysis.common.ResponseConsts.RSEPONSE_SUCCESS;
+@Log4j2
@RestController
@RequestMapping("/intents")
public class IntentController {
@@ -52,41 +59,85 @@ public class IntentController {
}
@GetMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<Intent> getIntentById(
- @PathVariable(INTENT_ID) String intentId) {
- return ResponseEntity.ok(intentService.getIntent(intentId));
+ public ServiceResult getIntentById(
+ @PathVariable(INTENT_ID) String intentId) {
+ return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "get Intent success"),
+ intentService.getIntent(intentId));
+
}
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<Intent> createIntent(@RequestBody Intent intent) {
-
- processService.setIntentRole(formatIntentInputManagementFunction, null);
- //save original intent
- IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE);
- IntentGoalBean newIntentGoalBean = processService.intentProcess(intentGoalBean);
- return ResponseEntity.ok(intentService.createIntent(newIntentGoalBean.getIntent()));
+ public ServiceResult createIntent(@RequestBody Intent intent) {
+ ResultHeader resultHeader = new ResultHeader();
+ Intent returnIntent = new Intent();
+ log.info("Execute create intent %s start",intent.getIntentName());
+ try {
+ processService.setIntentRole(formatIntentInputManagementFunction, null);
+ IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.CREATE);
+ IntentGoalBean newIntentGoalBean = processService.intentProcess(intentGoalBean);
+
+ newIntentGoalBean.getIntent().setIntentGenerateType(IntentGenerateType.USERINPUT);
+ returnIntent = intentService.createIntent(newIntentGoalBean.getIntent());
+ resultHeader.setResult_code(RSEPONSE_SUCCESS);
+ resultHeader.setResult_message("create intent success");
+ log.info("Execute create intent finished");
+ } catch (CommonException exception) {
+ log.error("Execute create intent Exception:", exception);
+ resultHeader.setResult_code(exception.getRetCode());
+ resultHeader.setResult_message(exception.getMessage());
+ } catch (Exception exception) {
+ log.error("Execute create intent Exception:", exception);
+ resultHeader.setResult_code(RESPONSE_ERROR);
+ resultHeader.setResult_message(exception.getMessage());
+ }
+ return new ServiceResult(resultHeader, returnIntent);
}
@PutMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<Intent> updateIntentById(
- @PathVariable(INTENT_ID) String intentId,
- @RequestBody Intent intent) {
-
- processService.setIntentRole(formatIntentInputManagementFunction, null);
- //save original intent
-
- IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.UPDATE);
- IntentGoalBean newIntentGoalBean = processService.intentProcess(intentGoalBean);
- return ResponseEntity.ok(intentService.updateIntent(newIntentGoalBean.getIntent()));
+ public ServiceResult updateIntentById(@PathVariable(INTENT_ID) String intentId,
+ @RequestBody Intent intent) {
+ log.info("Execute update intent start");
+ try {
+ processService.setIntentRole(formatIntentInputManagementFunction, null);
+ IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.UPDATE);
+ IntentGoalBean newIntentGoalBean = processService.intentProcess(intentGoalBean);
+ Intent reIntent = intentService.updateIntent(newIntentGoalBean.getIntent());
+ log.info("Execute update intent finished");
+ return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "update intent success"), reIntent);
+ } catch (CommonException exception) {
+ log.error("Execute update intent Exception:", exception);
+ return new ServiceResult(new ResultHeader(exception.getRetCode(), exception.getMessage()));
+ } catch (Exception exception) {
+ log.error("Execute update intent Exception:", exception);
+ return new ServiceResult(new ResultHeader(RESPONSE_ERROR, exception.getMessage()));
+ }
}
@DeleteMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
- public void removeIntentById(@PathVariable(INTENT_ID) String intentId) {
+ public ServiceResult removeIntentById(@PathVariable(INTENT_ID) String intentId) {
+ log.info("Execute delete intent start");
+ try {
+ processService.setIntentRole(formatIntentInputManagementFunction, null);
+ Intent intent = intentService.getIntent(intentId);
+ IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.DELETE);
+ processService.intentProcess(intentGoalBean);
+ log.info("Execute delete intent finished");
+ return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "delete intent success"));
+ } catch (CommonException exception) {
+ log.error("Execute delete intent Exception:", exception);
+ return new ServiceResult(new ResultHeader(exception.getRetCode(), exception.getMessage()));
+ }
+ }
- processService.setIntentRole(formatIntentInputManagementFunction, null);
- Intent intent = intentService.getIntent(intentId);
- IntentGoalBean intentGoalBean = new IntentGoalBean(intent, IntentGoalType.DELETE);
- processService.intentProcess(intentGoalBean);
+ @GetMapping(value = {"/intentGenerateType/{intentGenerateType}"}, produces = "application/json")
+ public ServiceResult getIntentListByIntentGenerateType(
+ @PathVariable(value = "intentGenerateType") String intentGenerateType) {
+ try {
+ List<Intent> list = intentService.getIntentListByUserInput(intentGenerateType);
+ return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "query success"), list);
+ } catch (CommonException exception) {
+ return new ServiceResult(new ResultHeader(exception.getRetCode(), exception.getMessage()));
+ }
}
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java
index 7f136fa..fee876b 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java
@@ -23,4 +23,7 @@ public class CommonException extends RuntimeException{
super(message);
errMsg = new ErrorMessage(ret, null);
}
+ public int getRetCode(){
+ return this.errMsg.getRetCode();
+ }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/IntentInputException.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/IntentInputException.java
new file mode 100644
index 0000000..d6d5c6f
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/IntentInputException.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2022 CMCC Technologies Co., Ltd.
+ *
+ * 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.intentanalysis.exception;
+
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+
+public class IntentInputException extends CommonException {
+
+ public IntentInputException(String message, int ret) {
+
+ super(message, ret);
+ }
+
+
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java
index 9e0a443..be6d9ef 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/formatintentinputMgt/formatintentinputModule/FormatIntentInputDecisionModule.java
@@ -15,29 +15,29 @@
*/
package org.onap.usecaseui.intentanalysis.formatintentinputMgt.formatintentinputModule;
-import java.util.ArrayList;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
-import org.onap.usecaseui.intentanalysis.bean.enums.OperatorType;
-import org.onap.usecaseui.intentanalysis.bean.models.Condition;
-import org.onap.usecaseui.intentanalysis.bean.models.Context;
import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.cllBusinessIntentMgt.CLLBusinessIntentManagementFunction;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.IntentInputException;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.contextService.IntentContextService;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
import org.onap.usecaseui.intentanalysis.service.IntentService;
-import org.onap.usecaseui.intentanalysis.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
+import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
+@Slf4j
@Component
public class FormatIntentInputDecisionModule extends DecisionModule {
@Autowired
@@ -58,8 +58,11 @@ public class FormatIntentInputDecisionModule extends DecisionModule {
// if intentName contain cll return
if (intentGoalBean.getIntent().getIntentName().toLowerCase(Locale.ROOT).contains("cll")) {
return (IntentManagementFunction) applicationContext.getBean(CLLBusinessIntentManagementFunction.class.getSimpleName());
+ }else{
+ String msg = String.format("intentName is: %s can't find corresponding IntentManagementFunction,please check Intent Name",intentGoalBean.getIntent().getIntentName());
+ log.error(msg);
+ throw new IntentInputException(msg, ResponseConsts.RET_FIND_CORRESPONDING_FAIL);
}
- return null;
}
@@ -73,13 +76,16 @@ public class FormatIntentInputDecisionModule extends DecisionModule {
@Override
public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationCreateProcess(IntentGoalBean intentGoalBean) {
+ log.info("FormatIntentInputMgt investigation create process start");
LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>();
boolean needDecompostion = needDecompostion(intentGoalBean);
+ log.debug("FormatIntentInputMgt need decompose :"+ needDecompostion);
if (needDecompostion) {
intentDecomposition(intentGoalBean);
} else {
intentMap.put(intentGoalBean, exploreIntentHandlers(intentGoalBean));
}
+ log.info("FormatIntentInputMgt investigation create process finished");
return intentMap;
}
@@ -106,6 +112,7 @@ public class FormatIntentInputDecisionModule extends DecisionModule {
@Override
//format is
public LinkedHashMap<IntentGoalBean, IntentManagementFunction> investigationUpdateProcess(IntentGoalBean intentGoalBean) {
+ log.info("FormatIntentInputMgt investigation update process start");
//get format-cll intent
LinkedHashMap<IntentGoalBean, IntentManagementFunction> intentMap = new LinkedHashMap<>();
// update format-cll intentContext
@@ -118,6 +125,7 @@ public class FormatIntentInputDecisionModule extends DecisionModule {
IntentGoalBean subIntentGoalBean = new IntentGoalBean(intent, IntentGoalType.UPDATE);
intentMap.put(subIntentGoalBean, intentHandlerInfo);
}
+ log.info("FormatIntentInputMgt investigation update process finished");
return intentMap;
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/IMFRegInfoService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/IMFRegInfoService.java
index ead7a0c..9d20b60 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/IMFRegInfoService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/IMFRegInfoService.java
@@ -16,15 +16,16 @@
package org.onap.usecaseui.intentanalysis.intentBaseService.intentFunctionManageService;
import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo;
+import org.onap.usecaseui.intentanalysis.bean.models.ServiceResult;
import java.util.List;
public interface IMFRegInfoService {
- int createFunctionManage(IntentManagementFunctionRegInfo intentManage) ;
+ ServiceResult createFunctionManage(IntentManagementFunctionRegInfo intentManage) ;
- int deleteFunctionManage(String id);
+ ServiceResult deleteFunctionManage(String id);
- int updateIntentManageById(String id, IntentManagementFunctionRegInfo intentManage);
+ ServiceResult updateIntentManageById(String id, IntentManagementFunctionRegInfo intentManage);
List<IntentManagementFunctionRegInfo> getIntentManage();
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/impl/IMFRegInfoServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/impl/IMFRegInfoServiceImpl.java
index 5d46d1e..cf4b154 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/impl/IMFRegInfoServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentFunctionManageService/impl/IMFRegInfoServiceImpl.java
@@ -15,7 +15,12 @@
*/
package org.onap.usecaseui.intentanalysis.intentBaseService.intentFunctionManageService.impl;
+import lombok.extern.log4j.Log4j2;
import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo;
+import org.onap.usecaseui.intentanalysis.bean.models.ResultHeader;
+import org.onap.usecaseui.intentanalysis.bean.models.ServiceResult;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentFunctionManageService.IMFRegInfoService;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
@@ -27,25 +32,52 @@ import org.springframework.stereotype.Service;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
+import static org.onap.usecaseui.intentanalysis.common.ResponseConsts.RESPONSE_ERROR;
+import static org.onap.usecaseui.intentanalysis.common.ResponseConsts.RSEPONSE_SUCCESS;
+
+@Log4j2
@Service("intentFunctionManageService")
public class IMFRegInfoServiceImpl implements IMFRegInfoService {
+
+ @Autowired
+ IMFRegInfoMapper imfRegInfoMapper;
+
@Override
- public int createFunctionManage(IntentManagementFunctionRegInfo intentManage) {
- return 0;
+ public ServiceResult createFunctionManage(IntentManagementFunctionRegInfo intentManage) {
+ try {
+ imfRegInfoMapper.insertIMFRegInfoRegInfo(intentManage);
+ return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "create intentFunctionManageInfo success"));
+ } catch (Exception exception) {
+ log.error("Execute create intentFunctionManageInfo Exception:", exception);
+ return new ServiceResult(new ResultHeader(RESPONSE_ERROR, exception.getMessage()));
+ }
}
@Override
- public int deleteFunctionManage(String id) {
- return 0;
+ public ServiceResult deleteFunctionManage(String id) {
+ try {
+ imfRegInfoMapper.deleteFunctionManageById(id);
+ return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "delete intentFunctionManageInfo " + id + " success"));
+ } catch (Exception exception) {
+ log.error("Execute delete intentFunctionManageInfo Exception:", exception);
+ return new ServiceResult(new ResultHeader(RESPONSE_ERROR, exception.getMessage()));
+ }
}
@Override
- public int updateIntentManageById(String id, IntentManagementFunctionRegInfo intentManage) {
- return 0;
+ public ServiceResult updateIntentManageById(String id, IntentManagementFunctionRegInfo intentManage) {
+ try{
+ imfRegInfoMapper.updateIntentManageById(id,intentManage);
+ return new ServiceResult(new ResultHeader(RSEPONSE_SUCCESS, "update intentFunctionManageInfo " + id + " success"));
+ }catch(Exception exception){
+ log.error("Execute update intentFunctionManageInfo Exception:", exception);
+ return new ServiceResult(new ResultHeader(RESPONSE_ERROR, exception.getMessage()));
+ }
}
@Override
public List<IntentManagementFunctionRegInfo> getIntentManage() {
- return null;
+
+ return imfRegInfoMapper.getImfRegInfoList();
}
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java
index 27ae97c..51d50d4 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentModule/DecisionModule.java
@@ -16,7 +16,9 @@
package org.onap.usecaseui.intentanalysis.intentBaseService.intentModule;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
+import org.onap.usecaseui.intentanalysis.bean.enums.IntentGenerateType;
import org.onap.usecaseui.intentanalysis.bean.models.*;
import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
import org.onap.usecaseui.intentanalysis.util.CommonUtil;
@@ -26,7 +28,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
-
+@Slf4j
public abstract class DecisionModule {
public abstract void determineUltimateGoal();
@@ -34,9 +36,11 @@ public abstract class DecisionModule {
public abstract IntentManagementFunction exploreIntentHandlers(IntentGoalBean intentGoalBean);
public Intent intentDefinition(Intent originIntent, Intent intent) {
+ log.debug("definition create process start to define intent:" + intent.getIntentName());
Intent newIntent = new Intent();
newIntent.setIntentId(CommonUtil.getUUid());
newIntent.setIntentName(intent.getIntentName());
+ newIntent.setIntentGenerateType(IntentGenerateType.SYSTEMGENARATE);
List<Expectation> originalExpectationList = intent.getIntentExpectations();
List<Expectation> newExpectationList = new ArrayList<>();
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java
index 92be843..c2a48ff 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentDefinitionService.java
@@ -16,6 +16,7 @@
package org.onap.usecaseui.intentanalysis.intentBaseService.intentProcessService;
+import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
@@ -28,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
-
+@Slf4j
@Service
public class IntentDefinitionService {
@@ -59,7 +60,8 @@ public class IntentDefinitionService {
intentContextService.updateIntentOwnerHandlerContext(newIdIntent, intentOwner, intentHandler);
intentContextService.updateParentIntentContext(originIntent, newIdIntent);
intentContextService.updateChindIntentContext(originIntent, newIdIntent);
- intentActuationModule.saveIntentToDb(newIdIntent);//id type
+ log.debug(newIdIntent.toString());
+ intentActuationModule.saveIntentToDb(newIdIntent);
return new IntentGoalBean(newIdIntent,IntentGoalType.CREATE);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java
index 331628f..6776175 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/intentProcessService/IntentProcessService.java
@@ -22,6 +22,7 @@ import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunct
import org.onap.usecaseui.intentanalysis.service.IntentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -54,6 +55,7 @@ public class IntentProcessService {
}
}
+ @Transactional(rollbackFor = Exception.class)
public IntentGoalBean intentProcess(IntentGoalBean originIntentGoalBean) {
intentDetectionService.setIntentRole(intentOwner, intentHandler);
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java
index 0e76679..030bb45 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IMFRegInfoMapper.java
@@ -16,12 +16,18 @@
package org.onap.usecaseui.intentanalysis.mapper;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo;
import java.util.List;
@Mapper
public interface IMFRegInfoMapper {
- int insertIMFRegInfoRegInfo(IntentManagementFunctionRegInfo info);
+ int insertIMFRegInfoRegInfo(@Param(value = "imf")IntentManagementFunctionRegInfo imf);
List<IntentManagementFunctionRegInfo> getImfRegInfoList();
+
+ int deleteFunctionManageById(String id);
+
+ int updateIntentManageById(@Param(value = "id") String id,
+ @Param(value = "imf") IntentManagementFunctionRegInfo imf);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
index 1178b6d..d94f11d 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
@@ -38,4 +38,6 @@ public interface IntentMapper {
int deleteIntent(@Param(value = "intentId") String intentId);
List<Intent> getIntentByName(@Param(value = "intentName") String name);
+
+ List<Intent> getIntentListByIntentGenerateType(@Param(value="intentGenerateType")String intentGenerateType);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java
index 51bbea5..2dc69da 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java
@@ -35,4 +35,6 @@ public interface IntentService {
List<Intent> getIntentByName(String name);
List<String> getSubIntentList(Intent intent);
+
+ List<Intent> getIntentListByUserInput(String intentGenerateType);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java
index 6309b1b..eaa1f58 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ImfRegInfoServiceImpl.java
@@ -21,6 +21,9 @@ import org.apache.commons.lang.StringUtils;
import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType;
import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
import org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
+import org.onap.usecaseui.intentanalysis.exception.IntentInputException;
import org.onap.usecaseui.intentanalysis.mapper.IMFRegInfoMapper;
import org.onap.usecaseui.intentanalysis.service.ImfRegInfoService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -50,7 +53,11 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService {
String intentName = intentGoalBean.getIntent().getIntentName();
IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType();
List<IntentManagementFunctionRegInfo> imfRegInfoList = imfRegInfoMapper.getImfRegInfoList();
-
+ if (CollectionUtils.isEmpty(imfRegInfoList)){
+ String msg = "query IntentManagementFunctionRegInfo from database is empty,Please contact the corresponding person in charge to check the basic configuration";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
List<IntentManagementFunctionRegInfo> imfList = new ArrayList<>();
for (IntentManagementFunctionRegInfo imfr : imfRegInfoList) {
boolean containsArea = false;
@@ -73,7 +80,9 @@ public class ImfRegInfoServiceImpl implements ImfRegInfoService {
}
}
if (CollectionUtils.isEmpty(imfList)) {
- log.info("The intent name is %s not find the corresponding IntentManagementFunction", intentName);
+ String msg = String.format("subIntent Name : %s Failed to find the corresponding IntentManagementFunction ",intentName);
+ log.error(msg,intentName);
+ throw new IntentInputException(msg, ResponseConsts.RET_FIND_CORRESPONDING_FAIL);
}
//TODO call probe interface if fail intentFulfilmentInfo throw exception
return imfList.get(0);
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
index d2b41bb..8656587 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
@@ -174,4 +174,16 @@ public class IntentServiceImpl implements IntentService {
}
return subIntentIds;
}
+
+ @Override
+ public List<Intent> getIntentListByUserInput(String intentGenerateType) {
+ List<Intent> intentList = intentMapper.getIntentListByIntentGenerateType(intentGenerateType);
+ if (CollectionUtils.isEmpty(intentList)) {
+ log.info("Intent list is null");
+ }
+ for (Intent intent : intentList) {
+ intent.setIntentExpectations(expectationService.getIntentExpectationList(intent.getIntentId()));
+ }
+ return intentList;
+ }
}
diff --git a/intentanalysis/src/main/resources/intent-analysis-init.sql b/intentanalysis/src/main/resources/intent-analysis-init.sql
index 88773f6..682c976 100644
--- a/intentanalysis/src/main/resources/intent-analysis-init.sql
+++ b/intentanalysis/src/main/resources/intent-analysis-init.sql
@@ -2,7 +2,8 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
create table if not exists intent(
intent_id varchar(255) primary key,
- intent_name varchar(255)
+ intent_name varchar(255),
+ intent_generateType VARCHAR (225)
);
create table if not exists expectation(
diff --git a/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml
index 504c244..aaca817 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/IMFRegInfoMapper.xml
@@ -8,7 +8,7 @@
<insert id="insertIMFRegInfoRegInfo">
insert into intent_management_function_reg_info(imfr_info_id,imfr_info_description,support_area,support_model,support_interfaces,handle_name,intent_function_type)
values
- (#{imfregInfo.id}, #{imfregInfo.description},#{imfregInfo.supportArea} , #{imfregInfo.supportModel},#{imfregInfo.supportInterfaces},#{imfregInfo.handleName},#{imfregInfo.intentFunctionType})
+ (#{imf.id}, #{imf.description},#{imf.supportArea} , #{imf.supportModel},#{imf.supportInterfaces},#{imf.handleName},#{imf.intentFunctionType})
</insert>
<select id="getImfRegInfoList" resultType="org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo">
@@ -17,4 +17,23 @@
from intent_management_function_reg_info
</select>
+ <delete id="deleteFunctionManageById">
+ delete from intent_management_function_reg_info
+ where imfr_info_id = #{id}
+ </delete>
+
+
+ <update id="updateIntentManageById" parameterType="org.onap.usecaseui.intentanalysis.bean.models.IntentManagementFunctionRegInfo">
+ update intent_management_function_reg_info
+ <trim prefix="set" suffixOverrides=",">
+ <if test="imf.description != null">imfr_info_description = #{imf.description},</if>
+ <if test="imf.supportArea != null">support_area = #{imf.supportArea},</if>
+ <if test="imf.supportModel != null">support_model = #{imf.supportModel},</if>
+ <if test="imf.supportInterfaces != null">support_interfaces = #{imf.supportInterfaces},</if>
+ <if test="imf.handleName != null">handle_name = #{imf.handleName},</if>
+ <if test="imf.intentFunctionType!= null">intent_function_type = #{imf.intentFunctionType},</if>
+ </trim>
+ where imfr_info_id = #{imf.id}
+ </update>
+
</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
index 57c8952..b08d88a 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
@@ -5,17 +5,17 @@
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.IntentMapper">
<select id="selectIntent" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
- select intent_id intentId, intent_name intentName from intent
+ select intent_id intentId, intent_name intentName,intent_generateType intentGenerateType from intent
where intent_id = #{intentId}
</select>
<select id="selectIntentList" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
- select intent_id intentId, intent_name intentName from intent
+ select intent_id intentId, intent_name intentName intent_generateType intentGenerateType from intent
</select>
<insert id="insertIntent">
- insert into Intent(intent_id, intent_name)
- values(#{intent.intentId}, #{intent.intentName})
+ insert into Intent(intent_id, intent_name,intent_generateType)
+ values(#{intent.intentId}, #{intent.intentName},#{intent.intentGenerateType})
</insert>
<update id="updateIntent" parameterType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
@@ -33,8 +33,13 @@
</delete>
<select id="getIntentByName" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
- select intent_id intentId, intent_name intentName from intent
+ select intent_id intentId, intent_name intentName, intent_generateType intentGenerateType from intent
where intent_name like #{intentName}
</select>
+ <select id="getIntentListByIntentGenerateType" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
+ select intent_id intentId, intent_name intentName,intent_generateType intentGenerateType from intent
+ where intent_generateType = #{intentGenerateType}
+ </select>
+
</mapper> \ No newline at end of file