aboutsummaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main
diff options
context:
space:
mode:
authorzhangfan345 <zhangfan345@huawei.com>2022-08-30 10:47:22 +0800
committerguanyu zhu <zhuguanyu5@huawei.com>2022-08-30 12:20:27 +0000
commit6331fc23cbe8321150fbcf0f176a1106e3982aa0 (patch)
tree94d8e38425d30e120f91596e82eb28d766490e9e /intentanalysis/src/main
parenta6a29c67cbb22b9b120d08fe5310a45a16d987c6 (diff)
Update intent module and CRUD APIs
Issue-ID: USECASEUI-710 Signed-off-by: zhangfan345 <zhangfan345@huawei.com> Change-Id: I3e53e952b3554235e324b87adef2a997bae82d2a Signed-off-by: zhangfan345 <zhangfan345@huawei.com>
Diffstat (limited to 'intentanalysis/src/main')
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java4
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ConditionMapper.java22
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java18
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java12
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java9
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java16
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java7
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java5
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ConditionService.java18
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java12
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java10
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java12
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfilmentInfoService.java6
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java4
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java102
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java119
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java67
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java186
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java152
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java51
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java100
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java4
-rw-r--r--intentanalysis/src/main/resources/application.yaml4
-rw-r--r--intentanalysis/src/main/resources/intent-analysis-init.sql15
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml63
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml45
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml24
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml15
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml46
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml24
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml18
32 files changed, 882 insertions, 314 deletions
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 ce51440..bb5e085 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
@@ -48,7 +48,7 @@ public class IntentController {
@GetMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Intent> getIntentById(
@PathVariable(INTENT_ID) String intentId) {
- return ResponseEntity.ok(intentService.getIntentById(intentId));
+ return ResponseEntity.ok(intentService.getIntent(intentId));
}
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@@ -65,7 +65,7 @@ public class IntentController {
@DeleteMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
public void removeIntentById(@PathVariable(INTENT_ID) String intentId) {
- intentService.deleteIntentById(intentId);
+ intentService.deleteIntent(intentId);
}
@PostMapping(value="/handleIntent",produces = MediaType.APPLICATION_JSON_VALUE)
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ConditionMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ConditionMapper.java
index 6f3c642..1d9cfc1 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ConditionMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ConditionMapper.java
@@ -26,11 +26,23 @@ import java.util.List;
@Mapper
public interface ConditionMapper {
- void insertConditionList(@Param(value = "conditionList") List<Condition> conditionList);
+ int insertConditionList(@Param(value = "conditionList") List<Condition> conditionList,
+ @Param(value = "parentId") String parentId);
+
+ int insertCondition(@Param(value = "condition") Condition condition,
+ @Param(value = "parentId") String parentId);
void insertConditionParentList(@Param(value = "conditionList") List<Condition> conditionList,
- @Param(value = "parentType") ConditionParentType conditionParentType,
- @Param(value = "parentId") String parentId);
+ @Param(value = "parentType") ConditionParentType conditionParentType,
+ @Param(value = "parentId") String parentId);
+
+ List<Condition> selectConditionList(@Param(value = "parentId") String parentId);
+
+ Condition selectCondition(@Param(value = "conditionId") String conditionId);
+
+ int updateCondition(@Param(value = "condition") Condition condition);
+
+ int deleteCondition(@Param(value = "conditionId") String conditionId);
- List<Condition> selectConditionByParentId(String parentId);
-}
+ int deleteConditionList(@Param(value = "parentId") String parentId);
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java
index 5878f81..0e72726 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ContextMapper.java
@@ -20,6 +20,7 @@ package org.onap.usecaseui.intentanalysis.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
+import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
@@ -29,6 +30,19 @@ public interface ContextMapper {
int insertContextList(@Param(value = "contextList") List<Context> contextList,
@Param(value = "parentId") String parentId);
- List<Context> selectContextByParentId(@Param(value = "parentId") String parentId);
-}
+ int insertContextParentList(@Param(value = "contextList") List<Context> contextList,
+ @Param(value = "parentId") String parentId);
+
+ List<Context> selectContextList(@Param(value = "parentId") String parentId);
+
+ Context selectContext(@Param(value = "contextId") String contextId);
+
+ int insertContext(@Param(value = "context") Context context,
+ @Param(value = "parentId") String parentId);
+ int updateContext(@Param(value = "context") Context context);
+
+ int deleteContext(@Param(value = "contextId") String contextId);
+
+ int deleteContextList(@Param(value = "parentId") String parentId);
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java
index 72d96a3..076d815 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java
@@ -29,14 +29,16 @@ public interface ExpectationMapper {
int insertIntentExpectationList(@Param(value = "intentExpectationList") List<Expectation> intentExpectationList,
@Param(value = "intentId") String intentId);
- int insertIntentExpectation(@Param(value = "expectation") Expectation expectation,
+ int insertIntentExpectation(@Param(value = "intentExpectation") Expectation intentExpectation,
@Param(value = "intentId") String intentId);
- int deleteIntentExpectationListByIntentId(@Param(value = "intentId") String intentId);
+ int deleteIntentExpectationList(@Param(value = "intentId") String intentId);
- int updateIntentExpectation(@Param(value = "expectation") Expectation expectation);
+ int updateIntentExpectation(@Param(value = "intentExpectation") Expectation intentExpectation);
- int deleteIntentExpectationById(@Param(value = "expectationId") String expectationId);
+ int deleteIntentExpectation(@Param(value = "expectationId") String expectationId);
- List<Expectation> selectIntentExpectationListByIntentId(@Param(value = "intentId") String intentId);
+ List<Expectation> selectIntentExpectationList(@Param(value = "intentId") String intentId);
+
+ Expectation selectIntentExpectation(@Param(value = "expectationId") String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
index 57f2bd3..563a5b3 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationObjectMapper.java
@@ -26,9 +26,14 @@ import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
public interface ExpectationObjectMapper {
int insertExpectationObject(@Param(value = "expectationObject") ExpectationObject expectationObject,
- @Param(value = "expectationId") String expectationId);
+ @Param(value = "expectationId") String expectationId);
- ExpectationObject selectExpectationObjectByExpectationId(@Param(value = "expectationId") String expectationId);
+ ExpectationObject selectExpectationObject(@Param(value = "expectationId") String expectationId);
String selectExpectationObjectId(@Param(value = "expectationId") String expectationId);
+
+ int updateExpectationObject(@Param(value = "expectationObject") ExpectationObject expectationObject,
+ @Param(value = "expectationId") String expectationId);
+
+ int deleteExpectationObject(@Param(value = "expectationId") String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java
index c418ff4..a0310ce 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationTargetMapper.java
@@ -27,8 +27,20 @@ import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
public interface ExpectationTargetMapper {
int insertExpectationTarget(@Param(value = "expectationTarget") ExpectationTarget expectationTarget,
+ @Param(value = "expectationId") String expectationId);
+
+ int insertExpectationTargetList(@Param(value = "expectationTargetList") List<ExpectationTarget> expectationTargetList,
@Param(value = "expectationId") String expectationId);
- List<ExpectationTarget> selectExpectationTargetListByExpectationId(
- @Param(value = "expectationId") String expectationId);
+ List<ExpectationTarget> selectExpectationTargetList(
+ @Param(value = "expectationId") String expectationId);
+
+ ExpectationTarget selectExpectationTarget(@Param(value = "expectationTargetId") String expectationTargetId);
+
+ int updateExpectationTarget(@Param(value = "expectationTarget") ExpectationTarget expectationTarget,
+ @Param(value = "expectationTargetId") String expectationTargetId);
+
+ int deleteExpectationTarget(@Param(value = "expectationTargetId") String expectationTargetId);
+
+ int deleteExpectationTargetList(@Param(value = "expectationId") String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java
index 9e3819f..278e3ab 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/FulfilmentInfoMapper.java
@@ -26,7 +26,12 @@ import org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo;
public interface FulfilmentInfoMapper {
int insertFulfilmentInfo(@Param(value = "fulfilmentInfo") FulfilmentInfo fulfilmentInfo,
+ @Param(value = "parentId") String parentId);
+
+ FulfilmentInfo selectFulfilmentInfo(@Param(value = "parentId") String parentId);
+
+ int updateFulfilmentInfo(@Param(value = "fulfilmentInfo") FulfilmentInfo fulfilmentInfo,
@Param(value = "parentId") String parentId);
- FulfilmentInfo selectFulfilmentInfoById(@Param(value = "parentId") String parentId);
+ int deleteFulfilmentInfo(@Param(value = "parentId") String parentId);
}
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 c051e68..cc253ab 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
@@ -20,6 +20,7 @@ package org.onap.usecaseui.intentanalysis.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
+
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
@@ -30,11 +31,11 @@ public interface IntentMapper {
int updateIntent(@Param(value = "intent") Intent intent);
- Intent selectIntentById(@Param(value = "intentId") String intentId);
+ Intent selectIntent(@Param(value = "intentId") String intentId);
List<Intent> selectIntentList();
- int deleteIntentById(@Param(value = "intentId") String intentId);
+ int deleteIntent(@Param(value = "intentId") String intentId);
List<Intent> getIntentByName(@Param(value = "name") String name);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ConditionService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ConditionService.java
index 474fce2..2ae288c 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ConditionService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ConditionService.java
@@ -16,9 +16,7 @@
package org.onap.usecaseui.intentanalysis.service;
-import org.onap.usecaseui.intentanalysis.bean.enums.ConditionParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Condition;
-import org.springframework.stereotype.Service;
import java.util.List;
@@ -26,16 +24,18 @@ import java.util.List;
public interface ConditionService {
- void createConditionList(List<Condition> cnditionList, ConditionParentType conditionParentType, String parentId);
+ void createConditionList(List<Condition> conditionList, String parentId);
- void insertCondition(Condition condition, String parentId);
+ void createCondition(Condition condition, String parentId);
- void deleteConditionListByParentId(String parentId);
+ void deleteConditionList(String parentId);
- void deleteConditionById(String conditionId);
+ void deleteCondition(String conditionId);
- void updateConditionListByParentId(List<Condition> conditionList, String parentId);
+ void updateConditionList(List<Condition> conditionList, String parentId);
- List<Condition> getConditionListByParentId(String parentId);
+ List<Condition> getConditionList(String parentId);
-}
+ Condition getCondition(String conditionId);
+
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java
index 502cdc2..66b3348 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ContextService.java
@@ -18,6 +18,8 @@ package org.onap.usecaseui.intentanalysis.service;
import java.util.List;
+
+import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
@@ -27,9 +29,13 @@ public interface ContextService {
void createContext(Context context, String parentId);
- void deleteContextById(String contextId);
+ void deleteContextList(String parentId);
+
+ void deleteContext(String contextId);
+
+ void updateContextList(List<Context> contextList, String parentId);
- void updateContextListByParentId(List<Context> contextList, String parentId);
+ List<Context> getContextList(String parentId);
- List<Context> getContextListByParentId(String parentId);
+ Context getContext(String contextId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java
index 4cf6bd5..7a0c239 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationObjectService.java
@@ -24,6 +24,10 @@ public interface ExpectationObjectService {
void createExpectationObject(ExpectationObject expectationObject, String expectationId);
- ExpectationObject getExpectationObjectByExpectationId(String expectationId);
+ ExpectationObject getExpectationObject(String expectationId);
+
+ void updateExpectationObject(ExpectationObject expectationObject, String expectationId);
+
+ void deleteExpectationObject(String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java
index a4f47ac..5bfa0db 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java
@@ -27,11 +27,13 @@ public interface ExpectationService {
void createIntentExpectation(Expectation expectation, String intentId);
- void deleteIntentExpectationListByIntentId(String intentId);
+ void deleteIntentExpectationList(String intentId);
- void deleteIntentExpectationById(String expectationId);
+ void deleteIntentExpectation(String expectationId);
- void updateIntentExpectationListByIntentId(List<Expectation> intentExpectationList, String intentId);
+ void updateIntentExpectationList(List<Expectation> intentExpectationList, String intentId);
- List<Expectation> getIntentExpectationListByIntentId(String intentId);
+ List<Expectation> getIntentExpectationList(String intentId);
+
+ Expectation getIntentExpectation(String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java
index 7521e59..3976bbf 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationTargetService.java
@@ -18,6 +18,8 @@ package org.onap.usecaseui.intentanalysis.service;
import java.util.List;
+
+import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
@@ -27,5 +29,13 @@ public interface ExpectationTargetService {
void createExpectationTargetList(List<ExpectationTarget> expectationTargetList, String expectationId);
- List<ExpectationTarget> getExpectationTargetListByExpectationId(String expectationId);
+ List<ExpectationTarget> getExpectationTargetList(String expectationId);
+
+ ExpectationTarget getExpectationTarget(String expectationTargetId);
+
+ void updateExpectationTargetList(List<ExpectationTarget> expectationTargetList, String expectationId);
+
+ void deleteExpectationTarget(String expectationTargetId);
+
+ void deleteExpectationTargetList(String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfilmentInfoService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfilmentInfoService.java
index 4572a2f..0692462 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfilmentInfoService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/FulfilmentInfoService.java
@@ -22,9 +22,9 @@ public interface FulfilmentInfoService {
void createFulfilmentInfo(FulfilmentInfo fulfilmentInfo, String parentId);
- void deleteFulfilmentInfoByParentId(String parentId);
+ void deleteFulfilmentInfo(String parentId);
- void updateFulfilmentInfoByParentId(FulfilmentInfo fulfilmentInfo, String parentId);
+ void updateFulfilmentInfo(FulfilmentInfo fulfilmentInfo, String parentId);
- FulfilmentInfo getFulfilmentInfoByParentId(String parentId);
+ FulfilmentInfo getFulfilmentInfo(String parentId);
}
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 9986351..d823245 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
@@ -24,13 +24,13 @@ import org.onap.usecaseui.intentanalysis.bean.models.Intent;
public interface IntentService {
List<Intent> getIntentList();
- Intent getIntentById(String intentId);
+ Intent getIntent(String intentId);
Intent createIntent(Intent intent);
Intent updateIntent(Intent intent);
- void deleteIntentById(String intentId);
+ void deleteIntent(String intentId);
List<Intent> getIntentByName(String name);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java
index 10864f1..86ab3bb 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ConditionServiceImpl.java
@@ -16,13 +16,17 @@
package org.onap.usecaseui.intentanalysis.service.impl;
import lombok.extern.slf4j.Slf4j;
-import org.onap.usecaseui.intentanalysis.bean.enums.ConditionParentType;
+
import org.onap.usecaseui.intentanalysis.bean.models.Condition;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.onap.usecaseui.intentanalysis.mapper.ConditionMapper;
import org.onap.usecaseui.intentanalysis.service.ConditionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import java.util.ArrayList;
import java.util.List;
@@ -37,33 +41,103 @@ public class ConditionServiceImpl implements ConditionService {
private ConditionService conditionService;
@Override
- public void createConditionList(List<Condition> conditionList, ConditionParentType conditionParentType, String parentId) {
- conditionMapper.insertConditionList(conditionList);
- conditionMapper.insertConditionParentList(conditionList, conditionParentType, parentId);
+ public void createConditionList(List<Condition> conditionList, String parentId) {
+ if (!CollectionUtils.isEmpty(conditionList)) {
+ if (conditionMapper.insertConditionList(conditionList, parentId) < 1) {
+ String msg = "Failed to create condition list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ log.info("Successfully created condition list to database.");
+ //conditionMapper.insertConditionParentList(conditionList,conditionParentType,parentId);
+ }
+
}
@Override
- public void insertCondition(Condition condition, String parentId) {
-
+ public void createCondition(Condition condition, String parentId) {
+ int res = conditionMapper.insertCondition(condition, parentId);
+ if (res < 1) {
+ String msg = "Failed to create condition to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ log.info("Successfully created condition to database.");
}
@Override
- public void deleteConditionListByParentId(String parentId) {
-
+ public void deleteConditionList(String parentId) {
+ List<Condition> conditionList = conditionService.getConditionList(parentId);
+ if (!CollectionUtils.isEmpty(conditionList)) {
+ int res = conditionMapper.deleteConditionList(parentId);
+ if (res < 1) {
+ String msg = "Failed to delete condition list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted condition list to database.");
+ }
}
@Override
- public void deleteConditionById(String conditionId) {
-
+ public void deleteCondition(String conditionId) {
+ Condition condition = conditionService.getCondition(conditionId);
+ if (condition != null) {
+ if (conditionMapper.deleteCondition(conditionId) < 1) {
+ String msg = "Failed to delete condition to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted condition to database.");
+ }
}
@Override
- public void updateConditionListByParentId(List<Condition> conditionList, String parentId) {
+ public void updateConditionList(List<Condition> conditionList, String parentId) {
+ List<Condition> conditionListFromDB = conditionService.getConditionList(parentId);
+ if (!CollectionUtils.isEmpty(conditionListFromDB) && CollectionUtils.isEmpty(conditionList)) {
+ conditionService.deleteConditionList(parentId);
+ } else if (CollectionUtils.isEmpty(conditionListFromDB) && !CollectionUtils.isEmpty(conditionList)) {
+ conditionService.createConditionList(conditionList, parentId);
+ } else if (!CollectionUtils.isEmpty(conditionListFromDB) && !CollectionUtils.isEmpty(conditionList)) {
+ List<String> conditionIdListFromDB = new ArrayList<>();
+ for (Condition conditionDB : conditionListFromDB) {
+ conditionIdListFromDB.add(conditionDB.getConditionId());
+ }
+ for (Condition condition : conditionList) {
+ if (conditionIdListFromDB.contains(condition.getConditionId())) {
+ if (conditionMapper.updateCondition(condition) < 1) {
+ String msg = "Failed to update condition list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ conditionIdListFromDB.remove(condition.getConditionId());
+ } else {
+ conditionService.createCondition(condition, parentId);
+ }
+ }
+ for (String conditionIdFromDB : conditionIdListFromDB) {
+ conditionService.deleteCondition(conditionIdFromDB);
+ }
+ log.info("Successfully updated condition list to database.");
+ }
+ }
+ @Override
+ public List<Condition> getConditionList(String parentId) {
+ List<Condition> conditionList = conditionMapper.selectConditionList(parentId);
+ if (CollectionUtils.isEmpty(conditionList)) {
+ log.info(String.format("Condition list is null, parentId = %s", parentId));
+ }
+ return conditionList;
}
@Override
- public List<Condition> getConditionListByParentId(String parentId) {
- return conditionMapper.selectConditionByParentId(parentId);
+ public Condition getCondition(String conditionId) {
+ Condition condition = conditionMapper.selectCondition(conditionId);
+ if (condition == null) {
+ log.info(String.format("Condition is null, conditionId = %s", conditionId));
+ }
+ return condition;
}
-}
+} \ No newline at end of file
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java
index ef75755..9623917 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ContextServiceImpl.java
@@ -19,19 +19,19 @@ package org.onap.usecaseui.intentanalysis.service.impl;
import java.util.ArrayList;
import java.util.List;
+
import lombok.extern.slf4j.Slf4j;
+
import org.onap.usecaseui.intentanalysis.bean.enums.ConditionParentType;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.springframework.stereotype.Service;
import org.onap.usecaseui.intentanalysis.bean.models.Context;
import org.onap.usecaseui.intentanalysis.mapper.ContextMapper;
-import org.onap.usecaseui.intentanalysis.service.ConditionService;
import org.onap.usecaseui.intentanalysis.service.ContextService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
+import org.onap.usecaseui.intentanalysis.service.ConditionService;
+import org.springframework.util.CollectionUtils;
@Service
@@ -51,37 +51,116 @@ public class ContextServiceImpl implements ContextService {
@Override
public void createContextList(List<Context> contextList, String parentId) {
- if (contextMapper.insertContextList(contextList, parentId) < 1) {
- String msg = "Create context list to database failed.";
+ if (!CollectionUtils.isEmpty(contextList)) {
+ for (Context context : contextList) {
+ conditionService.createConditionList(context.getContextConditions(), context.getContextId());
+ }
+ if (contextMapper.insertContextList(contextList, parentId) < 1) {
+ String msg = "Failed to create context list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ log.info("Successfully created context list to database.");
+ }
+
+
+ //contextMapper.insertContextParentList(contextList, parentId);
+ }
+
+ @Override
+ public void createContext(Context context, String parentId) {
+ conditionService.createConditionList(context.getContextConditions(), context.getContextId());
+ if (contextMapper.insertContext(context, parentId) < 1) {
+ String msg = "Failed to create context to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
- for (Context context : contextList) {
- conditionService.createConditionList(context.getContextConditions(), conditionParentType.CONTEXT,
- context.getContextId());
- }
+ log.info("Successfully created context to database.");
}
@Override
- public void createContext(Context context, String parentId) {
+ public void deleteContextList(String parentId) {
+ List<Context> contextList = contextService.getContextList(parentId);
+ if (!CollectionUtils.isEmpty(contextList)) {
+ for (Context context : contextList) {
+ conditionService.deleteConditionList(context.getContextId());
+ }
+ if (contextMapper.deleteContextList(parentId) < 1) {
+ String msg = "Failed to delete context list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted context list to database.");
+ }
+
}
@Override
- public void deleteContextById(String contextId) {
+ public void deleteContext(String contextId) {
+ Context context = contextService.getContext(contextId);
+ if (context != null) {
+ conditionService.deleteConditionList(contextId);
+ if (contextMapper.deleteContext(contextId) < 1) {
+ String msg = "Failed to delete context to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted context to database.");
+ }
}
@Override
- public void updateContextListByParentId(List<Context> contextList, String parentId) {
+ public void updateContextList(List<Context> contextList, String parentId) {
+ List<Context> contextListFromDB = contextService.getContextList(parentId);
+ if (!CollectionUtils.isEmpty(contextListFromDB) && CollectionUtils.isEmpty(contextList)) {
+ contextService.deleteContextList(parentId);
+ } else if (CollectionUtils.isEmpty(contextListFromDB) && !CollectionUtils.isEmpty(contextList)) {
+ contextService.createContextList(contextList, parentId);
+ } else if (!CollectionUtils.isEmpty(contextListFromDB) && !CollectionUtils.isEmpty(contextList)) {
+ List<String> contextIdListFromDB = new ArrayList<>();
+ for (Context contextInDB : contextListFromDB) {
+ contextIdListFromDB.add(contextInDB.getContextId());
+ }
+ for (Context context : contextList) {
+ if (contextIdListFromDB.contains(context.getContextId())) {
+ if (contextMapper.updateContext(context) < 1) {
+ String msg = "Failed to update context list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ contextIdListFromDB.remove(context.getContextId());
+ } else {
+ contextService.createContext(context, parentId);
+ }
+ }
+ for (String contextIdFromDB : contextIdListFromDB) {
+ contextService.deleteContext(contextIdFromDB);
+ }
+ log.info("Successfully updated context list to database.");
+ }
}
@Override
- public List<Context> getContextListByParentId(String parentId) {
- List<Context> contextList = contextMapper.selectContextByParentId(parentId);
- if (contextList == null) {
- String msg = String.format("Context: Intent id %s doesn't exist in database.", parentId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ public List<Context> getContextList(String parentId) {
+ List<Context> contextList = contextMapper.selectContextList(parentId);
+ if (!CollectionUtils.isEmpty(contextList)) {
+ for (Context context : contextList) {
+ context.setContextConditions(conditionService.getConditionList(context.getContextId()));
+ }
+ } else {
+ log.info(String.format("Context list is null, parentId = %s", parentId));
}
return contextList;
}
-} \ No newline at end of file
+
+ @Override
+ public Context getContext(String contextId) {
+ Context context = contextMapper.selectContext(contextId);
+ if (context != null) {
+ context.setContextConditions(conditionService.getConditionList(contextId));
+ } else {
+ log.info(String.format("Condition is null, contextId = %s", contextId));
+ }
+ return context;
+ }
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
index d94dfdc..d3bfd34 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationObjectServiceImpl.java
@@ -17,21 +17,29 @@
package org.onap.usecaseui.intentanalysis.service.impl;
+import java.util.ArrayList;
+import java.util.List;
+
import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject;
+import org.onap.usecaseui.intentanalysis.bean.models.Context;
import org.onap.usecaseui.intentanalysis.mapper.ExpectationObjectMapper;
import org.onap.usecaseui.intentanalysis.service.ContextService;
import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
+import org.springframework.util.CollectionUtils;
@Service
@Slf4j
public class ExpectationObjectServiceImpl implements ExpectationObjectService {
+ private ContextParentType contextParentType;
+
@Autowired
private ExpectationObjectMapper expectationObjectMapper;
@@ -43,25 +51,60 @@ public class ExpectationObjectServiceImpl implements ExpectationObjectService {
@Override
public void createExpectationObject(ExpectationObject expectationObject, String expectationId) {
+ contextService.createContextList(expectationObject.getObjectContexts(),
+ expectationObjectMapper.selectExpectationObjectId(expectationId));
if (expectationObjectMapper.insertExpectationObject(expectationObject, expectationId) < 1) {
- String msg = "Create expectation object to database failed.";
+ String msg = "Failed to create expectation object to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
- contextService.createContextList(expectationObject.getObjectContexts(),
- expectationObjectMapper.selectExpectationObjectId(expectationId));
+ log.info("Successfully created expectation object to database.");
}
@Override
- public ExpectationObject getExpectationObjectByExpectationId(String expectationId) {
- ExpectationObject expectationObject = expectationObjectMapper.selectExpectationObjectByExpectationId(expectationId);
- if (expectationObject == null) {
- String msg = String.format("ExpectationObject: expectation id %s doesn't exist in database.", expectationId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ public ExpectationObject getExpectationObject(String expectationId) {
+ ExpectationObject expectationObject = expectationObjectMapper.selectExpectationObject(expectationId);
+ String expectationObjectId = expectationObjectMapper.selectExpectationObjectId(expectationId);
+ List<Context> contextList = contextService.getContextList(expectationObjectId);
+ if (!CollectionUtils.isEmpty(contextList)) {
+ expectationObject.setObjectContexts(contextService.getContextList(expectationObjectId));
+ } else {
+ log.info(String.format("Expectation object is null, expectationObjectId = %s", expectationObjectId));
}
- expectationObject.setObjectContexts(contextService.getContextListByParentId(expectationObjectMapper.selectExpectationObjectId(expectationId)));
-
return expectationObject;
}
-} \ No newline at end of file
+
+ @Override
+ public void updateExpectationObject(ExpectationObject expectationObject, String expectationId) {
+ ExpectationObject expectationObjectFromDB = expectationObjectService.getExpectationObject(expectationId);
+ if (expectationObject == null && expectationObjectFromDB != null) {
+ expectationObjectService.deleteExpectationObject(expectationId);
+ } else if (expectationObject != null && expectationObjectFromDB == null) {
+ expectationObjectService.createExpectationObject(expectationObject, expectationId);
+ } else if (expectationObject != null) {
+ contextService.updateContextList(expectationObject.getObjectContexts(),
+ expectationObjectMapper.selectExpectationObjectId(expectationId));
+ if (expectationObjectMapper.updateExpectationObject(expectationObject, expectationId) < 1) {
+ String msg = "Failed to update expectation object to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ log.info("Successfully updated expectation object to database.");
+ }
+
+ }
+
+ @Override
+ public void deleteExpectationObject(String expectationId) {
+ ExpectationObject expectationObject = expectationObjectService.getExpectationObject(expectationId);
+ if (expectationObject != null) {
+ contextService.deleteContextList(expectationObjectMapper.selectExpectationObjectId(expectationId));
+ if (expectationObjectMapper.deleteExpectationObject(expectationId) < 1) {
+ String msg = "Failed to update expectation object to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted expectation object to database.");
+ }
+ }
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java
index 76911e9..7052ed3 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java
@@ -19,14 +19,21 @@ package org.onap.usecaseui.intentanalysis.service.impl;
import java.util.ArrayList;
import java.util.List;
+
import lombok.extern.slf4j.Slf4j;
-import org.onap.usecaseui.intentanalysis.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.onap.usecaseui.intentanalysis.mapper.ExpectationMapper;
+import org.onap.usecaseui.intentanalysis.service.ContextService;
+import org.onap.usecaseui.intentanalysis.service.ExpectationService;
+import org.onap.usecaseui.intentanalysis.service.ExpectationObjectService;
+import org.onap.usecaseui.intentanalysis.service.ExpectationTargetService;
+import org.onap.usecaseui.intentanalysis.service.FulfilmentInfoService;
+import org.springframework.util.CollectionUtils;
@Service
@@ -48,110 +55,155 @@ public class ExpectationServiceImpl implements ExpectationService {
@Autowired
private ContextService contextService;
-
@Autowired
private FulfilmentInfoService fulfilmentInfoService;
+ private ContextParentType contextParentType;
+
@Override
public void createIntentExpectationList(List<Expectation> intentExpectationList, String intentId) {
+ for (Expectation expectation : intentExpectationList) {
+ if (expectation != null) {
+ String expectationId = expectation.getExpectationId();
+ expectationObjectService.createExpectationObject(expectation.getExpectationObject(),
+ expectationId);
+ expectationTargetService.createExpectationTargetList(expectation.getExpectationTargets(),
+ expectationId);
+ contextService.createContextList(expectation.getExpectationContexts(), expectationId);
+ fulfilmentInfoService.createFulfilmentInfo(expectation.getExpectationFulfilmentInfo(),
+ expectationId);
+ }
+ }
if (expectationMapper.insertIntentExpectationList(intentExpectationList, intentId) < 1) {
- String msg = "Create expectation to database failed.";
+ String msg = "Failed to create expectation list to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
- for (Expectation expectation : intentExpectationList) {
- String expectationId = expectation.getExpectationId();
- expectationObjectService.createExpectationObject(expectation.getExpectationObject(),
- expectationId);
- expectationTargetService.createExpectationTargetList(expectation.getExpectationTargets(),
- expectationId);
- contextService.createContextList(expectation.getExpectationContexts(), expectationId);
- fulfilmentInfoService.createFulfilmentInfo(expectation.getExpectationFulfilmentInfo(),
- expectationId);
- }
+ log.info("Successfully created expectation list to database.");
}
@Override
public void createIntentExpectation(Expectation expectation, String intentId) {
+ expectationObjectService.createExpectationObject(expectation.getExpectationObject(),
+ expectation.getExpectationId());
+ expectationTargetService.createExpectationTargetList(expectation.getExpectationTargets(),
+ expectation.getExpectationId());
+ contextService.createContextList(expectation.getExpectationContexts(),
+ expectation.getExpectationId());
+ fulfilmentInfoService.createFulfilmentInfo(expectation.getExpectationFulfilmentInfo(),
+ expectation.getExpectationId());
+
if (expectationMapper.insertIntentExpectation(expectation, intentId) < 1) {
- String msg = "Create expectation to database failed.";
+ String msg = "Failed to create expectation to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
+ log.info("Successfully created expectation to database.");
}
@Override
- public List<Expectation> getIntentExpectationListByIntentId(String intentId) {
- List<Expectation> expectationList = expectationMapper.selectIntentExpectationListByIntentId(intentId);
- if (expectationList == null) {
- String msg = String.format("Expectation: Intent id %s doesn't exist in database.", intentId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- for (Expectation expectation : expectationList) {
- if (expectation != null) {
+ public List<Expectation> getIntentExpectationList(String intentId) {
+ List<Expectation> expectationList = expectationMapper.selectIntentExpectationList(intentId);
+ if (!CollectionUtils.isEmpty(expectationList)) {
+ for (Expectation expectation : expectationList) {
String expectationId = expectation.getExpectationId();
- expectation.setExpectationObject(expectationObjectService.getExpectationObjectByExpectationId(expectationId));
- expectation.setExpectationTargets(expectationTargetService.getExpectationTargetListByExpectationId(expectationId));
- expectation.setExpectationContexts(contextService.getContextListByParentId(expectationId));
- expectation.setExpectationFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfoByParentId(expectationId));
+ expectation.setExpectationObject(expectationObjectService.getExpectationObject(expectationId));
+ expectation.setExpectationTargets(expectationTargetService.getExpectationTargetList(expectationId));
+ expectation.setExpectationContexts(contextService.getContextList(expectationId));
+ expectation.setExpectationFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfo(expectationId));
}
+ } else {
+ log.info(String.format("Expectation list is null, intentId = %s", intentId));
}
return expectationList;
}
@Override
- public void updateIntentExpectationListByIntentId(List<Expectation> intentExpectationList, String intentId) {
- List<Expectation> expectationList = expectationMapper.selectIntentExpectationListByIntentId(intentId);
- if (expectationList == null) {
- String msg = String.format("Intent id %s doesn't exist in database.", intentId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- List<String> expectationIdList = new ArrayList<>();
- for (Expectation expectationDB : expectationList) {
- expectationIdList.add(expectationDB.getExpectationId());
+ public Expectation getIntentExpectation(String expectationId) {
+ Expectation expectation = expectationMapper.selectIntentExpectation(expectationId);
+ if (expectation != null) {
+ expectation.setExpectationObject(expectationObjectService.getExpectationObject(expectationId));
+ expectation.setExpectationTargets(expectationTargetService.getExpectationTargetList(expectationId));
+ expectation.setExpectationContexts(contextService.getContextList(expectationId));
+ expectation.setExpectationFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfo(expectationId));
+ } else {
+ log.info(String.format("Expectation is null, expectationId = %s", expectationId));
}
+ return expectation;
+ }
- for (Expectation expectation : intentExpectationList) {
- if (expectationIdList.contains(expectation.getExpectationId())) {
- if (expectationMapper.updateIntentExpectation(expectation) < 1) {
- String msg = "Update expectation in database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ @Override
+ public void updateIntentExpectationList(List<Expectation> intentExpectationList, String intentId) {
+ List<Expectation> expectationListFromDB = expectationService.getIntentExpectationList(intentId);
+ if (CollectionUtils.isEmpty(expectationListFromDB) && !CollectionUtils.isEmpty(intentExpectationList)) {
+ expectationService.createIntentExpectationList(intentExpectationList, intentId);
+ } else if (!CollectionUtils.isEmpty(expectationListFromDB) && CollectionUtils.isEmpty(intentExpectationList)) {
+ expectationService.deleteIntentExpectationList(intentId);
+ } else if (!CollectionUtils.isEmpty(expectationListFromDB) && !CollectionUtils.isEmpty(intentExpectationList)) {
+ List<String> expectationIdListFromDB = new ArrayList<>();
+ for (Expectation expectationDB : expectationListFromDB) {
+ expectationIdListFromDB.add(expectationDB.getExpectationId());
+ }
+
+ for (Expectation expectation : intentExpectationList) {
+ if (expectationIdListFromDB.contains(expectation.getExpectationId())) {
+ expectationObjectService.updateExpectationObject(expectation.getExpectationObject(), expectation.getExpectationId());
+ expectationTargetService.updateExpectationTargetList(expectation.getExpectationTargets(), expectation.getExpectationId());
+ contextService.updateContextList(expectation.getExpectationContexts(), expectation.getExpectationId());
+ fulfilmentInfoService.updateFulfilmentInfo(expectation.getExpectationFulfilmentInfo(), expectation.getExpectationId());
+ if (expectationMapper.updateIntentExpectation(expectation) < 1) {
+ String msg = "Failed to update expectation to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ expectationIdListFromDB.remove(expectation.getExpectationId());
+ } else {
+ expectationService.createIntentExpectation(expectation, intentId);
}
- expectationIdList.remove(expectation.getExpectationId());
- } else {
- expectationService.createIntentExpectation(expectation, intentId);
}
+ for (String expectationIdFromDB : expectationIdListFromDB) {
+ expectationService.deleteIntentExpectation(expectationIdFromDB);
+ }
+ log.info("Successfully updated expectation list to database.");
}
- for (String expectationDBId : expectationIdList) {
- expectationService.deleteIntentExpectationById(expectationDBId);
- }
- log.info("Expectations are successfully updated.");
+
}
@Override
- public void deleteIntentExpectationById(String expectationId) {
- if (expectationMapper.deleteIntentExpectationById(expectationId) < 1) {
- String msg = "Delete expectation in database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ public void deleteIntentExpectation(String expectationId) {
+ Expectation expectation = expectationService.getIntentExpectation(expectationId);
+ if (expectation != null) {
+ expectationObjectService.deleteExpectationObject(expectationId);
+ expectationTargetService.deleteExpectationTargetList(expectationId);
+ contextService.deleteContextList(expectationId);
+ fulfilmentInfoService.deleteFulfilmentInfo(expectationId);
+ if (expectationMapper.deleteIntentExpectation(expectationId) < 1) {
+ String msg = "Failed to delete expectation to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted expectation to database.");
}
+
}
@Override
- public void deleteIntentExpectationListByIntentId(String intentId) {
- List<Expectation> expectationList = expectationMapper.selectIntentExpectationListByIntentId(intentId);
- if (expectationList == null) {
- String msg = String.format("Intent id %s doesn't exist in database.", intentId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- if (expectationMapper.deleteIntentExpectationListByIntentId(intentId) < 1) {
- String msg = "Delete expectation in database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ public void deleteIntentExpectationList(String intentId) {
+ List<Expectation> expectationList = expectationService.getIntentExpectationList(intentId);
+ if (!CollectionUtils.isEmpty(expectationList)) {
+ for (Expectation expectation : expectationList) {
+ String expectationId = expectation.getExpectationId();
+ expectationObjectService.deleteExpectationObject(expectationId);
+ expectationTargetService.deleteExpectationTargetList(expectationId);
+ contextService.deleteContextList(expectationId);
+ fulfilmentInfoService.deleteFulfilmentInfo(expectationId);
+ }
+ if (expectationMapper.deleteIntentExpectationList(intentId) < 1) {
+ String msg = "Failed to delete expectation list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted expectation list to database.");
}
}
-} \ No newline at end of file
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java
index a6de3da..ebf430d 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationTargetServiceImpl.java
@@ -17,26 +17,31 @@
package org.onap.usecaseui.intentanalysis.service.impl;
+import java.util.ArrayList;
import java.util.List;
+import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.bean.enums.ConditionParentType;
import org.onap.usecaseui.intentanalysis.service.ConditionService;
-import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
import org.onap.usecaseui.intentanalysis.mapper.ExpectationTargetMapper;
import org.onap.usecaseui.intentanalysis.service.ContextService;
import org.onap.usecaseui.intentanalysis.service.ExpectationTargetService;
import org.onap.usecaseui.intentanalysis.service.FulfilmentInfoService;
+import org.springframework.util.CollectionUtils;
@Service
@Slf4j
public class ExpectationTargetServiceImpl implements ExpectationTargetService {
+ private ContextParentType contextParentType;
+
private ConditionParentType conditionParentType;
@Autowired
@@ -45,7 +50,6 @@ public class ExpectationTargetServiceImpl implements ExpectationTargetService {
@Autowired
private ExpectationTargetService expectationTargetService;
-
@Autowired
private FulfilmentInfoService fulfilmentInfoService;
@@ -57,42 +61,142 @@ public class ExpectationTargetServiceImpl implements ExpectationTargetService {
@Override
public void createExpectationTarget(ExpectationTarget expectationTarget, String expectationId) {
+ String expectationTargetId = expectationTarget.getTargetId();
+ contextService.createContextList(expectationTarget.getTargetContexts(), expectationTargetId);
+ fulfilmentInfoService.createFulfilmentInfo(expectationTarget.getTargetFulfilmentInfo(),
+ expectationTargetId);
+ conditionService.createConditionList(expectationTarget.getTargetConditions(), expectationTargetId);
if (expectationTargetMapper.insertExpectationTarget(expectationTarget, expectationId) < 1) {
- String msg = "Create expectation to database failed.";
+ String msg = "Failed to create expectation target to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
- contextService.createContextList(expectationTarget.getTargetContexts(), expectationTarget.getTargetId());
- fulfilmentInfoService.createFulfilmentInfo(expectationTarget.getTargetFulfilmentInfo(),
- expectationTarget.getTargetId());
- conditionService.createConditionList(expectationTarget.getTargetConditions(),
- conditionParentType.EXPECTATION_TARGET, expectationId);
+ log.info("Successfully created expectation target to database.");
+
}
@Override
public void createExpectationTargetList(List<ExpectationTarget> expectationTargetList, String expectationId) {
- for (ExpectationTarget expectationTarget : expectationTargetList) {
- if (expectationTarget != null) {
- expectationTargetService.createExpectationTarget(expectationTarget, expectationId);
+ if (!CollectionUtils.isEmpty(expectationTargetList)) {
+ for (ExpectationTarget expectationTarget : expectationTargetList) {
+ String expectationTargetId = expectationTarget.getTargetId();
+ contextService.createContextList(expectationTarget.getTargetContexts(), expectationTargetId);
+ fulfilmentInfoService.createFulfilmentInfo(expectationTarget.getTargetFulfilmentInfo(),
+ expectationTargetId);
+ conditionService.createConditionList(expectationTarget.getTargetConditions(), expectationTargetId);
+ }
+ if (expectationTargetMapper.insertExpectationTargetList(expectationTargetList, expectationId) < 1) {
+ String msg = "Failed to create expectation target list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
+ log.info("Successfully created expectation target list to database.");
}
+
}
@Override
- public List<ExpectationTarget> getExpectationTargetListByExpectationId(String expectationId) {
- List<ExpectationTarget> expectationTargetList = expectationTargetMapper.selectExpectationTargetListByExpectationId(expectationId);
- if (expectationTargetList == null) {
- String msg = String.format("Target: Expectation id %s doesn't exist in database.", expectationId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
- }
- for (ExpectationTarget expectationTarget : expectationTargetList) {
- if (expectationTarget != null) {
- String targetId = expectationTarget.getTargetId();
- expectationTarget.setTargetContexts(contextService.getContextListByParentId(targetId));
- expectationTarget.setTargetFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfoByParentId(targetId));
+ public List<ExpectationTarget> getExpectationTargetList(String expectationId) {
+ List<ExpectationTarget> expectationTargetList = expectationTargetMapper.selectExpectationTargetList(expectationId);
+ if (!CollectionUtils.isEmpty(expectationTargetList)) {
+ for (ExpectationTarget expectationTarget : expectationTargetList) {
+ String expectationTargetId = expectationTarget.getTargetId();
+ expectationTarget.setTargetConditions(conditionService.getConditionList(expectationTargetId));
+ expectationTarget.setTargetContexts(contextService.getContextList(expectationTargetId));
+ expectationTarget.setTargetFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfo(expectationTargetId));
}
+ } else {
+ log.info(String.format("Expectation target list is null, expectationId = %s", expectationId));
}
+
return expectationTargetList;
}
-} \ No newline at end of file
+
+ @Override
+ public ExpectationTarget getExpectationTarget(String expectationTargetId) {
+ ExpectationTarget expectationTarget = expectationTargetMapper.selectExpectationTarget(expectationTargetId);
+ if (expectationTarget != null) {
+ expectationTarget.setTargetConditions(conditionService.getConditionList(expectationTargetId));
+ expectationTarget.setTargetContexts(contextService.getContextList(expectationTargetId));
+ expectationTarget.setTargetFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfo(expectationTargetId));
+ } else {
+ log.info(String.format("Expectation target is null, expectationTargetId = %s", expectationTargetId));
+ }
+ return expectationTarget;
+ }
+
+ @Override
+ public void updateExpectationTargetList(List<ExpectationTarget> expectationTargetList, String expectationId) {
+ List<ExpectationTarget> expectationTargetListFromDB = expectationTargetService.getExpectationTargetList(expectationId);
+ if (!CollectionUtils.isEmpty(expectationTargetListFromDB) && CollectionUtils.isEmpty(expectationTargetList)) {
+ expectationTargetService.deleteExpectationTargetList(expectationId);
+ } else if (CollectionUtils.isEmpty(expectationTargetListFromDB) && !CollectionUtils.isEmpty(expectationTargetList)) {
+ expectationTargetService.createExpectationTargetList(expectationTargetList, expectationId);
+ } else if (!CollectionUtils.isEmpty(expectationTargetListFromDB) && !CollectionUtils.isEmpty(expectationTargetList)) {
+ List<String> expectationTargetIdListFromDB = new ArrayList<>();
+ for (ExpectationTarget expectationTargetDB : expectationTargetListFromDB) {
+ expectationTargetIdListFromDB.add(expectationTargetDB.getTargetId());
+ }
+
+ for (ExpectationTarget expectationTarget : expectationTargetList) {
+ String expectationTargetId = expectationTarget.getTargetId();
+ if (expectationTargetIdListFromDB.contains(expectationTargetId)) {
+ contextService.updateContextList(expectationTarget.getTargetContexts(), expectationTargetId);
+ fulfilmentInfoService.updateFulfilmentInfo(expectationTarget.getTargetFulfilmentInfo(), expectationTargetId);
+ conditionService.updateConditionList(expectationTarget.getTargetConditions(), expectationTargetId);
+ if (expectationTargetMapper.updateExpectationTarget(expectationTarget, expectationTargetId) < 1) {
+ String msg = "Failed to update expectation target list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ expectationTargetIdListFromDB.remove(expectationTargetId);
+ } else {
+ expectationTargetService.createExpectationTarget(expectationTarget, expectationTargetId);
+ }
+ }
+ for (String expectationTargetIdFromDB : expectationTargetIdListFromDB) {
+ expectationTargetService.deleteExpectationTarget(expectationTargetIdFromDB);
+ }
+ log.info("Successfully updated expectation target list to database.");
+ }
+
+ }
+
+ @Override
+ public void deleteExpectationTarget(String expectationTargetId) {
+ ExpectationTarget expectationTarget = expectationTargetService.getExpectationTarget(expectationTargetId);
+ if (expectationTarget != null) {
+ contextService.deleteContextList(expectationTargetId);
+ fulfilmentInfoService.deleteFulfilmentInfo(expectationTargetId);
+ conditionService.deleteConditionList(expectationTargetId);
+ if (expectationTargetMapper.deleteExpectationTarget(expectationTargetId) < 1) {
+ String msg = "Failed to delete expectation target to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted expectation target to database.");
+ }
+ }
+
+ @Override
+ public void deleteExpectationTargetList(String expectationId) {
+ List<ExpectationTarget> expectationTargetList = expectationTargetService.getExpectationTargetList(expectationId);
+ if (!CollectionUtils.isEmpty(expectationTargetList)) {
+ for (ExpectationTarget expectationTarget : expectationTargetList) {
+ String expectationTargetId = expectationTarget.getTargetId();
+ contextService.deleteContextList(expectationTargetId);
+ fulfilmentInfoService.deleteFulfilmentInfo(expectationTargetId);
+ conditionService.deleteConditionList(expectationTargetId);
+ }
+ if (expectationTargetMapper.deleteExpectationTargetList(expectationId) < 1) {
+ String msg = "Failed to delete expectation target list to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted expectation target list to database.");
+ }
+
+ }
+
+
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java
index f42b87d..0b2c20d 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/FulfilmentInfoServiceImpl.java
@@ -17,14 +17,16 @@
package org.onap.usecaseui.intentanalysis.service.impl;
-import lombok.extern.slf4j.Slf4j;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo;
import org.onap.usecaseui.intentanalysis.mapper.FulfilmentInfoMapper;
import org.onap.usecaseui.intentanalysis.service.FulfilmentInfoService;
+import lombok.extern.slf4j.Slf4j;
@Service
@@ -39,29 +41,52 @@ public class FulfilmentInfoServiceImpl implements FulfilmentInfoService {
@Override
public void createFulfilmentInfo(FulfilmentInfo fulfilmentInfo, String parentId) {
- if (fulfilmentInfoMapper.insertFulfilmentInfo(fulfilmentInfo, parentId) < 1) {
- String msg = "Create fulfilmentInfoMapper to database failed.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ if (fulfilmentInfo != null) {
+ if (fulfilmentInfoMapper.insertFulfilmentInfo(fulfilmentInfo, parentId) < 1) {
+ String msg = "Failed to create fulfilment info to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ log.info("Successfully created fulfilment info to database.");
}
}
@Override
- public void deleteFulfilmentInfoByParentId(String parentId) {
+ public void deleteFulfilmentInfo(String parentId) {
+ if (fulfilmentInfoService.getFulfilmentInfo(parentId) != null) {
+ if (fulfilmentInfoMapper.deleteFulfilmentInfo(parentId) < 1) {
+ String msg = "Failed to delete fulfilment info to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ log.info("Successfully deleted fulfilment info to database.");
+ }
}
@Override
- public void updateFulfilmentInfoByParentId(FulfilmentInfo fulfilmentInfo, String parentId) {
+ public void updateFulfilmentInfo(FulfilmentInfo fulfilmentInfo, String parentId) {
+
+ FulfilmentInfo fulfillmentInfoDB = fulfilmentInfoService.getFulfilmentInfo(parentId);
+ if (fulfillmentInfoDB == null && fulfilmentInfo != null) {
+ fulfilmentInfoService.createFulfilmentInfo(fulfilmentInfo, parentId);
+ } else if (fulfillmentInfoDB != null && fulfilmentInfo == null) {
+ fulfilmentInfoService.deleteFulfilmentInfo(parentId);
+ } else if (fulfillmentInfoDB != null) {
+ if (fulfilmentInfoMapper.updateFulfilmentInfo(fulfilmentInfo, parentId) < 1) {
+ String msg = "Failed to update fulfilment info to database.";
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ log.info("Successfully updated fulfilment info to database.");
+ }
}
@Override
- public FulfilmentInfo getFulfilmentInfoByParentId(String parentId) {
- FulfilmentInfo fulfilmentInfo = fulfilmentInfoMapper.selectFulfilmentInfoById(parentId);
+ public FulfilmentInfo getFulfilmentInfo(String parentId) {
+ FulfilmentInfo fulfilmentInfo = fulfilmentInfoMapper.selectFulfilmentInfo(parentId);
if (fulfilmentInfo == null) {
- String msg = String.format("FulfilmentInfo: Parent id %s doesn't exist in database.", parentId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ log.info(String.format("FulfilmentInfo is null, parentId = %s", parentId));
}
return fulfilmentInfo;
}
-} \ No newline at end of file
+}
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 02a85f8..952b6dd 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
@@ -18,11 +18,13 @@ package org.onap.usecaseui.intentanalysis.service.impl;
import java.util.List;
+
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
@@ -46,103 +48,103 @@ public class IntentServiceImpl implements IntentService {
@Autowired
private ContextService contextService;
+ private ContextParentType contextParentType;
+
@Autowired
private FulfilmentInfoService fulfilmentInfoService;
+ @Autowired
+ private IntentService intentService;
+
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Intent createIntent(Intent intent) {
if (intentMapper.insertIntent(intent) < 1) {
- String msg = "Create intent to database failed.";
+ String msg = "Failed to create intent to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
expectationService.createIntentExpectationList(intent.getIntentExpectations(), intent.getIntentId());
contextService.createContextList(intent.getIntentContexts(), intent.getIntentId());
fulfilmentInfoService.createFulfilmentInfo(intent.getIntentFulfilmentInfo(), intent.getIntentId());
- log.debug("Intent was successfully created.");
+ log.info("Successfully created intent to database.");
return intent;
}
@Override
public List<Intent> getIntentList() {
List<Intent> intentList = intentMapper.selectIntentList();
- if (intentList == null || intentList.size() <= 0) {
- String msg = "Intent list doesn't exist in the intent database.";
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ if (CollectionUtils.isEmpty(intentList)) {
+ log.info("Intent list is null");
}
for (Intent intent : intentList) {
- if (null != intent) {
- String intentId = intent.getIntentId();
- intent.setIntentExpectations(expectationService.getIntentExpectationListByIntentId(intentId));
- intent.setIntentContexts(contextService.getContextListByParentId(intentId));
- intent.setIntentFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfoByParentId(intentId));
- log.debug("Intent %s was successfully found", intentId);
- }
+ intent.setIntentExpectations(expectationService.getIntentExpectationList(intent.getIntentId()));
}
return intentList;
}
@Override
- public Intent getIntentById(String intentId) {
- Intent intent = intentMapper.selectIntentById(intentId);
- if (intent == null) {
- String msg = String.format("Intent id %s doesn't exist in database.", intentId);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ public Intent getIntent(String intentId) {
+ Intent intent = intentMapper.selectIntent(intentId);
+ if (intent != null) {
+ intent.setIntentExpectations(expectationService.getIntentExpectationList(intent.getIntentId()));
+ } else {
+ log.info(String.format("Intent is null, intentId = %s", intentId));
}
- intent.setIntentExpectations(expectationService.getIntentExpectationListByIntentId(intentId));
- intent.setIntentContexts(contextService.getContextListByParentId(intentId));
- intent.setIntentFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfoByParentId(intentId));
- log.debug("Intent was successfully found");
return intent;
}
@Override
public Intent updateIntent(Intent intent) {
- Intent intentDB = intentMapper.selectIntentById(intent.getIntentId());
- if (intentDB == null) {
- String msg = String.format("Intent id %s doesn't exist in database.", intent.getIntentId());
+ String intentId = intent.getIntentId();
+ Intent intentFromDB = intentService.getIntent(intentId);
+ if (intentFromDB == null) {
+ String msg = String.format("Intent id %s doesn't exist in database.", intentId);
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
- expectationService.updateIntentExpectationListByIntentId(intent.getIntentExpectations(), intent.getIntentId());
- int res = intentMapper.updateIntent(intent);
- if (res < 1) {
- String msg = "Update intent in database failed.";
+ expectationService.updateIntentExpectationList(intent.getIntentExpectations(), intentId);
+ contextService.updateContextList(intent.getIntentContexts(), intentId);
+ fulfilmentInfoService.updateFulfilmentInfo(intent.getIntentFulfilmentInfo(), intentId);
+ if (intentMapper.updateIntent(intent) < 1) {
+ String msg = "Failed to update intent to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
}
- log.debug("Update intent successfully.");
- return intentMapper.selectIntentById(intent.getIntentId());
+ log.info("Successfully updated intent to database.");
+ return intentService.getIntent(intentId);
}
@Override
- public void deleteIntentById(String intentId) {
- if (intentMapper.deleteIntentById(intentId) < 1) {
- String msg = "Delete intent in database failed.";
+ public void deleteIntent(String intentId) {
+ Intent intent = intentService.getIntent(intentId);
+ if (intent == null) {
+ String msg = String.format("Intent id %s doesn't exist in database.", intentId);
+ log.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ fulfilmentInfoService.deleteFulfilmentInfo(intentId);
+ contextService.deleteContextList(intentId);
+ expectationService.deleteIntentExpectationList(intentId);
+ if (intentMapper.deleteIntent(intentId) < 1) {
+ String msg = "Failed to delete intent to database.";
log.error(msg);
throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
}
- expectationService.deleteIntentExpectationListByIntentId(intentId);
- log.debug("Intent has been deleted successfully.");
+ log.info("Successfully deleted intent to database.");
}
@Override
- public List<Intent> getIntentByName(String name) {
- List<Intent> intentList = intentMapper.getIntentByName(name);
- if (CollectionUtils.isNotEmpty(intentList)) {
- for (Intent intent:intentList) {
- // intent.setIntentContexts();
- //
- intent.setIntentExpectations(expectationService.getIntentExpectationListByIntentId(intent.getIntentId()));
+ public List<Intent> getIntentByName(String intentName) {
+ List<Intent> intentList = intentMapper.getIntentByName(intentName);
+ if (!CollectionUtils.isEmpty(intentList)) {
+ for (Intent intent : intentList) {
+ intent.setIntentExpectations(expectationService.getIntentExpectationList(intent.getIntentId()));
}
- return intentList;
+
} else {
- String msg = String.format("Intent name contain %s doesn't exist in database.", name);
- log.error(msg);
- throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ log.info(String.format("Intent list is null, intentName = %s", intentName));
}
+ return intentList;
}
-} \ No newline at end of file
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
index c2b8354..b9c7b95 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
@@ -23,8 +23,10 @@ import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.onap.usecaseui.intentanalysis.mapper.StateMapper;
import org.onap.usecaseui.intentanalysis.service.StateService;
+
import java.util.ArrayList;
import java.util.List;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -97,7 +99,7 @@ public class StateServiceImpl implements StateService {
for (String stateDBId : stateDBIdList) {
stateService.deleteStateById(stateDBId);
}
- log.debug("States are successfully updated.");
+ log.info("States are successfully updated.");
}
@Override
diff --git a/intentanalysis/src/main/resources/application.yaml b/intentanalysis/src/main/resources/application.yaml
index 39b8e02..4dbd108 100644
--- a/intentanalysis/src/main/resources/application.yaml
+++ b/intentanalysis/src/main/resources/application.yaml
@@ -8,6 +8,10 @@ spring:
username: ${POSTGRES_USERNAME}
password: ${POSTGRES_PASSWORD}
driver-class-name: org.postgresql.Driver
+ sql:
+ init:
+ schema-locations: classpath*:intent-analysis-init.sql
+ mode: always
mybatis:
configuration:
database-id: PostgreSQL
diff --git a/intentanalysis/src/main/resources/intent-analysis-init.sql b/intentanalysis/src/main/resources/intent-analysis-init.sql
index d777077..d7c513c 100644
--- a/intentanalysis/src/main/resources/intent-analysis-init.sql
+++ b/intentanalysis/src/main/resources/intent-analysis-init.sql
@@ -23,14 +23,18 @@ create table if not exists expectation_object(
create table if not exists expectation_target(
target_id varchar(255) primary key,
target_name varchar(255),
- target_condition varchar(255),
expectation_id varchar(255)
);
create table if not exists context(
context_id varchar(255) primary key,
context_name varchar(255),
- context_condition varchar(255),
+ parent_id varchar(255)
+);
+
+create table if not exists context_mapping(
+ context_id varchar(255) primary key,
+ parent_type varchar(255),
parent_id varchar(255)
);
@@ -53,12 +57,7 @@ create table if not exists condition(
condition_id varchar(255) primary key,
condition_name varchar(255),
operator_type varchar(255),
- condition_value varchar(255)
-);
-
-create table if not exists condition_mapping(
- condition_id varchar(255) primary key,
- parent_type varchar(255),
+ condition_value varchar(255),
parent_id varchar(255)
);
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml
index 7f4b24a..012dfca 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ConditionMapper.xml
@@ -5,30 +5,55 @@
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.ConditionMapper">
<insert id="insertConditionList">
- <if test="conditionList != null">
- insert into condition(condition_id, condition_name, operator_type, condition_value)
- values
- <foreach collection="conditionList" index="index" item="item" separator=",">
- (#{item.conditionId}, #{item.conditionName}, #{item.operatorType}, #{item.conditionValue})
- </foreach>
- </if>
+ insert into condition(condition_id, condition_name, operator_type, condition_value, parent_id)
+ values
+ <foreach collection="conditionList" index="index" item="item" separator=",">
+ (#{item.conditionId}, #{item.conditionName}, #{item.operator}, #{item.conditionValue}, #{parentId})
+ </foreach>
</insert>
<insert id="insertConditionParentList">
- <if test="conditionList != null">
- insert into condition_mapping(condition_id, parent_type, parent_id)
- values
- <foreach collection="conditionList" index="index" item="item" separator=",">
- (#{item.conditionId}, #{parentType}, #{parentId})
- </foreach>
- </if>
+ insert into condition_mapping(condition_id, parent_type, parent_id)
+ values
+ <foreach collection="conditionList" index="index" item="item" separator=",">
+ (#{item.conditionId}, #{parentType}, #{parentId})
+ </foreach>
</insert>
-<!-- 这里的查询有问题-->
- <select id="selectConditionByParentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.Condition">
- select condition_id conditionId, condition_name conditiontName, operator_type operatorType
+ <insert id="insertCondition">
+ insert into condition(condition_id, condition_name, operator_type, condition_value, parent_id)
+ values
+ (#{condition.conditionId}, #{condition.conditionName}, #{condition.operator}, #{condition.conditionValue}, #{parentId})
+ </insert>
+ <!-- 这里的查询有问题-->
+ <select id="selectConditionList" resultType="org.onap.usecaseui.intentanalysis.bean.models.Condition">
+ select condition_id conditionId, condition_name conditionName, operator_type operator, condition_value conditionValue
+ from condition
+ where parent_id = #{parentId}
+ </select>
+
+ <select id="selectCondition" resultType="org.onap.usecaseui.intentanalysis.bean.models.Condition">
+ select condition_id conditionId, condition_name conditionName, operator_type operator, condition_value conditionValue
from condition
- where condition_id = #{parentId}
+ where condition_id = #{conditionId}
</select>
-</mapper> \ No newline at end of file
+ <update id="updateCondition">
+ update condition
+ <trim prefix="set" suffixOverrides=",">
+ <if test="condition.conditionName != null">condition_name = #{condition.conditionName},</if>
+ <if test="condition.operator != null">operator_type = #{condition.operator},</if>
+ <if test="condition.conditionValue != null">condition_value = #{condition.conditionValue},</if>
+ </trim>
+ where condition_id = #{condition.conditionId}
+ </update>
+
+ <delete id="deleteCondition">
+ DELETE FROM condition WHERE condition_id = #{condition.conditionId}
+ </delete>
+
+ <delete id="deleteConditionList">
+ DELETE FROM condition WHERE parent_id = #{parentId}
+ </delete>
+
+</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml
index 975bd03..ff04551 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ContextMapper.xml
@@ -6,19 +6,44 @@
<insert id="insertContextList">
- <if test="contextList != null">
- insert into context(context_id, context_name, parent_id)
- values
- <foreach collection="contextList" index="index" item="item" separator=",">
- (#{item.contextId}, #{item.contextName}, #{parentId})
- </foreach>
- </if>
+ insert into context(context_id, context_name, parent_id)
+ values
+ <foreach collection="contextList" index="index" item="item" separator=",">
+ (#{item.contextId}, #{item.contextName}, #{parentId})
+ </foreach>
</insert>
- <select id="selectContextByParentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.Context">
- select context_id contextId, context_name contextName, context_condition contextCondition
+ <select id="selectContextList" resultType="org.onap.usecaseui.intentanalysis.bean.models.Context">
+ select context_id contextId, context_name contextName
from context
where parent_id = #{parentId}
</select>
-</mapper> \ No newline at end of file
+ <select id="selectContext" resultType="org.onap.usecaseui.intentanalysis.bean.models.Context">
+ select context_id contextId, context_name contextName
+ from context
+ where context_id = #{contextId}
+ </select>
+
+ <insert id="insertContext">
+ insert into context(context_id, context_name, parent_id)
+ values
+ (#{context.contextId}, #{context.contextName}, #{parentId})
+ </insert>
+
+ <update id="updateContext">
+ update context
+ <trim prefix="set" suffixOverrides=",">
+ <if test="context.contextName != null">context_name = #{context.contextName},</if>
+ </trim>
+ where context_id = #{context.contextId}
+ </update>
+
+ <delete id="deleteContext">
+ DELETE FROM context WHERE context_id = #{context.contextId}
+ </delete>
+
+ <delete id="deleteContextList">
+ DELETE FROM context WHERE parent_id = #{parentId}
+ </delete>
+</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
index 24d574b..16c7850 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
@@ -17,34 +17,42 @@
<insert id="insertIntentExpectation">
insert into expectation(expectation_id, expectation_name, expectation_type, intent_id)
- values (#{expectation.expectationId}, #{expectation.expectationName}, #{expectation.expectationType}, #{intentId})
+ values (#{intentExpectation.expectationId}, #{intentExpectation.expectationName}, #{intentExpectation.expectationType}, #{intentId})
</insert>
- <select id="selectIntentExpectationListByIntentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.Expectation">
+ <select id="selectIntentExpectationList" resultType="org.onap.usecaseui.intentanalysis.bean.models.Expectation">
select expectation_id expectationId, expectation_name expectationName, expectation_type expectationType,
- intent_id intentId
+ intent_id intentId
from expectation
where intent_id = #{intentId}
</select>
+ <select id="selectIntentExpectation" resultType="org.onap.usecaseui.intentanalysis.bean.models.Expectation">
+ select expectation_id expectationId, expectation_name expectationName, expectation_type expectationType,
+ intent_id intentId
+ from expectation
+ where expectation_id = #{expectationId}
+ </select>
+
<update id="updateIntentExpectation">
update expectation
<trim prefix="set" suffixOverrides=",">
- <if test="expectationName != null">expectation_name = #{expectationName},</if>
+ <if test="intentExpectation.expectationName != null">expectation_name = #{intentExpectation.expectationName},</if>
+ <if test="intentExpectation.expectationType != null">expectation_type = #{intentExpectation.expectationType},</if>
</trim>
- where expectation_id = #{expectationId}
+ where expectation_id = #{intentExpectation.expectationId}
</update>
- <delete id="deleteIntentExpectationListByIntentId">
+ <delete id="deleteIntentExpectationList">
delete
from expectation
where intent_id = #{intentId}
</delete>
- <delete id="deleteIntentExpectationById">
+ <delete id="deleteIntentExpectation">
delete
from expectation
where expectation_id = #{expectationId}
</delete>
-</mapper> \ No newline at end of file
+</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml
index b158eb2..1c8b513 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationObjectMapper.xml
@@ -13,7 +13,7 @@
</if>
</insert>
- <select id="selectIntentExpectationObjectByExpectationId" resultType="org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject">
+ <select id="selectExpectationObject" resultType="org.onap.usecaseui.intentanalysis.bean.models.ExpectationObject">
select object_type objectType, object_instance objectInstance
from expectation_object
where expectation_id = #{expectationId}
@@ -25,4 +25,17 @@
where expectation_id = #{expectationId}
</select>
+ <update id="updateExpectationObject">
+ update expectation_object
+ <trim prefix="set" suffixOverrides=",">
+ <if test="expectationObject.objectType != null">object_type = #{expectationObject.objectType},</if>
+ <if test="expectationObject.objectInstance != null">object_instance = #{expectationObject.objectInstance},</if>
+ </trim>
+ where expectation_id = #{expectationId}
+ </update>
+
+ <delete id="deleteExpectationObject">
+ delete from expectation_object
+ where expectation_id = #{expectationId}
+ </delete>
</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml
index 1910912..31625c8 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationTargetMapper.xml
@@ -6,17 +6,47 @@
<insert id="insertExpectationTarget">
- <if test="expectationTarget != null">
- insert into expectation_target(target_id, target_name, target_condition, expectation_id)
- values
- (#{expectationTarget.targetId}, #{expectationTarget.targetName}, #{expectationTarget.targetCondition}, #{expectationId})
- </if>
+ insert into expectation_target(target_id, target_name, expectation_id)
+ values
+ (#{expectationTarget.targetId}, #{expectationTarget.targetName}, #{expectationId})
</insert>
- <select id="selectIntentExpectationTargetListByExpectationId" resultType="org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget">
- select target_id targetId, target_name targetName, target_condition targetCondition
+ <insert id="insertExpectationTargetList">
+ insert into expectation_target(target_id, target_name, expectation_id)
+ values
+ <foreach collection="expectationTargetList" index="index" item="item" separator=",">
+ (#{item.targetId}, #{item.targetName}, #{expectationId})
+ </foreach>
+ </insert>
+
+ <select id="selectExpectationTargetList" resultType="org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget">
+ select target_id targetId, target_name targetName
from expectation_target
where expectation_id = #{expectationId}
</select>
-</mapper> \ No newline at end of file
+ <select id="selectExpectationTarget" resultType="org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget">
+ select target_id targetId, target_name targetName
+ from expectation_target
+ where target_id = #{expectationTargetId}
+ </select>
+
+ <update id="updateExpectationTarget">
+ update expectation_target
+ <trim prefix="set" suffixOverrides=",">
+ <if test="expectationTarget.targetName != null">target_name = #{expectationTarget.targetName},</if>
+ </trim>
+ where target_id = #{expectationTargetId}
+ </update>
+
+ <delete id="deleteExpectationTarget">
+ delete from expectation_target
+ where target_id = #{expectationTargetId}
+ </delete>
+
+ <delete id="deleteExpectationTargetList">
+ delete from expectation_target
+ where expectation_id= #{expectationId}
+ </delete>
+
+</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml
index 2290703..d9b9f7f 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/FulfilmentInfoMapper.xml
@@ -6,17 +6,29 @@
<insert id="insertFulfilmentInfo">
- <if test="fulfilmentInfo != null">
- insert into fulfilment_info(fulfilment_info_id, fulfilment_info_status, not_fulfilled_state, not_fulfilled_reason)
- values (#{parentId}, #{fulfilmentInfo.fulfilmentStatus}, #{fulfilmentInfo.notFulfilledState}, #{fulfilmentInfo.notFulfilledReason})
- </if>
+ insert into fulfilment_info(fulfilment_info_id, fulfilment_info_status, not_fulfilled_state, not_fulfilled_reason)
+ values (#{parentId}, #{fulfilmentInfo.fulfilmentStatus}, #{fulfilmentInfo.notFulfilledState}, #{fulfilmentInfo.notFulfilledReason})
</insert>
- <select id="selectFulfilmentInfoById" resultType="org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo">
+ <select id="selectFulfilmentInfo" resultType="org.onap.usecaseui.intentanalysis.bean.models.FulfilmentInfo">
select fulfilment_info_status fulfilmentStatus, not_fulfilled_state notFulfilledState,
- not_fulfilled_reason notFulfilledReason
+ not_fulfilled_reason notFulfilledReason
from fulfilment_info
where fulfilment_info_id = #{parentId}
</select>
+ <update id="updateFulfilmentInfo">
+ update fulfilment_info
+ <trim prefix="set" suffixOverrides=",">
+ <if test="fulfilmentInfo.fulfilmentStatus != null">fulfilment_info_status = #{fulfilmentInfo.fulfilmentStatus},</if>
+ <if test="fulfilmentInfo.notFulfilledState != null">not_fulfilled_state = #{fulfilmentInfo.notFulfilledState},</if>
+ <if test="fulfilmentInfo.notFulfilledReason != null">not_fulfilled_reason = #{fulfilmentInfo.notFulfilledReason},</if>
+ </trim>
+ where fulfilment_info_id = #{parentId}
+ </update>
+
+ <delete id="deleteFulfilmentInfo" parameterType="string">
+ delete from fulfilment_info
+ where fulfilment_info_id = #{parentId}
+ </delete>
</mapper>
diff --git a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
index 643c193..c5d3b3d 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
@@ -4,18 +4,16 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.IntentMapper">
- <select id="selectIntentById" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
- select intent_id intentId, intent_name intentName
- from intent
+ <select id="selectIntent" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
+ select intent_id intentId, intent_name intentName 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 from intent
</select>
- <insert id="insertIntent" >
+ <insert id="insertIntent">
insert into Intent(intent_id, intent_name)
values(#{intent.intentId}, #{intent.intentName})
</insert>
@@ -23,12 +21,12 @@
<update id="updateIntent" parameterType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
update intent
<trim prefix="set" suffixOverrides=",">
- <if test="intentName != null">intent_name = #{intentName},</if>
+ <if test="intent.intentName != null">intent_name = #{intent.intentName},</if>
</trim>
- where intent_id = #{intentId}
+ where intent_id = #{intent.intentId}
</update>
- <delete id="deleteIntentById" parameterType="string">
+ <delete id="deleteIntent" parameterType="string">
delete
from intent
where intent_id = #{intentId}
@@ -36,7 +34,7 @@
<select id="getIntentByName" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
select intent_id intentId, intent_name intentName from intent
- where intent_name like "%"#{intentName}"%"
+ where intent_name like "%"#{intent.intentName}"%"
</select>
</mapper> \ No newline at end of file