diff options
author | shiria <shiri.amichai@amdocs.com> | 2018-07-09 08:36:15 +0300 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-07-11 05:49:02 +0000 |
commit | 35767f3c6ea98e643e2d0bc638fa87ac1ef65808 (patch) | |
tree | aca9484cb7f81c3074539d4b5854ec0193b8928e /openecomp-be/lib/openecomp-tosca-lib/src/main/java/org | |
parent | 6acf9fb74dc9ee8d93c4f5c6040876dada27beb2 (diff) |
Add support for CapabilityDefinition isTypeOf
Change-Id: Id84b5b67ef85b6e252676f1004184fb3180cd053
Issue-ID: SDC-1475
Signed-off-by: shiria <shiri.amichai@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main/java/org')
2 files changed, 19 insertions, 8 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java index 34f5a905fd..97d2a7f8ff 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java @@ -54,6 +54,9 @@ public interface ToscaAnalyzerService { boolean isTypeOf(DefinitionOfDataType parameterDefinition, String dataType, ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel); + boolean isTypeOf(CapabilityDefinition capabilityDefinition, String capabilityType, ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel); + List<RequirementAssignment> getRequirements(NodeTemplate nodeTemplate, String requirementId); Optional<NodeTemplate> getNodeTemplateById(ServiceTemplate serviceTemplate, String nodeTemplateId); diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java index 5e0f2f2e41..2d0d3fb59c 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java @@ -38,13 +38,14 @@ import java.util.*; public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { - private final String GET_NODE_TYPE_METHOD_NAME = "getNode_types"; - private final String GET_DERIVED_FROM_METHOD_NAME = "getDerived_from"; - private final String GET_TYPE_METHOD_NAME = "getType"; - private final String GET_DATA_TYPE_METHOD_NAME = "getData_types"; - private final String GET_INTERFACE_TYPE_METHOD_NAME = "getInterface_types"; - private final String TOSCA_DOT = "tosca."; - private final String DOT_ROOT = ".Root"; + private static final String GET_NODE_TYPE_METHOD_NAME = "getNode_types"; + private static final String GET_DERIVED_FROM_METHOD_NAME = "getDerived_from"; + private static final String GET_TYPE_METHOD_NAME = "getType"; + private static final String GET_DATA_TYPE_METHOD_NAME = "getData_types"; + private static final String GET_INTERFACE_TYPE_METHOD_NAME = "getInterface_types"; + private static final String GET_CAPABILITY_TYPE_METHOD_NAME = "getCapability_types"; + private static final String TOSCA_DOT = "tosca."; + private static final String DOT_ROOT = ".Root"; @Override public List<Map<String, RequirementDefinition>> calculateExposedRequirements(List<Map<String, RequirementDefinition>> nodeTypeRequirementsDefinitionList, @@ -925,6 +926,13 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { return isTypeOf(parameterDefinition, dataType, GET_DATA_TYPE_METHOD_NAME, serviceTemplate, toscaServiceModel); } + @Override + public boolean isTypeOf(CapabilityDefinition capabilityDefinition, String capabilityType, + ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) { + return isTypeOf(capabilityDefinition, capabilityType, GET_CAPABILITY_TYPE_METHOD_NAME, serviceTemplate, toscaServiceModel); + } + + private <T> boolean isTypeOf(T object, String type, String getTypesMethodName, ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) { if (object == null) { @@ -944,7 +952,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { () -> new CoreException(new ToscaElementTypeNotFoundErrorBuilder(objectType).build())); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - throw new RuntimeException(e); + throw new SdcRuntimeException(e); } } } |