summaryrefslogtreecommitdiffstats
path: root/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
blob: 3b0923f3817e21e8f0f293ece8b1a4b5488614ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?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.intentanalysis.mapper.ExpectationMapper">


    <select id="selectExpectationByIntentId" resultType="org.onap.usecaseui.intentanalysis.bean.models.Expectation">
        select expectation_id expectationId, expectation_name expectationName,
               target_moi targetMOI, intent_id intentId
        from expectation
        where intent_id = #{intentId}
    </select>

    <insert id="insertExpectationList">
        insert into expectation(expectation_id, expectation_name, target_moi, intent_id)
        values
        <foreach collection="expectationList" index="index" item="item" separator=",">
            (#{item.expectationId}, #{item.expectationName}, #{item.targetMOI}, #{intentId})
        </foreach>
    </insert>

    <delete id="deleteExpectationByIntentId">
        delete from expectation
        where intent_id = #{intentId}
    </delete>

    <update id="updateExpectation">
        update expectation
        <trim prefix="set" suffixOverrides=",">
            <if test="expectationName != null">expectation_name = #{expectationName},</if>
            <if test="targetMOI != null">target_moi = #{targetMOI},</if>
        </trim>
        where expectation_id = #{expectationId}
    </update>

    <insert id="insertExpectation">
        insert into expectation(expectation_id, expectation_name, target_moi, intent_id)
        values (#{expectation.expectationId}, #{expectation.expectationName}, #{expectation.targetMOI}, #{intentId})
    </insert>

    <delete id="deleteExpectationById">
        delete
        from expectation
        where expectation_id = #{expectationId}
    </delete>

</mapper>