From 9c2559ce31cbd3610c097a0ba351473395e6389f Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 17 May 2019 10:16:07 +0530 Subject: Recipe retrieval for groups Recipe retrieval for groups. Change-Id: I2ba68777f3655ebc7794b75d357253022fe7739b Issue-ID: SO-1393 Signed-off-by: subhash kumar singh --- .../so/adapters/catalogdb/catalogrest/QueryGroups.java | 4 ++-- .../so/adapters/catalogdb/rest/CatalogDbAdapterRest.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java index c15b0d9df1..facdd2f4ca 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java @@ -77,9 +77,9 @@ public class QueryGroups extends CatalogQuery { if (instanceGroup != null) { put(valueMap, "MODEL_NAME", instanceGroup.getModelName()); - put(valueMap, "MODEL_UUID", instanceGroup.getModelInvariantUUID()); + put(valueMap, "MODEL_UUID", instanceGroup.getModelUUID()); put(valueMap, "MODEL_INVARIANT_ID", instanceGroup.getModelInvariantUUID()); - put(valueMap, "MODEL_VERSION", instanceGroup.getModelUUID()); + put(valueMap, "MODEL_VERSION", instanceGroup.getModelVersion()); } String subItem = new QueryVnfcs(vnfcCustomizationNull ? null : o.getVnfcCustomizations()).JSON2(true, true); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index 589f119337..f2e0762a79 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -48,6 +48,7 @@ import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs; import org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule; import org.onap.so.db.catalog.beans.AllottedResource; import org.onap.so.db.catalog.beans.AllottedResourceCustomization; +import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Recipe; @@ -55,11 +56,13 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ToscaCsar; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.AllottedResourceRepository; import org.onap.so.db.catalog.data.repository.ArRecipeRepository; +import org.onap.so.db.catalog.data.repository.InstanceGroupRepository; import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; @@ -120,6 +123,9 @@ public class CatalogDbAdapterRest { @Autowired private AllottedResourceRepository arResourceRepo; + @Autowired + private InstanceGroupRepository instanceGroupRepository; + private static final String NO_MATCHING_PARAMETERS = "no matching parameters"; public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) { @@ -536,6 +542,16 @@ public class CatalogDbAdapterRest { arResource.getModelVersion()); } } + + if (null == recipe) { + InstanceGroup grpResource = instanceGroupRepository.findByModelUUID(rmUuid); + if (grpResource != null) { + recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndActionAndVersionStr( + grpResource.getModelName(), action, grpResource.getModelVersion()); + } + + } + if (recipe != null) { QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe); entity = resourceRecipe.JSON2(false, false); -- cgit 1.2.3-korg