aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main
diff options
context:
space:
mode:
authorChrisC <cc697w@intl.att.com>2017-01-31 11:40:03 +0100
committerChrisC <cc697w@intl.att.com>2017-01-31 12:59:33 +0100
commit025301d08b061482c1f046d562bf017c8cbcfe8d (patch)
tree68a2a549736c9bf0f7cd4e71c76e40ef7e2606f2 /mso-catalog-db/src/main
parent2754ad52f833278a5c925bd788a16d1dce16a598 (diff)
Initial OpenECOMP MSO commit
Change-Id: Ia6a7574859480717402cc2f22534d9973a78fa6d Signed-off-by: ChrisC <cc697w@intl.att.com>
Diffstat (limited to 'mso-catalog-db/src/main')
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java1838
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java141
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java137
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java97
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java217
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java78
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java51
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java139
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java112
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java127
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java119
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java195
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java83
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java115
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java72
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java63
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java225
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java118
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioningComparator.java49
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/package-info.java26
-rw-r--r--mso-catalog-db/src/main/resources/HeatEnvironment.hbm.xml58
-rw-r--r--mso-catalog-db/src/main/resources/HeatNestedTemplate.hbm.xml38
-rw-r--r--mso-catalog-db/src/main/resources/HeatTemplate.hbm.xml93
-rw-r--r--mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml61
-rw-r--r--mso-catalog-db/src/main/resources/NetworkResource.hbm.xml55
-rw-r--r--mso-catalog-db/src/main/resources/Service.hbm.xml84
-rw-r--r--mso-catalog-db/src/main/resources/VfModule.hbm.xml81
-rw-r--r--mso-catalog-db/src/main/resources/VfModuleToHeatFiles.hbm.xml36
-rw-r--r--mso-catalog-db/src/main/resources/VnfComponent.hbm.xml43
-rw-r--r--mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml53
-rw-r--r--mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml66
-rw-r--r--mso-catalog-db/src/main/resources/VnfResource.hbm.xml134
-rw-r--r--mso-catalog-db/src/main/resources/hibernate-catalog-ajsc.cfg.xml75
-rw-r--r--mso-catalog-db/src/main/resources/hibernate-catalog-mysql.cfg.xml52
34 files changed, 4931 insertions, 0 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
new file mode 100644
index 0000000000..35158a46b4
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
@@ -0,0 +1,1838 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 java.io.Closeable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.openecomp.mso.db.catalog.beans.*;
+import org.hibernate.HibernateException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.service.ServiceRegistry;
+import org.hibernate.service.ServiceRegistryBuilder;
+
+import org.openecomp.mso.db.catalog.utils.MavenLikeVersioningComparator;
+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 {
+
+ 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 VNF_COMPONENT_TYPE = "vnfComponentType";
+ private static final String MODEL_NAME = "modelName";
+ private static final String TYPE = "type";
+ private static final String VF_MODULE_ID = "vfModuleId";
+ private static boolean initialized = false;
+ private static SessionFactory sessionFactory;
+ private static ServiceRegistry serviceRegistry;
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
+
+ private Session session = null;
+
+ public CatalogDatabase () {
+ }
+
+
+ private Session getSession () {
+ if (!initialized) {
+ LOGGER.debug ("Initializing Catalog Database in Hibernate");
+ Configuration configuration = null;
+ try {
+ if ("MYSQL".equals (System.getProperty ("mso.db"))
+ || "MARIADB".equals (System.getProperty ("mso.db"))) {
+ configuration = new Configuration ().configure ("hibernate-catalog-mysql.cfg.xml");
+
+ serviceRegistry = new ServiceRegistryBuilder ().applySettings (configuration.getProperties ()).buildServiceRegistry ();
+
+ sessionFactory = configuration.buildSessionFactory (serviceRegistry);
+ } 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");
+ }
+ } catch (Exception e) {
+ LOGGER.error (MessageEnum.GENERAL_EXCEPTION_ARG,
+ "Catalog DB initialization issue: " + e.getMessage (), "", "", MsoLogger.ErrorCode.DataError, "Catalog DB initialization issue: " + e.getMessage (), e);
+ throw e;
+ }
+ initialized = true;
+
+ LOGGER.debug ("Catalog Database initialization complete");
+ }
+
+ if (session == null) {
+ try {
+ session = sessionFactory.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
+ * @return HeatTemplate object or null if none found
+ */
+ 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
+ * @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;
+ }
+ Collections.sort (resultList, 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 ("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);
+ }
+
+ /**
+ * Fetch a Service definition
+ */
+ public Service getService (String serviceName) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get service with name " + serviceName);
+
+ String hql = "FROM Service WHERE serviceName = :service_name";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("service_name", serviceName);
+
+ 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: serviceName='" + serviceName + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for serviceName=" + serviceName, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for serviceName=" + serviceName);
+ return null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: serviceName='" + serviceName + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for serviceName=" + serviceName, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for serviceName=" + serviceName);
+ return null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: serviceName='" + serviceName);
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for serviceName=" + serviceName, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for serviceName=" + serviceName);
+ return null;
+ }
+ 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;
+ }
+
+ /**
+ * Fetch a Service definition
+ */
+ public Service getServiceByUUID (String serviceNameVersionId) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get service with UUID " + serviceNameVersionId);
+
+ String hql = "FROM Service WHERE serviceNameVersionId = :service_id";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("service_id", serviceNameVersionId);
+
+ 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: serviceNameVersionId='" + serviceNameVersionId + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " non unique result for serviceNameVersionId=" + serviceNameVersionId, "", "", MsoLogger.ErrorCode.DataError, "Non unique result for serviceNameVersionId=" + serviceNameVersionId);
+ return null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: serviceName='" + serviceNameVersionId + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for serviceNameVersionId=" + serviceNameVersionId, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for serviceNameVersionId=" + serviceNameVersionId);
+ return null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: serviceName='" + serviceNameVersionId);
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for serviceNameVersionId=" + serviceNameVersionId, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for serviceNameVersionId=" + serviceNameVersionId);
+ return null;
+ }
+ 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;
+ }
+
+ /**
+ * Fetch the Common Service API definition using Http Method + serviceNameVersionId
+ */
+ public Service getService(HashMap<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 serviceNameVersionId with id " + serviceNameVersionId);
+
+ String hql = "FROM Service WHERE service_name_version_id = :service_name_version_id and http_method = :http_method";
+ query = getSession ().createQuery (hql);
+ query.setParameter ("service_name_version_id", 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);
+ service = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "'");
+ 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);
+ service = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: service_id='" + serviceId + "', serviceVersion='" + serviceVersion + "'");
+ 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);
+ service = null;
+ }
+ 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 serviceName
+ * @return Service object or null if none found
+ */
+ public Service getServiceByName (String serviceName) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get service with name " + serviceName);
+
+ String hql = "FROM Service WHERE serviceName = :service_name";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("service_name", serviceName);
+
+ @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;
+ }
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceByName", null);
+ return resultList.get (0);
+ }
+
+ /**
+ * Return a newest version of Service recipe that matches a given SERVICE_ID and ACTION
+ *
+ * @param serviceId
+ * @param action *
+ * @return ServiceRecipe object or null if none found
+ */
+ public ServiceRecipe getServiceRecipe (int serviceId, String action) {
+
+ StringBuilder hql = new StringBuilder ("FROM ServiceRecipe WHERE serviceId = :serviceId AND action = :action ");
+
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get Service recipe with serviceId " + Integer.toString(serviceId)
+ + " and action "
+ + action
+ );
+
+ Query query = getSession ().createQuery (hql.toString ());
+ query.setParameter ("serviceId", serviceId);
+ 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;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getServiceRecipe", null);
+ return resultList.get (0);
+ }
+
+
+ /**
+ * 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
+ */
+ 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);
+ result = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: vnf_id='" + vnfId + "', componentType='" + type + "'");
+ 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);
+ result = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: vnf_id='" + vnfId + "', componentType='" + type + "'");
+ 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);
+ result = null;
+ }
+
+ //LOGGER.debug("Found VNF Component: " + result.toString());
+ 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 name " + vnfType);
+
+ String hql = "FROM VnfResource WHERE vnfType = :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;
+ }
+ Collections.sort (resultList, 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 version
+ * @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 name " + vnfType);
+
+ String hql = "FROM VnfResource WHERE vnfType = :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);
+ resource = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: vnfType='" + vnfType + "', asdc_service_model_version='" + serviceVersion + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for vnfType=" + vnfType);
+ resource = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: vnfType='" + vnfType + "', serviceVersion='" + serviceVersion + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for vnfType=" + vnfType + " and serviceVersion=" + serviceVersion, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for vnfType=" + vnfType);
+ resource = null;
+ }
+ 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
+ */
+ 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 model_name = :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;
+ }
+ Collections.sort (resultList, 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 model_name = :model_name and version = :model_version";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("model_name", 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);
+ module = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: type='" + modelName + "', asdc_service_model_version='" + model_version + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for type=" + modelName + " and version=" + model_version, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for type=" + modelName);
+ module = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: type='" + modelName + "', asdc_service_model_version='" + model_version + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for type=" + modelName + " and version=" + model_version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for type=" + modelName);
+ module = null;
+ }
+ 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;
+ }
+
+
+ /**
+ * 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 networkType = :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;
+ }
+
+ Collections.sort (resultList, 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", "getVnfRecipe", null);
+ return null;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null);
+ return resultList.get (0);
+ }
+
+ /**
+ * Return a 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) {
+ StringBuilder hql = new StringBuilder ("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action ");
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get VNF recipe with name " + vnfType
+ + " and action "
+ + action);
+
+ Query query = getSession ().createQuery (hql.toString ());
+ 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", "getVnfRecipe", null);
+ return null;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null);
+ return resultList.get (0);
+ }
+
+ /**
+ * Return a 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) {
+
+ StringBuilder hql = new StringBuilder ("FROM VnfRecipe WHERE vfModuleId = :vfModuleId and action = :action ");
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get VNF Recipe with vfModuleId " + vfModuleId);
+
+ Query query = getSession ().createQuery (hql.toString ());
+ query.setParameter (VF_MODULE_ID, 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;
+ }
+
+ Collections.sort (resultList, 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 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;
+ }
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModuleType", null);
+ return resultList.get (0);
+ }
+
+ 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 ("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);
+ module = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: type='" + type + "', asdc_service_model_version='" + version + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Hibernate exception searching for type=" + type + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Hibernate exception searching for type=" + type);
+ module = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: type='" + type + "', asdc_service_model_version='" + version + "'");
+ LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " Generic exception searching for type=" + type + " and version=" + version, "", "", MsoLogger.ErrorCode.DataError, "Generic exception searching for type=" + type);
+ module = null;
+ }
+ 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;
+ }
+
+
+ /**
+ * 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;
+
+ StringBuilder hql = new StringBuilder ("FROM VfModule WHERE type = :type ");
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType);
+
+ Query query = getSession ().createQuery (hql.toString ());
+ 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;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ VfModule vfMod = resultList.get(0);
+
+ int id = vfMod.getId();
+ String vfModuleId = Integer.toString(id);
+
+ StringBuilder hql1 = new StringBuilder ("FROM VnfRecipe WHERE vfModuleId = :vfModuleId AND action = :action ");
+
+ LOGGER.debug ("Catalog database - get VNF recipe with vf module id " + vfModuleId
+ + " and action "
+ + action);
+
+ Query query1 = getSession ().createQuery (hql1.toString ());
+ query1.setParameter (VF_MODULE_ID, 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;
+ }
+
+ Collections.sort (resultList1, 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 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 getVnfComponentsRecipe (String vnfType, String vfModuleModelName, String asdcServiceModelVersion, String modelVersion, String action) {
+ String vfModuleType = vnfType + "::" + vfModuleModelName;
+
+ StringBuilder hql = new StringBuilder ("FROM VfModule WHERE type = :type AND version = :version AND modelVersion = :modelVersion");
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get VF MODULE with type " + vfModuleType + ", asdcServiceModelVersion " + asdcServiceModelVersion + ", modelVersion " + modelVersion);
+
+ Query query = getSession ().createQuery (hql.toString ());
+ query.setParameter (TYPE, vfModuleType);
+ query.setParameter ("version", asdcServiceModelVersion);
+ query.setParameter ("modelVersion", modelVersion);
+
+ @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", "getVnfComponentsRecipe", null);
+ return null;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ VfModule vfMod = resultList.get(0);
+
+ int id = vfMod.getId();
+ String vfModuleId = Integer.toString(id);
+
+ StringBuilder hql1 = new StringBuilder ("FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND action = :action ");
+
+ LOGGER.debug ("Catalog database - get Vnf Components recipe with vf module id " + vfModuleId
+ + " and action "
+ + action);
+
+ Query query1 = getSession ().createQuery (hql1.toString ());
+ query1.setParameter (VF_MODULE_ID, 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;
+ }
+
+ Collections.sort (resultList1, 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")
+ 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 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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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
+ */
+ 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
+ */
+
+ public Map <String, Object> getNestedTemplates (int templateId) {
+ Map <String, Object> nestedTemplates = null;
+ 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 <String, Object> ();
+ 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;
+ }
+
+ /*
+ * Fetch any files in the HEAT_FILES table 1510
+ */
+ public Map <String, HeatFiles> getHeatFiles (int vnfResourceId) {
+ Map <String, HeatFiles> heatFiles = null;
+
+ 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 <String, HeatFiles> ();
+ 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
+
+ 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
+ //TODO - convert this all with one join - brute force for now due to time
+ 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;
+ }
+
+
+
+ /**
+ * 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
+ */
+ 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 ("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());
+
+ heat.setParameters(null);
+ try {
+ HeatTemplate heatTemp = this.getHeatTemplate (heat.getTemplateName (),
+ heat.getVersion (),
+ heat.getAsdcResourceName ());
+ if (heatTemp == null) {
+ this.getSession ().save (heat);
+
+ if (paramSet != null) {
+ for (HeatTemplateParam param : paramSet) {
+ param.setHeatTemplateId (heat.getId ());
+ }
+ heat.setParameters (paramSet);
+ this.getSession ().merge (heat);
+ }
+
+ } else {
+ heat.setId(heatTemp.getId());
+ }
+ } finally {
+ heat.setParameters(paramSet);
+ 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
+ */
+ 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 ("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);
+ 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);
+ 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);
+ 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;
+ }
+
+ /**
+ * 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());
+ try {
+ HeatEnvironment dbEnv = getHeatEnvironment (env.getName (), env.getVersion (), env.getAsdcResourceName ());
+ if (dbEnv == null) {
+
+ this.getSession ().save (env);
+
+ } else {
+ env.setId(dbEnv.getId());
+ }
+
+ } 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.getVnfType ());
+ try {
+
+ if (vnfResource.getId() != 0) {
+ this.getSession ().merge (vnfResource);
+ } else {
+ this.getSession ().save (vnfResource);
+ }
+
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVnfResource", 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.getServiceName()+"/"+service.getServiceVersion()+"/"+service.getServiceNameVersionId());
+ try {
+ Service serviceDB = this.getServiceByUUID(service.getServiceNameVersionId());
+ if (serviceDB == null) {
+ this.getSession ().save (service);
+ }
+
+ } 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 VNF Module with VF Model Name " + vfModule.getModelName());
+ try {
+
+ if (vfModule.getId() != 0) {
+ this.getSession ().merge (vfModule);
+ } else {
+ this.getSession ().save (vfModule);
+ }
+
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveOrUpdateVfModule", null);
+ }
+ }
+
+ 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);
+ }
+ }
+
+ public void saveNestedHeatTemplate (int parentTemplateId, HeatTemplate childTemplate, String yamlFile) {
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - save nested Heat template with name "
+ + childTemplate.getTemplateName ());
+ try {
+
+ saveHeatTemplate(childTemplate, childTemplate.getParameters());
+ if (getNestedHeatTemplate(parentTemplateId,childTemplate.getId()) == null) {
+ HeatNestedTemplate nestedTemplate = new HeatNestedTemplate ();
+ nestedTemplate.setParentTemplateId (parentTemplateId);
+ nestedTemplate.setChildTemplateId (childTemplate.getId ());
+ nestedTemplate.setProviderResourceFile (yamlFile);
+ session.save (nestedTemplate);
+ }
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNestedHeatTemplate", null);
+ }
+ }
+
+ 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 ("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);
+ heatFilesResult = null;
+ } catch (org.hibernate.HibernateException he) {
+ LOGGER.debug("Hibernate Exception - while searching for: fileName='" + fileName + "', vnfResourceId='" + vnfResourceId + "' and asdcResourceName=" + asdcResourceName + " and version=" + version);
+ 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);
+ heatFilesResult = null;
+ } catch (Exception e) {
+ LOGGER.debug("Generic Exception - while searching for: fileName='" + fileName + "', vnfResourceId='" + vnfResourceId + "' and asdcResourceName=" + asdcResourceName + " and version=" + version);
+ 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);
+ heatFilesResult = null;
+ }
+
+ // 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());
+ 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.setId(heatFiles.getId());
+ }
+
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveHeatFiles", null);
+ }
+ }
+
+ public void saveVfModuleToHeatFiles (int parentVfModuleId, HeatFiles childFile) {
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - save Heat File to VFmodule link "
+ + childFile.getFileName());
+ try {
+ saveHeatFiles (childFile);
+ VfModuleToHeatFiles vfModuleToHeatFile = new VfModuleToHeatFiles ();
+ vfModuleToHeatFile.setVfModuleId(parentVfModuleId);
+ vfModuleToHeatFile.setHeatFilesId(childFile.getId());
+
+ session.save (vfModuleToHeatFile);
+
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVfModuleToHeatFiles", 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;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ return resultList.get (0);
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null);
+ }
+ }
+
+ /**
+ * Return a Network recipe that matches a given NETWORK_TYPE and ACTION
+ *
+ * @param networkType
+ * @param action
+ * @return NetworkRecipe object or null if none found
+ */
+ public NetworkRecipe getNetworkRecipe (String networkType, String action) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get network recipe with network type " + networkType
+ + " and action "
+ + action
+ );
+
+ try {
+ String hql = "FROM NetworkRecipe WHERE networkType = :networkType AND action = :action";
+
+ Query query = getSession ().createQuery (hql);
+ query.setParameter (NETWORK_TYPE, networkType);
+ query.setParameter (ACTION, action);
+
+ @SuppressWarnings("unchecked")
+ List <NetworkRecipe> resultList = query.list ();
+
+ if (resultList.isEmpty ()) {
+ return null;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ return resultList.get (0);
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null);
+ }
+ }
+
+ /**
+ * Return a 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;
+ }
+ Collections.sort (resultList, 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 vfModuleId
+ * @param vnfComponentType
+ * @param action
+ * @return VnfComponentsRecipe object or null if none found
+ */
+ public VnfComponentsRecipe getVnfComponentsRecipeByVfModuleId (String vfModuleId,
+ String vnfComponentType,
+ String action) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get Vnf Component recipe with vfModuleId " + vfModuleId
+ + " and component type "
+ + vnfComponentType
+ + " and action "
+ + action);
+
+ try {
+ String hql;
+ hql = "FROM VnfComponentsRecipe WHERE vfModuleId = :vfModuleId AND vnfComponentType = :vnfComponentType AND action = :action ";
+
+ Query query = getSession ().createQuery (hql);
+ query.setParameter (VF_MODULE_ID, vfModuleId);
+ query.setParameter (VNF_COMPONENT_TYPE, vnfComponentType);
+ query.setParameter (ACTION, action);
+
+ @SuppressWarnings("unchecked")
+ List <VnfComponentsRecipe> resultList = query.list ();
+
+ if (resultList.isEmpty ()) {
+ return null;
+ }
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ return resultList.get (0);
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfComponentsRecipeByVfModuleId", null);
+ }
+ }
+
+
+
+ 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 {
+
+ if (vnfComponentDb != null) {
+ this.getSession ().merge (vnfComponent);
+ } else {
+ 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;
+ }
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ return resultList.get (0);
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVfModule", 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.createSQLQuery (" show tables ");
+
+ List<?> list = query.list();
+ LOGGER.debug("healthCheck CatalogDB - Successful");
+ return true;
+ }
+}
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
new file mode 100644
index 0000000000..69db27e989
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatEnvironment.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+public class HeatEnvironment extends MavenLikeVersioning {
+ private int id;
+ private String name = null;
+ private String description = null;
+ private String environment = null;
+
+ private String asdcUuid;
+ private String asdcResourceName;
+ private String asdcLabel;
+
+ private Timestamp created;
+
+ public HeatEnvironment() {}
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+
+ /**
+ * @return the name
+ */
+ public String getName () {
+ return name;
+ }
+
+
+ /**
+ * @param name the name to set
+ */
+ 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 getAsdcUuid() {
+ return asdcUuid;
+ }
+
+ public void setAsdcUuid(String asdcUuid) {
+ this.asdcUuid = asdcUuid;
+ }
+ public String getAsdcLabel() {
+ return this.asdcLabel;
+ }
+ public void setAsdcLabel(String asdcLabel) {
+ this.asdcLabel = asdcLabel;
+ }
+
+
+ /**
+ * @return the asdcResourceName
+ */
+ public String getAsdcResourceName () {
+ return asdcResourceName;
+ }
+
+
+ /**
+ * @param asdcResourceName the asdcResourceName to set
+ */
+ public void setAsdcResourceName (String asdcResourceName) {
+ this.asdcResourceName = asdcResourceName;
+ }
+
+ public Timestamp getCreated() {
+ return created;
+ }
+
+ public void setCreated(Timestamp created) {
+ this.created = created;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer sb = new StringBuffer();
+ sb.append ("ID=" + this.id);
+ sb.append (", name=");
+ sb.append (name);
+ sb.append (", version=");
+ sb.append (version);
+ sb.append(", description=");
+ sb.append (description == null ? "null" : description);
+ sb.append(", environment=");
+ sb.append (environment == null ? "null" : environment);
+ sb.append(", asdcUuid=");
+ sb.append (asdcUuid == null ? "null" : asdcUuid);
+ sb.append (", asdcResourceName=");
+ sb.append (asdcResourceName == null ? "null" : asdcResourceName);
+ 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/HeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java
new file mode 100644
index 0000000000..a1b6f228e1
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatFiles.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+public class HeatFiles extends MavenLikeVersioning {
+ private int id;
+ private String description = null;
+ private String fileName;
+ private String fileBody;
+ private int vnfResourceId;
+ private Timestamp created;
+ private String asdcUuid;
+ private String asdcLabel;
+ private String asdcResourceName;
+
+ public HeatFiles() {}
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ 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 int getVnfResourceId() {
+ return this.vnfResourceId;
+ }
+ public void setVnfResourceId(int vnfResourceId) {
+ this.vnfResourceId = vnfResourceId;
+ }
+
+ public Timestamp getCreated() {
+ return created;
+ }
+
+ public void setCreated(Timestamp created) {
+ this.created = created;
+ }
+
+ public String getAsdcUuid() {
+ return this.asdcUuid;
+ }
+ public void setAsdcUuid(String asdcUuid) {
+ this.asdcUuid = asdcUuid;
+ }
+ public String getAsdcLabel() {
+ return this.asdcLabel;
+ }
+ public void setAsdcLabel(String asdcLabel) {
+ this.asdcLabel = asdcLabel;
+ }
+ public String getAsdcResourceName() {
+ return asdcResourceName;
+ }
+
+ public void setAsdcResourceName(String asdcResourceName) {
+ this.asdcResourceName = asdcResourceName;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer sb = new StringBuffer();
+ sb.append ("ID=" + this.id);
+ if (this.description == null) {
+ sb.append(", description=null");
+ } else {
+ sb.append(", description=" + this.description);
+ }
+ if (this.fileName == null) {
+ sb.append(", fileName=null");
+ } else {
+ sb.append(",fileName=" + this.fileName);
+ }
+ if (this.fileBody == null) {
+ sb.append(", fileBody=null");
+ } else {
+ sb.append(",fileBody=" + this.fileBody);
+ }
+ if (this.asdcResourceName == null) {
+ sb.append(", asdcResourceName=null");
+ } else {
+ sb.append(",asdcResourceName=" + this.asdcResourceName);
+ }
+ if (created != null) {
+ sb.append (",created=");
+ sb.append (DateFormat.getInstance().format(created));
+ }
+ sb.append(", vnfResourceId=" + this.vnfResourceId);
+ 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
new file mode 100644
index 0000000000..eabbacf547
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatNestedTemplate.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 HeatNestedTemplate implements Serializable {
+
+ private int parentTemplateId;
+ private int childTemplateId;
+ private String providerResourceFile;
+ public static final long serialVersionUID = -1322322139926390329L;
+
+ public HeatNestedTemplate () {
+ super ();
+ }
+
+ public void setParentTemplateId (int parentTemplateId) {
+ this.parentTemplateId = parentTemplateId;
+ }
+
+ public int getParentTemplateId () {
+ return this.parentTemplateId;
+ }
+
+ public void setChildTemplateId (int childTemplateId) {
+ this.childTemplateId = childTemplateId;
+ }
+
+ public int 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=" + this.parentTemplateId);
+ sb.append (", ChildTemplateId=" + this.childTemplateId);
+ if (this.providerResourceFile == null) {
+ sb.append (", providerResourceFile=null");
+ } else {
+ sb.append (",providerResourceFile=" + 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 = 0;
+ result = this.parentTemplateId + this.childTemplateId;
+ 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
new file mode 100644
index 0000000000..a80fa598b9
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplate.java
@@ -0,0 +1,217 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.BufferedReader;
+import java.io.FileReader;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Set;
+
+import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+import org.openecomp.mso.logger.MsoLogger;
+
+public class HeatTemplate extends MavenLikeVersioning {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
+
+ private int id;
+ private String templateName;
+ private String templatePath = null;
+ private String templateBody = null;
+ private int timeoutMinutes;
+ private Set <HeatTemplateParam> parameters;
+ private Set <HeatNestedTemplate> files;
+ private String description;
+ private String asdcUuid;
+ private String asdcResourceName;
+ private String asdcLabel;
+
+ private Timestamp created;
+
+ public enum TemplateStatus {
+ PARENT, CHILD, PARENT_COMPLETE
+ }
+
+ public HeatTemplate () {
+ }
+
+ public int getId () {
+ return id;
+ }
+
+ public void setId (int id) {
+ this.id = id;
+ }
+
+ public String getTemplateName () {
+ return templateName;
+ }
+
+ public void setTemplateName (String templateName) {
+ this.templateName = templateName;
+ }
+
+ public String getTemplatePath () {
+ return templatePath;
+ }
+
+ public void setTemplatePath (String templatePath) {
+ this.templatePath = templatePath;
+ }
+
+ 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 () {
+ if (templateBody != null && !templateBody.isEmpty ()) {
+ // The template body is in the DB table. Just return it.
+ return templateBody;
+ }
+
+ String body = null;
+
+ try (BufferedReader reader = new BufferedReader (new FileReader (templatePath)))
+ {
+ String line = null;
+ StringBuilder stringBuilder = new StringBuilder ();
+ while ((line = reader.readLine ()) != null) {
+ stringBuilder.append (line);
+ }
+ body = stringBuilder.toString ();
+ } catch (Exception e) {
+ LOGGER.debug ("Error reading template file " + templatePath, e);
+ }
+
+ return body;
+ }
+
+ 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 getAsdcResourceName() {
+ return asdcResourceName;
+ }
+
+ public void setAsdcResourceName(String asdcResourceName) {
+ this.asdcResourceName = asdcResourceName;
+ }
+ public String getAsdcLabel() {
+ return this.asdcLabel;
+ }
+ public void setAsdcLabel(String asdcLabel) {
+ this.asdcLabel = asdcLabel;
+ }
+
+ 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 (",path=")
+ .append (templatePath)
+ .append (",body=")
+ .append (body)
+ .append (",timeout=")
+ .append (timeoutMinutes)
+ .append (",asdcUuid=")
+ .append (asdcUuid)
+ .append (",asdcResourceName=")
+ .append (asdcResourceName)
+ .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/HeatTemplateParam.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java
new file mode 100644
index 0000000000..0d77a0a4f8
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/HeatTemplateParam.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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;
+
+
+public class HeatTemplateParam {
+ private int id;
+ private int heatTemplateId;
+ private String paramName;
+ private boolean required;
+ private String paramType;
+ private String paramAlias;
+
+ public HeatTemplateParam() {}
+
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+ public int getHeatTemplateId() {
+ return heatTemplateId;
+ }
+ public void setHeatTemplateId(int heatTemplateId) {
+ this.heatTemplateId = heatTemplateId;
+ }
+ 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;
+ }
+}
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
new file mode 100644
index 0000000000..1cd3526946
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkRecipe.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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;
+
+
+public class NetworkRecipe extends Recipe {
+ private String networkType;
+ private String networkParamXSD;
+ public NetworkRecipe() {}
+
+ public String getNetworkType() {
+ return networkType;
+ }
+ public void setNetworkType(String networkType) {
+ this.networkType = networkType;
+ }
+
+ public String getNetworkParamXSD() {
+ return networkParamXSD;
+ }
+ public void setNetworkParamXSD(String networkParamXSD) {
+ this.networkParamXSD = networkParamXSD;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer sb = new StringBuffer();
+ sb.append(super.toString());
+ sb.append (",networkType=" + networkType);
+ sb.append (",networkParamXSD=" + networkParamXSD);
+ return sb.toString();
+ }
+}
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
new file mode 100644
index 0000000000..be812fa346
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/NetworkResource.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+
+public class NetworkResource extends MavenLikeVersioning {
+ private int id;
+ private String networkType;
+ private String orchestrationMode = null;
+ private String description = null;
+ private int templateId;
+ private String neutronNetworkType = null;
+ private String aicVersionMin = null;
+ private String aicVersionMax = null;
+
+ private Timestamp created;
+
+ public NetworkResource() {}
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getNetworkType() {
+ return networkType;
+ }
+ public void setNetworkType(String networkType) {
+ this.networkType = networkType;
+ }
+
+ 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 int getTemplateId () {
+ return templateId;
+ }
+
+ public void setTemplateId (int templateId) {
+ this.templateId = templateId;
+ }
+
+ 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;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer sb = new StringBuffer();
+ sb.append("NETWORK=");
+ sb.append(networkType);
+ sb.append(",version=");
+ sb.append(version);
+ sb.append(",mode=");
+ sb.append(orchestrationMode);
+ sb.append(",template=");
+ sb.append(templateId);
+ sb.append(",neutronType=");
+ sb.append(neutronNetworkType);
+ sb.append(",aicVersionMin=");
+ sb.append(aicVersionMin);
+ sb.append(",aicVersionMax=");
+ sb.append(aicVersionMax);
+
+ sb.append("id=");
+ sb.append(id);
+
+ 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/Recipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java
new file mode 100644
index 0000000000..b0a34e6c60
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Recipe.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+public class Recipe extends MavenLikeVersioning {
+
+ private int id;
+ protected String action;
+ private String description;
+ protected String orchestrationUri;
+ private int recipeTimeout;
+ private String serviceType;
+
+ private Timestamp created;
+
+ 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;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("RECIPE: " + action);
+ sb.append(",uri=" + 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
new file mode 100644
index 0000000000..07fb35596e
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/Service.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.util.Map;
+
+public class Service extends MavenLikeVersioning {
+ private int id;
+ private String serviceName;
+ private String description;
+ private String httpMethod;
+ private String serviceNameVersionId;
+ private String serviceVersion;
+ private Map<String,ServiceRecipe> recipes;
+
+ private String modelInvariantUUID;
+ private Timestamp created;
+
+ public Service() {}
+
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ 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 getHttpMethod() {
+ return httpMethod;
+ }
+
+ public void setHttpMethod(String httpMethod) {
+ this.httpMethod = httpMethod;
+ }
+
+ public String getServiceNameVersionId() {
+ return serviceNameVersionId;
+ }
+
+ public void setServiceNameVersionId(String serviceNameVersionId) {
+ this.serviceNameVersionId = serviceNameVersionId;
+ }
+
+ public String getServiceVersion() {
+ return serviceVersion;
+ }
+
+ public void setServiceVersion(String serviceVersion) {
+ this.serviceVersion = serviceVersion;
+ }
+
+ public String getModelInvariantUUID() {
+ return modelInvariantUUID;
+ }
+
+ public void setModelInvariantUUID(String modelInvariantUUID) {
+ this.modelInvariantUUID = modelInvariantUUID;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("SERVICE: id=" + id + ",name=" + serviceName + ",version=" + version + ",description=" + description+",modelInvariantUUID="+modelInvariantUUID);
+ for (String recipeAction : recipes.keySet()) {
+ ServiceRecipe recipe = recipes.get(recipeAction);
+ sb.append ("\n" + recipe.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/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java
new file mode 100644
index 0000000000..53ec3ba278
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/ServiceRecipe.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+public class ServiceRecipe extends MavenLikeVersioning {
+ private int id;
+ private int serviceId;
+ private String action;
+ private String description;
+ private String orchestrationUri;
+ private String serviceParamXSD;
+ private int recipeTimeout;
+ private Integer serviceTimeoutInterim;
+
+ private Timestamp created;
+
+
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getServiceId() {
+ return serviceId;
+ }
+ public void setServiceId(int serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ 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: " + action);
+ sb.append(",uri=" + 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/VfModule.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java
new file mode 100644
index 0000000000..505b3bba9a
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModule.java
@@ -0,0 +1,195 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+public class VfModule extends MavenLikeVersioning {
+
+ private int id;
+ private Integer vnfResourceId;
+ private String type;
+ private String modelName;
+ private int isBase;
+ private Integer templateId;
+ private Integer environmentId;
+ private Integer volTemplateId;
+ private Integer volEnvironmentId;
+ private String description;
+ private String asdcUuid;
+ private Timestamp created;
+ private String modelInvariantUuid;
+ private String modelVersion;
+
+ public VfModule() {
+ super();
+ }
+
+ public int getId(){
+ return this.id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Integer getVnfResourceId() {
+ return this.vnfResourceId;
+ }
+ public void setVnfResourceId(Integer vnfResourceId) {
+ this.vnfResourceId = vnfResourceId;
+ }
+
+ public String getModelName() {
+ return this.modelName;
+ }
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ 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 Integer getTemplateId() {
+ return this.templateId;
+ }
+ public void setTemplateId(Integer templateId) {
+ this.templateId = templateId;
+ }
+
+ public Integer getEnvironmentId() {
+ return this.environmentId;
+ }
+ public void setEnvironmentId(Integer environmentId) {
+ this.environmentId = environmentId;
+ }
+
+ public Integer getVolTemplateId() {
+ return this.volTemplateId;
+ }
+ public void setVolTemplateId(Integer volTemplateId) {
+ this.volTemplateId = volTemplateId;
+ }
+
+ public Integer getVolEnvironmentId() {
+ return this.volEnvironmentId;
+ }
+ public void setVolEnvironmentId(Integer volEnvironmentId) {
+ this.volEnvironmentId = volEnvironmentId;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getAsdcUuid() {
+ return asdcUuid;
+ }
+
+ public void setAsdcUuid(String asdcUuidp) {
+ this.asdcUuid = asdcUuidp;
+ }
+
+ 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 getModelVersion() {
+ return this.modelVersion;
+ }
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append("VF=");
+ buf.append(this.type);
+ buf.append(",modelName=");
+ buf.append(modelName);
+ buf.append(",version=");
+ buf.append(version);
+ buf.append(",id=");
+ buf.append(this.id);
+ buf.append(",vnfResourceId=");
+ buf.append(this.vnfResourceId);
+ buf.append(",templateId=");
+ buf.append(this.templateId);
+ buf.append(",envtId=");
+ buf.append(this.environmentId);
+ buf.append(",volTemplateId=");
+ buf.append(this.volTemplateId);
+ buf.append(",volEnvtId=");
+ buf.append(this.volEnvironmentId);
+ buf.append(", description=");
+ buf.append(this.description);
+ buf.append(",asdcUuid=");
+ buf.append(asdcUuid);
+ buf.append(",modelVersion=");
+ buf.append(this.modelVersion);
+
+ 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/VfModuleToHeatFiles.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java
new file mode 100644
index 0000000000..b0b00759f0
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VfModuleToHeatFiles.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 int vfModuleId;
+ private int heatFilesId;
+ public static final long serialVersionUID = -1322322139926390329L;
+
+ public VfModuleToHeatFiles() {
+ super();
+ }
+
+ public int getVfModuleId() {
+ return this.vfModuleId;
+ }
+ public void setVfModuleId(int vfModuleId) {
+ this.vfModuleId = vfModuleId;
+ }
+
+ public int getHeatFilesId() {
+ return this.heatFilesId;
+ }
+ public void setHeatFilesId(int heatFilesId) {
+ this.heatFilesId = heatFilesId;
+ }
+
+ @Override
+ public String toString () {
+ StringBuilder sb = new StringBuilder ();
+ sb.append ("VF_MODULE_ID=" + this.vfModuleId);
+ sb.append (", HEAT_FILES_ID=" + this.heatFilesId);
+ return sb.toString ();
+ }
+
+ @Override
+ public boolean equals (Object o) {
+ if (!(o instanceof VfModuleToHeatFiles)) {
+ return false;
+ }
+ if (this == o) {
+ return true;
+ }
+ VfModuleToHeatFiles vmthf = (VfModuleToHeatFiles) o;
+ if (vmthf.getVfModuleId() == this.getVfModuleId() && vmthf.getVfModuleId() == this.getVfModuleId()) {
+ 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.vfModuleId + this.heatFilesId;
+ return result;
+ }
+
+}
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
new file mode 100644
index 0000000000..5a05b957f0
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponent.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 java.io.Serializable;
+
+public class VnfComponent implements Serializable {
+ private int vnfId;
+ private String componentType = null;
+ private Integer heatTemplateId;
+ private Integer heatEnvironmentId;
+ public static final long serialVersionUID = -1322322139926390329L;
+
+ private Timestamp created;
+
+ 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=" + vnfId);
+ sb.append(",componentType=" + componentType);
+ sb.append(",heatTemplateId=" + heatTemplateId);
+ sb.append(",heatEnvironmentId=" + 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).toString().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
new file mode 100644
index 0000000000..547b2fc70a
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfComponentsRecipe.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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;
+
+
+public class VnfComponentsRecipe extends Recipe {
+
+ private String vnfType;
+ private String vnfComponentParamXSD;
+ private String vnfComponentType;
+ private String vfModuleId;
+
+ public VnfComponentsRecipe() {}
+
+ public String getVnfType() {
+ return vnfType;
+ }
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ public String getVnfComponentParamXSD() {
+ return vnfComponentParamXSD;
+ }
+ public void setVnfComponentParamXSD(String vnfComponentParamXSD) {
+ this.vnfComponentParamXSD = vnfComponentParamXSD;
+ }
+
+ public String getVnfComponentType() {
+ return vnfComponentType;
+ }
+ public void setVnfComponentType(String vnfComponentType) {
+ this.vnfComponentType = vnfComponentType;
+ }
+
+ public String getVfModuleId() {
+ return vfModuleId;
+ }
+
+ public void setVfModuleId(String vfModuleId) {
+ this.vfModuleId = vfModuleId;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer sb = new StringBuffer();
+ sb.append(super.toString());
+ sb.append (",vnfComponentParamXSD=" + vnfComponentParamXSD);
+ sb.append (",serviceType=" + getServiceType ());
+ sb.append (",vnfComponentType=" + getVnfComponentType ());
+ sb.append (",vfModuleId=" + getVfModuleId ());
+ return sb.toString();
+ }
+}
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
new file mode 100644
index 0000000000..1f0cd0ab1d
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfRecipe.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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;
+
+
+public class VnfRecipe extends Recipe {
+
+ private String vnfType;
+ private String vnfParamXSD;
+ private String vfModuleId;
+
+ public VnfRecipe() {}
+
+ public String getVnfType() {
+ return vnfType;
+ }
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ public String getVnfParamXSD() {
+ return vnfParamXSD;
+ }
+ public void setVnfParamXSD(String vnfParamXSD) {
+ this.vnfParamXSD = vnfParamXSD;
+ }
+
+ public String getVfModuleId() {
+ return vfModuleId;
+ }
+
+ public void setVfModuleId(String vfModuleId) {
+ this.vfModuleId = vfModuleId;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer sb = new StringBuffer();
+ sb.append(super.toString());
+ sb.append (",vnfParamXSD=" + vnfParamXSD);
+ sb.append (",serviceType=" + getServiceType ());
+ sb.append (",vfModuleId=" + getVfModuleId ());
+ return sb.toString();
+ }
+}
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
new file mode 100644
index 0000000000..60c7ef216e
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/beans/VnfResource.java
@@ -0,0 +1,225 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 java.util.Map;
+
+import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+
+public class VnfResource extends MavenLikeVersioning {
+
+ private int id;
+ private String vnfType;
+
+ private String orchestrationMode = null;
+ private String description = null;
+ private Integer templateId;
+ private Integer environmentId = null;
+
+ private Map <String, HeatFiles> heatFiles;
+
+ private String asdcUuid;
+
+ private Timestamp created;
+
+ private String aicVersionMin = null;
+ private String aicVersionMax = null;
+
+ private String modelInvariantUuid = null;
+ private String modelVersion = null;
+
+ private String modelCustomizationName = null;
+
+ private String modelName = null;
+ private String serviceModelInvariantUUID = null;
+
+ public VnfResource () {
+ }
+
+ public int getId () {
+ return id;
+ }
+
+ public void setId (int id) {
+ this.id = id;
+ }
+
+ public String getVnfType () {
+ return vnfType;
+ }
+
+ public void setVnfType (String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ 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 Integer getTemplateId () {
+ return templateId;
+ }
+
+ public void setTemplateId (Integer templateId) {
+ this.templateId = templateId;
+ }
+
+ public Integer getEnvironmentId () {
+ return this.environmentId;
+ }
+
+ public void setEnvironmentId (Integer environmentId) {
+ this.environmentId = environmentId;
+ }
+
+ public Map <String, HeatFiles> getHeatFiles () {
+ return this.heatFiles;
+ }
+
+ public void setHeatFiles (Map <String, HeatFiles> heatFiles) {
+ this.heatFiles = heatFiles;
+ }
+
+ public String getAsdcUuid() {
+ return asdcUuid;
+ }
+
+ public void setAsdcUuid(String asdcUuidp) {
+ this.asdcUuid = asdcUuidp;
+ }
+
+ 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;
+ }
+
+ 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 getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getServiceModelInvariantUUID() {
+ return serviceModelInvariantUUID;
+ }
+
+ public void setServiceModelInvariantUUID(String serviceModelInvariantUUID) {
+ this.serviceModelInvariantUUID = serviceModelInvariantUUID;
+ }
+
+ @Override
+ public String toString () {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append("VNF=");
+ buf.append(vnfType);
+ buf.append(",version=");
+ buf.append(version);
+ buf.append(",mode=");
+ buf.append(orchestrationMode);
+ buf.append(",template=");
+ buf.append(templateId);
+ buf.append(",envtId=");
+ buf.append(environmentId);
+ buf.append(",asdcUuid=");
+ buf.append(asdcUuid);
+ buf.append(",aicVersionMin=");
+ buf.append(this.aicVersionMin);
+ buf.append(",aicVersionMax=");
+ buf.append(this.aicVersionMax);
+ buf.append(",modelInvariantUuid=");
+ buf.append(this.modelInvariantUuid);
+ buf.append(",modelVersion=");
+ buf.append(this.modelVersion);
+ buf.append(",modelCustomizationName=");
+ buf.append(this.modelCustomizationName);
+ buf.append(",modelName=");
+ buf.append(this.modelName);
+ buf.append(",serviceModelInvariantUUID=");
+ buf.append(this.serviceModelInvariantUUID);
+
+ if (created != null) {
+ buf.append(",created=");
+ buf.append(DateFormat.getInstance().format(created));
+ }
+ return buf.toString();
+ }
+
+}
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
new file mode 100644
index 0000000000..c617a4a6f4
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioning.java
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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;
+
+
+
+/**
+ * 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 {
+
+ 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 || this.version == null) {
+ return Boolean.FALSE;
+ }
+ String [] currentVersionArray = this.version.split("\\.");
+ String [] specifiedVersionArray = versionToCompare.split("\\.");
+
+ int smalestStringLength = 0;
+
+ if (currentVersionArray.length > specifiedVersionArray.length) {
+ smalestStringLength = specifiedVersionArray.length;
+ } else {
+ smalestStringLength = currentVersionArray.length;
+ }
+
+ for (int currentVersionIndex=0;currentVersionIndex < smalestStringLength;++currentVersionIndex) {
+
+ if (Integer.valueOf(currentVersionArray[currentVersionIndex]) < Integer.valueOf(specifiedVersionArray[currentVersionIndex])) {
+ return Boolean.FALSE;
+ } else if (Integer.valueOf(currentVersionArray[currentVersionIndex]) > Integer.valueOf(specifiedVersionArray[currentVersionIndex])) {
+ return Boolean.TRUE;
+ }
+ }
+
+ // Even if versionToCompare has more digits, it means versionToCompare is more recent
+ if (Integer.valueOf(currentVersionArray[smalestStringLength-1]).intValue () == Integer.valueOf(specifiedVersionArray[smalestStringLength-1]).intValue ()) {
+ if (currentVersionArray.length > specifiedVersionArray.length) {
+ return Boolean.TRUE;
+ } else {
+ return Boolean.FALSE;
+ }
+ }
+
+ return Boolean.TRUE;
+ }
+
+ /**
+ * 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 Boolean.TRUE;
+ } else if (versionToCompare == null || this.version == null) {
+ return Boolean.FALSE;
+ }
+ String [] currentVersionArray = this.version.split("\\.");
+ String [] specifiedVersionArray = versionToCompare.split("\\.");
+
+ if (currentVersionArray.length != specifiedVersionArray.length) {
+ return Boolean.FALSE;
+ }
+
+ for (int currentVersionIndex=0;currentVersionIndex < currentVersionArray.length;++currentVersionIndex) {
+
+ if (Integer.valueOf(currentVersionArray[currentVersionIndex]).intValue () != Integer.valueOf(specifiedVersionArray[currentVersionIndex]).intValue ()) {
+ return Boolean.FALSE;
+ }
+ }
+
+ return Boolean.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
new file mode 100644
index 0000000000..e80c03cc27
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/MavenLikeVersioningComparator.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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/package-info.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/package-info.java
new file mode 100644
index 0000000000..3644529fd3
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/utils/package-info.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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;
+
diff --git a/mso-catalog-db/src/main/resources/HeatEnvironment.hbm.xml b/mso-catalog-db/src/main/resources/HeatEnvironment.hbm.xml
new file mode 100644
index 0000000000..992e5d467a
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/HeatEnvironment.hbm.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Generated Aug 6, 2015 1:11:38 PM by Hibernate Tools 3.4.0.CR1 -->
+<hibernate-mapping>
+ <class name="org.openecomp.mso.db.catalog.beans.HeatEnvironment" table="HEAT_ENVIRONMENT">
+ <meta attribute="class-description">
+ This class describes a HEAT Environment
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+ <properties name="uk_heatenv" unique="true">
+ <property name="name" type="string" >
+ <column name="NAME" length="100" not-null="true"/>
+ </property>
+ <property name="version" type="string" >
+ <column name="VERSION" length="20" not-null="true"/>
+ </property>
+ <property name="asdcResourceName" type="string" >
+ <column name="ASDC_RESOURCE_NAME" length="100" default="'MANUAL RECORD'" not-null="true"/>
+ </property>
+ </properties>
+ <property name="description" column="DESCRIPTION" type="string" length="1200"/>
+ <property name="environment" type="text">
+ <column name="ENVIRONMENT" not-null="true"/>
+ </property>
+ <property name="created" type="timestamp" generated="insert" insert="false" update="false">
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+ <property name="asdcUuid" type="string">
+ <column name="ASDC_UUID" length="200" default="'MANUAL RECORD'" not-null="false"/>
+ </property>
+ <property name="asdcLabel" column="ASDC_LABEL" type="string" length="200"/>
+
+ </class>
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/HeatNestedTemplate.hbm.xml b/mso-catalog-db/src/main/resources/HeatNestedTemplate.hbm.xml
new file mode 100644
index 0000000000..90ae8ab2ea
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/HeatNestedTemplate.hbm.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="HeatNestedTemplate" table="HEAT_NESTED_TEMPLATE">
+ <meta attribute="class-description">
+ This class describes a nested HEAT template relationship
+ </meta>
+
+ <composite-id>
+ <key-property name="parentTemplateId" column="PARENT_TEMPLATE_ID" type="int" />
+ <key-property name="childTemplateId" column="CHILD_TEMPLATE_ID" type="int" />
+ </composite-id>
+
+ <property name="providerResourceFile" column="PROVIDER_RESOURCE_FILE" type="string" length="100"/>
+
+ </class>
+
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/HeatTemplate.hbm.xml b/mso-catalog-db/src/main/resources/HeatTemplate.hbm.xml
new file mode 100644
index 0000000000..9bc6fb1414
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/HeatTemplate.hbm.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="HeatTemplate" table="HEAT_TEMPLATE">
+ <meta attribute="class-description">
+ This class describes a HEAT template
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+
+ <properties name="uk_template" unique="true">
+ <property name="templateName" type="string" >
+ <column name="TEMPLATE_NAME" length="200" not-null="true"/>
+ </property>
+ <property name="version" type="string" >
+ <column name="VERSION" length="20" not-null="true"/>
+ </property>
+ <property name="asdcResourceName" type="string" >
+ <column name="ASDC_RESOURCE_NAME" default="'MANUAL RECORD'" length="100" not-null="true"/>
+ </property>
+ </properties>
+
+ <property name="templatePath" column="TEMPLATE_PATH" type="string" length="100"/>
+ <property name="templateBody" type="text">
+ <column name="TEMPLATE_BODY" not-null="true"/>
+ </property>
+ <property name="timeoutMinutes" column="TIMEOUT_MINUTES" type="int"/>
+ <property name="asdcUuid" type="string" >
+ <column name="ASDC_UUID" length="200" default="'MANUAL RECORD'" not-null="true"/>
+ </property>
+ <property name="description" column="DESCRIPTION" type="string" length="1200"/>
+ <property name="asdcLabel" column="ASDC_LABEL" type="string" length="200"/>
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false" >
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+ <set name="parameters" cascade="all">
+ <key column="HEAT_TEMPLATE_ID"/>
+ <one-to-many class="HeatTemplateParam"/>
+ </set>
+ <set name="files" table="HEAT_NESTED_TEMPLATE" cascade="all">
+ <key column="CHILD_TEMPLATE_ID"/>
+ <one-to-many class="HeatTemplate" not-found="ignore"/>
+ </set>
+
+ </class>
+
+ <class name="HeatTemplateParam" table="HEAT_TEMPLATE_PARAMS">
+ <meta attribute="class-description">
+ This class describes an input parameter to a heat template
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+
+ <properties name="uk_heat_params" unique="true">
+ <property name="heatTemplateId" type="int">
+ <column name="HEAT_TEMPLATE_ID" not-null="true"/>
+ </property>
+ <property name="paramName" type="string" >
+ <column name="PARAM_NAME" length="100" not-null="true"/>
+ </property>
+ </properties>
+ <property name="required" type="boolean">
+ <column name="IS_REQUIRED" not-null="true"/>
+ </property>
+ <property name="paramType" column="PARAM_TYPE" type="string" length="20"/>
+ <property name="paramAlias" column="PARAM_ALIAS" type="string" length="45"/>
+ </class>
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml b/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml
new file mode 100644
index 0000000000..bdd16d37e6
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/NetworkRecipe.hbm.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="NetworkRecipe" table="NETWORK_RECIPE">
+ <meta attribute="class-description">
+ This class describes a Network recipe
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+
+ <properties name="uk_network_recipe" unique="true">
+ <property name="networkType" type="string" >
+ <column name="NETWORK_TYPE" not-null="true" length="20"/>
+ </property>
+ <property name="action" type="string" >
+ <column name="ACTION" not-null="true" length="20"/>
+ </property>
+ <property name="version" type="string">
+ <column name="VERSION_STR" not-null="true" length="20"/>
+ </property>
+
+ </properties>
+
+ <property name="serviceType" type="string" length="45">
+ <column name="SERVICE_TYPE" not-null="false" length="45"/>
+ </property>
+ <property name="description" column="DESCRIPTION" type="string" length="1200"/>
+ <property name="orchestrationUri" type="string">
+ <column name="ORCHESTRATION_URI" not-null="true" length="256"/>
+ </property>
+ <property name="networkParamXSD" column="NETWORK_PARAM_XSD" type="string" length="2048"/>
+ <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/>
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false" >
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+ </class>
+
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/NetworkResource.hbm.xml b/mso-catalog-db/src/main/resources/NetworkResource.hbm.xml
new file mode 100644
index 0000000000..b3b657aa9f
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/NetworkResource.hbm.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="NetworkResource" table="NETWORK_RESOURCE">
+ <meta attribute="class-description">
+ This class describes a Network Resource
+ </meta>
+
+ <id name="id" type="int" column="id"/>
+
+ <properties name="uk_network_resource" unique="true">
+ <property name="networkType" type="string" >
+ <column name="NETWORK_TYPE" not-null="true" length="45"/>
+ </property>
+ <property name="version" type="string" >
+ <column name="VERSION_STR" not-null="true" length="20"/>
+ </property>
+ </properties>
+ <property name="orchestrationMode" column="ORCHESTRATION_MODE" type="string" length="20"/>
+ <property name="description" column="DESCRIPTION" type="string" length="1200"/>
+ <property name="templateId" column="TEMPLATE_ID" type="int"/>
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false" >
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+ <property name="aicVersionMin" type="string" >
+ <column name="AIC_VERSION_MIN" not-null="false" default="2.5" length="20" />
+ </property>
+ <property name="aicVersionMax" type="string">
+ <column name="AIC_VERSION_MAX" not-null="false" default="2.5" length="20"/>
+ </property>
+ <property name="neutronNetworkType" column="NEUTRON_NETWORK_TYPE" type="string" length="20"/>
+ </class>
+
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/Service.hbm.xml b/mso-catalog-db/src/main/resources/Service.hbm.xml
new file mode 100644
index 0000000000..4e43413f47
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/Service.hbm.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="Service" table="SERVICE">
+ <meta attribute="class-description">
+ This class describes a Service that may be orchestrated
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+
+ <property name="serviceName" column="SERVICE_NAME" type="string" length="40"/>
+ <property name="version" column="VERSION_STR" type="string" length="20"/>
+ <property name="description" column="DESCRIPTION" type="string" length="1200"/>
+ <property name="serviceNameVersionId" column="SERVICE_NAME_VERSION_ID" type="string" length="50"/>
+
+ <property name="serviceVersion" column="SERVICE_VERSION" type="string" length="10"/>
+ <property name="httpMethod" column="HTTP_METHOD" type="string" length="50"/>
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false" >
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+ <property name="modelInvariantUUID" type="string">
+ <column name="MODEL_INVARIANT_UUID" default="'MANUAL_RECORD'" not-null="true" length="200"/>
+ </property>
+
+ <map name="recipes" cascade="all">
+ <key column="SERVICE_ID"/>
+ <map-key column="action" type="string"/>
+ <one-to-many class="ServiceRecipe"/>
+ </map>
+ </class>
+
+ <class name="ServiceRecipe" table="SERVICE_RECIPE">
+ <meta attribute="class-description">
+ This class describes a Service recipe
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+
+ <properties name="uk1_service_recipe" unique="true">
+ <property name="serviceId" type="int">
+ <column name="SERVICE_ID" not-null="true"/>
+ </property>
+ <property name="action" type="string" >
+ <column name="ACTION" not-null="true" length="40"/>
+ </property>
+ </properties>
+ <property name="version" column="VERSION_STR" type="string" length="20"/>
+ <property name="description" column="DESCRIPTION" type="string" length="1200"/>
+ <property name="orchestrationUri" type="string">
+ <column name="ORCHESTRATION_URI" not-null="true" length="256"/>
+ </property>
+ <property name="serviceParamXSD" column="SERVICE_PARAM_XSD" type="string" length="2048"/>
+ <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/>
+ <property name="serviceTimeoutInterim" column="SERVICE_TIMEOUT_INTERIM" type="java.lang.Integer"/>
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false" >
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+ </class>
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VfModule.hbm.xml b/mso-catalog-db/src/main/resources/VfModule.hbm.xml
new file mode 100644
index 0000000000..1ccc48daf6
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/VfModule.hbm.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Generated Apr 28, 2016 2:44:06 PM by Hibernate Tools 3.4.0.CR1 -->
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="VfModule" table="VF_MODULE">
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+
+ <properties name="uk_vfmodule" unique="true">
+ <property name="type" type="string" >
+ <column name="TYPE" not-null="true" length="200"/>
+ </property>
+ <property name="version" type="string" >
+ <column name="ASDC_SERVICE_MODEL_VERSION" not-null="true" length="20"/>
+ </property>
+ </properties>
+
+ <property name="modelName" type="string" >
+ <column name="MODEL_NAME" not-null="true" length="200"/>
+ </property>
+ <property name="modelVersion" type="string" >
+ <column name="MODEL_VERSION" not-null="true" length="20"/>
+ </property>
+
+ <property name="asdcUuid" type="java.lang.String" >
+ <column name="ASDC_UUID" not-null="false" length="255"/>
+ </property>
+ <property name="volEnvironmentId" type="java.lang.Integer" >
+ <column name="VOL_ENVIRONMENT_ID" not-null="false"/>
+ </property>
+ <property name="templateId" type="java.lang.Integer" >
+ <column name="TEMPLATE_ID" not-null="false"/>
+ </property>
+ <property name="isBase" type="int">
+ <column name="IS_BASE" not-null="true"/>
+ </property>
+
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false" >
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+
+ <property name="description" type="java.lang.String" >
+ <column name="DESCRIPTION" not-null="false" length="255"/>
+ </property>
+ <property name="volTemplateId" type="java.lang.Integer" >
+ <column name="VOL_TEMPLATE_ID" not-null="false"/>
+ </property>
+ <property name="vnfResourceId" type="java.lang.Integer" >
+ <column name="VNF_RESOURCE_ID" not-null="true"/>
+ </property>
+ <property name="environmentId" type="java.lang.Integer" >
+ <column name="ENVIRONMENT_ID" not-null="false"/>
+ </property>
+ <property name="modelInvariantUuid" type="java.lang.String" >
+ <column name="MODEL_INVARIANT_UUID" not-null="false" length="255"/>
+ </property>
+
+ </class>
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VfModuleToHeatFiles.hbm.xml b/mso-catalog-db/src/main/resources/VfModuleToHeatFiles.hbm.xml
new file mode 100644
index 0000000000..9af02d866a
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/VfModuleToHeatFiles.hbm.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="VfModuleToHeatFiles" table="VF_MODULE_TO_HEAT_FILES">
+ <meta attribute="class-description">
+ This class describes a VF Module to HEAT Files Entry
+ </meta>
+
+ <composite-id>
+ <key-property name="vfModuleId" column="VF_MODULE_ID" type="int" />
+ <key-property name="heatFilesId" column="HEAT_FILES_ID" type="int" />
+ </composite-id>
+
+ </class>
+
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VnfComponent.hbm.xml b/mso-catalog-db/src/main/resources/VnfComponent.hbm.xml
new file mode 100644
index 0000000000..3cda770e63
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/VnfComponent.hbm.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="VnfComponent" table="VNF_COMPONENTS">
+ <meta attribute="class-description">
+ VnfComponent describes a table of components for a VNF_RESOURCE
+ </meta>
+
+ <composite-id>
+ <key-property name="vnfId" column="VNF_ID" type="int" />
+ <key-property name="componentType" column="COMPONENT_TYPE" type="string" length="20"/>
+ </composite-id>
+
+ <property name="heatTemplateId" column="HEAT_TEMPLATE_ID" type="int" />
+ <property name="heatEnvironmentId" column="HEAT_ENVIRONMENT_ID" type="int" />
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false" >
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+
+ </class>
+
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml b/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml
new file mode 100644
index 0000000000..e0ef0d2bc2
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/VnfComponentsRecipe.hbm.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="VnfComponentsRecipe" table="VNF_COMPONENTS_RECIPE">
+ <meta attribute="class-description">
+ This class describes a VNF Components Recipe
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+ <properties name="uk_vnf_component_recipe" unique="true">
+ <property name="vnfType" column="VNF_TYPE" type="string" length="200"/>
+ <property name="vfModuleId" column="VF_MODULE_ID" type="string" length="100" not-null="false"/>
+ <property name="vnfComponentType" type="string">
+ <column name="VNF_COMPONENT_TYPE" not-null="true" length="45"/>
+ </property>
+ <property name="action" type="string">
+ <column name="ACTION" not-null="true" length="20"/>
+ </property>
+ <property name="serviceType" column="SERVICE_TYPE" type="string" length="45"/>
+ <property name="version" column="VERSION" type="string" length="20"/>
+ </properties>
+ <property name="description" column="DESCRIPTION" type="string" length="1200"/>
+ <property name="orchestrationUri" type="string">
+ <column name="ORCHESTRATION_URI" not-null="true" length="256"/>
+ </property>
+ <property name="vnfComponentParamXSD" column="VNF_COMPONENT_PARAM_XSD" type="string" length="2048"/>
+ <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/>
+ <property name="created" column="CREATION_TIMESTAMP" type="timestamp" generated="insert" update="false" insert="false" />
+ </class>
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml b/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml
new file mode 100644
index 0000000000..ea2b39e861
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/VnfRecipe.hbm.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="VnfRecipe" table="VNF_RECIPE">
+ <meta attribute="class-description">
+ This class describes a VNF Recipe
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+
+ <properties name="uk_vnf_recipe" unique="true">
+
+ <property name="vfModuleId" type="string">
+ <column name="VF_MODULE_ID" not-null="false" length="100" />
+ </property>
+ <property name="action" type="string">
+ <column name="ACTION" not-null="true" length="20" />
+ </property>
+ <property name="version" type="string">
+ <column name="VERSION_STR" not-null="true" length="20" />
+ </property>
+
+ </properties>
+
+ <property name="vnfType" type="string">
+ <column name="VNF_TYPE" not-null="false" length="200" />
+ </property>
+
+ <property name="serviceType" type="string">
+ <column name="SERVICE_TYPE" not-null="false" length="45" />
+ </property>
+
+ <property name="description" column="DESCRIPTION" type="string" length="1200"/>
+
+ <property name="orchestrationUri" type="string">
+ <column name="ORCHESTRATION_URI" not-null="true" length="256"/>
+ </property>
+
+ <property name="vnfParamXSD" column="VNF_PARAM_XSD" type="string" length="2048"/>
+ <property name="recipeTimeout" column="RECIPE_TIMEOUT" type="int"/>
+ <property name="created" column="CREATION_TIMESTAMP" type="timestamp" generated="insert" update="false" insert="false" />
+ </class>
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/VnfResource.hbm.xml b/mso-catalog-db/src/main/resources/VnfResource.hbm.xml
new file mode 100644
index 0000000000..4c9e3b59e3
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/VnfResource.hbm.xml
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.openecomp.mso.db.catalog.beans">
+ <class name="VnfResource" table="VNF_RESOURCE">
+ <meta attribute="class-description">
+ This class describes a VNF Resource
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+ <properties name="uk1" unique="true">
+ <property name="vnfType" type="string" >
+ <column name="VNF_TYPE" not-null="true" length="200"/>
+ </property>
+ <property name="version" type="string" >
+ <column name="ASDC_SERVICE_MODEL_VERSION" not-null="true" length="20"/>
+ </property>
+ </properties>
+ <property name="orchestrationMode" type="string" >
+ <column name="ORCHESTRATION_MODE" not-null="true" length="20"/>
+ </property>
+ <property name="description" type="string" >
+ <column name="DESCRIPTION" not-null="false" length="1200"/>
+ </property>
+
+ <property name="templateId" type="int" not-null="false">
+ <column name="TEMPLATE_ID" not-null="false"/>
+ </property>
+ <property name="environmentId" type="int">
+ <column name="ENVIRONMENT_ID" not-null="false"/>
+ </property>
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false" >
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+ <property name="asdcUuid" type="string" >
+ <column name="ASDC_UUID" not-null="false" length="200"/>
+ </property>
+ <property name="aicVersionMin" type="string" >
+ <column name="AIC_VERSION_MIN" not-null="false" length="20"/>
+ </property>
+ <property name="aicVersionMax" type="string" >
+ <column name="AIC_VERSION_MAX" not-null="false" length="20"/>
+ </property>
+ <property name="modelInvariantUuid" type="string" >
+ <column name="MODEL_INVARIANT_UUID" not-null="false" length="200"/>
+ </property>
+ <property name="modelVersion" type="string" >
+ <column name="MODEL_VERSION" not-null="true" length="20"/>
+ </property>
+ <property name="modelCustomizationName" type="string" >
+ <column name="MODEL_CUSTOMIZATION_NAME" not-null="false" length="200"/>
+ </property>
+ <property name="modelName" type="string" >
+ <column name="MODEL_NAME" not-null="false" length="200"/>
+ </property>
+ <property name="serviceModelInvariantUUID" type="string" >
+ <column name="SERVICE_MODEL_INVARIANT_UUID" not-null="false" length="200"/>
+ </property>
+
+ <map name="heatFiles" cascade="all">
+ <key column="VNF_RESOURCE_ID" foreign-key="none"/>
+ <map-key column="FILE_NAME" type="string"/>
+ <one-to-many class="HeatFiles"/>
+ </map>
+
+ </class>
+
+ <class name="HeatFiles" table="HEAT_FILES">
+ <meta attribute="class-description">
+ This class describes a HEAT Template File
+ </meta>
+
+ <id name="id" type="int" column="id">
+ <generator class="native"/>
+ </id>
+
+ <properties name="uk_heat_files" unique="true">
+ <property name="fileName" type="string" >
+ <column name="FILE_NAME" not-null="true" length="200"/>
+ </property>
+ <property name="asdcResourceName" type="string" >
+ <column name="ASDC_RESOURCE_NAME" not-null="true" length="100"/>
+ </property>
+ <property name="version" type="string" >
+ <column name="VERSION" not-null="true" length="20"/>
+ </property>
+ </properties>
+
+ <property name="vnfResourceId" type="int">
+ <column name="VNF_RESOURCE_ID" not-null="false"/>
+ </property>
+ <property name="description" type="string" >
+ <column name="DESCRIPTION" not-null="false" length="1200"/>
+ </property>
+ <property name="fileBody" type="text">
+ <column name="FILE_BODY" not-null="true"/>
+ </property>
+ <property name="created" type="timestamp" generated="insert" update="false" insert="false">
+ <column name="CREATION_TIMESTAMP" not-null="true"/>
+ </property>
+
+ <property name="asdcUuid" type="string" >
+ <column name="ASDC_UUID" not-null="false" length="200"/>
+ </property>
+ <property name="asdcLabel" type="string" >
+ <column name="ASDC_LABEL" not-null="false" length="200"/>
+ </property>
+
+
+ </class>
+
+</hibernate-mapping>
diff --git a/mso-catalog-db/src/main/resources/hibernate-catalog-ajsc.cfg.xml b/mso-catalog-db/src/main/resources/hibernate-catalog-ajsc.cfg.xml
new file mode 100644
index 0000000000..7f28a36346
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/hibernate-catalog-ajsc.cfg.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+
+<!DOCTYPE hibernate-configuration SYSTEM "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+ <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
+ <property name="hibernate.show_sql">false</property>
+ <property name="hibernate.format_sql">true</property>
+
+ <mapping resource="VnfResource.hbm.xml"/>
+ <mapping resource="VnfRecipe.hbm.xml"/>
+ <mapping resource="HeatTemplate.hbm.xml"/>
+ <mapping resource="Service.hbm.xml"/>
+ <mapping resource="NetworkResource.hbm.xml"/>
+ <mapping resource="NetworkRecipe.hbm.xml"/>
+ <mapping resource="HeatEnvironment.hbm.xml"/>
+ <mapping resource="HeatNestedTemplate.hbm.xml"/>
+ <mapping resource="VnfComponent.hbm.xml"/>
+ <mapping resource="VnfComponentsRecipe.hbm.xml"/>
+ <mapping resource="VfModule.hbm.xml"/>
+ <mapping resource="VfModuleToHeatFiles.hbm.xml"/>
+ <!-- <property name="connection.url">${CATALOG_CONNECTION_URL}</property>
+ <property name="connection.username">${CATALOG_USERNAME}</property>
+ <property name="connection.password">${CATALOG_PASSWORD}</property>
+ <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
+ <property name="hibernate.default_schema">mso_catalog</property>
+ <property name="connection.driver_class">org.mariadb.jdbc.Driver</property>
+ <property name="hibernate.current_session_context_class">thread</property>
+ <property name="hibernate.show_sql">false</property>
+ <property name="hibernate.format_sql">true</property>
+
+
+ <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
+ <property name="hibernate.c3p0.min_size">${CATALOG_MIN_POOL_SIZE}</property>
+ <property name="hibernate.c3p0.max_size">${CATALOG_MAX_POOL_SIZE}</property>
+ <property name="hibernate.c3p0.timeout">${CATALOG_TIMEOUT}</property>
+ <property name="hibernate.c3p0.max_statements">50</property>
+ <property name="hibernate.c3p0.idle_test_period">1000</property>
+ <property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>
+
+
+ <mapping resource="VnfResource.hbm.xml"/>
+ <mapping resource="VnfRecipe.hbm.xml"/>
+ <mapping resource="HeatTemplate.hbm.xml"/>
+ <mapping resource="CloudSite.hbm.xml"/>
+ <mapping resource="Service.hbm.xml"/>
+ <mapping resource="NetworkResource.hbm.xml"/>
+ <mapping resource="NetworkRecipe.hbm.xml"/>
+ <mapping resource="HeatEnvironment.hbm.xml"/>
+ <mapping resource="HeatNestedTemplate.hbm.xml"/>
+ <mapping resource="VnfComponent.hbm.xml"/>
+ <mapping resource="VnfComponentsRecipe.hbm.xml"/> -->
+ </session-factory>
+</hibernate-configuration>
diff --git a/mso-catalog-db/src/main/resources/hibernate-catalog-mysql.cfg.xml b/mso-catalog-db/src/main/resources/hibernate-catalog-mysql.cfg.xml
new file mode 100644
index 0000000000..306dfc6d0b
--- /dev/null
+++ b/mso-catalog-db/src/main/resources/hibernate-catalog-mysql.cfg.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ECOMP MSO
+ ================================================================================
+ 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=========================================================
+ -->
+
+
+<!DOCTYPE hibernate-configuration SYSTEM "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+ <!-- <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property> -->
+ <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
+ <property name="hibernate.show_sql">false</property>
+ <property name="hibernate.format_sql">true</property>
+ <property name="connection.datasource">java:jboss/datasources/mso-catalog</property>
+ <property name="hibernate.c3p0.min_size">5</property>
+ <property name="hibernate.c3p0.max_size">50</property>
+ <property name="hibernate.c3p0.timeout">1800</property>
+ <property name="hibernate.c3p0.max_statements">50</property>
+
+<!-- <property name="hibernate.hbm2ddl.auto">create</property> -->
+
+ <mapping resource="VnfResource.hbm.xml"/>
+ <mapping resource="VnfRecipe.hbm.xml"/>
+ <mapping resource="HeatTemplate.hbm.xml"/>
+ <mapping resource="Service.hbm.xml"/>
+ <mapping resource="NetworkResource.hbm.xml"/>
+ <mapping resource="NetworkRecipe.hbm.xml"/>
+ <mapping resource="HeatEnvironment.hbm.xml"/>
+ <mapping resource="HeatNestedTemplate.hbm.xml"/>
+ <mapping resource="VnfComponent.hbm.xml"/>
+ <mapping resource="VnfComponentsRecipe.hbm.xml"/>
+ <mapping resource="VfModule.hbm.xml"/>
+ <mapping resource="VfModuleToHeatFiles.hbm.xml"/>
+ </session-factory>
+</hibernate-configuration>