summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorSébastien Determe <sebastien.determe@intl.att.com>2019-03-15 07:28:02 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-15 07:28:02 +0000
commit00c267ab4f48207a0f129235e67a4f2e1d154408 (patch)
tree1943b8873962feae2c4f65e87e71ad3cc9e2bd25 /src/main/java/org
parentf02fc13f2a5b1680fc39740e5e0a429641a5698a (diff)
parentec7f47aacc6c124d8d2e01416e80e2278b427be8 (diff)
Merge "Rework UI"
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopController.java4
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java7
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java23
3 files changed, 20 insertions, 14 deletions
diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java
index 2bcce1e37..8b64e9d70 100644
--- a/src/main/java/org/onap/clamp/loop/LoopController.java
+++ b/src/main/java/org/onap/clamp/loop/LoopController.java
@@ -75,6 +75,10 @@ public class LoopController {
return loopService.updateAndSaveGlobalPropertiesJson(loopName, globalProperties);
}
+ public MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
+ return loopService.updateMicroservicePolicy(loopName, newMicroservicePolicy);
+ }
+
public String getSVGRepresentation(String loopName) {
return loopService.getClosedLoopModelSVG(loopName);
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index cf2f4c669..051ab6ed6 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -86,6 +86,13 @@ public class LoopService {
return loopsRepository.save(loop);
}
+ MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
+ Loop loop = findClosedLoopByName(loopName);
+ MicroServicePolicy newPolicies = microservicePolicyService
+ .getAndUpdateMicroServicePolicy(loop, newMicroservicePolicy);
+ return newPolicies;
+ }
+
private Loop updateOperationalPolicies(Loop loop, List<OperationalPolicy> newOperationalPolicies) {
Set<OperationalPolicy> newPolicies = operationalPolicyService
.updatePolicies(loop, newOperationalPolicies);
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 91794b754..c316f1f5d 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
@@ -24,11 +24,13 @@
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.policy.PolicyService;
+
import org.onap.clamp.loop.Loop;
+import org.onap.clamp.policy.PolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -45,12 +47,8 @@ public class MicroservicePolicyService implements PolicyService<MicroServicePoli
@Override
@Transactional
- public Set<MicroServicePolicy> updatePolicies(Loop loop,
- List<MicroServicePolicy> newMicroservicePolicies) {
- return newMicroservicePolicies
- .stream()
- .map(policy ->
- getAndUpdateMicroServicePolicy(loop, policy))
+ public Set<MicroServicePolicy> updatePolicies(Loop loop, List<MicroServicePolicy> newMicroservicePolicies) {
+ return newMicroservicePolicies.stream().map(policy -> getAndUpdateMicroServicePolicy(loop, policy))
.collect(Collectors.toSet());
}
@@ -59,13 +57,10 @@ public class MicroservicePolicyService implements PolicyService<MicroServicePoli
return repository.existsById(policyName);
}
- private MicroServicePolicy getAndUpdateMicroServicePolicy(Loop loop, MicroServicePolicy policy) {
- return repository
- .findById(policy.getName())
- .map(p -> updateMicroservicePolicyProperties(p, policy, loop))
- .orElse(new MicroServicePolicy(policy.getName(), policy.getPolicyTosca(),
- policy.getShared(), policy.getJsonRepresentation(),
- Sets.newHashSet(loop)));
+ public MicroServicePolicy getAndUpdateMicroServicePolicy(Loop loop, MicroServicePolicy policy) {
+ return repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop))
+ .orElse(new MicroServicePolicy(policy.getName(), policy.getPolicyTosca(), policy.getShared(),
+ policy.getJsonRepresentation(), Sets.newHashSet(loop)));
}
private MicroServicePolicy updateMicroservicePolicyProperties(MicroServicePolicy oldPolicy,