From: Xue Gao Date: Tue, 10 Mar 2020 10:18:34 +0000 (+0000) Subject: Merge "Rework tosca converter" X-Git-Tag: 5.0.0~25 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=0c4e6af85daabe730917898f466a1d45cbc16f92;hp=-c;p=clamp.git Merge "Rework tosca converter" --- 0c4e6af85daabe730917898f466a1d45cbc16f92 diff --combined src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java index b0e8b0c3,97567426..9cf51633 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java @@@ -4,7 -4,6 +4,7 @@@ * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright (C) 2020 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. @@@ -45,14 -44,12 +45,12 @@@ import javax.persistence.Entity import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; - import javax.persistence.JoinColumns; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Transient; import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; - import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor; - import org.onap.clamp.clds.util.JsonUtils; + import org.onap.clamp.clds.tosca.update.UnknownComponentException; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.clamp.loop.Loop; import org.onap.clamp.loop.template.LoopElementModel; @@@ -120,17 -117,15 +118,15 @@@ public class OperationalPolicy extends if (isLegacy()) { // Op policy Legacy case LegacyOperationalPolicy.preloadConfiguration(jsonReturned, loop); - this.setJsonRepresentation( - OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(loop.getModelService())); + jsonReturned = + OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(loop.getModelService()); } else { // Generic Case - this.setJsonRepresentation(JsonUtils.GSON - .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyModel.getPolicyModelTosca(), - policyModel.getPolicyModelType()), JsonObject.class)); + jsonReturned = Policy.generateJsonRepresentationFromToscaModel(policyModel.getPolicyModelTosca(), + policyModel.getPolicyModelType()); } - } catch (JsonSyntaxException | IOException | NullPointerException e) { + } catch (UnknownComponentException | IOException | NullPointerException e) { logger.error("Unable to generate the operational policy Schema ... ", e); - this.setJsonRepresentation(new JsonObject()); } return jsonReturned; } @@@ -221,7 -216,7 +217,7 @@@ metadata.addProperty("policy-id", this.name); operationalPolicyDetails.add("properties", LegacyOperationalPolicy - .reworkPayloadAttributes(this.getConfigurationsJson().get("operational_policy").deepCopy())); + .reworkActorAttributes(this.getConfigurationsJson().get("operational_policy").deepCopy())); DumperOptions options = new DumperOptions(); options.setIndent(2);