summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-03-12 16:35:25 +0100
committersebdet <sebastien.determe@intl.att.com>2019-03-12 16:47:15 +0100
commitd022281adea3da26beee6457767577a313c5b617 (patch)
treede331bfb2556235a018c28dbb778814b62ce8d69 /src/main
parent92cc4185fca63ddd882be5bcd9d4a626b627164f (diff)
Add svg support
Add SVG support to the CSAR installer so that UI could render the loop Issue-ID: CLAMP-306 Change-Id: Ief963c4ad8e4c142f20c16b2049cad3a8aeedfb0 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java18
-rw-r--r--src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java42
-rw-r--r--src/main/java/org/onap/clamp/loop/Loop.java2
3 files changed, 44 insertions, 18 deletions
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java
index b05b80f00..27c5b9cbd 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java
@@ -26,21 +26,23 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
+
import org.springframework.stereotype.Component;
@Component
public class ChainGenerator {
- ChainGenerator() {}
+ ChainGenerator() {
+ }
- List<MicroService> getChainOfMicroServices(Set<MicroService> input) {
+ public List<MicroService> getChainOfMicroServices(Set<MicroService> input) {
LinkedList<MicroService> returnList = new LinkedList<>();
- if(preValidate(input)) {
+ if (preValidate(input)) {
LinkedList<MicroService> theList = new LinkedList<>();
for (MicroService ms : input) {
insertNodeTemplateIntoChain(ms, theList);
}
- if(postValidate(theList)) {
+ if (postValidate(theList)) {
returnList = theList;
}
}
@@ -48,16 +50,16 @@ public class ChainGenerator {
}
private boolean preValidate(Set<MicroService> input) {
- List<MicroService> noInputs =
- input.stream().filter(ms -> "".equals(ms.getInputFrom())).collect(Collectors.toList());
+ List<MicroService> noInputs = input.stream().filter(ms -> "".equals(ms.getInputFrom()))
+ .collect(Collectors.toList());
return noInputs.size() == 1;
}
private boolean postValidate(LinkedList<MicroService> microServices) {
for (int i = 1; i < microServices.size() - 1; i++) {
- MicroService prev = microServices.get(i-1);
+ MicroService prev = microServices.get(i - 1);
MicroService current = microServices.get(i);
- if(!current.getInputFrom().equals(prev.getName())) {
+ if (!current.getInputFrom().equals(prev.getName())) {
return false;
}
}
diff --git a/src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java
index 6e12f2940..07f1b777f 100644
--- a/src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java
+++ b/src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java
@@ -31,6 +31,7 @@ import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -46,6 +47,7 @@ import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller;
import org.onap.clamp.clds.sdc.controller.installer.MicroService;
import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.util.drawing.SvgFacade;
import org.onap.clamp.policy.Policy;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
@@ -82,6 +84,9 @@ public class CsarInstallerImpl implements CsarInstaller {
@Autowired
DcaeInventoryServices dcaeInventoryService;
+ @Autowired
+ private SvgFacade svgFacade;
+
@Override
public boolean isCsarAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException {
boolean alreadyInstalled = true;
@@ -113,6 +118,16 @@ public class CsarInstallerImpl implements CsarInstaller {
}
}
+ private String getSvgInLoop(BlueprintArtifact blueprintArtifact) {
+ List<MicroService> microServicesChain = chainGenerator
+ .getChainOfMicroServices(blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint()));
+ if (microServicesChain.isEmpty()) {
+ microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint());
+ }
+ return svgFacade.getSvgImage(microServicesChain);
+
+ }
+
private Loop createLoopFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact)
throws IOException, ParseException, InterruptedException {
Loop newLoop = new Loop();
@@ -124,10 +139,10 @@ public class CsarInstallerImpl implements CsarInstaller {
newLoop.setLastComputedState(LoopState.DESIGN);
newLoop.setMicroServicePolicies(createMicroServicePolicies(csar, blueprintArtifact, newLoop));
newLoop.setOperationalPolicies(createOperationalPolicies(csar, blueprintArtifact, newLoop));
- // Set SVG XML computed
- // newLoop.setSvgRepresentation(svgRepresentation);
- newLoop.setGlobalPropertiesJson(createGlobalPropertiesJson(csar, blueprintArtifact));
- newLoop.setModelPropertiesJson(createModelPropertiesJson(csar, blueprintArtifact));
+
+ newLoop.setSvgRepresentation(getSvgInLoop(blueprintArtifact));
+ newLoop.setGlobalPropertiesJson(createGlobalPropertiesJson(blueprintArtifact));
+ newLoop.setModelPropertiesJson(createModelPropertiesJson(csar));
DcaeInventoryResponse dcaeResponse = queryDcaeToGetServiceTypeId(blueprintArtifact);
newLoop.setDcaeBlueprintId(dcaeResponse.getTypeId());
return newLoop;
@@ -144,21 +159,30 @@ public class CsarInstallerImpl implements CsarInstaller {
private HashSet<MicroServicePolicy> createMicroServicePolicies(CsarHandler csar,
BlueprintArtifact blueprintArtifact, Loop newLoop) throws IOException {
HashSet<MicroServicePolicy> newSet = new HashSet<>();
- for (MicroService microService : blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint())) {
- newSet.add(new MicroServicePolicy(microService.getName(), csar.getPolicyModelYaml().orElse(""), false,
- new HashSet<>(Arrays.asList(newLoop))));
+ List<MicroService> microServicesChain = chainGenerator
+ .getChainOfMicroServices(blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint()));
+ if (microServicesChain.isEmpty()) {
+ microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint());
+ }
+ for (MicroService microService : microServicesChain) {
+ newSet.add(new MicroServicePolicy(
+ Policy.generatePolicyName(microService.getName(), csar.getSdcNotification().getServiceName(),
+ csar.getSdcNotification().getServiceVersion(),
+ blueprintArtifact.getResourceAttached().getResourceInstanceName(),
+ blueprintArtifact.getBlueprintArtifactName()),
+ csar.getPolicyModelYaml().orElse(""), false, new HashSet<>(Arrays.asList(newLoop))));
}
return newSet;
}
- private JsonObject createGlobalPropertiesJson(CsarHandler csar, BlueprintArtifact blueprintArtifact) {
+ private JsonObject createGlobalPropertiesJson(BlueprintArtifact blueprintArtifact) {
JsonObject globalProperties = new JsonObject();
globalProperties.add("dcaeDeployParameters", getAllBlueprintParametersInJson(blueprintArtifact));
return globalProperties;
}
- private JsonObject createModelPropertiesJson(CsarHandler csar, BlueprintArtifact blueprintArtifact) {
+ private JsonObject createModelPropertiesJson(CsarHandler csar) {
JsonObject modelProperties = new JsonObject();
Gson gson = new Gson();
modelProperties.add("serviceDetails",
diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java
index a4cd86d07..473364ae4 100644
--- a/src/main/java/org/onap/clamp/loop/Loop.java
+++ b/src/main/java/org/onap/clamp/loop/Loop.java
@@ -78,7 +78,7 @@ public class Loop implements Serializable {
@Column(name = "dcae_blueprint_id")
private String dcaeBlueprintId;
- @Column(name = "svg_representation")
+ @Column(columnDefinition = "MEDIUMTEXT", name = "svg_representation")
private String svgRepresentation;
@Expose