diff options
-rw-r--r-- | src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java | 9 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java | 12 |
2 files changed, 19 insertions, 2 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 7683f7c..df5224c 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 @@ -31,8 +31,8 @@ import java.util.Optional; import java.util.Properties; import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException; import org.onap.aai.babel.xml.generator.model.Resource; -import org.onap.aai.babel.xml.generator.model.WidgetType; import org.onap.aai.babel.xml.generator.model.Widget; +import org.onap.aai.babel.xml.generator.model.WidgetType; import org.onap.aai.babel.xml.generator.types.ModelType; public class WidgetConfigurationUtil { @@ -66,7 +66,12 @@ public class WidgetConfigurationUtil { } public static Optional<Resource> createModelFromType(String typePrefix) { - return Optional.ofNullable(typeToResource.get(typePrefix)); + Optional<Resource> resource = Optional.ofNullable(typeToResource.get(typePrefix)); + if (resource.isPresent()) { + // Make a copy of the Resource found in the mappings table. + return Optional.of(new Resource(resource.get())); + } + return resource; } public static Widget createWidgetFromType(String widgetType) throws XmlArtifactGenerationException { diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java index f5f7c50..89d02bb 100644 --- a/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java +++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java @@ -44,6 +44,16 @@ public class Resource extends Model { this.deleteFlag = deleteFlag; } + /** + * Copy Constructor. + * + * @param baseResource + */ + public Resource(Resource baseResource) { + this(baseResource.getWidgetType(), baseResource.getDeleteFlag()); + setModelType(baseResource.getModelType()); + } + @Override public int hashCode() { final String uuid = getModelNameVersionId(); @@ -113,10 +123,12 @@ public class Resource extends Model { } } + @Override public WidgetType getWidgetType() { return type; } + @Override public String getModelTypeName() { return "resource"; } |