aboutsummaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/resources
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/resources
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/resources')
-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
9 files changed, 184 insertions, 70 deletions
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