aboutsummaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/resources
diff options
context:
space:
mode:
authorShuhaoCai <caishuhao@huawei.com>2022-07-25 11:01:46 +0800
committerShuhaoCai <caishuhao@huawei.com>2022-07-25 16:00:45 +0800
commitc556b574b03a0458e1f8121351c80286ac02bb63 (patch)
treef9acf9961cad5fd0c3ed6dc214bf8c82d4a32f6e /intentanalysis/src/main/resources
parent2a905d6fd39322fc5714dfc0f2dc3f44094daf23 (diff)
Intent service impletation
Signed-off-by: ShuhaoCai <caishuhao@huawei.com> Issue-ID: USECASEUI-704 Change-Id: If31afadd3c81ffa308a51ad4e6ba65a82e557010
Diffstat (limited to 'intentanalysis/src/main/resources')
-rw-r--r--intentanalysis/src/main/resources/application.yaml12
-rw-r--r--intentanalysis/src/main/resources/intent-analysis-init.sql20
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml28
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml35
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml27
5 files changed, 122 insertions, 0 deletions
diff --git a/intentanalysis/src/main/resources/application.yaml b/intentanalysis/src/main/resources/application.yaml
index 644d527..22f59a5 100644
--- a/intentanalysis/src/main/resources/application.yaml
+++ b/intentanalysis/src/main/resources/application.yaml
@@ -2,3 +2,15 @@ server:
port: 8083
servlet:
context-path: /api/usecaseui-intent-analysis/v1
+spring:
+ datasource:
+ url: jdbc:postgresql://${POSTGRES_IP:127.0.0.1}:${POSTGRES_PORT:5432}/${POSTGRES_DB_NAME:intentdb}
+ username: ${POSTGRES_USERNAME}
+ password: ${POSTGRES_PASSWORD}
+ driver-class-name: org.postgresql.Driver
+ schema: classpath:intent-analysis-init.sql
+ initialization-mode: always
+mybatis:
+ configuration:
+ database-id: PostgreSQL
+ mapper-locations: classpath*:mybatis/sql/*.xml \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/intent-analysis-init.sql b/intentanalysis/src/main/resources/intent-analysis-init.sql
new file mode 100644
index 0000000..64074fa
--- /dev/null
+++ b/intentanalysis/src/main/resources/intent-analysis-init.sql
@@ -0,0 +1,20 @@
+create table if not exists intent(
+ intent_id varchar(255) primary key,
+ intent_name varchar(255)
+);
+
+create table if not exists expectation(
+ expectation_id varchar(255) primary key,
+ expectation_name varchar(255),
+ target_moi varchar(255),
+ intent_id varchar(255)
+);
+
+create table if not exists state(
+ state_id varchar(255) primary key,
+ state_name varchar(255),
+ is_satisfied boolean,
+ condition varchar(255),
+ expectation_id varchar(255)
+);
+
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
new file mode 100644
index 0000000..5c5ac06
--- /dev/null
+++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.onap.usecaseui.server.mapper.ExpectationMapper">
+
+
+ <select id="selectExpectationByIntentId" resultType="org.onap.usecaseui.intentanalysis.bean.po.ExpectationPo">
+ select expectation_id expectationId, expectation_name expectationName,
+ target_moi targetMOI, intent_id intentId
+ from expectation
+ where intent_id = #{intentId}
+ </select>
+
+ <insert id="insertExpectation">
+ insert into expectation(expectation_id, expectation_name, target_moi, intent_id)
+ values
+ <foreach collection="list" index="index" item="item" separator=",">
+ (#{item.expectationId}, #{item.expectationName}, #{item.targetMOI}, #{item.intentId})
+ </foreach>
+ </insert>
+
+ <delete id="deleteExpectationByIntentId">
+ delete from expectation
+ where intent_id = #{intentId}
+ </delete>
+
+</mapper> \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
new file mode 100644
index 0000000..c814bfe
--- /dev/null
+++ b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.onap.usecaseui.server.mapper.IntentMapper">
+
+ <select id="selectIntentById" resultType="org.onap.usecaseui.intentanalysis.bean.po.IntentPo">
+ select intent_id intentId, intent_name intentName from intent
+ where intent_id = #{intentId}
+ </select>
+
+ <select id="selectIntents" resultType="org.onap.usecaseui.intentanalysis.bean.po.IntentPo">
+ select intent_id intentId, intent_name intentName from intent
+ </select>
+
+ <insert id="insertIntent" >
+ insert into Intent(intent_id, intent_name)
+ values(#{intentId}, #{intentName})
+ </insert>
+
+ <update id="updateIntent" parameterType="org.onap.usecaseui.intentanalysis.bean.po.IntentPo">
+ update intent
+ <trim prefix="set" suffixOverrides=",">
+ <if test="intentId != null">intent_id = #{intentId},</if>
+ <if test="intentName != null">intent_name = #{intentName},</if>
+ </trim>
+ where intent_id = #{intentId}
+ </update>
+
+ <delete id="deleteIntentById" parameterType="string">
+ delete from intent
+ where intent_id = #{intentId}
+ </delete>
+
+</mapper> \ No newline at end of file
diff --git a/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
new file mode 100644
index 0000000..987c75f
--- /dev/null
+++ b/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.onap.usecaseui.server.mapper.StateMapper">
+
+ <select id="selectStateByExpectation" resultType="org.onap.usecaseui.intentanalysis.bean.po.StatePo">
+ select state_id stateId, state_name stateName, expectation_id expectationId,
+ is_satisfied isSatisfied, condition
+ from state
+ where expectation_id = #{expectationId}
+ </select>
+
+ <insert id="insertState" parameterType="java.util.ArrayList">
+ insert into state(state_id, state_name, expectation_id, is_satisfied, condition)
+ values
+ <foreach collection="list" index="index" item="item" separator=",">
+ (#{item.stateId}, #{item.stateName}, #{item.expectationId}, #{item.isSatisfied}, #{item.condition})
+ </foreach>
+ </insert>
+
+ <delete id="deleteStateByExpectationId">
+ delete from state
+ where expectation_id = #{expectationId}
+ </delete>
+
+</mapper> \ No newline at end of file