aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2019-03-26 10:51:07 +0000
committermark.j.leonard <mark.j.leonard@gmail.com>2019-03-26 10:51:07 +0000
commit8a7d9a0d7782b9339810b02208620bdd2f0a12b2 (patch)
treee3cac78df7c662eee95ad17cf9a01d19158114ad /src/main/java
parent550216df935437b1380b6d4425fd422ea7c013f5 (diff)
Allow UUID definitions in the mappings JSON
Add support for reading the Widget invariant and version UUIDs from the TOSCA mappings JSON. In this commit the artifact-generator.properties is also read and used to provide default values. This step prevents any existing deployments (e.g. automated test integration) from failing. The redundant properties file will be deprecated in a future commit, only when the JSON configuration has been updated. Also remove two unused Java files to help with coverage stats. Change-Id: Idc82e28092a2b028214225c7974db411c9f8a173 Issue-ID: AAI-2284 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java35
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/data/WidgetTypeConfig.java4
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java30
3 files changed, 41 insertions, 28 deletions
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
index baecada..620f792 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
@@ -37,6 +37,9 @@ import org.onap.aai.babel.xml.generator.types.ModelType;
public class WidgetConfigurationUtil {
+ public static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND =
+ "Cannot generate artifacts. Widget configuration not found for %s";
+
private static Properties config;
private static List<String> instanceGroups = Collections.emptyList();
private static Map<String, Resource> typeToResource = new HashMap<>();
@@ -49,10 +52,6 @@ public class WidgetConfigurationUtil {
throw new UnsupportedOperationException("This static class should not be instantiated!");
}
- public static Properties getConfig() {
- return config;
- }
-
public static void setConfig(Properties config) {
WidgetConfigurationUtil.config = config;
}
@@ -98,8 +97,14 @@ public class WidgetConfigurationUtil {
if (type.type == null || type.name == null) {
throw new IllegalArgumentException("Incomplete widget type specified: " + type);
}
- WidgetType widgetType = new WidgetType(type.type);
- Widget widget = new Widget(widgetType, type.name, type.deleteFlag);
+ if (type.modelInvariantId == null) {
+ type.modelInvariantId = WidgetConfigurationUtil.getModelInvariantId(type.name);
+ }
+ if (type.modelVersionId == null) {
+ type.modelVersionId = WidgetConfigurationUtil.getModelVersionId(type.name);
+ }
+ Widget widget = new Widget(new WidgetType(type.type), type.name, type.deleteFlag, //
+ type.modelInvariantId, type.modelVersionId);
typeToWidget.put(type.type, widget);
}
WidgetType.validateElements();
@@ -117,4 +122,22 @@ public class WidgetConfigurationUtil {
typeToResource.put(mapping.prefix, resource);
}
}
+
+ public static String getModelInvariantId(String name) {
+ String id = config.getProperty(ArtifactType.AAI.name() + ".model-invariant-id." + name);
+ if (id == null) {
+ throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGLPROP_NOT_FOUND,
+ ArtifactType.AAI.name() + ".model-invariant-id." + name));
+ }
+ return id;
+ }
+
+ public static String getModelVersionId(String name) {
+ String id = config.getProperty(ArtifactType.AAI.name() + ".model-version-id." + name);
+ if (id == null) {
+ throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGLPROP_NOT_FOUND,
+ ArtifactType.AAI.name() + ".model-version-id." + name));
+ }
+ return id;
+ }
}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetTypeConfig.java b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetTypeConfig.java
index 0d0fe6b..b52c7a5 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetTypeConfig.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetTypeConfig.java
@@ -22,7 +22,7 @@
package org.onap.aai.babel.xml.generator.data;
/**
- * Widget Type as configured in the TOSCA Mappings.
+ * Widget Type as configured in the TOSCA Mappings.
*
*/
public class WidgetTypeConfig {
@@ -30,5 +30,7 @@ public class WidgetTypeConfig {
String type;
String name;
boolean deleteFlag = false;
+ String modelInvariantId;
+ String modelVersionId;
}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java
index 78a1e8a..ee04abc 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java
@@ -24,29 +24,29 @@ package org.onap.aai.babel.xml.generator.model;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Properties;
import java.util.Set;
import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
-import org.onap.aai.babel.xml.generator.data.ArtifactType;
import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
import org.onap.aai.babel.xml.generator.error.IllegalAccessException;
import org.onap.aai.babel.xml.generator.types.ModelType;
public class Widget extends Model {
- public static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND =
- "Cannot generate artifacts. Widget configuration not found for %s";
-
private Set<String> keys = new HashSet<>();
protected String name;
protected WidgetType type;
protected boolean deleteFlag = false;
- public Widget(WidgetType widgetType, String name, boolean deleteFlag) {
+ private String modelInvariantId;
+ private String modelVersionId;
+
+ public Widget(WidgetType widgetType, String name, boolean deleteFlag, String modelInvariantId, String modelVersionId) {
type = widgetType;
this.name = name;
this.deleteFlag = deleteFlag;
+ this.modelInvariantId = modelInvariantId;
+ this.modelVersionId = modelVersionId;
}
/**
@@ -57,7 +57,7 @@ public class Widget extends Model {
* if there is no widget mapping defined for any of the VSERVER child types
*/
public Widget(Widget baseWidget) throws XmlArtifactGenerationException {
- this(baseWidget.getWidgetType(), baseWidget.getName(), baseWidget.getDeleteFlag());
+ this(baseWidget.getWidgetType(), baseWidget.getName(), baseWidget.getDeleteFlag(), baseWidget.getWidgetId(), baseWidget.getId());
if (this.hasWidgetType("VSERVER")) {
widgets.add(createWidget("FLAVOR"));
widgets.add(createWidget("IMAGE"));
@@ -97,13 +97,7 @@ public class Widget extends Model {
}
public String getId() {
- String id = WidgetConfigurationUtil.getConfig()
- .getProperty(ArtifactType.AAI.name() + ".model-version-id." + getName());
- if (id == null) {
- throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGLPROP_NOT_FOUND,
- ArtifactType.AAI.name() + ".model-version-id." + getName()));
- }
- return id;
+ return modelVersionId;
}
public ModelType getType() {
@@ -121,13 +115,7 @@ public class Widget extends Model {
*/
@Override
public String getWidgetId() {
- Properties properties = WidgetConfigurationUtil.getConfig();
- String id = properties.getProperty(ArtifactType.AAI.name() + ".model-invariant-id." + getName());
- if (id == null) {
- throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGLPROP_NOT_FOUND,
- ArtifactType.AAI.name() + ".model-invariant-id." + getName()));
- }
- return id;
+ return modelInvariantId;
}
@Override