2 * Copyright 2022 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.usecaseui.intentanalysis.service.impl;
20 import java.util.ArrayList;
21 import java.util.List;
23 import org.onap.usecaseui.intentanalysis.bean.enums.ConditionParentType;
24 import org.onap.usecaseui.intentanalysis.service.ConditionService;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.stereotype.Service;
29 import org.onap.usecaseui.intentanalysis.bean.enums.ContextParentType;
30 import org.onap.usecaseui.intentanalysis.bean.models.ExpectationTarget;
31 import org.onap.usecaseui.intentanalysis.mapper.ExpectationTargetMapper;
32 import org.onap.usecaseui.intentanalysis.service.ContextService;
33 import org.onap.usecaseui.intentanalysis.service.ExpectationTargetService;
34 import org.onap.usecaseui.intentanalysis.service.FulfilmentInfoService;
38 public class ExpectationTargetServiceImpl implements ExpectationTargetService {
40 private static Logger LOGGER = LoggerFactory.getLogger(ExpectationTargetServiceImpl.class);
42 private ContextParentType contextParentType;
44 private ConditionParentType conditionParentType;
46 private ExpectationTargetMapper expectationTargetMapper;
49 private ExpectationTargetService expectationTargetService;
53 private FulfilmentInfoService fulfilmentInfoService;
56 private ContextService contextService;
59 private ConditionService conditionService;
61 public void createTarget(ExpectationTarget expectationTarget, String expectationId) {
62 expectationTargetMapper.insertExpectationTarget(expectationTarget, expectationId);
63 contextService.createContextList(expectationTarget.getTargetContexts(),
64 contextParentType.EXPECTATION_TARGET,
65 expectationTarget.getTargetId());
66 fulfilmentInfoService.createFulfilmentInfo(expectationTarget.getTargetFulfilmentInfo(),
67 expectationTarget.getTargetId());
68 conditionService.createConditionList(expectationTarget.getTargetConditions(),conditionParentType.EXPECTATION_TARGET,expectationId);
72 public void createTargets(List<ExpectationTarget> expectationTargets, String expectationId) {
73 for (ExpectationTarget expectationTarget : expectationTargets) {
74 if (null != expectationTarget) {
75 expectationTargetService.createTarget(expectationTarget, expectationId);