From a51fa2e8573a8463109e7c8b1ed6938c9488fb21 Mon Sep 17 00:00:00 2001 From: ShuhaoCai Date: Thu, 28 Jul 2022 17:59:38 +0800 Subject: Delete imtent po and reformat code Signed-off-by: ShuhaoCai Issue-ID: USECASEUI-704 Change-Id: I1047a092291996c609bfa5efd03e35c3b2ff607a --- .../intentanalysis/bean/models/Expectation.java | 22 +-------- .../intentanalysis/bean/models/Intent.java | 20 -------- .../intentanalysis/bean/models/State.java | 10 +--- .../intentanalysis/bean/po/ExpectationPo.java | 57 ---------------------- .../usecaseui/intentanalysis/bean/po/IntentPo.java | 53 -------------------- .../usecaseui/intentanalysis/bean/po/StatePo.java | 43 ---------------- .../IntentManagementFunction.java | 2 + .../intentanalysis/mapper/ExpectationMapper.java | 9 ++-- .../intentanalysis/mapper/IntentMapper.java | 10 ++-- .../intentanalysis/mapper/StateMapper.java | 7 +-- .../intentanalysis/service/ExpectationService.java | 8 +-- .../intentanalysis/service/StateService.java | 8 +-- .../service/impl/ExpectationServiceImpl.java | 39 ++++++++------- .../service/impl/IntentServiceImpl.java | 37 ++++++-------- .../service/impl/StateServiceImpl.java | 18 +++---- .../resources/mybatis/sql/ExpectationMapper.xml | 8 +-- .../main/resources/mybatis/sql/IntentMapper.xml | 8 +-- .../src/main/resources/mybatis/sql/StateMapper.xml | 8 +-- 18 files changed, 81 insertions(+), 286 deletions(-) delete mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/ExpectationPo.java delete mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/IntentPo.java delete mode 100644 intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/StatePo.java (limited to 'intentanalysis') 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 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 getStatePoList() { - List 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 expectationList; - public IntentPo transferToIntentPo() { - IntentPo intentPo = new IntentPo(); - intentPo.setIntentPoId(this.intentId); - intentPo.setIntentPoName(this.intentName); - intentPo.setExpectationPoList(getExpectationPoList()); - return intentPo; - } - - private List getExpectationPoList() { - List 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 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 getStateList() { - List 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 expectationPoList; - - public Intent transferToIntent() { - Intent intent = new Intent(); - intent.setIntentId(this.intentPoId); - intent.setIntentName(this.intentPoName); - - intent.setExpectationList(getExpectationList()); - return intent; - } - - private List getExpectationList() { - List 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/bean/po/StatePo.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/StatePo.java deleted file mode 100644 index 5b334cc..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/bean/po/StatePo.java +++ /dev/null @@ -1,43 +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.State; -import lombok.Data; - -@Data -public class StatePo { - - private String statePoId; - - 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; - } -} 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..c05a344 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,19 @@ 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 expectation); + void insertExpectation(@Param(value = "expectationList") List expectationList, @Param(value = "intentId") String intentId); - List selectExpectationByIntentId(String intentId); + List selectExpectationByIntentId(String intentId); void deleteExpectationByIntentId(String intentId); - void updateExpectation(List expectation); + void updateExpectation(List 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 index 4de598a..e3bd6f3 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); + void insertIntent(Intent intent); - void updateIntent(IntentPo intentPo); + void updateIntent(Intent intent); - IntentPo selectIntentById(String intentId); + Intent selectIntentById(String intentId); - List selectIntents(); + List 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 index b1b1416..ab7e47b 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,16 @@ 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.State; import java.util.List; @Mapper public interface StateMapper { - void insertState(List state); + void insertState(@Param(value = "stateList") List state, @Param(value = "expectationId") String expectationId); - List selectStateByExpectation(String expectationId); + List selectStateByExpectation(String expectationId); void deleteStateByExpectationId(String expectationId); } 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..8d0759f 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,17 @@ 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 expectationPoList, String intentId); + void createExpectationList(List expectationList, String intentId); void deleteExpectationListById(String intentId); - void updateExpectationListById(List expectationPoList, String intentId); + void updateExpectationListById(List expectationList, String intentId); - List getExpectationListByIntentId(String intentId); + List getExpectationListByIntentId(String intentId); } 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..187f964 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,17 @@ 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 statePoList, String expectationId); + void createStateList(List stateList, String expectationId); void deleteStateListByExpectationId(String expectationId); - void updateStateListByExpectationId(List statePoList, String expectationId); + void updateStateListByExpectationId(List stateList, String expectationId); - List getStateListByExpectationId(String expectationId); + List getStateListByExpectationId(String expectationId); } 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..5f21f58 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,8 @@ 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.mapper.ExpectationMapper; import org.onap.usecaseui.intentanalysis.service.ExpectationService; import org.onap.usecaseui.intentanalysis.service.StateService; @@ -41,43 +41,42 @@ public class ExpectationServiceImpl implements ExpectationService { private StateService stateService; @Override - public void createExpectationList(List expectationPoList, String intentId) { - for (ExpectationPo expectationPo : expectationPoList) { - if (null != expectationPo) { - expectationPo.setIntentPoId(intentId); - stateService.createStateList(expectationPo.getStatePoList(), expectationPo.getExpectationPoId()); + public void createExpectationList(List expectationList, String intentId) { + for (Expectation expectation : expectationList) { + if (null != expectation) { + stateService.createStateList(expectation.getStateList(), expectation.getExpectationId()); } } - expectationMapper.insertExpectation(expectationPoList); + expectationMapper.insertExpectation(expectationList, intentId); } @Override - public List getExpectationListByIntentId(String intentId) { - List expectationList = expectationMapper.selectExpectationByIntentId(intentId); - for (ExpectationPo expectation : expectationList) { - List stateList = stateService.getStateListByExpectationId(expectation.getExpectationPoId()); - expectation.setStatePoList(stateList); + public List getExpectationListByIntentId(String intentId) { + List expectationList = expectationMapper.selectExpectationByIntentId(intentId); + for (Expectation expectation : expectationList) { + List stateList = stateService.getStateListByExpectationId(expectation.getExpectationId()); + expectation.setStateList(stateList); } return expectationList; } @Override public void deleteExpectationListById(String intentId) { - List expectationList = expectationMapper.selectExpectationByIntentId(intentId); + List expectationList = expectationMapper.selectExpectationByIntentId(intentId); expectationMapper.deleteExpectationByIntentId(intentId); - for (ExpectationPo expectation : expectationList) { - stateService.deleteStateListByExpectationId(expectation.getExpectationPoId()); + for (Expectation expectation : expectationList) { + stateService.deleteStateListByExpectationId(expectation.getExpectationId()); } } @Override - public void updateExpectationListById(List expectationPoList, String intentId) { - List expectationList = expectationMapper.selectExpectationByIntentId(intentId); - if (expectationList == null) { + public void updateExpectationListById(List expectationList, String intentId) { + List expectationDBList = expectationMapper.selectExpectationByIntentId(intentId); + if (expectationDBList == 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); + expectationMapper.updateExpectation(expectationDBList); 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 index 29a7480..7372510 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; @@ -43,26 +42,22 @@ public class IntentServiceImpl implements IntentService { @Override public List getIntentList() { - List intentList = new ArrayList<>(); - List intentPoList = intentMapper.selectIntents(); - if (intentPoList == null || intentPoList.size() <= 0) { - return intentList; + List intentList = intentMapper.selectIntents(); + if (intentList == null || intentList.size() <= 0) { + return new ArrayList<>(); } - 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"; LOGGER.error(msg); @@ -73,10 +68,9 @@ public class IntentServiceImpl implements IntentService { @Transactional(rollbackFor = RuntimeException.class) @Override public Intent createIntent(Intent intent) { - IntentPo intentPo = intent.transferToIntentPo(); - intentMapper.insertIntent(intentPo); + intentMapper.insertIntent(intent); // 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; } @@ -84,18 +78,19 @@ public class IntentServiceImpl implements IntentService { @Override public Intent updateIntent(Intent intent) { String intentId = intent.getIntentId(); - IntentPo intentPo = intentMapper.selectIntentById(intentId); - if (intentPo == null) { + Intent intentDB = intentMapper.selectIntentById(intentId); + if (intentDB == null) { LOGGER.error("intent id {} not exists in db.", intentId); } - intentMapper.updateIntent(intentPo); + intentMapper.updateIntent(intentDB); LOGGER.info("update intent successfully."); - return intentMapper.selectIntentById(intentId).transferToIntent(); + return intentMapper.selectIntentById(intentId); } @Override public void deleteIntentById(String intentId) { intentMapper.deleteIntentById(intentId); 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..134e84a 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,7 +17,7 @@ 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.mapper.StateMapper; import org.onap.usecaseui.intentanalysis.service.StateService; import org.springframework.beans.factory.annotation.Autowired; @@ -32,16 +32,13 @@ public class StateServiceImpl implements StateService { private StateMapper stateMapper; @Override - public void createStateList(List stateList, String expectationId) { - for (StatePo state : stateList) { - state.setStatePoId(expectationId); - } - stateMapper.insertState(stateList); + public void createStateList(List stateList, String expectationId) { + stateMapper.insertState(stateList, expectationId); } @Override - public List getStateListByExpectationId(String expectationId) { - List stateList = stateMapper.selectStateByExpectation(expectationId); + public List getStateListByExpectationId(String expectationId) { + List stateList = stateMapper.selectStateByExpectation(expectationId); return stateList; } @@ -51,6 +48,7 @@ public class StateServiceImpl implements StateService { } @Override - public void updateStateListByExpectationId(List statePoList, String expectationId){ - }; + public void updateStateListByExpectationId(List stateList, String expectationId){ + + } } diff --git a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml index 5c5ac06..720bdd5 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/ExpectationMapper.xml @@ -2,10 +2,10 @@ - + - select expectation_id expectationId, expectation_name expectationName, target_moi targetMOI, intent_id intentId from expectation @@ -15,8 +15,8 @@ insert into expectation(expectation_id, expectation_name, target_moi, intent_id) values - - (#{item.expectationId}, #{item.expectationName}, #{item.targetMOI}, #{item.intentId}) + + (#{item.expectationId}, #{item.expectationName}, #{item.targetMOI}, #{intentId}) diff --git a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml index c814bfe..335ba6d 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/IntentMapper.xml @@ -2,14 +2,14 @@ - + - select intent_id intentId, intent_name intentName from intent where intent_id = #{intentId} - select intent_id intentId, intent_name intentName from intent @@ -18,7 +18,7 @@ values(#{intentId}, #{intentName}) - + update intent 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..4850870 100644 --- a/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml +++ b/intentanalysis/src/main/resources/mybatis/sql/StateMapper.xml @@ -2,9 +2,9 @@ - + - select state_id stateId, state_name stateName, expectation_id expectationId, is_satisfied isSatisfied, condition from state @@ -14,8 +14,8 @@ insert into state(state_id, state_name, expectation_id, is_satisfied, condition) values - - (#{item.stateId}, #{item.stateName}, #{item.expectationId}, #{item.isSatisfied}, #{item.condition}) + + (#{item.stateId}, #{item.stateName}, #{expectationId}, #{item.isSatisfied}, #{item.condition}) -- cgit 1.2.3-korg