summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Expectation.java22
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java20
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/State.java10
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/ExpectationPo.java57
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/IntentPo.java53
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java42
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java26
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/DataBaseException.java23
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/ErrorMessage.java (renamed from intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/StatePo.java)33
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java2
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/ExpectationMapper.java14
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/IntentMapper.java12
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java16
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/ExpectationService.java12
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java12
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/ExpectationServiceImpl.java113
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/IntentServiceImpl.java70
-rw-r--r--intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java89
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml30
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml9
-rw-r--r--intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml31
21 files changed, 417 insertions, 279 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Expectation.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Expectation.java
index b883662..ee1fc49 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Expectation.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Expectation.java
@@ -15,8 +15,6 @@
*/
package org.onap.usecaseui.intentanalysis.bean.models;
-import org.onap.usecaseui.intentanalysis.bean.po.ExpectationPo;
-import org.onap.usecaseui.intentanalysis.bean.po.StatePo;
import lombok.Data;
import java.util.ArrayList;
@@ -25,6 +23,7 @@ import java.util.List;
@Data
public class Expectation {
+
private String expectationId;
private String expectationName;
@@ -33,23 +32,4 @@ public class Expectation {
List<State> stateList;
- public ExpectationPo transferToExpectationPo() {
- ExpectationPo expectationPo = new ExpectationPo();
- expectationPo.setExpectationPoId(this.expectationId);
- expectationPo.setExpectationPoName(this.expectationName);
- expectationPo.setTargetMOI(this.targetMOI);
- expectationPo.setStatePoList(getStatePoList());
- return expectationPo;
- }
-
- private List<StatePo> getStatePoList() {
- List<StatePo> statePoList = new ArrayList<>();
- if (null == this.stateList) {
- return statePoList;
- }
- for (State state : this.stateList) {
- statePoList.add(state.transferToStatePo());
- }
- return statePoList;
- }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java
index f2a98ce..69138e4 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/Intent.java
@@ -16,8 +16,6 @@
package org.onap.usecaseui.intentanalysis.bean.models;
-import org.onap.usecaseui.intentanalysis.bean.po.ExpectationPo;
-import org.onap.usecaseui.intentanalysis.bean.po.IntentPo;
import lombok.Data;
import java.util.ArrayList;
@@ -32,22 +30,4 @@ public class Intent {
private List<Expectation> expectationList;
- public IntentPo transferToIntentPo() {
- IntentPo intentPo = new IntentPo();
- intentPo.setIntentPoId(this.intentId);
- intentPo.setIntentPoName(this.intentName);
- intentPo.setExpectationPoList(getExpectationPoList());
- return intentPo;
- }
-
- private List<ExpectationPo> getExpectationPoList() {
- List<ExpectationPo> expectationPoList = new ArrayList<>();
- if (null == this.expectationList) {
- return expectationPoList;
- }
- for (Expectation expectation : this.expectationList) {
- expectationPoList.add(expectation.transferToExpectationPo());
- }
- return expectationPoList;
- }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/State.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/State.java
index e39b954..fba8cf4 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/State.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/models/State.java
@@ -16,11 +16,11 @@
package org.onap.usecaseui.intentanalysis.bean.models;
-import org.onap.usecaseui.intentanalysis.bean.po.StatePo;
import lombok.Data;
@Data
public class State {
+
private String stateId;
private String stateName;
@@ -29,12 +29,4 @@ public class State {
private Boolean isSatisfied;
- public StatePo transferToStatePo() {
- StatePo statePo = new StatePo();
- statePo.setStatePoId(this.stateId);
- statePo.setStatePoName(this.stateName);
- statePo.setCondition(this.condition);
- statePo.setIsSatisfied(this.isSatisfied);
- return statePo;
- }
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/ExpectationPo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/ExpectationPo.java
deleted file mode 100644
index 00e4b56..0000000
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/ExpectationPo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.bean.po;
-
-import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
-import org.onap.usecaseui.intentanalysis.bean.models.State;
-import lombok.Data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Data
-public class ExpectationPo {
-
- private String expectationPoId;
-
- private String expectationPoName;
-
- private String targetMOI;
-
- private String intentPoId;
-
- List<StatePo> statePoList;
-
- public Expectation transferToExpectation() {
- Expectation expectation = new Expectation();
- expectation.setExpectationId(this.expectationPoId);
- expectation.setExpectationName(this.expectationPoName);
- expectation.setTargetMOI(this.targetMOI);
- expectation.setStateList(getStateList());
- return expectation;
- }
-
- private List<State> getStateList() {
- List<State> stateList = new ArrayList<>();
- if (null == this.statePoList) {
- return stateList;
- }
- for (StatePo statePo : this.statePoList) {
- stateList.add(statePo.transferToState());
- }
- return stateList;
- }
-}
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
deleted file mode 100644
index 844ff6d..0000000
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/IntentPo.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.bean.po;
-
-import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
-import org.onap.usecaseui.intentanalysis.bean.models.Intent;
-import lombok.Data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Data
-public class IntentPo {
-
- private String intentPoId;
-
- private String intentPoName;
-
- private List<ExpectationPo> expectationPoList;
-
- public Intent transferToIntent() {
- Intent intent = new Intent();
- intent.setIntentId(this.intentPoId);
- intent.setIntentName(this.intentPoName);
-
- intent.setExpectationList(getExpectationList());
- return intent;
- }
-
- private List<Expectation> getExpectationList() {
- List<Expectation> expectationList = new ArrayList<>();
- if (null == this.expectationPoList ) {
- return expectationList;
- }
- for (ExpectationPo expectationPo : this.expectationPoList) {
- expectationList.add(expectationPo.transferToExpectation());
- }
- return expectationList;
- }
-}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java
new file mode 100644
index 0000000..fd63581
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/common/ResponseConsts.java
@@ -0,0 +1,42 @@
+/*
+ * 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.common;
+
+public final class ResponseConsts {
+ private ResponseConsts() {
+ throw new IllegalStateException("ResponseConsts class");
+ }
+
+ /**
+ * insert data to database failed.
+ */
+ public static final int RET_INSERT_DATA_FAIL = 10001;
+
+ /**
+ * update data from database failed.
+ */
+ public static final int RET_UPDATE_DATA_FAIL = 10002;
+
+ /**
+ * query data from database is empty.
+ */
+ public static final int RET_QUERY_DATA_EMPTY = 10003;
+
+ /**
+ * delete data from database failed.
+ */
+ public static final int RET_DELETE_DATA_FAIL = 10004;
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java
new file mode 100644
index 0000000..7f136fa
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/CommonException.java
@@ -0,0 +1,26 @@
+/*
+ * 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.exception;
+
+public class CommonException extends RuntimeException{
+
+ private ErrorMessage errMsg;
+
+ public CommonException(String message, int ret) {
+ super(message);
+ errMsg = new ErrorMessage(ret, null);
+ }
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/DataBaseException.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/DataBaseException.java
new file mode 100644
index 0000000..b7121d1
--- /dev/null
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/DataBaseException.java
@@ -0,0 +1,23 @@
+/*
+ * 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.exception;
+
+public class DataBaseException extends CommonException {
+
+ public DataBaseException(String message, int ret) {
+ super(message, ret);
+ }
+}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/StatePo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/ErrorMessage.java
index 5b334cc..5ced950 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/StatePo.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/exception/ErrorMessage.java
@@ -13,31 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.onap.usecaseui.intentanalysis.exception;
-package org.onap.usecaseui.intentanalysis.bean.po;
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
-import org.onap.usecaseui.intentanalysis.bean.models.State;
-import lombok.Data;
+@Getter
+@Setter
+public class ErrorMessage {
-@Data
-public class StatePo {
+ private int retCode;
- private String statePoId;
+ private List<String> params;
- private String statePoName;
-
- private String condition;
-
- private String expectationPoId;
-
- private Boolean isSatisfied;
-
- public State transferToState() {
- State state = new State();
- state.setStateId(this.statePoId);
- state.setStateName(this.statePoName);
- state.setIsSatisfied(this.isSatisfied);
- state.setCondition(this.condition);
- return state;
+ public ErrorMessage(int retCode, List<String> params) {
+ this.retCode = retCode;
+ this.params = params;
}
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
index ec41f3f..550051e 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/intentBaseService/IntentManagementFunction.java
@@ -20,8 +20,10 @@ import lombok.Data;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
+import org.springframework.context.annotation.Configuration;
@Data
+@Configuration
public class IntentManagementFunction {
private ActuationModule actuationModule;
private DecisionModule decisionModule;
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 bcca440..9e910b5 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
@@ -16,18 +16,22 @@
package org.onap.usecaseui.intentanalysis.mapper;
import org.apache.ibatis.annotations.Mapper;
-import org.onap.usecaseui.intentanalysis.bean.po.ExpectationPo;
+import org.apache.ibatis.annotations.Param;
+import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
import java.util.List;
@Mapper
public interface ExpectationMapper {
- void insertExpectation(List<ExpectationPo> expectation);
+ int insertExpectationList(@Param(value = "expectationList") List<Expectation> expectationList, @Param(value = "intentId") String intentId);
- List<ExpectationPo> selectExpectationByIntentId(String intentId);
+ List<Expectation> selectExpectationByIntentId(String intentId);
- void deleteExpectationByIntentId(String intentId);
+ int deleteExpectationByIntentId(String intentId);
- void updateExpectation(List<ExpectationPo> expectation);
+ int updateExpectation(Expectation expectation);
+ int insertExpectation(@Param(value = "expectation") Expectation expectation, @Param(value = "intentId") String intentId);
+
+ int deleteExpectationById(String expectationId);
}
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 4de598a..7cf69a0 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
@@ -17,20 +17,20 @@
package org.onap.usecaseui.intentanalysis.mapper;
import org.apache.ibatis.annotations.Mapper;
-import org.onap.usecaseui.intentanalysis.bean.po.IntentPo;
+import org.onap.usecaseui.intentanalysis.bean.models.Intent;
import java.util.List;
@Mapper
public interface IntentMapper {
- void insertIntent(IntentPo intentPo);
+ int insertIntent(Intent intent);
- void updateIntent(IntentPo intentPo);
+ int updateIntent(Intent intent);
- IntentPo selectIntentById(String intentId);
+ Intent selectIntentById(String intentId);
- List<IntentPo> selectIntents();
+ List<Intent> selectIntents();
- void deleteIntentById(String intentId);
+ int 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
index b1b1416..ad7d3a1 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.java
@@ -17,15 +17,23 @@
package org.onap.usecaseui.intentanalysis.mapper;
import org.apache.ibatis.annotations.Mapper;
-import org.onap.usecaseui.intentanalysis.bean.po.StatePo;
+import org.apache.ibatis.annotations.Param;
+import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
+import org.onap.usecaseui.intentanalysis.bean.models.State;
import java.util.List;
@Mapper
public interface StateMapper {
- void insertState(List<StatePo> state);
+ int insertStateList(@Param(value = "stateList") List<State> state, @Param(value = "expectationId") String expectationId);
- List<StatePo> selectStateByExpectation(String expectationId);
+ List<State> selectStateByExpectation(String expectationId);
- void deleteStateByExpectationId(String expectationId);
+ int deleteStateByExpectationId(String expectationId);
+
+ int updateState(State state);
+
+ int insertState(@Param(value = "state") State state, @Param(value = "expectationId") String expectationId);
+
+ int deleteStateById(String stateId);
}
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 bcdc89e..ba51de1 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
@@ -17,17 +17,21 @@
package org.onap.usecaseui.intentanalysis.service;
-import org.onap.usecaseui.intentanalysis.bean.po.ExpectationPo;
+import org.onap.usecaseui.intentanalysis.bean.models.Expectation;
import java.util.List;
public interface ExpectationService {
- void createExpectationList(List<ExpectationPo> expectationPoList, String intentId);
+ void createExpectationList(List<Expectation> expectationList, String intentId);
void deleteExpectationListById(String intentId);
- void updateExpectationListById(List<ExpectationPo> expectationPoList, String intentId);
+ void updateExpectationListById(List<Expectation> expectationList, String intentId);
- List<ExpectationPo> getExpectationListByIntentId(String intentId);
+ List<Expectation> getExpectationListByIntentId(String intentId);
+
+ void insertExpectation(Expectation expectation, String intentId);
+
+ void deleteExpectationById(String expectationId);
}
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java
index 237c54a..6ee82d6 100644
--- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java
+++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java
@@ -16,17 +16,21 @@
package org.onap.usecaseui.intentanalysis.service;
-import org.onap.usecaseui.intentanalysis.bean.po.StatePo;
+import org.onap.usecaseui.intentanalysis.bean.models.State;
import java.util.List;
public interface StateService {
- void createStateList(List<StatePo> statePoList, String expectationId);
+ void createStateList(List<State> stateList, String expectationId);
void deleteStateListByExpectationId(String expectationId);
- void updateStateListByExpectationId(List<StatePo> statePoList, String expectationId);
+ void updateStateListByExpectationId(List<State> stateList, String expectationId);
- List<StatePo> getStateListByExpectationId(String expectationId);
+ List<State> getStateListByExpectationId(String expectationId);
+
+ void insertState(State state, String expectationId);
+
+ void deleteStateById(String stateId);
}
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 98e5364..af7a2e9 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
@@ -17,8 +17,9 @@
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.bean.models.Expectation;
+import org.onap.usecaseui.intentanalysis.bean.models.State;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
import org.onap.usecaseui.intentanalysis.mapper.ExpectationMapper;
import org.onap.usecaseui.intentanalysis.service.ExpectationService;
import org.onap.usecaseui.intentanalysis.service.StateService;
@@ -26,8 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
+import java.util.ArrayList;
import java.util.List;
@Service
@@ -40,44 +43,108 @@ public class ExpectationServiceImpl implements ExpectationService {
@Autowired
private StateService stateService;
+ @Autowired
+ private ExpectationService expectationService;
+
@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());
+ public void createExpectationList(List<Expectation> expectationList, String intentId) {
+ for (Expectation expectation : expectationList) {
+ if (null != expectation) {
+ stateService.createStateList(expectation.getStateList(), expectation.getExpectationId());
}
}
- expectationMapper.insertExpectation(expectationPoList);
+ int res = expectationMapper.insertExpectationList(expectationList, intentId);
+ if (res < 1) {
+ String msg = "Create expectation to database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
}
@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);
+ public List<Expectation> getExpectationListByIntentId(String intentId) {
+ List<Expectation> expectationList = expectationMapper.selectExpectationByIntentId(intentId);
+ if (expectationList == null) {
+ String msg = String.format("Intent id %s doesn't exist in database.", intentId);
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ for (Expectation expectation : expectationList) {
+ List<State> stateList = stateService.getStateListByExpectationId(expectation.getExpectationId());
+ expectation.setStateList(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());
+ List<Expectation> expectationList = expectationMapper.selectExpectationByIntentId(intentId);
+ if (expectationList == null) {
+ String msg = String.format("Intent id %s doesn't exist in database.", intentId);
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ int res = expectationMapper.deleteExpectationByIntentId(intentId);
+ if (res < 1) {
+ String msg = "Delete expectation in database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ for (Expectation expectation : expectationList) {
+ stateService.deleteStateListByExpectationId(expectation.getExpectationId());
}
}
@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.");
+ public void updateExpectationListById(List<Expectation> expectationList, String intentId) {
+ List<Expectation> expectationDBList = expectationMapper.selectExpectationByIntentId(intentId);
+ if (expectationDBList == null) {
+ String msg = String.format("Intent id %s doesn't exist in database.", intentId);
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ List<String> expectationDBIdList = new ArrayList<>();
+ for (Expectation expectationDB : expectationDBList) {
+ expectationDBIdList.add(expectationDB.getExpectationId());
+ }
+
+ for (Expectation expectation : expectationList) {
+ if (expectationDBIdList.contains(expectation.getExpectationId())) {
+ stateService.updateStateListByExpectationId(expectation.getStateList(), expectation.getExpectationId());
+ int res = expectationMapper.updateExpectation(expectation);
+ if (res < 1) {
+ String msg = "Update expectation in database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ expectationDBIdList.remove(expectation.getExpectationId());
+ } else {
+ expectationService.insertExpectation(expectation, intentId);
+ }
+ }
+ for (String expectationDBId : expectationDBIdList) {
+ expectationService.deleteExpectationById(expectationDBId);
}
- expectationMapper.updateExpectation(expectationPoList);
LOGGER.info("Expectations are successfully updated.");
}
+
+ @Override
+ public void insertExpectation(Expectation expectation, String intentId) {
+ int res = expectationMapper.insertExpectation(expectation, intentId);
+ if (res < 1) {
+ String msg = "Create expectation to database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ }
+
+ @Override
+ public void deleteExpectationById(String expectationId) {
+ int res = expectationMapper.deleteExpectationById(expectationId);
+ if (res < 1) {
+ String msg = "Delete expectation in database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ }
}
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 29a7480..21dfe21 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,7 +18,6 @@ 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;
@@ -27,6 +26,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.onap.usecaseui.intentanalysis.exception.DataBaseException;
+import org.onap.usecaseui.intentanalysis.common.ResponseConsts;
import java.util.ArrayList;
import java.util.List;
@@ -43,59 +44,74 @@ public class IntentServiceImpl implements IntentService {
@Override
public List<Intent> getIntentList() {
- List<Intent> intentList = new ArrayList<>();
- List<IntentPo> intentPoList = intentMapper.selectIntents();
- if (intentPoList == null || intentPoList.size() <= 0) {
- return intentList;
+ List<Intent> intentList = intentMapper.selectIntents();
+ if (intentList == null || intentList.size() <= 0) {
+ String msg = "Intent list doesn't exist in the intent database.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
- for (IntentPo intentPo : intentPoList) {
- if (intentPo != null) {
- intentPo.setExpectationPoList(expectationService.getExpectationListByIntentId(intentPo.getIntentPoId()));
- intentList.add(intentPo.transferToIntent());
- }
+ for (Intent intent : intentList) {
+ intent.setExpectationList(expectationService.getExpectationListByIntentId(intent.getIntentId()));
}
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();
+ Intent intent = intentMapper.selectIntentById(intentId);
+ if (intent != null) {
+ intent.setExpectationList(expectationService.getExpectationListByIntentId(intent.getIntentId()));
+ return intent;
} else {
- String msg = "Intent Id requested doesn't exist in the intent database";
+ String msg = String.format("Intent id %s doesn't exist in database.", intentId);
LOGGER.error(msg);
- throw new IllegalArgumentException(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
}
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Intent createIntent(Intent intent) {
- IntentPo intentPo = intent.transferToIntentPo();
- intentMapper.insertIntent(intentPo);
+ int res = intentMapper.insertIntent(intent);
+ if (res < 1) {
+ String msg = "Create intent to database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
// saving expectation list into expectation table
- expectationService.createExpectationList(intentPo.getExpectationPoList(), intentPo.getIntentPoId());
+ expectationService.createExpectationList(intent.getExpectationList(), intent.getIntentId());
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);
+ Intent intentDB = intentMapper.selectIntentById(intent.getIntentId());
+ if (intentDB == null) {
+ String msg = String.format("Intent id %s doesn't exist in database.", intent.getIntentId());
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
}
- intentMapper.updateIntent(intentPo);
- LOGGER.info("update intent successfully.");
- return intentMapper.selectIntentById(intentId).transferToIntent();
+ expectationService.updateExpectationListById(intent.getExpectationList(), intent.getIntentId());
+ int res = intentMapper.updateIntent(intent);
+ if (res < 1) {
+ String msg = "Update intent in database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ LOGGER.info("Update intent successfully.");
+ return intentMapper.selectIntentById(intent.getIntentId());
}
@Override
public void deleteIntentById(String intentId) {
- intentMapper.deleteIntentById(intentId);
+ int res = intentMapper.deleteIntentById(intentId);
+ if (res < 1) {
+ String msg = "Delete intent in database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
expectationService.deleteExpectationListById(intentId);
+ LOGGER.info("Intent has been deleted successfully.");
}
}
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 c907ff8..06fa9fd 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
@@ -17,40 +17,109 @@
package org.onap.usecaseui.intentanalysis.service.impl;
-import org.onap.usecaseui.intentanalysis.bean.po.StatePo;
+import org.onap.usecaseui.intentanalysis.bean.models.State;
+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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
@Service
public class StateServiceImpl implements StateService {
+ private static Logger LOGGER = LoggerFactory.getLogger(StateServiceImpl.class);
+
@Autowired
private StateMapper stateMapper;
+ @Autowired
+ private StateService stateService;
+
@Override
- public void createStateList(List<StatePo> stateList, String expectationId) {
- for (StatePo state : stateList) {
- state.setStatePoId(expectationId);
+ public void createStateList(List<State> stateList, String expectationId) {
+ int res = stateMapper.insertStateList(stateList, expectationId);
+ if (res < 1) {
+ String msg = "Create state to database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
}
- stateMapper.insertState(stateList);
}
@Override
- public List<StatePo> getStateListByExpectationId(String expectationId) {
- List<StatePo> stateList = stateMapper.selectStateByExpectation(expectationId);
+ public List<State> getStateListByExpectationId(String expectationId) {
+ List<State> stateList = stateMapper.selectStateByExpectation(expectationId);
+ if (stateList == null) {
+ String msg = String.format("Expectation id %s doesn't exist in database.", expectationId);
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
return stateList;
}
@Override
public void deleteStateListByExpectationId(String expectationId) {
- stateMapper.deleteStateByExpectationId(expectationId);
+ int res = stateMapper.deleteStateByExpectationId(expectationId);
+ if (res < 1) {
+ String msg = "Delete state in database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ }
+
+ @Override
+ public void updateStateListByExpectationId(List<State> stateList, String expectationId) {
+ List<State> stateDBList = stateMapper.selectStateByExpectation(expectationId);
+ if (stateDBList == null) {
+ String msg = String.format("Expectation id %s doesn't exist in database.", expectationId);
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY);
+ }
+ List<String> stateDBIdList = new ArrayList<>();
+ for (State stateDB : stateDBList) {
+ stateDBIdList.add(stateDB.getStateId());
+ }
+ for (State state : stateList) {
+ if (stateDBIdList.contains(state.getStateId())) {
+ int res = stateMapper.updateState(state);
+ if (res < 1) {
+ String msg = "Update state in database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL);
+ }
+ stateDBIdList.remove(state.getStateId());
+ } else {
+ stateService.insertState(state, expectationId);
+ }
+ }
+ for (String stateDBId : stateDBIdList) {
+ stateService.deleteStateById(stateDBId);
+ }
+ LOGGER.info("States are successfully updated.");
}
@Override
- public void updateStateListByExpectationId(List<StatePo> statePoList, String expectationId){
- };
+ public void insertState(State state, String expectationId) {
+ int res = stateMapper.insertState(state, expectationId);
+ if (res < 1) {
+ String msg = "Create state to database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL);
+ }
+ }
+
+ @Override
+ public void deleteStateById(String stateId) {
+ int res = stateMapper.deleteStateById(stateId);
+ if (res < 1) {
+ String msg = "Delete state in database failed.";
+ LOGGER.error(msg);
+ throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL);
+ }
+ }
}
diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
index 5c5ac06..3b0923f 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml
@@ -2,21 +2,21 @@
<!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">
+<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.ExpectationMapper">
- <select id="selectExpectationByIntentId" resultType="org.onap.usecaseui.intentanalysis.bean.po.ExpectationPo">
+ <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="insertExpectation">
+ <insert id="insertExpectationList">
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 collection="expectationList" index="index" item="item" separator=",">
+ (#{item.expectationId}, #{item.expectationName}, #{item.targetMOI}, #{intentId})
</foreach>
</insert>
@@ -25,4 +25,24 @@
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> \ 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
index c814bfe..5e2847b 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml
@@ -2,14 +2,14 @@
<!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">
+<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.IntentMapper">
- <select id="selectIntentById" resultType="org.onap.usecaseui.intentanalysis.bean.po.IntentPo">
+ <select id="selectIntentById" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
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 id="selectIntents" resultType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
select intent_id intentId, intent_name intentName from intent
</select>
@@ -18,10 +18,9 @@
values(#{intentId}, #{intentName})
</insert>
- <update id="updateIntent" parameterType="org.onap.usecaseui.intentanalysis.bean.po.IntentPo">
+ <update id="updateIntent" parameterType="org.onap.usecaseui.intentanalysis.bean.models.Intent">
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}
diff --git a/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
index 987c75f..9e30981 100644
--- a/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
+++ b/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml
@@ -2,20 +2,20 @@
<!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">
+<mapper namespace="org.onap.usecaseui.intentanalysis.mapper.StateMapper">
- <select id="selectStateByExpectation" resultType="org.onap.usecaseui.intentanalysis.bean.po.StatePo">
+ <select id="selectStateByExpectation" resultType="org.onap.usecaseui.intentanalysis.bean.models.State">
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 id="insertStateList" 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 collection="stateList" index="index" item="item" separator=",">
+ (#{item.stateId}, #{item.stateName}, #{expectationId}, #{item.isSatisfied}, #{item.condition})
</foreach>
</insert>
@@ -24,4 +24,25 @@
where expectation_id = #{expectationId}
</delete>
+ <insert id="insertState">
+ insert into state(state_id, state_name, expectation_id, is_satisfied, condition)
+ values (#{state.stateId}, #{state.stateName}, #{expectationId}, #{state.isSatisfied}, #{state.condition})
+ </insert>
+
+ <update id="updateState" parameterType="java.util.List">
+ update state
+ <trim prefix="set" suffixOverrides=",">
+ <if test="stateName != null">state_name = #{stateName},</if>
+ <if test="isSatisfied != null">is_satisfied = #{isSatisfied},</if>
+ <if test="condition != null">condition = #{condition},</if>
+ </trim>
+ where state_id = #{stateId}
+ </update>
+
+ <delete id="deleteStateById">
+ delete
+ from state
+ where state_id = #{stateId}
+ </delete>
+
</mapper> \ No newline at end of file