summaryrefslogtreecommitdiffstats
path: root/intentanalysis
diff options
context:
space:
mode:
Diffstat (limited to 'intentanalysis')
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java3
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/IntentPo.java1
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/controller/IntentController.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java33
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java36
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java31
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/IntentService.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java83
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java101
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java56
-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
15 files changed, 467 insertions, 3 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java
index 819c1e7..c2a0ec2 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/IntentAnalysisApplication.java
@@ -16,9 +16,10 @@
package org.onap.usecaseui.intentanalysis;
+import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-
+@MapperScan("org.onap.usecaseui.intentanalysis.mapper")
@SpringBootApplication
public class IntentAnalysisApplication {
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/IntentPo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/IntentPo.java
index 5372081..844ff6d 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/IntentPo.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/IntentPo.java
@@ -35,6 +35,7 @@ public class IntentPo {
Intent intent = new Intent();
intent.setIntentId(this.intentPoId);
intent.setIntentName(this.intentPoName);
+
intent.setExpectationList(getExpectationList());
return intent;
}
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 00d8d3a..d1b4aac 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
@@ -53,7 +53,7 @@ public class IntentController {
public ResponseEntity<Intent> updateIntentById(
@PathVariable(INTENT_ID) String intentId,
@RequestBody Intent intent) {
- return ResponseEntity.ok(intentService.updateIntentById(intentId, intent));
+ return ResponseEntity.ok(intentService.updateIntent(intent));
}
@DeleteMapping(value = "/{intentId}", produces = MediaType.APPLICATION_JSON_VALUE)
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
new file mode 100644
index 0000000..bcca440
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.intentanalysis.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.onap.usecaseui.intentanalysis.bean.po.ExpectationPo;
+
+import java.util.List;
+@Mapper
+public interface ExpectationMapper {
+
+ void insertExpectation(List<ExpectationPo> expectation);
+
+ List<ExpectationPo> selectExpectationByIntentId(String intentId);
+
+ void deleteExpectationByIntentId(String intentId);
+
+ void updateExpectation(List<ExpectationPo> expectation);
+
+}
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
new file mode 100644
index 0000000..4de598a
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.onap.usecaseui.intentanalysis.bean.po.IntentPo;
+
+import java.util.List;
+
+@Mapper
+public interface IntentMapper {
+
+ void insertIntent(IntentPo intentPo);
+
+ void updateIntent(IntentPo intentPo);
+
+ IntentPo selectIntentById(String intentId);
+
+ List<IntentPo> selectIntents();
+
+ void deleteIntentById(String intentId);
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
new file mode 100644
index 0000000..b1b1416
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.onap.usecaseui.intentanalysis.bean.po.StatePo;
+
+import java.util.List;
+@Mapper
+public interface StateMapper {
+
+ void insertState(List<StatePo> state);
+
+ List<StatePo> selectStateByExpectation(String expectationId);
+
+ void deleteStateByExpectationId(String expectationId);
+}
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 4e8765a..36615ab 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
@@ -27,7 +27,7 @@ public interface IntentService {
Intent createIntent(Intent intent);
- Intent updateIntentById(String intentId, Intent intent);
+ Intent updateIntent(Intent intent);
void deleteIntentById(String intentId);
}
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
new file mode 100644
index 0000000..98e5364
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.service.impl;
+
+
+import org.onap.usecaseui.intentanalysis.bean.po.ExpectationPo;
+import org.onap.usecaseui.intentanalysis.bean.po.StatePo;
+import org.onap.usecaseui.intentanalysis.mapper.ExpectationMapper;
+import org.onap.usecaseui.intentanalysis.service.ExpectationService;
+import org.onap.usecaseui.intentanalysis.service.StateService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import java.util.List;
+
+@Service
+public class ExpectationServiceImpl implements ExpectationService {
+
+ private static Logger LOGGER = LoggerFactory.getLogger(ExpectationServiceImpl.class);
+ @Autowired
+ private ExpectationMapper expectationMapper;
+
+ @Autowired
+ private StateService stateService;
+
+ @Override
+ public void createExpectationList(List<ExpectationPo> expectationPoList, String intentId) {
+ for (ExpectationPo expectationPo : expectationPoList) {
+ if (null != expectationPo) {
+ expectationPo.setIntentPoId(intentId);
+ stateService.createStateList(expectationPo.getStatePoList(), expectationPo.getExpectationPoId());
+ }
+ }
+ expectationMapper.insertExpectation(expectationPoList);
+ }
+
+ @Override
+ public List<ExpectationPo> getExpectationListByIntentId(String intentId) {
+ List<ExpectationPo> expectationList = expectationMapper.selectExpectationByIntentId(intentId);
+ for (ExpectationPo expectation : expectationList) {
+ List<StatePo> stateList = stateService.getStateListByExpectationId(expectation.getExpectationPoId());
+ expectation.setStatePoList(stateList);
+ }
+ return expectationList;
+ }
+
+ @Override
+ public void deleteExpectationListById(String intentId) {
+ List<ExpectationPo> expectationList = expectationMapper.selectExpectationByIntentId(intentId);
+ expectationMapper.deleteExpectationByIntentId(intentId);
+ for (ExpectationPo expectation : expectationList) {
+ stateService.deleteStateListByExpectationId(expectation.getExpectationPoId());
+ }
+ }
+
+ @Override
+ public void updateExpectationListById(List<ExpectationPo> expectationPoList, String intentId) {
+ List<ExpectationPo> expectationList = expectationMapper.selectExpectationByIntentId(intentId);
+ if (expectationList == null) {
+ LOGGER.error("Intent ID {} doesn't exist in database.", intentId);
+ throw new IllegalArgumentException("This intent ID doesn't exist in database.");
+ }
+ expectationMapper.updateExpectation(expectationPoList);
+ LOGGER.info("Expectations are successfully updated.");
+ }
+}
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
new file mode 100644
index 0000000..29a7480
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.service.impl;
+
+
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
+import org.onap.usecaseui.intentanalysis.bean.po.IntentPo;
+import org.onap.usecaseui.intentanalysis.mapper.IntentMapper;
+import org.onap.usecaseui.intentanalysis.service.ExpectationService;
+import org.onap.usecaseui.intentanalysis.service.IntentService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class IntentServiceImpl implements IntentService {
+ private static Logger LOGGER = LoggerFactory.getLogger(IntentService.class);
+
+ @Autowired
+ private IntentMapper intentMapper;
+
+ @Autowired
+ private ExpectationService expectationService;
+
+ @Override
+ public List<Intent> getIntentList() {
+ List<Intent> intentList = new ArrayList<>();
+ List<IntentPo> intentPoList = intentMapper.selectIntents();
+ if (intentPoList == null || intentPoList.size() <= 0) {
+ return intentList;
+ }
+ for (IntentPo intentPo : intentPoList) {
+ if (intentPo != null) {
+ intentPo.setExpectationPoList(expectationService.getExpectationListByIntentId(intentPo.getIntentPoId()));
+ intentList.add(intentPo.transferToIntent());
+ }
+ }
+ return intentList;
+ }
+
+ @Override
+ public Intent getIntentById(String intentId) {
+ IntentPo intentPo = intentMapper.selectIntentById(intentId);
+ if (intentPo != null) {
+ intentPo.setExpectationPoList(expectationService.getExpectationListByIntentId(intentPo.getIntentPoId()));
+ return intentPo.transferToIntent();
+ } else {
+ String msg = "Intent Id requested doesn't exist in the intent database";
+ LOGGER.error(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ @Transactional(rollbackFor = RuntimeException.class)
+ @Override
+ public Intent createIntent(Intent intent) {
+ IntentPo intentPo = intent.transferToIntentPo();
+ intentMapper.insertIntent(intentPo);
+ // saving expectation list into expectation table
+ expectationService.createExpectationList(intentPo.getExpectationPoList(), intentPo.getIntentPoId());
+ LOGGER.info("Intent was successfully created.");
+ return intent;
+ }
+
+ @Override
+ public Intent updateIntent(Intent intent) {
+ String intentId = intent.getIntentId();
+ IntentPo intentPo = intentMapper.selectIntentById(intentId);
+ if (intentPo == null) {
+ LOGGER.error("intent id {} not exists in db.", intentId);
+ }
+ intentMapper.updateIntent(intentPo);
+ LOGGER.info("update intent successfully.");
+ return intentMapper.selectIntentById(intentId).transferToIntent();
+ }
+
+ @Override
+ public void deleteIntentById(String intentId) {
+ intentMapper.deleteIntentById(intentId);
+ expectationService.deleteExpectationListById(intentId);
+ }
+}
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
new file mode 100644
index 0000000..c907ff8
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2022 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.usecaseui.intentanalysis.service.impl;
+
+
+import org.onap.usecaseui.intentanalysis.bean.po.StatePo;
+import org.onap.usecaseui.intentanalysis.mapper.StateMapper;
+import org.onap.usecaseui.intentanalysis.service.StateService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class StateServiceImpl implements StateService {
+
+ @Autowired
+ private StateMapper stateMapper;
+
+ @Override
+ public void createStateList(List<StatePo> stateList, String expectationId) {
+ for (StatePo state : stateList) {
+ state.setStatePoId(expectationId);
+ }
+ stateMapper.insertState(stateList);
+ }
+
+ @Override
+ public List<StatePo> getStateListByExpectationId(String expectationId) {
+ List<StatePo> stateList = stateMapper.selectStateByExpectation(expectationId);
+ return stateList;
+ }
+
+ @Override
+ public void deleteStateListByExpectationId(String expectationId) {
+ stateMapper.deleteStateByExpectationId(expectationId);
+ }
+
+ @Override
+ public void updateStateListByExpectationId(List<StatePo> statePoList, String expectationId){
+ };
+}
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