aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java')
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java35
1 files changed, 29 insertions, 6 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;
+ }
}