diff options
Diffstat (limited to 'src/main/java/org')
15 files changed, 111 insertions, 77 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java b/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java index b3fcb6f18..44abc9dde 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java @@ -25,10 +25,8 @@ package org.onap.clamp.clds.client; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; - import com.google.gson.JsonArray; import com.google.gson.JsonObject; - import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; @@ -38,27 +36,21 @@ import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.builder.ExchangeBuilder; -import org.json.simple.parser.ParseException; import org.onap.clamp.clds.config.ClampProperties; import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.loop.template.PolicyModel; -import org.onap.clamp.loop.template.PolicyModelId; import org.onap.clamp.loop.template.PolicyModelsService; import org.onap.clamp.policy.pdpgroup.PdpGroup; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.yaml.snakeyaml.Yaml; - - /** * The class implements the communication with the Policy Engine to retrieve * policy models (tosca). It mainly delegates the physical calls to Camel * engine. - * */ @Component public class PolicyEngineServices { @@ -76,16 +68,15 @@ public class PolicyEngineServices { /** * Default constructor. * - * @param camelContext Camel context bean - * @param clampProperties ClampProperties bean - * @param policyModelsSService policyModel repository bean + * @param camelContext Camel context bean + * @param clampProperties ClampProperties bean * @param policyModelsService policyModel service */ @Autowired public PolicyEngineServices(CamelContext camelContext, ClampProperties clampProperties, - PolicyModelsService policyModelsSService) { + PolicyModelsService policyModelsService) { this.camelContext = camelContext; - this.policyModelsService = policyModelsSService; + this.policyModelsService = policyModelsService; if (clampProperties.getStringValue(POLICY_RETRY_LIMIT) != null) { retryLimit = Integer.parseInt(clampProperties.getStringValue(POLICY_RETRY_LIMIT)); } @@ -97,7 +88,7 @@ public class PolicyEngineServices { /** * This method query Policy engine and create a PolicyModel object with type and version. * - * @param policyType The policyType id + * @param policyType The policyType id * @param policyVersion The policy version of that type * @return A PolicyModel created from policyEngine data */ @@ -130,7 +121,8 @@ public class PolicyEngineServices { List<LinkedHashMap<String, Object>> policyTypesList = (List<LinkedHashMap<String, Object>>) loadedYaml .get("policy_types"); policyTypesList.parallelStream().forEach(policyType -> { - Map.Entry<String, Object> policyTypeEntry = (Map.Entry<String, Object>) new ArrayList(policyType.entrySet()).get(0); + Map.Entry<String, Object> policyTypeEntry = + (Map.Entry<String, Object>) new ArrayList(policyType.entrySet()).get(0); policyModelsService.createPolicyInDbIfNeeded( createPolicyModelFromPolicyEngine(policyTypeEntry.getKey(), @@ -141,31 +133,34 @@ public class PolicyEngineServices { /** * This method can be used to download all policy types + data types defined in * policy engine. - * + * * @return A yaml containing all policy Types and all data types */ public String downloadAllPolicies() { - return callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-policy-models", "Get all policies"); + return callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-policy-models", + "Get all policies"); } /** * This method can be used to download a policy tosca model on the engine. - * + * * @param policyType The policy type (id) * @param policyVersion The policy version * @return A string with the whole policy tosca model */ public String downloadOnePolicy(String policyType, String policyVersion) { return callCamelRoute(ExchangeBuilder.anExchange(camelContext).withProperty("policyModelName", policyType) - .withProperty("policyModelVersion", policyVersion).build(), "direct:get-policy-model", "Get one policy"); + .withProperty("policyModelVersion", policyVersion).build(), "direct:get-policy-model", + "Get one policy"); } /** * This method can be used to download all Pdp Groups data from policy engine. - * */ public void downloadPdpGroups() { - String responseBody = callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-pdp-groups", "Get Pdp Groups"); + String responseBody = + callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-pdp-groups", + "Get Pdp Groups"); if (responseBody == null || responseBody.isEmpty()) { logger.warn("getPdpGroups returned by policy engine could not be decoded, as it's null or empty"); diff --git a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java index 626227e20..a7ef10738 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java @@ -26,14 +26,12 @@ package org.onap.clamp.clds.config; import com.google.gson.JsonParseException; - import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; - import org.apache.commons.io.IOUtils; -import org.onap.clamp.clds.exception.CldsUsersException; import org.onap.clamp.authorization.CldsUser; +import org.onap.clamp.clds.exception.CldsUsersException; import org.onap.clamp.clds.util.JsonUtils; public class CldsUserJsonDecoder { diff --git a/src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java b/src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java index a4515860e..1261a5e95 100644 --- a/src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/DefaultUserConfiguration.java @@ -27,12 +27,10 @@ package org.onap.clamp.clds.config; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; - import java.io.IOException; - +import org.onap.clamp.authorization.CldsUser; import org.onap.clamp.clds.exception.CldsConfigException; import org.onap.clamp.clds.exception.CldsUsersException; -import org.onap.clamp.authorization.CldsUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java index 7edf6c1a4..8e3b06a46 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java @@ -88,12 +88,10 @@ public class ClampGraphBuilder { public ClampGraphBuilder addLoopElementModel(LoopElementModel loopElementModel) { if (LoopElementModel.MICRO_SERVICE_TYPE.equals(loopElementModel.getLoopElementType())) { microServices.add(new MicroServicePolicy(loopElementModel.getName(), - loopElementModel.getPolicyModels().first(), - false, - null)); + loopElementModel.getPolicyModels().first(), false, loopElementModel)); } else if (LoopElementModel.OPERATIONAL_POLICY_TYPE.equals(loopElementModel.getLoopElementType())) { policies.add(new OperationalPolicy(loopElementModel.getName(), null, null, - loopElementModel.getPolicyModels().first())); + loopElementModel.getPolicyModels().first(), loopElementModel)); } return this; } diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java index af62d84a8..5ec59dbaf 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java @@ -83,7 +83,7 @@ public class Painter { for (MicroServicePolicy ms : microServices) { ib.arrow().rectangle(ms.getName(), - RectTypes.MICROSERVICE, ms.getPolicyModel().getPolicyAcronym()); + RectTypes.MICROSERVICE, ms.getPolicyModel().getPolicyAcronym()).arrow(); } for (OperationalPolicy policy : policies) { ib.arrow().rectangle(policy.getName(), RectTypes.POLICY, policy.getPolicyModel().getPolicyAcronym()) diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index 676626a1f..b3fe58f9c 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -60,6 +60,7 @@ import org.onap.clamp.loop.components.external.ExternalComponent; import org.onap.clamp.loop.components.external.PolicyComponent; import org.onap.clamp.loop.log.LoopLog; import org.onap.clamp.loop.service.Service; +import org.onap.clamp.loop.template.LoopElementModel; import org.onap.clamp.loop.template.LoopTemplate; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.operational.OperationalPolicy; @@ -155,6 +156,28 @@ public class Loop extends AuditEntity implements Serializable { initializeExternalComponents(); } + /** + * This constructor creates a loop from a loop template. + * + * @param name The loop name + * @param loopTemplate The loop template from which a new loop instance must be created + */ + public Loop(String name, LoopTemplate loopTemplate) { + this(name,""); + this.setLoopTemplate(loopTemplate); + this.setModelService(loopTemplate.getModelService()); + loopTemplate.getLoopElementModelsUsed().forEach(element -> { + if (LoopElementModel.MICRO_SERVICE_TYPE.equals(element.getLoopElementModel().getLoopElementType())) { + this.addMicroServicePolicy(new MicroServicePolicy(name, + element.getLoopElementModel().getPolicyModels().first(), false, element.getLoopElementModel())); + } else if (LoopElementModel.OPERATIONAL_POLICY_TYPE + .equals(element.getLoopElementModel().getLoopElementType())) { + this.addOperationalPolicy(new OperationalPolicy(name, null, new JsonObject(), + element.getLoopElementModel().getPolicyModels().first(), element.getLoopElementModel())); + } + }); + } + public String getName() { return name; } diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java index c161c550e..7b037da6d 100644 --- a/src/main/java/org/onap/clamp/loop/LoopController.java +++ b/src/main/java/org/onap/clamp/loop/LoopController.java @@ -40,16 +40,22 @@ import org.springframework.stereotype.Controller; public class LoopController { private final LoopService loopService; - private static final Type OPERATIONAL_POLICY_TYPE = new TypeToken<List<OperationalPolicy>>() {} - .getType(); - private static final Type MICROSERVICE_POLICY_TYPE = new TypeToken<List<MicroServicePolicy>>() {} - .getType(); + private static final Type OPERATIONAL_POLICY_TYPE = new TypeToken<List<OperationalPolicy>>() { + } + .getType(); + private static final Type MICROSERVICE_POLICY_TYPE = new TypeToken<List<MicroServicePolicy>>() { + } + .getType(); @Autowired public LoopController(LoopService loopService) { this.loopService = loopService; } + public Loop createLoop(String loopName, String templateName) { + return loopService.createLoopFromTemplate(loopName, templateName); + } + public List<String> getLoopNames() { return loopService.getClosedLoopNames(); } diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java index 6ea412c00..34be2038e 100644 --- a/src/main/java/org/onap/clamp/loop/LoopService.java +++ b/src/main/java/org/onap/clamp/loop/LoopService.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Set; import javax.persistence.EntityNotFoundException; import org.apache.commons.lang3.RandomStringUtils; +import org.onap.clamp.loop.template.LoopTemplatesService; import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.loop.template.PolicyModelsService; import org.onap.clamp.policy.Policy; @@ -53,6 +54,9 @@ public class LoopService { @Autowired private PolicyModelsService policyModelsService; + @Autowired + private LoopTemplatesService loopTemplateService; + Loop saveOrUpdateLoop(Loop loop) { return loopsRepository.save(loop); } @@ -70,6 +74,17 @@ public class LoopService { } /** + * Creates a Loop Instance from Loop Template Name. + * + * @param loopName Name of the Loop to be created + * @param templateName Loop Template to used for Loop + * @return Loop Instance + */ + public Loop createLoopFromTemplate(String loopName, String templateName) { + return loopsRepository.save(new Loop(loopName,loopTemplateService.getLoopTemplate(templateName))); + } + + /** * This method is used to refresh the DCAE deployment status fields. * * @param loop The loop instance to be modified @@ -96,7 +111,7 @@ public class LoopService { loop.addOperationalPolicy( new OperationalPolicy(Policy.generatePolicyName("OPERATIONAL", loop.getModelService().getName(), loop.getModelService().getVersion(), RandomStringUtils.randomAlphanumeric(3), - RandomStringUtils.randomAlphanumeric(4)), loop, null, policyModel)); + RandomStringUtils.randomAlphanumeric(4)), loop, null, policyModel, null)); return loopsRepository.save(loop); } diff --git a/src/main/java/org/onap/clamp/loop/template/LoopTemplatesService.java b/src/main/java/org/onap/clamp/loop/template/LoopTemplatesService.java index 29382137e..09bc80f89 100644 --- a/src/main/java/org/onap/clamp/loop/template/LoopTemplatesService.java +++ b/src/main/java/org/onap/clamp/loop/template/LoopTemplatesService.java @@ -49,6 +49,17 @@ public class LoopTemplatesService { return loopTemplatesRepository.save(loopTemplate); } + + /** + * Get the SVG representation of the loopTemplate. + * + * @param templateName The loopTemplate name + * @return The SVG representation in xml + */ + public String getSvgRepresentation(String templateName) { + return loopTemplatesRepository.findById(templateName).orElse(new LoopTemplate()).getSvgRepresentation(); + } + public List<String> getLoopTemplateNames() { return loopTemplatesRepository.getAllLoopTemplateNames(); } diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java index 7334eceb8..66b05f65f 100644 --- a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java +++ b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java @@ -35,7 +35,6 @@ import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.ManyToMany; import javax.persistence.Table; - import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; @@ -72,7 +71,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable */ @Id @Expose - @Column(name = "version",nullable = false) + @Column(name = "version", nullable = false) private String version; @Column(columnDefinition = "MEDIUMTEXT", name = "policy_tosca") @@ -198,17 +197,17 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable /** * Constructor. * - * @param policyType The policyType (referenced in the blueprint + * @param policyType The policyType (referenced in the blueprint * @param policyModelTosca The policy tosca model in yaml - * @param version the version like 1.0.0 - * @param policyAcronym Subtype for policy if it exists (could be used by UI) + * @param version the version like 1.0.0 + * @param policyAcronym Subtype for policy if it exists (could be used by UI) */ public PolicyModel(String policyType, String policyModelTosca, String version, - String policyAcronym) { + String policyAcronym) { this.policyModelType = policyType; this.policyModelTosca = policyModelTosca; this.version = version; - this.policyAcronym=policyAcronym; + this.policyAcronym = policyAcronym; if (this.policyAcronym == null) { this.policyAcronym = createDefaultPolicyAcronym(policyType); } @@ -216,7 +215,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable /** * Constructor with acronym generated by default from policyType. - * + * * @param policyType The policyType (referenced in the blueprint * @param policyModelTosca The policy tosca model in yaml * @param version the version like 1.0.0 diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java b/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java index b38be942e..7e21cc390 100644 --- a/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java +++ b/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java @@ -52,8 +52,7 @@ public class PolicyModelsService { /** * Save or Update Policy Model. * - * @param policyModel - * The policyModel + * @param policyModel The policyModel * @return The Policy Model */ public PolicyModel saveOrUpdatePolicyModel(PolicyModel policyModel) { @@ -63,8 +62,7 @@ public class PolicyModelsService { /** * Verify whether Policy Model exist by ID. * - * @param policyModelId - * The policyModel Id + * @param policyModelId The policyModel Id * @return The flag indicates whether Policy Model exist */ public boolean existsById(PolicyModelId policyModelId) { @@ -157,14 +155,14 @@ public class PolicyModelsService { } } - /** + /** * Update the Pdp Group info in Policy Model DB. * * @param pdpGroupList The list of Pdp Group info received from Policy Engine */ public void updatePdpGroupInfo(List<PdpGroup> pdpGroupList) { List<PolicyModel> policyModelList = policyModelsRepository.findAll(); - for (PolicyModel policyModel : policyModelList) { + for (PolicyModel policyModel : policyModelList) { JsonArray supportedPdpGroups = new JsonArray(); for (PdpGroup pdpGroup : pdpGroupList) { JsonObject supportedPdpGroup = pdpGroup.getSupportedSubgroups(policyModel.getPolicyModelType(), @@ -175,7 +173,7 @@ public class PolicyModelsService { } if (supportedPdpGroups.size() > 0) { - JsonObject supportedPdpJson = new JsonObject (); + JsonObject supportedPdpJson = new JsonObject(); supportedPdpJson.add("supportedPdpGroups", supportedPdpGroups); policyModel.setPolicyPdpGroup(supportedPdpJson); policyModelsRepository.save(policyModel); diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java index 8d9017eae..75efca769 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java @@ -51,6 +51,7 @@ import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.clamp.loop.Loop; +import org.onap.clamp.loop.template.LoopElementModel; import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.policy.Policy; import org.yaml.snakeyaml.Yaml; @@ -110,23 +111,17 @@ public class MicroServicePolicy extends Policy implements Serializable { } /** - * The constructor that create the json representation from the policyTosca + * The constructor that creates the json representation from the policyTosca * using the ToscaYamlToJsonConvertor. * * @param name The name of the MicroService * @param policyModel The policy model of the MicroService * @param shared The flag indicate whether the MicroService is shared - * @param usedByLoops The list of loops that uses this MicroService */ - public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, - Set<Loop> usedByLoops) { - this.name = name; - this.policyModel = policyModel; - this.shared = shared; - this.setJsonRepresentation(JsonUtils.GSON_JPA_MODEL + public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, LoopElementModel loopElementModel) { + this(name,policyModel,shared,JsonUtils.GSON_JPA_MODEL .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyModel.getPolicyModelTosca(), - policyModel.getPolicyModelType()), JsonObject.class)); - this.usedByLoops = usedByLoops; + policyModel.getPolicyModelType()), JsonObject.class),loopElementModel); } private JsonObject createJsonFromPolicyTosca() { @@ -138,21 +133,20 @@ public class MicroServicePolicy extends Policy implements Serializable { /** * The constructor that does not make use of ToscaYamlToJsonConvertor but take * the jsonRepresentation instead. - * * @param name The name of the MicroService * @param policyModel The policy model type of the MicroService * @param shared The flag indicate whether the MicroService is - * shared + * shared * @param jsonRepresentation The UI representation in json format - * @param usedByLoops The list of loops that uses this MicroService + * @param loopElementModel The loop element model from which this instance should be created */ public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, - JsonObject jsonRepresentation, Set<Loop> usedByLoops) { + JsonObject jsonRepresentation, LoopElementModel loopElementModel) { this.name = name; this.policyModel = policyModel; this.shared = shared; - this.usedByLoops = usedByLoops; this.setJsonRepresentation(jsonRepresentation); + this.setLoopElementModel(loopElementModel); } @Override diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java index b17bf1ac4..2af8ec720 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java @@ -23,12 +23,9 @@ package org.onap.clamp.policy.microservice; -import com.google.common.collect.Sets; - import java.util.List; import java.util.Set; import java.util.stream.Collectors; - import org.onap.clamp.loop.Loop; import org.onap.clamp.policy.PolicyService; import org.springframework.beans.factory.annotation.Autowired; @@ -66,7 +63,7 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli return repository.save( repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop)) .orElse(new MicroServicePolicy(policy.getName(), policy.getPolicyModel(), - policy.getShared(), policy.getJsonRepresentation(), Sets.newHashSet(loop)))); + policy.getShared(), policy.getJsonRepresentation(),null))); } private MicroServicePolicy updateMicroservicePolicyProperties(MicroServicePolicy oldPolicy, @@ -84,7 +81,6 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli * @param microServicePolicy The micro service policy * @param deploymentId The deployment ID as returned by DCAE * @param deploymentUrl The Deployment URL as returned by DCAE - * @throws MicroServicePolicy doesn't exist in DB */ public void updateDcaeDeploymentFields(MicroServicePolicy microServicePolicy, String deploymentId, String deploymentUrl) { diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java index 0825ea9e5..52b877208 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java @@ -55,6 +55,7 @@ import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.clamp.loop.Loop; +import org.onap.clamp.loop.template.LoopElementModel; import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.policy.Policy; import org.yaml.snakeyaml.DumperOptions; @@ -93,18 +94,20 @@ public class OperationalPolicy extends Policy implements Serializable { /** * The constructor. - * - * @param name The name of the operational policy + * @param name The name of the operational policy * @param loop The loop that uses this operational policy * @param configurationsJson The operational policy property in the format of - * json + * json * @param policyModel The policy model associated if any, can be null + * @param loopElementModel The loop element from which this instance is supposed to be created */ - public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson, PolicyModel policyModel) { + public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson, PolicyModel policyModel, + LoopElementModel loopElementModel) { this.name = name; this.loop = loop; this.setPolicyModel(policyModel); this.setConfigurationsJson(configurationsJson); + this.setLoopElementModel(loopElementModel); LegacyOperationalPolicy.preloadConfiguration(configurationsJson, loop); try { this.setJsonRepresentation( diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java index 174912b22..cc636babb 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java @@ -52,7 +52,7 @@ public class OperationalPolicyService implements PolicyService<OperationalPolicy .map(p -> setConfigurationJson(p, policy.getConfigurationsJson())) .orElse(new OperationalPolicy(policy.getName(), loop, policy.getConfigurationsJson(), - policy.getPolicyModel()))) + policy.getPolicyModel(), null))) .collect(Collectors.toSet()); } |