diff options
Diffstat (limited to 'intentanalysis/src/main/java')
5 files changed, 6 insertions, 204 deletions
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 cc253ab..1178b6d 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 @@ -37,5 +37,5 @@ public interface IntentMapper { int deleteIntent(@Param(value = "intentId") String intentId); - List<Intent> getIntentByName(@Param(value = "name") String name); + List<Intent> getIntentByName(@Param(value = "intentName") String name); } 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 deleted file mode 100644 index 10538c4..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/mapper/StateMapper.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.mapper; - - -import java.util.List; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.onap.usecaseui.intentanalysis.bean.models.Expectation; -import org.onap.usecaseui.intentanalysis.bean.models.State; - - -@Mapper - -public interface StateMapper { - - int insertStateList(@Param(value = "stateList") List<State> state, - @Param(value = "expectationId") String expectationId); - - List<State> selectStateByExpectation(@Param(value = "expectationId") String expectationId); - - int deleteStateByExpectationId(@Param(value = "expectationId") String expectationId); - - int updateState(@Param(value = "state") State state); - - int insertState(@Param(value = "state") State state, @Param(value = "expectationId") String expectationId); - - int deleteStateById(@Param(value = "stateId") String stateId); -} 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 deleted file mode 100644 index d2d66c7..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/StateService.java +++ /dev/null @@ -1,37 +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.service; - - -import java.util.List; -import org.onap.usecaseui.intentanalysis.bean.models.State; - - -public interface StateService { - - void createStateList(List<State> stateList, String expectationId); - - void deleteStateListByExpectationId(String expectationId); - - void updateStateListByExpectationId(List<State> stateList, String expectationId); - - List<State> getStateListByExpectationId(String expectationId); - - void createState(State state, String expectationId); - - void deleteStateById(String stateId); -} 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 952b6dd..bb1759c 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 @@ -87,7 +87,9 @@ public class IntentServiceImpl implements IntentService { public Intent getIntent(String intentId) { Intent intent = intentMapper.selectIntent(intentId); if (intent != null) { - intent.setIntentExpectations(expectationService.getIntentExpectationList(intent.getIntentId())); + intent.setIntentExpectations(expectationService.getIntentExpectationList(intentId)); + intent.setIntentContexts(contextService.getContextList(intentId)); + intent.setIntentFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfo(intentId)); } else { log.info(String.format("Intent is null, intentId = %s", intentId)); } @@ -140,6 +142,8 @@ public class IntentServiceImpl implements IntentService { if (!CollectionUtils.isEmpty(intentList)) { for (Intent intent : intentList) { intent.setIntentExpectations(expectationService.getIntentExpectationList(intent.getIntentId())); + intent.setIntentContexts(contextService.getContextList(intent.getIntentId())); + intent.setIntentFulfilmentInfo(fulfilmentInfoService.getFulfilmentInfo(intent.getIntentId())); } } else { 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 deleted file mode 100644 index b9c7b95..0000000 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/service/impl/StateServiceImpl.java +++ /dev/null @@ -1,122 +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.service.impl; - - -import lombok.extern.slf4j.Slf4j; -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 java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - -@Service -@Slf4j -public class StateServiceImpl implements StateService { - - @Autowired - private StateMapper stateMapper; - - @Autowired - private StateService stateService; - - @Override - public void createStateList(List<State> stateList, String expectationId) { - int res = stateMapper.insertStateList(stateList, expectationId); - if (res < 1) { - String msg = "Create state to database failed."; - log.error(msg); - throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL); - } - } - - @Override - public List<State> getStateListByExpectationId(String expectationId) { - List<State> stateList = stateMapper.selectStateByExpectation(expectationId); - if (stateList == null) { - String msg = String.format("State: Expectation id %s doesn't exist in database.", expectationId); - log.error(msg); - throw new DataBaseException(msg, ResponseConsts.RET_QUERY_DATA_EMPTY); - } - return stateList; - } - - @Override - public void deleteStateListByExpectationId(String expectationId) { - if (stateMapper.deleteStateByExpectationId(expectationId) < 1) { - String msg = "Delete state in database failed."; - log.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); - log.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."; - log.error(msg); - throw new DataBaseException(msg, ResponseConsts.RET_UPDATE_DATA_FAIL); - } - stateDBIdList.remove(state.getStateId()); - } else { - stateService.createState(state, expectationId); - } - } - for (String stateDBId : stateDBIdList) { - stateService.deleteStateById(stateDBId); - } - log.info("States are successfully updated."); - } - - @Override - public void createState(State state, String expectationId) { - if (stateMapper.insertState(state, expectationId) < 1) { - String msg = "Create state to database failed."; - log.error(msg); - throw new DataBaseException(msg, ResponseConsts.RET_INSERT_DATA_FAIL); - } - } - - @Override - public void deleteStateById(String stateId) { - if (stateMapper.deleteStateById(stateId) < 1) { - String msg = "Delete state in database failed."; - log.error(msg); - throw new DataBaseException(msg, ResponseConsts.RET_DELETE_DATA_FAIL); - } - } -}
\ No newline at end of file |