diff options
author | 2018-07-30 15:56:09 -0400 | |
---|---|---|
committer | 2018-07-31 11:09:25 -0400 | |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /mso-catalog-db/src/main/java/org/openecomp | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-catalog-db/src/main/java/org/openecomp')
38 files changed, 0 insertions, 9596 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 deleted file mode 100644 index af0ea101f4..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java +++ /dev/null @@ -1,5203 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog; - -import java.io.Closeable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.hibernate.HibernateException; -import org.hibernate.Query; -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; -import org.openecomp.mso.db.catalog.beans.HeatTemplate; -import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; -import org.openecomp.mso.db.catalog.beans.Model; -import org.openecomp.mso.db.catalog.beans.ModelRecipe; -import org.openecomp.mso.db.catalog.beans.NetworkRecipe; -import org.openecomp.mso.db.catalog.beans.NetworkResource; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; -import org.openecomp.mso.db.catalog.beans.ServiceRecipe; -import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources; -import org.openecomp.mso.db.catalog.beans.ServiceToNetworks; -import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization; -import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup; -import org.openecomp.mso.db.catalog.beans.ToscaCsar; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; -import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles; -import org.openecomp.mso.db.catalog.beans.VnfComponent; -import org.openecomp.mso.db.catalog.beans.VnfComponentsRecipe; -import org.openecomp.mso.db.catalog.beans.VnfRecipe; -import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioningComparator; -import org.openecomp.mso.db.catalog.utils.RecordNotFoundException; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * This class encapsulates all of the objects that can be queried from a Catalog database. - * Clients must use these methods to retrieve catalog objects. The session is not - * available for clients to do their own direct queries to the database. - * - * - */ -public class CatalogDatabase implements Closeable { - - protected final AbstractSessionFactoryManager sessionFactoryCatalogDB; - - private static final String NETWORK_TYPE = "networkType"; - private static final String ACTION = "action"; - private static final String VNF_TYPE = "vnfType"; - private static final String SERVICE_TYPE = "serviceType"; - private static final String MODEL_UUID= "modelUUID"; - 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"; - private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUuid"; - private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUId"; - private static final String NETWORK_SERVICE = "network service"; - private static final String TEMPLATE_NAME = "template_name"; - private static final String GET_VNF_RECIPE = "getVnfRecipe"; - - protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - - protected Session session = null; - - protected CatalogDatabase (AbstractSessionFactoryManager sessionFactoryCatalog) { - sessionFactoryCatalogDB = sessionFactoryCatalog; - } - - public static CatalogDatabase getInstance() { - return new CatalogDatabase(new CatalogDbSessionFactoryManager ()); - } - - private Session getSession () { - - if (session == null) { - try { - session = sessionFactoryCatalogDB.getSessionFactory ().openSession (); - session.beginTransaction (); - } catch (HibernateException he) { - LOGGER.error (MessageEnum.GENERAL_EXCEPTION_ARG, "Error creating Hibernate Session: " + he, "", "", MsoLogger.ErrorCode.DataError, "Error creating Hibernate Session: " + he); - throw he; - } - } - - return session; - } - - - /** - * Close an open Catalog Database session. - * This method should always be called when a client is finished using a - * CatalogDatabase instance. - */ - @Override - public void close () { - if (session != null) { - session.close (); - session = null; - } - } - - /** - * Commits the current transaction on this session and starts a fresh one. - */ - public void commit () { - getSession ().getTransaction ().commit (); - getSession ().beginTransaction (); - } - - /** - * Rolls back current transaction and starts a fresh one. - */ - public void rollback () { - getSession ().getTransaction ().rollback (); - getSession ().beginTransaction (); - } - - /** - * Return all Heat Templates in the Catalog DB - * - * @return A list of HeatTemplate objects - */ - @SuppressWarnings("unchecked") - public List <HeatTemplate> getAllHeatTemplates() { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get all Heat templates"); - String hql = "FROM HeatTemplate"; - Query query = getSession().createQuery(hql); - - List <HeatTemplate> result = query.list(); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllHeatTemplates", null); - return result; - } - - /** - * Fetch a specific Heat Template by ID. - * - * @param templateId template id - * @return HeatTemplate object or null if none found - */ - @Deprecated - public HeatTemplate getHeatTemplate(int templateId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get Heat template with id " + templateId); - - HeatTemplate template = (HeatTemplate) getSession().get(HeatTemplate.class, templateId); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return template; - } - - /** - * Return the newest version of a specific Heat Template (queried by Name). - * - * @param templateName template name - * @return HeatTemplate object or null if none found - */ - public HeatTemplate getHeatTemplate(String templateName) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Heat template with name " + templateName); - - String hql = "FROM HeatTemplate WHERE templateName = :template_name"; - Query query = getSession().createQuery (hql); - query.setParameter(TEMPLATE_NAME, templateName); - - @SuppressWarnings("unchecked") - List <HeatTemplate> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found", "CatalogDB", "getHeatTemplate", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return resultList.get(0); - } - - /** - * Return a specific version of a specific Heat Template (queried by Name). - * - * @param templateName - * @param version - * @return HeatTemplate object or null if none found - */ - public HeatTemplate getHeatTemplate(String templateName, String version) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Heat template with name " + templateName - + " and version " - + version); - - String hql = "FROM HeatTemplate WHERE templateName = :template_name AND version = :version"; - Query query = getSession().createQuery(hql); - query.setParameter(TEMPLATE_NAME, templateName); - query.setParameter(MODEL_VERSION, version); - - @SuppressWarnings("unchecked") - List <HeatTemplate> resultList = query.list(); - - // See if something came back. - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found.", "CatalogDB", "getHeatTemplate", null); - return null; - } - // Name + Version is unique, so should only be one element - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return resultList.get(0); - } - - /** - * Return a specific Heat Template by ARTIFACT_UUID). - * - * @param artifactUuid - * @return HeatTemplate object or null if none found - */ - - public HeatTemplate getHeatTemplateByArtifactUuid(String artifactUuid) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Heat template with artifactUuid " + artifactUuid); - - // Will this work if the id is a string? - HeatTemplate template = (HeatTemplate) getSession ().get (HeatTemplate.class, artifactUuid); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return template; - } - - /** - * Return a specific Heat Template by ARTIFACT_UUID using standard query method. unique record expected. - * - * @param artifactUuid - * @return HeatTemplate object or null if none found - */ - public HeatTemplate getHeatTemplateByArtifactUuidRegularQuery(String artifactUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Heat template (regular query) with artifactUuid " + artifactUuid); - - String hql = "FROM HeatTemplate WHERE artifactUuid = :artifactUuidValue"; - HashMap<String, String> variables = new HashMap<>(); - variables.put("artifactUuidValue", artifactUuid); - HeatTemplate template = (HeatTemplate) this.executeQuerySingleRow(hql, variables, true); - - if (template == null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null); - } else { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplateByArtifactUuidRegularQuery", null); - } - return template; - } - - public List<HeatTemplateParam> getParametersForHeatTemplate(String heatTemplateArtifactUuid) { - LOGGER.debug ("Catalog database - getParametersForHeatTemplate with artifactUuid " + heatTemplateArtifactUuid); - - String hql = "FROM HeatTemplateParams WHERE artifactUuid = :artifactUuidValue"; - Query query = getSession().createQuery(hql); - query.setParameter ("artifactUuidValue", heatTemplateArtifactUuid); - List<HeatTemplateParam> resultList = new ArrayList<>(); - try { - resultList = query.list (); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching HeatTemplateParams for: heatTemplateArtifactUuid='" + heatTemplateArtifactUuid + "'" + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching HeatTemplateParams for artifactUuid=" + heatTemplateArtifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for artifactUuid=" + heatTemplateArtifactUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching HeatTemplateParam for: artifactUuid='" + heatTemplateArtifactUuid + "'" + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching HeatTemplate for artifactUuid=" + heatTemplateArtifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for artifactUuid=" + heatTemplateArtifactUuid); - throw e; - } - - return resultList; - - } - - /** - * Return a specific Heat Environment by ARTIFACT_UUID using standard query method. unique record expected. - * - * @param artifactUuid - * @return HeatEnvironment object or null if none found - */ - public HeatEnvironment getHeatEnvironmentByArtifactUuid(String artifactUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Heat Environment with artifactUuid " + artifactUuid); - - String hql = "FROM HeatEnvironment WHERE artifactUuid = :artifactUuidValue"; - Query query = getSession().createQuery(hql); - query.setParameter("artifactUuidValue", artifactUuid); - HeatEnvironment environment = null; - try { - environment = (HeatEnvironment) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row for Envt - data integrity error: artifactUuid='" + artifactUuid +"'", nure); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for heatEnvironment artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for artifactUuid==" + artifactUuid); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for envt: artifactUuid='" + artifactUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching envt for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching envt for artifactUuid=" + artifactUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: artifactUuid='" + artifactUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching envt for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching envt for artifactUuid=" + artifactUuid); - - throw e; - } - - if (environment == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatEnvironmentByArtifactUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatEnvironmentByArtifactUuid", null); - } - return environment; - } - - /** - * Fetch a Service definition by InvariantUUID - */ - public Service getServiceByInvariantUUID (String modelInvariantUUID) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with Invariant UUID " + modelInvariantUUID); - - String hql = "FROM Service WHERE modelInvariantUUID = :model_invariant_uuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("model_invariant_uuid", modelInvariantUUID); - - @SuppressWarnings("unchecked") - List <Service> resultList = query.list (); - - // See if something came back. - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByName", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByName", null); - return resultList.get (0); - } - - /** - * Fetch a Service definition - */ - public Service getService (String modelName) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with name " + modelName); - - String hql = "FROM Service WHERE modelName = :MODEL_NAME"; - Query query = getSession().createQuery(hql); - query.setParameter("MODEL_NAME", modelName); - - Service service = null; - try { - service = (Service) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelName='" + modelName + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelName=" + modelName, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelName=" + modelName); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelName='" + modelName + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelName=" + modelName, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelName=" + modelName); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelName='" + modelName + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelName=" + modelName, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelName=" + modelName); - throw e; - } - if (service == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getService", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getService", null); - } - - return service; - } - - public Service getServiceByModelUUID (String modelUUID) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with Model UUID " + modelUUID); - - String hql = "FROM Service WHERE modelUUID = :MODEL_UUID"; - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("MODEL_UUID", modelUUID); - - - Service service = this.executeQuerySingleRow(hql, parameters, true); - - /* - try { - service = (Service) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelUUID='" + modelUUID + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelUUID=" + modelUUID, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelUUID=" + modelUUID); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelUUID='" + modelUUID + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelUUID=" + modelUUID, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelUUID=" + modelUUID); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelUUID='" + modelUUID + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelUUID=" + modelUUID, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelUUID=" + modelUUID); - throw e; - } - */ - if (service == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getServiceByModelUUID", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelUUID", null); - } - - return service; - } - - /** - * Fetch the Common Service API definition using Http Method + serviceNameVersionId - */ - public Service getService(Map<String, String> map, String httpMethod) { - - String serviceNameVersionId = map.get("serviceNameVersionId"); - Query query; - String serviceId = "not_set"; - String serviceVersion = "not_set"; - - if(serviceNameVersionId != null && serviceNameVersionId.length() > 0){ - LOGGER.debug ("Catalog database - get service modelUUID with id " + serviceNameVersionId); - - String hql = "FROM Service WHERE MODEL_UUID = :MODEL_UUID and http_method = :http_method"; - query = getSession().createQuery(hql); - query.setParameter("MODEL_UUID", serviceNameVersionId); - } else { - serviceId = map.get("serviceId"); - serviceVersion = map.get("serviceVersion"); - LOGGER.debug("Catalog database - get serviceId with id " + serviceId + " and serviceVersion with " + serviceVersion); - - String hql = "FROM Service WHERE service_id = :service_id and service_version = :service_version and http_method = :http_method"; - query = getSession().createQuery(hql); - query.setParameter("service_id", serviceId); - query.setParameter("service_version", serviceVersion); - } - - query.setParameter("http_method", httpMethod); - - long startTime = System.currentTimeMillis(); - Service service = null; - try { - service = (Service) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - data integrity error: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for service_id=" + serviceId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for service_id=" + serviceId); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for service_id=" + serviceId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for service_id=" + serviceId); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for service_id=" + serviceId + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for service_id=" + serviceId); - - throw e; - } - if (service == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getService", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getService", null); - } - return service; - } - - /** - * Return the newest version of a Service (queried by Name). - * - * @param modelName - * @return Service object or null if none found - */ - public Service getServiceByModelName(String modelName){ - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with name " + modelName); - - String hql = "FROM Service WHERE modelName = :MODEL_NAME"; - Query query = getSession().createQuery(hql); - query.setParameter("MODEL_NAME", modelName); - - @SuppressWarnings("unchecked") - List <Service> resultList = query.list(); - - // See if something came back. - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByModelName", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByModelName", null); - return resultList.get(0); - } - - public Service getServiceByVersionAndInvariantId(String modelInvariantId, String modelVersion) throws Exception { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get service with modelInvariantId: " + modelInvariantId + " and modelVersion: " + modelVersion); - - String hql = "FROM Service WHERE modelInvariantUUID = :MODEL_INVARIANT_UUID AND version = :VERSION_STR"; - Query query = getSession().createQuery(hql); - query.setParameter("MODEL_INVARIANT_UUID", modelInvariantId); - query.setParameter("VERSION_STR", modelVersion); - - Service result = null; - try { - result = (Service) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantId='" + modelInvariantId + "', modelVersion='" + modelVersion + "'", nure); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelInvariantId=" + modelInvariantId + " and modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantId=" + modelInvariantId); - throw new Exception("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantId='" + modelInvariantId + "', modelVersion='" + modelVersion + "'"); - } - // See if something came back. - if (result==null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service not found", "CatalogDB", "getServiceByVersionAndInvariantId", null); - return null; - } - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByVersionAndInvariantId", null); - return result; - } - - /** - * Return a newest version of Service recipe that matches a given SERVICE_ID and ACTION - * - * @param serviceModelUUID - * @param action * - * @return ServiceRecipe object or null if none found - */ - @Deprecated - public ServiceRecipe getServiceRecipe (int serviceModelUUID, String action) { - - StringBuilder hql; - - if(action == null){ - hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID"); - }else { - hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID AND action = :action "); - } - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Service recipe with serviceModelUUID " + Integer.toString(serviceModelUUID) - + " and action " - + action - ); - - Query query = getSession ().createQuery (hql.toString ()); - query.setParameter ("serviceModelUUID", serviceModelUUID); - if(action != null){ - query.setParameter (ACTION, action); - } - - @SuppressWarnings("unchecked") - List <ServiceRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); - return resultList.get (0); - } - - /** - * Return a newest version of Service recipe that matches a given SERVICE_MODEL_UUID and ACTION - * - * @param serviceModelUuid - * @param action * - * @return ServiceRecipe object or null if none found - */ - public ServiceRecipe getServiceRecipeByServiceModelUuid(String serviceModelUuid, String action) { - - StringBuilder hql; - - if(action == null){ - hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid"); - }else { - hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUuid = :serviceModelUuid AND action = :action "); - } - - long startTime = System.currentTimeMillis (); - LOGGER.debug("Catalog database - get Service recipe with serviceModelUuid " + serviceModelUuid - + " and action " - + action - ); - - Query query = getSession().createQuery(hql.toString()); - query.setParameter("serviceModelUuid", serviceModelUuid); - if(action != null){ - query.setParameter(ACTION, action); - } - - @SuppressWarnings("unchecked") - List <ServiceRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); - return resultList.get(0); - } - - public List<ServiceRecipe> getServiceRecipes(String serviceModelUuid) { - - StringBuilder hql; - - hql = new StringBuilder("FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID"); - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Service recipe with serviceModelUUID " + serviceModelUuid); - - Query query = getSession().createQuery(hql.toString()); - query.setParameter("serviceModelUUID", serviceModelUuid); - - @SuppressWarnings("unchecked") - List <ServiceRecipe> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getServiceRecipes", null); - return Collections.EMPTY_LIST; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipes", null); - return resultList; - } - - - /** - * Return the VNF component data - queried by the VNFs ID and the component type. - * - * @param vnfId - * @param type - * @return VnfComponent object or null if none found - */ - @Deprecated - public VnfComponent getVnfComponent (int vnfId, String type) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get VnfComponent where vnfId="+ vnfId+ " AND componentType="+ type); - - String hql = "FROM VnfComponent WHERE vnfId = :vnf_id AND componentType = :type"; - Query query = getSession ().createQuery (hql); - query.setParameter ("vnf_id", vnfId); - query.setParameter ("type", type); - - VnfComponent result = null; - try { - result = (VnfComponent) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnf_id='" + vnfId + "', componentType='" + type + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnf_id=" + vnfId + " and componentType=" + type, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnf_id=" + vnfId); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: vnf_id='" + vnfId + "', componentType='" + type + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnf_id=" + vnfId + " and componentType=" + type, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnf_id=" + vnfId); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: vnf_id='" + vnfId + "', componentType='" + type + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnf_id=" + vnfId + " and componentType=" + type, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnf_id=" + vnfId); - - throw e; - } - - if (result != null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfComponent", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No VNFComponent found", "CatalogDB", "getVnfComponent", null); - } - return result; - } - - /** - * Return the newest version of a specific VNF resource (queried by Name). - * - * @param vnfType - * @return VnfResource object or null if none found - */ - public VnfResource getVnfResource (String vnfType) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vnf resource with model_name " + vnfType); - - String hql = "FROM VnfResource WHERE modelName = :vnf_name"; - Query query = getSession().createQuery(hql); - query.setParameter("vnf_name", vnfType); - - @SuppressWarnings("unchecked") - List <VnfResource> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF not found", "CatalogDB", "getVnfResource", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null); - return resultList.get(0); - } - - /** - * Return the newest version of a specific VNF resource (queried by Name). - * - * @param vnfType - * @param serviceVersion - * @return VnfResource object or null if none found - */ - public VnfResource getVnfResource (String vnfType, String serviceVersion) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF resource with model_name " + vnfType + " and version=" + serviceVersion); - - String hql = "FROM VnfResource WHERE modelName = :vnfName and version = :serviceVersion"; - Query query = getSession().createQuery(hql); - query.setParameter("vnfName", vnfType); - query.setParameter("serviceVersion", serviceVersion); - - VnfResource resource = null; - try { - resource = (VnfResource) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnfType='" + vnfType + "', serviceVersion='" + serviceVersion + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfType=" + vnfType); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: vnfType='" + vnfType + "', asdc_service_model_version='" + serviceVersion + "' " + he.getMessage()); - LOGGER.debug(Arrays.toString(he.getStackTrace())); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfType=" + vnfType); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: vnfType='" + vnfType + "', serviceVersion='" + serviceVersion + "' " + e.getMessage()); - LOGGER.debug(Arrays.toString(e.getStackTrace())); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnfType=" + vnfType); - - throw e; - } - if (resource == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResource", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null); - } - return resource; - } - - /** - * Return VnfResource (queried by modelCustomizationId). - * - * @param modelCustomizationId - * @return VnfResource object or null if none found - */ - public VnfResource getVnfResourceByModelCustomizationId(String modelCustomizationId) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF resource with modelCustomizationId " + modelCustomizationId); - - String hql = "SELECT vr " - + "FROM VnfResource as vr JOIN vr.vnfResourceCustomizations as vrc " - + "WHERE vrc.modelCustomizationUuid = :modelCustomizationId"; - - Query query = getSession().createQuery(hql); - query.setParameter("modelCustomizationId", modelCustomizationId); - - VnfResource resource = null; - try { - resource = (VnfResource) query.uniqueResult(); - } catch(org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationId + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelCustomizationUuid=" + modelCustomizationId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationId=" + modelCustomizationId); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationId='" + modelCustomizationId + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationId=" + modelCustomizationId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationId=" + modelCustomizationId); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelCustomizationId='" + modelCustomizationId + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationId=" + modelCustomizationId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationId=" + modelCustomizationId); - - throw e; - } - if (resource == null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceByModelCustomizationId", null); - } else { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelCustomizationId", null); - } - return resource; - } - - - /** - * Return the newest version of a specific VNF resource Customization (queried by modelCustomizationName and modelVersionId). - * - * @return {@link VnfResourceCustomization} object or null if none found - */ - public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationName (String modelCustomizationName, String modelVersionId) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF resource Customization with modelCustomizationName " + modelCustomizationName + " serviceModelUUID " + modelVersionId); - - String hql = "SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.modelCustomizationUuid IN " - + "(SELECT src.resourceModelCustomizationUUID FROM ServiceToResourceCustomization src " - + "WHERE src.serviceModelUUID = :modelVersionId)" - + "AND vrc.modelInstanceName = :modelCustomizationName"; - - Query query = getSession().createQuery(hql); - query.setParameter("modelCustomizationName", modelCustomizationName); - query.setParameter("modelVersionId", modelVersionId); - - @SuppressWarnings("unchecked") - List<VnfResourceCustomization> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResourceCustomization not found", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationName", null); - return resultList.get(0); - } - - - /** - * Return the newest version of a specific VNF resource (queried by modelInvariantId). - * - * @param modelInvariantUuid model invariant ID - * @param modelVersion model version - * @return VnfResource object or null if none found - */ - public VnfResource getVnfResourceByModelInvariantId(String modelInvariantUuid, String modelVersion) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF resource with modelInvariantUuid " + modelInvariantUuid); - - String hql = "FROM VnfResource WHERE modelInvariantUuid = :modelInvariantUuid and version = :serviceVersion"; - Query query = getSession().createQuery(hql); - query.setParameter("modelInvariantUuid", modelInvariantUuid); - query.setParameter("serviceVersion", modelVersion); - - VnfResource resource = null; - try { - resource = (VnfResource) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantUuid='" + modelInvariantUuid + "', serviceVersion='" + modelVersion + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelInvariantUuid=" + modelInvariantUuid + " and serviceVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantUuid=" + modelInvariantUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelInvariantUuid='" + modelInvariantUuid + "', asdc_service_model_version='" + modelVersion + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelInvariantUuid=" + modelInvariantUuid + " and serviceVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelInvariantUuid=" + modelInvariantUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelInvariantUuid='" + modelInvariantUuid + "', serviceVersion='" + modelVersion + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelInvariantUuid=" + modelInvariantUuid + " and serviceVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelInvariantUuid=" + modelInvariantUuid); - - throw e; - } - if (resource == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResource", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResource", null); - } - return resource; - } - - /** - * Return the newest version of a specific VNF resource (queried by ID). - * - * @param id The vnf id - * @return VnfResource object or null if none found - */ - @Deprecated - public VnfResource getVnfResourceById (int id) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get VNF resource with id " + id); - - String hql = "FROM VnfResource WHERE id = :id"; - Query query = getSession ().createQuery (hql); - query.setParameter ("id", id); - - @SuppressWarnings("unchecked") - List <VnfResource> resultList = query.list (); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResource not found", "CatalogDB", "getVnfResourceById", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceById", null); - return resultList.get (0); - } - - /** - * Return the newest version of a vfModule - 1607 - * - */ - public VfModule getVfModuleModelName(String modelName) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleModelName with name " + modelName); - - String hql = "FROM VfModule WHERE modelName = :model_name"; - Query query = getSession().createQuery(hql); - query.setParameter("model_name", modelName); - - @SuppressWarnings("unchecked") - List<VfModule> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF not found", "CatalogDB", "getVfModuleModelName", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleModelName", null); - return resultList.get(0); - } - - public VfModule getVfModuleModelName(String modelName, String model_version) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleModelName with type='" + modelName + "' and asdc_service_model_version='" + model_version + "'"); - - String hql = "FROM VfModule WHERE Name = :model_name and version = :model_version"; - Query query = getSession().createQuery(hql); - query.setParameter("modelName", modelName); - query.setParameter("model_version", model_version); - - VfModule module = null; - try { - module = (VfModule) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: type='" + modelName + "', asdc_service_model_version='" + model_version + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for type=" + modelName + " and version=" + model_version, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for type=" + modelName); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: type='" + modelName + "', asdc_service_model_version='" + model_version + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for type=" + modelName + " and version=" + model_version, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for type=" + modelName); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: type='" + modelName + "', asdc_service_model_version='" + model_version + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for type=" + modelName + " and version=" + model_version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for type=" + modelName); - - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleModelName", null); - } else { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleModelName", null); - } - return module; - } - - /** - * Need this for 1707 DHV. This may be a temporary solution. May - * change it to get resources using service's model name. - * - *@author cb645j - * - */ - public VfModuleCustomization getVfModuleCustomizationByModelName(String modelName) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VfModuleCustomization By VfModule's ModelName: " + modelName); - - String hql = "SELECT VfModuleCustomization FROM VfModuleCustomization as vfmc LEFT OUTER JOIN VfModule as vfm on vfm.modelUUID = vfmc.vfModuleModelUuid where vfm.modelName = :model_name"; - Query query = getSession().createQuery(hql); - query.setParameter("model_name", modelName); - - @SuppressWarnings("unchecked") - List<VfModuleCustomization> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful query but Vf module NOT found", "CatalogDB", "getVfModuleCustomizationByModelName", null); - return null; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful query ", "CatalogDB", "getVfModuleCustomizationByModelName", null); - return resultList.get(0); - } - - - /** - * Return the newest version of a specific Network resource (queried by Type). - * - * @param networkType - * @return NetworkResource object or null if none found - */ - public NetworkResource getNetworkResource(String networkType) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get network resource with type " + networkType); - - String hql = "FROM NetworkResource WHERE model_name = :network_type"; - Query query = getSession().createQuery(hql); - query.setParameter("network_type", networkType); - - @SuppressWarnings("unchecked") - List <NetworkResource> resultList = query.list(); - - // See if something came back. Name is unique, so - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Network Resource not found", "CatalogDB", "getNetworkResource", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResource", null); - return resultList.get(0); - } - - /** - * Return a VNF recipe that matches a given VNF_TYPE, ACTION, and, if specified, SERVICE_TYPE - * - * @param vnfType - * @param action - * @param serviceType The service Name, if null or empty is provided, it won't be taken into account - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVnfRecipe(String vnfType, String action, String serviceType) { - boolean withServiceType = false; - - StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); - - // If query c - if (serviceType == null || serviceType.isEmpty()) { - hql.append("AND serviceType is NULL "); - } else { - hql.append("AND serviceType = :serviceType "); - withServiceType = true; - } - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF recipe with name " + vnfType - + " and action " - + action - + " and service type " - + serviceType); - - Query query = getSession().createQuery(hql.toString()); - query.setParameter(VNF_TYPE, vnfType); - query.setParameter(ACTION, action); - if (withServiceType) { - query.setParameter(SERVICE_TYPE, serviceType); - } - - @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", GET_VNF_RECIPE, null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", GET_VNF_RECIPE, null); - return resultList.get(0); - } - - - - /** - * Return a VNF recipe that matches a given VNF_TYPE and ACTION - * - * @param vnfType - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVnfRecipe(String vnfType, String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF recipe with name " + vnfType - + " and action " - + action); - - Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); - query.setParameter(VNF_TYPE, vnfType); - 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", GET_VNF_RECIPE, null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", GET_VNF_RECIPE, 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) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF recipe with name " + modelName + " and action " + action); - - Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action "); - 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", GET_VNF_RECIPE, null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", GET_VNF_RECIPE, null); - return resultList.get(0); - } - - /** - * Return a Network recipe that matches a given MODEL_UUID and ACTION - * - * @param vnfModelUuid - * @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.getVersion(), action); - - if (recipe == null && vnfResource.getSubCategory().equalsIgnoreCase(NETWORK_SERVICE)) { - recipe = getDefaultVnfRecipe(action); - } - return recipe; - } - - private VnfRecipe getDefaultVnfRecipe(String action) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get default VNF recipe with action: " + action); - - Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); - query.setParameter(VNF_TYPE, "NS_DEFAULT"); - 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", GET_VNF_RECIPE, null); - return null; - } - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", GET_VNF_RECIPE, null); - return resultList.get(0); - } - - /** - * Return a VNF recipe that matches a given VF_MODULE_ID and ACTION - * - * @param vfModuleId - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVnfRecipeByVfModuleId(String vnfType, String vfModuleId, String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get VNF Recipe with vfModuleId " + vfModuleId); - - Query query = getSession().createQuery("FROM VnfRecipe WHERE vfModuleId = :vfModuleId and action = :action "); - query.setParameter(VF_MODULE_MODEL_UUID, vfModuleId); - 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 Entry not found", "CatalogDB", "getVnfRecipeByVfModuleId", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(resultList); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF Recipe Entry found", "CatalogDB", "getVnfRecipeByVfModuleId", null); - return resultList.get(0); - } - - public VfModule getVfModuleTypeByUuid(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleTypeByUuid with uuid=" + modelCustomizationUuid); - - String hql = "FROM VfModule WHERE modelCustomizationUuid = :modelCustomizationUuid"; - Query query = getSession().createQuery(hql); - query.setParameter("modelCustomizationUuid", modelCustomizationUuid); - - VfModule module = null; - try { - module = (VfModule) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleTypeByUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleTypeByUuid", null); - } - return module; - } - - @Deprecated - public VfModule getVfModuleType(String type) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleType with type " + type); - - String hql = "FROM VfModule WHERE type = :type"; - Query query = getSession().createQuery(hql); - query.setParameter("type", type); - - @SuppressWarnings("unchecked") - List<VfModule> resultList = query.list(); - if (resultList.isEmpty()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF not found", "CatalogDB", "getVfModuleType", null); - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); - return resultList.get (0); - } - - @Deprecated - public VfModule getVfModuleType(String type, String version) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get vfModuleType with type " + type + " and model_version " + version); - - String hql = "FROM VfModule WHERE type = :type and version = :version"; - Query query = getSession().createQuery(hql); - query.setParameter ("type", type); - query.setParameter (MODEL_VERSION, version); - VfModule module = null; - try { - module = (VfModule) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: type='" + type + "', asdc_service_model_version='" + version + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for type=" + type + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for type==" + type); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: type='" + type + "', asdc_service_model_version='" + version + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for type=" + type + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for type=" + type); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: type='" + type + "', asdc_service_model_version='" + version + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for type=" + type + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for type=" + type); - - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleType", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); - } - return module; - } - - public VnfResource getVnfResourceByServiceUuid(String serviceModelInvariantUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get vfModuleType with serviceModelInvariantUuid " + serviceModelInvariantUuid); - - String hql = "FROM VnfResource WHERE serviceModelInvariantUuid = :serviceModelInvariantUuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("serviceModelInvariantUuid", serviceModelInvariantUuid); - VnfResource vnfResource = null; - try { - vnfResource = (VnfResource) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: serviceModelInvariantUuid='" + serviceModelInvariantUuid); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for serviceModelInvariantUuid==" + serviceModelInvariantUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - - throw e; - } - if (vnfResource == null) { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleType", null); - } else { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); - } - return vnfResource; - } - - public VnfResource getVnfResourceByVnfUuid(String vnfResourceModelInvariantUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get vfModuleType with vnfResourceModelInvariantUuid " + vnfResourceModelInvariantUuid); - - String hql = "FROM VnfResource WHERE vnfResourceModelInvariantUuid = :vnfResourceModelInvariantUuid"; - Query query = getSession().createQuery(hql); - query.setParameter("vnfResourceModelInvariantUuid", vnfResourceModelInvariantUuid); - VnfResource vnfResource = null; - try { - vnfResource = (VnfResource) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfResourceModelInvariantUuid==" + vnfResourceModelInvariantUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: vnfResourceModelInvariantUuid='" + vnfResourceModelInvariantUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnfResourceModelInvariantUuid=" + vnfResourceModelInvariantUuid); - - throw e; - } - if (vnfResource == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleType", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null); - } - return vnfResource; - } - - public VnfResource getVnfResourceByType(String vnfType) { - return this.getVnfResource(vnfType); - } - - public VfModule getVfModuleByModelInvariantUuid(String modelInvariantUUID) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get vfModuleTypeByModelInvariantUuid with uuid " + modelInvariantUUID); - - String hql = "FROM VfModule WHERE modelInvariantUUID = :modelInvariantUUID "; - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("modelInvariantUUID", modelInvariantUUID); - List<VfModule> modules = this.executeQueryMultipleRows(hql, parameters, true); - VfModule module = null; - - if (modules != null && ! modules.isEmpty()) { - modules.sort(new MavenLikeVersioningComparator()); - Collections.reverse (modules); - module = modules.get(0); - } - - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelInvariantUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelInvariantUuid", null); - } - return module; - } - - public VfModuleCustomization getVfModuleByModelCustomizationUuid(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get vfModuleTypeByModelCustomizationUuid with uuid " + modelCustomizationUuid); - - String hql = "FROM VfModuleCustomization WHERE modelCustomizationUuid = :modelCustomizationUuid "; - Query query = getSession().createQuery(hql); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - VfModuleCustomization module = null; - try { - module = (VfModuleCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vfModuleModelInvariantUuid=" + modelCustomizationUuid , "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid); - - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelCustomizationUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelCustomizationUuid", null); - } - return module; - } - - - public VfModule getVfModuleByModelInvariantUuidAndModelVersion(String modelInvariantUuid, String modelVersion) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleByModelInvariantUuidAndModelVersion with modelInvariantUuid: " + modelInvariantUuid + ", modelVersion: " + modelVersion); - - String hql = "FROM VfModule WHERE modelInvariantUUID = :modelInvariantUuid and version = :modelVersion"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelInvariantUuid", modelInvariantUuid); - query.setParameter("modelVersion", modelVersion); - VfModule module = null; - try { - module = (VfModule) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelInvariantUuid='" + modelInvariantUuid + "', modelVersion='" +modelVersion + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vfModule ModelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for ModelInvariantUuid==" + modelInvariantUuid + " modelVersion==" + modelVersion); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelInvariantUuid='" + modelInvariantUuid + "', modelVersion='" +modelVersion + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelInvariantUuid='" + modelInvariantUuid + "', modelVersion='" +modelVersion + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelInvariantUuid=" + modelInvariantUuid + " modelVersion=" + modelVersion); - throw e; - } - if (module == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelInvariantUuidAndModelVersion", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelInvariantUuidAndModelVersion", null); - } - return module; - } - - /** - * Return the VfModuleCustomization object identified by the given modelCustomizationUuid 1707 - * - * @param modelCustomizationUuid - * @return VfModuleCustomization or null if not found - */ - public VfModuleCustomization getVfModuleCustomizationByModelCustomizationId(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleCustomizationByModelCustomizationId with modelCustomizationUuid: " + modelCustomizationUuid); - - String hql = "FROM VfModuleCustomization WHERE modelCustomizationUuid = :modelCustomizationUuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - VfModuleCustomization VfModuleCustomization = null; - try { - VfModuleCustomization = (VfModuleCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid +"'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vfModuleCustomization modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw e; - } - if (VfModuleCustomization != null) { - LOGGER.debug("Found VMC of " + VfModuleCustomization.getModelCustomizationUuid() + ", now looking for vfModule=" + VfModuleCustomization.getVfModuleModelUuid()); - VfModuleCustomization.setVfModule(this.getVfModuleByModelUuid(VfModuleCustomization.getVfModuleModelUuid())); - } - - if (VfModuleCustomization == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleCustomizationByModelCustomizationId", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleCustomizationByModelCustomizationId", null); - } - return VfModuleCustomization; - } - - /** - * Return the VfModule object identified by the given modelUuid 1707 - * per Mike Z. - this may return more than one row - and even if it does, - * the heat template will be the same - so just return any of the rows. - * - * @param modelUuid - * @return VfModule or null if not found - */ - public VfModule getVfModuleByModelUuid(String modelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleByModelUuid with modelUuid: " + modelUuid); - - String hql = "FROM VfModule WHERE modelUUID = :modelUuidValue"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelUuidValue", modelUuid); - List<VfModule> vfModules = null; - try { - vfModules = query.list (); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VfModule for: modelUuid='" + modelUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VfModule for modelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelUuid=" + modelUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VfModule for: modelUuid='" + modelUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for modelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelUuid=" + modelUuid); - throw e; - } - - if (vfModules == null || vfModules.isEmpty()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelUuid", null); - return null; - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelUuid", null); - } - return vfModules.get(0); - } - /** - * 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 - * @return VnfResourceCustomization or null if not found - */ - public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationUuid(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVnfResourceByModelCustomizatonUuid with modelCustomizationUuid: " + modelCustomizationUuid); - - String hql = "FROM VnfResourceCustomization WHERE modelCustomizationUuid = :modelCustomizationUuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - VnfResourceCustomization vnfResourceCustomization = null; - try { - vnfResourceCustomization = (VnfResourceCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelCustomizationUuid='" + modelCustomizationUuid +"'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelCustomizationUuid==" + modelCustomizationUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelCustomizationUuid='" + modelCustomizationUuid + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw e; - } - if (vnfResourceCustomization != null) { - LOGGER.debug("Found VRC of " + vnfResourceCustomization.getModelCustomizationUuid() + ", now looking for vnfResource=" + vnfResourceCustomization.getVnfResourceModelUuid() ); - vnfResourceCustomization.setVnfResource(this.getVnfResourceByModelUuid(vnfResourceCustomization.getVnfResourceModelUuid())); - LOGGER.debug("Now looking for vfModules for " + vnfResourceCustomization.getModelCustomizationUuid()); - vnfResourceCustomization.setVfModuleCustomizations(this.getAllVfModuleCustomizations(vnfResourceCustomization.getModelCustomizationUuid())); - } - - if (vnfResourceCustomization == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelCustomizationUuid", null); - } - return vnfResourceCustomization; - } - - /** - * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 - * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean - * - * @param modelVersionId - * @return VnfResourceCustomization or null if not found - */ - public VnfResourceCustomization getVnfResourceCustomizationByModelVersionId(String modelVersionId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVnfResourceCustomizationByModelVersionId with modelVersionId: " + modelVersionId); - - String hql = "FROM VnfResourceCustomization WHERE vnfResourceModelUuid = :modelVersionId"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelVersionId", modelVersionId); - VnfResourceCustomization vnfResourceCustomization = null; - try { - vnfResourceCustomization = (VnfResourceCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelVersionId='" + modelVersionId +"'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelVersionId==" + modelVersionId); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelVersionId='" + modelVersionId + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelVersionId=" + modelVersionId); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelVersionId='" + modelVersionId + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelVersionId=" + modelVersionId); - throw e; - } - if (vnfResourceCustomization != null) { - LOGGER.debug("Found VRC of " + vnfResourceCustomization.getModelCustomizationUuid() + ", now looking for vnfResource=" + vnfResourceCustomization.getVnfResourceModelUuid() ); - vnfResourceCustomization.setVnfResource(this.getVnfResourceByModelUuid(vnfResourceCustomization.getVnfResourceModelUuid())); - LOGGER.debug("Now looking for vfModules for " + vnfResourceCustomization.getModelCustomizationUuid()); - vnfResourceCustomization.setVfModuleCustomizations(this.getAllVfModuleCustomizations(vnfResourceCustomization.getModelCustomizationUuid())); - } - - if (vnfResourceCustomization == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceCustomizationByModelVersionId", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelVersionId", null); - } - return vnfResourceCustomization; - } - - /** - * Return the VfModule object identified by the given modelCustomizationId, modelVersionId 1707 - * - * @param modelVersionId, modelCustomizationId - * @return VfModule or null if not found - */ - public VfModule getVfModuleByModelCustomizationIdAndVersion(String modelCustomizationId, String modelVersionId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleByModelCustomizationIdAndVersion with modelVersionId: " + modelVersionId + " modelCustomizationId: " + modelCustomizationId); - -// select * from vf_module vfm where vfm.MODEL_UUID IN ( -// select vfmc.VF_MODULE_MODEL_UUID from vf_module_customization vfmc where vfmc.MODEL_CUSTOMIZATION_UUID='222bd8f2-341d-4419-aa0e-98398fa34050') -// and vfm.MODEL_UUID = 'fa1c8558-006c-4fb6-82f2-4fc0646d6b06'; - - String hql = "Select vfm FROM VfModule as vfm WHERE vfm.modelUUID IN (" - + "SELECT vfmc.vfModuleModelUuid FROM VfModuleCustomization as vfmc " - + "WHERE vfmc.modelCustomizationUuid = :modelCustomizationId) " - + "AND vfm.modelUUID = :modelVersionId"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelVersionId", modelVersionId); - query.setParameter ("modelCustomizationId", modelCustomizationId); - VfModule vfModule = null; - try { - vfModule = (VfModule) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelVersionId='" + modelVersionId +"' modelCustomizationId='" + modelCustomizationId + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelVersionId=" + modelVersionId + " modelCustomizationId=" + modelCustomizationId); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelVersionId='" + modelVersionId + "' modelCustomizationId='" + modelCustomizationId + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelVersionId=" + modelVersionId + " modelCustomizationId=" + modelCustomizationId); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelVersionId='" + modelVersionId + "' modelCustomizationId='" + modelCustomizationId + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelVersionId=" + modelVersionId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelVersionId=" + modelVersionId + " modelCustomizationId=" + modelCustomizationId); - throw e; - } - - if (vfModule == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelCustomizationIdAndVersion", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelCustomizationIdAndVersion", null); - } - return vfModule; - } - - /** - * Return the VfModule object identified by the given modelCustomizationId, modelVersion, modelInvariantId 1707 - * - * @param modelCustomizationId, modelVersion, modelInvariantId - * @return VfModule or null if not found - */ - public VfModule getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId(String modelCustomizationId, String modelVersion, String modelInvariantId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId with modelVersionId: " + modelVersion); - - //select * from vf_module vfm left outer join vf_module_customization vfmc on vfmc.VF_MODULE_MODEL_UUID = vfm.MODEL_UUID -// where vfmc.MODEL_CUSTOMIZATION_UUID='52643a8e-7953-4e48-8eab-97165b2b3a4b' and vfm.MODEL_UUID = '' - - String hql = "Select vfm FROM VfModule as vfm LEFT OUTER JOIN VfModuleCustomization as vfmc on vfmc.vfModuleModelUuid = vfm.modelUUID" - + "WHERE vfmc.modelCustomizationUuid = :modelCustomizationId AND vfm.modelInvariantUUID = :modelInvariantId AND vfm.modelVersion = :modelVersion"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelInvariantId", modelInvariantId); - query.setParameter ("modelCustomizationId", modelCustomizationId); - query.setParameter ("modelVersion", modelVersion); - VfModule vfModule = null; - try { - vfModule = (VfModule) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelInvariantId='" + modelInvariantId +"' modelVersion='" + modelVersion + "' modelCustomizationId='" + modelCustomizationId +"'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantId=" + modelInvariantId + " modelVersion=" + modelVersion + " modelCustomizationId=" + modelCustomizationId); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelInvariantId='" + modelInvariantId + "' modelVersion='" + modelVersion + "' modelCustomizationId='" + modelCustomizationId + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelInvariantId=" + modelInvariantId + " modelVersion=" + modelVersion + " modelCustomizationId=" + modelCustomizationId); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelInvariantId='" + modelInvariantId + "' modelVersion='" + modelVersion + "' modelCustomizationId='" + modelCustomizationId + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelInvariantId=" + modelInvariantId + " modelVersion=" + modelVersion + " modelCustomizationId=" + modelCustomizationId); - throw e; - } - - if (vfModule == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId", null); - } - return vfModule; - } - - /** - * Return the VnfResourceCustomization object identified by the given modelCustomizationName, modelInvariantId and modelVersion 1707 - * - * @param modelInvariantId, modelVersion, modelCustomizationName - * @return VnfResourceCustomization or null if not found - */ - public VnfResourceCustomization getVnfResourceCustomizationByModelInvariantId(String modelInvariantId, String modelVersion, String modelCustomizationName) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVnfResourceCustomizationByModelInvariantId with modelInvariantId: " + modelInvariantId + ", modelVersion: " - + modelVersion + ", modelCustomizationName: " + modelCustomizationName); - - String hql = "SELECT VnfResourceCustomization FROM VnfResourceCustomization as vrc " - + "LEFT OUTER JOIN VnfResource as vr " - + "on vr.modelUuid =vrc.vnfResourceModelUuid " - + "WHERE vr.modelInvariantUuid = :modelInvariantId AND vr.modelVersion = :modelVersion AND vrc.modelInstanceName = :modelCustomizationName"; - - Query query = getSession().createQuery(hql); - query.setParameter ("modelInvariantId", modelInvariantId); - query.setParameter("modelVersion", modelVersion); - query.setParameter("modelCustomizationName", modelCustomizationName); - VnfResourceCustomization vnfResourceCustomization = null; - try { - vnfResourceCustomization = (VnfResourceCustomization) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row in VRC - data integrity error: modelInvariantId='" + modelInvariantId +"' and modelVersion='" + modelVersion + "' modelCustomizationName='" + modelCustomizationName + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for vnfResourceCustomization modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for modelInvariantId==" + modelInvariantId+"' and modelVersion='" + modelVersion + "'modelCustomizationName='" + modelCustomizationName + "'"); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching VRC for: modelInvariantId='" + modelInvariantId +"' and modelVersion='" + modelVersion + "'modelCustomizationName='" + modelCustomizationName + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching VRC for modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelInvariantId=" + modelInvariantId+"' and modelVersion='" + modelVersion + "'modelCustomizationName='" + modelCustomizationName + "'"); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching VRC for: modelInvariantId='" + modelInvariantId +"' and modelVersion='" + modelVersion + "' " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching VRC for modelInvariantId=" + modelInvariantId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for modelInvariantId=" + modelInvariantId+"' and modelVersion='" + modelVersion + "'modelCustomizationName='" + modelCustomizationName + "'"); - throw e; - } - if (vnfResourceCustomization != null) { - LOGGER.debug("Found VRC of " + vnfResourceCustomization.getModelCustomizationUuid() + ", now looking for vnfResource=" + vnfResourceCustomization.getVnfResourceModelUuid() ); - vnfResourceCustomization.setVnfResource(this.getVnfResourceByModelUuid(vnfResourceCustomization.getVnfResourceModelUUID())); - LOGGER.debug("Now looking for vfModules for " + vnfResourceCustomization.getModelCustomizationUuid()); - vnfResourceCustomization.setVfModuleCustomizations(this.getAllVfModuleCustomizations(vnfResourceCustomization.getModelCustomizationUuid())); - } - - if (vnfResourceCustomization == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceCustomizationByModelInvariantId", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByModelInvariantId", null); - } - return vnfResourceCustomization; - } - - /** - * Return list of VnfResourceCustomization objects identified by the given modelCustomizationUuid 1707 - * - * @param modelCustomizationUuid - * @return List<VfModuleCustomization> or null if not found - */ - public List<VfModuleCustomization> getVfModuleCustomizationByVnfModuleCustomizationUuid(String modelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get getVfModuleCustomizationByVnfModuleCustomizationUuid with modelCustomizationUuid: " + modelCustomizationUuid); - -// select * from vf_module_customization as vfmc where vfmc.MODEL_CUSTOMIZATION_UUID IN( -// select vrcmc.VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID from vnf_res_custom_to_vf_module_custom as vrcmc -// where vrcmc.VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID = 'd279139c-4b85-48ff-8ac4-9b83a6fc6da7') - - String hql = "SELECT vfmc FROM VfModuleCustomization as vfmc where vfmc.modelCustomizationUuid " - + "IN(select vrcmc.vfModuleCustModelCustomizationUuid from VnfResCustomToVfModuleCustom as vrcmc " - + "WHERE vrcmc.vnfResourceCustModelCustomizationUuid = :modelCustomizationUuid)"; - - Query query = getSession().createQuery(hql); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - List<VfModuleCustomization> resultList = null; - try { - resultList = query.list(); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - getVfModuleCustomizationByVnfModuleCustomizationUuid - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + " " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModuleCustomizationByVnfModuleCustomizationUuid - searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Exception - getVfModuleCustomizationByVnfModuleCustomizationUuid - while searching for: modelCustomizationUuid='" + modelCustomizationUuid + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModuleCustomizationByVnfModuleCustomizationUuid - searching for modelCustomizationUuid=" + modelCustomizationUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for modelCustomizationUuid=" + modelCustomizationUuid); - throw e; - } - - if (resultList == null) { - resultList = new ArrayList<>(); - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleCustomizationByVnfModuleCustomizationUuid", null); - return resultList; - } - - /** - * Return the newest version of a specific VNF resource Customization (queried by modelCustomizationName and modelVersionId). - * - * @return {@link VnfResourceCustomization} object or null if none found - */ - public VnfResourceCustomization getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId (String modelCustomizationName, String modelVersionId) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get VNF resource Customization with modelCustomizationName " + modelCustomizationName + " modelUUID " + modelVersionId); - - String hql = "SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.vnfResourceModelUuid IN " - + "(SELECT vr.modelUuid FROM VnfResource vr " - + "WHERE vr.modelUuid = :modelVersionId)" - + "AND vrc.modelInstanceName = :modelCustomizationName"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("modelCustomizationName", modelCustomizationName); - query.setParameter ("modelVersionId", modelVersionId); - - @SuppressWarnings("unchecked") - List <VnfResourceCustomization> resultList = query.list (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VnfResourceCustomization not found", "CatalogDB", "getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId", null); - return resultList.get (0); - } - - public ArrayList<VfModuleCustomization> getAllVfModuleCustomizations(String vnfResourceCustomizationMCU) { - LOGGER.debug ("Catalog database - getAllVfModuleCustomizations with vnfResourceCustomizationMCU " + vnfResourceCustomizationMCU); - - List<VnfResCustomToVfModuleCustom> matches = this.getVRCtoVFMC(vnfResourceCustomizationMCU, null); - if (matches == null || matches.isEmpty()) { - LOGGER.debug("Found no vf modules for " + vnfResourceCustomizationMCU); - return new ArrayList<>(); - } - ArrayList<VfModuleCustomization> list = new ArrayList<>(); - for (VnfResCustomToVfModuleCustom v : matches) { - String m = v.getVfModuleCustModelCustomizationUuid(); - LOGGER.debug("VfModule to match: " + m); - VfModuleCustomization c = this.getVfModuleCustomizationByModelCustomizationId(m); - if (c != null) { - list.add(c); - } else { - LOGGER.debug("**UNABLE to find vfModule " + m); - } - } - return list; - } - - /** - * Return the VnfResourceCustomization object identified by the given modelCustomizationUuid 1707 - * Note that the corresponding VnfResource Object will be put in the VnfResourceCustomization bean - * - * @param modelUuid - * @return VnfResourceCustomization or null if not found - */ - public VnfResource getVnfResourceByModelUuid(String modelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug ("Catalog database - get VnfResource with modelUuid " + modelUuid); - - String hql = "FROM VnfResource WHERE modelUuid = :modelUuid"; - Query query = getSession().createQuery(hql); - query.setParameter ("modelUuid", modelUuid); - VnfResource vnfResource = null; - try { - vnfResource = (VnfResource) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique Vnf_Resource row - data integrity error: modelUuid='" + modelUuid); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for Vnf Resource modelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for vnfResource modelUuid==" + modelUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: VnfResource modelUuid='" + modelUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnfResource ModelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResource modelUuid=" + modelUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: vnfResource ModelUuid='" + modelUuid + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnfResource ModelUuid=" + modelUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnfResource modelUuid=" + modelUuid); - throw e; - } - if (vnfResource == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResourceByModelUuid", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceByModelUuid", null); - } - return vnfResource; - } - - public VnfResCustomToVfModuleCustom getVnfResCustomToVfModule(String vnfId, String vfId) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - getVnfResCustomToVfModule - vnfResourceCustModelCustUuid: " + vnfId + ", vfModuleCustModelCustomUuid=" + vfId); - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("vnfIdValue", vnfId); - parameters.put("vfIdValue", vfId); - VnfResCustomToVfModuleCustom vrctvmc = this.executeQuerySingleRow( - "FROM VnfResCustomToVfModuleCustom where vnfResourceCustModelCustomizationUuid = :vnfIdValue and vfModuleCustModelCustomizationUuid = :vfIdValue", parameters, true); - if (vrctvmc == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getVnfResCustomToVfModule", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResCustomToVfModule", null); - } - return vrctvmc; - } - - public List<VfModule> getVfModulesForVnfResource(VnfResource vnfResource) { - if (vnfResource == null) - return Collections.EMPTY_LIST; - String vnfResourceModelUuid = vnfResource.getModelUuid(); - - LOGGER.debug("Catalog database - getVfModulesForVnfResource - vnfResource: " + vnfResource.toString()); - - return this.getVfModulesForVnfResource(vnfResourceModelUuid); - - } - - public List<VfModule> getVfModulesForVnfResource(String vnfResourceModelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - getVfModulesForVnfResource - vnfResourceModelUuid: " + vnfResourceModelUuid); - Query query = getSession().createQuery("FROM VfModule where vnfResourceModelUUId = :vnfResourceModelUUId"); - query.setParameter("vnfResourceModelUUId", vnfResourceModelUuid); - List<VfModule> resultList = null; - try { - resultList = query.list(); - if (resultList != null) - LOGGER.debug("\tQuery found " + resultList.size() + " records."); - else - LOGGER.debug("\tQuery found no records."); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - getVfModulesForVnfResource - while searching for: vnfResourceModelUUId='" + vnfResourceModelUuid + " " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModulesForVnfResource - searching for vnfResourceModelUUId=" + vnfResourceModelUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceModelUUId=" + vnfResourceModelUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Exception - getVfModulesForVnfResource - while searching for: vnfResourceModelUUId='" + vnfResourceModelUuid + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception - getVfModulesForVnfResource - searching for vnfResourceModelUUId=" + vnfResourceModelUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfResourceModelUUId=" + vnfResourceModelUuid); - throw e; - } - if (resultList == null) { - resultList = new ArrayList<>(); - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModulesForVnfResource", null); - return resultList; - } - - public Service getServiceByUuid (String serviceModelInvariantUuid) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get service with ModelInvariantUuid " + serviceModelInvariantUuid); - - String hql = "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"; - Query query = getSession ().createQuery (hql); - query.setParameter ("serviceModelInvariantUuid", serviceModelInvariantUuid); - - Service service = null; - try { - service = (Service) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: serviceModelInvariantUuid='" + serviceModelInvariantUuid + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: serviceName='" + serviceModelInvariantUuid + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: serviceModelInvariantUuid='" + serviceModelInvariantUuid + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for serviceModelInvariantUuid=" + serviceModelInvariantUuid); - throw e; - } - if (service == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getService", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getService", null); - } - - return service; - } - - public NetworkResource getNetworkResourceById(Integer id) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getNetworkResource with id " + id); - - String hql = "FROM NetworkResource WHERE id = :id"; - Query query = getSession ().createQuery (hql); - query.setParameter ("id", id); - - NetworkResource networkResource = null; - try { - networkResource = (NetworkResource) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: NETWORK_RESOURCE.id='" + id + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for NETWORK_RESOURCE.id=" + id); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: NETWORK_RESOURCE.id='" + id + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for NETWORK_RESOURCE.id=" + id); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: NETWORK_RESOURCE.id='" + id + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for NETWORK_RESOURCE.id=" + id, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for NETWORK_RESOURCE.id=" + id); - throw e; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceById", null); - return networkResource; - - } - - public NetworkResource getNetworkResourceById(String id) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getNetworkResource with model_uuid " + id); - - String hql = "FROM NetworkResource WHERE modelUUID = :model_uuid"; - Query query = getSession ().createQuery (hql); - query.setParameter ("model_uuid", id); - - List<NetworkResource> networkResources = null; - try { - networkResources = query.list (); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: NETWORK_RESOURCE.id='" + id + "' " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for NETWORK_RESOURCE.model_uuid=" + id, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for NETWORK_RESOURCE.model_uuid=" + id); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: NETWORK_RESOURCE.id='" + id + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for NETWORK_RESOURCE.model_uuid=" + id, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for NETWORK_RESOURCE.model_uuid=" + id); - throw e; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceById", null); - if (networkResources == null || networkResources.isEmpty()) - return null; - else - return networkResources.get(0); - } - - // 1707 API Spec - - public static boolean isEmptyOrNull(String str) { - if (str == null) - return true; - if ("null".equals(str)) - return true; - if ("".equals(str)) - return true; - return false; - } - - public List<ServiceToResourceCustomization> getSTR(String serviceModelUuid, String resourceModelCustomizationUuid, String modelType) { - LOGGER.debug("Catalog database: getSTR - smu=" + serviceModelUuid + ", rmcu=" + resourceModelCustomizationUuid + ", modelType = " + modelType); - - if (isEmptyOrNull(serviceModelUuid) && isEmptyOrNull(resourceModelCustomizationUuid) && isEmptyOrNull(modelType)) - return null; - - StringBuilder hql = new StringBuilder("FROM ServiceToResourceCustomization WHERE "); - boolean first = true; - if (serviceModelUuid != null && !serviceModelUuid.equals("")) { - hql.append("serviceModelUUID = :smu"); - first = false; - } - if (resourceModelCustomizationUuid != null && !resourceModelCustomizationUuid.equals("")) { - if (!first) { - hql.append(" AND "); - } - hql.append("resourceModelCustomizationUUID = :rmcu"); - first = false; - } - if (modelType != null && !modelType.equals("")) { - if (!first) { - hql.append(" AND "); - first = false; - } - hql.append("modelType = :modelType"); - first = false; - } - Query query = getSession().createQuery(hql.toString()); - if (hql.toString().contains(":smu")) - query.setParameter("smu", serviceModelUuid); - if (hql.toString().contains(":rmcu")) - query.setParameter("rmcu", resourceModelCustomizationUuid); - if (hql.toString().contains(":modelType")) - query.setParameter("modelType", modelType); - LOGGER.debug("query - " + hql.toString()); - - @SuppressWarnings("unchecked") - List<ServiceToResourceCustomization> resultList = query.list(); - if (resultList == null || resultList.isEmpty()) { - LOGGER.debug("Found no matches to the query - " + hql.toString()); - return new ArrayList<>(); - } - return resultList; - } - - public List<VnfResCustomToVfModuleCustom> getVRCtoVFMC (String vrc_mcu, String vfmc_mcu) { - LOGGER.debug("Catalog database: getVRCtoVFMC - vrc_mcu=" + vrc_mcu + ", vfmc_mcu=" + vfmc_mcu); - - if (isEmptyOrNull(vrc_mcu) && isEmptyOrNull(vfmc_mcu)) - return null; - - StringBuilder hql = new StringBuilder("FROM VnfResCustomToVfModuleCustom WHERE "); - boolean first = true; - if (vrc_mcu != null && !vrc_mcu.equals("")) { - hql.append("vnfResourceCustModelCustomizationUuid = :vrc_mcu"); - first = false; - } - if (vfmc_mcu != null && !vfmc_mcu.equals("")) { - if (!first) { - hql.append(" AND "); - } - hql.append("vfModuleCustModelCustomizationUuid = :vfmc_mcu"); - first = false; - } - Query query = getSession().createQuery(hql.toString()); - if (hql.toString().contains(":vrc_mcu")) - query.setParameter("vrc_mcu", vrc_mcu); - if (hql.toString().contains(":vfmc_mcu")) - query.setParameter("vfmc_mcu", vfmc_mcu); - @SuppressWarnings("unchecked") - List<VnfResCustomToVfModuleCustom> resultList = query.list(); - if (resultList == null || resultList.isEmpty()) { - LOGGER.debug("Found no matches to the query - " + hql.toString()); - return new ArrayList<>(); - } - return resultList; - } - - @SuppressWarnings("unchecked") - public List <TempNetworkHeatTemplateLookup> getTempNetworkHeatTemplateLookup (String networkResourceModelName) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - GetTempNetworkHeatTemplateLookup for Network Name " + networkResourceModelName); - - String hql = "FROM TempNetworkHeatTemplateLookup where networkResourceModelName = :networkResourceModelName"; - Query query = getSession ().createQuery (hql); - query.setParameter ("networkResourceModelName", networkResourceModelName); - - List <TempNetworkHeatTemplateLookup> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getTempNetworkHeatTemplateLookup", null); - return result; - } - - // 1702 API Spec - Query for all networks in a Service: - public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getServiceNetworksByServiceModelUuid - " + serviceModelUuid); - - List<ServiceToResourceCustomization> strMappings = this.getSTR(serviceModelUuid, null, "network"); - if (strMappings == null || strMappings.isEmpty()) { - LOGGER.debug("Found NO matches for NRC with ServiceModelUuid=" + serviceModelUuid); - return new ArrayList<>(); - } - LOGGER.debug("Found " + strMappings.size() + " entries in ServiceToResourceCustomizations.network with smu=" + serviceModelUuid); - - ArrayList<NetworkResourceCustomization> masterList = new ArrayList<>(); - for (ServiceToResourceCustomization stn : strMappings) { - String networkModelCustomizationUuid = stn.getResourceModelCustomizationUUID(); - LOGGER.debug("Now searching for NetworkResourceCustomization for " + networkModelCustomizationUuid); - List<NetworkResourceCustomization> resultSet = this.getAllNetworksByNetworkModelCustomizationUuid(networkModelCustomizationUuid); - masterList.addAll(resultSet); - } - LOGGER.debug("Returning " + masterList.size() + " NRC records"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByServiceModelUuid", null); - return masterList; - } - public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid) { - LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Could not find Service for " + serviceModelInvariantUuid); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - String serviceNameVersionId = service.getModelUUID(); - LOGGER.debug("The highest version for the Service " + serviceModelInvariantUuid + " is " + serviceNameVersionId); - - // Service.serviceNameVersionId == ServiceToNetworks.serviceModelUuid - return this.getAllNetworksByServiceModelUuid(serviceNameVersionId); - } - public List<NetworkResourceCustomization> getAllNetworksByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { - LOGGER.debug("Catalog database: getServiceNetworksByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - - Query query = getSession().createQuery( - "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - query.setParameter("serviceModelVersion", serviceModelVersion); - - //TODO - //can fix this later - no time - could do a unique query here - but this should work - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("No Service found with smu=" + serviceModelInvariantUuid + " and smv=" + serviceModelVersion); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - String serviceNameVersionId = service.getModelUUID(); - - // Service.serviceNameVersionId == ServiceToNetworks.serviceModelUuid - return this.getAllNetworksByServiceModelUuid(serviceNameVersionId); - - } - public List<NetworkResourceCustomization> getAllNetworksByNetworkModelCustomizationUuid(String networkModelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllNetworksByNetworkModelCustomizationUuid - " + networkModelCustomizationUuid); - - //Query query = getSession().createQuery(hql.toString()); - //query.setParameter("networkModelCustomizationUuid", networkModelCustomizationUuid); - //LOGGER.debug("QUERY: " + hql.toString() + ", networkModelCustomizationUuid=" + networkModelCustomizationUuid); - - //@SuppressWarnings("unchecked") - //List<NetworkResourceCustomization> resultList = query.list(); - - HashMap<String, String> params = new HashMap<>(); - params.put("networkModelCustomizationUuid", networkModelCustomizationUuid); - - List<NetworkResourceCustomization> resultList = this.executeQueryMultipleRows( - "FROM NetworkResourceCustomization WHERE modelCustomizationUuid = :networkModelCustomizationUuid", params, true); - - if (resultList.isEmpty()) { - LOGGER.debug("Unable to find an NMC with nmcu=" + networkModelCustomizationUuid); - return new ArrayList<>(); - } - for (NetworkResourceCustomization nrc : resultList) { - nrc.setNetworkResource(this.getNetworkResourceById(nrc.getNetworkResourceModelUuid())); - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByNetworkModelCustomizationUuid", null); - return resultList; - } - - public List<NetworkResourceCustomization> getAllNetworksByNetworkType(String networkType) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getServiceNetworksByNetworkType - " + networkType); - - NetworkResource nr = this.getNetworkResource(networkType); - if (nr == null) { - return new ArrayList<>(); - } - String networkResourceId = nr.getModelUUID(); - - LOGGER.debug("Now searching for NRC's with networkResourceId = " + networkResourceId); - - Query query = getSession().createQuery( - "FROM NetworkResourceCustomization WHERE networkResourceModelUuid = :networkResourceId"); - query.setParameter("networkResourceId", networkResourceId); - - @SuppressWarnings("unchecked") - List<NetworkResourceCustomization> resultList = query.list(); - - if (resultList != null && ! resultList.isEmpty()) { - LOGGER.debug("Found " + resultList.size() + " results"); - for (NetworkResourceCustomization nrc : resultList) { - nrc.setNetworkType(networkType); - nrc.setNetworkResource(nr); - } - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworksByNetworkType", null); - - return resultList; - } - public ArrayList<VfModuleCustomization> getAllVfmcForVrc(VnfResourceCustomization vrc) { - LOGGER.debug("Catalog database: getAllVfmcForVrc - " + vrc.getModelCustomizationUuid()); - - List<VnfResCustomToVfModuleCustom> vfmcs = this.getVRCtoVFMC(vrc.getModelCustomizationUuid(), null); - if (vfmcs == null || vfmcs.isEmpty()) { - return new ArrayList<>(); - } - ArrayList<VfModuleCustomization> vfModuleCusts = new ArrayList<>(); - for (VnfResCustomToVfModuleCustom vfmc : vfmcs) { - VfModuleCustomization vfmcust = this.getVfModuleCustomizationByModelCustomizationId(vfmc.getVfModuleCustModelCustomizationUuid()); - if (vfmcust != null) { - vfModuleCusts.add(vfmcust); - } - } - return vfModuleCusts; - } - - //1702 API Spec cont'd - Query for all VnfResources in a Service: - //1707 modified for db refactoring - public List<VnfResourceCustomization> getAllVnfsByServiceModelUuid(String serviceModelUuid) { - LOGGER.debug("Catalog database: getAllVnfsByServiceModelUuid - " + serviceModelUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelUUID = :serviceModelUuid"); - query.setParameter("serviceModelUuid", serviceModelUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Unable to find a service with modelUuid=" + serviceModelUuid); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - - // Step 2 - Now query to get the related VnfResourceCustomizations - - List<ServiceToResourceCustomization> strcs = this.getSTR(serviceModelUuid, null, "vnf"); - - if (strcs.isEmpty()) { - LOGGER.debug("Unable to find any related vnfs to a service with modelUuid=" + serviceModelUuid); - return new ArrayList<>(); - } - - ArrayList<VnfResourceCustomization> allVrcs = new ArrayList<>(); - for (ServiceToResourceCustomization strc : strcs) { - LOGGER.debug("Try to find VRC for mcu=" + strc.getResourceModelCustomizationUUID()); - VnfResourceCustomization vrc = this.getVnfResourceCustomizationByModelCustomizationUuid(strc.getResourceModelCustomizationUUID()); - if (vrc != null) - allVrcs.add(vrc); - } - return allVrcs; - - } - public List<VnfResourceCustomization> getAllVnfsByServiceModelInvariantUuid(String serviceModelInvariantUuid) { - LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - @SuppressWarnings("unchecked") - List<Service> resultList = query.list(); - - if (resultList.isEmpty()) { - return new ArrayList<>(); - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - Service service = resultList.get(0); - //now just call the method that takes the version - the service object will have the highest version - return this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - } - public List<VnfResourceCustomization> getAllVnfsByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllVnfsByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - - Query query = getSession().createQuery( - "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - query.setParameter("serviceModelVersion", serviceModelVersion); - - @SuppressWarnings("unchecked") - List<Service> resultList = query.list(); - - if (resultList.isEmpty()) { - return new ArrayList<>(); - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - Service service = resultList.get(0); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByServiceModelInvariantUuid", null); - return this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - } - - public List<VnfResourceCustomization> getAllVnfsByServiceName(String serviceName, String serviceVersion) { - LOGGER.debug("Catalog database: getAllVnfsByServiceName - " + serviceName + ", version=" + serviceVersion); - if (serviceVersion == null || serviceVersion.equals("")) { - return this.getAllVnfsByServiceName(serviceName); - } - - Query query = getSession().createQuery( - "FROM Service WHERE modelName = :serviceName and version = :serviceVersion"); - query.setParameter("serviceName", serviceName); - query.setParameter("serviceVersion", serviceVersion); - - @SuppressWarnings("unchecked") - List<Service> resultList = query.list(); - - if (resultList.isEmpty()) { - return Collections.EMPTY_LIST; - } - Service service = resultList.get(0); - return this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - } - public List<VnfResourceCustomization> getAllVnfsByServiceName(String serviceName) { - LOGGER.debug("Catalog database: getAllVnfsByServiceName - " + serviceName); - - Query query = getSession().createQuery("FROM Service WHERE modelName = :serviceName"); - query.setParameter("serviceName", serviceName); - - @SuppressWarnings("unchecked") - List<Service> resultList = query.list(); - - if (resultList.isEmpty()) { - return Collections.EMPTY_LIST; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - Service service = resultList.get(0); - - return this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - } - - public List<VnfResourceCustomization> getAllVnfsByVnfModelCustomizationUuid(String vnfModelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllVnfsByVnfModelCustomizationUuid - " + vnfModelCustomizationUuid); - - Query query1 = getSession().createQuery("FROM VnfResourceCustomization WHERE modelCustomizationUuid = :vrcmcu"); - query1.setParameter("vrcmcu", vnfModelCustomizationUuid); - @SuppressWarnings("unchecked") - List<VnfResourceCustomization> resultList1 = query1.list(); - - if (resultList1.isEmpty()) { - LOGGER.debug("Found no records matching " + vnfModelCustomizationUuid); - return Collections.EMPTY_LIST; - } - - for (VnfResourceCustomization vrc : resultList1) { - VnfResource vr = this.getVnfResourceByModelUuid(vrc.getVnfResourceModelUuid()); - vrc.setVnfResource(vr); - vrc.setVfModuleCustomizations(this.getAllVfmcForVrc(vrc)); - } - - LOGGER.debug("Returning " + resultList1.size() + " vnf modules"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfsByVnfModelCustomizationUuid", null); - return resultList1; - } - - //1702 API Spec cont'd - Query for all allotted resources in a Service - - public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelUuid - " + serviceModelUuid); - - List<ServiceToResourceCustomization> strcs = this.getSTR(serviceModelUuid, null, "allottedResource"); - if (strcs == null || strcs.isEmpty()) { - LOGGER.debug("No AR entries found for " + serviceModelUuid); - return new ArrayList<>(); - } - LOGGER.debug("Found " + strcs.size() + " entries in ServiceToResourceCustomizations with smu=" + serviceModelUuid + ", allottedResource"); - - ArrayList<AllottedResourceCustomization> masterList = new ArrayList<>(); - for (ServiceToResourceCustomization star : strcs) { - String arModelCustomizationUuid = star.getResourceModelCustomizationUUID(); - LOGGER.debug("Now searching for AllottedResourceCustomization for " + arModelCustomizationUuid); - List<AllottedResourceCustomization> resultSet = this.getAllAllottedResourcesByArModelCustomizationUuid(arModelCustomizationUuid); - masterList.addAll(resultSet); - } - LOGGER.debug("Returning " + masterList.size() + " ARC records"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllAllottedResourcesByServiceModelUuid", null); - return masterList; - } - - public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid) { - LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Could not find Service for " + serviceModelInvariantUuid); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - String serviceModelUuid = service.getModelUUID(); - LOGGER.debug("The highest version for the Service " + serviceModelInvariantUuid + " is " + serviceModelUuid); - - return this.getAllAllottedResourcesByServiceModelUuid(serviceModelUuid); - } - - public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { - LOGGER.debug("Catalog database: getAllAllottedResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - - Query query = getSession().createQuery( - "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - query.setParameter("serviceModelVersion", serviceModelVersion); - - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("No Service found with smu=" + serviceModelInvariantUuid + " and smv=" + serviceModelVersion); - return new ArrayList<>(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - String serviceModelUuid = service.getModelUUID(); - - return this.getAllAllottedResourcesByServiceModelUuid(serviceModelUuid); - } - - public List<AllottedResourceCustomization> getAllAllottedResourcesByArModelCustomizationUuid(String arModelCustomizationUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllAllottedResourcesByArModelCustomizationUuid - " + arModelCustomizationUuid); - - Query query = getSession().createQuery( - "FROM AllottedResourceCustomization WHERE modelCustomizationUuid = :arModelCustomizationUuid"); - query.setParameter("arModelCustomizationUuid", arModelCustomizationUuid); - - @SuppressWarnings("unchecked") - List<AllottedResourceCustomization> resultList = query.list(); - - if (resultList.isEmpty()) { - LOGGER.debug("No ARC found with arc_mcu=" + arModelCustomizationUuid); - return new ArrayList<>(); - } - // There should only be one - but we'll handle if multiple - for (AllottedResourceCustomization arc : resultList) { - AllottedResource ar = this.getAllottedResourceByModelUuid(arc.getArModelUuid()); - arc.setAllottedResource(ar); - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllAllottedResourcesByArModelCustomizationUuid", null); - return resultList; - } - - public AllottedResource getAllottedResourceByModelUuid(String arModelUuid) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Allotted Resource with modelUuid= " + arModelUuid); - - String hql = "FROM AllottedResource WHERE modelUuid = :arModelUuid"; - Query query = getSession ().createQuery (hql); - query.setParameter ("arModelUuid", arModelUuid); - - @SuppressWarnings("unchecked") - List <AllottedResource> resultList = query.list (); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. AllottedResource not found", "CatalogDB", "getAllottedResourceByModelUuid", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllottedResourceByModelUuid", null); - return resultList.get (0); - - } - - //1702 API Spec cont'd - Query for all resources in a Service: - public ServiceMacroHolder getAllResourcesByServiceModelUuid(String serviceModelUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllResourcesByServiceModelUuid - " + serviceModelUuid); - - StringBuilder hql = new StringBuilder("FROM Service WHERE modelUUID = :serviceModelUuid"); - Query query = getSession().createQuery(hql.toString()); - query.setParameter("serviceModelUuid", serviceModelUuid); - LOGGER.debug("Query: " + hql.toString() + ", smu=" + serviceModelUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Unable to find a Service with serviceModelUuid=" + serviceModelUuid); - return new ServiceMacroHolder(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - ServiceMacroHolder smh = new ServiceMacroHolder(service); - ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(serviceModelUuid); - smh.setNetworkResourceCustomization(nrcList); - ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(serviceModelUuid); - smh.setAllottedResourceCustomization(arcList); - ArrayList<VnfResourceCustomization> vnfList = (ArrayList<VnfResourceCustomization>) this.getAllVnfsByServiceModelUuid(serviceModelUuid); - smh.setVnfResourceCustomizations(vnfList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelUuid", null); - return smh; - } - public ServiceMacroHolder getAllResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid); - - Query query = getSession().createQuery("FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Unable to find a Service with serviceModelInvariantUuid=" + serviceModelInvariantUuid); - return new ServiceMacroHolder(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - ServiceMacroHolder smh = new ServiceMacroHolder(service); - ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(service.getModelUUID()); - smh.setNetworkResourceCustomization(nrcList); - ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(service.getModelUUID()); - smh.setAllottedResourceCustomization(arcList); - ArrayList<VnfResourceCustomization> vnfList = (ArrayList<VnfResourceCustomization>) this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - smh.setVnfResourceCustomizations(vnfList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelInvariantUuid", null); - return smh; - - } - public ServiceMacroHolder getAllResourcesByServiceModelInvariantUuid(String serviceModelInvariantUuid, String serviceModelVersion) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database: getAllResourcesByServiceModelInvariantUuid - " + serviceModelInvariantUuid + ", version=" + serviceModelVersion); - - Query query = getSession().createQuery( - "FROM Service WHERE modelInvariantUUID = :serviceModelInvariantUuid and version = :serviceModelVersion"); - query.setParameter("serviceModelInvariantUuid", serviceModelInvariantUuid); - query.setParameter("serviceModelVersion", serviceModelVersion); - //TODO make this a unique query - @SuppressWarnings("unchecked") - List<Service> serviceList = query.list(); - - if (serviceList.isEmpty()) { - LOGGER.debug("Unable to find a Service with serviceModelInvariantUuid=" + serviceModelInvariantUuid + " and serviceModelVersion=" + serviceModelVersion); - return new ServiceMacroHolder(); - } - - serviceList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (serviceList); - Service service = serviceList.get(0); - - ServiceMacroHolder smh = new ServiceMacroHolder(service); - ArrayList<NetworkResourceCustomization> nrcList = (ArrayList<NetworkResourceCustomization>) this.getAllNetworksByServiceModelUuid(service.getModelUUID()); - smh.setNetworkResourceCustomization(nrcList); - ArrayList<AllottedResourceCustomization> arcList = (ArrayList<AllottedResourceCustomization>) this.getAllAllottedResourcesByServiceModelUuid(service.getModelUUID()); - smh.setAllottedResourceCustomization(arcList); - ArrayList<VnfResourceCustomization> vnfList = (ArrayList<VnfResourceCustomization>) this.getAllVnfsByServiceModelUuid(service.getModelUUID()); - smh.setVnfResourceCustomizations(vnfList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllResourcesByServiceModelUuid with version", null); - return smh; - } - - // 1707 New API queries - public NetworkResourceCustomization getSingleNetworkByModelCustomizationUuid(String modelCustomizationUuid) { - LOGGER.debug("Catalog database; getSingleNetworkByModelCustomizationUuid - " + modelCustomizationUuid); - List<NetworkResourceCustomization> resultList = this.getAllNetworksByNetworkModelCustomizationUuid(modelCustomizationUuid); - if (resultList == null || resultList.isEmpty()) { - return null; - } - return resultList.get(0); - } - public AllottedResourceCustomization getSingleAllottedResourceByModelCustomizationUuid(String modelCustomizationUuid) { - LOGGER.debug("Catalog database; getSingleAllottedResourceByModelCustomizationUuid - " + modelCustomizationUuid); - List<AllottedResourceCustomization> resultList = this.getAllAllottedResourcesByArModelCustomizationUuid(modelCustomizationUuid); - if (resultList == null || resultList.isEmpty()) { - return null; - } - return resultList.get(0); - } - @Deprecated - public VnfResource getSingleVnfResourceByModelCustomizationUuid(String modelCustomizationUuid) { - /* - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database; getSingleVnfResourceByModelCustomizationUuid - " + modelCustomizationUuid); - List<VnfResource> resultList = this.getAllVnfsByVnfModelCustomizationUuid(modelCustomizationUuid); - if (resultList == null || resultList.size() < 1) { - return null; - } - return resultList.get(0); - */ - return null; - } - - private void populateNetworkResourceType(List<NetworkResourceCustomization> resultList) { - HashMap<String, NetworkResource> networkResources = new HashMap<>(); - - for (NetworkResourceCustomization nrc : resultList) { - String network_id = nrc.getNetworkResourceModelUuid(); - if (network_id == null) { - nrc.setNetworkResource(null); - nrc.setNetworkType("UNKNOWN_NETWORK_ID_NULL"); - continue; - } - if (networkResources.containsKey(network_id)) { - nrc.setNetworkResource(networkResources.get(network_id)); - nrc.setNetworkType(networkResources.get(network_id).getModelName()); - } else { - NetworkResource nr = this.getNetworkResourceById(network_id); - if (nr == null) { - nrc.setNetworkType("INVALID_NETWORK_TYPE_ID_NOT_FOUND"); - } else { - nrc.setNetworkType(nr.getModelName()); - nrc.setNetworkResource(nr); - networkResources.put(network_id, nr); - } - } - } - } - - /** - * Return a VNF recipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, and ACTION - * first query VF_MODULE table by type, and then use the ID to query - * VNF_RECIPE by VF_MODULE_ID and ACTION - * - * @param vnfType - * @parm vfModuleModelName - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfRecipe getVfModuleRecipe (String vnfType, String vfModuleModelName, String action) { - String vfModuleType = vnfType + "::" + vfModuleModelName; - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType); - - Query query = getSession ().createQuery ("FROM VfModule WHERE type = :type "); - query.setParameter (TYPE, vfModuleType); - - @SuppressWarnings("unchecked") - List <VfModule> resultList = query.list (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF Module Entry not found", "CatalogDB", "getVfModuleRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - VfModule vfMod = resultList.get(0); - - String vfModuleId = vfMod.getModelUUID(); - - LOGGER.debug ("Catalog database - get VNF recipe with vf module id " + vfModuleId - + " and action " - + action); - - Query query1 = getSession ().createQuery ("FROM VnfRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); - query1.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfRecipe> resultList1 = query1.list (); - - if (resultList1.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVfModuleRecipe", null); - return null; - } - - resultList1.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList1); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVfModuleRecipe", null); - return resultList1.get (0); - } - - /** - * Return a VNF Module List that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, - * ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION - * - * @param vfModuleType - * @parm modelCustomizationUuid - * @param asdcServiceModelVersion - * @param modelVersion - * @param action - * @return VfModule list - */ - public List<VfModule> getVfModule (String vfModuleType, String modelCustomizationUuid, String asdcServiceModelVersion, String modelVersion, String action) { - StringBuilder hql; - Query query; - if(modelCustomizationUuid != null){ - hql = new StringBuilder ("FROM VfModule WHERE modelCustomizationUuid = :modelCustomizationUuid AND version = :version"); - - LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType + ", asdcServiceModelVersion " + asdcServiceModelVersion + ", modelVersion " + modelVersion); - - query = getSession ().createQuery (hql.toString ()); - query.setParameter ("modelCustomizationUuid", modelCustomizationUuid); - query.setParameter (MODEL_VERSION, asdcServiceModelVersion); - }else{ - hql = new StringBuilder ("FROM VfModule WHERE type = :type AND version = :version AND modelVersion = :modelVersion"); - - LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType + ", asdcServiceModelVersion " + asdcServiceModelVersion + ", modelVersion " + modelVersion); - - query = getSession ().createQuery (hql.toString ()); - query.setParameter (TYPE, vfModuleType); - query.setParameter (MODEL_VERSION, asdcServiceModelVersion); - query.setParameter ("modelVersion", modelVersion); - } - - @SuppressWarnings("unchecked") - List <VfModule> resultList = query.list (); - return resultList; - } - - - /** - * Return a VNF COMPONENTSrecipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, - * MODEL_CUSTOMIZATION_UUID, ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION - * first query VF_MODULE table by type, and then use the ID to query - * VNF_COMPONENTS_RECIPE by VF_MODULE_ID and ACTION - * - * @param vnfType - * @parm vfModuleModelName - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfComponentsRecipe getVnfComponentsRecipe (String vnfType, String vfModuleModelName, String modelCustomizationUuid, String asdcServiceModelVersion, String modelVersion, String action) { - String vfModuleType = vnfType + "::" + vfModuleModelName; - long startTime = System.currentTimeMillis (); - List <VfModule> resultList = getVfModule(vfModuleType, modelCustomizationUuid, asdcServiceModelVersion, modelVersion, action); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF Module Entry not found", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - VfModule vfMod = resultList.get(0); - - String vfModuleId = vfMod.getModelUUID(); - - LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId - + " and action " - + action); - - Query query1 = getSession ().createQuery ( - "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); - query1.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList1 = query1.list (); - - if (resultList1.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - - resultList1.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList1); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVnfComponentsRecipe", null); - if (resultList1.size() > 1 && (!resultList1. get (0).getOrchestrationUri().equals(resultList1.get (1).getOrchestrationUri ()))) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Different ORCHESTRATION URIs found for same VERSION and ID. No result returned.", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - return resultList1.get (0); - } - - /** - * Return a VNF COMPONENTSrecipe that matches a given VNF_TYPE, VF_MODULE_MODEL_NAME, - * ASDC_SERVICE_MODEL_VERSION, MODEL_VERSION, and ACTION - * first query VF_MODULE table by type, and then use the ID to query - * VNF_COMPONENTS_RECIPE by VF_MODULE_ID and ACTION - * - * @param vnfType - * @parm vfModuleModelName - * @param action - * @return VnfRecipe object or null if none found - */ - public VnfComponentsRecipe getVnfComponentsRecipeByVfModule(List <VfModule> resultList, String action) { - long startTime = System.currentTimeMillis (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VF Module Entry not found", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - VfModule vfMod = resultList.get(0); - - String vfModuleId = vfMod.getModelName(); - - LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId - + " and action " - + action); - - Query query1 = getSession ().createQuery ( - "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action "); - query1.setParameter (VF_MODULE_MODEL_UUID, vfModuleId); - query1.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList1 = query1.list (); - - if (resultList1.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - - resultList1.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList1); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe found", "CatalogDB", "getVnfComponentsRecipe", null); - if (resultList1.size() > 1 && (!resultList1. get (0).getOrchestrationUri().equals(resultList1.get (1).getOrchestrationUri ()))) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Different ORCHESTRATION URIs found for same VERSION and ID. No result returned.", "CatalogDB", "getVnfComponentsRecipe", null); - return null; - } - return resultList1.get (0); - } - - - /** - * Return all VNF Resources in the Catalog DB - * - * @return A list of VnfResource objects - */ - @SuppressWarnings("unchecked") - public List <VnfResource> getAllVnfResources () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all VNF resources"); - - String hql = "FROM VnfResource"; - Query query = getSession ().createQuery (hql); - - List <VnfResource> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVnfResources", null); - return result; - } - - /** - * Return VNF Resources in the Catalog DB that match a given VNF role - * - * @return A list of VnfResource objects - */ - @SuppressWarnings("unchecked") - @Deprecated // vnfRole is no longer in VnfResource - public List <VnfResource> getVnfResourcesByRole (String vnfRole) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all VNF resources for role " + vnfRole); - - String hql = "FROM VnfResource WHERE vnfRole = :vnfRole"; - Query query = getSession ().createQuery (hql); - query.setParameter ("vnfRole", vnfRole); - - List <VnfResource> resources = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourcesByRole", null); - return resources; - } - - /** - * Return VNF Resources in the Catalog DB that match a given VNF role - * - * @return A list of VnfResource objects - */ - @SuppressWarnings("unchecked") - public List<VnfResourceCustomization> getVnfResourceCustomizationsByRole(String vnfRole) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all VNF resource customizations for role " + vnfRole); - - String hql = "FROM VnfResourceCustomization WHERE nfRole = :vnfRole"; - Query query = getSession ().createQuery (hql); - query.setParameter ("vnfRole", vnfRole); - - List <VnfResourceCustomization> resources = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfResourceCustomizationsByRole", null); - return resources; - } - - /** - * Return all Network Resources in the Catalog DB - * - * @return A list of NetworkResource objects - */ - @SuppressWarnings("unchecked") - public List <NetworkResource> getAllNetworkResources () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all network resources"); - - String hql = "FROM NetworkResource"; - Query query = getSession ().createQuery (hql); - - List <NetworkResource> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworkResources", null); - return result; - } - - @SuppressWarnings("unchecked") - public List<NetworkResourceCustomization> getAllNetworkResourceCustomizations() { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all network resource customizations"); - - String hql = "FROM NetworkResourceCustomization"; - Query query = getSession ().createQuery (hql); - - List <NetworkResourceCustomization> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllNetworkResourceCustomizations", null); - return result; - } - - /** - * Return all VF Modules in the Catalog DB - * - * @return A list of VfModule objects - */ - @SuppressWarnings("unchecked") - public List <VfModule> getAllVfModules () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all vf modules"); - - String hql = "FROM VfModule"; - Query query = getSession ().createQuery (hql); - - List <VfModule> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVfModules", null); - return result; - } - - @SuppressWarnings("unchecked") - public List <VfModuleCustomization> getAllVfModuleCustomizations () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all vf module customizations"); - - String hql = "FROM VfModuleCustomization"; - Query query = getSession ().createQuery (hql); - - List <VfModuleCustomization> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllVfModuleCustomizations", null); - return result; - } - - - /** - * Return all HeatEnvironment in the Catalog DB - * - * @return A list of HeatEnvironment objects - */ - @SuppressWarnings("unchecked") - public List <HeatEnvironment> getAllHeatEnvironment () { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get all Heat environments"); - - String hql = "FROM HeatEnvironment"; - Query query = getSession ().createQuery (hql); - - List <HeatEnvironment> result = query.list (); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllHeatEnvironment", null); - return result; - } - - /** - * Fetch the Environment by Environment ID - 1510 - */ - @Deprecated // no longer in heat envt table - public HeatEnvironment getHeatEnvironment (int id) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Heat environment with id " + id); - - String hql = "FROM HeatEnvironment WHERE id = :idValue"; - - LOGGER.debug ("getHeatEnvironment called with id=" + id); - - Query query = getSession ().createQuery (hql); - query.setParameter ("idValue", id); - - @SuppressWarnings("unchecked") - List <HeatEnvironment> resultList = query.list (); - - // See if something came back. - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Heat environment not found", "CatalogDB", "getHeatEnvironment", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatEnvironment", null); - return resultList.get (0); - } - - /** - * Fetch the nested templates - 1510 - */ - - @Deprecated - public Map <String, Object> getNestedTemplates (int templateId) { - Map <String, Object> nestedTemplates; - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getNestedTemplates called with templateId " + templateId); - - String hql = "FROM HeatNestedTemplate where parent_template_id = :parentIdValue"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("parentIdValue", templateId); - - @SuppressWarnings("unchecked") - List <HeatNestedTemplate> resultList = query.list (); - // If nothing comes back, there are no nested templates - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No nestedTemplate found", "CatalogDB", "getNestedTemplates", null); - LOGGER.debug ("No nestedTemplates found for templateId=" + templateId + ", " + hql); - return null; - } - // Now, for each entry in NESTED_HEAT_TEMPLATES, we need to grab the template body from HEAT_TEMPLATE - nestedTemplates = new HashMap <> (); - for (HeatNestedTemplate hnt : resultList) { - LOGGER.debug ("Querying for " + hnt); - HeatTemplate ht = this.getHeatTemplate (hnt.getChildTemplateId ()); - if (ht == null) { - LOGGER.debug ("No template found matching childTemplateId=" + hnt.getChildTemplateId ()); - continue; - } - String providerResourceFile = hnt.getProviderResourceFile (); - String heatTemplateBody = ht.getTemplateBody (); - if (providerResourceFile != null && heatTemplateBody != null) { - nestedTemplates.put (providerResourceFile, heatTemplateBody); - } else { - LOGGER.debug ("providerResourceFile or heatTemplateBody were null - do not add to HashMap!"); - } - } - // Make sure we're not returning an empty map - if so, just return null - if (nestedTemplates.isEmpty ()) { - LOGGER.debug ("nestedTemplates is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Nested template is empty", "CatalogDB", "getNestedTemplate", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNestedTemplate", null); - return nestedTemplates; - } - /** - * Return a Map<String, Object> for returning the child templates and their contents - * - * @param parentHeatTemplateId - * @return Map<String,Object> or null if none found - */ - public Map <String, Object> getNestedTemplates (String parentHeatTemplateId) { - Map <String, Object> nestedTemplates; - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getNestedTemplates called with parentTemplateId " + parentHeatTemplateId); - - String hql = "FROM HeatNestedTemplate where parentTemplateId = :parentHeatTemplateId"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("parentHeatTemplateId", parentHeatTemplateId); - - @SuppressWarnings("unchecked") - List <HeatNestedTemplate> resultList = query.list (); - // If nothing comes back, there are no nested templates - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No nestedTemplate found", "CatalogDB", "getNestedTemplates", null); - LOGGER.debug ("No nestedTemplates found for templateId=" + parentHeatTemplateId + ", " + hql); - return null; - } - // Now, for each entry in NESTED_HEAT_TEMPLATES, we need to grab the template body from HEAT_TEMPLATE - nestedTemplates = new HashMap <> (); - for (HeatNestedTemplate hnt : resultList) { - LOGGER.debug ("Querying for " + hnt); - HeatTemplate ht = this.getHeatTemplateByArtifactUuid (hnt.getChildTemplateId ()); - if (ht == null) { - LOGGER.debug ("No template found matching childTemplateId=" + hnt.getChildTemplateId ()); - continue; - } - String providerResourceFile = hnt.getProviderResourceFile (); - String heatTemplateBody = ht.getTemplateBody (); - if (providerResourceFile != null && heatTemplateBody != null) { - nestedTemplates.put (providerResourceFile, heatTemplateBody); - } else { - LOGGER.debug ("providerResourceFile or heatTemplateBody were null - do not add to HashMap!"); - } - } - // Make sure we're not returning an empty map - if so, just return null - if (nestedTemplates.isEmpty ()) { - LOGGER.debug ("nestedTemplates is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Nested template is empty", "CatalogDB", "getNestedTemplate", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNestedTemplate", null); - return nestedTemplates; - } - - /* - * Fetch any files in the HEAT_FILES table 1510 - */ - @Deprecated - public Map <String, HeatFiles> getHeatFiles (int vnfResourceId) { - Map <String, HeatFiles> heatFiles; - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFiles called with vnfResourceId " + vnfResourceId); - String hql = "FROM HeatFiles where vnf_resource_id = :vnfResourceIdValue"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("vnfResourceIdValue", vnfResourceId); - - @SuppressWarnings("unchecked") - List <HeatFiles> resultList = query.list (); - // If nothing comes back, there are no heat files - if (resultList.isEmpty ()) { - LOGGER.debug ("No heatFiles found for vnfResourceId=" + vnfResourceId); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No heat files", "CatalogDB", "getHeatFiles", null); - return null; - } - // Now, we just need to return a HashMap (key=fileName, object=fileBody) - heatFiles = new HashMap <> (); - for (HeatFiles hf : resultList) { - LOGGER.debug ("Adding " + hf.getFileName () + "->" + hf.getFileBody ()); - heatFiles.put (hf.getFileName (), hf); - } - // Make sure we're not returning an empty map - if so, just return null - if (heatFiles.isEmpty ()) { - LOGGER.debug ("heatFiles is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Heat files is empty", "CatalogDB", "getHeatFiles", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFiles", null); - return heatFiles; - } - - // New 1607 - with modularization, use new table to determine which HEAT_FILES entries to attach - @Deprecated - public Map <String, HeatFiles> getHeatFilesForVfModule(int vfModuleId) { - /* - Map <String, HeatFiles> heatFiles = null; - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFilesForVfModule called with vfModuleId " + vfModuleId); - String hql = "FROM VfModuleToHeatFiles where vf_module_id = :vfModuleIdValue"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("vfModuleIdValue", vfModuleId); - - List<VfModuleToHeatFiles> mapList = query.list(); - if (mapList.isEmpty()) { - LOGGER.debug ("No heatFiles found for vfModuleId=" + vfModuleId); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No heatfiles found for vfModule", "CatalogDB", "getHeatFilesForVfModule", null); - return null; - } - //Now the fun part - we have a list of the heat files we need to get - could clean this up with a join - heatFiles = new HashMap<String, HeatFiles>(); - for (VfModuleToHeatFiles vmthf : mapList) { - int heatFilesId = vmthf.getHeatFilesId(); - hql = "FROM HeatFiles where id = :id_value"; - query = getSession().createQuery(hql); - query.setParameter("id_value", heatFilesId); - List<HeatFiles> fileList = query.list(); - if (fileList.isEmpty()) { - // Should this throw an exception?? - LOGGER.debug("Unable to find a HEAT_FILES entry at " + heatFilesId); - String errorString = "_ERROR|" + heatFilesId; - // The receiving code needs to know to throw an exception for this - or ignore it. - heatFiles.put(errorString, null); - } else { - // Should only ever have 1 result - add it to our Map - LOGGER.debug("Retrieved " + fileList.size() + " heat file entry at " + heatFilesId); - for (HeatFiles hf : fileList) { - LOGGER.debug("Adding " + hf.getFileName() + "->" + hf.getFileBody()); - heatFiles.put(hf.getFileName(), hf); - } - } - } - if (heatFiles.isEmpty()) { - LOGGER.debug ("heatFiles is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. HeatFiles is empty", "CatalogDB", "getHeatFilesForVfModule", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFilesForVfModule", null); - return heatFiles; - */ - return null; - } - - /** - * Return a VfModuleToHeatFiles object - * - * @param vfModuleModelUuid, heatFilesArtifactUuid - * @return VfModuleToHeatFiles or null if none found - */ - public VfModuleToHeatFiles getVfModuleToHeatFilesEntry(String vfModuleModelUuid, String heatFilesArtifactUuid) { - - LOGGER.debug ("Catalog database - getVfModuleToHeatFilesEntry with vfModuleModelUuid " + vfModuleModelUuid + ", heatFilesArtifactUuid=" + heatFilesArtifactUuid); - String hql = "FROM VfModuleToHeatFiles where vfModuleModelUuid = :vfModuleModelUuidValue and heatFilesArtifactUuid = :heatFilesArtifactUuidValue"; - - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("vfModuleModelUuidValue", vfModuleModelUuid); - parameters.put("heatFilesArtifactUuidValue", heatFilesArtifactUuid); - - VfModuleToHeatFiles vmthf = null; - - try { - vmthf = this.executeQuerySingleRow(hql, parameters, true); - } catch (Exception e) { - throw e; - } - return vmthf; - } - - - /** - * Return a ServiceToResourceCustomization object - * - * @param serviceModelUuid - * @param resourceModelCustomizationUuid - * @param modelType - * @return VfModuleToHeatFiles or null if none found - */ - public ServiceToResourceCustomization getServiceToResourceCustomization(String serviceModelUuid, String resourceModelCustomizationUuid, String modelType) { - - LOGGER.debug ("Catalog database - getServiceToResourceCustomization with serviceModelUuid=" + serviceModelUuid + ", resourceModelCustomizationUuid=" + resourceModelCustomizationUuid + ", modelType=" + modelType); - String hql = "FROM ServiceToResourceCustomization where serviceModelUUID = :serviceModelUuidValue and resourceModelCustomizationUUID = :resourceModelCustomizationUuidValue and modelType = :modelTypeValue "; - - HashMap<String, String> parameters = new HashMap<>(); - parameters.put("serviceModelUuidValue", serviceModelUuid); - parameters.put("resourceModelCustomizationUuidValue", resourceModelCustomizationUuid); - parameters.put("modelTypeValue", modelType); - - ServiceToResourceCustomization strc = null; - - try { - strc = this.executeQuerySingleRow(hql, parameters, true); - } catch (Exception e) { - throw e; - } - return strc; - } - - /** - * Return a Map<String, HeatFiles> for returning the heat files associated with a vfModule 1707 - * - * @param vfModuleModelUuid - * @return Map<String,Object> or null if none found - */ - public Map <String, HeatFiles> getHeatFilesForVfModule(String vfModuleModelUuid) { - Map <String, HeatFiles> heatFiles; - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFilesForVfModule called with vfModuleModelUuid " + vfModuleModelUuid); - String hql = "FROM VfModuleToHeatFiles where vfModuleModelUuid = :vfModuleModelUuidValue"; - - Query query = getSession ().createQuery (hql); - query.setParameter ("vfModuleModelUuidValue", vfModuleModelUuid); - - @SuppressWarnings("unchecked") - List<VfModuleToHeatFiles> mapList = query.list(); - if (mapList.isEmpty()) { - LOGGER.debug ("No heatFiles found for vfModuleModelUuid=" + vfModuleModelUuid); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No heatfiles found for vfModule", "CatalogDB", "getHeatFilesForVfModule", null); - return null; - } - //Now the fun part - we have a list of the heat files we need to get - could clean this up with a join - heatFiles = new HashMap<>(); - for (VfModuleToHeatFiles vmthf : mapList) { - String heatFilesUuid = vmthf.getHeatFilesArtifactUuid(); - hql = "FROM HeatFiles where artifactUuid = :heatFilesUuidValue"; - query = getSession().createQuery(hql); - query.setParameter("heatFilesUuidValue", heatFilesUuid); - @SuppressWarnings("unchecked") - List<HeatFiles> fileList = query.list(); - if (fileList.isEmpty()) { - // Should this throw an exception?? - LOGGER.debug("Unable to find a HEAT_FILES entry at " + heatFilesUuid); - String errorString = "_ERROR|" + heatFilesUuid; - // The receiving code needs to know to throw an exception for this - or ignore it. - heatFiles.put(errorString, null); - } else { - // Should only ever have 1 result - add it to our Map - LOGGER.debug("Retrieved " + fileList.size() + " heat file entry at " + heatFilesUuid); - for (HeatFiles hf : fileList) { - LOGGER.debug("Adding " + hf.getFileName() + "->" + hf.getFileBody()); - heatFiles.put(hf.getFileName(), hf); - } - } - } - if (heatFiles.isEmpty()) { - LOGGER.debug ("heatFiles is empty - just return null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. HeatFiles is empty", "CatalogDB", "getHeatFilesForVfModule", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFilesForVfModule", null); - return heatFiles; - } - - /** - * Get the heat template object based on asdc attributes - * - * @param templateName The template name, generally the yaml filename. "example.yaml" - * @param version The version as specified by ASDC. "1.1" - * @param asdcResourceName The ASDC resource name provided in the ASDC artifact - * - * @return The HeatTemplate - */ - @Deprecated // asdcResourceName is no longer in heatTeamplate - public HeatTemplate getHeatTemplate (String templateName, String version, String asdcResourceName) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatTemplate with name " + templateName - + " and version " - + version - + " and ASDC resource name " - + asdcResourceName); - - String hql = "FROM HeatTemplate WHERE templateName = :template_name AND version = :version AND asdcResourceName = :asdcResourceName"; - Query query = getSession ().createQuery (hql); - query.setParameter (TEMPLATE_NAME, templateName); - query.setParameter (MODEL_VERSION, version); - query.setParameter ("asdcResourceName", asdcResourceName); - - @SuppressWarnings("unchecked") - List <HeatTemplate> resultList = query.list (); - - // See if something came back. - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Heat template not found", "CatalogDB", "getHeatTemplate", null); - return null; - } - // Name + Version is unique, so should only be one element - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - return resultList.get (0); - } - - - /** - * Save the Heat Template - * - * @param heat The heat template - * @param paramSet The list of heat template parameters - */ - public void saveHeatTemplate (HeatTemplate heat, Set <HeatTemplateParam> paramSet) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat Template with name " + heat.getTemplateName() + ", artifactUUID=" + heat.getArtifactUuid()); - - heat.setParameters(null); - try { - - HeatTemplate heatTemp = this.getHeatTemplateByArtifactUuidRegularQuery(heat.getArtifactUuid()); - - if (heatTemp == null) { - this.getSession ().save (heat); - - if (paramSet != null) { - StringBuilder sb = new StringBuilder("Parameters: "); - for (HeatTemplateParam param : paramSet) { - param.setHeatTemplateArtifactUuid(heat.getArtifactUuid()); - sb.append(param.getParamName()).append(", "); - } - LOGGER.debug(sb.toString()); - heat.setParameters (paramSet); - try { - Session session = this.getSession(); - if (!(session.isConnected() && session.isOpen())) { - LOGGER.debug("Initial session is not connected or open - get another"); - session = this.getSession(); - } - session.save(heat); - } catch (HibernateException he1) { - LOGGER.debug("Hibernate Exception encountered on first attempt at save(heat) - try again..." + he1.getMessage(), he1); - try { - Session session = this.getSession(); - session.save(heat); - } catch (HibernateException he2) { - LOGGER.debug("Hibernate Exception encountered on second attempt at save(heat)" + he2.getMessage()); - LOGGER.debug(Arrays.toString(he2.getStackTrace())); - throw he2; - } catch (Exception e2) { - LOGGER.debug("General Exception encountered on second attempt at save(heat)..." + e2.getMessage(),e2); - LOGGER.debug(Arrays.toString(e2.getStackTrace())); - throw e2; - } - - } catch (Exception e1) { - LOGGER.debug("General Exception encountered on first attempt at save(heat) - try again..." + e1.getMessage(), e1); - LOGGER.debug(Arrays.toString(e1.getStackTrace())); - try { - Session session = this.getSession(); - session.save(heat); - } catch (HibernateException he2) { - LOGGER.debug("General Exception encountered on second attempt at save(heat)" + he2.getMessage(), he2); - LOGGER.debug(Arrays.toString(he2.getStackTrace())); - throw he2; - } catch (Exception e2) { - LOGGER.debug("General Exception encountered on second attempt at save(heat)..." + e2.getMessage(), e2); - LOGGER.debug(Arrays.toString(e2.getStackTrace())); - throw e2; - } - } - } - - } else { - heat.setArtifactUuid(heatTemp.getArtifactUuid()); - } - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatTemplate", null); - } - } - - /** - * Retrieves a Heat environment from DB based on its unique key. - * - * @param name the environment artifact name - * @param version the environment resource version - * @param asdcResourceName the environment resource name - * @return the heat environment from DB or null if not found - */ - @Deprecated - public HeatEnvironment getHeatEnvironment (String name, String version, String asdcResourceName) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Heat environment with name " + name - + " and version " - + version - + " and ASDC resource name " - + asdcResourceName); - - String hql = "FROM HeatEnvironment WHERE name=:name AND version=:version AND asdcResourceName=:asdcResourceName"; - Query query = getSession ().createQuery (hql); - query.setParameter ("name", name); - query.setParameter (MODEL_VERSION, version); - query.setParameter ("asdcResourceName", asdcResourceName); - HeatEnvironment env = null; - try { - env = (HeatEnvironment) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: envName='" + name + "', version='" + version + "' and asdcResourceName=" + asdcResourceName, nure); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for envName=" + name + " and version=" + version + " and asdcResourceName=" + asdcResourceName, "", "", MsoLogger.ErrorCode.DataError, "non unique result for envName=" + name); - env = null; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: envName='" + name + "', asdc_service_model_version='" + version + "' and asdcResourceName=" + asdcResourceName, he); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for envName=" + name + " and version=" + version + " and asdcResourceName=" + asdcResourceName, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for envName=" + name); - env = null; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: envName='" + name + "', asdc_service_model_version='" + version + "' and asdcResourceName=" + asdcResourceName, e); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for envName=" + name + " and version=" + version + " and asdcResourceName=" + asdcResourceName, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for envName=" + name); - env = null; - } - if (env == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplate", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - } - return env; - } - - /** - * Retrieves a Heat environment from DB based on its unique key. 1707 - * - * @param artifactUuid the environment artifact name - * @param version the environment resource version - * @return the heat environment from DB or null if not found - */ - public HeatEnvironment getHeatEnvironment (String artifactUuid, String version) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Heat environment with uuid " + artifactUuid - + " and version " - + version); - - String hql = "FROM HeatEnvironment WHERE artifactUuid=:artifactUuid AND version=:version"; - Query query = getSession ().createQuery (hql); - query.setParameter ("artifactUuid", artifactUuid); - query.setParameter (MODEL_VERSION, version); - HeatEnvironment env = null; - try { - env = (HeatEnvironment) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: envName='" + artifactUuid + "', version='" + version); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for artifactUUID=" + artifactUuid + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "non unique result for ArtifactUUID=" + artifactUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: artifactUUID='" + artifactUuid + "', asdc_service_model_version='" + version + " " + he.getMessage() ); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for artifactUUID=" + artifactUuid + " and version=" + version , "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for artifactUUID=" + artifactUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: artifactUUID='" + artifactUuid + "', asdc_service_model_version='" + version + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for artifactUUID=" + artifactUuid + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for artifactUUID=" + artifactUuid); - throw e; - } - if (env == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "getHeatTemplate", null); - } else { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null); - } - return env; - } - - /** - * Save the HeatEnvironment - * - * @param env The Environment - */ - public void saveHeatEnvironment (HeatEnvironment env) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat environment with name " - + env.getEnvironment() + " and ArtifactUUID " + env.getArtifactUuid()); - try { - HeatEnvironment dbEnv = getHeatEnvironment (env.getArtifactUuid(), env.getVersion ()); - if (dbEnv == null) { - - this.getSession ().save (env); - - } else { - env.setArtifactUuid(dbEnv.getArtifactUuid()); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatTemplate", null); - } - } - - /** - * Save the heatTemplate - * - * @param heat The heat template - */ - public void saveHeatTemplate (HeatTemplate heat) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat template with name " + heat.getTemplateName ()); - try { - this.getSession ().update (heat); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatTemplate", null); - } - } - - public void saveHeatFile (HeatFiles heatFile) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat file with name " + heatFile.getFileName ()); - try { - this.getSession ().save (heatFile); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatFile", null); - } - } - - public void saveVnfRecipe (VnfRecipe vnfRecipe) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VNF recipe with VNF type " + vnfRecipe.getVnfType ()); - try { - this.getSession ().save (vnfRecipe); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVnfRecipe", null); - } - } - - public void saveVnfComponentsRecipe (VnfComponentsRecipe vnfComponentsRecipe) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VNF Component recipe with VNF type " + vnfComponentsRecipe.getVnfType ()); - try { - this.getSession ().save (vnfComponentsRecipe); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVnfComponentsRecipe", null); - } - } - - - public void saveOrUpdateVnfResource (VnfResource vnfResource) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VNF Resource with VNF type " + vnfResource.getModelName()); - try { - - VnfResource existing = this.getVnfResourceByModelUuid(vnfResource.getModelUuid()); - if (existing == null) { - LOGGER.debug("No existing entry found - attempting to save..."); - this.getSession ().save (vnfResource); - } else { - LOGGER.debug("Existing vnf resource found!"); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVnfResource", null); - } - } - - public boolean saveVnfResourceCustomization (VnfResourceCustomization vnfResourceCustomization) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VNF Resource Customization with Name " + vnfResourceCustomization.getModelInstanceName()); - try { - LOGGER.debug(vnfResourceCustomization.toString()); - } catch (Exception e) { - LOGGER.debug("Unable to print VRC " + e.getMessage(), e); - } - try { - // Check if NetworkResourceCustomzation record already exists. If so, skip saving it. - // List<NetworkResource> networkResourceList = getAllNetworksByNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid()); - // Do any matching customization records exist? - // if(networkResourceList.size() == 0){ - - // networkResourceCustomization.setNetworkResourceModelUuid(networkResource.getModelUuid()); - // this.getSession().flush(); - // this.getSession().clear(); - - VnfResourceCustomization existing = this.getVnfResourceCustomizationByModelCustomizationUuid(vnfResourceCustomization.getModelCustomizationUuid()); - - if (existing == null) { - LOGGER.debug("No existing entry found...attempting to save..."); - this.getSession ().save (vnfResourceCustomization); - return true; - }else { - try { - LOGGER.debug("Existing VRC entry found\n" + existing.toString()); - } catch (Exception e) { - LOGGER.debug("Unable to print VRC2 " + e.getMessage(), e); - } - return false; - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVnfResourceCustomization", null); - } - } - - public void saveAllottedResourceCustomization (AllottedResourceCustomization resourceCustomization) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Allotted Resource with Name " + resourceCustomization.getModelInstanceName()); - try { - List<AllottedResourceCustomization> allottedResourcesList = getAllAllottedResourcesByArModelCustomizationUuid(resourceCustomization.getModelCustomizationUuid()); - - if(allottedResourcesList.isEmpty()){ - this.getSession ().save(resourceCustomization); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateAllottedResourceCustomization", null); - } - } - - public void saveAllottedResource (AllottedResource allottedResource) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Allotted Resource with Name " + allottedResource.getModelName()); - try { - AllottedResource existing = this.getAllottedResourceByModelUuid(allottedResource.getModelUuid()); - if (existing == null) { - this.getSession ().save (allottedResource); - } else { - LOGGER.debug("Found existing allottedResource with this modelUuid - no need to save"); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateAllottedResourceCustomization", null); - } - } - - public void saveVnfResource (VnfResource vnfResource) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save vnf Resource with Name " + vnfResource.getModelName()); - try { - VnfResource existing = this.getVnfResourceByModelUuid(vnfResource.getModelUuid()); - if (existing == null) { - this.getSession().save(vnfResource); - } else { - LOGGER.debug("Found existing vnfResource with this modelUuid - no need to save"); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVnfResourceCustomization", null); - } - } - - public void saveNetworkResource (NetworkResource networkResource) throws RecordNotFoundException { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Network Resource with Network Name " + networkResource.getModelName()); - try { - // Check if NetworkResourceCustomzation record already exists. If so, skip saving it. - // List<NetworkResource> networkResourceList = getAllNetworksByNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid()); - // Do any matching customization records exist? - if(getNetworkResourceByModelUuid(networkResource.getModelUUID()) == null){ - this.getSession ().save(networkResource); - } - - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNetworkResourceCustomization", null); - } - } - - public void saveToscaCsar (ToscaCsar toscaCsar) throws RecordNotFoundException { - - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Tosca Csar with Name " + toscaCsar.getName()); - try { - - if(getToscaCsar(toscaCsar.getArtifactChecksum()) == null){ - this.getSession ().save (toscaCsar); - } - LOGGER.debug("Temporarily disabling saveToscaCsar pending further investigation 2017-06-02"); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveToscaCsar", null); - } - } - - - /** - * Return the newest version of a specific Tosca CSAR Record resource (queried by Name). - * - * @param artifactChecksum - * @return ToscaCsar object or null if none found - */ - public ToscaCsar getToscaCsar (String artifactChecksum) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Tosca CSAR record with artifactChecksum " + artifactChecksum); - - String hql = "FROM ToscaCsar WHERE artifactChecksum = :artifactChecksum"; - Query query = getSession ().createQuery (hql); - query.setParameter ("artifactChecksum", artifactChecksum); - - @SuppressWarnings("unchecked") - List <ToscaCsar> resultList = query.list (); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Tosca Csar not found", "CatalogDB", "getToscaCsar", null); - return null; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsar", null); - return resultList.get (0); - } - - /** - * Return a specific Tosca CSAR Record resource (queried by atrifact uuid). - * - * @param toscaCsarArtifactUUID the artifact uuid of the tosca csar - * @return ToscaCsar object or null if none found - */ - public ToscaCsar getToscaCsarByUUID(String toscaCsarArtifactUUID){ - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Tosca CSAR record with artifactUUID " + toscaCsarArtifactUUID); - - String hql = "FROM ToscaCsar WHERE artifactUUID = :toscaCsarArtifactUUID"; - Query query = getSession ().createQuery (hql); - query.setParameter ("toscaCsarArtifactUUID", toscaCsarArtifactUUID); - - @SuppressWarnings("unchecked") - List <ToscaCsar> resultList = query.list (); - - // See if something came back. Name is unique, so - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Tosca Csar not found", "CatalogDB", "getToscaCsarByUUID", null); - return null; - } - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsarByUUID", null); - return resultList.get (0); - } - - /** - * Return a specific Tosca CSAR Record resource (queried by service model uuid). - * <br> - * - * @param serviceModelUUID the service model uuid - * @return ToscaCsar object or null if none found - * @since ONAP Beijing Release - */ - public ToscaCsar getToscaCsarByServiceModelUUID(String serviceModelUUID){ - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Tosca CSAR record with serviceModelUUID " + serviceModelUUID); - Service service = getServiceByModelUUID(serviceModelUUID); - if(null == service){ - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Service not found", "CatalogDB", "getToscaCsarByServiceModelUUID", null); - return null; - } - ToscaCsar csar = getToscaCsarByUUID(service.getToscaCsarArtifactUUID()); - if(null == csar){ - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Tosca csar of the service not found", "CatalogDB", "getToscaCsarByServiceModelUUID", null); - return null; - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsarByServiceModelUUID", null); - return csar; - } - - public void saveTempNetworkHeatTemplateLookup (TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save TempNetworkHeatTemplateLookup with Network Model Name " + tempNetworkHeatTemplateLookup.getNetworkResourceModelName() + - " and Heat Template Artifact UUID " + tempNetworkHeatTemplateLookup.getHeatTemplateArtifactUuid()); - try { - this.getSession ().save (tempNetworkHeatTemplateLookup); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveTempNetworkHeatTemplateLookup", null); - } - } - - public void saveVfModuleToHeatFiles (VfModuleToHeatFiles vfModuleToHeatFiles) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VfModuleToHeatFiles with VF Module UUID " + vfModuleToHeatFiles.getVfModuleModelUuid() + - " and Heat Files Artifact UUID " + vfModuleToHeatFiles.getHeatFilesArtifactUuid()); - try { - - this.getSession ().save (vfModuleToHeatFiles); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVFModuleToHeatFiles", null); - } - } - - public void saveVnfResourceToVfModuleCustomization(VnfResourceCustomization vnfResourceCustomizationUUID, VfModuleCustomization vfModuleCustomizationUUID) throws RecordNotFoundException { - long startTime = System.currentTimeMillis (); - VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom(); - - if(vnfResourceCustomizationUUID != null && vfModuleCustomizationUUID != null){ - vnfResCustomToVfModuleCustom.setVnfResourceCustModelCustomizationUuid(vnfResourceCustomizationUUID.getModelCustomizationUuid()); - vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vfModuleCustomizationUUID.getModelCustomizationUuid()); - String vnfId = vnfResourceCustomizationUUID.getModelCustomizationUuid(); - String vfId = vfModuleCustomizationUUID.getModelCustomizationUuid(); - LOGGER.debug ("Catalog database - save VnfResCustomToVfModuleCustom with vnf=" + vnfId + ", vf=" + vfId); - try { - VnfResCustomToVfModuleCustom existing = this.getVnfResCustomToVfModule(vnfId, vfId); - if (existing == null) { - LOGGER.debug("No existing entry found - will now try to save"); - this.getSession ().save (vnfResCustomToVfModuleCustom); - } else { - LOGGER.debug("Existing entry already found - no save needed"); - } - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVnfResourceToVfModuleCustomization", null); - } - } - } - - public void saveNetworkResourceCustomization (NetworkResourceCustomization networkResourceCustomization) throws RecordNotFoundException { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Network Resource Customization with Network Name " + networkResourceCustomization.getModelInstanceName()); - try { - // Check if NetworkResourceCustomzation record already exists. If so, skip saving it. - List<NetworkResourceCustomization> networkResourceCustomizationList = getAllNetworksByNetworkModelCustomizationUuid(networkResourceCustomization.getModelCustomizationUuid()); - // Do any matching customization records exist? - if(networkResourceCustomizationList.isEmpty()){ - - // Retreive the record from the Network_Resource table associated to the Customization record based on ModelName - // ?? is it modelInstanceName with 1707? - NetworkResource networkResource = getNetworkResource(networkResourceCustomization.getModelInstanceName()); - - if(networkResource == null){ - throw new RecordNotFoundException("No record found in NETWORK_RESOURCE table for model name " + networkResourceCustomization.getModelInstanceName()); - } - - networkResourceCustomization.setNetworkResourceModelUuid(networkResource.getModelUUID()); - - this.getSession ().save(networkResourceCustomization); - } - - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNetworkResourceCustomization", null); - } - } - - @Deprecated // table is gone - mapped to ServiceToResource - public void saveServiceToNetworks (ServiceToNetworks serviceToNetworks) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save to ServiceToNetworks table with NetworkModelCustomizationUUID of " + serviceToNetworks.getNetworkModelCustomizationUuid() + " and ServiceModelUUID of " + serviceToNetworks.getServiceModelUuid()); - try { - this.getSession ().save(serviceToNetworks); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNetworkResourceCustomization", null); - } - } - - public void saveServiceToResourceCustomization(ServiceToResourceCustomization serviceToResource) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save to ServiceToResourceCustomization table with ServiceModelUuid of " + serviceToResource.getServiceModelUUID() + ", ResourceModelUUID of " + serviceToResource.getResourceModelCustomizationUUID() + " and model_type=" + serviceToResource.getModelType()); - ServiceToResourceCustomization strc = this.getServiceToResourceCustomization(serviceToResource.getServiceModelUUID(), serviceToResource.getResourceModelCustomizationUUID(), serviceToResource.getModelType()); - try { - if (strc != null) { - LOGGER.debug("**This ServiceToResourceCustomization record already exists - no need to save"); - } else { - this.getSession ().save(serviceToResource); - } - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveServiceToResourceCustomization", null); - } - } - - @Deprecated // table is gone - mapped to ServiceToResourceCustomization - public void saveServiceToAllottedResources (ServiceToAllottedResources serviceToAllottedResources) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save to serviceToAllottedResources table with ARModelCustomizationUUID of " + serviceToAllottedResources.getArModelCustomizationUuid() + " and ServiceModelUUID of " + serviceToAllottedResources.getServiceModelUuid()); - try { - this.getSession ().save(serviceToAllottedResources); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveServiceToAllottedResources", null); - } - } - - public void saveService (Service service) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Service with ServiceName/Version/serviceUUID(SERVICE_NAME_VERSION_ID)" + service.getModelName()+"/"+service.getVersion()+"/"+service.getModelUUID()); - try { - Service serviceInvariantDB = null; - // Retrieve existing service record by nameVersionId - Service serviceDB = this.getServiceByModelUUID(service.getModelUUID()); - if (serviceDB == null) { - // Check to see if a record with the same modelInvariantId already exists. This tells us that a previous version exists and we can copy its recipe Record for the new service record. - serviceInvariantDB = this.getServiceByInvariantUUID(service.getModelInvariantUUID()); - // Save the new Service record - this.getSession ().save (service); - } - - if(serviceInvariantDB != null){ // existing modelInvariantId was found. - // copy the recipe record with the matching invariant id. We will duplicate this for the new service record - List<ServiceRecipe> serviceRecipes = getServiceRecipes(serviceInvariantDB.getModelUUID()); - - if(serviceRecipes != null && ! serviceRecipes.isEmpty()){ - for(ServiceRecipe serviceRecipe : serviceRecipes){ - if(serviceRecipe != null){ - // Fetch the service record that we just added. We do this so we can extract its Id column value, this will be the foreign key we use in the service recipe table. - Service newService = this.getServiceByModelUUID(service.getModelUUID()); - // Create a new ServiceRecipe record based on the existing one we just copied from the DB. - ServiceRecipe newServiceRecipe = new ServiceRecipe(); - newServiceRecipe.setAction(serviceRecipe.getAction()); - newServiceRecipe.setDescription(serviceRecipe.getDescription()); - newServiceRecipe.setOrchestrationUri(serviceRecipe.getOrchestrationUri()); - newServiceRecipe.setRecipeTimeout(serviceRecipe.getRecipeTimeout()); - newServiceRecipe.setServiceParamXSD(serviceRecipe.getServiceParamXSD()); - newServiceRecipe.setServiceModelUUID(newService.getModelUUID()); - newServiceRecipe.setVersion(serviceRecipe.getVersion()); - // Check recipe does not exist before inserting - ServiceRecipe recipe = getServiceRecipeByModelUUID(newServiceRecipe.getServiceModelUUID(), newServiceRecipe.getAction()); - // Save the new recipe record in the service_recipe table and associate it to the new service record that we just added. - if(recipe == null){ - this.getSession ().save (newServiceRecipe); - } - } - } - } - } - - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateService", null); - } - } - - public void saveOrUpdateVfModule (VfModule vfModule) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save or update VF Module with VF Model Name " + vfModule.getModelName()); - VfModule vfModuleInvariantDB = null; - try { - LOGGER.debug("heat template id = " + vfModule.getHeatTemplateArtifactUUId() + ", vol template id = "+ vfModule.getVolHeatTemplateArtifactUUId()); - LOGGER.debug(vfModule.toString()); - } catch (Exception e) { - LOGGER.debug("unable to print vfmodule " + e.getMessage(), e); - } - try { - VfModule existing = this.getVfModuleByModelUUID(vfModule.getModelUUID()); - if (existing == null) { - // Check to see if a record with the same modelInvariantId already exists. This tells us that a previous version exists and we can copy its recipe Record for the new service record. - vfModuleInvariantDB = this.getVfModuleByModelInvariantUuid(vfModule.getModelInvariantUUID()); - LOGGER.debug("No existing entry found, attempting to save..."); - this.getSession ().save (vfModule); - } else { - try { - LOGGER.debug("Found an existing vf module!\n" + existing.toString()); - } catch (Exception e) { - LOGGER.debug("unable to print vfmodule2 " + e.getMessage(), e); - } - } - - if(vfModuleInvariantDB != null){ // existing modelInvariantId was found. - // copy the recipe record with the matching invariant id. We will duplicate this for the new service record - List<VnfComponentsRecipe> vfRecipes = getVnfComponentRecipes(vfModuleInvariantDB.getModelUUID()); - - - if(vfRecipes != null && ! vfRecipes.isEmpty()){ - for(VnfComponentsRecipe vfRecipe : vfRecipes){ - if(vfRecipe != null){ - // Fetch the service record that we just added. We do this so we can extract its Id column value, this will be the foreign key we use in the service recipe table. - VfModule newRecipe = this.getVfModuleByModelUUID(vfModule.getModelUUID()); - // Create a new ServiceRecipe record based on the existing one we just copied from the DB. - VnfComponentsRecipe newVnfRecipe = new VnfComponentsRecipe(); - newVnfRecipe.setAction(vfRecipe.getAction()); - newVnfRecipe.setDescription(vfRecipe.getDescription()); - newVnfRecipe.setOrchestrationUri(vfRecipe.getOrchestrationUri()); - newVnfRecipe.setRecipeTimeout(vfRecipe.getRecipeTimeout()); - newVnfRecipe.setParamXSD(vfRecipe.getParamXSD()); - newVnfRecipe.setVfModuleModelUUId(newRecipe.getModelUUID()); - newVnfRecipe.setVersion(vfRecipe.getVersion()); - newVnfRecipe.setVnfComponentType(vfRecipe.getVnfComponentType()); - newVnfRecipe.setVnfType(vfRecipe.getVnfType()); - // Check recipe does not exist before inserting - // VnfComponentsRecipe recipe = getVnfComponentRecipes(newVnfRecipe.getVfModuleModelUUId()); - List<VnfComponentsRecipe> recipe = getVnfComponentRecipes(newVnfRecipe.getVfModuleModelUUId()); - // Save the new recipe record in the service_recipe table and associate it to the new service record that we just added. - // if(recipe == null){ - this.getSession ().save (newVnfRecipe); - // } - } - } - } - - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVfModule", null); - } - } - - public void saveOrUpdateVfModuleCustomization (VfModuleCustomization vfModuleCustomization) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save VF Module Customization with VF Customization Model Name UUID " + vfModuleCustomization.getVfModuleModelUuid()); - try { - LOGGER.debug("env id = " + vfModuleCustomization.getHeatEnvironmentArtifactUuid() + ", vol Env=" + vfModuleCustomization.getVolEnvironmentArtifactUuid()); - LOGGER.debug(vfModuleCustomization.toString()); - } catch (Exception e) { - LOGGER.debug("unable to print vfmodulecust " + e.getMessage(), e); - } - try { - VfModuleCustomization existing = this.getVfModuleCustomizationByModelCustomizationId(vfModuleCustomization.getModelCustomizationUuid()); - if (existing == null) { - LOGGER.debug("No existing entry found, attempting to save..."); - this.getSession ().save (vfModuleCustomization); - } else { - try { - LOGGER.debug("Found an existing vf module customization entry\n" + existing.toString()); - } catch (Exception e) { - LOGGER.debug("unable to print vfmodulecust2 " + e.getMessage(), e); - } - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVfModuleCustomization", null); - } - } - - @Deprecated - public HeatNestedTemplate getNestedHeatTemplate(int parentTemplateId, int childTemplateId) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get nested Heat template with PerentId-Child Id " - + parentTemplateId +"-"+childTemplateId); - try { - HeatNestedTemplate nestedTemplate = new HeatNestedTemplate (); -// nestedTemplate.setParentTemplateId (parentTemplateId); -// nestedTemplate.setChildTemplateId (childTemplateId); - - return (HeatNestedTemplate)session.get (HeatNestedTemplate.class,nestedTemplate); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNestedHeatTemplate", null); - } - } - - // 1707 version - public HeatNestedTemplate getNestedHeatTemplate(String parentTemplateId, String childTemplateId) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get nested Heat template with PerentId=" - + parentTemplateId +", ChildId="+childTemplateId); - try { - HeatNestedTemplate nestedTemplate = new HeatNestedTemplate (); - nestedTemplate.setParentTemplateId (parentTemplateId); - nestedTemplate.setChildTemplateId (childTemplateId); - - return (HeatNestedTemplate)session.get (HeatNestedTemplate.class,nestedTemplate); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNestedHeatTemplate", null); - } - } - - // 1707 - public void saveNestedHeatTemplate (String parentTemplateId, HeatTemplate childTemplate, String yamlFile) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save nested Heat template with name " - + childTemplate.getTemplateName () + ",parentId=" + parentTemplateId + ",childId=" + childTemplate.getArtifactUuid() + ", providerResourceFile=" + yamlFile); - try { - - saveHeatTemplate(childTemplate, childTemplate.getParameters()); - if (getNestedHeatTemplate(parentTemplateId,childTemplate.getArtifactUuid()) == null) { - HeatNestedTemplate nestedTemplate = new HeatNestedTemplate (); - nestedTemplate.setParentTemplateId (parentTemplateId); - nestedTemplate.setChildTemplateId (childTemplate.getArtifactUuid ()); - nestedTemplate.setProviderResourceFile (yamlFile); - session.flush(); - session.save (nestedTemplate); - } - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNestedHeatTemplate", null); - } - } - - @Deprecated - public HeatFiles getHeatFiles(int vnfResourceId,String fileName,String asdcResourceName, String version) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFiles with name " + fileName - + " and vnfResourceID " - + vnfResourceId -// + " and ASDC resource name " - + asdcResourceName - + " and version " - + version); - - String hql = "FROM HeatFiles WHERE fileName = :fileName AND vnfResourceId = :vnfResourceId AND asdcResourceName = :asdcResourceName AND version = :version"; - Query query = getSession ().createQuery (hql); - query.setParameter ("fileName", fileName); - query.setParameter ("vnfResourceId", vnfResourceId); - query.setParameter ("asdcResourceName", asdcResourceName); - query.setParameter (MODEL_VERSION, version); - - @SuppressWarnings("unchecked") - - HeatFiles heatFilesResult = null; - try { - heatFilesResult = (HeatFiles) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: fileName='" + fileName + "', vnfResourceId='" + vnfResourceId + "' and asdcResourceName=" + asdcResourceName + " and version=" + version); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for fileName=" + fileName + " and vnfResourceId=" + vnfResourceId + " and asdcResourceName=" + asdcResourceName + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for fileName=" + fileName); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: fileName='" + fileName + "', vnfResourceId='" + vnfResourceId + "' and asdcResourceName=" + asdcResourceName + " and version=" + version + " " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for fileName=" + fileName + " and vnfResourceId=" + vnfResourceId + " and asdcResourceName=" + asdcResourceName + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for fileName=" + fileName); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: fileName='" + fileName + "', vnfResourceId='" + vnfResourceId + "' and asdcResourceName=" + asdcResourceName + " and version=" + version + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for fileName=" + fileName + " and vnfResourceId=" + vnfResourceId + " and asdcResourceName=" + asdcResourceName + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for fileName=" + fileName); - throw e; - } - - // See if something came back. - if (heatFilesResult == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. HeatFiles not found", "CatalogDB", "getHeatFiles", null); - return null; - } - // Name + Version is unique, so should only be one element - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFiles", null); - return heatFilesResult; - } - - public HeatFiles getHeatFiles(String artifactUuid) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - getHeatFiles with artifactUuid " + artifactUuid); - - String hql = "FROM HeatFiles WHERE artifactUuid = :artifactUuid"; - Query query = getSession ().createQuery (hql); - query.setParameter ("artifactUuid", artifactUuid); - - @SuppressWarnings("unchecked") - - HeatFiles heatFilesResult = null; - try { - heatFilesResult = (HeatFiles) query.uniqueResult (); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row - data integrity error: artifactUuid='" + artifactUuid ); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for artifactUuid=" + artifactUuid); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while searching for: artifactUuid='" + artifactUuid + " " + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for artifactUuid=" + artifactUuid, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for artifactUuid=" + artifactUuid); - throw he; - } catch (Exception e) { - LOGGER.debug("Generic Exception - while searching for: artifactUuid='" + artifactUuid + " " + e.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for artifactUuid=" + artifactUuid , "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for artifactUuid=" + artifactUuid); - throw e; - } - - // See if something came back. - if (heatFilesResult == null) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. HeatFiles not found", "CatalogDB", "getHeatFiles", null); - return null; - } - // Name + Version is unique, so should only be one element - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatFiles", null); - return heatFilesResult; - } - - public void saveHeatFiles (HeatFiles childFile) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat File with name " - + childFile.getFileName()); - try { -// HeatFiles heatFiles = getHeatFiles (childFile.getVnfResourceId(), childFile.getFileName(), childFile.getAsdcResourceName (),childFile.getVersion()); - HeatFiles heatFiles = getHeatFiles (childFile.getArtifactUuid()); - if (heatFiles == null) { - - // asdc_heat_files_save - this.getSession ().save (childFile); - - } else { - /* replaced 'heatFiles' by 'childFile' - Based on following comment: - It must be childFile.setId instead of heatFiles.setId, we must return the ID if it exists in DB. - */ - childFile.setArtifactUuid(heatFiles.getArtifactUuid()); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatFiles", null); - } - } - - public void saveVfModuleToHeatFiles (String parentVfModuleId, HeatFiles childFile) { - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - save Heat File to VFmodule link " - + childFile.getFileName()); - try { - saveHeatFiles (childFile); - VfModuleToHeatFiles checkExistingEntry = this.getVfModuleToHeatFilesEntry(parentVfModuleId, childFile.getArtifactUuid()); - if (checkExistingEntry == null) { - VfModuleToHeatFiles vfModuleToHeatFile = new VfModuleToHeatFiles (); - vfModuleToHeatFile.setVfModuleModelUuid(parentVfModuleId); - vfModuleToHeatFile.setHeatFilesArtifactUuid(childFile.getArtifactUuid()); - session.flush(); - session.save (vfModuleToHeatFile); - } else { - LOGGER.debug("**Found existing VfModuleToHeatFiles entry for " + checkExistingEntry.toString()); - LOGGER.debug("No need to save..."); - } - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVfModuleToHeatFiles", null); - } - } - - /** - * Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID - * - * @param modelUUID - * @return NetworkRecipe object or null if none found - */ - public NetworkResource getNetworkResourceByModelUuid(String modelUUID) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network resource with modelUUID " + modelUUID); - - try { - String hql = "FROM NetworkResource WHERE modelUUID=:modelUUID"; - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_UUID, modelUUID); - - @SuppressWarnings("unchecked") - List <NetworkResource> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } catch (Exception e) { - LOGGER.debug("Error trying to find Network Resource with " + modelUUID +", " + e.getMessage(),e); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceByModelUuid", null); - } - return null; - } - - - /** - * Return a Network recipe that matches a given NETWORK_TYPE, ACTION, and, if specified, SERVICE_TYPE - * - * @param networkType - * @param action - * @param serviceType - * @return NetworkRecipe object or null if none found - */ - public NetworkRecipe getNetworkRecipe (String networkType, String action, String serviceType) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network recipe with network type " + networkType - + " and action " - + action - + " and service type " - + serviceType); - - try { - String hql; - if (serviceType == null) { - hql = "FROM NetworkRecipe WHERE networkType = :networkType AND action = :action AND serviceType IS NULL "; - } else { - hql = "FROM NetworkRecipe WHERE networkType = :networkType AND action = :action AND serviceType = :serviceType "; - } - Query query = getSession ().createQuery (hql); - query.setParameter (NETWORK_TYPE, networkType); - query.setParameter (ACTION, action); - if (serviceType != null) { - query.setParameter ("serviceType", serviceType); - } - - @SuppressWarnings("unchecked") - List <NetworkRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(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 recipe that matches a given MODEL_UUID and ACTION - * - * @param networkModelUuid - * @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); - - if (recipe == null) { - recipe = getDefaultNetworkReceipe(action); - } - - return recipe; - } - - private NetworkRecipe getDefaultNetworkReceipe(String action) { - String modelName = "SDNC_DEFAULT"; - return getNetworkRecipe(modelName, action); - } - - /** - * Return a Network recipe that matches a given MODEL_NAME and ACTION - * - * @param modelName - * @param action - * @return NetworkRecipe object or null if none found - */ - public NetworkRecipe getNetworkRecipe (String modelName, String action) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network recipe with network model name " + modelName - + " and action " - + action - ); - - try { - String hql = "FROM NetworkRecipe WHERE modelName = :modelName AND action = :action"; - - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_NAME, modelName); - query.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <NetworkRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null); - } - } - - /** - * 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; - } - - resultList.sort(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 modelCustomizationUuid - * @return NetworkRecipe object or null if none found - */ - public NetworkResource getNetworkResourceByModelCustUuid(String modelCustomizationUuid) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get network resource with modelCustomizationUuid " + modelCustomizationUuid); - - try { - String hql = "select n FROM NetworkResource n, NetworkResourceCustomization c WHERE n.modelUUID=c.networkResourceModelUuid and c.modelCustomizationUuid = :modelCustomizationUuid"; - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_CUSTOMIZATION_UUID, modelCustomizationUuid); - - @SuppressWarnings("unchecked") - List <NetworkResource> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } catch (Exception e) { - LOGGER.debug("Error trying to find Network Resource with " + modelCustomizationUuid +", " + e.getMessage(),e); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkResourceByModelCustUuid", null); - } - return null; - } - - /** - * Return a VnfComponents recipe that matches a given VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, and, if specified, - * SERVICE_TYPE - * - * @param vnfType - * @param vnfComponentType - * @param action - * @param serviceType - * @return VnfComponentsRecipe object or null if none found - */ - public VnfComponentsRecipe getVnfComponentsRecipe (String vnfType, - String vnfComponentType, - String action, - String serviceType) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Vnf Component recipe with network type " + vnfType - + " and component type " - + vnfComponentType - + " and action " - + action - + " and service type " - + serviceType); - - try { - String hql; - if (serviceType == null) { - hql = "FROM VnfComponentsRecipe WHERE vnfType = :vnfType AND vnfComponentType = :vnfComponentType AND action = :action AND serviceType IS NULL "; - } else { - hql = "FROM VnfComponentsRecipe WHERE vnfType = :vnfType AND vnfComponentType = :vnfComponentType AND action = :action AND serviceType = :serviceType "; - } - Query query = getSession ().createQuery (hql); - query.setParameter (VNF_TYPE, vnfType); - query.setParameter (VNF_COMPONENT_TYPE, vnfComponentType); - query.setParameter (ACTION, action); - if (serviceType != null) { - query.setParameter ("serviceType", serviceType); - } - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfComponentsRecipe", null); - } - } - - /** - * Return a VnfComponents recipe that matches a given VF_MODULE_ID, VNF_COMPONENT_TYPE, ACTION - * - * @param vfModuleModelUUId - * @param vnfComponentType - * @param action - * @return VnfComponentsRecipe object or null if none found - */ - public VnfComponentsRecipe getVnfComponentsRecipeByVfModuleModelUUId (String vfModuleModelUUId, - String vnfComponentType, - String action) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Vnf Component recipe with vfModuleModelUUId " + vfModuleModelUUId - + " and component type " - + vnfComponentType - + " and action " - + action); - - try { - String hql; - hql = "FROM VnfComponentsRecipe WHERE vfModuleModelUUId = :vfModuleModelUUId AND vnfComponentType = :vnfComponentType AND action = :action "; - - Query query = getSession ().createQuery (hql); - query.setParameter (VF_MODULE_MODEL_UUID, vfModuleModelUUId); - query.setParameter (VNF_COMPONENT_TYPE, vnfComponentType); - query.setParameter (ACTION, action); - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfComponentsRecipeByVfModuleModelUUId", null); - } - } - - public List<VnfComponentsRecipe> getVnfComponentRecipes (String vfModuleModelUUId) { - - StringBuilder hql = null; - - hql = new StringBuilder ("FROM VnfComponentsRecipe WHERE vfModuleModelUUId = :vfModuleModelUUId"); - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get Service recipe with vfModuleModelUUId " + vfModuleModelUUId); - - Query query = getSession ().createQuery (hql.toString ()); - query.setParameter ("vfModuleModelUUId", vfModuleModelUUId); - - @SuppressWarnings("unchecked") - List <VnfComponentsRecipe> resultList = query.list (); - - if (resultList.isEmpty ()) { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Service recipe not found", "CatalogDB", "getVfModuleRecipes", null); - return Collections.EMPTY_LIST; - } - - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleRecipes", null); - return resultList; - } - - - - public void saveOrUpdateVnfComponent (VnfComponent vnfComponent) { - long startTime = System.currentTimeMillis (); - - LOGGER.debug ("Catalog database - save VnfComponent where vnfId="+ vnfComponent.getVnfId()+ " AND componentType="+ vnfComponent.getComponentType()); - - VnfComponent vnfComponentDb = this.getVnfComponent(vnfComponent.getVnfId(), vnfComponent.getComponentType()); - - try { - - this.getSession ().save (vnfComponent); - - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVnfComponent", null); - } - } - - /** - * Return a VfModule record that matches a given MODEL_NAME - * - * @param modelName - * @return VfModule object or null if none found - */ - public VfModule getVfModule (String modelName) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get vf module with model name " + modelName); - - try { - String hql; - - hql = "FROM VfModule WHERE modelName = :modelName"; - - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_NAME, modelName); - - @SuppressWarnings("unchecked") - List <VfModule> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModule", null); - } - } - - /** - * Return a VfModule record that matches a given MODEL_NAME - * - * @param modelUUID - * @return VfModule object or null if none found - */ - public VfModule getVfModuleByModelUUID (String modelUUID) { - - long startTime = System.currentTimeMillis (); - LOGGER.debug ("Catalog database - get vf module with modelUUID " + modelUUID); - - try { - String hql; - - hql = "FROM VfModule WHERE modelUUID = :modelUUID"; - - Query query = getSession ().createQuery (hql); - query.setParameter (MODEL_UUID, modelUUID); - - @SuppressWarnings("unchecked") - List <VfModule> resultList = query.list (); - - if (resultList.isEmpty ()) { - return null; - } - resultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse (resultList); - - return resultList.get (0); - } finally { - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleByModelUUID", null); - } - } - - /** - * Return a Service recipe that matches a given service ModelUUID and action - * (modelUUID) and ACTION - * - * @param modelUUID - * @param action - * @return ServiceRecipe object or null if none found - */ - public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Service recipe with modelUUID=" + modelUUID + " and action=" + action); - - try { - String hql; - // based on the new SERVICE_RECIPE schema where SERVICE_MODEL_UUID == MODEL_UUID, a JOIN with the SERVICE table is no longer needed -// hql = "SELECT new ServiceRecipe(SR.id, SR.serviceModelUUID, SR.action, SR.description, " + -// "SR.orchestrationUri, SR.serviceParamXSD, case when SR.recipeTimeout is null then 0 else SR.recipeTimeout end, " + -// "case when SR.serviceTimeoutInterim is null then 0 else SR.serviceTimeoutInterim end, SR.created) " + -// "FROM Service as S RIGHT OUTER JOIN S.recipes SR " + -// "WHERE SR.serviceModelUUID = :modelUUID AND SR.action = :action"; - hql = "FROM ServiceRecipe WHERE serviceModelUUID = :modelUUID AND action = :action"; - Query query = getSession().createQuery(hql); - query.setParameter(MODEL_UUID, modelUUID); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List<ServiceRecipe> recipeResultList = query.list(); - if (recipeResultList.isEmpty()) { - LOGGER.debug("Catalog database - recipeResultList is null"); - return null; - } - recipeResultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(recipeResultList); - LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); - - return recipeResultList.get(0); - } finally { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipeByModelUUID", null); - } - } - - /** - * Return a Service recipe that matches a given SERVICE_NAME_VERSION_ID - * (MODEL_VERSION_ID) and ACTION - * - * @param modelVersionId - * @param action - * @return ServiceRecipe object or null if none found - */ - @Deprecated - public ServiceRecipe getServiceRecipe(String modelVersionId, - String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Service recipe with modeVersionId=" + modelVersionId - + " and action=" + action); - - try { - String hql; - // Note: Even with the implementation of the HQL JOIN below, the code for the two separate - // SELECTs will be retained/commented for now in the event some subsequent JOIN issue arises - // 1st query to get the Service record for the given SERVICE_NAME_VERSION_ID (MODEL_VERSION_ID) -/* hql = "FROM Service WHERE serviceNameVersionId = :serviceNameVersionId"; - Query query = getSession().createQuery(hql); - query.setParameter(SERVICE_NAME_VERSION_ID, modelVersionId); - - @SuppressWarnings("unchecked") - List<Service> serviceResultList = query.list(); - if (serviceResultList.isEmpty()) { - LOGGER.debug("Catalog database - serviceResultList is null"); - return null; - } - Collections.sort(serviceResultList, new MavenLikeVersioningComparator()); - Collections.reverse(serviceResultList); - LOGGER.debug("Catalog database - serviceResultList contains " + serviceResultList.get(0).toString()); - - // 2nd query to get the ServiceRecipe record corresponding to the Service from the 1st query - hql = "FROM ServiceRecipe WHERE serviceModelUUID = :serviceModelUUID AND action = :action"; - query = getSession().createQuery(hql); - // The SERVICE table 'id' field maps to the SERVICE_RECIPE table 'SERVICE_ID' field - query.setParameter(SERVICE_ID, serviceResultList.get(0).getId()); - query.setParameter(ACTION, action); -*/ - // The following SELECT performs a JOIN across the SERVICE and SERVICE_RECIPE tables. It required a new - // CTR in the ServiceRecipe Class to populate that object (the other option was to parse the Object[] - // returned by createQuery() and manually populate the ServiceRecipe object). Two of the 'int' fields in the - // SERVICE_RECIPE DB schema (the timeouts) permit NULL values which required some additional code in the - // SELECT to generate a default of 0 (needed by the CTR) in the cases where the value is NULL. - hql = "SELECT new ServiceRecipe(SR.id, SR.serviceModelUUID, SR.action, SR.description, " + - "SR.orchestrationUri, SR.serviceParamXSD, case when SR.recipeTimeout is null then 0 else SR.recipeTimeout end, " + - "case when SR.serviceTimeoutInterim is null then 0 else SR.serviceTimeoutInterim end, SR.created) " + - "FROM Service as S RIGHT OUTER JOIN S.recipes SR " + - "WHERE SR.serviceModelUUID = S.id AND S.serviceNameVersionId = :serviceNameVersionId AND SR.action = :action"; - Query query = getSession().createQuery(hql); - query.setParameter(MODEL_UUID, modelVersionId); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List<ServiceRecipe> recipeResultList = query.list(); - if (recipeResultList.isEmpty()) { - LOGGER.debug("Catalog database - recipeResultList is null"); - return null; - } - recipeResultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(recipeResultList); - LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); - - return recipeResultList.get(0); - } finally { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null); - } - } - - /** - * Return a Model recipe that matches a given MODEL_TYPE, MODEL_VERSION_ID, ACTION - * Note: This method is not currently used but was retained in the event the - * architecture moves back to a MODEL/MODEL_RECIPE structure. - * - * @param modelType - * @param modelVersionId - * @param action - * @return ModelRecipe object or null if none found - */ - public ModelRecipe getModelRecipe(String modelType, - String modelVersionId, - String action) { - - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - get Model recipe with modelType=" + modelType - + " and modeVersionId=" + modelVersionId - + " and action=" + action); - - try { - String hql; - // TBD - at some point it would be desirable to figure out how to do a HQL JOIN across - // the MODEL and MODEL_RECIPE tables in HQL instead of 2 separate queries. - // There seems to be 2 issues: formatting a hql query that executes successfully - // and then being able to generate a result that will fit into the ModelRecipe class. - - // 1st query to get the Model record for the given MODEL_TYPE and MODEL_VERSION_ID - hql = "FROM Model WHERE modelType = :modelType AND modelVersionId = :modelVersionId"; - Query query = getSession().createQuery(hql); - query.setParameter(MODEL_TYPE, modelType); - query.setParameter(MODEL_VERSION_ID, modelVersionId); - - @SuppressWarnings("unchecked") - List<Model> modelResultList = query.list(); - if (modelResultList.isEmpty()) { - LOGGER.debug("Catalog database - modelResultList is null"); - return null; - } - modelResultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(modelResultList); - LOGGER.debug("Catalog database - modelResultList contains " + modelResultList.get(0).toString()); - - // 2nd query to get the ModelRecipe record corresponding to the Model from the 1st query - hql = "FROM ModelRecipe WHERE modelId = :modelId AND action = :action"; - query = getSession().createQuery(hql); - // The MODEL table 'id' field maps to the MODEL_RECIPE table 'MODEL_ID' field - query.setParameter(MODEL_ID, modelResultList.get(0).getId()); - query.setParameter(ACTION, action); - - @SuppressWarnings("unchecked") - List<ModelRecipe> recipeResultList = query.list(); - if (recipeResultList.isEmpty()) { - LOGGER.debug("Catalog database - recipeResultList is null"); - return null; - } - recipeResultList.sort(new MavenLikeVersioningComparator()); - Collections.reverse(recipeResultList); - LOGGER.debug("Catalog database - recipeResultList contains " + recipeResultList.get(0).toString()); - - return recipeResultList.get(0); - } finally { - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getModelRecipe", null); - } - } - - - /** - * Verify the health of the DB. - * - * @return boolean value indicate whether DB is healthy - */ - public boolean healthCheck () { - long startTime = System.currentTimeMillis (); - Session session = this.getSession (); - - // Query query = session.createQuery (" from ActiveRequests "); - Query query = session.createSQLQuery (" show tables "); - - List<?> list = query.list(); - LOGGER.debug("healthCheck CatalogDB - Successful"); - return true; - } - - public < E > E executeQuerySingleRow(String hql, HashMap<String, String> variables, boolean retry) { - long startTime = System.currentTimeMillis(); - LOGGER.debug("Catalog database - executeQuery: " + hql + (retry ? ", retry=true" : ", retry=false")); - Query query = getSession().createQuery(hql); - - StringBuilder sb = new StringBuilder(); - if (variables != null) { - for(Map.Entry<String, String> entry : variables.entrySet()){ - sb.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); - query.setParameter(entry.getKey(), entry.getValue()); - } - } - LOGGER.debug("Variables:\n" + sb.toString()); - - E theObject = null; - try { - theObject = (E) query.uniqueResult(); - } catch (org.hibernate.NonUniqueResultException nure) { - LOGGER.debug("Non Unique Result Exception - the Catalog Database does not match a unique row"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for " + hql, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for " + hql ); - throw nure; - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while performing " + hql + "; he message:" + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception while performing hql=" + hql, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for hql=" + hql); - if (retry) { - LOGGER.debug("***WILL RETRY***"); - return this.executeQuerySingleRow(hql, variables, false); - } else { - throw he; - } - } catch (Exception e) { - LOGGER.debug("Generic Exception - while performing '" + hql + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception performing " + hql, "", "", MsoLogger.ErrorCode.DataError, "Generic exception performing " + hql); - if (retry) { - LOGGER.debug("***WILL RETRY***"); - return this.executeQuerySingleRow(hql, variables, false); - } else { - throw e; - } - } - - if (theObject == null) { - LOGGER.debug("Returning null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "executeQuerySingleRow", null); - } else { - LOGGER.debug("Returning an Object"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "executeQuerySingleRow", null); - } - return theObject; - } - - public < E > List<E> executeQueryMultipleRows(String hql, HashMap<String, String> variables, boolean retry) { - long startTime = System.currentTimeMillis (); - LOGGER.debug("Catalog database - executeQuery: " + hql + (retry ? ", retry=true" : ", retry=false")); - Query query = getSession().createQuery(hql); - - StringBuilder sb = new StringBuilder(); - if (variables != null) { - for(Map.Entry<String, String> entry : variables.entrySet()){ - sb.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); - query.setParameter(entry.getKey(), entry.getValue()); - } - } - LOGGER.debug("Variables:\n" + sb.toString()); - - List<E> theObjects = null; - try { - theObjects = (List<E>) query.list (); - } catch (org.hibernate.HibernateException he) { - LOGGER.debug("Hibernate Exception - while performing " + hql + "; he message:" + he.getMessage()); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception while performing hql=" + hql, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for hql=" + hql); - if (retry) { - LOGGER.debug("***WILL RETRY***"); - return this.executeQuerySingleRow(hql, variables, false); - } else { - throw he; - } - } catch (Exception e) { - LOGGER.debug("Generic Exception - while performing '" + hql + "'"); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception performing " + hql, "", "", MsoLogger.ErrorCode.DataError, "Generic exception performing " + hql); - if (retry) { - LOGGER.debug("***WILL RETRY***"); - return this.executeQuerySingleRow(hql, variables, false); - } else { - throw e; - } - } - - if (theObjects == null) { - LOGGER.debug("Returning null"); - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "NotFound", "CatalogDB", "executeQuerySingleRow", null); - } else { - try { - LOGGER.debug("Returning theObjects:" + theObjects.size()); - } catch (Exception e) { - LOGGER.debug("Returning theObjects",e); - } - LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "executeQuerySingleRow", null); - } - 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; - } - - resultList.sort(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/CatalogDbSessionFactoryManager.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManager.java deleted file mode 100644 index 6646bc3109..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManager.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog; - -import org.openecomp.mso.db.AbstractSessionFactoryManager; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import java.net.URL; - -public class CatalogDbSessionFactoryManager extends AbstractSessionFactoryManager { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - - @Override - protected URL getHibernateConfigFile() { - try { - if ("MYSQL".equals (System.getProperty ("mso.db")) || "MARIADB".equals(System.getProperty("mso.db"))) { - return this.getClass().getClassLoader().getResource("hibernate-catalog-core-mysql.cfg.xml"); - } else { - LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC", "", "", MsoLogger.ErrorCode.DataError , "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC"); - return null; - } - } catch (Exception ex) { - LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, ex.getMessage (), "", "", MsoLogger.ErrorCode.DataError , "Problem in getting DB connection type", ex); - return null; - } - } -}
\ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java deleted file mode 100644 index a0af4b2300..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResource.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class AllottedResource extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelUuid = null; - private String modelInvariantUuid = null; - private String modelVersion = null; - private String modelName = null; - private String toscaNodeType = null; - private String subcategory = null; - private String description = null; - private Timestamp created = null; - - public AllottedResource() { - } - - public String getModelUuid() { - return this.modelUuid; - } - public void setModelUuid(String modelUuid) { - this.modelUuid = modelUuid; - } - public String getModelInvariantUuid() { - return this.modelInvariantUuid; - } - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUuid = modelInvariantUuid; - } - public String getModelVersion() { - return this.modelVersion; - } - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - public String getModelName() { - return this.modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - public String getToscaNodeType() { - return this.toscaNodeType; - } - public void setToscaNodeType(String toscaNodeType) { - this.toscaNodeType = toscaNodeType; - } - public String getSubcategory() { - return this.subcategory; - } - public void setSubcategory(String subcategory) { - this.subcategory = subcategory; - } - public String getDescription() { - return this.description; - } - public void setDescription(String description) { - this.description = description; - } - public Timestamp getCreated() { - return created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java deleted file mode 100644 index e5a653760b..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/AllottedResourceCustomization.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; -import org.openecomp.mso.db.catalog.beans.AllottedResource; - -public class AllottedResourceCustomization extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelCustomizationUuid = null; - private String arModelUuid = null; - private Timestamp created = null; - private String modelInstanceName = null; - private String providingServiceModelInvariantUuid = null; - private String targetNetworkRole = null; - private String nfFunction = null; - private String nfType = null; - private String nfRole = null; - private String nfNamingCode = null; - private Integer minInstances; - private Integer maxInstances; - private AllottedResource allottedResource = null; - private String providingServiceModelUuid = null; - private String providingServiceModelName = null; - - public AllottedResourceCustomization() { - super(); - } - - public String getModelCustomizationUuid() { - return this.modelCustomizationUuid; - } - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - - public String getArModelUuid() { - return this.arModelUuid; - } - public void setArModelUuid(String arModelUuid) { - this.arModelUuid = arModelUuid; - } - - public Timestamp getCreated() { - return this.created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getModelInstanceName() { - return this.modelInstanceName; - } - public void setModelInstanceName(String modelInstanceName) { - this.modelInstanceName = modelInstanceName; - } - public AllottedResource getAllottedResource() { - return this.allottedResource; - } - public void setAllottedResource(AllottedResource ar) { - this.allottedResource = ar; - } - public String getProvidingServiceModelInvariantUuid() { - return this.providingServiceModelInvariantUuid; - } - public void setProvidingServiceModelInvariantUuid(String providingServiceModelInvariantUuid) { - this.providingServiceModelInvariantUuid = providingServiceModelInvariantUuid; - } - public String getTargetNetworkRole() { - return this.targetNetworkRole; - } - public void setTargetNetworkRole(String targetNetworkRole) { - this.targetNetworkRole = targetNetworkRole; - } - public String getNfFunction() { - return this.nfFunction; - } - public void setNfFunction(String nfFunction) { - this.nfFunction = nfFunction; - } - public String getNfType() { - return this.nfType; - } - public void setNfType(String nfType) { - this.nfType = nfType; - } - public String getNfRole() { - return this.nfRole; - } - public void setNfRole(String nfRole) { - this.nfRole = nfRole; - } - public String getNfNamingCode() { - return this.nfNamingCode; - } - public void setNfNamingCode(String nfNamingCode) { - this.nfNamingCode = nfNamingCode; - } - public Integer getMinInstances() { - return this.minInstances; - } - public void setMinInstances(Integer minInstances) { - this.minInstances = minInstances; - } - public Integer getMaxInstances() { - return this.maxInstances; - } - public void setMaxInstances(Integer maxInstances) { - this.maxInstances = maxInstances; - } - public String getProvidingServiceModelUuid() { - return this.providingServiceModelUuid; - } - public void setProvidingServiceModelUuid(String providingServiceModelUuid) { - this.providingServiceModelUuid = providingServiceModelUuid; - } - public String getProvidingServiceModelName() { - return this.providingServiceModelName; - } - public void setProvidingServiceModelName(String providingServiceModelName) { - this.providingServiceModelName = providingServiceModelName; - } - - @Override - public String toString () { - return "modelCustomizationUuid=" + this.modelCustomizationUuid + - ",modelInstanceName=" + this.modelInstanceName + - ",modelInstanceName=" + this.modelInstanceName + - ",created=" + this.created + - ",ar=" + this.allottedResource; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java deleted file mode 100644 index d3532886d5..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ArRecipe.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; - -public class ArRecipe extends Recipe implements Serializable { - private static final long serialVersionUID = 768026109321305392L; - private String modelName = null; - public ArRecipe() {} - - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - - @Override - public String toString () { - return super.toString() + ",modelName=" + modelName + ",arParamXSD=" + getParamXSD(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java deleted file mode 100644 index 8baf62018c..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class HeatEnvironment extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String artifactUuid = null; - private String name = null; - private String description = null; - private String environment = null; - private String artifactChecksum = null; - - private Timestamp created = null; - - public String getArtifactUuid() { - return this.artifactUuid; - } - public void setArtifactUuid(String artifactUuid) { - this.artifactUuid = artifactUuid; - } - - public String getName () { - return name; - } - - public void setName (String name) { - this.name = name; - } - - public String getDescription() { - return this.description; - } - public void setDescription(String description) { - this.description = description; - } - - public String getEnvironment() { - return this.environment; - } - public void setEnvironment(String environment) { - this.environment = environment; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("Artifact UUID=").append(this.artifactUuid); - sb.append (", name="); - sb.append (name); - sb.append (", version="); - sb.append (version); - sb.append(", description="); - sb.append (this.description == null ? "null" : this.description); - sb.append(", body="); - sb.append (this.environment == null ? "null" : this.environment); - if (this.created != null) { - sb.append (",creationTimestamp="); - sb.append (DateFormat.getInstance().format(this.created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java deleted file mode 100644 index 542cd45081..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class HeatFiles extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String artifactUuid = null; - private String description = null; - private String fileName = null; - private String fileBody = null; - private Timestamp created = null; - private String version = null; - private String artifactChecksum = null; - - - public String getArtifactUuid() { - return this.artifactUuid; - } - public void setArtifactUuid(String artifactUuid) { - this.artifactUuid = artifactUuid; - } - - public String getDescription() { - return this.description; - } - public void setDescription(String description) { - this.description = description; - } - - public String getFileName() { - return this.fileName; - } - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public String getFileBody() { - return this.fileBody; - } - public void setFileBody(String fileBody) { - this.fileBody = fileBody; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getAsdcUuid() { - return this.artifactUuid; - } - public void setAsdcUuid(String artifactUuid) { - this.artifactUuid = artifactUuid; - } - - @Override - public String getVersion() { - return version; - } - - @Override - public void setVersion(String version) { - this.version = version; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("artifactUuid=").append(this.artifactUuid); - if (this.description == null) { - sb.append(", description=null"); - } else { - sb.append(", description=").append(this.description); - } - if (this.fileName == null) { - sb.append(", fileName=null"); - } else { - sb.append(",fileName=").append(this.fileName); - } - if (this.fileBody == null) { - sb.append(", fileBody=null"); - } else { - sb.append(",fileBody=").append(this.fileBody); - } - sb.append(", artifactChecksum=").append(this.artifactChecksum); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java deleted file mode 100644 index 1fff17612e..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; - -import com.openpojo.business.annotation.BusinessKey; - -public class HeatNestedTemplate implements Serializable { - - @BusinessKey - private String parentTemplateId = null; - @BusinessKey - private String childTemplateId = null; - private String providerResourceFile = null; - public static final long serialVersionUID = -1322322139926390329L; - - public HeatNestedTemplate () { - super (); - } - - public void setParentTemplateId (String parentTemplateId) { - this.parentTemplateId = parentTemplateId; - } - - public String getParentTemplateId () { - return this.parentTemplateId; - } - - public void setChildTemplateId (String childTemplateId) { - this.childTemplateId = childTemplateId; - } - - public String getChildTemplateId () { - return this.childTemplateId; - } - - public void setProviderResourceFile (String providerResourceFile) { - this.providerResourceFile = providerResourceFile; - } - - public String getProviderResourceFile () { - return this.providerResourceFile; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder (); - sb.append("ParentTemplateId=").append(this.parentTemplateId); - sb.append(", ChildTemplateId=").append(this.childTemplateId); - if (this.providerResourceFile == null) { - sb.append (", providerResourceFile=null"); - } else { - sb.append(",providerResourceFile=").append(this.providerResourceFile); - } - return sb.toString (); - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof HeatNestedTemplate)) { - return false; - } - if (this == o) { - return true; - } - HeatNestedTemplate hnt = (HeatNestedTemplate) o; - if (hnt.getChildTemplateId () == this.childTemplateId && hnt.getParentTemplateId () == this.parentTemplateId) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result; - int parentTemplateIdHash = 0; - int childTemplateIdHash = 0; - if (this.parentTemplateId != null) { - parentTemplateIdHash = this.parentTemplateId.hashCode(); - } - if (this.childTemplateId != null) { - childTemplateIdHash = this.childTemplateId.hashCode(); - } - result = parentTemplateIdHash + childTemplateIdHash; - return result; - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java deleted file mode 100644 index c6386efdd6..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.Set; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class HeatTemplate extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String artifactUuid = null; - private String templateName = null; - private String templateBody = null; - private int timeoutMinutes; - private Set <HeatTemplateParam> parameters; - private Set <HeatNestedTemplate> files; - private String description = null; - private String asdcUuid = null; - private String artifactChecksum = null; - - private Timestamp created = null; - - public enum TemplateStatus { - PARENT, CHILD, PARENT_COMPLETE - } - - public HeatTemplate () { - } - - public String getArtifactUuid() { - return this.artifactUuid; - } - - public void setArtifactUuid (String artifactUuid) { - this.artifactUuid = artifactUuid; - } - - public String getTemplateName () { - return templateName; - } - - public void setTemplateName (String templateName) { - this.templateName = templateName; - } - - public String getTemplateBody () { - return templateBody; - } - - public void setTemplateBody (String templateBody) { - this.templateBody = templateBody; - } - - public int getTimeoutMinutes () { - return timeoutMinutes; - } - - public void setTimeoutMinutes (int timeout) { - this.timeoutMinutes = timeout; - } - - public Set <HeatTemplateParam> getParameters () { - return parameters; - } - - public void setParameters (Set <HeatTemplateParam> parameters) { - this.parameters = parameters; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getHeatTemplate () { - return this.templateBody; - } - - public void setFiles (Set <HeatNestedTemplate> files) { - this.files = files; - } - - public Set <HeatNestedTemplate> getFiles () { - return this.files; - } - - public String getAsdcUuid() { - return asdcUuid; - } - - public void setAsdcUuid(String asdcUuidp) { - this.asdcUuid = asdcUuidp; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString () { - String body = (templateBody != null) ? "(" + templateBody.length () + " chars)" : "(Not defined)"; - StringBuilder sb = new StringBuilder (); - sb.append ("Template=") - .append (templateName) - .append (",version=") - .append (version) - .append (",body=") - .append (body) - .append (",timeout=") - .append (timeoutMinutes) - .append (",asdcUuid=") - .append (asdcUuid) - .append (",description=") - .append (description); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - - - if (parameters != null && !parameters.isEmpty ()) { - sb.append (",params=["); - for (HeatTemplateParam param : parameters) { - sb.append (param.getParamName ()); - if (param.isRequired ()) { - sb.append ("(reqd)"); - } - sb.append (","); - } - sb.replace (sb.length () - 1, sb.length (), "]"); - } - return sb.toString (); - } - - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java deleted file mode 100644 index 9bfc41b675..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateArtifactUuidModelUuid.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; - -import com.openpojo.business.annotation.BusinessKey; - -// an embeddable class to represent the Composite key for NetworkResource in the 1707 db refactoring -public class HeatTemplateArtifactUuidModelUuid implements Serializable { - - @BusinessKey - private String heatTemplateArtifactUuid = null; - @BusinessKey - private String modelUuid = null; - public static final long serialVersionUID = -1322322139926390329L; - - public HeatTemplateArtifactUuidModelUuid() { - } - - public String getHeatTemplateArtifactUuid() { - return this.heatTemplateArtifactUuid; - } - public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { - this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; - } - public String getModelUuid() { - return this.modelUuid; - } - public void setModelUuid(String modelUuid) { - this.modelUuid = modelUuid; - } - - @Override - public String toString() { - return "heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid + " modelUuid=" + this.modelUuid; - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof HeatTemplateArtifactUuidModelUuid)) { - return false; - } - if (this == o) { - return true; - } - HeatTemplateArtifactUuidModelUuid htaumu = (HeatTemplateArtifactUuidModelUuid) o; - if (htaumu.getHeatTemplateArtifactUuid().equals(this.getHeatTemplateArtifactUuid()) - && htaumu.getModelUuid().equals(this.getModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - return this.heatTemplateArtifactUuid.hashCode() + this.modelUuid.hashCode(); - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java deleted file mode 100644 index 7f7dd2b4c6..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; - -import org.apache.commons.lang3.builder.EqualsBuilder; - -import com.openpojo.business.annotation.BusinessKey; - -public class HeatTemplateParam implements Serializable { - - @BusinessKey - private String heatTemplateArtifactUuid = null; - @BusinessKey - private String paramName = null; - private boolean required; - private String paramType = null; - private String paramAlias = null; - public static final long serialVersionUID = -1322322139926390329L; - - public HeatTemplateParam() {} - - public String getHeatTemplateArtifactUuid() { - return this.heatTemplateArtifactUuid; - } - public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { - this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; - } - - public String getParamName() { - return paramName; - } - public void setParamName(String paramName) { - this.paramName = paramName; - } - public boolean isRequired() { - return required; - } - public void setRequired(boolean required) { - this.required = required; - } - public String getParamAlias() { - return paramAlias; - } - public void setParamAlias(String paramAlias) { - this.paramAlias = paramAlias; - } - - public String getParamType() { - return paramType; - } - public void setParamType (String paramType) { - this.paramType = paramType; - } - - - @Override - public String toString () { - return "Param=" + paramName + ",type=" + paramType + ",required=" + required + ",paramAlias=" + paramAlias + ", heatTemplateArtifactUuid=" + this.heatTemplateArtifactUuid; - } - - @Override - public boolean equals(final Object other) { - if (!(other instanceof HeatTemplateParam)) { - return false; - } - HeatTemplateParam castOther = (HeatTemplateParam) other; - return new EqualsBuilder().append(heatTemplateArtifactUuid, castOther.heatTemplateArtifactUuid) - .append(paramName, castOther.paramName).isEquals(); - } - - @Override - public int hashCode () { - int result; - result = this.paramName == null ? 0 : this.paramName.hashCode() + this.heatTemplateArtifactUuid == null ? 0 : this.heatTemplateArtifactUuid.hashCode(); - return result; - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java deleted file mode 100644 index 5cd6b58aee..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Model.java +++ /dev/null @@ -1,201 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.Map; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; -public class Model extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private int id; - private String modelCustomizationId = null; - private String modelCustomizationName = null; - private String modelInvariantId = null; - private String modelName = null; - private String modelType = null; - private String modelVersion = null; - private String modelVersionId = null; - private Timestamp created = null; - private Map<String,ServiceRecipe> recipes; - - /** - * @return the id - */ - public int getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(int id) { - this.id = id; - } - - /** - * @return the modelCustomizationId - */ - public String getModelCustomizationId() { - return modelCustomizationId; - } - - /** - * @param modelCustomizationId the modelCustomizationId to set - */ - public void setModelCustomizationId(String modelCustomizationId) { - this.modelCustomizationId = modelCustomizationId; - } - - /** - * @return the modelCustomizationName - */ - public String getModelCustomizationName() { - return modelCustomizationName; - } - - /** - * @param modelCustomizationName the modelCustomizationName to set - */ - public void setModelCustomizationName(String modelCustomizationName) { - this.modelCustomizationName = modelCustomizationName; - } - - /** - * @return the modelInvariantId - */ - public String getModelInvariantId() { - return modelInvariantId; - } - - /** - * @param modelInvariantId the modelInvariantId to set - */ - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - - /** - * @return the modelName - */ - public String getModelName() { - return modelName; - } - - /** - * @param modelName the modelName to set - */ - public void setModelName(String modelName) { - this.modelName = modelName; - } - - /** - * @return the modelType - */ - public String getModelType() { - return modelType; - } - - /** - * @param modelType the modelType to set - */ - public void setModelType(String modelType) { - this.modelType = modelType; - } - - /** - * @return the modelVersion - */ - public String getModelVersion() { - return modelVersion; - } - - /** - * @param modelVersion the modelVersion to set - */ - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - /** - * @return the modelVersionId - */ - public String getModelVersionId() { - return modelVersionId; - } - - /** - * @param modelVersionId the modelVersionId to set - */ - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - - /** - * @return the created - */ - public Timestamp getCreated() { - return created; - } - - /** - * @param created the created to set - */ - public void setCreated(Timestamp created) { - this.created = created; - } - - /** - * @return the recipes - */ - public Map<String, ServiceRecipe> getRecipes() { - return recipes; - } - - /** - * @param recipes the recipes to set - */ - public void setRecipes(Map<String, ServiceRecipe> recipes) { - this.recipes = recipes; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Model: "); - sb.append("modelCustomizationId=").append(modelCustomizationId); - sb.append(",modelCustomizationName=").append(modelCustomizationName); - sb.append(",modelInvariantId=").append(modelInvariantId); - sb.append(",modelName=").append(modelName); - sb.append(",modelType=").append(modelType); - sb.append(",modelVersion=").append(modelVersion); - sb.append(",modelVersionId=").append(modelVersionId); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} 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 deleted file mode 100644 index 4ba35f7f42..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ModelRecipe.java +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class ModelRecipe extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private int id; - private Integer modelId; - private String action = null; - private String schemaVersion = null; - private String description = null; - private String orchestrationUri = null; - private String modelParamXSD = null; - private Integer recipeTimeout; - private Timestamp created = null; - - /** - * @return the id - */ - public int getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(int id) { - this.id = id; - } - - /** - * @return the modelId - */ - public Integer getModelId() { - return modelId; - } - - /** - * @param modelId the modelId to set - */ - public void setModelId(Integer modelId) { - this.modelId = modelId; - } - - /** - * @return the action - */ - public String getAction() { - return action; - } - - /** - * @param action the action to set - */ - public void setAction(String action) { - this.action = action; - } - - /** - * @return the versionStr - */ - public String getSchemaVersion() { - return schemaVersion; - } - - /** - * @param schemaVersion the versionStr to set - */ - public void setSchemaVersion(String schemaVersion) { - this.schemaVersion = schemaVersion; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * @return the orchestrationUri - */ - public String getOrchestrationUri() { - return orchestrationUri; - } - - /** - * @param orchestrationUri the orchestrationUri to set - */ - public void setOrchestrationUri(String orchestrationUri) { - this.orchestrationUri = orchestrationUri; - } - - /** - * @return the modelParamXSD - */ - public String getModelParamXSD() { - return modelParamXSD; - } - - /** - * @param modelParamXSD the modelParamXSD to set - */ - public void setModelParamXSD(String modelParamXSD) { - this.modelParamXSD = modelParamXSD; - } - - /** - * @return the recipeTimeout - */ - public Integer getRecipeTimeout() { - return recipeTimeout; - } - - /** - * @param recipeTimeout the recipeTimeout to set - */ - public void setRecipeTimeout(Integer recipeTimeout) { - this.recipeTimeout = recipeTimeout; - } - - /** - * @return the created - */ - public Timestamp getCreated() { - return created; - } - - /** - * @param created the created to set - */ - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ModelRecipe: "); - sb.append("modelId=").append(modelId); - sb.append(",action=").append(action); - sb.append(",schemaVersion=").append(schemaVersion); - sb.append(",orchestrationUri=").append(orchestrationUri); - sb.append(",modelParamXSD=").append(modelParamXSD); - sb.append(",recipeTimeout=").append(recipeTimeout); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java deleted file mode 100644 index d10b633557..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; - -public class NetworkRecipe extends Recipe implements Serializable { - private static final long serialVersionUID = 768026109321305392L; - private String modelName = null; - public NetworkRecipe() {} - - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - - @Override - public String toString () { - return super.toString() + ",modelName=" + modelName + ",networkParamXSD=" + getParamXSD(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java deleted file mode 100644 index d4e1ec536a..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java +++ /dev/null @@ -1,209 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class NetworkResource extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String orchestrationMode = null; - private String description = null; - private String neutronNetworkType = null; - private String aicVersionMin = null; - private String aicVersionMax = null; - private String modelName = null; - private String modelInvariantUUID = null; - private String modelVersion = null; - private String toscaNodeType = null; - private Timestamp created = null; - private String modelUUID = null; - private String category = null; - private String subCategory = null; - private String heatTemplateArtifactUUID = null; - - public NetworkResource() {} - - public String getOrchestrationMode() { - return orchestrationMode; - } - - public void setOrchestrationMode(String orchestrationMode) { - this.orchestrationMode = orchestrationMode; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - public String getNeutronNetworkType() { - return neutronNetworkType; - } - - public void setNeutronNetworkType(String neutronNetworkType) { - this.neutronNetworkType = neutronNetworkType; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getAicVersionMin() { - return aicVersionMin; - } - - public void setAicVersionMin(String aicVersionMin) { - this.aicVersionMin = aicVersionMin; - } - - public String getAicVersionMax() { - return aicVersionMax; - } - - public void setAicVersionMax(String aicVersionMax) { - this.aicVersionMax = aicVersionMax; - } - - public String getModelName() { - return modelName; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public String getModelInvariantUUID() { - return modelInvariantUUID; - } - - public void setModelInvariantUUID(String modelInvariantUUID) { - this.modelInvariantUUID = modelInvariantUUID; - } - - public String getToscaNodeType() { - return toscaNodeType; - } - - public void setToscaNodeType(String toscaNodeType) { - this.toscaNodeType = toscaNodeType; - } - - public String getModelUUID() { - return modelUUID; - } - - public void setModelUUID(String modelUUID) { - this.modelUUID = modelUUID; - } - - - /** - * @return Returns the category. - */ - public String getCategory() { - return category; - } - - - /** - * @param category The category to set. - */ - public void setCategory(String category) { - this.category = category; - } - - - /** - * @return Returns the subCategory. - */ - public String getSubCategory() { - return subCategory; - } - - - /** - * @param subCategory The subCategory to set. - */ - public void setSubCategory(String subCategory) { - this.subCategory = subCategory; - } - - public String getHeatTemplateArtifactUUID() { - return heatTemplateArtifactUUID; - } - - public void setHeatTemplateArtifactUUID(String heatTemplateArtifactUUID) { - this.heatTemplateArtifactUUID = heatTemplateArtifactUUID; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - sb.append("NETWORK Resource:"); - sb.append("modelVersion="); - sb.append(modelVersion); - sb.append(",mode="); - sb.append(orchestrationMode); - sb.append(",neutronType="); - sb.append(neutronNetworkType); - sb.append(",aicVersionMin="); - sb.append(aicVersionMin); - sb.append(",aicVersionMax="); - sb.append(aicVersionMax); - sb.append(",modelName="); - sb.append(modelName); - sb.append(",modelInvariantUUID="); - sb.append(modelInvariantUUID); - sb.append(",toscaNodeType="); - sb.append(toscaNodeType); - sb.append(",modelUUID="); - sb.append(modelUUID); - sb.append(",heatTemplateArtifactUUID="); - sb.append(heatTemplateArtifactUUID); - - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java deleted file mode 100644 index f1d5d4f003..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResourceCustomization.java +++ /dev/null @@ -1,146 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.beans; - -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -import java.io.Serializable; - -public class NetworkResourceCustomization implements Serializable{ - - // modelCustomizationUuid and networkResourceModelUuid form a composite primary key - @BusinessKey - private String modelCustomizationUuid = null; - @BusinessKey - private String networkResourceModelUuid = null; - public static final long serialVersionUID = -1322322139926390329L; - private String modelInstanceName = null; - private Timestamp created = null; - private String networkTechnology = null; - private String networkType = null; - private String networkScope = null; - private String networkRole = null; - - // These fields are not in the table directly - but I'm adding them here for storage in the objects we're dealing with - private NetworkResource networkResource = null; - - public NetworkResourceCustomization() { - super(); - } - - public String getModelCustomizationUuid() { - return this.modelCustomizationUuid; - } - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - - public String getNetworkResourceModelUuid() { - return this.networkResourceModelUuid; - } - public void setNetworkResourceModelUuid(String networkResourceModelUuid) { - this.networkResourceModelUuid = networkResourceModelUuid; - } - - public String getModelInstanceName() { - return this.modelInstanceName; - } - public void setModelInstanceName(String modelInstanceName) { - this.modelInstanceName = modelInstanceName; - } - - public NetworkResource getNetworkResource() { - return this.networkResource; - } - public void setNetworkResource(NetworkResource networkResource) { - this.networkResource = networkResource; - } - - public String getNetworkType() { - return this.networkType; - } - public void setNetworkType(String networkType) { - this.networkType = networkType; - } - public Timestamp getCreated() { - return this.created; - } - public void setCreated(java.sql.Timestamp timestamp) { - this.created = timestamp; - } - - public String getNetworkTechnology() { - return this.networkTechnology; - } - public void setNetworkTechnology(String networkTechnology) { - this.networkTechnology = networkTechnology; - } - public String getNetworkScope() { - return this.networkScope; - } - public void setNetworkScope(String networkScope) { - this.networkScope = networkScope; - } - public void setNetworkRole(String networkRole) { - this.networkRole = networkRole; - } - public String getNetworkRole() { - return this.networkRole; - } - - @Override - public String toString() { - return "modelCustomizationUuid=" + this.modelCustomizationUuid + - "networkResourceModelUuid=" + this.networkResourceModelUuid + - "modelInstanceName=" + this.modelInstanceName + - "networkType=" + this.networkType + - "networkTechnology=" + this.networkTechnology + - "networkScope=" + this.networkScope + - "networkRole=" + this.networkRole; - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof NetworkResourceCustomization)) { - return false; - } - if (this == o) { - return true; - } - NetworkResourceCustomization nrc = (NetworkResourceCustomization) o; - if (nrc.getModelCustomizationUuid().equals(this.getModelCustomizationUuid()) - && nrc.getNetworkResourceModelUuid().equals(this.getNetworkResourceModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result; - result = (this.modelCustomizationUuid != null ? this.modelCustomizationUuid.hashCode() : 0) + (this.networkResourceModelUuid != null ? this.networkResourceModelUuid.hashCode() : 0); - return result; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java deleted file mode 100644 index 3f2093b7e2..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class Recipe extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private int id; - protected String action = null; - private String description = null; - protected String orchestrationUri = null; - private int recipeTimeout; - private String serviceType = null; - private String paramXSD = null; - private Timestamp created = null; - - public Recipe () { - super (); - } - - public int getId () { - return id; - } - - public void setId (int id) { - this.id = id; - } - - public String getAction () { - return action; - } - - public void setAction (String action) { - this.action = action; - } - - public String getDescription () { - return description; - } - - public void setDescription (String description) { - this.description = description; - } - - public String getOrchestrationUri () { - return orchestrationUri; - } - - public void setOrchestrationUri (String orchestrationUri) { - this.orchestrationUri = orchestrationUri; - } - - public int getRecipeTimeout () { - return recipeTimeout; - } - - public void setRecipeTimeout (int recipeTimeout) { - this.recipeTimeout = recipeTimeout; - } - - public String getServiceType () { - return serviceType; - } - - public void setServiceType (String serviceType) { - this.serviceType = serviceType; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - /** - * @return Returns the paramXSD. - */ - public String getParamXSD() { - return paramXSD; - } - - /** - * @param paramXSD The paramXSD to set. - */ - public void setParamXSD(String paramXSD) { - this.paramXSD = paramXSD; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("RECIPE: ").append(action); - sb.append(",uri=").append(orchestrationUri); - - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java deleted file mode 100644 index 620c6bb17c..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class Service extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelName = null; - private String description = null; - private String modelUUID = null; - private String modelInvariantUUID = null; - private Timestamp created = null; - private String toscaCsarArtifactUUID = null; - private String modelVersion = null; - private String category = null; - private String serviceType = null; - private String serviceRole = null; - private String environmentContext = null; - private String workloadContext = null; - private Map<String,ServiceRecipe> recipes = new HashMap<>(); - private Set<ServiceToResourceCustomization> serviceResourceCustomizations = new HashSet<>(); - - public Service() {} - - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - public Map<String, ServiceRecipe> getRecipes() { - return recipes; - } - public void setRecipes(Map<String, ServiceRecipe> recipes) { - this.recipes = recipes; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getModelUUID() { - return modelUUID; - } - - public void setModelUUID(String modelUUID) { - this.modelUUID = modelUUID; - } - - public String getModelInvariantUUID() { - return modelInvariantUUID; - } - - public void setModelInvariantUUID(String modelInvariantUUID) { - this.modelInvariantUUID = modelInvariantUUID; - } - - public String getToscaCsarArtifactUUID() { - return toscaCsarArtifactUUID; - } - - public void setToscaCsarArtifactUUID(String toscaCsarArtifactUUID) { - this.toscaCsarArtifactUUID = toscaCsarArtifactUUID; - } - - public Set<ServiceToResourceCustomization> getServiceResourceCustomizations() { - return serviceResourceCustomizations; - } - - public void setServiceResourceCustomizations(Set<ServiceToResourceCustomization> serviceResourceCustomizations) { - this.serviceResourceCustomizations = serviceResourceCustomizations; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - /** - * @return Returns the category. - */ - public String getCategory() { - return category; - } - - - /** - * @param category The category to set. - */ - public void setCategory(String category) { - this.category = category; - } - - public String getServiceType() { - return serviceType; - } - - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - public String getServiceRole() { - return serviceRole; - } - - public void setServiceRole(String serviceRole) { - this.serviceRole = serviceRole; - } - public String getEnvironmentContext() { - return this.environmentContext; - } - public void setEnvironmentContext(String environmentContext) { - this.environmentContext = environmentContext; - } - - public String getWorkloadContext() { - return this.workloadContext; - } - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("SERVICE: name=").append(modelName).append(",modelVersion=").append(modelVersion) - .append(",description=").append(description).append(",modelInvariantUUID=").append(modelInvariantUUID) - - .append(",toscaCsarArtifactUUID=").append(toscaCsarArtifactUUID).append(",serviceType=").append(serviceType) - .append(",serviceRole=").append(serviceRole).append(",envtContext=").append(this.environmentContext) - .append(",workloadContext=").append(this.workloadContext); - for (String recipeAction : recipes.keySet()) { - ServiceRecipe recipe = recipes.get(recipeAction); - sb.append("\n").append(recipe.toString()); - } - - for(ServiceToResourceCustomization serviceResourceCustomization : serviceResourceCustomizations) { - sb.append("\n").append(serviceResourceCustomization.toString()); - } - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java deleted file mode 100644 index 3fad9a4d02..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceMacroHolder.java +++ /dev/null @@ -1,171 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/* - * A simple holder for Service and its associated elements: - * VnfResource, 1-n VfModule, Network TBD - */ - -public class ServiceMacroHolder implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private Service service; - private List<VnfResource> vnfResources; - private List<NetworkResourceCustomization> networkResourceCustomization; - private List<AllottedResourceCustomization> allottedResourceCustomization; - private List<VnfResourceCustomization> vnfResourceCustomizations; - - public ServiceMacroHolder() { - super(); - this.service = null; - this.vnfResources = new ArrayList<>(); - this.networkResourceCustomization = new ArrayList<>(); - this.allottedResourceCustomization = new ArrayList<>(); - this.vnfResourceCustomizations = new ArrayList<>(); - } - public ServiceMacroHolder(Service service) { - this(); - this.service = service; - } - - public Service getService() { - return this.service; - } - public void setService(Service service) { - this.service = service; - } - - public void setVnfResources(List<VnfResource> vnfResources) { - this.vnfResources = vnfResources; - } - public List<VnfResource> getVnfResources() { - return this.vnfResources; - } - public void addVnfResource(VnfResource vr) { - if (vr != null) { - if (this.vnfResources != null) { - this.vnfResources.add(vr); - } else { - this.vnfResources = new ArrayList<>(); - this.vnfResources.add(vr); - } - } - } - - public void setVnfResourceCustomizations(List<VnfResourceCustomization> vnfResourceCustomizations) { - this.vnfResourceCustomizations = vnfResourceCustomizations; - } - public List<VnfResourceCustomization> getVnfResourceCustomizations() { - return this.vnfResourceCustomizations; - } - public void addVnfResourceCustomizations(VnfResourceCustomization vrc) { - if (vrc != null) { - if (this.vnfResourceCustomizations != null) { - this.vnfResourceCustomizations.add(vrc); - } else { - this.vnfResourceCustomizations = new ArrayList<>(); - this.vnfResourceCustomizations.add(vrc); - } - } - } - - public void setNetworkResourceCustomization(List<NetworkResourceCustomization> networkResourceCustomizations) { - this.networkResourceCustomization = networkResourceCustomizations; - } - public List<NetworkResourceCustomization> getNetworkResourceCustomization() { - return this.networkResourceCustomization; - } - public void addNetworkResourceCustomizations(NetworkResourceCustomization nrc) { - if (this.networkResourceCustomization != null) { - this.networkResourceCustomization.add(nrc); - } else { - this.networkResourceCustomization = new ArrayList<>(); - this.networkResourceCustomization.add(nrc); - } - } - - public void setAllottedResourceCustomization(List<AllottedResourceCustomization> allottedResourceCustomizations) { - this.allottedResourceCustomization = allottedResourceCustomizations; - } - public List<AllottedResourceCustomization> getAllottedResourceCustomization() { - return this.allottedResourceCustomization; - } - public void addAllottedResourceCustomization(AllottedResourceCustomization arc) { - if (this.allottedResourceCustomization != null) { - this.allottedResourceCustomization.add(arc); - } else { - this.allottedResourceCustomization = new ArrayList<>(); - this.allottedResourceCustomization.add(arc); - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ServicePlus: "); - if (this.service != null) { - sb.append("service: ").append(this.service.toString()); - } else { - sb.append("service: null"); - } - if (this.vnfResourceCustomizations != null && this.vnfResourceCustomizations.size() > 0) { - int i=0; - sb.append("vnfResourceCustomization: "); - for (VnfResourceCustomization vrc : this.vnfResourceCustomizations) { - sb.append(", vnfResourceCustomization[").append(i++).append("]:").append(vrc.toString()); - } - } else { - sb.append("none"); - } - if (this.vnfResources != null && this.vnfResources.size() > 0) { - int i=0; - sb.append("VnfResources: "); - for (VnfResource vr : this.vnfResources) { - sb.append(", vnfResource[").append(i++).append("]:").append(vr.toString()); - } - } else { - sb.append("none"); - } - if (this.networkResourceCustomization != null && this.networkResourceCustomization.size() > 0) { - int i=0; - sb.append("NetworkResourceCustomizations:"); - for (NetworkResourceCustomization nrc : this.networkResourceCustomization) { - sb.append("NRC[").append(i++).append("]: ").append(nrc.toString()); - } - } - if (this.allottedResourceCustomization != null && this.allottedResourceCustomization.size() > 0) { - int i=0; - sb.append("AllottedResourceCustomizations:"); - for (AllottedResourceCustomization arc : this.allottedResourceCustomization) { - sb.append("ARC[").append(i++).append("]: ").append(arc.toString()); - } - } - - return sb.toString(); - } - - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java deleted file mode 100644 index d0bc9b33f7..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.Date; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; -import org.openecomp.mso.logger.MsoLogger; - -public class ServiceRecipe extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private int id; - private String serviceModelUUID = null; - private String action = null; - private String description = null; - private String orchestrationUri = null; - private String serviceParamXSD = null; - private int recipeTimeout; - private Integer serviceTimeoutInterim; - private Timestamp created = null; - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - - // This 'default' CTR is now needed for backward compatibility since a new CTR was added below - public ServiceRecipe() { - super(); - } - - // This CTR is needed by the HQL SELECT JOIN between the SERVICE and SERVICE_RECIPE tables - // in CatalogDatabase::getServiceRecipe() - public ServiceRecipe(int id, String serviceModelUUID, String action, - String description, String orchestrationUri, - String serviceParamXSD, int recipeTimeout, - int serviceTimeoutInterim, Date created) { - super(); - LOGGER.debug("ServiceRecipe id=" + id + ", serviceModelUUID=" + serviceModelUUID + ", action=" + action + ", description=" + description + - ", orchestrationUri=" + orchestrationUri + ", serviceParamXSD=" + serviceParamXSD + - ", recipeTimeout=" + recipeTimeout + ", serviceTimeoutInterim=" + serviceTimeoutInterim + ", created=" + created); - this.id = id; - this.serviceModelUUID = serviceModelUUID; - this.action = action; - this.description = description; - this.orchestrationUri = orchestrationUri; - this.serviceParamXSD = serviceParamXSD; - this.recipeTimeout = recipeTimeout; - this.serviceTimeoutInterim = serviceTimeoutInterim; - long date = created.getTime(); - this.created = new Timestamp(date); - } - - public int getId() { - return id; - } - public void setId(int id) { - this.id = id; - } - - public String getServiceModelUUID() { - return serviceModelUUID; - } - public void setServiceModelUUID(String serviceModelUUID) { - this.serviceModelUUID = serviceModelUUID; - } - - public String getAction() { - return action; - } - public void setAction(String action) { - this.action = action; - } - - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - public String getOrchestrationUri() { - return orchestrationUri; - } - public void setOrchestrationUri(String orchestrationUri) { - this.orchestrationUri = orchestrationUri; - } - - public String getServiceParamXSD() { - return serviceParamXSD; - } - public void setServiceParamXSD(String serviceParamXSD) { - this.serviceParamXSD = serviceParamXSD; - } - - public int getRecipeTimeout() { - return recipeTimeout; - } - public void setRecipeTimeout(int recipeTimeout) { - this.recipeTimeout = recipeTimeout; - } - - public Integer getServiceTimeoutInterim() { - return serviceTimeoutInterim; - } - - public void setServiceTimeoutInterim(Integer serviceTimeoutInterim) { - this.serviceTimeoutInterim = serviceTimeoutInterim; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("RECIPE: ").append(action); - sb.append(",uri=").append(orchestrationUri); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java deleted file mode 100644 index 2ac71f4ddf..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToAllottedResources.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -public class ServiceToAllottedResources implements Serializable { - - @BusinessKey - private String serviceModelUuid = null; - @BusinessKey - private String arModelCustomizationUuid = null; - private Timestamp created = null; - - public static final long serialVersionUID = -1322322139926390329L; - - public ServiceToAllottedResources() { - super(); - } - - public String getServiceModelUuid() { - return this.serviceModelUuid; - } - public void setServiceModelUuid(String serviceModelUuid) { - this.serviceModelUuid = serviceModelUuid; - } - public String getArModelCustomizationUuid() { - return this.arModelCustomizationUuid; - } - public void setArModelCustomizationUuid(String arModelCustomizationUuid) { - this.arModelCustomizationUuid = arModelCustomizationUuid; - } - public Timestamp getCreated() { - return this.created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof ServiceToAllottedResources)) { - return false; - } - if (this == o) { - return true; - } - ServiceToAllottedResources star = (ServiceToAllottedResources) o; - if (star.getArModelCustomizationUuid().equals(this.getArModelCustomizationUuid()) - && star.getServiceModelUuid().equals(this.getServiceModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode() { - - int code = this.arModelCustomizationUuid == null ? 0 : this.arModelCustomizationUuid.hashCode(); - code += this.serviceModelUuid == null ? 0 : this.serviceModelUuid.hashCode(); - - return code; - } - - @Override - public String toString() { - return "serviceModelUuid=" + this.serviceModelUuid + "arModelCustomizationUuid=" + this.arModelCustomizationUuid; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java deleted file mode 100644 index 3894b4f7b5..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToNetworks.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -public class ServiceToNetworks implements Serializable { - - // This maps to SERVICE.SERVICE_NAME_VERSION_ID / Service.serviceNameVersionId in SERVICE/Service table - @BusinessKey - private String serviceModelUuid = null; - // This maps to NETWORK_RESOURCE_CUSTOMIZATION.MODEL_CUSTOMIZATION_UUID / NetworkResourceCustomization.ModelCustomizationUuid - @BusinessKey - private String networkModelCustomizationUuid = null; - private Timestamp created = null; - public static final long serialVersionUID = -1322322139926390329L; - - public ServiceToNetworks() { - super(); - } - - public String getServiceModelUuid() { - return this.serviceModelUuid; - } - public void setServiceModelUuid(String serviceModelUuid) { - this.serviceModelUuid = serviceModelUuid; - } - - public String getNetworkModelCustomizationUuid() { - return this.networkModelCustomizationUuid; - } - public void setNetworkModelCustomizationUuid(String networkCustomizationUuid) { - this.networkModelCustomizationUuid = networkCustomizationUuid; - } - - public Timestamp getCreated() { - return this.created; - } - public void setCreated(Timestamp timestamp) { - this.created = timestamp; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof ServiceToNetworks)) { - return false; - } - if (this == o) { - return true; - } - ServiceToNetworks stn = (ServiceToNetworks) o; - if (stn.getNetworkModelCustomizationUuid().equals(this.getNetworkModelCustomizationUuid()) - && stn.getServiceModelUuid().equals(this.getServiceModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode() { - - int code = this.networkModelCustomizationUuid == null ? 0 : this.networkModelCustomizationUuid.hashCode(); - code += this.serviceModelUuid == null ? 0 : this.serviceModelUuid.hashCode(); - - return code; - } - - @Override - public String toString() { - return "ServiceToNetworks mapping: " + "serviceModelUuid=" + this.serviceModelUuid - + ",networkModelCustomizationUuid=" + networkModelCustomizationUuid; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java deleted file mode 100644 index 3babe4ad23..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceToResourceCustomization.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.apache.commons.lang3.builder.EqualsBuilder; - -import com.openpojo.business.annotation.BusinessKey; - -public class ServiceToResourceCustomization implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - @BusinessKey - private String modelType = null; - @BusinessKey - private String serviceModelUUID = null; - private Timestamp created = null; - @BusinessKey - private String resourceModelCustomizationUUID = null; - - public ServiceToResourceCustomization() {} - - public String getServiceModelUUID() { - return serviceModelUUID; - } - - public void setServiceModelUUID(String serviceModelUUID) { - this.serviceModelUUID = serviceModelUUID; - } - - public String getModelType() { - return modelType; - } - - public void setModelType(String modelType) { - this.modelType = modelType; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getResourceModelCustomizationUUID() { - return resourceModelCustomizationUUID; - } - - public void setResourceModelCustomizationUUID(String resourceModelCustomizationUUID) { - this.resourceModelCustomizationUUID = resourceModelCustomizationUUID; - } - - - @Override - public boolean equals (final Object other) { - if (!(other instanceof ServiceToResourceCustomization)) { - return false; - } - ServiceToResourceCustomization castOther = (ServiceToResourceCustomization) other; - return new EqualsBuilder().append(modelType, castOther.modelType) - .append(serviceModelUUID, castOther.serviceModelUUID) - .append(resourceModelCustomizationUUID, castOther.resourceModelCustomizationUUID).isEquals(); - } - - @Override - public int hashCode() { - - int code = this.modelType == null ? 0 : this.modelType.hashCode(); - code += this.serviceModelUUID == null ? 0 : this.serviceModelUUID.hashCode(); - code += this.resourceModelCustomizationUUID == null ? 0 : this.resourceModelCustomizationUUID.hashCode(); - - return code; - - }@Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("ServiceToResourceCustomization: modelType=").append(modelType).append(",serviceModelUUID=") - .append(serviceModelUUID).append(",resourceModelCustomizationUUID=").append(resourceModelCustomizationUUID); - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java deleted file mode 100644 index 6fd6e3e6ae..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/TempNetworkHeatTemplateLookup.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; - -import com.openpojo.business.annotation.BusinessKey; - -public class TempNetworkHeatTemplateLookup implements Serializable { - - @BusinessKey - private String networkResourceModelName = null; - @BusinessKey - private String heatTemplateArtifactUuid = null; - private String aicVersionMin = null; - private String aicVersionMax = null; - public static final long serialVersionUID = -1322322139926390329L; - - public TempNetworkHeatTemplateLookup() { - super(); - } - - public String getNetworkResourceModelName() { - return this.networkResourceModelName; - } - public void setNetworkResourceModelName(String networkResourceModelName) { - this.networkResourceModelName = networkResourceModelName; - } - - public String getHeatTemplateArtifactUuid() { - return this.heatTemplateArtifactUuid; - } - public void setHeatTemplateArtifactUuid(String heatTemplateArtifactUuid) { - this.heatTemplateArtifactUuid = heatTemplateArtifactUuid; - } - public String getAicVersionMin() { - return this.aicVersionMin; - } - - public void setAicVersionMin(String aicVersionMin) { - this.aicVersionMin = aicVersionMin; - } - - public String getAicVersionMax() { - return this.aicVersionMax; - } - - public void setAicVersionMax(String aicVersionMax) { - this.aicVersionMax = aicVersionMax; - } - - @Override - public String toString() { - return "NetworkResourceModelName=" + this.networkResourceModelName + "HeatTemplateArtifactUuid=" + - this.heatTemplateArtifactUuid + "aicVersionMin=" + this.aicVersionMin + "aicVersionMax=" + this.aicVersionMax; - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof TempNetworkHeatTemplateLookup)) { - return false; - } - if (this == o) { - return true; - } - TempNetworkHeatTemplateLookup tnhtl = (TempNetworkHeatTemplateLookup) o; - if (tnhtl.getHeatTemplateArtifactUuid().equals(this.getHeatTemplateArtifactUuid()) && tnhtl.getNetworkResourceModelName().equals(this.getNetworkResourceModelName())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result; - result = (this.networkResourceModelName != null ? this.networkResourceModelName.hashCode() : 0) + (this.heatTemplateArtifactUuid != null ? this.heatTemplateArtifactUuid.hashCode() : 0); - return result; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java deleted file mode 100644 index 92d02d8a11..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ToscaCsar.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.HashSet; -import java.util.Set; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class ToscaCsar extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String artifactUUID = null; - private String name = null; - private String artifactChecksum = null; - private String url = null; - private String description = null; - private Timestamp created = null; - private Set<Service> services = new HashSet<>(); - - public ToscaCsar() { } - - public String getArtifactUUID() { - return artifactUUID; - } - - public void setArtifactUUID(String artifactUUID) { - this.artifactUUID = artifactUUID; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public Set<Service> getServices() { - return services; - } - - public void setServices(Set<Service> services) { - this.services = services; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("TOSCACSAR: artifactUUID=").append(artifactUUID).append(",name=").append(name).append(",version=") - .append(version).append(",description=").append(description).append(",artifactChecksum=") - .append(artifactChecksum).append(",url=").append(url); - for (Service service : services) { - sb.append("\n").append(service.toString()); - } - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java deleted file mode 100644 index ec3bc7fefb..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - - - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class VfModule extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelInvariantUUID = null; - private String modelName = null; - private String modelVersion = null; - private String description = null; - private int isBase; - private String heatTemplateArtifactUUId = null; - private String volHeatTemplateArtifactUUId = null; - private Timestamp created = null; - private String modelUUID = null; - private String vnfResourceModelUUId = null; - - public VfModule() { - super(); - } - - public String getVnfResourceModelUUId() { - return this.vnfResourceModelUUId; - } - - public void setVnfResourceModelUUId(String vnfResourceModelUUId) { - this.vnfResourceModelUUId = vnfResourceModelUUId; - } - - public String getModelName() { - return this.modelName; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public int getIsBase() { - return this.isBase; - } - - public void setIsBase(int isBase) { - this.isBase = isBase; - } - - public boolean isBase() { - if (this.isBase == 0) { - return false; - } else { - return true; - } - } - - public String getHeatTemplateArtifactUUId() { - return this.heatTemplateArtifactUUId; - } - - public void setHeatTemplateArtifactUUId(String heatTemplateArtifactUUId) { - this.heatTemplateArtifactUUId = heatTemplateArtifactUUId; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getModelInvariantUuid() { - return this.modelInvariantUUID; - } - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUUID = modelInvariantUuid; - } - public String getModelInvariantUUID() { - return this.modelInvariantUUID; - } - public void setModelInvariantUUID(String modelInvariantUuid) { - this.modelInvariantUUID = modelInvariantUuid; - } - - public String getVolHeatTemplateArtifactUUId() { - return this.volHeatTemplateArtifactUUId; - } - - public void setVolHeatTemplateArtifactUUId(String volHeatTemplateArtifactUUId) { - this.volHeatTemplateArtifactUUId = volHeatTemplateArtifactUUId; - } - - public String getModelUUID() { - return modelUUID; - } - - public void setModelUUID(String modelUUID) { - this.modelUUID = modelUUID; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - @Override - public String toString () { - StringBuilder buf = new StringBuilder(); - - buf.append("VFModule:"); - buf.append("modelName="); - buf.append(modelName); - buf.append(",modelVersion="); - buf.append(modelVersion); - buf.append(",vnfResourceModelUUId="); - buf.append(this.vnfResourceModelUUId); - buf.append(",heatTemplateArtifactUUId="); - buf.append(this.heatTemplateArtifactUUId); - buf.append(", description="); - buf.append(this.description); - buf.append(",volHeatTemplateArtifactUUId="); - buf.append(this.volHeatTemplateArtifactUUId); - buf.append(",isBase="); - buf.append(this.isBase); - buf.append(",modelInvariantUUID="); - buf.append(this.modelInvariantUUID); - buf.append(",modelUUID="); - buf.append(this.modelUUID); - - if (this.created != null) { - buf.append (",created="); - buf.append (DateFormat.getInstance().format(this.created)); - } - - return buf.toString(); - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java deleted file mode 100644 index 5b3dec4700..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleCustomization.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -public class VfModuleCustomization implements Serializable { - - @BusinessKey - private String modelCustomizationUuid = null; - @BusinessKey - private String vfModuleModelUuid = null; - private String label = null; - private Integer minInstances; - private Integer maxInstances; - private Integer initialCount; - private Integer availabilityZoneCount; - private String heatEnvironmentArtifactUuid = null; - private String volEnvironmentArtifactUuid = null; - private Timestamp created = null; - private VfModule vfModule; - public static final long serialVersionUID = -1322322139926390329L; - - public VfModuleCustomization() { - super(); - } - - public String getModelCustomizationUuid() { - return this.modelCustomizationUuid; - } - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - public String getVfModuleModelUuid() { - return this.vfModuleModelUuid; - } - public void setVfModuleModelUuid(String vfModuleModelUuid) { - this.vfModuleModelUuid = vfModuleModelUuid; - } - public String getHeatEnvironmentArtifactUuid() { - return this.heatEnvironmentArtifactUuid; - } - public void setHeatEnvironmentArtifactUuid(String heatEnvironmentArtifactUuid) { - this.heatEnvironmentArtifactUuid = heatEnvironmentArtifactUuid; - } - public String getVolEnvironmentArtifactUuid() { - return this.volEnvironmentArtifactUuid; - } - public void setVolEnvironmentArtifactUuid(String volEnvironmentArtifactUuid) { - this.volEnvironmentArtifactUuid = volEnvironmentArtifactUuid; - } - - public Integer getMinInstances() { - return this.minInstances; - } - public void setMinInstances(Integer minInstances) { - this.minInstances = minInstances; - } - public Integer getMaxInstances() { - return this.maxInstances; - } - public void setMaxInstances(Integer maxInstances) { - this.maxInstances = maxInstances; - } - public Integer getInitialCount() { - return this.initialCount; - } - public void setInitialCount(Integer initialCount) { - this.initialCount = initialCount; - } - public Integer getAvailabilityZoneCount() { - return this.availabilityZoneCount; - } - public void setAvailabilityZoneCount(Integer availabilityZoneCount) { - this.availabilityZoneCount = availabilityZoneCount; - } - public Timestamp getCreated() { - return created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - public String getLabel() { - return this.label; - } - public void setLabel(String label) { - this.label = label; - } - public VfModule getVfModule() { - return this.vfModule; - } - public void setVfModule(VfModule vfModule) { - this.vfModule = vfModule; - } - - @Override - public String toString() { - return "modelCustomizationUuid=" + this.modelCustomizationUuid + - "vfModuleModelUuid=" + this.vfModuleModelUuid + - "label=" + this.label + - "initalCount=" + this.initialCount + - "minInstances=" + this.minInstances + - "maxInstances=" + this.maxInstances + - "availabilityZoneCount=" + this.availabilityZoneCount + - "heatEnvironmentArtifactUuid=" + this.heatEnvironmentArtifactUuid + - "volEnvironmentArtifactUuid=" + this.volEnvironmentArtifactUuid + - "created=" + this.created; - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof VfModuleCustomization)) { - return false; - } - if (this == o) { - return true; - } - VfModuleCustomization vfmc = (VfModuleCustomization) o; - if (vfmc.getModelCustomizationUuid().equals(this.getModelCustomizationUuid()) && vfmc.getVfModuleModelUuid().equals(this.getVfModuleModelUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result = 0; - result = (this.modelCustomizationUuid != null ? this.modelCustomizationUuid.hashCode() : 0) + (this.vfModuleModelUuid != null ? this.vfModuleModelUuid.hashCode() : 0); - return result; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java deleted file mode 100644 index 3796650364..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - - - -import java.io.Serializable; - -public class VfModuleToHeatFiles implements Serializable { - - private String vfModuleModelUuid = null; - private String heatFilesArtifactUuid = null; - public static final long serialVersionUID = -1322322139926390329L; - - public VfModuleToHeatFiles() { - super(); - } - - public String getVfModuleModelUuid() { - return this.vfModuleModelUuid; - } - public void setVfModuleModelUuid(String vfModuleModelUuid) { - this.vfModuleModelUuid = vfModuleModelUuid; - } - public String getHeatFilesArtifactUuid() { - return this.heatFilesArtifactUuid; - } - public void setHeatFilesArtifactUuid(String heatFilesArtifactUuid) { - this.heatFilesArtifactUuid = heatFilesArtifactUuid; - } - - @Override - public String toString() { - return "vfModuleModelUuid=" + this.vfModuleModelUuid + ", heatFilesArtifactUuid=" + this.heatFilesArtifactUuid; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java deleted file mode 100644 index 9b701df1d2..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - - - -import java.sql.Timestamp; -import java.text.DateFormat; - -import com.openpojo.business.annotation.BusinessKey; - -import java.io.Serializable; - -public class VnfComponent implements Serializable { - @BusinessKey - private int vnfId; - @BusinessKey - private String componentType = null; - private Integer heatTemplateId; - private Integer heatEnvironmentId; - public static final long serialVersionUID = -1322322139926390329L; - - private Timestamp created = null; - - public VnfComponent() {} - - public int getVnfId() { - return vnfId; - } - public void setVnfId(int id) { - this.vnfId = id; - } - - public String getComponentType() { - return componentType; - } - public void setComponentType(String ct) { - this.componentType = ct; - } - - public Integer getHeatTemplateId() { - return heatTemplateId; - } - public void setHeatTemplateId(Integer ht) { - this.heatTemplateId = ht; - } - - public Integer getHeatEnvironmentId() { - return heatEnvironmentId; - } - public void setHeatEnvironmentId(Integer he) { - this.heatEnvironmentId = he; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("VnfComponent: "); - sb.append("vnfId=").append(vnfId); - sb.append(",componentType=").append(componentType); - sb.append(",heatTemplateId=").append(heatTemplateId); - sb.append(",heatEnvironmentId=").append(heatEnvironmentId); - - if (created != null) { - sb.append (",created="); - sb.append (DateFormat.getInstance().format(created)); - } - return sb.toString(); - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof VnfComponent)) { - return false; - } - if (this == o) { - return true; - } - VnfComponent vnfComponent = (VnfComponent) o; - if (vnfComponent.getVnfId() == this.vnfId && vnfComponent.componentType.equalsIgnoreCase(this.componentType)) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // return the hashCode of the concat string of type+vnfId - should be okay. - int result = 0; - result = (this.componentType + this.vnfId).hashCode(); - return result; - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java deleted file mode 100644 index 2240191d45..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; - -public class VnfComponentsRecipe extends Recipe implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String vnfType = null; - private String vnfComponentType = null; - private String vfModuleModelUUId = null; - - public VnfComponentsRecipe() {} - - public String getVnfType() { - return vnfType; - } - public void setVnfType(String vnfType) { - this.vnfType = vnfType; - } - - public String getVnfComponentType() { - return vnfComponentType; - } - public void setVnfComponentType(String vnfComponentType) { - this.vnfComponentType = vnfComponentType; - } - - public String getVfModuleModelUUId() { - return vfModuleModelUUId; - } - - public void setVfModuleModelUUId(String vfModuleModelUUId) { - this.vfModuleModelUUId = vfModuleModelUUId; - } - - @Override - public String toString () { - return super.toString() + ",vnfComponentParamXSD=" + getParamXSD() + ",serviceType=" + getServiceType() + - ",vnfComponentType=" + getVnfComponentType() + ",vfModuleId=" + getVfModuleModelUUId(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java deleted file mode 100644 index d94334c98d..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; - -public class VnfRecipe extends Recipe implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String vnfType = null; - private String vfModuleId = null; - - public VnfRecipe() {} - - public String getVnfType() { - return vnfType; - } - public void setVnfType(String vnfType) { - this.vnfType = vnfType; - } - - public String getVfModuleId() { - return vfModuleId; - } - - public void setVfModuleId(String vfModuleId) { - this.vfModuleId = vfModuleId; - } - - @Override - public String toString () { - return super.toString() + ",vnfParamXSD=" + getParamXSD() + ",serviceType=" + getServiceType() + ",vfModuleId=" + - getVfModuleId(); - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java deleted file mode 100644 index 6b1cb0a19c..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResCustomToVfModuleCustom.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; - -import com.openpojo.business.annotation.BusinessKey; - -public class VnfResCustomToVfModuleCustom implements Serializable { - - @BusinessKey - private String vnfResourceCustModelCustomizationUuid = null; - @BusinessKey - private String vfModuleCustModelCustomizationUuid = null; - private Timestamp created = null; - - public static final long serialVersionUID = -1322322139926390329L; - - - public VnfResCustomToVfModuleCustom() { - super(); - } - public String getVnfResourceCustModelCustomizationUuid() { - return this.vnfResourceCustModelCustomizationUuid; - } - public void setVnfResourceCustModelCustomizationUuid(String vnfResourceCustModelCustomizationUuid) { - this.vnfResourceCustModelCustomizationUuid = vnfResourceCustModelCustomizationUuid; - } - public String getVfModuleCustModelCustomizationUuid() { - return this.vfModuleCustModelCustomizationUuid; - } - public void setVfModuleCustModelCustomizationUuid(String vfModuleCustModelCustomizationUuid) { - this.vfModuleCustModelCustomizationUuid = vfModuleCustModelCustomizationUuid; - } - public Timestamp getCreated() { - return created; - } - public void setCreated(Timestamp created) { - this.created = created; - } - - @Override - public String toString() { - return "vnfResourceCustModelCustomizationUuid=" + this.vnfResourceCustModelCustomizationUuid + - "vfModuleCustModelCustomizationUuid=" + this.vfModuleCustModelCustomizationUuid + "created=" + this.created; - } - - @Override - public boolean equals (Object o) { - if (!(o instanceof VnfResCustomToVfModuleCustom)) { - return false; - } - if (this == o) { - return true; - } - VnfResCustomToVfModuleCustom vrctvmc = (VnfResCustomToVfModuleCustom) o; - if (vrctvmc.getVnfResourceCustModelCustomizationUuid().equals(this.getVnfResourceCustModelCustomizationUuid()) && vrctvmc.getVfModuleCustModelCustomizationUuid().equals(this.getVfModuleCustModelCustomizationUuid())) { - return true; - } - return false; - } - - @Override - public int hashCode () { - // hash code does not have to be a unique result - only that two objects that should be treated as equal - // return the same value. so this should work. - int result = 0; - result = (this.vnfResourceCustModelCustomizationUuid != null ? this.vnfResourceCustModelCustomizationUuid.hashCode() : 0) + (this.vfModuleCustModelCustomizationUuid != null ? this.vfModuleCustModelCustomizationUuid.hashCode() : 0); - return result; - } - - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java deleted file mode 100644 index f8e6024e69..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java +++ /dev/null @@ -1,283 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.beans; - - -import java.io.Serializable; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.util.HashSet; -import java.util.Set; -import java.util.List; -import java.util.ArrayList; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class VnfResource extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelUuid = null; - private String modelInvariantUuid = null; - private String modelName = null; - private String toscaNodeType = null; - private String description = null; - private String orchestrationMode = null; - private String aicVersionMin = null; - private String aicVersionMax = null; - private String category = null; - private String subCategory = null; - private String heatTemplateArtifactUUId = null; - private Timestamp created = null; - private String modelVersion = null; - private Set<VnfResourceCustomization> vnfResourceCustomizations = new HashSet<>(); - private Set<VfModule> vfModules = new HashSet<>(); - private List<VfModuleCustomization> vfModuleCustomizations = new ArrayList<>(); - - public VnfResource () { } - - public String getOrchestrationMode () { - return orchestrationMode; - } - - public void setOrchestrationMode (String orchestrationMode) { - this.orchestrationMode = orchestrationMode; - } - - public String getDescription () { - return description; - } - - public void setDescription (String description) { - this.description = description; - } - - public String getTemplateId () { - return heatTemplateArtifactUUId; - } - - public void setTemplateId (String heatTemplateArtifactUUId) { - this.heatTemplateArtifactUUId = heatTemplateArtifactUUId; - } - public String getHeatTemplateArtifactUUId () { - return heatTemplateArtifactUUId; - } - - public void setHeatTemplateArtifactUUId (String heatTemplateArtifactUUId) { - this.heatTemplateArtifactUUId = heatTemplateArtifactUUId; - } - - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public String getAicVersionMin() { - return this.aicVersionMin; - } - - public void setAicVersionMin(String aicVersionMin) { - this.aicVersionMin = aicVersionMin; - } - - public String getAicVersionMax() { - return this.aicVersionMax; - } - - public void setAicVersionMax(String aicVersionMax) { - this.aicVersionMax = aicVersionMax; - } - - - /** - * @return Returns the category. - */ - public String getCategory() { - return category; - } - - - /** - * @param category The category to set. - */ - public void setCategory(String category) { - this.category = category; - } - - - /** - * @return Returns the subCategory. - */ - public String getSubCategory() { - return subCategory; - } - - - /** - * @param subCategory The subCategory to set. - */ - public void setSubCategory(String subCategory) { - this.subCategory = subCategory; - } - - public String getModelInvariantUuid() { - return this.modelInvariantUuid; - } - - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUuid = modelInvariantUuid; - } - - public String getModelName() { - return modelName; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public String getModelUuid() { - return modelUuid; - } - - public void setModelUuid(String modelUuid) { - this.modelUuid = modelUuid; - } - - public String getModelInvariantId() { - return this.modelInvariantUuid; - } - - public String getToscaNodeType() { - return toscaNodeType; - } - - public void setToscaNodeType(String toscaNodeType) { - this.toscaNodeType = toscaNodeType; - } - - public Set<VnfResourceCustomization> getVnfResourceCustomizations() { - return vnfResourceCustomizations; - } - - public void setVnfResourceCustomizations(Set<VnfResourceCustomization> vnfResourceCustomizations) { - this.vnfResourceCustomizations = vnfResourceCustomizations; - } - - public Set<VfModule> getVfModules() { - return vfModules; - } - - public void setVfModules(Set<VfModule> vfModules) { - this.vfModules = vfModules; - } - - public List<VfModuleCustomization> getVfModuleCustomizations() { - return this.vfModuleCustomizations == null ? new ArrayList<>() : this.vfModuleCustomizations; - } - public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) { - this.vfModuleCustomizations = vfModuleCustomizations; - } - public void addVfModuleCustomization(VfModuleCustomization vfmc) { - if (vfmc != null) { - if (this.vfModuleCustomizations != null) { - this.vfModuleCustomizations.add(vfmc); - } else { - this.vfModuleCustomizations = new ArrayList<>(); - this.vfModuleCustomizations.add(vfmc); - } - } - } - - public void addVfModule(VfModule vfm) { - if (vfm != null) { - if (this.vfModules != null) { - this.vfModules.add(vfm); - } else { - this.vfModules = new HashSet<>(); - this.vfModules.add(vfm); - } - } - } - public ArrayList<VfModule> getVfModuleList() { - if (this.vfModules == null || this.vfModules.size() < 1) { - return null; - } - ArrayList<VfModule> list = new ArrayList<>(); - list.addAll(this.vfModules); - return list; - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - @Override - public String toString () { - StringBuilder sb = new StringBuilder(); - - sb.append("VNF="); - sb.append(",modelVersion="); - sb.append(modelVersion); - sb.append(",mode="); - sb.append(orchestrationMode); - sb.append(",heatTemplateArtifactUUId="); - sb.append(heatTemplateArtifactUUId); - sb.append(",envtId="); - sb.append(",asdcUuid="); - sb.append(",aicVersionMin="); - sb.append(this.aicVersionMin); - sb.append(",aicVersionMax="); - sb.append(this.aicVersionMax); - sb.append(",modelInvariantUuid="); - sb.append(this.modelInvariantUuid); - sb.append(",modelVersion="); - sb.append(",modelCustomizationName="); - sb.append(",modelName="); - sb.append(this.modelName); - sb.append(",serviceModelInvariantUUID="); - sb.append(",modelCustomizationUuid="); - sb.append(",toscaNodeType="); - sb.append(toscaNodeType); - - if (created != null) { - sb.append(",created="); - sb.append(DateFormat.getInstance().format(created)); - } - - for(VnfResourceCustomization vrc : vnfResourceCustomizations) { - sb.append("/n").append(vrc.toString()); - } - - for(VfModule vfm : vfModules) { - sb.append("/n").append(vfm.toString()); - } - return sb.toString(); - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java deleted file mode 100644 index e510ee867d..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResourceCustomization.java +++ /dev/null @@ -1,203 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.beans; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; - -public class VnfResourceCustomization extends MavenLikeVersioning implements Serializable { - - private static final long serialVersionUID = 768026109321305392L; - - private String modelCustomizationUuid = null; - private String modelInstanceName = null; - private Timestamp created = null; - private String vnfResourceModelUuid = null; - private String vnfResourceModelUUID = null; - private Integer minInstances; - private Integer maxInstances; - private Integer availabilityZoneMaxCount; - private VnfResource vnfResource; - private String nfFunction = null; - private String nfType = null; - private String nfRole = null; - private String nfNamingCode = null; - private String multiStageDesign = null; - private List<VfModuleCustomization> vfModuleCustomizations; - private Set<ServiceToResourceCustomization> serviceResourceCustomizations; - - public VnfResourceCustomization() { - } - - - public String getModelCustomizationUuid() { - return modelCustomizationUuid; - } - - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - - public String getModelInstanceName() { - return this.modelInstanceName; - } - public void setModelInstanceName(String modelInstanceName) { - this.modelInstanceName = modelInstanceName; - } - - public Timestamp getCreationTimestamp() { - return this.created; - } - public void setCreationTimestamp(Timestamp created) { - this.created = created; - } - - public String getVnfResourceModelUuid() { - return this.vnfResourceModelUuid == null ? this.vnfResourceModelUUID : this.vnfResourceModelUuid; - } - public void setVnfResourceModelUuid(String vnfResourceModelUuid) { - this.vnfResourceModelUuid = vnfResourceModelUuid; - } - public String getVnfResourceModelUUID() { - return this.vnfResourceModelUUID; - } - public void setVnfResourceModelUUID(String vnfResourceModelUUID) { - this.vnfResourceModelUUID = vnfResourceModelUUID; - } - public Integer getMinInstances() { - return this.minInstances; - } - public void setMinInstances(Integer minInstances) { - this.minInstances = minInstances; - } - - public Integer getMaxInstances() { - return this.maxInstances; - } - public void setMaxInstances(Integer maxInstances) { - this.maxInstances = maxInstances; - } - - public Integer getAvailabilityZoneMaxCount() { - return this.availabilityZoneMaxCount; - } - public void setAvailabilityZoneMaxCount(Integer availabilityZoneMaxCount) { - this.availabilityZoneMaxCount = availabilityZoneMaxCount; - } - - public VnfResource getVnfResource() { - return this.vnfResource; - } - public void setVnfResource(VnfResource vnfResource) { - this.vnfResource = vnfResource; - } - - public String getNfFunction() { - return nfFunction; - } - - public void setNfFunction(String nfFunction) { - this.nfFunction = nfFunction; - } - - public String getNfType() { - return nfType; - } - - public void setNfType(String nfType) { - this.nfType = nfType; - } - - public String getNfRole() { - return nfRole; - } - - public void setNfRole(String nfRole) { - this.nfRole = nfRole; - } - - public String getNfNamingCode() { - return nfNamingCode; - } - - public void setNfNamingCode(String nfNamingCode) { - this.nfNamingCode = nfNamingCode; - } - public String getMultiStageDesign() { - return this.multiStageDesign; - } - public void setMultiStageDesign(String multiStageDesign) { - this.multiStageDesign = multiStageDesign; - } - public List<VfModuleCustomization> getVfModuleCustomizations() { - return this.vfModuleCustomizations; - } - public void setVfModuleCustomizations(List<VfModuleCustomization> vfModuleCustomizations) { - this.vfModuleCustomizations = vfModuleCustomizations; - } - public void addVfModuleCustomization(VfModuleCustomization vfmc) { - if (vfmc != null) { - if (this.vfModuleCustomizations != null) { - this.vfModuleCustomizations.add(vfmc); - } else { - this.vfModuleCustomizations = new ArrayList<>(); - this.vfModuleCustomizations.add(vfmc); - } - } - } - public Timestamp getCreated() { - return created; - } - - public void setCreated(Timestamp created) { - this.created = created; - } - - public Set<ServiceToResourceCustomization> getServiceResourceCustomizations() { - return serviceResourceCustomizations; - } - - public void setServiceResourceCustomizations( - Set<ServiceToResourceCustomization> serviceResourceCustomizations) { - this.serviceResourceCustomizations = serviceResourceCustomizations; - } - - @Override - public String toString() { - return "VnfResourceCustomization: " + "ModelCustUuid=" + this.modelCustomizationUuid + - ", ModelInstanceName=" + this.modelInstanceName + - ", vnfResourceModelUuid=" + this.vnfResourceModelUUID + - ", creationTimestamp=" + this.created + - ", minInstances=" + this.minInstances + - ", maxInstances=" + this.maxInstances + - ", availabilityZoneMaxCount=" + this.availabilityZoneMaxCount + - ", nfFunction=" + this.nfFunction + - ", nfType=" + this.nfType + - ", nfRole=" + this.nfRole + - ", nfNamingCode=" + this.nfNamingCode + - ", multiStageDesign=" + this.multiStageDesign; - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java deleted file mode 100644 index e42f734a64..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.utils; - - -import java.io.Serializable; - -/** - * This class is the base class for object that requires a Version in Catalog DB. - * The version is built on a string as ASDC provides a number like 1.2 or 2.0 ... - * This class supports also 1.2.3.4... (Maven like version) - * - * - */ -public class MavenLikeVersioning implements Serializable { - - protected String version; - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - /** - * This method is used to compare the current object version to a specified one - * It is assumed that the version is like the maven one, eg: 2.0.1.5.6 - * - * @param versionToCompare The version that will be used for comparison - * @return True if the current object is more recent than the specified version, False otherwise - * - */ - public boolean isMoreRecentThan (String versionToCompare) { - if (versionToCompare == null || versionToCompare.trim().isEmpty() || this.version == null || this.version.trim().isEmpty()) { - return false; - } - String[] currentVersionArray = this.version.split("\\."); - String[] specifiedVersionArray = versionToCompare.split("\\."); - - int smalestStringLength = Math.min(currentVersionArray.length, specifiedVersionArray.length); - - for (int currentVersionIndex = 0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) { - - if (Integer.parseInt(currentVersionArray[currentVersionIndex]) < Integer - .parseInt(specifiedVersionArray[currentVersionIndex])) { - return false; - } else if (Integer.parseInt(currentVersionArray[currentVersionIndex]) > Integer - .parseInt(specifiedVersionArray[currentVersionIndex])) { - return true; - } - } - try { - // Even if versionToCompare has more digits, it means versionToCompare is more recent - return Integer.parseInt(currentVersionArray[smalestStringLength - 1]) != Integer - .parseInt(specifiedVersionArray[smalestStringLength - 1]) - || currentVersionArray.length > specifiedVersionArray.length; - } catch (NumberFormatException e) { - return false; - } - } - - /** - * This method is used to compare the current object version to a specified one - * It is assumed that the version is like the maven one, eg: 2.0.1.5.6 - * - * @param versionToCompare The version that will be used for comparison - * @return True if the current object is equal to the specified version, False otherwise - * - */ - public boolean isTheSameVersion (String versionToCompare) { - if (versionToCompare == null && this.version == null) { - return true; - } else if (versionToCompare == null || versionToCompare.trim().equals("") || this.version == null || this.version.trim().equals("")) { - return false; - } - String [] currentVersionArray = this.version.split("\\."); - String [] specifiedVersionArray = versionToCompare.split("\\."); - - if (currentVersionArray.length != specifiedVersionArray.length) { - return false; - } - - for (int currentVersionIndex=0;currentVersionIndex < currentVersionArray.length;++currentVersionIndex) { - - if (Integer.parseInt(currentVersionArray[currentVersionIndex]) != Integer.parseInt(specifiedVersionArray[currentVersionIndex])) { - return false; - } - } - - return true; - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioningComparator.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioningComparator.java deleted file mode 100644 index 49fd1fa6f6..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioningComparator.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db.catalog.utils; - - -import java.util.Comparator; - -/** - * This class can be used to sort object from MavenLikeVersioning type. - * - * - * - */ -public class MavenLikeVersioningComparator implements Comparator<MavenLikeVersioning> { - - @Override - public int compare(MavenLikeVersioning o1, MavenLikeVersioning o2) { - final int BEFORE = -1; - final int EQUAL = 0; - final int AFTER = 1; - - if (o1.isTheSameVersion(o2.getVersion())) { - return EQUAL; - } else if (o1.isMoreRecentThan(o2.getVersion())) { - return AFTER; - } else { - return BEFORE; - } - } - -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.java deleted file mode 100644 index 33ece6679e..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/RecordNotFoundException.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.db.catalog.utils; - -/* -* Exception of the ASDC controller. -*/ -public class RecordNotFoundException extends Exception { - - /** - * serialization id. - */ - private static final long serialVersionUID = 8425657297510362736L; - - /** - * @param message The message to dump - * @param cause The Throwable cause object - */ - public RecordNotFoundException(final String message) { - super (message); - - } - - /** - * @param message The message to dump - * @param cause The Throwable cause object - */ - public RecordNotFoundException(final String message, final Throwable cause) { - super (message, cause); - - } -} diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/package-info.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/package-info.java deleted file mode 100644 index b5e4348930..0000000000 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -/** - * Utility classes for catalog DB. - */ - -package org.openecomp.mso.db.catalog.utils; - |