diff options
Diffstat (limited to 'intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java')
-rw-r--r-- | intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java index 6a091c5..c80c717 100644 --- a/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java +++ b/intentanalysis/src/main/java/org/onap/usecaseui/intentanalysis/cllassuranceIntentmgt/cllassurancemodule/CLLAssuranceActuationModule.java @@ -15,22 +15,44 @@ */ package org.onap.usecaseui.intentanalysis.cllassuranceIntentmgt.cllassurancemodule; -import org.onap.usecaseui.intentanalysis.bean.models.Intent; -import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean; +import org.apache.commons.lang.StringUtils; +import org.onap.usecaseui.intentanalysis.adapters.policy.PolicyService; +import org.onap.usecaseui.intentanalysis.bean.enums.IntentGoalType; +import org.onap.usecaseui.intentanalysis.bean.models.*; import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction; import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule; +import org.onap.usecaseui.intentanalysis.service.IntentService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; + @Component public class CLLAssuranceActuationModule extends ActuationModule { + @Autowired + private IntentService intentService; + + @Autowired + private PolicyService policyService; + @Override public void toNextIntentHandler(IntentGoalBean intentGoalBean, IntentManagementFunction IntentHandler) { } @Override - public void directOperation() { - + public void directOperation(IntentGoalBean intentGoalBean) { + Intent intent = intentGoalBean.getIntent(); + String cllId = getCLLId(intent); + String bandwidth = getBandwidth(cllId); + IntentGoalType intentGoalType = intentGoalBean.getIntentGoalType(); + if (StringUtils.equalsIgnoreCase("create", intentGoalType.name())) { + policyService.updateIntentConfigPolicy(cllId, bandwidth, "true"); + } else if (StringUtils.equalsIgnoreCase("update", intentGoalType.name())) { + policyService.updateIntentConfigPolicy(cllId, bandwidth, "false"); + } else if (StringUtils.equalsIgnoreCase("delete", intentGoalType.name())) { + policyService.updateIntentConfigPolicy(cllId, bandwidth, "false"); + } } @Override @@ -40,10 +62,44 @@ public class CLLAssuranceActuationModule extends ActuationModule { @Override public void fulfillIntent(IntentGoalBean intentGoalBean, IntentManagementFunction intentHandler) { - directOperation(); + directOperation(intentGoalBean); } + @Override public void updateIntentOperationInfo(Intent originIntent, IntentGoalBean intentGoalBean){ } + + private String getBandwidth(String cllId) { + List<Intent> deliveryIntentList = intentService.getIntentByName("CLL Delivery Intent"); + for (Intent deliveryIntent : deliveryIntentList) { + List<Expectation> deliveryExpectationList = deliveryIntent.getIntentExpectations(); + for (Expectation deliveryExpectation : deliveryExpectationList) { + if (StringUtils.equalsIgnoreCase(cllId, deliveryExpectation.getExpectationObject().getObjectInstance())) { + List<ExpectationTarget> deliveryTargetList = deliveryExpectation.getExpectationTargets(); + for (ExpectationTarget deliveryTarget : deliveryTargetList) { + if (StringUtils.equalsIgnoreCase("bandwidth", deliveryTarget.getTargetName())) { + List<Condition> deliveryConditionList = deliveryTarget.getTargetConditions(); + for (Condition deliveryCondition : deliveryConditionList) { + if (StringUtils.equalsIgnoreCase("condition of the cll service bandwidth", deliveryCondition.getConditionName())) { + return deliveryCondition.getConditionValue(); + } + } + } + } + } + } + } + return null; + } + + public String getCLLId(Intent intent) { + List<Expectation> expectationList = intent.getIntentExpectations(); + for (Expectation expectation : expectationList) { + if (StringUtils.equalsIgnoreCase("assurance", expectation.getExpectationType().name())) { + return expectation.getExpectationObject().getObjectInstance(); + } + } + return null; + } } |