X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Floop%2FLoopController.java;h=9c2c71f5f1d6ade5d979358f658f5620c7bda0b5;hb=e916ac28ba46ff7cad64f1a3150b128ba4772c70;hp=d230eb976b16c748448d536c3b26d7d030891a2d;hpb=82775724cf35060294388f84d2e7d2b0671ee838;p=clamp.git diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java index d230eb97..9c2c71f5 100644 --- a/src/main/java/org/onap/clamp/loop/LoopController.java +++ b/src/main/java/org/onap/clamp/loop/LoopController.java @@ -29,9 +29,12 @@ import com.google.gson.reflect.TypeToken; import java.io.IOException; import java.lang.reflect.Type; import java.util.List; +import org.onap.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.policy.microservice.MicroServicePolicy; +import org.onap.clamp.policy.microservice.MicroServicePolicyService; import org.onap.clamp.policy.operational.OperationalPolicy; +import org.onap.clamp.policy.operational.OperationalPolicyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -39,13 +42,36 @@ import org.springframework.stereotype.Controller; public class LoopController { private final LoopService loopService; - private static final Type OPERATIONAL_POLICY_TYPE = new TypeToken>() {}.getType(); - private static final Type MICROSERVICE_POLICY_TYPE = new TypeToken>() {}.getType(); + private final ToscaConverterWithDictionarySupport toscaConverter; + private final OperationalPolicyService operationalPolicyService; + + private final MicroServicePolicyService microServicePolicyService; + + private static final Type OPERATIONAL_POLICY_TYPE = new TypeToken>() { + }.getType(); + + private static final Type MICROSERVICE_POLICY_TYPE = new TypeToken>() { + }.getType(); + + + /** + * Constructor. + * + * @param loopService loopService + * @param operationalPolicyService operationalPolicyService + * @param microServicePolicyService microServicePolicyService + * @param toscaConverter toscaConverter + */ @Autowired - public LoopController(LoopService loopService) { + public LoopController(LoopService loopService, OperationalPolicyService operationalPolicyService, + MicroServicePolicyService microServicePolicyService, + ToscaConverterWithDictionarySupport toscaConverter) { this.loopService = loopService; + this.toscaConverter = toscaConverter; + this.operationalPolicyService = operationalPolicyService; + this.microServicePolicyService = microServicePolicyService; } public Loop createLoop(String loopName, String templateName) { @@ -156,10 +182,34 @@ public class LoopController { /** * Refresh the Operational Policy Json representation of the loop. * - * @param loopName The loop name - * @return The refreshed Loop + * @param loop The loop + * @param operationalPolicyName The operational policy name that needs a refresh + * @return The loop object + */ + public Loop refreshOperationalPolicyJsonRepresentation(Loop loop, String operationalPolicyName) { + for (OperationalPolicy operationalPolicy : loop.getOperationalPolicies()) { + if (operationalPolicy.getName().equals(operationalPolicyName)) { + this.operationalPolicyService + .refreshOperationalPolicyJsonRepresentation(operationalPolicy, toscaConverter); + } + } + return loop; + } + + /** + * Refresh the Config Policy Json representation of the loop. + * + * @param loop The loop + * @param microServicePolicyName The microservice policy name that needs a refresh + * @return The loop object */ - public Loop refreshOpPolicyJsonRepresentation(String loopName) { - return loopService.refreshOpPolicyJsonRepresentation(loopName); + public Loop refreshMicroServicePolicyJsonRepresentation(Loop loop, String microServicePolicyName) { + for (MicroServicePolicy microServicePolicy : loop.getMicroServicePolicies()) { + if (microServicePolicy.getName().equals(microServicePolicyName)) { + this.microServicePolicyService + .refreshMicroServicePolicyJsonRepresentation(microServicePolicy, toscaConverter); + } + } + return loop; } }