diff options
Diffstat (limited to 'mso-catalog-db/src/main')
-rw-r--r-- | mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java | 212 | ||||
-rw-r--r-- | mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java | 2 |
2 files changed, 198 insertions, 16 deletions
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java index 46d0473746..c556ddadb5 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java @@ -36,6 +36,7 @@ import org.hibernate.Session; import org.openecomp.mso.db.AbstractSessionFactoryManager; import org.openecomp.mso.db.catalog.beans.AllottedResource; import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; +import org.openecomp.mso.db.catalog.beans.ArRecipe; import org.openecomp.mso.db.catalog.beans.HeatEnvironment; import org.openecomp.mso.db.catalog.beans.HeatFiles; import org.openecomp.mso.db.catalog.beans.HeatNestedTemplate; @@ -87,6 +88,7 @@ public class CatalogDatabase implements Closeable { private static final String VNF_COMPONENT_TYPE = "vnfComponentType"; private static final String MODEL_ID = "modelId"; private static final String MODEL_NAME = "modelName"; + private static final String MODEL_VERSION = "version"; private static final String TYPE = "type"; private static final String MODEL_TYPE = "modelType"; private static final String MODEL_VERSION_ID = "modelVersionId"; @@ -1129,6 +1131,8 @@ public class CatalogDatabase implements Closeable { return resultList.get(0); } + + /** * Return a VNF recipe that matches a given VNF_TYPE and ACTION * @@ -1161,6 +1165,63 @@ public class CatalogDatabase implements Closeable { LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); return resultList.get(0); } + + /** + * Return a VNF recipe that matches a given ModelName and Modelversion and ACTION + * + * @param modelName + * @param modelVersion + * @param action + * @return VnfRecipe object or null if none found + */ + public VnfRecipe getVnfRecipeByNameVersion(String modelName, String modelVersion, String action) { + StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action "); + + long startTime = System.currentTimeMillis(); + LOGGER.debug("Catalog database - get VNF recipe with name " + modelName + + " and action " + + action); + + Query query = getSession().createQuery(hql.toString()); + query.setParameter(VNF_TYPE, modelName); + query.setParameter(MODEL_VERSION, modelVersion); + query.setParameter(ACTION, action); + + @SuppressWarnings("unchecked") + List <VnfRecipe> resultList = query.list(); + + if (resultList.isEmpty()) { + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVnfRecipe", null); + return null; + } + + Collections.sort(resultList, new MavenLikeVersioningComparator()); + Collections.reverse(resultList); + + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); + return resultList.get(0); + } + + /** + * Return a Network recipe that matches a given MODEL_UUID and ACTION + * + * @param modelName + * @param action + * @return NetworkRecipe object or null if none found + */ + public VnfRecipe getVnfRecipeByModuleUuid (String vnfModelUuid, String action) { + LOGGER.debug ("Catalog database - get vnf recipe with vnf resource model uuid " + vnfModelUuid + + " and action " + + action + ); + VnfResource vnfResource = getVnfResourceByModelUuid(vnfModelUuid); + if(null == vnfResource){ + return null; + } + + VnfRecipe recipe = this.getVnfRecipeByNameVersion(vnfResource.getModelName(), vnfResource.getModelVersion(), action); + return recipe; + } /** * Return a VNF recipe that matches a given VF_MODULE_ID and ACTION @@ -1577,7 +1638,7 @@ public class CatalogDatabase implements Closeable { * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean * - * @param getVnfResourceCustomizationByModelVersionId + * @param modelVersionId * @return VnfResourceCustomization or null if not found */ public VnfResourceCustomization getVnfResourceCustomizationByModelVersionId(String modelVersionId) { @@ -1859,7 +1920,7 @@ public class CatalogDatabase implements Closeable { * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean * - * @param modelCustomizationUuid + * @param modelUuid * @return VnfResourceCustomization or null if not found */ public VnfResource getVnfResourceByModelUuid(String modelUuid) { @@ -2767,7 +2828,7 @@ public class CatalogDatabase implements Closeable { * Return a VNF Module List that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, * ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION * - * @param vnfModuleType + * @param vfModuleType * @parm modelCustomizationUuid * @param asdcServiceModelVersion * @param modelVersion @@ -3305,7 +3366,9 @@ public class CatalogDatabase implements Closeable { /** * Return a ServiceToResourceCustomization object * - * @param vfModuleModelUuid, heatFilesArtifactUuid + * @param serviceModelUuid + * @param resourceModelCustomizationUuid + * @param modelType * @return VfModuleToHeatFiles or null if none found */ public ServiceToResourceCustomization getServiceToResourceCustomization(String serviceModelUuid, String resourceModelCustomizationUuid, String modelType) { @@ -3331,7 +3394,7 @@ public class CatalogDatabase implements Closeable { /** * Return a Map<String, HeatFiles> for returning the heat files associated with a vfModule 1707 * - * @param parentHeatTemplateId + * @param vfModuleModelUuid * @return Map<String,Object> or null if none found */ public Map <String, HeatFiles> getHeatFilesForVfModule(String vfModuleModelUuid) { @@ -3547,7 +3610,7 @@ public class CatalogDatabase implements Closeable { /** * Retrieves a Heat environment from DB based on its unique key. 1707 * - * @param name the environment artifact name + * @param artifactUuid the environment artifact name * @param version the environment resource version * @return the heat environment from DB or null if not found */ @@ -3780,7 +3843,7 @@ public class CatalogDatabase implements Closeable { /** * Return the newest version of a specific Tosca CSAR Record resource (queried by Name). * - * @param ToscaCsar + * @param artifactChecksum * @return ToscaCsar object or null if none found */ public ToscaCsar getToscaCsar (String artifactChecksum) { @@ -4343,9 +4406,7 @@ public class CatalogDatabase implements Closeable { /** * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID * - * @param networkType - * @param action - * @param serviceType + * @param modelUUID * @return NetworkRecipe object or null if none found */ public NetworkResource getNetworkResourceByModelUuid(String modelUUID) { @@ -4425,6 +4486,26 @@ public class CatalogDatabase implements Closeable { } } + /** + * Return a Network recipe that matches a given MODEL_UUID and ACTION + * + * @param modelName + * @param action + * @return NetworkRecipe object or null if none found + */ + public NetworkRecipe getNetworkRecipeByModuleUuid (String networkModelUuid, String action) { + LOGGER.debug ("Catalog database - get network recipe with network model uuid " + networkModelUuid + + " and action " + + action + ); + NetworkResource networkResource = getNetworkResourceByModelUuid(networkModelUuid); + if(null == networkResource){ + return null; + } + + NetworkRecipe recipe = getNetworkRecipeByNameVersion(networkResource.getModelName(), networkResource.getModelVersion(), action); + return recipe; + } /** * Return a Network recipe that matches a given MODEL_NAME and ACTION @@ -4465,11 +4546,49 @@ public class CatalogDatabase implements Closeable { } /** + * get network recipe by module name and version and action. + * <br> + * + * @param modelName + * @param modelVersion + * @param action + * @return + * @since ONAP Beijing Release + */ + public NetworkRecipe getNetworkRecipeByNameVersion(String modelName, String modelVersion, String action) { + + long startTime = System.currentTimeMillis (); + LOGGER.debug ("Catalog database - get network recipe with network model name " + modelName + +"model version " + modelVersion + " and action " + action); + + try { + String hql = "FROM NetworkRecipe WHERE modelName = :modelName AND version=:version AND action = :action"; + + Query query = getSession ().createQuery (hql); + query.setParameter (MODEL_NAME, modelName); + query.setParameter (MODEL_VERSION, modelVersion); + query.setParameter (ACTION, action); + + @SuppressWarnings("unchecked") + List <NetworkRecipe> resultList = query.list (); + + if (resultList.isEmpty ()) { + return null; + } + + Collections.sort (resultList, new MavenLikeVersioningComparator ()); + Collections.reverse (resultList); + + return resultList.get (0); + } finally { + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); + } + } + + /** * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID * - * @param networkType - * @param action - * @param serviceType + * @param modelCustomizationUuid * @return NetworkRecipe object or null if none found */ public NetworkResource getNetworkResourceByModelCustUuid(String modelCustomizationUuid) { @@ -4558,7 +4677,7 @@ public class CatalogDatabase implements Closeable { /** * Return a VnfComponents recipe that matches a given VF_MODULE_ID, VNF_COMPONENT_TYPE, ACTION * - * @param vfModuleId + * @param vfModuleModelUUId * @param vnfComponentType * @param action * @return VnfComponentsRecipe object or null if none found @@ -4680,7 +4799,7 @@ public class CatalogDatabase implements Closeable { /** * Return a VfModule record that matches a given MODEL_NAME * - * @param modelName + * @param modelUUID * @return VfModule object or null if none found */ public VfModule getVfModuleByModelUUID (String modelUUID) { @@ -5009,4 +5128,67 @@ public class CatalogDatabase implements Closeable { } return theObjects; } + + + /** + * get allotted resource recipe by module name and version and action. + * <br> + * + * @param modelName + * @param modelVersion + * @param action + * @return + * @since ONAP Beijing Release + */ + public ArRecipe getArRecipeByNameVersion(String modelName, String modelVersion, String action) { + + long startTime = System.currentTimeMillis (); + LOGGER.debug ("Catalog database - get ar recipe with ar model name " + modelName + +"model version " + modelVersion + " and action " + action); + + try { + String hql = "FROM ArRecipe WHERE modelName = :modelName AND version=:version AND action = :action"; + + Query query = getSession ().createQuery (hql); + query.setParameter (MODEL_NAME, modelName); + query.setParameter (MODEL_VERSION, modelVersion); + query.setParameter (ACTION, action); + + @SuppressWarnings("unchecked") + List <ArRecipe> resultList = query.list (); + + if (resultList.isEmpty ()) { + return null; + } + + Collections.sort (resultList, new MavenLikeVersioningComparator ()); + Collections.reverse (resultList); + + return resultList.get (0); + } finally { + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); + } + } + + /** + * Return a allotted resource recipe that matches a given MODEL_UUID and ACTION + * + * @param modelName + * @param action + * @return ArRecipe object or null if none found + */ + public ArRecipe getArRecipeByModuleUuid (String ArModelUuid, String action) { + LOGGER.debug ("Catalog database - get ar recipe with ar model uuid " + ArModelUuid + + " and action " + + action + ); + AllottedResource arResource = this.getAllottedResourceByModelUuid(ArModelUuid); + if(null == arResource){ + return null; + } + + ArRecipe recipe = getArRecipeByNameVersion(arResource.getModelName(), arResource.getModelVersion(), action); + return recipe; + } + } diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java index 7f8c3dbacb..7ef5a4a7b9 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java @@ -89,7 +89,7 @@ public class ModelRecipe extends MavenLikeVersioning implements Serializable { } /** - * @param versionStr the versionStr to set + * @param schemaVersion the versionStr to set */ public void setSchemaVersion(String schemaVersion) { this.schemaVersion = schemaVersion; |