Merge "Rework tosca converter"
authorXue Gao <xg353y@intl.att.com>
Tue, 10 Mar 2020 10:18:34 +0000 (10:18 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 10 Mar 2020 10:18:34 +0000 (10:18 +0000)
1  2 
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;
      }
          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);