From b213e23edf68d36b4c0984d94d38d444f96949e2 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Thu, 4 Oct 2018 07:06:41 +0100 Subject: Fix creation of sub Avro items When an Avro object is created, nested sub avro objects are not created automatically. This change allows invocation of a method to create sub objects of Avro objects. Issue-ID: POLICY-954 Change-Id: Ie510867f2631ba6a8c6f5452c08aef5db67e8997 Signed-off-by: liamfallon --- .../src/main/java/org/onap/policy/apex/context/SchemaHelper.java | 8 ++++++++ .../policy/apex/context/impl/schema/AbstractSchemaHelper.java | 9 +++++++++ .../policy/apex/context/impl/schema/java/JavaSchemaHelper.java | 1 - 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'context/context-management/src/main') diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/SchemaHelper.java b/context/context-management/src/main/java/org/onap/policy/apex/context/SchemaHelper.java index 44ec06c6d..b6d21a20d 100644 --- a/context/context-management/src/main/java/org/onap/policy/apex/context/SchemaHelper.java +++ b/context/context-management/src/main/java/org/onap/policy/apex/context/SchemaHelper.java @@ -91,6 +91,14 @@ public interface SchemaHelper { */ Object createNewInstance(Object incomingObject); + /** + * Create an object of a sub type of this object. + * + * @param subType the sub type definition of this type + * @return a new object of the sub type + */ + Object createNewSubInstance(String subType); + /** * Unmarshal an object in schema format into a Java object. * diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java index f50eb5914..6d98313ed 100644 --- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java +++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java @@ -22,6 +22,7 @@ package org.onap.policy.apex.context.impl.schema; import java.lang.reflect.Constructor; +import org.apache.commons.lang3.NotImplementedException; import org.onap.policy.apex.context.ContextRuntimeException; import org.onap.policy.apex.context.SchemaHelper; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; @@ -169,4 +170,12 @@ public abstract class AbstractSchemaHelper implements SchemaHelper { throw new ContextRuntimeException(returnString); } } + + /* (non-Javadoc) + * @see org.onap.policy.apex.context.SchemaHelper#createNewSubInstance(java.lang.String) + */ + @Override + public Object createNewSubInstance(String subType) { + throw new NotImplementedException("sub types are not supported on this schema helper"); + } } diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java index 8b61f718a..fcc7c4d60 100644 --- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java +++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java @@ -279,5 +279,4 @@ public class JavaSchemaHelper extends AbstractSchemaHelper { return gsonBuilder.create(); } - } -- cgit 1.2.3-korg