summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bpgenerator/src/main/java/org/onap/blueprintgenerator')
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java39
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java148
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java15
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java122
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java40
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java46
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java4
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java132
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java121
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java13
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java16
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java15
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java5
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java211
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java11
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java9
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java5
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java10
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java6
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java10
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java181
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java248
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java151
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java102
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java118
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java229
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java226
41 files changed, 1247 insertions, 1093 deletions
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java
index 16eca51..c3b1453 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java
@@ -27,6 +27,10 @@ import java.util.LinkedHashMap;
@UtilityClass
public class BlueprintHelper {
+ public static final String INTEGER_TYPE = "integer";
+ public static final String BOOLEAN_TYPE = "boolean";
+ public static final String STRING_TYPE = "string";
+
public static LinkedHashMap<String, Object> createInputValue(String type, String description, Object defaultValue) {
LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
inputMap.put("type", type);
@@ -34,4 +38,39 @@ public class BlueprintHelper {
inputMap.put("default", defaultValue);
return inputMap;
}
+
+ public static LinkedHashMap<String, Object> createInputValue(String type, Object defaultValue) {
+ LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
+ inputMap.put("type", type);
+ inputMap.put("default", defaultValue);
+ return inputMap;
+ }
+
+ public static LinkedHashMap<String, Object> createIntegerInput(String description, Object defaultValue){
+ return createInputValue(INTEGER_TYPE, description, defaultValue);
+ }
+
+ public static LinkedHashMap<String, Object> createBooleanInput(String description, Object defaultValue){
+ return createInputValue(BOOLEAN_TYPE, description, defaultValue);
+ }
+
+ public static LinkedHashMap<String, Object> createStringInput(String description, Object defaultValue){
+ return createInputValue(STRING_TYPE, description, defaultValue);
+ }
+
+ public static LinkedHashMap<String, Object> createStringInput(Object defaultValue){
+ return createInputValue(STRING_TYPE, defaultValue);
+ }
+
+ public static String joinUnderscore(String firstValue, String secondValue){
+ return firstValue + "_" + secondValue;
+ }
+
+ public static boolean isDataRouterType(String type) {
+ return type.equals("data_router") || type.equals("data router");
+ }
+
+ public static boolean isMessageRouterType(String type) {
+ return type.equals("message_router") || type.equals("message router");
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
index 5d4131b..f9fa2cb 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java
@@ -18,18 +18,32 @@
*/
-
package org.onap.blueprintgenerator.core;
-
-
-
+import java.util.ArrayList;
+import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;
+import org.onap.blueprintgenerator.models.componentspec.Artifacts;
+import org.onap.blueprintgenerator.models.componentspec.Auxilary;
+import org.onap.blueprintgenerator.models.componentspec.CallsObj;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+import org.onap.blueprintgenerator.models.componentspec.Container;
+import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
+import org.onap.blueprintgenerator.models.componentspec.Host;
+import org.onap.blueprintgenerator.models.componentspec.Parameters;
+import org.onap.blueprintgenerator.models.componentspec.Policy;
+import org.onap.blueprintgenerator.models.componentspec.ProvidesObj;
+import org.onap.blueprintgenerator.models.componentspec.Publishes;
+import org.onap.blueprintgenerator.models.componentspec.Self;
+import org.onap.blueprintgenerator.models.componentspec.Services;
+import org.onap.blueprintgenerator.models.componentspec.Streams;
+import org.onap.blueprintgenerator.models.componentspec.Subscribes;
+import org.onap.blueprintgenerator.models.componentspec.Volumes;
@Getter @Setter
public class TestComponentSpec {
- private String cs = "{\r\n" +
+ private String componentSpecAsString = "{\r\n" +
" \"self\": {\r\n" +
" \"component_type\": \"docker\",\r\n" +
" \"description\": \"Test component spec\",\r\n" +
@@ -129,4 +143,128 @@ public class TestComponentSpec {
" }] \r\n" +
"\r\n" +
"}";
+ private ComponentSpec componentSpec;
+
+ public TestComponentSpec() {
+ this.componentSpec = createComponentSpec();
+ }
+
+ private ComponentSpec createComponentSpec(){
+ //Manually fill a component spec object with the values from the file itself
+ ComponentSpec manualSpec = new ComponentSpec();
+
+ Self self = new Self();
+ self.setComponent_type("docker");
+ self.setDescription("Test component spec");
+ self.setName("test.component.spec");
+ self.setVersion("1.0.1");
+ manualSpec.setSelf(self);
+
+ Services services = new Services();
+ CallsObj[] calls = new CallsObj[0];
+ ProvidesObj[] provides = new ProvidesObj[0];
+ services.setCalls(calls);
+ services.setProvides(provides);
+ manualSpec.setServices(null);
+
+ Streams streams = new Streams();
+ Publishes[] publishes = new Publishes[2];
+ Publishes pub1 = new Publishes();
+ pub1.setConfig_key("TEST-PUB-DR");
+ pub1.setFormat("dataformat_Hello_World_PM");
+ pub1.setType("data_router");
+ pub1.setVersion("1.0.0");
+
+ Publishes pub2 = new Publishes();
+ pub2.setConfig_key("TEST-PUB-MR");
+ pub2.setFormat("dataformat_Hello_World_PM");
+ pub2.setType("message_router");
+ pub2.setVersion("1.0.0");
+ publishes[0] = pub1;
+ publishes[1] = pub2;
+ streams.setPublishes(publishes);
+
+ Subscribes[] subscribes = new Subscribes[2];
+ Subscribes sub1 = new Subscribes();
+ sub1.setConfig_key("TEST-SUB-MR");
+ sub1.setFormat("dataformat_Hello_World_PM");
+ sub1.setRoute("/TEST_HELLO_WORLD_SUB_MR");
+ sub1.setType("message_router");
+ sub1.setVersion("1.0.0");
+
+ Subscribes sub2 = new Subscribes();
+ sub2.setConfig_key("TEST-SUB-DR");
+ sub2.setFormat("dataformat_Hello_World_PM");
+ sub2.setRoute("/TEST-HELLO-WORLD-SUB-DR");
+ sub2.setType("data_router");
+ sub2.setVersion("1.0.0");
+ subscribes[0] = sub1;
+ subscribes[1] = sub2;
+ streams.setSubscribes(subscribes);
+
+ manualSpec.setStreams(streams);
+
+ Parameters[] parameters = new Parameters[1];
+ Parameters par1 = new Parameters();
+ par1.setName("testParam1");
+ par1.setValue("test-param-1");
+ par1.setDescription("test parameter 1");
+ par1.setSourced_at_deployment(true);
+ par1.setDesigner_editable(true);
+ par1.setPolicy_editable(true);
+ par1.setPolicy_group("Test_Parameters");
+ par1.setRequired(true);
+ par1.setType("string");
+ parameters[0] = par1;
+
+ manualSpec.setParameters(parameters);
+
+ Auxilary auxilary = new Auxilary();
+ HealthCheck healthcheck = new HealthCheck();
+ healthcheck.setInterval("300s");
+ healthcheck.setTimeout("120s");
+ healthcheck.setScript("/etc/init.d/nagios status");
+ healthcheck.setType("docker");
+ auxilary.setHealthcheck(healthcheck);
+
+ Volumes[] volumes = new Volumes[1];
+ Volumes vol1 = new Volumes();
+ Container con1 = new Container();
+ con1.setBind("/opt/app/manager/config/hostname");
+ Host host1 = new Host();
+ host1.setPath("/etc/hostname");
+ host1.setMode("ro");
+ vol1.setContainer(con1);
+ vol1.setHost(host1);
+
+ volumes[0] = vol1;
+
+ auxilary.setVolumes(volumes);
+
+ ArrayList<Object> ports = new ArrayList();
+ ports.add("80:80");
+
+ TreeMap<String, String> dataBases = new TreeMap<>();
+ dataBases.put("TestDB1", "PGaaS");
+ dataBases.put("TestDB2", "PGaaS");
+ auxilary.setDatabases(dataBases);
+
+ Policy pol = new Policy();
+ pol.setTrigger_type("docker");
+ pol.setScript_path("/opt/app/manager/bin/reconfigure.sh");
+ auxilary.setPolicy(pol);
+
+ auxilary.setPorts(ports);
+
+ manualSpec.setAuxilary(auxilary);
+
+ Artifacts[] artifacts = new Artifacts[1];
+ Artifacts art = new Artifacts();
+ art.setType("docker image");
+ art.setUri("test.tester");
+
+ artifacts[0] = art;
+ manualSpec.setArtifacts(artifacts);
+ return manualSpec;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
index b39a8ec..75864be 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
@@ -52,8 +52,7 @@ public class Appconfig {
public TreeMap<String, LinkedHashMap<String, Object>> createAppconfig(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override,
boolean isDmaap) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
//set service calls
CallsObj[] call = new CallsObj[0];
@@ -83,7 +82,7 @@ public class Appconfig {
}
//set the stream publishes
- TreeMap<String, DmaapObj> streamSubscribes = new TreeMap<String, DmaapObj>();
+ TreeMap<String, DmaapObj> streamSubscribes = new TreeMap<>();
if(cs.getStreams().getSubscribes().length != 0) {
for(Subscribes s: cs.getStreams().getSubscribes()) {
@@ -110,7 +109,7 @@ public class Appconfig {
this.setStreams_subscribes(streamSubscribes);
//set the parameters into the appconfig
- TreeMap<String, Object> parameters = new TreeMap<String, Object>();
+ TreeMap<String, Object> parameters = new TreeMap<>();
for(Parameters p: cs.getParameters()) {
String pName = p.getName();
if(p.isSourced_at_deployment()) {
@@ -119,17 +118,17 @@ public class Appconfig {
parameters.put(pName, paramInput);
if(!p.getValue().equals("")) {
- LinkedHashMap<String, Object> inputs = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> inputs = new LinkedHashMap<>();
inputs.put("type", "string");
inputs.put("default", p.getValue());
retInputs.put(pName, inputs);
} else {
- LinkedHashMap<String, Object> inputs = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> inputs = new LinkedHashMap<>();
inputs.put("type", "string");
retInputs.put(pName, inputs);
}
} else {
- if(p.getType() == "string") {
+ if("string".equals(p.getType())) {
String val =(String) p.getValue();
val = '"' + val + '"';
parameters.put(pName, val);
@@ -143,7 +142,7 @@ public class Appconfig {
GetInput ov = new GetInput();
ov.setBpInputName("service_component_name_override");
parameters.put("service_component_name_override", ov);
- LinkedHashMap<String, Object> over = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> over = new LinkedHashMap<>();
over.put("type", "string");
over.put("default", override);
retInputs.put("service_component_name_override", over);
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
index c043a9e..f2ef7aa 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
@@ -20,35 +20,27 @@
package org.onap.blueprintgenerator.models.blueprint;
-import java.io.*;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.TreeMap;
import java.util.regex.Pattern;
-
+import lombok.Getter;
+import lombok.Setter;
import org.onap.blueprintgenerator.core.Fixes;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.Parameters;
-import org.onap.blueprintgenerator.models.componentspec.Publishes;
-import org.onap.blueprintgenerator.models.componentspec.Subscribes;
import org.onap.blueprintgenerator.models.dmaapbp.DmaapBlueprint;
import org.onap.blueprintgenerator.models.onapbp.OnapBlueprint;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonProcessingException;
-//import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import org.yaml.snakeyaml.Yaml;
-
-
@Getter @Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -100,93 +92,43 @@ public class Blueprint {
public void blueprintToYaml(String outputPath, String bluePrintName, ComponentSpec cs) {
File outputFile;
-
- if(bluePrintName.equals("")) {
- String name = cs.getSelf().getName();
- if(name.contains(".")) {
- name = name.replaceAll(Pattern.quote("."), "_");
- }
- if(name.contains(" ")) {
- name = name.replaceAll(" ", "");
- }
- String file = name + ".yaml";
-
-
- outputFile = new File(outputPath, file);
- outputFile.getParentFile().mkdirs();
- try {
- outputFile.createNewFile();
- } catch (IOException e) {
-
- throw new RuntimeException(e);
- }
- } else {
- if(bluePrintName.contains(" ") || bluePrintName.contains(".")) {
- bluePrintName = bluePrintName.replaceAll(Pattern.quote("."), "_");
- bluePrintName = bluePrintName.replaceAll(" ", "");
- }
- String file = bluePrintName + ".yaml";
- outputFile = new File(outputPath, file);
- outputFile.getParentFile().mkdirs();
- try {
- outputFile.createNewFile();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ String name = bluePrintName.equals("") ? cs.getSelf().getName() : bluePrintName;
+ if(name.contains(".")) {
+ name = name.replaceAll(Pattern.quote("."), "_");
+ }
+ if(name.contains(" ")) {
+ name = name.replaceAll(" ", "");
+ }
+ String file = name + ".yaml";
+ outputFile = new File(outputPath, file);
+ outputFile.getParentFile().mkdirs();
+ try {
+ outputFile.createNewFile();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
String version = "#blueprint_version: " + cs.getSelf().getVersion() + '\n';
String description = "#description: " + cs.getSelf().getDescription() + '\n';
- BufferedWriter writer = null;
- try {
- writer = new BufferedWriter(new FileWriter(outputFile, false));
+ try(BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile, false))) {
+ writer.write(description);
+ writer.write(version);
} catch (IOException e1) {
throw new RuntimeException(e1);
}
- if(writer != null) {
- try {
- writer.write(description);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- try {
- writer.write(version);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- try {
- writer.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
//read the translated blueprint into the file
ObjectMapper blueprintMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
- PrintWriter out = null;
- try {
- out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)));
+ try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)))) {
+ blueprintMapper.writeValue(out, this);
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
- if(out != null) {
- blueprintMapper.writeValue(out, this);
- out.close();
- }
- } catch (IOException e) {
-
- throw new RuntimeException(e);
- }
-
-
- Fixes fix = new Fixes();
- try {
- fix.fixSingleQuotes(outputFile);
+ Fixes.fixSingleQuotes(outputFile);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java
new file mode 100644
index 0000000..ac14b47
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java
@@ -0,0 +1,40 @@
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ */
+
+package org.onap.blueprintgenerator.models.blueprint;
+
+public final class BpConstants {
+
+ private BpConstants() {}
+
+ public static final String CLOUDIFY_DSL_1_3 = "cloudify_dsl_1_3";
+
+ public static final String CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP = "dcae.nodes.ContainerizedServiceComponentUsingDmaap";
+ public static final String CONTENERIZED_SERVICE_COMPONENT = "dcae.nodes.ContainerizedServiceComponent";
+ public static final String FEED = "dcaegen2.nodes.Feed";
+ public static final String TOPIC = "dcaegen2.nodes.Topic";
+ public static final String PUBLISH_EVENTS = "dcaegen2.relationships.publish_events";
+ public static final String PUBLISH_FILES = "dcaegen2.relationships.publish_files";
+ public static final String SUBSCRIBE_TO_EVENTS = "dcaegen2.relationships.subscribe_to_events";
+ public static final String SUBSCRIBE_TO_FILES = "dcaegen2.relationships.subscribe_to_files";
+
+ public static final String TOSCA_DATATYPES_ROOT = "tosca.datatypes.Root";
+ public static final String TOSCA_NODES_ROOT = "tosca.nodes.Root";
+ public static final String TOSCA_SIMPLE_YAML = "tosca_simple_yaml_1_0_0";
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
index b17b045..7b55e17 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
@@ -20,24 +20,16 @@
package org.onap.blueprintgenerator.models.blueprint;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
-
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-import lombok.AllArgsConstructor;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
-
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import lombok.Getter;
+import lombok.Setter;
@Getter @Setter
@JsonInclude(value=Include.NON_NULL)
@@ -46,32 +38,30 @@ public class Imports {
private ArrayList<String> imports;
public static ArrayList<String> createOnapImports() {
- ArrayList<String> imps = new ArrayList<String>();
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml");
+ ArrayList<String> imps = new ArrayList<>();
+ imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
+ imps.add("plugin:k8splugin?version=3.4.2");
+ imps.add("plugin:dcaepolicyplugin?version=2.4.0");
return imps;
}
+
public static ArrayList<String> createDmaapImports(){
- ArrayList<String> imps = new ArrayList<String>();
- imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R5/k8splugin/1.6.0/k8splugin_types.yaml");
- imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml");
+ ArrayList<String> imps = new ArrayList<>();
+ imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml");
+ imps.add("plugin:k8splugin?version=3.4.2");
+ imps.add("plugin:dmaap?version=1.5.0");
return imps;
}
+
public static ArrayList<String> createImportsFromFile(String path) {
- Imports imports = new Imports();
ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
File importPath = new File(path);
try {
- imports = importMapper.readValue(importPath, Imports.class);
+ Imports imports = importMapper.readValue(importPath, Imports.class);
+ imports.getImports().removeIf(String::isBlank);
+ return imports.getImports();
} catch (IOException e) {
throw new RuntimeException(e);
}
- ArrayList<String> imps = new ArrayList<String>();
- for(String s: imports.getImports()) {
- imps.add(s);
- }
- return imps;
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
index a3404f6..435059e 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
@@ -31,11 +31,9 @@ import lombok.Getter; import lombok.Setter;
public class Interfaces {
private Start start;
public TreeMap<String, LinkedHashMap<String, Object>> createInterface(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
//create the start object
Start start = new Start();
- retInputs = start.createOnapStart(retInputs, cs);
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = start.createOnapStart(inps, cs);
this.setStart(start);
return retInputs;
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
index d32d6f4..9aa5354 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
@@ -20,6 +20,11 @@
package org.onap.blueprintgenerator.models.blueprint;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createBooleanInput;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createIntegerInput;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -31,7 +36,6 @@ import java.util.Map;
import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;
-import org.onap.blueprintgenerator.common.blueprint.BlueprintHelper;
import org.onap.blueprintgenerator.models.blueprint.tls.ExternalCertificateParametersFactory;
import org.onap.blueprintgenerator.models.blueprint.tls.ExternalTlsInfoFactory;
import org.onap.blueprintgenerator.models.blueprint.tls.TlsInfo;
@@ -42,11 +46,16 @@ import org.onap.blueprintgenerator.models.componentspec.Publishes;
import org.onap.blueprintgenerator.models.componentspec.Subscribes;
import org.onap.blueprintgenerator.models.dmaapbp.DmaapStreams;
+
@Getter
@Setter
@JsonInclude(value = Include.NON_NULL)
public class Properties {
+ private static final String EMPTY_VALUE = "";
+
+ ArrayList<DmaapStreams> streams_publishes;
+ ArrayList<DmaapStreams> streams_subscribes;
private Appconfig application_config;
private Auxilary docker_config;
private Object image;
@@ -58,13 +67,11 @@ public class Properties {
private String name;
private GetInput topic_name;
private GetInput feed_name;
- ArrayList<DmaapStreams> streams_publishes;
- ArrayList<DmaapStreams> streams_subscribes;
private TlsInfo tls_info;
private ExternalTlsInfo external_cert;
private ResourceConfig resource_config;
private GetInput always_pull_image;
- //private boolean useExisting;
+ private Boolean useExisting;
@JsonIgnore
private ExternalTlsInfoFactory externalCertFactory;
@@ -74,35 +81,29 @@ public class Properties {
}
public TreeMap<String, LinkedHashMap<String, Object>> createOnapProperties(
- TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec componentSpec, String override) {
TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
//set the image
GetInput image = new GetInput();
image.setBpInputName("image");
this.setImage(image);
- LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
- img.put("type", "string");
- img.put("default", cs.getArtifacts()[0].getUri());
- retInputs.put("image", img);
+ retInputs.put("image", createStringInput(componentSpec.getImageUri()));
//set the location id
GetInput location = new GetInput();
location.setBpInputName("location_id");
this.setLocation_id(location);
- LinkedHashMap<String, Object> locMap = new LinkedHashMap();
- locMap.put("type", "string");
- locMap.put("default", "");
- retInputs.put("location_id", locMap);
+ retInputs.put("location_id", createStringInput(EMPTY_VALUE));
//set the log info
- this.setLog_info(cs.getAuxilary().getLog_info());
+ this.setLog_info(componentSpec.getAuxilary().getLog_info());
//set the replicas
GetInput replica = new GetInput();
replica.setBpInputName("replicas");
this.setReplicas(replica);
- LinkedHashMap<String, Object> rep = BlueprintHelper.createInputValue("integer", "number of instances", 1);
+ LinkedHashMap<String, Object> rep = createIntegerInput("number of instances", 1);
retInputs.put("replicas", rep);
//set the dns name
@@ -112,7 +113,7 @@ public class Properties {
//this.setName(cs.getSelf().getName());
//set the docker config
- Auxilary aux = cs.getAuxilary();
+ Auxilary aux = componentSpec.getAuxilary();
// if(aux.getPorts() != null) {
// retInputs = aux.createPorts(retInputs);
// }
@@ -120,76 +121,67 @@ public class Properties {
//set the app config
Appconfig app = new Appconfig();
- retInputs = app.createAppconfig(retInputs, cs, override, false);
+ retInputs = app.createAppconfig(retInputs, componentSpec, override, false);
this.setApplication_config(app);
// set always_pull_image
this.always_pull_image = new GetInput();
this.always_pull_image.setBpInputName("always_pull_image");
- LinkedHashMap<String, Object> inputAlwaysPullImage = BlueprintHelper.createInputValue("boolean",
+ LinkedHashMap<String, Object> inputAlwaysPullImage = createBooleanInput(
"Set to true if the image should always be pulled",
true);
retInputs.put("always_pull_image", inputAlwaysPullImage);
//set service component type
- String sType = cs.getSelf().getName();
- sType = sType.replace('.', '-');
- this.setService_component_type(sType);
+ String serviceComponentType = componentSpec.getSelfName().replace('.', '-');
+ this.setService_component_type(serviceComponentType);
//set the tls info for internal and external communication
- TreeMap<String, Object> tls_info = cs.getAuxilary().getTls_info();
+ TreeMap<String, Object> tls_info = componentSpec.getAuxilary().getTls_info();
if (tls_info != null) {
- addTlsInfo(cs, retInputs);
+ addTlsInfo(componentSpec, retInputs);
if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) {
- retInputs.putAll(addExternalTlsInfo(cs));
+ retInputs.putAll(addExternalTlsInfo(componentSpec));
}
}
//set the reource config
ResourceConfig resource = new ResourceConfig();
- retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
+ retInputs = resource.createResourceConfig(retInputs, componentSpec.getSelf().getName());
this.setResource_config(resource);
return retInputs;
}
public TreeMap<String, LinkedHashMap<String, Object>> createDmaapProperties(
- TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec componentSpec, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
//set the image
GetInput image = new GetInput();
image.setBpInputName("tag_version");
this.setImage(image);
- LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
- img.put("type", "string");
- img.put("default", cs.getArtifacts()[0].getUri());
- retInputs.put("tag_version", img);
+ retInputs.put("tag_version", createStringInput(componentSpec.getImageUri()));
//set the location id
GetInput location = new GetInput();
location.setBpInputName("location_id");
this.setLocation_id(location);
- LinkedHashMap<String, Object> locMap = new LinkedHashMap();
- locMap.put("type", "string");
- locMap.put("default", "");
- retInputs.put("location_id", locMap);
+ retInputs.put("location_id", createStringInput(EMPTY_VALUE));
//set the log info
- this.setLog_info(cs.getAuxilary().getLog_info());
+ this.setLog_info(componentSpec.getAuxilary().getLog_info());
//set service component type
- String sType = cs.getSelf().getName();
- sType = sType.replace('.', '-');
- this.setService_component_type(sType);
+ String serviceComponentType = componentSpec.getSelfName().replace('.', '-');
+ this.setService_component_type(serviceComponentType);
//set the tls info for internal and external communication
- TreeMap<String, Object> tls_info = cs.getAuxilary().getTls_info();
+ TreeMap<String, Object> tls_info = componentSpec.getAuxilary().getTls_info();
if (tls_info != null) {
- addTlsInfo(cs, retInputs);
+ addTlsInfo(componentSpec, retInputs);
if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) {
- retInputs.putAll(addExternalTlsInfo(cs));
+ retInputs.putAll(addExternalTlsInfo(componentSpec));
}
}
@@ -197,7 +189,7 @@ public class Properties {
GetInput replica = new GetInput();
replica.setBpInputName("replicas");
this.setReplicas(replica);
- LinkedHashMap<String, Object> rep = BlueprintHelper.createInputValue("integer", "number of instances", 1);
+ LinkedHashMap<String, Object> rep = createIntegerInput("number of instances", 1);
retInputs.put("replicas", rep);
// //set the dns name
@@ -207,7 +199,7 @@ public class Properties {
// this.setName(cs.getSelf().getName());
//set the docker config
- Auxilary aux = cs.getAuxilary();
+ Auxilary aux = componentSpec.getAuxilary();
// if(aux.getPorts() != null) {
// retInputs = aux.createPorts(retInputs);
// }
@@ -215,59 +207,63 @@ public class Properties {
//set the appconfig
Appconfig app = new Appconfig();
- retInputs = app.createAppconfig(retInputs, cs, override, true);
+ retInputs = app.createAppconfig(retInputs, componentSpec, override, true);
this.setApplication_config(app);
//set the stream publishes
- ArrayList<DmaapStreams> pubStreams = new ArrayList();
- if (cs.getStreams().getPublishes() != null) {
- for (Publishes p : cs.getStreams().getPublishes()) {
- if (p.getType().equals("message_router") || p.getType().equals("message router")) {
- String topic = p.getConfig_key() + "_topic";
+ ArrayList<DmaapStreams> pubStreams = new ArrayList<>();
+ if (componentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publishes : componentSpec.getStreams().getPublishes()) {
+ if (isMessageRouterType(publishes.getType())) {
+ String topic = publishes.getConfig_key() + "_topic";
DmaapStreams mrStreams = new DmaapStreams();
retInputs = mrStreams
- .createStreams(inps, cs, topic, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
+ .createStreams(inps, componentSpec, topic, publishes.getType(), publishes.getConfig_key(),
+ publishes.getRoute(), 'p');
pubStreams.add(mrStreams);
- } else if (p.getType().equals("data_router") || p.getType().equals("data router")) {
- String feed = p.getConfig_key() + "_feed";
+ } else if (isDataRouterType(publishes.getType())) {
+ String feed = publishes.getConfig_key() + "_feed";
DmaapStreams drStreams = new DmaapStreams();
retInputs = drStreams
- .createStreams(inps, cs, feed, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
+ .createStreams(inps, componentSpec, feed, publishes.getType(), publishes.getConfig_key(),
+ publishes.getRoute(), 'p');
pubStreams.add(drStreams);
}
}
}
//set the stream subscribes
- ArrayList<DmaapStreams> subStreams = new ArrayList();
- if (cs.getStreams().getSubscribes() != null) {
- for (Subscribes s : cs.getStreams().getSubscribes()) {
- if (s.getType().equals("message_router") || s.getType().equals("message router")) {
- String topic = s.getConfig_key() + "_topic";
+ ArrayList<DmaapStreams> subStreams = new ArrayList<>();
+ if (componentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) {
+ if (isMessageRouterType(subscribes.getType())) {
+ String topic = subscribes.getConfig_key() + "_topic";
DmaapStreams mrStreams = new DmaapStreams();
retInputs = mrStreams
- .createStreams(inps, cs, topic, s.getType(), s.getConfig_key(), s.getRoute(), 's');
+ .createStreams(inps, componentSpec, topic, subscribes.getType(), subscribes.getConfig_key(),
+ subscribes.getRoute(), 's');
subStreams.add(mrStreams);
- } else if (s.getType().equals("data_router") || s.getType().equals("data router")) {
- String feed = s.getConfig_key() + "_feed";
+ } else if (isDataRouterType(subscribes.getType())) {
+ String feed = subscribes.getConfig_key() + "_feed";
DmaapStreams drStreams = new DmaapStreams();
retInputs = drStreams
- .createStreams(inps, cs, feed, s.getType(), s.getConfig_key(), s.getRoute(), 's');
+ .createStreams(inps, componentSpec, feed, subscribes.getType(), subscribes.getConfig_key(),
+ subscribes.getRoute(), 's');
subStreams.add(drStreams);
}
}
}
- if (pubStreams.size() != 0) {
+ if (!pubStreams.isEmpty()) {
this.setStreams_publishes(pubStreams);
}
- if (subStreams.size() != 0) {
+ if (!subStreams.isEmpty()) {
this.setStreams_subscribes(subStreams);
}
//set the reource config
ResourceConfig resource = new ResourceConfig();
- retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
+ retInputs = resource.createResourceConfig(retInputs, componentSpec.getSelf().getName());
this.setResource_config(resource);
return retInputs;
@@ -280,7 +276,7 @@ public class Properties {
useTLSFlag.setBpInputName("use_tls");
tlsInfo.setUseTls(useTLSFlag);
this.setTls_info(tlsInfo);
- LinkedHashMap<String, Object> useTlsFlagInput = BlueprintHelper.createInputValue("boolean",
+ LinkedHashMap<String, Object> useTlsFlagInput = createBooleanInput(
"flag to indicate tls enable/disable",
cs.getAuxilary().getTls_info().get("use_tls"));
retInputs.put("use_tls", useTlsFlagInput);
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
index 13aa0d0..030374f 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
@@ -21,6 +21,8 @@
package org.onap.blueprintgenerator.models.blueprint;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput;
+
import java.util.LinkedHashMap;
import java.util.TreeMap;
@@ -32,93 +34,94 @@ import lombok.Setter;
//TODO: Auto-generated Javadoc
/* (non-Javadoc)
-* @see java.lang.Object#toString()
-*/
-@Getter @Setter
+ * @see java.lang.Object#toString()
+ */
+@Getter
+@Setter
/* (non-Javadoc)
-* @see java.lang.Object#toString()
-*/
+ * @see java.lang.Object#toString()
+ */
@Builder
/**
-* Instantiates a new resource config obj.
-*/
+ * Instantiates a new resource config obj.
+ */
@NoArgsConstructor
/**
-* Instantiates a new resource config obj.
-*
-* @param limits the limits
-* @param requests the requests
-*/
+ * Instantiates a new resource config obj.
+ *
+ * @param limits the limits
+ * @param requests the requests
+ */
@AllArgsConstructor
public class ResourceConfig {
- /** The limits. */
- private TreeMap<String, GetInput> limits;
-
- /** The requests. */
- private TreeMap<String, GetInput> requests;
+ /**
+ * The limits.
+ */
+ private TreeMap<String, GetInput> limits;
+ /**
+ * The requests.
+ */
+ private TreeMap<String, GetInput> requests;
- /**
- * Creates the resource config.
- *
- * @param inps the inps
- * @param name the name
- * @return the tree map
- */
- public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- LinkedHashMap<String, Object> mi = new LinkedHashMap<String, Object>();
- mi.put("type", "string");
- mi.put("default", "128Mi");
+ /**
+ * Creates the resource config.
+ *
+ * @param inps the inps
+ * @param name the name
+ * @return the tree map
+ */
+ public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String name) {
- LinkedHashMap<String, Object> m = new LinkedHashMap<String, Object>();
- m.put("type", "string");
- m.put("default", "250m");
+ LinkedHashMap<String, Object> memoryLimit = createStringInput("128Mi");
+ LinkedHashMap<String, Object> cpuLimit = createStringInput("250m");
+ String namePrefix = getNamePrefix(name);
- if(!name.equals("")) {
- name = name + "_";
- }
+ //set the limits
+ TreeMap<String, GetInput> limits = new TreeMap<>();
- //set the limits
- TreeMap<String, GetInput> lim = new TreeMap<String, GetInput>();
+ GetInput cpu = new GetInput();
+ cpu.setBpInputName(namePrefix + "cpu_limit");
+ limits.put("cpu", cpu);
- GetInput cpu = new GetInput();
- cpu.setBpInputName(name + "cpu_limit");
- lim.put("cpu", cpu);
+ GetInput memL = new GetInput();
+ memL.setBpInputName(namePrefix + "memory_limit");
+ limits.put("memory", memL);
- GetInput memL = new GetInput();
- memL.setBpInputName(name + "memory_limit");
- lim.put("memory", memL);
+ inps.put(namePrefix + "cpu_limit", cpuLimit);
+ inps.put(namePrefix + "memory_limit", memoryLimit);
- retInputs.put(name + "cpu_limit", m);
- retInputs.put(name + "memory_limit", mi);
+ this.setLimits(limits);
- this.setLimits(lim);
+ //set the requests
+ TreeMap<String, GetInput> requests = new TreeMap<>();
- //set the requests
- TreeMap<String, GetInput> req = new TreeMap<String, GetInput>();
+ GetInput cpuR = new GetInput();
+ cpuR.setBpInputName(namePrefix + "cpu_request");
+ requests.put("cpu", cpuR);
- GetInput cpuR = new GetInput();
- cpuR.setBpInputName(name + "cpu_request");
- req.put("cpu", cpuR);
+ GetInput memR = new GetInput();
+ memR.setBpInputName(namePrefix + "memory_request");
+ requests.put("memory", memR);
- GetInput memR = new GetInput();
- memR.setBpInputName(name + "memory_request");
- req.put("memory", memR);
+ inps.put(namePrefix + "cpu_request", cpuLimit);
+ inps.put(namePrefix + "memory_request", memoryLimit);
- retInputs.put(name + "cpu_request", m);
- retInputs.put(name + "memory_request", mi);
+ this.setRequests(requests);
- this.setRequests(req);
+ return inps;
+ }
- return retInputs;
- }
+ private String getNamePrefix(String name) {
+ return name.isEmpty() ? "" : name + "_";
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java
index d9c885d..0b03777 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java
@@ -36,14 +36,12 @@ public class Start {
private LinkedHashMap<String, Object> envs;
public TreeMap<String, LinkedHashMap<String, Object>> createOnapStart(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- retInputs = inps;
-
+
//create the start inputs
StartInputs inputs = new StartInputs();
- inputs.createOnapStartInputs(retInputs, cs);
+ inputs.createOnapStartInputs(inps, cs);
this.setInputs(inputs);
- return retInputs;
+ return inps;
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
index 1055fbd..a0cfe20 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
@@ -41,10 +41,9 @@ public class StartInputs {
private Object envs;
public TreeMap<String, LinkedHashMap<String, Object>> createOnapStartInputs(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
int count = 0;
- ArrayList<String> portList = new ArrayList();
+ ArrayList<String> portList = new ArrayList<>();
Auxilary aux = cs.getAuxilary();
if (aux.getPorts() != null) {
@@ -56,10 +55,10 @@ public class StartInputs {
, ports[0], count);
portList.add(internal);
- LinkedHashMap<String, Object> portType = new LinkedHashMap();
+ LinkedHashMap<String, Object> portType = new LinkedHashMap<>();
portType.put("type", "string");
portType.put("default", ports[1]);
- retInputs.put("external_port_" + count, portType);
+ inps.put("external_port_" + count, portType);
count++;
}
@@ -98,7 +97,7 @@ public class StartInputs {
// }
//set the envs
- LinkedHashMap<String, Object> eMap = new LinkedHashMap();
+ LinkedHashMap<String, Object> eMap = new LinkedHashMap<>();
if(cs.getAuxilary().getDatabases() != null){
//set db env variables
LinkedHashMap<String, Object> envVars = PgaasNodeBuilder.getEnvVariables(cs.getAuxilary().getDatabases());
@@ -111,9 +110,9 @@ public class StartInputs {
this.setEnvs(env);
eMap.put("default", "{}");
}
- retInputs.put("envs", eMap);
+ inps.put("envs", eMap);
- return retInputs;
+ return inps;
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java
index 464fc4a..0cec284 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java
@@ -46,9 +46,7 @@ public class DmaapInfo {
public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRInfo(
TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
stringType.put("type", "string");
config = config.replaceAll("-", "_");
@@ -62,9 +60,9 @@ public class DmaapInfo {
topic.setBpInputName(config);
this.setTopic_url(topic);
- retInputs.put(config, stringType);
+ inps.put(config, stringType);
- return retInputs;
+ return inps;
}
public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRInfo(
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java
index 6af69e5..30f59e2 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java
@@ -40,10 +40,8 @@ public class DmaapObj {
public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRObj(TreeMap<String, LinkedHashMap<String, Object>> inps,
String config, char type, String n, String num, boolean isDmaap) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- LinkedHashMap<String, Object> stringType = new LinkedHashMap();
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
stringType.put("type", "string");
- retInputs = inps;
//set the dmaapinfo
DmaapInfo info = new DmaapInfo();
@@ -58,20 +56,18 @@ public class DmaapObj {
GetInput u = new GetInput();
u.setBpInputName(config + "_" + num +"_aaf_username");
this.setUser(u);
- retInputs.put(config + "_" + num +"_aaf_username", stringType);
+ inps.put(config + "_" + num +"_aaf_username", stringType);
//set password
GetInput p = new GetInput();
p.setBpInputName(config + "_" + num +"_aaf_password");
this.setPass(p);
- retInputs.put(config + "_" + num +"_aaf_password", stringType);
+ inps.put(config + "_" + num +"_aaf_password", stringType);
}
- return retInputs;
+ return inps;
}
public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num, boolean isDmaap) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
-
+
//set the dmaapinfo
DmaapInfo info = new DmaapInfo();
if(!isDmaap){
@@ -82,6 +78,6 @@ public class DmaapObj {
String infoType = "<<" + n + ">>";
this.setDmaap_info(infoType);
}
- return retInputs;
+ return inps;
}
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
index f7f5a03..198dc19 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java
@@ -21,13 +21,11 @@
package org.onap.blueprintgenerator.models.componentspec;
-
import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -53,6 +51,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
+@EqualsAndHashCode
//Called in Component Spec Object
public class Artifacts {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
index a36deb5..58e1e0c 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
@@ -22,19 +22,15 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import java.util.ArrayList;
+import java.util.TreeMap;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -64,6 +60,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in component Spec Object
public class Auxilary {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
index 0b7dcee..d130632 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java
@@ -24,11 +24,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java
index 3876b53..0cd2b72 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java
@@ -1,21 +1,22 @@
-/**============LICENSE_START=======================================================
- org.onap.dcae
- ================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
-
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+
*/
package org.onap.blueprintgenerator.models.componentspec;
@@ -30,11 +31,13 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
+import lombok.Setter;
import lombok.NoArgsConstructor;
import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo;
// TODO: Auto-generated Javadoc
+
/**
* The Class ComponentSpec.
*/
@@ -43,13 +46,13 @@ import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo;
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
-@Getter @Setter
+@Getter
+@Setter
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
-
/**
* Instantiates a new component spec.
*/
@@ -66,82 +69,98 @@ import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo;
* @param artifacts the artifacts
*/
-@JsonInclude(value=Include.NON_NULL)
+@JsonInclude(value = Include.NON_NULL)
//main object that the component spec file is written in
public class ComponentSpec {
-
- /** The self. */
- private Self self;
-
- /** The services. */
- private Services services;
-
- /** The streams. */
- private Streams streams;
-
- /** The parameters. */
- private Parameters[] parameters;
-
- /** The auxilary. */
- private Auxilary auxilary;
-
- @JsonProperty("policy_info")
- private PolicyInfo policyInfo;
-
- /** The artifacts. */
- private Artifacts[] artifacts;
-
- /**
- * Creates the component spec from file.
- *
- * @param path the path
- */
- public void createComponentSpecFromFile(String path) {
- ObjectMapper componentMapper = new ObjectMapper();
- File specPathFile = new File(path);
- ComponentSpec cs = new ComponentSpec();
-
- try {
- cs = componentMapper.readValue(specPathFile, ComponentSpec.class);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
-
-
- //set all the pieces of the component spec
- this.setSelf(cs.getSelf());
- this.setArtifacts(cs.getArtifacts());
- this.setAuxilary(cs.getAuxilary());
- this.setParameters(cs.getParameters());
- this.setServices(cs.getServices());
- this.setStreams(cs.getStreams());
- this.setPolicyInfo(cs.getPolicyInfo());
- }
-
-
- /**
- * Creates the component spec from string.
- *
- * @param specString the spec string
- */
- public void createComponentSpecFromString(String specString) {
- ObjectMapper componentMapper = new ObjectMapper();
- ComponentSpec cs = new ComponentSpec();
- try {
- cs = componentMapper.readValue(specString, ComponentSpec.class);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- //set all the pieces of the component spec
- this.setSelf(cs.getSelf());
- this.setArtifacts(cs.getArtifacts());
- this.setAuxilary(cs.getAuxilary());
- this.setParameters(cs.getParameters());
- this.setServices(cs.getServices());
- this.setStreams(cs.getStreams());
- }
-
+ /**
+ * The self.
+ */
+ private Self self;
+
+ /**
+ * The services.
+ */
+ private Services services;
+
+ /**
+ * The streams.
+ */
+ private Streams streams;
+
+ /**
+ * The parameters.
+ */
+ private Parameters[] parameters;
+
+ /**
+ * The auxilary.
+ */
+ private Auxilary auxilary;
+
+ @JsonProperty("policy_info")
+ private PolicyInfo policyInfo;
+
+ /**
+ * The artifacts.
+ */
+ private Artifacts[] artifacts;
+
+ /**
+ * Creates the component spec from file.
+ *
+ * @param path the path
+ */
+ public void createComponentSpecFromFile(String path) {
+ ObjectMapper componentMapper = new ObjectMapper();
+ File specPathFile = new File(path);
+ ComponentSpec cs = new ComponentSpec();
+
+ try {
+ cs = componentMapper.readValue(specPathFile, ComponentSpec.class);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ //set all the pieces of the component spec
+ this.setSelf(cs.getSelf());
+ this.setArtifacts(cs.getArtifacts());
+ this.setAuxilary(cs.getAuxilary());
+ this.setParameters(cs.getParameters());
+ this.setServices(cs.getServices());
+ this.setStreams(cs.getStreams());
+ this.setPolicyInfo(cs.getPolicyInfo());
+ }
+
+
+ /**
+ * Creates the component spec from string.
+ *
+ * @param specString the spec string
+ */
+ public void createComponentSpecFromString(String specString) {
+ ObjectMapper componentMapper = new ObjectMapper();
+ ComponentSpec cs = new ComponentSpec();
+ try {
+ cs = componentMapper.readValue(specString, ComponentSpec.class);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ //set all the pieces of the component spec
+ this.setSelf(cs.getSelf());
+ this.setArtifacts(cs.getArtifacts());
+ this.setAuxilary(cs.getAuxilary());
+ this.setParameters(cs.getParameters());
+ this.setServices(cs.getServices());
+ this.setStreams(cs.getStreams());
+ }
+
+ public String getImageUri() {
+ return artifacts[0].getUri();
+ }
+
+ public String getSelfName() {
+ return this.self.getName();
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
index 3615605..785df35 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java
@@ -20,18 +20,10 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.HashMap;
-
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
* The Class ConstraintsObj.
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
index d94e2bb..cbe02dc 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java
@@ -22,11 +22,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,6 +49,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
public class Container {
/** The bind. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
index 45f9091..ef33aaf 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
index acc9379..76e1036 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -53,6 +52,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in Auxillary Object
public class HealthCheck {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
index 91734ad..f178c94 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java
@@ -22,11 +22,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -46,6 +45,7 @@ import lombok.NoArgsConstructor;
* @param mode the mode
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
public class Host{
/** The path. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
index 515ecc7..eb95202 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java
@@ -20,17 +20,13 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.ArrayList;
-
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
@@ -68,6 +64,7 @@ import lombok.NoArgsConstructor;
* @param constraints the constraints
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in component Spec Object
public class Parameters {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
index 3cc14fe..d295ca4 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -51,6 +50,7 @@ import lombok.NoArgsConstructor;
* @param script_path the script path
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//called in auxilary
public class Policy {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
index 7af16d6..aa38271 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
index ad9c87d..9ad24c3 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java
@@ -21,11 +21,9 @@
package org.onap.blueprintgenerator.models.componentspec;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
index 3ee47b9..4f46313 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -54,6 +53,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Streams Object
public class Publishes {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
index 6c389d6..6d78805 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,7 +49,7 @@ import lombok.NoArgsConstructor;
* @param policy the policy
*/
@JsonInclude(value=Include.NON_NULL)
-
+@EqualsAndHashCode
public class ReconfigsObj {
/** The dti. */
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
index 2aaf60b..7ca1830 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java
@@ -25,11 +25,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.NoArgsConstructor;
-
// TODO: Auto-generated Javadoc
/**
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
index a566661..8b5f35e 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java
@@ -20,16 +20,13 @@
package org.onap.blueprintgenerator.models.componentspec;
-import java.util.Map;
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -55,6 +52,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//called in Component Spec object
public class Self {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
index afe0904..772d859 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java
@@ -24,11 +24,9 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
index 1b7dcd3..500f32d 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java
@@ -24,11 +24,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -52,6 +51,7 @@ import lombok.NoArgsConstructor;
*/
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Component Spec Object
public class Streams {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
index 14485a0..ec4aa41 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -57,6 +56,7 @@ import lombok.NoArgsConstructor;
@JsonInclude(value=Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
+@EqualsAndHashCode
//Called in Streams Object
public class Subscribes {
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
index 1034242..777bdeb 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java
@@ -23,11 +23,10 @@ package org.onap.blueprintgenerator.models.componentspec;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
import lombok.NoArgsConstructor;
+import lombok.Setter;
// TODO: Auto-generated Javadoc
/* (non-Javadoc)
@@ -50,6 +49,7 @@ import lombok.NoArgsConstructor;
* @param host the host
*/
@JsonInclude(value=Include.NON_NULL)
+@EqualsAndHashCode
//Called in Auxillary Object
public class Volumes {
@@ -58,4 +58,4 @@ public class Volumes {
/** The host. */
private Host host;
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
index c4cc663..0c8f8a9 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
@@ -1,4 +1,4 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
@@ -8,16 +8,16 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============LICENSE_END=========================================================
-
+
*/
package org.onap.blueprintgenerator.models.dmaapbp;
@@ -28,92 +28,99 @@ import java.util.TreeMap;
import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
import org.onap.blueprintgenerator.models.blueprint.Blueprint;
-import org.onap.blueprintgenerator.models.blueprint.Imports;
import org.onap.blueprintgenerator.models.blueprint.Node;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import org.onap.blueprintgenerator.models.componentspec.Publishes;
import org.onap.blueprintgenerator.models.componentspec.Subscribes;
-public class DmaapBlueprint extends Blueprint{
- public Blueprint createDmaapBlueprint(ComponentSpec cs, String importPath, String override) {
- Blueprint bp = new Blueprint();
-
- //set tosca definition
- bp.setTosca_definitions_version("cloudify_dsl_1_3");
-
- //set the description
- bp.setDescription(cs.getSelf().getDescription());
-
- //create the inpus object that will be added to over the creation of the blueprint
- TreeMap<String, LinkedHashMap<String, Object>> inps = new TreeMap<String, LinkedHashMap<String, Object>>();
-
- //set the imports
- Imports imps = new Imports();
- if(importPath.equals("")) {
- bp.setImports(imps.createDmaapImports());
- }
- else {
- bp.setImports(imps.createImportsFromFile(importPath));
- }
-
- //bp.setImports(imps.getImports());
-
- //set and create the node templates
- TreeMap<String, Node> nodeTemplate = new TreeMap();
-
- //create and add the main dmaap node
- DmaapNode dmaap = new DmaapNode();
- inps = dmaap.createDmaapNode(cs, inps, override);
- nodeTemplate.put(cs.getSelf().getName(), dmaap);
-
- //create and add the topic/feed nodes
-
- //go through the streams publishes
- if(cs.getStreams().getPublishes() != null) {
- for(Publishes p: cs.getStreams().getPublishes()) {
- if(p.getType().equals("message_router") || p.getType().equals("message router")) {
- String topic = p.getConfig_key() + "_topic";
- DmaapNode topicNode = new DmaapNode();
- inps = topicNode.createTopicNode(cs, inps, topic);
- nodeTemplate.put(topic, topicNode);
- } else if(p.getType().equals("data_router") || p.getType().equals("data router")) {
- String feed = p.getConfig_key() + "_feed";
- DmaapNode feedNode = new DmaapNode();
- inps = feedNode.createFeedNode(cs, inps, feed);
- nodeTemplate.put(feed, feedNode);
- }
- }
- }
- //go through the stream subscribes
- if(cs.getStreams().getSubscribes() != null) {
- for(Subscribes s: cs.getStreams().getSubscribes()) {
- if(s.getType().equals("message_router") || s.getType().equals("message router")) {
- String topic = s.getConfig_key() + "_topic";
- DmaapNode topicNode = new DmaapNode();
- inps = topicNode.createTopicNode(cs, inps, topic);
- nodeTemplate.put(topic, topicNode);
- } else if(s.getType().equals("data_router") || s.getType().equals("data router")) {
- String feed = s.getConfig_key() + "_feed";
- DmaapNode feedNode = new DmaapNode();
- inps = feedNode.createFeedNode(cs, inps, feed);
- nodeTemplate.put(feed, feedNode);
- }
- }
- }
-
- //if present in component spec, populate policyNodes information in the blueprint
- if(cs.getPolicyInfo() != null){
- PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inps);
- }
-
- //if present in component spec, populate pgaasNodes information in the blueprint
- if(cs.getAuxilary().getDatabases() != null){
- PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inps);
- }
-
- bp.setNode_templates(nodeTemplate);
-
- bp.setInputs(inps);
- return bp;
- }
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.joinUnderscore;
+import static org.onap.blueprintgenerator.models.blueprint.Imports.createDmaapImports;
+import static org.onap.blueprintgenerator.models.blueprint.Imports.createImportsFromFile;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3;
+
+public class DmaapBlueprint extends Blueprint {
+
+ private static final String TOPIC = "topic";
+ private static final String FEED = "feed";
+
+ public Blueprint createDmaapBlueprint(ComponentSpec componentSpec, String importPath, String override) {
+ Blueprint blueprint = new Blueprint();
+
+ //set tosca definition
+ blueprint.setTosca_definitions_version(CLOUDIFY_DSL_1_3);
+
+ //set the description
+ blueprint.setDescription(componentSpec.getSelf().getDescription());
+
+ //create the inpus object that will be added to over the creation of the blueprint
+ TreeMap<String, LinkedHashMap<String, Object>> inps = new TreeMap<>();
+
+ //set the imports
+ if (importPath.equals("")) {
+ blueprint.setImports(createDmaapImports());
+ } else {
+ blueprint.setImports(createImportsFromFile(importPath));
+ }
+
+ //set and create the node templates
+ TreeMap<String, Node> nodeTemplate = new TreeMap();
+
+ //create and add the main dmaap node
+ DmaapNode dmaap = new DmaapNode();
+ inps = dmaap.createDmaapNode(componentSpec, inps, override);
+ nodeTemplate.put(componentSpec.getSelf().getName(), dmaap);
+
+ //create and add the topic/feed nodes
+
+ //go through the streams publishes
+ if (componentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publisher : componentSpec.getStreams().getPublishes()) {
+ if (isMessageRouterType(publisher.getType())) {
+ String topic = joinUnderscore(publisher.getConfig_key(), TOPIC);
+ DmaapNode topicNode = new DmaapNode();
+ inps = topicNode.createTopicNode(componentSpec, inps, topic);
+ nodeTemplate.put(topic, topicNode);
+ } else if (isDataRouterType(publisher.getType())) {
+ String feed = joinUnderscore(publisher.getConfig_key(), FEED);
+ DmaapNode feedNode = new DmaapNode();
+ inps = feedNode.createFeedNode(componentSpec, inps, feed);
+ nodeTemplate.put(feed, feedNode);
+ }
+ }
+ }
+ //go through the stream subscribes
+ if (componentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes subscriber : componentSpec.getStreams().getSubscribes()) {
+ if (isMessageRouterType(subscriber.getType())) {
+ String topic = joinUnderscore(subscriber.getConfig_key(), TOPIC);
+ DmaapNode topicNode = new DmaapNode();
+ inps = topicNode.createTopicNode(componentSpec, inps, topic);
+ nodeTemplate.put(topic, topicNode);
+ } else if (isDataRouterType(subscriber.getType())) {
+ String feed = joinUnderscore(subscriber.getConfig_key(), FEED);
+ DmaapNode feedNode = new DmaapNode();
+ inps = feedNode.createFeedNode(componentSpec, inps, feed);
+ nodeTemplate.put(feed, feedNode);
+ }
+ }
+ }
+
+ //if present in component spec, populate policyNodes information in the blueprint
+ if (componentSpec.getPolicyInfo() != null) {
+ PolicyNodeBuilder.addPolicyNodesAndInputs(componentSpec, nodeTemplate, inps);
+ }
+
+ //if present in component spec, populate pgaasNodes information in the blueprint
+ if (componentSpec.getAuxilary().getDatabases() != null) {
+ PgaasNodeBuilder.addPgaasNodesAndInputs(componentSpec, nodeTemplate, inps);
+ }
+
+ blueprint.setNode_templates(nodeTemplate);
+
+ blueprint.setInputs(inps);
+ return blueprint;
+ }
+
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
index 37d7d2d..515099a 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
@@ -43,117 +43,143 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType;
+
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.FEED;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOPIC;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.PUBLISH_EVENTS;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.PUBLISH_FILES;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_EVENTS;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_FILES;
+
@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter @Setter
-@EqualsAndHashCode(callSuper=false)
+@Getter
+@Setter
+@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
-@JsonInclude(value=Include.NON_NULL)
-
-public class DmaapNode extends Node{
-
- public TreeMap<String, LinkedHashMap<String, Object>> createDmaapNode(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> inps, String override) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
-
- //set the type
- this.setType("dcae.nodes.ContainerizedServiceComponentUsingDmaap");
-
- //create the interface
- Interfaces inter = new Interfaces();
- retInputs = inter.createInterface(retInputs, cs);
- TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
- interfaces.put("cloudify.interfaces.lifecycle", inter);
- this.setInterfaces(interfaces);
-
- //create and set the relationships
- ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
-
- //go through the streams publishes
- if(cs.getStreams().getPublishes() != null) {
- for(Publishes p: cs.getStreams().getPublishes()) {
- LinkedHashMap<String, String> pubRelations = new LinkedHashMap();
- if(p.getType().equals("message_router") || p.getType().equals("message router")) {
- pubRelations.put("type", "ccsdk.relationships.publish_events");
- pubRelations.put("target", p.getConfig_key() + "_topic");
- } else if(p.getType().equals("data_router") || p.getType().equals("data router")) {
- pubRelations.put("type", "ccsdk.relationships.publish_files");
- pubRelations.put("target", p.getConfig_key() + "_feed");
- }
- rets.add(pubRelations);
- }
- }
- //go through the stream subscribes
- if(cs.getStreams().getSubscribes() != null) {
- for(Subscribes s: cs.getStreams().getSubscribes()) {
- LinkedHashMap<String, String> subRelations = new LinkedHashMap();
- if(s.getType().equals("message_router") || s.getType().equals("message router")) {
- subRelations.put("type", "ccsdk.relationships.subscribe_to_events");
- subRelations.put("target", s.getConfig_key() + "_topic");
- } else if(s.getType().equals("data_router") || s.getType().equals("data router")) {
- subRelations.put("type", "ccsdk.relationships.subscribe_to_files");
- subRelations.put("target", s.getConfig_key() + "_feed");
- }
- rets.add(subRelations);
- }
- }
-
- //add relationship for policy if exist
- if(cs.getPolicyInfo() != null){
- ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.getPolicyRelationships(cs);
- rets.addAll(policyRelationshipsList);
- }
-
- //add relationships and env_variables for pgaas dbs if exist
- if(cs.getAuxilary().getDatabases() != null){
- ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder.getPgaasNodeRelationships(cs);
- rets.addAll(pgaasRelationshipsList);
- }
-
- this.setRelationships(rets);
-
- //create and set the properties
- Properties props = new Properties();
- retInputs = props.createDmaapProperties(retInputs, cs, override);
- this.setProperties(props);
-
- return retInputs;
- }
- public TreeMap<String, LinkedHashMap<String, Object>> createFeedNode(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap();
- stringType.put("type", "string");
-
- //set the type
- this.setType("ccsdk.nodes.Feed");
-
- //create and set the properties
- Properties props = new Properties();
- GetInput topicInput = new GetInput();
- topicInput.setBpInputName(name + "_name");
- props.setFeed_name(topicInput);
- //props.setUseExisting(true);
- retInputs.put(name + "_name", stringType);
- this.setProperties(props);
-
- return retInputs;
- }
-
- public TreeMap<String, LinkedHashMap<String, Object>> createTopicNode(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap();
- stringType.put("type", "string");
-
- //set the type
- this.setType("ccsdk.nodes.Topic");
-
- //create and set the properties
- Properties props = new Properties();
- GetInput topicInput = new GetInput();
- topicInput.setBpInputName(name + "_name");
- props.setTopic_name(topicInput);
- //props.setUseExisting(true);
- retInputs.put(name + "_name", stringType);
- this.setProperties(props);
-
- return retInputs;
- }
+@JsonInclude(value = Include.NON_NULL)
+
+public class DmaapNode extends Node {
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createDmaapNode(ComponentSpec componentSpec,
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+
+ //set the type
+ this.setType(CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP);
+
+ //create the interface
+ Interfaces inter = new Interfaces();
+ retInputs = inter.createInterface(retInputs, componentSpec);
+ TreeMap<String, Interfaces> interfaces = new TreeMap<>();
+ interfaces.put("cloudify.interfaces.lifecycle", inter);
+ this.setInterfaces(interfaces);
+
+ //create and set the relationships
+ ArrayList<LinkedHashMap<String, String>> relationships = new ArrayList<>();
+
+ //go through the streams publishes
+ if (componentSpec.getStreams().getPublishes() != null) {
+ for (Publishes publishes : componentSpec.getStreams().getPublishes()) {
+ relationships.add(createTypeAndTargetPubRelations(publishes));
+ }
+ }
+ //go through the stream subscribes
+ if (componentSpec.getStreams().getSubscribes() != null) {
+ for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) {
+ relationships.add(createTypeAndTargetSubRelations(subscribes));
+ }
+ }
+
+ //add relationship for policy if exist
+ if (componentSpec.getPolicyInfo() != null) {
+ ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder
+ .getPolicyRelationships(componentSpec);
+ relationships.addAll(policyRelationshipsList);
+ }
+
+ //add relationships and env_variables for pgaas dbs if exist
+ if (componentSpec.getAuxilary().getDatabases() != null) {
+ ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder
+ .getPgaasNodeRelationships(componentSpec);
+ relationships.addAll(pgaasRelationshipsList);
+ }
+
+ this.setRelationships(relationships);
+
+ //create and set the properties
+ Properties props = new Properties();
+ retInputs = props.createDmaapProperties(retInputs, componentSpec, override);
+ this.setProperties(props);
+
+ return retInputs;
+ }
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createFeedNode(ComponentSpec cs,
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String name) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
+ stringType.put("type", "string");
+
+ //set the type
+ this.setType(FEED);
+
+ //create and set the properties
+ Properties props = new Properties();
+ GetInput topicInput = new GetInput();
+ topicInput.setBpInputName(name + "_name");
+ props.setFeed_name(topicInput);
+ props.setUseExisting(true);
+ retInputs.put(name + "_name", stringType);
+ this.setProperties(props);
+
+ return retInputs;
+ }
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createTopicNode(ComponentSpec cs,
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String name) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap<>();
+ stringType.put("type", "string");
+
+ //set the type
+ this.setType(TOPIC);
+
+ //create and set the properties
+ Properties props = new Properties();
+ GetInput topicInput = new GetInput();
+ topicInput.setBpInputName(name + "_name");
+ props.setTopic_name(topicInput);
+ //props.setUseExisting(true);
+ retInputs.put(name + "_name", stringType);
+ this.setProperties(props);
+
+ return retInputs;
+ }
+
+ private LinkedHashMap<String, String> createTypeAndTargetPubRelations(Publishes publishes) {
+ LinkedHashMap<String, String> pubRelations = new LinkedHashMap<>();
+ if (isMessageRouterType(publishes.getType())) {
+ pubRelations.put("type", PUBLISH_EVENTS);
+ pubRelations.put("target", publishes.getConfig_key() + "_topic");
+ } else if (isDataRouterType(publishes.getType())) {
+ pubRelations.put("type", PUBLISH_FILES);
+ pubRelations.put("target", publishes.getConfig_key() + "_feed");
+ }
+ return pubRelations;
+ }
+
+ private LinkedHashMap<String, String> createTypeAndTargetSubRelations(Subscribes subscribes) {
+ LinkedHashMap<String, String> subRelations = new LinkedHashMap<>();
+ if (isMessageRouterType(subscribes.getType())) {
+ subRelations.put("type", SUBSCRIBE_TO_EVENTS);
+ subRelations.put("target", subscribes.getConfig_key() + "_topic");
+ } else if (isDataRouterType(subscribes.getType())) {
+ subRelations.put("type", SUBSCRIBE_TO_FILES);
+ subRelations.put("target", subscribes.getConfig_key() + "_feed");
+ }
+ return subRelations;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
index e2847d7..162337e 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java
@@ -33,72 +33,77 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import lombok.Getter;
import lombok.Setter;
-@Getter @Setter
-@JsonInclude(value=Include.NON_NULL)
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType;
+
+@Getter
+@Setter
+@JsonInclude(value = Include.NON_NULL)
public class DmaapStreams {
- private String name;
- private GetInput location;
- private GetInput client_role;
- private String type;
-
- private GetInput username;
- private GetInput password;
- //private GetInput delivery_url;
-
- private GetInput privileged;
- private GetInput decompress;
-
- private String route;
- private String scheme;
-
- public TreeMap<String, LinkedHashMap<String, Object>> createStreams(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String name, String type, String key, String route, char o){
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
- LinkedHashMap<String, Object> stringType = new LinkedHashMap();
- stringType.put("type", "string");
-
- //set the name
- this.setName(name);
-
- //set the type
- this.setType(type);
-
- //set the location
- GetInput location = new GetInput();
- location.setBpInputName(key + "_" + name + "_location");
- retInputs.put(key + "_" + name + "_location", stringType);
- this.setLocation(location);
-
- //if its data router we need to add some more
- if(type.equals("data_router") || type.equals("data router")) {
- if(o == 's') {
- //set the username
- GetInput username = new GetInput();
- username.setBpInputName(key + "_" + name + "_username");
- this.setUsername(username);
- retInputs.put(key + "_" + name + "_username", stringType);
-
- //set the password
- GetInput password = new GetInput();
- password.setBpInputName(key + "_" + name + "_password");
- this.setPassword(password);
- retInputs.put(key + "_" + name + "_password", stringType);
-
- //set privileged
- GetInput priviliged = new GetInput();
- priviliged.setBpInputName(key + "_" + name + "_priviliged");
- this.setPrivileged(priviliged);
- retInputs.put(key + "_" + name + "_priviliged", stringType);
-
- //set decompress
- GetInput decompress = new GetInput();
- decompress.setBpInputName(key + "_" + name + "_decompress");
- this.setDecompress(decompress);
- retInputs.put(key + "_" + name + "_decompress", stringType);
-
- this.setRoute(route);
- this.setScheme("https");
- }
+ private String name;
+ private GetInput location;
+ private GetInput client_role;
+ private String type;
+
+ private GetInput username;
+ private GetInput password;
+ //private GetInput delivery_url;
+
+ private GetInput privileged;
+ private GetInput decompress;
+
+ private String route;
+ private String scheme;
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createStreams(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String name, String type, String key,
+ String route, char o) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap();
+ stringType.put("type", "string");
+
+ //set the name
+ this.setName(name);
+
+ //set the type
+ this.setType(type);
+
+ //set the location
+ GetInput location = new GetInput();
+ location.setBpInputName(key + "_" + name + "_location");
+ retInputs.put(key + "_" + name + "_location", stringType);
+ this.setLocation(location);
+
+ //if its data router we need to add some more
+ if (isDataRouterType(type)) {
+ if ('s' == o) {
+ //set the username
+ GetInput username = new GetInput();
+ username.setBpInputName(key + "_" + name + "_username");
+ this.setUsername(username);
+ retInputs.put(key + "_" + name + "_username", stringType);
+
+ //set the password
+ GetInput password = new GetInput();
+ password.setBpInputName(key + "_" + name + "_password");
+ this.setPassword(password);
+ retInputs.put(key + "_" + name + "_password", stringType);
+
+ //set privileged
+ GetInput priviliged = new GetInput();
+ priviliged.setBpInputName(key + "_" + name + "_priviliged");
+ this.setPrivileged(priviliged);
+ retInputs.put(key + "_" + name + "_priviliged", stringType);
+
+ //set decompress
+ GetInput decompress = new GetInput();
+ decompress.setBpInputName(key + "_" + name + "_decompress");
+ this.setDecompress(decompress);
+ retInputs.put(key + "_" + name + "_decompress", stringType);
+
+ this.setRoute(route);
+ this.setScheme("https");
+ }
// //set the delivery url
// GetInput delivery = new GetInput();
@@ -106,13 +111,13 @@ public class DmaapStreams {
// this.setDelivery_url(delivery);
// retInputs.put(name + "delivery_url", stringType);
- } else {
- //set the client role
- GetInput client = new GetInput();
- client.setBpInputName(key + "_" + name + "_client_role");
- this.setClient_role(client);
- retInputs.put(key + "_" + name + "_client_role", stringType);
- }
- return retInputs;
- }
+ } else {
+ //set the client role
+ GetInput client = new GetInput();
+ client.setBpInputName(key + "_" + name + "_client_role");
+ this.setClient_role(client);
+ retInputs.put(key + "_" + name + "_client_role", stringType);
+ }
+ return retInputs;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
index 9f6f560..d9f3c16 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
@@ -1,4 +1,4 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
@@ -22,10 +22,14 @@
package org.onap.blueprintgenerator.models.onapbp;
-import java.util.ArrayList;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.LinkedHashMap;
import java.util.TreeMap;
-
+import lombok.Getter;
+import lombok.Setter;
import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
import org.onap.blueprintgenerator.models.blueprint.Blueprint;
@@ -33,67 +37,59 @@ import org.onap.blueprintgenerator.models.blueprint.Imports;
import org.onap.blueprintgenerator.models.blueprint.Node;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.Getter; import lombok.Setter;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
-@Getter @Setter
-@JsonInclude(value=Include.NON_NULL)
+@Getter
+@Setter
+@JsonInclude(value = Include.NON_NULL)
-public class OnapBlueprint extends Blueprint{
- public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) {
+public class OnapBlueprint extends Blueprint {
- //create the inputs that will be used
- TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- //set the tosca definition which is the same for everything
- this.setTosca_definitions_version("cloudify_dsl_1_3");
+ public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) {
- //set the imports
- if(!"".equals(importPath)) {
- Imports imps = new Imports();
- this.setImports(imps.createImportsFromFile(importPath));
- }
- else {
- Imports imps = new Imports();
- this.setImports(imps.createOnapImports());
- }
+ //create the inputs that will be used
+ TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ //set the tosca definition which is the same for everything
+ this.setTosca_definitions_version(CLOUDIFY_DSL_1_3);
- //create the node template
- TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
- String nodeName = cs.getSelf().getName();
+ //set the imports
+ if (!"".equals(importPath)) {
+ Imports imps = new Imports();
+ this.setImports(imps.createImportsFromFile(importPath));
+ } else {
+ Imports imps = new Imports();
+ this.setImports(imps.createOnapImports());
+ }
- //create the onap node that will be used
- OnapNode node = new OnapNode();
- inputs = node.createOnapNode(inputs, cs, override);
- nodeTemplate.put(nodeName, node);
- this.setNode_templates(nodeTemplate);
+ //create the node template
+ TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
+ String nodeName = cs.getSelf().getName();
- //if present in component spec, populate policyNode information in the blueprint
- if(cs.getPolicyInfo() != null){
- PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs);
- }
+ //create the onap node that will be used
+ OnapNode node = new OnapNode();
+ inputs = node.createOnapNode(inputs, cs, override);
+ nodeTemplate.put(nodeName, node);
+ this.setNode_templates(nodeTemplate);
- //if present in component spec, populate pgaasNodes information in the blueprint
- if(cs.getAuxilary().getDatabases() != null){
- PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs);
- }
+ //if present in component spec, populate policyNode information in the blueprint
+ if (cs.getPolicyInfo() != null) {
+ PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs);
+ }
- //set the inputs
- this.setInputs(inputs);
+ //if present in component spec, populate pgaasNodes information in the blueprint
+ if (cs.getAuxilary().getDatabases() != null) {
+ PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs);
+ }
+ //set the inputs
+ this.setInputs(inputs);
- Blueprint bp = new Blueprint();
- bp.setImports(this.getImports());
- bp.setInputs(this.getInputs());
- bp.setNode_templates(this.getNode_templates());
- bp.setTosca_definitions_version(this.getTosca_definitions_version());
+ Blueprint bp = new Blueprint();
+ bp.setImports(this.getImports());
+ bp.setInputs(this.getInputs());
+ bp.setNode_templates(this.getNode_templates());
+ bp.setTosca_definitions_version(this.getTosca_definitions_version());
- return bp;
+ return bp;
- }
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
index b0d1302..9daea56 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
@@ -1,8 +1,10 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@@ -20,10 +22,18 @@
package org.onap.blueprintgenerator.models.onapbp;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.TreeMap;
-
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
import org.onap.blueprintgenerator.models.blueprint.Interfaces;
@@ -31,60 +41,54 @@ import org.onap.blueprintgenerator.models.blueprint.Node;
import org.onap.blueprintgenerator.models.blueprint.Properties;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter; import lombok.Setter;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-
@JsonIgnoreProperties(ignoreUnknown = true)
-@Getter @Setter
-@EqualsAndHashCode(callSuper=false)
+@Getter
+@Setter
+@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
-@JsonInclude(value=Include.NON_NULL)
-
-public class OnapNode extends Node{
-
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
- TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
- retInputs = inps;
-
- //create and set the interfaces
- Interfaces inter = new Interfaces();
- retInputs = inter.createInterface(retInputs, cs);
- TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
- interfaces.put("cloudify.interfaces.lifecycle", inter);
- this.setInterfaces(interfaces);
-
- //set the type
- this.setType("dcae.nodes.ContainerizedServiceComponent");
-
- //create and set the relationships
- ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
-
- //add relationship for policy if exist
- if(cs.getPolicyInfo() != null){
- ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.getPolicyRelationships(cs);
- rets.addAll(policyRelationshipsList);
- }
-
- //add relationships and env_variables for pgaas dbs if exist
- if(cs.getAuxilary().getDatabases() != null){
- ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder.getPgaasNodeRelationships(cs);
- rets.addAll(pgaasRelationshipsList);
- }
-
- this.setRelationships(rets);
-
- //set the properties
- Properties props = new Properties();
- retInputs = props.createOnapProperties(retInputs, cs, override);
- this.setProperties(props);
-
- return retInputs;
- }
+@JsonInclude(value = Include.NON_NULL)
+
+public class OnapNode extends Node {
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ retInputs = inps;
+
+ //create and set the interfaces
+ Interfaces inter = new Interfaces();
+ retInputs = inter.createInterface(retInputs, cs);
+ TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
+ interfaces.put("cloudify.interfaces.lifecycle", inter);
+ this.setInterfaces(interfaces);
+
+ //set the type
+ this.setType(CONTENERIZED_SERVICE_COMPONENT);
+
+ //create and set the relationships
+ ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
+
+ //add relationship for policy if exist
+ if (cs.getPolicyInfo() != null) {
+ ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder
+ .getPolicyRelationships(cs);
+ rets.addAll(policyRelationshipsList);
+ }
+
+ //add relationships and env_variables for pgaas dbs if exist
+ if (cs.getAuxilary().getDatabases() != null) {
+ ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder
+ .getPgaasNodeRelationships(cs);
+ rets.addAll(pgaasRelationshipsList);
+ }
+
+ this.setRelationships(rets);
+
+ //set the properties
+ Properties props = new Properties();
+ retInputs = props.createOnapProperties(retInputs, cs, override);
+ this.setProperties(props);
+
+ return retInputs;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java
index 9c9bd51..81bc440 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java
@@ -1,37 +1,28 @@
-/**============LICENSE_START=======================================================
- org.onap.dcae
- ================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
+/*============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
*/
package org.onap.blueprintgenerator.models.policymodel;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.TreeMap;
-
-import org.onap.blueprintgenerator.models.blueprint.Node;
-import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import org.onap.blueprintgenerator.models.componentspec.Parameters;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_SIMPLE_YAML;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerationException;
@@ -39,101 +30,107 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
-
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+import org.onap.blueprintgenerator.models.componentspec.Parameters;
-@Getter @Setter
+@Getter
+@Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PolicyModel {
-
- private String tosca_definition_version;
- private TreeMap<String, PolicyModelNode> node_types;
- private TreeMap<String, PolicyModelNode> data_types;
-
- public ArrayList<PolicyModel> createPolicyModels(ComponentSpec cs, String filePath) {
- ArrayList<PolicyModel> models = new ArrayList();
- Parameters[] params = cs.getParameters();
-
- ArrayList<String> groups = new ArrayList<String>();
- groups = getModelGroups(params);
-
- for(String s: groups) {
- PolicyModel model = new PolicyModel();
- model = model.createPolicyModel(s, params);
- //models.add(model);
- policyModelToYaml(filePath, model, s);
- }
-
+
+ private String tosca_definition_version;
+ private TreeMap<String, PolicyModelNode> node_types;
+ private TreeMap<String, PolicyModelNode> data_types;
+
+ public ArrayList<PolicyModel> createPolicyModels(ComponentSpec cs, String filePath) {
+ ArrayList<PolicyModel> models = new ArrayList();
+ Parameters[] params = cs.getParameters();
+
+ ArrayList<String> groups = new ArrayList<String>();
+ groups = getModelGroups(params);
+
+ for (String s : groups) {
+ PolicyModel model = new PolicyModel();
+ model = model.createPolicyModel(s, params);
+ //models.add(model);
+ policyModelToYaml(filePath, model, s);
+ }
+
// for(PolicyModel p: models) {
// policyModelToYaml(filePath, p);
// }
- return models;
- }
-
- public ArrayList<String> getModelGroups(Parameters[] params) {
- ArrayList<String> groups = new ArrayList();
-
- for(Parameters p: params) {
- if(p.isPolicy_editable()) {
- if(groups.isEmpty()) {
- groups.add(p.getPolicy_group());
- } else {
- if(!groups.contains(p.getPolicy_group())) {
- groups.add(p.getPolicy_group());
- }
- }
- }
- }
-
- return groups;
- }
-
- public PolicyModel createPolicyModel(String s, Parameters[] params) {
- PolicyModel model = new PolicyModel();
- model.setTosca_definition_version("tosca_simple_yaml_1_0_0");
-
- PolicyModelNode node = new PolicyModelNode();
- String hasEntryScheme = node.createNodeType(s, params);
- String nodeTypeName = "onap.policy." + s;
- TreeMap<String, PolicyModelNode> nodeType = new TreeMap();
- nodeType.put(nodeTypeName, node);
- model.setNode_types(nodeType);
-
- if(!hasEntryScheme.equals("")) {
- PolicyModelNode data = new PolicyModelNode();
- TreeMap<String, PolicyModelNode> dataType = data.createDataTypes(hasEntryScheme, params);
- model.setData_types(dataType);
- }
-
- return model;
- }
-
- public void policyModelToYaml(String path, PolicyModel p, String name) {
- File outputFile;
- String filePath = path + "/" + name + ".yml";
- File policyFile = new File(filePath);
- ObjectMapper policyMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
- outputFile = new File(path, name + ".yml");
- outputFile.getParentFile().mkdirs();
-
- try {
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)));
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- try {
- policyMapper.writeValue(outputFile, p);
- } catch (JsonGenerationException e) {
- e.printStackTrace();
- } catch (JsonMappingException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- System.out.println("model " + name + " created");
- }
+ return models;
+ }
+
+ public ArrayList<String> getModelGroups(Parameters[] params) {
+ ArrayList<String> groups = new ArrayList();
+
+ for (Parameters p : params) {
+ if (p.isPolicy_editable()) {
+ if (groups.isEmpty()) {
+ groups.add(p.getPolicy_group());
+ } else {
+ if (!groups.contains(p.getPolicy_group())) {
+ groups.add(p.getPolicy_group());
+ }
+ }
+ }
+ }
+
+ return groups;
+ }
+
+ public PolicyModel createPolicyModel(String s, Parameters[] params) {
+ PolicyModel model = new PolicyModel();
+ model.setTosca_definition_version(TOSCA_SIMPLE_YAML);
+
+ PolicyModelNode node = new PolicyModelNode();
+ String hasEntryScheme = node.createNodeType(s, params);
+ String nodeTypeName = "onap.policy." + s;
+ TreeMap<String, PolicyModelNode> nodeType = new TreeMap();
+ nodeType.put(nodeTypeName, node);
+ model.setNode_types(nodeType);
+
+ if (!hasEntryScheme.equals("")) {
+ PolicyModelNode data = new PolicyModelNode();
+ TreeMap<String, PolicyModelNode> dataType = data.createDataTypes(hasEntryScheme, params);
+ model.setData_types(dataType);
+ }
+
+ return model;
+ }
+
+ public void policyModelToYaml(String path, PolicyModel p, String name) {
+ File outputFile;
+ String filePath = path + "/" + name + ".yml";
+ File policyFile = new File(filePath);
+ ObjectMapper policyMapper = new ObjectMapper(
+ new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
+ outputFile = new File(path, name + ".yml");
+ outputFile.getParentFile().mkdirs();
+
+ try {
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ policyMapper.writeValue(outputFile, p);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ System.out.println("model " + name + " created");
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java
index 56d1d13..89321de 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java
@@ -1,8 +1,10 @@
-/**============LICENSE_START=======================================================
+/*============LICENSE_START=======================================================
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@@ -20,128 +22,126 @@
package org.onap.blueprintgenerator.models.policymodel;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_DATATYPES_ROOT;
+import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_NODES_ROOT;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.TreeMap;
-
-import org.onap.blueprintgenerator.models.blueprint.Node;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.blueprintgenerator.models.componentspec.EntrySchemaObj;
import org.onap.blueprintgenerator.models.componentspec.Parameters;
import org.onap.blueprintgenerator.models.componentspec.PolicySchemaObj;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import lombok.Getter;
-import lombok.Setter;
-
-@Getter @Setter
+@Getter
+@Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PolicyModelNode {
-
- private String derived_from;
- private TreeMap<String, PolicyProperties> properties;
-
- public String createNodeType(String policyName, Parameters[] params) {
- String hasEntrySchema = "";
-
- TreeMap<String, PolicyProperties> props = new TreeMap();
- for(Parameters p: params) {
- if(p.getPolicy_group() != null) {
- if(p.getPolicy_group().equals(policyName)) {
- String name = p.getName();
- String type = p.getType();
- PolicyProperties polProps = new PolicyProperties();
- if(p.getPolicy_schema() != null) {
- polProps.setType("map");
- HashMap<String, String> entrySchema = new HashMap();
- entrySchema.put("type", "onap.datatypes." + name);
- //ArrayList<String> entrySchema = new ArrayList<String>();
- //entrySchema.add("type: onap.data." + name);
- polProps.setEntry_schema(entrySchema);
- hasEntrySchema = name;
- props.put(name, polProps);
- }
- else {
- polProps.setType(type);
- props.put(name, polProps);
- }
- }
- }
- }
-
- this.setDerived_from("tosca.datatypes.Root");
- this.setProperties(props);
- return hasEntrySchema;
- }
-
- public TreeMap<String, PolicyModelNode> createDataTypes(String param, Parameters[] parameters) {
- TreeMap<String, PolicyModelNode> dataType = new TreeMap<String, PolicyModelNode>();
-
- PolicyModelNode node = new PolicyModelNode();
- node.setDerived_from("tosca.datatypes.Root");
-
- TreeMap<String, PolicyProperties> properties = new TreeMap();
-
- Parameters par = new Parameters();
- for(Parameters p: parameters) {
- if(p.getName().equals(param)) {
- par = p;
- break;
- }
- }
-
- for(PolicySchemaObj pol: par.getPolicy_schema()) {
- if(pol.getEntry_schema() != null) {
- PolicyProperties prop = new PolicyProperties();
- prop.setType("map");
- HashMap<String, String> schema = new HashMap();
- schema.put("type", "onap.datatypes." + pol.getName());
+
+ private String derived_from;
+ private TreeMap<String, PolicyProperties> properties;
+
+ public String createNodeType(String policyName, Parameters[] params) {
+ String hasEntrySchema = "";
+
+ TreeMap<String, PolicyProperties> props = new TreeMap();
+ for (Parameters p : params) {
+ if (p.getPolicy_group() != null) {
+ if (p.getPolicy_group().equals(policyName)) {
+ String name = p.getName();
+ String type = p.getType();
+ PolicyProperties polProps = new PolicyProperties();
+ if (p.getPolicy_schema() != null) {
+ polProps.setType("map");
+ HashMap<String, String> entrySchema = new HashMap();
+ entrySchema.put("type", "onap.datatypes." + name);
+ //ArrayList<String> entrySchema = new ArrayList<String>();
+ //entrySchema.add("type: onap.data." + name);
+ polProps.setEntry_schema(entrySchema);
+ hasEntrySchema = name;
+ props.put(name, polProps);
+ } else {
+ polProps.setType(type);
+ props.put(name, polProps);
+ }
+ }
+ }
+ }
+
+ this.setDerived_from(TOSCA_DATATYPES_ROOT);
+ this.setProperties(props);
+ return hasEntrySchema;
+ }
+
+ public TreeMap<String, PolicyModelNode> createDataTypes(String param, Parameters[] parameters) {
+ TreeMap<String, PolicyModelNode> dataType = new TreeMap<String, PolicyModelNode>();
+
+ PolicyModelNode node = new PolicyModelNode();
+ node.setDerived_from(TOSCA_DATATYPES_ROOT);
+
+ TreeMap<String, PolicyProperties> properties = new TreeMap();
+
+ Parameters par = new Parameters();
+ for (Parameters p : parameters) {
+ if (p.getName().equals(param)) {
+ par = p;
+ break;
+ }
+ }
+
+ for (PolicySchemaObj pol : par.getPolicy_schema()) {
+ if (pol.getEntry_schema() != null) {
+ PolicyProperties prop = new PolicyProperties();
+ prop.setType("map");
+ HashMap<String, String> schema = new HashMap();
+ schema.put("type", "onap.datatypes." + pol.getName());
// prop.setType("list");
// ArrayList<String> schema = new ArrayList();
// schema.add("type: onap.data." + pol.getName());
- prop.setEntry_schema(schema);
- properties.put(pol.getName(), prop);
- dataType = translateEntrySchema(dataType, pol.getEntry_schema(), pol.getName());
- }
- else {
- PolicyProperties prop = new PolicyProperties();
- prop.setType(pol.getType());
- properties.put(pol.getName(), prop);
- }
- }
-
- node.setProperties(properties);
- dataType.put("onap.datatypes." + param, node);
- return dataType;
- }
-
- private TreeMap<String, PolicyModelNode> translateEntrySchema(TreeMap<String, PolicyModelNode> dataType, EntrySchemaObj[] entry, String name){
- TreeMap<String, PolicyModelNode> data = dataType;
- PolicyModelNode node = new PolicyModelNode();
- node.setDerived_from("tosca.nodes.Root");
- TreeMap<String, PolicyProperties> properties = new TreeMap<String, PolicyProperties>();
-
- for(EntrySchemaObj e: entry) {
- if(e.getEntry_schema() != null) {
- PolicyProperties prop = new PolicyProperties();
- prop.setType("list");
- ArrayList<String> schema = new ArrayList<String>();
- schema.add("type: onap.datatypes." + e.getName());
- prop.setEntry_schema(schema);
- properties.put(e.getName(), prop);
- data = translateEntrySchema(data, e.getEntry_schema(), e.getName());
- node.setProperties(properties);
- } else {
- PolicyProperties prop = new PolicyProperties();
- prop.setType(e.getType());
- properties.put(e.getName(), prop);
- node.setProperties(properties);
- }
- }
-
- dataType.put("onap.datatypes." + name, node);
- return data;
- }
+ prop.setEntry_schema(schema);
+ properties.put(pol.getName(), prop);
+ dataType = translateEntrySchema(dataType, pol.getEntry_schema(), pol.getName());
+ } else {
+ PolicyProperties prop = new PolicyProperties();
+ prop.setType(pol.getType());
+ properties.put(pol.getName(), prop);
+ }
+ }
+
+ node.setProperties(properties);
+ dataType.put("onap.datatypes." + param, node);
+ return dataType;
+ }
+
+ private TreeMap<String, PolicyModelNode> translateEntrySchema(TreeMap<String, PolicyModelNode> dataType,
+ EntrySchemaObj[] entry, String name) {
+ TreeMap<String, PolicyModelNode> data = dataType;
+ PolicyModelNode node = new PolicyModelNode();
+ node.setDerived_from(TOSCA_NODES_ROOT);
+ TreeMap<String, PolicyProperties> properties = new TreeMap<String, PolicyProperties>();
+
+ for (EntrySchemaObj e : entry) {
+ if (e.getEntry_schema() != null) {
+ PolicyProperties prop = new PolicyProperties();
+ prop.setType("list");
+ ArrayList<String> schema = new ArrayList<String>();
+ schema.add("type: onap.datatypes." + e.getName());
+ prop.setEntry_schema(schema);
+ properties.put(e.getName(), prop);
+ data = translateEntrySchema(data, e.getEntry_schema(), e.getName());
+ node.setProperties(properties);
+ } else {
+ PolicyProperties prop = new PolicyProperties();
+ prop.setType(e.getType());
+ properties.put(e.getName(), prop);
+ node.setProperties(properties);
+ }
+ }
+
+ dataType.put("onap.datatypes." + name, node);
+ return data;
+ }
}