From a1cdcda28701f603cf95f591ba447bd723273622 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Fri, 27 Aug 2021 15:07:43 +0100 Subject: Include custom data types from VSP in csar imports When a model with custom data types is created, the data types are now being added as part of the default model imports files. When a CSAR is generated from a Service Template that is associated to a derived model, the default imports from the parent model are also included in the package. Change-Id: I027d25d7237989a40085edec7fdd399ac09c4db1 Issue-ID: SDC-3692 Signed-off-by: andre.schmid --- .../sdc/be/model/operations/impl/ModelOperation.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'catalog-model/src/main') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java index d522e10d7c..87ab3fc79d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java @@ -176,6 +176,25 @@ public class ModelOperation { toscaModelImportCassandraDao.importAll(modelId, toscaImportByModelList); } + /** + * Find all the model default imports, with the option to include the default imports from the parent model. + * + * @param modelId the model id + * @param includeParent a flag to include the parent model imports. + * @return the list of model default imports, or an empty list if no imports were found. + */ + public List findAllModelImports(final String modelId, final boolean includeParent) { + final List toscaImportByModelList = toscaModelImportCassandraDao.findAllByModel(modelId); + if (includeParent) { + findModelByName(modelId).ifPresent(model -> { + if (model.getDerivedFrom() != null) { + toscaImportByModelList.addAll(toscaModelImportCassandraDao.findAllByModel(model.getDerivedFrom())); + } + }); + } + return toscaImportByModelList; + } + /** * Finds all the models. * -- cgit 1.2.3-korg