New endpoint 16/79916/1
authorsebdet <sebastien.determe@intl.att.com>
Thu, 7 Mar 2019 15:38:22 +0000 (16:38 +0100)
committersebdet <sebastien.determe@intl.att.com>
Thu, 7 Mar 2019 15:38:22 +0000 (16:38 +0100)
New endpoint to get svgRepresentation + remove Yaml field json

Issue-ID: CLAMP-301
Change-Id: I49f62f25a719849cab78d1c94ae67078e28e6185
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
src/main/java/org/onap/clamp/loop/LoopController.java
src/main/java/org/onap/clamp/loop/LoopService.java
src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
src/main/resources/clds/camel/rest/clamp-api-v2.xml
src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java

index eeb6105..7e45174 100644 (file)
@@ -25,15 +25,16 @@ package org.onap.clamp.loop;
 
 import com.google.gson.JsonArray;
 import com.google.gson.reflect.TypeToken;
+
 import java.lang.reflect.Type;
 import java.util.List;
+
 import org.onap.clamp.clds.util.JsonUtils;
 import org.onap.clamp.policy.microservice.MicroServicePolicy;
 import org.onap.clamp.policy.operational.OperationalPolicy;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 
-
 @Controller
 public class LoopController {
 
@@ -67,4 +68,9 @@ public class LoopController {
             .fromJson(microServicePoliciesJson, MICROSERVICE_POLICY_TYPE);
         return loopService.updateMicroservicePolicies(loopName, microservicePolicies);
     }
+
+    public String getSVGRepresentation(String loopName) {
+        return loopService.getClosedLoopModelSVG(loopName);
+
+    }
 }
index 7b79c11..91b4bdf 100644 (file)
@@ -47,7 +47,7 @@ public class LoopService {
         this.operationalPolicyService = operationalPolicyService;
     }
 
-    Loop addNewLoop(Loop loop) {
+    Loop saveOrUpdateLoop(Loop loop) {
         return loopsRepository.save(loop);
     }
 
index e5b333d..7ebe0ed 100644 (file)
@@ -39,9 +39,9 @@ import javax.persistence.Table;
 import org.hibernate.annotations.Type;
 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.policy.Policy;
-import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
 
 @Entity
 @Table(name = "micro_service_policies")
@@ -66,7 +66,6 @@ public class MicroServicePolicy implements Serializable, Policy {
     @Column(name = "shared", nullable = false)
     private Boolean shared;
 
-    @Expose
     @Column(name = "policy_tosca", nullable = false)
     private String policyTosca;
 
@@ -79,7 +78,7 @@ public class MicroServicePolicy implements Serializable, Policy {
     private Set<Loop> usedByLoops = new HashSet<>();
 
     public MicroServicePolicy() {
-        //serialization
+        // serialization
     }
 
     public MicroServicePolicy(String name, String policyTosca, Boolean shared, JsonObject jsonRepresentation,
@@ -91,6 +90,7 @@ public class MicroServicePolicy implements Serializable, Policy {
         this.usedByLoops = usedByLoops;
     }
 
+    @Override
     public String getName() {
         return name;
     }
@@ -119,6 +119,7 @@ public class MicroServicePolicy implements Serializable, Policy {
         this.policyTosca = policyTosca;
     }
 
+    @Override
     public JsonObject getJsonRepresentation() {
         return jsonRepresentation;
     }
index 0a72a0c..4423752 100644 (file)
             <to
                 uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" />
         </get>
+        <get uri="/v2/loop/svgRepresentation/{loopName}"
+            outType="java.lang.String"
+
+            produces="application/xml">
+            <to
+                uri="bean:org.onap.clamp.loop.LoopController?method=getSVGRepresentation(${header.loopName})" />
+        </get>
+        <post uri="/v2/loop/globalProperties/{loopName}"
+            type="com.google.gson.JsonArray"
+            consumes="application/json"
+            outType="org.onap.clamp.loop.Loop"
+            produces="application/json">
+            <to
+                uri="bean:org.onap.clamp.loop.LoopController?method=updateOperationalPolicies(${header.loopName},${body})" />
+        </post>
         <post uri="/v2/loop/updateOperationalPolicies/{loopName}"
             type="com.google.gson.JsonArray"
             consumes="application/json"
index a9c3087..b7781bf 100644 (file)
@@ -70,7 +70,7 @@ public class LoopServiceTestItCase {
         testLoop.setLastComputedState(LoopState.DESIGN);
 
         //when
-        Loop actualLoop = loopService.addNewLoop(testLoop);
+        Loop actualLoop = loopService.saveOrUpdateLoop(testLoop);
 
         //then
         assertThat(actualLoop).isNotNull();
@@ -166,7 +166,7 @@ public class LoopServiceTestItCase {
     private void saveTestLoopToDb() {
         Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, "blueprint", "representation");
         testLoop.setGlobalPropertiesJson(JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
-        loopService.addNewLoop(testLoop);
+        loopService.saveOrUpdateLoop(testLoop);
     }
 
     @Test