diff options
author | andre.schmid <andre.schmid@est.tech> | 2021-08-31 10:04:26 +0100 |
---|---|---|
committer | andre.schmid <andre.schmid@est.tech> | 2021-08-31 10:20:06 +0100 |
commit | 38c6faa738abe6e0acdd24df2364d725d36fca40 (patch) | |
tree | 3412c0ee222d60bbc98a997390dbae19d55e3fc9 /catalog-be/src/main | |
parent | a1cdcda28701f603cf95f591ba447bd723273622 (diff) |
Fix additional types import file generation
The additional_type_definitions.yaml is missing types entries and
header.
Also, the solution is not considering the types entries, i.e.
'data_types:', 'policy_types:', etc., when replacing types and
generating the new file, which renders the solution broken.
This change aims to fix the related problems.
Change-Id: I412683b49966c09dd067ecbf8a1d778155b23fa6
Issue-ID: SDC-3703
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/main')
7 files changed, 16 insertions, 18 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManager.java index c0188d79c3..48b9c58d93 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManager.java @@ -25,10 +25,10 @@ import java.util.Map; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.components.impl.CommonImportManager.ElementTypeEnum; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.model.CapabilityTypeDefinition; import org.openecomp.sdc.be.model.Model; +import org.openecomp.sdc.be.model.normatives.ElementTypeEnum; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation; import org.openecomp.sdc.be.model.operations.impl.ModelOperation; @@ -63,7 +63,7 @@ public class CapabilityTypeImportManager { capabilityTypesYml, capabilityTypesFromYml -> createCapabilityTypesFromYml(capabilityTypesYml, modelName), this::upsertCapabilityTypesByDao, ElementTypeEnum.CAPABILITY_TYPE); if (includeToModelDefaultImports && StringUtils.isNotEmpty(modelName)) { - commonImportManager.addTypesToDefaultImports(capabilityTypesYml, modelName); + commonImportManager.addTypesToDefaultImports(ElementTypeEnum.CAPABILITY_TYPE, capabilityTypesYml, modelName); } return elementTypes; } @@ -86,7 +86,7 @@ public class CapabilityTypeImportManager { private Either<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, ResponseFormat> upsertCapabilityTypesByDao( List<CapabilityTypeDefinition> capabilityTypesToCreate) { return commonImportManager.createElementTypesByDao(capabilityTypesToCreate, capabilityType -> Either.left(ActionStatus.OK), - capabilityType -> new ImmutablePair<>(CommonImportManager.ElementTypeEnum.CAPABILITY_TYPE, + capabilityType -> new ImmutablePair<>(ElementTypeEnum.CAPABILITY_TYPE, UniqueIdBuilder.buildCapabilityTypeUid(capabilityType.getModel(), capabilityType.getType())), capabilityTypeOperation::getCapabilityType, capabilityTypeOperation::addCapabilityType, this::updateCapabilityType); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java index c0da9eb17b..f1582eecb1 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java @@ -48,6 +48,7 @@ import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.GroupTypeDefinition; import org.openecomp.sdc.be.model.PolicyTypeDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.normatives.ElementTypeEnum; import org.openecomp.sdc.be.model.normatives.ToscaTypeMetadata; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.api.TypeOperations; @@ -534,12 +535,8 @@ public class CommonImportManager { } - public void addTypesToDefaultImports(final String typesYaml, final String modelName) { - modelOperation.addTypesToDefaultImports(typesYaml, modelName); - } - - public enum ElementTypeEnum { - POLICY_TYPE, GROUP_TYPE, DATA_TYPE, CAPABILITY_TYPE, INTERFACE_LIFECYCLE_TYPE, RELATIONSHIP_TYPE + public void addTypesToDefaultImports(final ElementTypeEnum elementTypeEnum, final String typesYaml, final String modelName) { + modelOperation.addTypesToDefaultImports(elementTypeEnum, typesYaml, modelName); } public interface ICreateElementType<T1, T2, T3> { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java index b24d81bcbc..cad0f28477 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java @@ -30,13 +30,13 @@ import java.util.stream.Collectors; import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.components.impl.CommonImportManager.ElementTypeEnum; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.Model; import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.normatives.ElementTypeEnum; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.ModelOperation; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; @@ -66,7 +66,7 @@ public class DataTypeImportManager { dataTypeYml, dataTypesFromYml -> createDataTypesFromYml(dataTypeYml, modelName), this::createDataTypesByDao, ElementTypeEnum.DATA_TYPE); if (includeToModelDefaultImports && StringUtils.isNotEmpty(modelName)) { - commonImportManager.addTypesToDefaultImports(dataTypeYml, modelName); + commonImportManager.addTypesToDefaultImports(ElementTypeEnum.DATA_TYPE, dataTypeYml, modelName); } return elementTypes; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java index e043bc2619..8ff7d994e2 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java @@ -27,7 +27,6 @@ import java.util.Optional; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.components.impl.CommonImportManager.ElementTypeEnum; import org.openecomp.sdc.be.components.impl.model.ToscaTypeImportData; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -39,6 +38,7 @@ import org.openecomp.sdc.be.model.GroupTypeDefinition; import org.openecomp.sdc.be.model.Model; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; +import org.openecomp.sdc.be.model.normatives.ElementTypeEnum; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation; import org.openecomp.sdc.be.model.operations.impl.ModelOperation; @@ -74,7 +74,7 @@ public class GroupTypeImportManager { final Either<List<ImmutablePair<GroupTypeDefinition, Boolean>>, ResponseFormat> elementTypes = commonImportManager.createElementTypes( toscaTypeImportData, this::createGroupTypesFromYml, this::upsertGroupTypesByDao, modelName); if (includeToModelDefaultImports && StringUtils.isNotEmpty(modelName)) { - commonImportManager.addTypesToDefaultImports(toscaTypeImportData.getToscaTypesYml(), modelName); + commonImportManager.addTypesToDefaultImports(ElementTypeEnum.GROUP_TYPE, toscaTypeImportData.getToscaTypesYml(), modelName); } return elementTypes; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java index 5cc8985b90..b757faf491 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java @@ -39,6 +39,7 @@ import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.Model; import org.openecomp.sdc.be.model.Operation; +import org.openecomp.sdc.be.model.normatives.ElementTypeEnum; import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.ModelOperation; @@ -72,7 +73,7 @@ public class InterfaceLifecycleTypeImportManager { } final Either<List<InterfaceDefinition>, ResponseFormat> elementTypes = createInterfacesByDao(interfaces.left().value()); if (includeToModelDefaultImports && StringUtils.isNotEmpty(modelName)) { - commonImportManager.addTypesToDefaultImports(interfaceLifecycleTypesYml, modelName); + commonImportManager.addTypesToDefaultImports(ElementTypeEnum.INTERFACE_LIFECYCLE_TYPE, interfaceLifecycleTypesYml, modelName); } return elementTypes; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java index 54d57800be..be34cce3e4 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java @@ -26,7 +26,6 @@ import java.util.Optional; import java.util.function.Consumer; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.components.impl.CommonImportManager.ElementTypeEnum; import org.openecomp.sdc.be.components.impl.model.ToscaTypeImportData; import org.openecomp.sdc.be.components.impl.utils.PolicyTypeImportUtils; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -36,6 +35,7 @@ import org.openecomp.sdc.be.model.GroupTypeDefinition; import org.openecomp.sdc.be.model.Model; import org.openecomp.sdc.be.model.PolicyTypeDefinition; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; +import org.openecomp.sdc.be.model.normatives.ElementTypeEnum; import org.openecomp.sdc.be.model.operations.api.IPolicyTypeOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.GroupOperation; @@ -75,7 +75,7 @@ public class PolicyTypeImportManager { final Either<List<ImmutablePair<PolicyTypeDefinition, Boolean>>, ResponseFormat> elementTypes = commonImportManager.createElementTypes( toscaTypeImportData, this::createPolicyTypesFromYml, this::upsertPolicyTypesByDao, modelName); if (includeToModelDefaultImports && StringUtils.isNotEmpty(modelName)) { - commonImportManager.addTypesToDefaultImports(toscaTypeImportData.getToscaTypesYml(), modelName); + commonImportManager.addTypesToDefaultImports(ElementTypeEnum.POLICY_TYPE, toscaTypeImportData.getToscaTypesYml(), modelName); } return elementTypes; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManager.java index 564eb3a794..1bd19143c6 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManager.java @@ -21,11 +21,11 @@ import java.util.Map; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.components.impl.CommonImportManager.ElementTypeEnum; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.Model; import org.openecomp.sdc.be.model.RelationshipTypeDefinition; +import org.openecomp.sdc.be.model.normatives.ElementTypeEnum; import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; import org.openecomp.sdc.be.model.operations.impl.ModelOperation; import org.openecomp.sdc.be.model.operations.impl.RelationshipTypeOperation; @@ -67,7 +67,7 @@ public class RelationshipTypeImportManager { relationshipTypesToCreate -> createRelationshipTypesByDao(relationshipTypesToCreate, inTransaction), ElementTypeEnum.RELATIONSHIP_TYPE); if (includeToModelDefaultImports && StringUtils.isNotEmpty(modelName)) { - commonImportManager.addTypesToDefaultImports(relationshipTypeYml, modelName); + commonImportManager.addTypesToDefaultImports(ElementTypeEnum.RELATIONSHIP_TYPE, relationshipTypeYml, modelName); } return elementTypes; } |