From 8b6be264a6f4b658632b7e263737eaae92e337aa Mon Sep 17 00:00:00 2001 From: talio Date: Thu, 15 Mar 2018 14:46:20 +0200 Subject: Interface definition Add separate Interface definition for node type and node template Change-Id: I0c4446227dd096959158fd4a4741cb5aa043e495 Issue-ID: SDC-1043 Signed-off-by: talio --- .../sdc/tosca/services/DataModelUtil.java | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main/java') diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java index aef23be03f..6b1046bb45 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java @@ -40,6 +40,7 @@ import org.openecomp.sdc.tosca.datatypes.model.EntrySchema; import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition; import org.openecomp.sdc.tosca.datatypes.model.Import; import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinition; +import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinitionType; import org.openecomp.sdc.tosca.datatypes.model.InterfaceType; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.datatypes.model.NodeType; @@ -1212,33 +1213,32 @@ public class DataModelUtil { return convertedInterfaceTypes; } - public static Optional convertObjToInterfaceDefinition( - String interfaceId, Object interfaceObj) - throws CoreException { + public static Optional + convertObjToInterfaceDefinition( + String interfaceId, Object interfaceObj, Class interfaceClass) { try { - Optional interfaceDefinition = - CommonUtil.createObjectUsingSetters(interfaceObj, InterfaceDefinition.class); - interfaceDefinition.ifPresent(interfaceDefinition1 -> updateInterfaceDefinitionOperations( + Optional interfaceDefinition = + CommonUtil.createObjectUsingSetters(interfaceObj, interfaceClass); + interfaceDefinition.ifPresent(interfaceDefinitionType1 -> updateInterfaceDefinitionOperations( CommonUtil.getObjectAsMap(interfaceObj), - interfaceDefinition1)); + interfaceDefinitionType1)); return interfaceDefinition; } catch (Exception ex) { throw new CoreException( - new CreateInterfaceObjectErrorBuilder(InterfaceDefinition.class.getName(), interfaceId, + new CreateInterfaceObjectErrorBuilder(InterfaceDefinitionType.class.getName(), interfaceId, ex.getMessage()).build()); } } public static Optional convertInterfaceDefinitionToObj( - InterfaceDefinition interfaceDefinition) { - return converInetrfaceToToscaInterfaceObj(interfaceDefinition); + InterfaceDefinitionType interfaceDefinitionType) { + return converInetrfaceToToscaInterfaceObj(interfaceDefinitionType); } public static Optional convertObjToInterfaceType(String interfaceId, - Object interfaceObj) - throws CoreException { + Object interfaceObj) { try { Optional interfaceType = CommonUtil.createObjectUsingSetters(interfaceObj, InterfaceType.class); @@ -1289,8 +1289,7 @@ public class DataModelUtil { private static Optional createOperation(String propertyName, Object operationCandidate, - Set fieldNames) - throws CoreException { + Set fieldNames) { if (!fieldNames.contains(propertyName)) { try { return CommonUtil.createObjectUsingSetters(operationCandidate, OperationDefinition.class); @@ -1306,7 +1305,7 @@ public class DataModelUtil { private static void updateInterfaceDefinitionOperations(Map interfaceAsMap, InterfaceDefinition interfaceDefinition) { - Set fieldNames = CommonUtil.getClassFieldNames(InterfaceDefinition.class); + Set fieldNames = CommonUtil.getClassFieldNames(InterfaceDefinitionType.class); for (Map.Entry entry : interfaceAsMap.entrySet()) { Optional operationDefinition = -- cgit 1.2.3-korg