diff options
author | shiria <shiri.amichai@amdocs.com> | 2018-03-19 15:23:23 +0200 |
---|---|---|
committer | shiria <shiri.amichai@amdocs.com> | 2018-03-22 08:21:36 +0200 |
commit | 43187c8495b88589f3187e110cf8d592a091c37f (patch) | |
tree | 87ffaf38a95344d76547478f0306b2a923896e44 /openecomp-be/lib/openecomp-tosca-lib/src/main/java/org | |
parent | d049ca05bbfb6fa6b86b2a093b09ffc1fc0a6e37 (diff) |
Update FlatEntity in TOSCA
Add support of dataType entity flat hierarchy in TOSCA
Fix existing nodeType entity flat hierarchy in TOSCA
Change-Id: I52cd188c595a263c70c2067fd1aac9752f7e24a4
Issue-ID: SDC-1147
Signed-off-by: shiria <shiri.amichai@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main/java/org')
3 files changed, 84 insertions, 7 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaInterfaceType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaInterfaceType.java new file mode 100644 index 0000000000..6a74f765e6 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaInterfaceType.java @@ -0,0 +1,31 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openecomp.sdc.tosca.datatypes; + +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; + +public class ToscaInterfaceType { + + private static Configuration config = ConfigurationManager.lookup(); + + //TOSCA native types + public static final String NATIVE_ROOT = " tosca.interfaces.Root"; + public static final String NATIVE_LIFECYCLE_STANDARD = "tosca.interfaces.node.lifecycle.Standard"; + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java index 1aa171961f..5d4b7dfa00 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ public class ToscaConstants { //General public static final String TOSCA_DEFINITIONS_VERSION = "tosca_simple_yaml_1_0_0"; public static final String MODELABLE_ENTITY_NAME_SELF = "SELF"; + public static final String MODELABLE_ENTITY_NAME_HOST = "HOST"; public static final String NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE = "substitutable"; public static final String NATIVE_TYPES_SERVICE_TEMPLATE_NAME = "NativeTypesServiceTemplate"; public static final String UNBOUNDED = "UNBOUNDED"; @@ -55,6 +56,7 @@ public class ToscaConstants { public static final String SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME = "substitute_service_template"; public static final String COUNT_PROPERTY_NAME = "count"; + public static final String MANDATORY_PROPERTY_NAME = "mandatory"; public static final String INDEX_VALUE_PROPERTY_NAME = "index_value"; public static final String SCALING_ENABLED_PROPERTY_NAME = "scaling_enabled"; @@ -73,9 +75,10 @@ public class ToscaConstants { public static final String VF_MODULE_LABEL_PROPERTY_NAME = "vf_module_label"; public static final String PARAM_NAME_PROPERTY_NAME = "param_name"; - // propertiies valid values + // properties valid values public static final String HEAT_SOURCE_TYPE = "HEAT"; public static final String GENERIC_SOURCE_TYPE = "Generic"; + } 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 6f514c03fe..411c50db5b 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 @@ -27,6 +27,7 @@ import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition; import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; import org.openecomp.sdc.tosca.datatypes.model.CapabilityType; import org.openecomp.sdc.tosca.datatypes.model.DefinitionOfDataType; +import org.openecomp.sdc.tosca.datatypes.model.DataType; import org.openecomp.sdc.tosca.datatypes.model.Import; import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinitionType; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; @@ -422,14 +423,20 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { case NODE_TYPE: returnEntity = new NodeType(); break; + case DATA_TYPE: + returnEntity = new DataType(); + break; default: throw new RuntimeException( "Entity[" + elementType + "] id[" + typeId + "] flat not supported"); } - scanAnFlatEntity(elementType, typeId, returnEntity, serviceTemplate, toscaModel, - new ArrayList<>(), 0); - + boolean isEntityFound = + scanAnFlatEntity(elementType, typeId, returnEntity, serviceTemplate, toscaModel, + new ArrayList<>(), 0); + if (!isEntityFound) { + throw new CoreException(new ToscaElementTypeNotFoundErrorBuilder(typeId).build()); + } return returnEntity; } @@ -635,6 +642,12 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { return false; } break; + case DATA_TYPE: + if (enrichDataTypeInfo(elementType, typeId, entity, serviceTemplate, toscaModel, + filesScanned, rootScanStartInx)) { + return false; + } + break; default: throw new RuntimeException( "Entity[" + elementType + "] id[" + typeId + "] flat not supported"); @@ -667,6 +680,28 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { return false; } + private boolean enrichDataTypeInfo(ToscaElementTypes elementType, String typeId, Object entity, + ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel, + List<String> filesScanned, int rootScanStartInx) { + String derivedFrom; + if (serviceTemplate.getData_types() != null + && serviceTemplate.getData_types().containsKey(typeId)) { + + filesScanned.clear(); + DataType targetDataType = (DataType) entity; + DataType sourceDataType = serviceTemplate.getData_types().get(typeId); + derivedFrom = sourceDataType.getDerived_from(); + if (derivedFrom != null) { + scanAnFlatEntity(elementType, derivedFrom, entity, serviceTemplate, toscaModel, + filesScanned, rootScanStartInx); + } + combineDataTypeInfo(sourceDataType, targetDataType); + } else { + return true; + } + return false; + } + private boolean enrichCapabilityType(ToscaElementTypes elementType, String typeId, Object entity, ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel, List<String> filesScanned, @@ -709,6 +744,16 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { } + private void combineDataTypeInfo(DataType sourceDataType, DataType targetDataType) { + targetDataType.setDerived_from(sourceDataType.getDerived_from()); + targetDataType.setDescription(sourceDataType.getDescription()); + targetDataType.setVersion(sourceDataType.getVersion()); + targetDataType.setProperties( + CommonMethods.mergeMaps(targetDataType.getProperties(), sourceDataType.getProperties())); + targetDataType.setConstraints( + CommonMethods.mergeLists(targetDataType.getConstraints(), sourceDataType.getConstraints())); + } + private void combineCapabilityTypeInfo(CapabilityType sourceCapabilityType, CapabilityType targetCapabilityType) { @@ -883,6 +928,4 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { throw new RuntimeException(e); } } - - } |