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 {
.fromJson(microServicePoliciesJson, MICROSERVICE_POLICY_TYPE);
return loopService.updateMicroservicePolicies(loopName, microservicePolicies);
}
+
+ public String getSVGRepresentation(String loopName) {
+ return loopService.getClosedLoopModelSVG(loopName);
+
+ }
}
this.operationalPolicyService = operationalPolicyService;
}
- Loop addNewLoop(Loop loop) {
+ Loop saveOrUpdateLoop(Loop loop) {
return loopsRepository.save(loop);
}
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")
@Column(name = "shared", nullable = false)
private Boolean shared;
- @Expose
@Column(name = "policy_tosca", nullable = false)
private String policyTosca;
private Set<Loop> usedByLoops = new HashSet<>();
public MicroServicePolicy() {
- //serialization
+ // serialization
}
public MicroServicePolicy(String name, String policyTosca, Boolean shared, JsonObject jsonRepresentation,
this.usedByLoops = usedByLoops;
}
+ @Override
public String getName() {
return name;
}
this.policyTosca = policyTosca;
}
+ @Override
public JsonObject getJsonRepresentation() {
return jsonRepresentation;
}
<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"
testLoop.setLastComputedState(LoopState.DESIGN);
//when
- Loop actualLoop = loopService.addNewLoop(testLoop);
+ Loop actualLoop = loopService.saveOrUpdateLoop(testLoop);
//then
assertThat(actualLoop).isNotNull();
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